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 @@ -67,6 +67,11 @@ userID: string, ) => Promise; +generateNonce: () => Promise; + +registerWalletUser?: ( + walletAddress: string, + siweMessage: string, + siweSignature: string, + ) => Promise; +logInWalletUser: ( walletAddress: string, siweMessage: string, 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 @@ -260,6 +260,45 @@ identityAuthResultValidator, ); }, + registerWalletUser: async ( + walletAddress: string, + siweMessage: string, + siweSignature: string, + ) => { + await commCoreModule.initializeCryptoAccount(); + const [ + { blobPayload, signature }, + { contentOneTimeKeys, notificationsOneTimeKeys }, + prekeys, + ] = await Promise.all([ + commCoreModule.getUserPublicKey(), + commCoreModule.getOneTimeKeys(ONE_TIME_KEYS_NUMBER), + commCoreModule.validateAndGetPrekeys(), + ]); + const registrationResult = await commRustModule.registerWalletUser( + siweMessage, + siweSignature, + blobPayload, + signature, + prekeys.contentPrekey, + prekeys.contentPrekeySignature, + prekeys.notifPrekey, + prekeys.notifPrekeySignature, + getOneTimeKeyValues(contentOneTimeKeys), + getOneTimeKeyValues(notificationsOneTimeKeys), + ); + const { userID, accessToken: token } = JSON.parse(registrationResult); + const identityAuthResult = { + accessToken: token, + userID, + username: walletAddress, + }; + + return assertWithValidator( + identityAuthResult, + identityAuthResultValidator, + ); + }, logInWalletUser: async ( walletAddress: string, siweMessage: string,