Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3747144
D11362.id38215.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D11362.id38215.diff
View Options
diff --git a/web/grpc/identity-service-client-wrapper.js b/web/grpc/identity-service-client-wrapper.js
--- a/web/grpc/identity-service-client-wrapper.js
+++ b/web/grpc/identity-service-client-wrapper.js
@@ -533,29 +533,60 @@
notifOneTimeKeys,
} = uploadData;
- const contentOneTimeKeysArray = [...contentOneTimeKeys];
- const notifOneTimeKeysArray = [...notifOneTimeKeys];
+ const identityKeyInfo = createIdentityKeyInfo(
+ keyPayload,
+ keyPayloadSignature,
+ );
+
+ const contentPrekeyUpload = createPrekey(
+ contentPrekey,
+ contentPrekeySignature,
+ );
+
+ const notifPrekeyUpload = createPrekey(notifPrekey, notifPrekeySignature);
+
+ const deviceKeyUpload = createDeviceKeyUpload(
+ identityKeyInfo,
+ contentPrekeyUpload,
+ notifPrekeyUpload,
+ contentOneTimeKeys,
+ notifOneTimeKeys,
+ );
+ return deviceKeyUpload;
+}
+
+function createIdentityKeyInfo(
+ keyPayload: string,
+ keyPayloadSignature: string,
+): IdentityKeyInfo {
const identityKeyInfo = new IdentityKeyInfo();
identityKeyInfo.setPayload(keyPayload);
identityKeyInfo.setPayloadSignature(keyPayloadSignature);
+ return identityKeyInfo;
+}
- const contentPrekeyUpload = new Prekey();
- contentPrekeyUpload.setPrekey(contentPrekey);
- contentPrekeyUpload.setPrekeySignature(contentPrekeySignature);
-
- const notifPrekeyUpload = new Prekey();
- notifPrekeyUpload.setPrekey(notifPrekey);
- notifPrekeyUpload.setPrekeySignature(notifPrekeySignature);
+function createPrekey(prekey: string, prekeySignature: string): Prekey {
+ const prekeyUpload = new Prekey();
+ prekeyUpload.setPrekey(prekey);
+ prekeyUpload.setPrekeySignature(prekeySignature);
+ return prekeyUpload;
+}
+function createDeviceKeyUpload(
+ identityKeyInfo: IdentityKeyInfo,
+ contentPrekeyUpload: Prekey,
+ notifPrekeyUpload: Prekey,
+ contentOneTimeKeys: $ReadOnlyArray<string> = [],
+ notifOneTimeKeys: $ReadOnlyArray<string> = [],
+): DeviceKeyUpload {
const deviceKeyUpload = new DeviceKeyUpload();
deviceKeyUpload.setDeviceKeyInfo(identityKeyInfo);
deviceKeyUpload.setContentUpload(contentPrekeyUpload);
deviceKeyUpload.setNotifUpload(notifPrekeyUpload);
- deviceKeyUpload.setOneTimeContentPrekeysList(contentOneTimeKeysArray);
- deviceKeyUpload.setOneTimeNotifPrekeysList(notifOneTimeKeysArray);
+ deviceKeyUpload.setOneTimeContentPrekeysList([...contentOneTimeKeys]);
+ deviceKeyUpload.setOneTimeNotifPrekeysList([...notifOneTimeKeys]);
deviceKeyUpload.setDeviceType(identityDeviceTypes.WEB);
-
return deviceKeyUpload;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 10, 7:04 PM (13 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2853849
Default Alt Text
D11362.id38215.diff (2 KB)
Attached To
Mode
D11362: [web] factor out common code in authNewDeviceKeyUpload
Attached
Detach File
Event Timeline
Log In to Comment