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 @@ -168,6 +168,13 @@ siweMessage: string, siweSignature: string, ) => Promise; + // Users cannot restore backup from web + +restoreUser?: ( + userID: string, + deviceList: SignedDeviceList, + siweMessage?: string, + siweSignature?: string, + ) => Promise; // on native, publishing prekeys to Identity is called directly from C++, // there is no need to expose it to JS +publishWebPrekeys?: (prekeys: SignedPrekeys) => Promise; 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 @@ -507,6 +507,42 @@ primaryIdentityPublicKeys.ed25519, ); }, + restoreUser: async ( + userID: string, + deviceList: SignedDeviceList, + siweMessage?: string, + siweSignature?: string, + ) => { + await commCoreModule.initializeCryptoAccount(); + const [ + { blobPayload, signature, primaryIdentityPublicKeys }, + { contentOneTimeKeys, notificationsOneTimeKeys }, + prekeys, + ] = await Promise.all([ + commCoreModule.getUserPublicKey(), + commCoreModule.getOneTimeKeys(ONE_TIME_KEYS_NUMBER), + commCoreModule.validateAndGetPrekeys(), + ]); + const restoreResult = await commRustModule.restoreUser( + userID, + siweMessage, + siweSignature, + blobPayload, + signature, + prekeys.contentPrekey, + prekeys.contentPrekeySignature, + prekeys.notifPrekey, + prekeys.notifPrekeySignature, + getOneTimeKeyValues(contentOneTimeKeys), + getOneTimeKeyValues(notificationsOneTimeKeys), + JSON.stringify(deviceList), + ); + + return await processAuthResult( + restoreResult, + primaryIdentityPublicKeys.ed25519, + ); + }, uploadKeysForRegisteredDeviceAndLogIn: async ( userID: string, nonceChallengeResponse: SignedNonce,