diff --git a/keyserver/src/responders/user-responders.js b/keyserver/src/responders/user-responders.js --- a/keyserver/src/responders/user-responders.js +++ b/keyserver/src/responders/user-responders.js @@ -49,6 +49,7 @@ import { identityKeysBlobValidator, signedIdentityKeysBlobValidator, + olmSessionInitializationKeysValidator, } from 'lib/utils/crypto-utils.js'; import { ServerError } from 'lib/utils/errors.js'; import { values } from 'lib/utils/objects.js'; @@ -214,6 +215,9 @@ // old clients, but we no longer do anything with it. primaryIdentityPublicKey: t.maybe(tRegex(primaryIdentityPublicKeyRegex)), signedIdentityKeysBlob: t.maybe(signedIdentityKeysBlobValidator), + notificationsSessionInitializationKeys: t.maybe( + olmSessionInitializationKeysValidator, + ), }); async function accountCreationResponder( @@ -361,6 +365,9 @@ // old clients, but we no longer do anything with it. primaryIdentityPublicKey: t.maybe(tRegex(primaryIdentityPublicKeyRegex)), signedIdentityKeysBlob: t.maybe(signedIdentityKeysBlobValidator), + notificationsSessionInitializationKeys: t.maybe( + olmSessionInitializationKeysValidator, + ), }); async function logInResponder( @@ -446,6 +453,9 @@ platformDetails: tPlatformDetails, watchedIDs: t.list(t.String), signedIdentityKeysBlob: t.maybe(signedIdentityKeysBlobValidator), + notificationsSessionInitializationKeys: t.maybe( + olmSessionInitializationKeysValidator, + ), }); async function siweAuthResponder( diff --git a/lib/types/account-types.js b/lib/types/account-types.js --- a/lib/types/account-types.js +++ b/lib/types/account-types.js @@ -1,6 +1,9 @@ // @flow -import type { SignedIdentityKeysBlob } from './crypto-types.js'; +import type { + SignedIdentityKeysBlob, + OLMSessionInitializationKeys, +} from './crypto-types.js'; import type { PlatformDetails } from './device-types.js'; import type { CalendarQuery, @@ -104,6 +107,7 @@ +calendarQuery: CalendarQuery, +deviceTokenUpdateRequest?: ?DeviceTokenUpdateRequest, +signedIdentityKeysBlob?: SignedIdentityKeysBlob, + +notificationsSessionInitializationKeys?: OLMSessionInitializationKeys, }; export type LogInInfo = { diff --git a/lib/types/crypto-types.js b/lib/types/crypto-types.js --- a/lib/types/crypto-types.js +++ b/lib/types/crypto-types.js @@ -16,6 +16,11 @@ +curve25519: { +[string]: string }, }; +export type OLMSessionInitializationKeys = { + +prekey: OLMPrekey, + +oneTimeKeysBatch: OLMOneTimeKeys, +}; + export type PickledOLMAccount = { +picklingKey: string, +pickledAccount: string, diff --git a/lib/utils/crypto-utils.js b/lib/utils/crypto-utils.js --- a/lib/utils/crypto-utils.js +++ b/lib/utils/crypto-utils.js @@ -18,6 +18,22 @@ curve25519: tRegex(primaryIdentityPublicKeyRegex), }); +const olmPrekeyValidator: TInterface = tShape({ + curve25519: tShape({ + id: t.String, + key: t.String, + }), +}); + +const olmOneTimeKeysValidator: TInterface = tShape({ + curve25519: t.dict(t.String, t.String), +}); + +const olmSessionInitializationKeysValidator: TInterface = tShape({ + prekey: olmPrekeyValidator, + oneTimeKeysBatch: olmOneTimeKeysValidator, +}); + const identityKeysBlobValidator: TInterface = tShape({ primaryIdentityPublicKeys: olmIdentityKeysValidator, notificationIdentityPublicKeys: olmIdentityKeysValidator, @@ -27,4 +43,7 @@ minimumOneTimeKeysRequired, signedIdentityKeysBlobValidator, identityKeysBlobValidator, + olmPrekeyValidator, + olmOneTimeKeysValidator, + olmSessionInitializationKeysValidator, }; diff --git a/native/selectors/account-selectors.js b/native/selectors/account-selectors.js --- a/native/selectors/account-selectors.js +++ b/native/selectors/account-selectors.js @@ -31,9 +31,20 @@ payload: blobPayload, signature, }; + const [notificationsPrekey, notificationsOneTimeKeys] = await Promise.all( + [ + commCoreModule.generateAndPublishNotificationsPrekey(), + commCoreModule.getNotificationsOneTimeKeys(1), + ], + ); + const notificationsSessionInitializationKeys = { + prekey: notificationsPrekey, + oneTimeKeysBatch: notificationsOneTimeKeys, + }; return { ...logInExtraInfoFunc(calendarActive), signedIdentityKeysBlob, + notificationsSessionInitializationKeys, }; }; return loginExtraFuncWithIdentityKey;