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 @@ -121,6 +121,7 @@ export interface IdentityServiceClient { +deleteWalletUser: () => Promise; + +deletePasswordUser: (password: string) => Promise; +logOut: () => Promise; +getKeyserverKeys: string => Promise; +registerPasswordUser?: ( 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 @@ -85,6 +85,19 @@ } = await getAuthMetadata(); return commRustModule.deleteWalletUser(userID, deviceID, token); }, + deletePasswordUser: async (password: string) => { + const { + deviceID, + userID, + accessToken: token, + } = await getAuthMetadata(); + return commRustModule.deletePasswordUser( + userID, + deviceID, + token, + password, + ); + }, logOut: async () => { const { deviceID, diff --git a/web/grpc/identity-service-client-wrapper.js b/web/grpc/identity-service-client-wrapper.js --- a/web/grpc/identity-service-client-wrapper.js +++ b/web/grpc/identity-service-client-wrapper.js @@ -137,6 +137,41 @@ await this.authClient.deleteWalletUser(new Empty()); }; + deletePasswordUser: (password: string) => Promise = async ( + password: string, + ) => { + const client = this.authClient; + if (!client) { + throw new Error('Identity service client is not initialized'); + } + + const opaqueLogin = new Login(); + const startRequestBytes = opaqueLogin.start(password); + + const deleteStartRequest = + new IdentityAuthStructs.DeletePasswordUserStartRequest(); + deleteStartRequest.setOpaqueLoginRequest(startRequestBytes); + + let deleteStartResponse; + try { + deleteStartResponse = + await client.deletePasswordUserStart(deleteStartRequest); + } catch (e) { + console.log('Error calling deletePasswordUserStart:', e); + throw new Error(getMessageForException(e) ?? 'unknown'); + } + const finishRequestBytes = opaqueLogin.finish( + deleteStartResponse.getOpaqueLoginResponse_asU8(), + ); + + const deleteFinishRequest = + new IdentityAuthStructs.DeletePasswordUserFinishRequest(); + deleteFinishRequest.setSessionId(deleteStartResponse.getSessionId()); + deleteFinishRequest.setOpaqueLoginUpload(finishRequestBytes); + + await client.deletePasswordUserFinish(deleteFinishRequest); + }; + logOut: () => Promise = async () => { if (!this.authClient) { throw new Error('Identity service client is not initialized'); diff --git a/web/grpc/identity-service-context-provider.react.js b/web/grpc/identity-service-context-provider.react.js --- a/web/grpc/identity-service-context-provider.react.js +++ b/web/grpc/identity-service-context-provider.react.js @@ -118,6 +118,7 @@ const client = React.useMemo(() => { return { deleteWalletUser: proxyMethodToWorker('deleteWalletUser'), + deletePasswordUser: proxyMethodToWorker('deletePasswordUser'), logOut: proxyMethodToWorker('logOut'), getKeyserverKeys: proxyMethodToWorker('getKeyserverKeys'), getOutboundKeysForUser: proxyMethodToWorker('getOutboundKeysForUser'),