diff --git a/package.json b/package.json index 1b268fd..71acdd3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@internxt/sdk", "author": "Internxt ", - "version": "1.8.0", + "version": "1.9.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 6b4f663..7f0d072 100644 --- a/src/auth/index.ts +++ b/src/auth/index.ts @@ -53,9 +53,22 @@ export class Auth { password: registerDetails.password, mnemonic: registerDetails.mnemonic, salt: registerDetails.salt, + /** + / @deprecated The individual fields for keys should not be used + */ privateKey: registerDetails.keys.privateKeyEncrypted, publicKey: registerDetails.keys.publicKey, revocationKey: registerDetails.keys.revocationCertificate, + keys: { + ecc: { + publicKey: registerDetails.keys.ecc.publicKey, + privateKeyEncrypted: registerDetails.keys.ecc.privateKeyEncrypted, + }, + kyber: { + publicKey: registerDetails.keys.kyber.publicKey, + privateKeyEncrypted: registerDetails.keys.kyber.privateKeyEncrypted, + } + }, referral: registerDetails.referral, referrer: registerDetails.referrer, }, @@ -79,9 +92,22 @@ export class Auth { password: registerDetails.password, mnemonic: registerDetails.mnemonic, salt: registerDetails.salt, + /** + / @deprecated The individual fields for keys should not be used + */ privateKey: registerDetails.keys.privateKeyEncrypted, publicKey: registerDetails.keys.publicKey, revocationKey: registerDetails.keys.revocationCertificate, + keys: { + ecc: { + publicKey: registerDetails.keys.ecc.publicKey, + privateKeyEncrypted: registerDetails.keys.ecc.privateKeyEncrypted, + }, + kyber: { + publicKey: registerDetails.keys.kyber.publicKey, + privateKeyEncrypted: registerDetails.keys.kyber.privateKeyEncrypted, + }, + }, referral: registerDetails.referral, referrer: registerDetails.referrer, invitationId: registerDetails.invitationId, @@ -147,9 +173,22 @@ export class Auth { email: details.email, password: encryptedPasswordHash, tfa: details.tfaCode, + /** + / @deprecated The individual fields for keys should not be used + */ privateKey: keys.privateKeyEncrypted, publicKey: keys.publicKey, revocateKey: keys.revocationCertificate, + keys: { + ecc: { + publicKey: keys.ecc.publicKey, + privateKeyEncrypted: keys.ecc.privateKeyEncrypted, + }, + kyber: { + publicKey: keys.kyber.publicKey, + privateKeyEncrypted: keys.kyber.privateKeyEncrypted, + } + }, }, this.basicHeaders(), ) @@ -169,10 +208,21 @@ export class Auth { public updateKeys(keys: Keys, token: Token) { return this.client.patch( '/user/keys', - { + { + /** + / @deprecated The individual fields for keys should not be used + */ publicKey: keys.publicKey, privateKey: keys.privateKeyEncrypted, revocationKey: keys.revocationCertificate, + ecc: { + publicKey: keys.ecc.publicKey, + privateKeyEncrypted: keys.ecc.privateKeyEncrypted, + }, + kyber: { + publicKey: keys.kyber.publicKey, + privateKeyEncrypted: keys.kyber.privateKeyEncrypted, + } }, this.headersWithToken(token), ); diff --git a/src/auth/types.ts b/src/auth/types.ts index 2959cfc..4cb8d4b 100644 --- a/src/auth/types.ts +++ b/src/auth/types.ts @@ -36,6 +36,14 @@ export interface Keys { privateKeyEncrypted: string; publicKey: string; revocationCertificate: string; + ecc: { + publicKey: string; + privateKeyEncrypted: string; + }; + kyber: { + publicKey: string | null; + privateKeyEncrypted: string | null; + }; } export interface CryptoProvider { diff --git a/src/shared/types/userSettings.ts b/src/shared/types/userSettings.ts index 09c2605..d2e3b11 100644 --- a/src/shared/types/userSettings.ts +++ b/src/shared/types/userSettings.ts @@ -21,6 +21,16 @@ export interface UserSettings { privateKey: string; publicKey: string; revocationKey: string; + keys: { + ecc: { + publicKey: string; + privateKeyEncrypted: string; + } + kyber: { + publicKey: string; + privateKeyEncrypted: string; + } + } teams?: boolean; appSumoDetails: AppSumoDetails | null; registerCompleted: boolean; diff --git a/test/auth/index.test.ts b/test/auth/index.test.ts index 4b2963f..03634df 100644 --- a/test/auth/index.test.ts +++ b/test/auth/index.test.ts @@ -26,8 +26,12 @@ describe('# auth service tests', () => { registerDetails.password = '4'; registerDetails.mnemonic = '5'; registerDetails.salt = '6'; - registerDetails.keys.revocationCertificate = '7'; - registerDetails.captcha = '8'; + registerDetails.keys.ecc.privateKeyEncrypted = '7'; + registerDetails.keys.ecc.publicKey = '8'; + registerDetails.keys.kyber.privateKeyEncrypted = '9'; + registerDetails.keys.kyber.publicKey = '10'; + registerDetails.keys.revocationCertificate = '11'; + registerDetails.captcha = '12'; const postCall = sinon.stub(httpClient, 'post').resolves({}); const { client, headers } = clientAndHeaders(); @@ -48,6 +52,16 @@ describe('# auth service tests', () => { privateKey: registerDetails.keys.privateKeyEncrypted, publicKey: registerDetails.keys.publicKey, revocationKey: registerDetails.keys.revocationCertificate, + keys: { + ecc: { + publicKey: registerDetails.keys.ecc.publicKey, + privateKeyEncrypted: registerDetails.keys.ecc.privateKeyEncrypted, + }, + kyber: { + publicKey: registerDetails.keys.kyber.publicKey, + privateKeyEncrypted: registerDetails.keys.kyber.privateKeyEncrypted, + }, + }, referral: registerDetails.referral, referrer: registerDetails.referrer, captcha: registerDetails.captcha, @@ -84,8 +98,12 @@ describe('# auth service tests', () => { registerDetails.password = '4'; registerDetails.mnemonic = '5'; registerDetails.salt = '6'; - registerDetails.keys.revocationCertificate = '7'; - registerDetails.captcha = '8'; + registerDetails.keys.ecc.privateKeyEncrypted = '7'; + registerDetails.keys.ecc.publicKey = '8'; + registerDetails.keys.kyber.privateKeyEncrypted = '9'; + registerDetails.keys.kyber.publicKey = '10'; + registerDetails.keys.revocationCertificate = '11'; + registerDetails.captcha = '12'; const mockInvitatioId = 'invitationId'; @@ -108,6 +126,16 @@ describe('# auth service tests', () => { privateKey: registerDetails.keys.privateKeyEncrypted, publicKey: registerDetails.keys.publicKey, revocationKey: registerDetails.keys.revocationCertificate, + keys: { + ecc: { + publicKey: registerDetails.keys.ecc.publicKey, + privateKeyEncrypted: registerDetails.keys.ecc.privateKeyEncrypted, + }, + kyber: { + publicKey: registerDetails.keys.kyber.publicKey, + privateKeyEncrypted: registerDetails.keys.kyber.privateKeyEncrypted, + }, + }, referral: registerDetails.referral, referrer: registerDetails.referrer, captcha: registerDetails.captcha, @@ -153,6 +181,14 @@ describe('# auth service tests', () => { privateKeyEncrypted: '', publicKey: '', revocationCertificate: '', + ecc: { + publicKey: '', + privateKeyEncrypted: '', + }, + kyber: { + publicKey: '', + privateKeyEncrypted: '', + }, }; return Promise.resolve(keys); }, @@ -181,6 +217,14 @@ describe('# auth service tests', () => { privateKeyEncrypted: '', publicKey: '', revocationCertificate: '', + ecc: { + publicKey: '', + privateKeyEncrypted: '', + }, + kyber: { + publicKey: '', + privateKeyEncrypted: '', + }, }; return Promise.resolve(keys); }, @@ -216,6 +260,14 @@ describe('# auth service tests', () => { privateKeyEncrypted: 'priv', publicKey: 'pub', revocationCertificate: 'rev', + ecc: { + publicKey: 'pub', + privateKeyEncrypted: 'priv', + }, + kyber: { + publicKey: 'pubKyber', + privateKeyEncrypted: 'privKyber', + }, }; return Promise.resolve(keys); }, @@ -253,6 +305,16 @@ describe('# auth service tests', () => { privateKey: 'priv', publicKey: 'pub', revocateKey: 'rev', + keys: { + ecc: { + publicKey: 'pub', + privateKeyEncrypted: 'priv', + }, + kyber: { + publicKey: 'pubKyber', + privateKeyEncrypted: 'privKyber', + }, + }, }, headers, ]); @@ -274,6 +336,14 @@ describe('# auth service tests', () => { privateKeyEncrypted: 'prik', publicKey: 'pubk', revocationCertificate: 'crt', + ecc: { + publicKey: 'pub', + privateKeyEncrypted: 'priv', + }, + kyber: { + publicKey: 'pubKyber', + privateKeyEncrypted: 'privKyber', + }, }; const axiosStub = sinon.stub(httpClient, 'patch').resolves({}); @@ -287,6 +357,14 @@ describe('# auth service tests', () => { publicKey: 'pubk', privateKey: 'prik', revocationKey: 'crt', + ecc: { + publicKey: 'pub', + privateKeyEncrypted: 'priv', + }, + kyber: { + publicKey: 'pubKyber', + privateKeyEncrypted: 'privKyber', + }, }, headers, ]); diff --git a/test/auth/registerDetails.mother.ts b/test/auth/registerDetails.mother.ts index e024db4..92805e3 100644 --- a/test/auth/registerDetails.mother.ts +++ b/test/auth/registerDetails.mother.ts @@ -5,6 +5,14 @@ export function emptyRegisterDetails(): RegisterDetails { privateKeyEncrypted: '', publicKey: '', revocationCertificate: '', + ecc: { + publicKey: '', + privateKeyEncrypted: '', + }, + kyber: { + publicKey: '', + privateKeyEncrypted: '', + }, }; return { name: '',