diff --git a/lib/types/identity-service-types.js b/lib/types/identity-service-types.js --- a/lib/types/identity-service-types.js +++ b/lib/types/identity-service-types.js @@ -15,6 +15,7 @@ type OlmSessionInitializationInfo, olmSessionInitializationInfoValidator, } from './olm-session-types.js'; +import { type SignedMessage } from './siwe-types.js'; import { currentUserInfoValidator, type CurrentUserInfo, @@ -172,8 +173,7 @@ +restoreUser?: ( userID: string, deviceList: SignedDeviceList, - siweMessage?: string, - siweSignature?: string, + siweSocialProof?: SignedMessage, ) => Promise; // on native, publishing prekeys to Identity is called directly from C++, // there is no need to expose it to JS diff --git a/native/account/restore-backup-screen.react.js b/native/account/restore-backup-screen.react.js --- a/native/account/restore-backup-screen.react.js +++ b/native/account/restore-backup-screen.react.js @@ -61,8 +61,7 @@ await restore( userIdentifier, credentials.backup.signature, - credentials.socialProof.message, - credentials.socialProof.signature, + credentials.socialProof, ); await commCoreModule.setSIWEBackupSecrets(credentials.backup); } diff --git a/native/account/restore.js b/native/account/restore.js --- a/native/account/restore.js +++ b/native/account/restore.js @@ -12,6 +12,7 @@ import { IdentityClientContext } from 'lib/shared/identity-client-context.js'; import type { SignedDeviceList } from 'lib/types/identity-service-types.js'; import { platformToIdentityDeviceType } from 'lib/types/identity-service-types.js'; +import type { SignedMessage } from 'lib/types/siwe-types.js'; import { getConfig } from 'lib/utils/config.js'; import { getContentSigningKey } from 'lib/utils/crypto-utils.js'; import { composeRawDeviceList } from 'lib/utils/device-list-utils.js'; @@ -29,8 +30,7 @@ // password or SIWE signature secret: string, // social proof for SIWE restore - siweMessage?: string, - siweSignature?: string, + siweSocialProof?: SignedMessage, ) => Promise { const identityContext = React.useContext(IdentityClientContext); invariant(identityContext, 'identity context not set'); @@ -49,8 +49,7 @@ async ( userIdentifier: string, secret: string, - siweMessage?: string, - siweSignature?: string, + siweSocialProof?: SignedMessage, ) => { //1. Runs Key Generation const { olmAPI } = getConfig(); @@ -97,8 +96,7 @@ const result = await restoreUser( userID, signedDeviceList, - siweMessage, - siweSignature, + siweSocialProof, ); //6. Mark keys as published @@ -140,8 +138,7 @@ function useRestore(): ( userIdentifier: string, secret: string, - siweMessage?: string, - siweSignature?: string, + siweSocialProof?: SignedMessage, ) => Promise { const restoreProtocol = useRestoreProtocol(); const dispatchActionPromise = useDispatchActionPromise(); @@ -149,15 +146,9 @@ ( userIdentifier: string, secret: string, - siweMessage?: string, - siweSignature?: string, + siweSocialProof?: SignedMessage, ) => { - const promise = restoreProtocol( - userIdentifier, - secret, - siweMessage, - siweSignature, - ); + const promise = restoreProtocol(userIdentifier, secret, siweSocialProof); void dispatchActionPromise(restoreUserActionTypes, promise); return promise; }, @@ -166,12 +157,8 @@ const logIn = useLogIn(); return React.useCallback( - ( - userIdentifier: string, - secret: string, - siweMessage?: string, - siweSignature?: string, - ) => logIn(restoreAuth(userIdentifier, secret, siweMessage, siweSignature)), + (userIdentifier: string, secret: string, siweSocialProof?: SignedMessage) => + logIn(restoreAuth(userIdentifier, secret, siweSocialProof)), [logIn, restoreAuth], ); } diff --git a/native/identity-service/identity-service-context-provider.react.js b/native/identity-service/identity-service-context-provider.react.js --- a/native/identity-service/identity-service-context-provider.react.js +++ b/native/identity-service/identity-service-context-provider.react.js @@ -32,6 +32,7 @@ type UsersDevicesPlatformDetails, peersDeviceListsValidator, } from 'lib/types/identity-service-types.js'; +import type { SignedMessage } from 'lib/types/siwe-types.js'; import { getContentSigningKey } from 'lib/utils/crypto-utils.js'; import { getMessageForException } from 'lib/utils/errors.js'; import { assertWithValidator } from 'lib/utils/validation-utils.js'; @@ -551,8 +552,7 @@ restoreUser: async ( userID: string, deviceList: SignedDeviceList, - siweSocialProofMessage?: string, - siweSocialProofSignature?: string, + siweSocialProof?: SignedMessage, ) => { await commCoreModule.initializeCryptoAccount(); const [ @@ -566,8 +566,8 @@ ]); const restoreResult = await commRustModule.restoreUser( userID, - siweSocialProofMessage, - siweSocialProofSignature, + siweSocialProof?.message, + siweSocialProof?.signature, blobPayload, signature, prekeys.contentPrekey,