From 207d8d506049c29425a29b71d84523af971608d0 Mon Sep 17 00:00:00 2001 From: tamarafinogina Date: Mon, 31 Aug 2026 14:53:25 +0200 Subject: [PATCH 1/5] add login and pwd change with argon2 --- package.json | 2 +- src/auth/index.ts | 30 ++++++++++++++++++++++++++++++ src/auth/types.ts | 1 + src/drive/users/index.ts | 22 ++++++++++++++++++++++ src/drive/users/types.ts | 11 +++++++++++ 5 files changed, 65 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 7e0c2849..e0cce7b2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@internxt/sdk", "author": "Internxt ", - "version": "1.20.2", + "version": "1.21.0", "description": "An sdk for interacting with Internxt's services", "repository": { "type": "git", diff --git a/src/auth/index.ts b/src/auth/index.ts index 1a9c7c7b..48528ad6 100644 --- a/src/auth/index.ts +++ b/src/auth/index.ts @@ -230,6 +230,34 @@ export class Auth { ); } + /** + * Tries to log in a user with Argon2 + * @param email - The user email address + * @param passwordHash - The argon2id hash of the user's password + * @param tfaCode - The 2 factor authentication code (if 2FA is enabled) + */ + public loginArgon2( + email: string, + passwordHash: string, + tfaCode?: string, + ): Promise<{ + token: Token; + user: UserSettings; + }> { + return this.client.post<{ + token: Token; + user: UserSettings; + }>( + '/auth/login-argon2/access', + { + email, + passwordHash, + tfa: tfaCode, + }, + this.basicHeaders(), + ); + } + /** * Tries to log in a user given its cli login details * @param details @@ -330,6 +358,7 @@ export class Auth { .post<{ sKey: string; tfa: boolean | null; + saltArgon2: string; }>( '/auth/login', { @@ -341,6 +370,7 @@ export class Auth { return { encryptedSalt: data.sKey, tfaEnabled: data.tfa === true, + saltArgon2: data.saltArgon2, }; }); } diff --git a/src/auth/types.ts b/src/auth/types.ts index 3a3ea8fe..ad2bb8e2 100644 --- a/src/auth/types.ts +++ b/src/auth/types.ts @@ -65,6 +65,7 @@ export class UserAccessError extends Error {} export interface SecurityDetails { encryptedSalt: string; tfaEnabled: boolean; + saltArgon2: string; } export interface TwoFactorAuthQR { diff --git a/src/drive/users/index.ts b/src/drive/users/index.ts index 7d31bcd7..24198b92 100644 --- a/src/drive/users/index.ts +++ b/src/drive/users/index.ts @@ -17,6 +17,7 @@ import { UserPublicKeyResponse, UserPublicKeyWithCreationResponse, VerifyEmailChangeResponse, + ChangePasswordArgon2Payload, } from './types'; export * as UserTypes from './types'; @@ -159,6 +160,27 @@ export class Users { ); } + /** + * Updates the authentication credentials with argon2 and invalidates previous tokens + * @param payload + * + * @returns {Promise} A promise that returns new tokens for this user. + */ + public changePasswordArgon2(payload: ChangePasswordArgon2Payload): Promise { + return this.client.patch( + '/users/password-argon2', + { + currentPassword: payload.currentPasswordHash, + newPassword: payload.newPasswordHash, + newSalt: payload.newSalt, + mnemonic: payload.encryptedMnemonic, + privateKey: payload.keys.encryptedPrivateKey, + privateKyberKey: payload.keys.encryptedPrivateKyberKey, + }, + this.headers(), + ); + } + /** * Pre registers an email * @param email diff --git a/src/drive/users/types.ts b/src/drive/users/types.ts index 6921fec5..5828ee2f 100644 --- a/src/drive/users/types.ts +++ b/src/drive/users/types.ts @@ -25,6 +25,17 @@ export interface ChangePasswordPayload { encryptedPrivateKey: string; } +export interface ChangePasswordArgon2Payload { + currentPasswordHash: string; + newPasswordHash: string; + newSalt: string; + encryptedMnemonic: string; + keys: { + encryptedPrivateKey: string; + encryptedPrivateKyberKey: string; + }; +} + export interface ChangePasswordPayloadNew { currentEncryptedPassword: string; newEncryptedPassword: string; From 0149439880d5afb8341599737272c5c8eaa3d6dc Mon Sep 17 00:00:00 2001 From: tamarafinogina Date: Mon, 31 Aug 2026 16:27:07 +0200 Subject: [PATCH 2/5] use existing endpoints with a flag --- src/auth/index.ts | 2 +- src/drive/users/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/auth/index.ts b/src/auth/index.ts index 48528ad6..51ccb49e 100644 --- a/src/auth/index.ts +++ b/src/auth/index.ts @@ -248,7 +248,7 @@ export class Auth { token: Token; user: UserSettings; }>( - '/auth/login-argon2/access', + '/auth/login/access?argon2=true', { email, passwordHash, diff --git a/src/drive/users/index.ts b/src/drive/users/index.ts index 24198b92..e4cce68c 100644 --- a/src/drive/users/index.ts +++ b/src/drive/users/index.ts @@ -168,7 +168,7 @@ export class Users { */ public changePasswordArgon2(payload: ChangePasswordArgon2Payload): Promise { return this.client.patch( - '/users/password-argon2', + '/users/password?argon2=true', { currentPassword: payload.currentPasswordHash, newPassword: payload.newPasswordHash, From 1240cf5569c0bff3a3b0de75f501b7423b1cc6b6 Mon Sep 17 00:00:00 2001 From: tamarafinogina Date: Mon, 31 Aug 2026 16:54:20 +0200 Subject: [PATCH 3/5] change to new endpoints --- src/auth/index.ts | 2 +- src/drive/users/index.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/auth/index.ts b/src/auth/index.ts index 51ccb49e..c5618c6d 100644 --- a/src/auth/index.ts +++ b/src/auth/index.ts @@ -248,7 +248,7 @@ export class Auth { token: Token; user: UserSettings; }>( - '/auth/login/access?argon2=true', + '/auth/v2/login/access', { email, passwordHash, diff --git a/src/drive/users/index.ts b/src/drive/users/index.ts index e4cce68c..f5b7266f 100644 --- a/src/drive/users/index.ts +++ b/src/drive/users/index.ts @@ -168,7 +168,7 @@ export class Users { */ public changePasswordArgon2(payload: ChangePasswordArgon2Payload): Promise { return this.client.patch( - '/users/password?argon2=true', + '/users/v2/password', { currentPassword: payload.currentPasswordHash, newPassword: payload.newPasswordHash, From db4f51fcc2ebdc5bf0c72ef4b51d1202e8ea401b Mon Sep 17 00:00:00 2001 From: tamarafinogina Date: Mon, 31 Aug 2026 18:00:36 +0200 Subject: [PATCH 4/5] fix typo --- src/drive/users/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/drive/users/index.ts b/src/drive/users/index.ts index f5b7266f..1b3bf1a3 100644 --- a/src/drive/users/index.ts +++ b/src/drive/users/index.ts @@ -170,8 +170,8 @@ export class Users { return this.client.patch( '/users/v2/password', { - currentPassword: payload.currentPasswordHash, - newPassword: payload.newPasswordHash, + currentPasswordHash: payload.currentPasswordHash, + newPasswordHash: payload.newPasswordHash, newSalt: payload.newSalt, mnemonic: payload.encryptedMnemonic, privateKey: payload.keys.encryptedPrivateKey, From aca145c5c4a061c9b5d4a67236a00c0721e93a6a Mon Sep 17 00:00:00 2001 From: tamarafinogina Date: Mon, 31 Aug 2026 18:01:20 +0200 Subject: [PATCH 5/5] make names reflect encrypted fields --- src/drive/users/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/drive/users/index.ts b/src/drive/users/index.ts index 1b3bf1a3..6bd2ea7d 100644 --- a/src/drive/users/index.ts +++ b/src/drive/users/index.ts @@ -173,9 +173,9 @@ export class Users { currentPasswordHash: payload.currentPasswordHash, newPasswordHash: payload.newPasswordHash, newSalt: payload.newSalt, - mnemonic: payload.encryptedMnemonic, - privateKey: payload.keys.encryptedPrivateKey, - privateKyberKey: payload.keys.encryptedPrivateKyberKey, + encryptedMnemonic: payload.encryptedMnemonic, + encryptedPrivateKey: payload.keys.encryptedPrivateKey, + encryptedPrivateKyberKey: payload.keys.encryptedPrivateKyberKey, }, this.headers(), );