From a9025e2bf4e04a5621ac62cb7a91e19cd2740210 Mon Sep 17 00:00:00 2001 From: jzunigax2 <125698953+jzunigax2@users.noreply.github.com> Date: Fri, 28 Mar 2025 14:49:30 -0600 Subject: [PATCH 1/3] feat: add PrivateKeys type and update changePasswordWithLink method to accept keys --- src/auth/index.ts | 4 ++++ src/auth/types.ts | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/auth/index.ts b/src/auth/index.ts index bc1ab305..0617d6ed 100644 --- a/src/auth/index.ts +++ b/src/auth/index.ts @@ -8,6 +8,7 @@ import { TwoFactorAuthQR, RegisterPreCreatedUser, RegisterPreCreatedUserResponse, + PrivateKeys, } from './types'; import { UserSettings, UUID } from '../shared/types/userSettings'; import { TeamsSettings } from '../shared/types/teams'; @@ -389,12 +390,14 @@ export class Auth { * @param password * @param salt * @param mnemonic + * @param keys */ public changePasswordWithLink( token: string | undefined, password: string, salt: string, mnemonic: string, + keys?: PrivateKeys, ): Promise { return this.client.put( `/users/recover-account?token=${token}&reset=false`, @@ -402,6 +405,7 @@ export class Auth { password: password, salt: salt, mnemonic: mnemonic, + privateKeys: keys, }, this.basicHeaders(), ); diff --git a/src/auth/types.ts b/src/auth/types.ts index 4cb8d4b7..8da4cb68 100644 --- a/src/auth/types.ts +++ b/src/auth/types.ts @@ -67,3 +67,8 @@ export interface BasicAuth { username: string; password: string; } + +export interface PrivateKeys { + ecc?: string; + kyber?: string; +} From 66b1c4ad6166449f50cdd60cbdb84a00dba6be19 Mon Sep 17 00:00:00 2001 From: jzunigax2 <125698953+jzunigax2@users.noreply.github.com> Date: Fri, 28 Mar 2025 15:00:48 -0600 Subject: [PATCH 2/3] chore: bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 062493a2..2f2ded8e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@internxt/sdk", "author": "Internxt ", - "version": "1.9.9", + "version": "1.9.10", "description": "An sdk for interacting with Internxt's services", "repository": { "type": "git", From 237e15bb80996672283190f717c40b50a4b8e214 Mon Sep 17 00:00:00 2001 From: jzunigax2 <125698953+jzunigax2@users.noreply.github.com> Date: Mon, 31 Mar 2025 09:13:36 -0600 Subject: [PATCH 3/3] chore: improve test coverage --- test/auth/index.test.ts | 52 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/test/auth/index.test.ts b/test/auth/index.test.ts index fbef1e8e..7879a3e3 100644 --- a/test/auth/index.test.ts +++ b/test/auth/index.test.ts @@ -129,7 +129,7 @@ describe('# auth service tests', () => { keys: { ecc: { publicKey: registerDetails.keys.ecc.publicKey, - privateKey: registerDetails.keys.ecc.privateKeyEncrypted, + privateKey: registerDetails.keys.ecc.privateKeyEncrypted, }, kyber: { publicKey: registerDetails.keys.kyber.publicKey, @@ -552,6 +552,56 @@ describe('# auth service tests', () => { expect(body).toEqual({}); }); }); + + describe('-> change password with link', () => { + it('Should call with right params without private keys', async () => { + const callStub = sinon.stub(httpClient, 'put').resolves({}); + const { client, headers } = clientAndHeaders(); + const token = 'token'; + const password = 'newPassword'; + const salt = 'newSalt'; + const mnemonic = 'newMnemonic'; + + await client.changePasswordWithLink(token, password, salt, mnemonic); + + expect(callStub.firstCall.args).toEqual([ + `/users/recover-account?token=${token}&reset=false`, + { + password, + salt, + mnemonic, + }, + headers, + ]); + }); + + it('Should call with right params including private keys', async () => { + const callStub = sinon.stub(httpClient, 'put').resolves({}); + const { client, headers } = clientAndHeaders(); + const token = 'token'; + const password = 'newPassword'; + const salt = 'newSalt'; + const mnemonic = 'newMnemonic'; + const privateKeys = { + ecc: 'newEccKey', + kyber: 'newKyberKey', + }; + + await client.changePasswordWithLink(token, password, salt, mnemonic, privateKeys); + + // Assert + expect(callStub.firstCall.args).toEqual([ + `/users/recover-account?token=${token}&reset=false`, + { + password, + salt, + mnemonic, + privateKeys, + }, + headers, + ]); + }); + }); }); function clientAndHeaders(