Changeset View
Changeset View
Standalone View
Standalone View
web/grpc/identity-service-client-wrapper.js
Show First 20 Lines • Show All 527 Lines • ▼ Show 20 Lines | const { | ||||
contentPrekey, | contentPrekey, | ||||
contentPrekeySignature, | contentPrekeySignature, | ||||
notifPrekey, | notifPrekey, | ||||
notifPrekeySignature, | notifPrekeySignature, | ||||
contentOneTimeKeys, | contentOneTimeKeys, | ||||
notifOneTimeKeys, | notifOneTimeKeys, | ||||
} = uploadData; | } = uploadData; | ||||
const contentOneTimeKeysArray = [...contentOneTimeKeys]; | const identityKeyInfo = createIdentityKeyInfo( | ||||
const notifOneTimeKeysArray = [...notifOneTimeKeys]; | 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(); | const identityKeyInfo = new IdentityKeyInfo(); | ||||
identityKeyInfo.setPayload(keyPayload); | identityKeyInfo.setPayload(keyPayload); | ||||
identityKeyInfo.setPayloadSignature(keyPayloadSignature); | identityKeyInfo.setPayloadSignature(keyPayloadSignature); | ||||
return identityKeyInfo; | |||||
} | |||||
const contentPrekeyUpload = new Prekey(); | function createPrekey(prekey: string, prekeySignature: string): Prekey { | ||||
contentPrekeyUpload.setPrekey(contentPrekey); | const prekeyUpload = new Prekey(); | ||||
contentPrekeyUpload.setPrekeySignature(contentPrekeySignature); | prekeyUpload.setPrekey(prekey); | ||||
prekeyUpload.setPrekeySignature(prekeySignature); | |||||
const notifPrekeyUpload = new Prekey(); | return prekeyUpload; | ||||
notifPrekeyUpload.setPrekey(notifPrekey); | } | ||||
notifPrekeyUpload.setPrekeySignature(notifPrekeySignature); | |||||
function createDeviceKeyUpload( | |||||
identityKeyInfo: IdentityKeyInfo, | |||||
contentPrekeyUpload: Prekey, | |||||
notifPrekeyUpload: Prekey, | |||||
contentOneTimeKeys: $ReadOnlyArray<string> = [], | |||||
notifOneTimeKeys: $ReadOnlyArray<string> = [], | |||||
): DeviceKeyUpload { | |||||
const deviceKeyUpload = new DeviceKeyUpload(); | const deviceKeyUpload = new DeviceKeyUpload(); | ||||
deviceKeyUpload.setDeviceKeyInfo(identityKeyInfo); | deviceKeyUpload.setDeviceKeyInfo(identityKeyInfo); | ||||
deviceKeyUpload.setContentUpload(contentPrekeyUpload); | deviceKeyUpload.setContentUpload(contentPrekeyUpload); | ||||
deviceKeyUpload.setNotifUpload(notifPrekeyUpload); | deviceKeyUpload.setNotifUpload(notifPrekeyUpload); | ||||
deviceKeyUpload.setOneTimeContentPrekeysList(contentOneTimeKeysArray); | deviceKeyUpload.setOneTimeContentPrekeysList([...contentOneTimeKeys]); | ||||
deviceKeyUpload.setOneTimeNotifPrekeysList(notifOneTimeKeysArray); | deviceKeyUpload.setOneTimeNotifPrekeysList([...notifOneTimeKeys]); | ||||
deviceKeyUpload.setDeviceType(identityDeviceTypes.WEB); | deviceKeyUpload.setDeviceType(identityDeviceTypes.WEB); | ||||
return deviceKeyUpload; | return deviceKeyUpload; | ||||
} | } | ||||
export { IdentityServiceClientWrapper }; | export { IdentityServiceClientWrapper }; |