Skip to content

Commit

Permalink
Merge pull request #262 from internxt/fix/remove-depth-level-on-auth-…
Browse files Browse the repository at this point in the history
…login-crypto-keys

[_]: refactor/remove-one-depth-level-on-crypto-keys-data-structure-on-login
  • Loading branch information
xabg2 authored Nov 25, 2024
2 parents a57fae0 + 0e8ec80 commit 1cf9599
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 89 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@internxt/sdk",
"author": "Internxt <[email protected]>",
"version": "1.6.3",
"version": "1.6.4",
"description": "An sdk for interacting with Internxt's services",
"repository": {
"type": "git",
Expand Down
36 changes: 18 additions & 18 deletions src/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ export class Auth {
revocationKey: registerDetails.keys.revocationCertificate,
keys: {
ecc: {
privateKey: registerDetails.keys.keys.ecc.privateKeyEncrypted,
publicKey: registerDetails.keys.keys.ecc.publicKey,
privateKey: registerDetails.keys.ecc.privateKeyEncrypted,
publicKey: registerDetails.keys.ecc.publicKey,
},
kyber: {
privateKey: registerDetails.keys.keys.kyber.privateKeyEncrypted,
publicKey: registerDetails.keys.keys.kyber.publicKey,
privateKey: registerDetails.keys.kyber.privateKeyEncrypted,
publicKey: registerDetails.keys.kyber.publicKey,
}
},
referral: registerDetails.referral,
Expand Down Expand Up @@ -100,13 +100,13 @@ export class Auth {
revocationKey: registerDetails.keys.revocationCertificate,
keys: {
ecc: {
privateKey: registerDetails.keys.keys.ecc.privateKeyEncrypted,
publicKey: registerDetails.keys.keys.ecc.publicKey,
},
privateKey: registerDetails.keys.ecc.privateKeyEncrypted,
publicKey: registerDetails.keys.ecc.publicKey,
},
kyber: {
privateKey: registerDetails.keys.keys.kyber.privateKeyEncrypted,
publicKey: registerDetails.keys.keys.kyber.publicKey,
}
privateKey: registerDetails.keys.kyber.privateKeyEncrypted,
publicKey: registerDetails.keys.kyber.publicKey,
},
},
referral: registerDetails.referral,
referrer: registerDetails.referrer,
Expand Down Expand Up @@ -181,12 +181,12 @@ export class Auth {
revocateKey: keys.revocationCertificate,
keys: {
ecc: {
privateKey: keys.keys.ecc.privateKeyEncrypted,
publicKey: keys.keys.ecc.publicKey,
privateKey: keys.ecc.privateKeyEncrypted,
publicKey: keys.ecc.publicKey,
},
kyber: {
privateKey: keys.keys.kyber.privateKeyEncrypted,
publicKey: keys.keys.kyber.publicKey,
privateKey: keys.kyber.privateKeyEncrypted,
publicKey: keys.kyber.publicKey,
}
},
},
Expand Down Expand Up @@ -217,12 +217,12 @@ export class Auth {
revocationKey: keys.revocationCertificate,
keys: {
ecc: {
privateKey: keys.keys.ecc.privateKeyEncrypted,
publicKey: keys.keys.ecc.publicKey,
privateKey: keys.ecc.privateKeyEncrypted,
publicKey: keys.ecc.publicKey,
},
kyber: {
privateKey: keys.keys.kyber.privateKeyEncrypted,
publicKey: keys.keys.kyber.publicKey,
privateKey: keys.kyber.privateKeyEncrypted,
publicKey: keys.kyber.publicKey,
}
},
},
Expand Down
16 changes: 7 additions & 9 deletions src/auth/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@ export interface Keys {
privateKeyEncrypted: string;
publicKey: string;
revocationCertificate: string;
keys: {
ecc: {
privateKeyEncrypted: string;
publicKey: string;
};
kyber: {
publicKey: string;
privateKeyEncrypted: string;
};
ecc: {
privateKeyEncrypted: string;
publicKey: string;
};
kyber: {
publicKey: string | null;
privateKeyEncrypted: string | null;
};
}

Expand Down
96 changes: 44 additions & 52 deletions test/auth/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ describe('# auth service tests', () => {
registerDetails.password = '4';
registerDetails.mnemonic = '5';
registerDetails.salt = '6';
registerDetails.keys.keys.ecc.privateKeyEncrypted = '7';
registerDetails.keys.keys.ecc.publicKey = '8';
registerDetails.keys.keys.kyber.privateKeyEncrypted = '9';
registerDetails.keys.keys.kyber.publicKey = '10';
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';

Expand All @@ -54,12 +54,12 @@ describe('# auth service tests', () => {
revocationKey: registerDetails.keys.revocationCertificate,
keys: {
ecc: {
privateKey: registerDetails.keys.keys.ecc.privateKeyEncrypted,
publicKey: registerDetails.keys.keys.ecc.publicKey,
privateKey: registerDetails.keys.ecc.privateKeyEncrypted,
publicKey: registerDetails.keys.ecc.publicKey,
},
kyber: {
privateKey: registerDetails.keys.keys.kyber.privateKeyEncrypted,
publicKey: registerDetails.keys.keys.kyber.publicKey,
privateKey: registerDetails.keys.kyber.privateKeyEncrypted,
publicKey: registerDetails.keys.kyber.publicKey,
},
},
referral: registerDetails.referral,
Expand Down Expand Up @@ -98,10 +98,10 @@ describe('# auth service tests', () => {
registerDetails.password = '4';
registerDetails.mnemonic = '5';
registerDetails.salt = '6';
registerDetails.keys.keys.ecc.privateKeyEncrypted = '7';
registerDetails.keys.keys.ecc.publicKey = '8';
registerDetails.keys.keys.kyber.privateKeyEncrypted = '9';
registerDetails.keys.keys.kyber.publicKey = '10';
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';

Expand All @@ -128,12 +128,12 @@ describe('# auth service tests', () => {
revocationKey: registerDetails.keys.revocationCertificate,
keys: {
ecc: {
privateKey: registerDetails.keys.keys.ecc.privateKeyEncrypted,
publicKey: registerDetails.keys.keys.ecc.publicKey,
privateKey: registerDetails.keys.ecc.privateKeyEncrypted,
publicKey: registerDetails.keys.ecc.publicKey,
},
kyber: {
privateKey: registerDetails.keys.keys.kyber.privateKeyEncrypted,
publicKey: registerDetails.keys.keys.kyber.publicKey,
privateKey: registerDetails.keys.kyber.privateKeyEncrypted,
publicKey: registerDetails.keys.kyber.publicKey,
},
},
referral: registerDetails.referral,
Expand Down Expand Up @@ -181,15 +181,13 @@ describe('# auth service tests', () => {
privateKeyEncrypted: '',
publicKey: '',
revocationCertificate: '',
keys: {
ecc: {
privateKeyEncrypted: '',
publicKey: '',
},
kyber: {
publicKey: '',
privateKeyEncrypted: '',
},
ecc: {
privateKeyEncrypted: '',
publicKey: '',
},
kyber: {
publicKey: '',
privateKeyEncrypted: '',
},
};
return Promise.resolve(keys);
Expand Down Expand Up @@ -219,15 +217,13 @@ describe('# auth service tests', () => {
privateKeyEncrypted: '',
publicKey: '',
revocationCertificate: '',
keys: {
ecc: {
privateKeyEncrypted: '',
publicKey: '',
},
kyber: {
publicKey: '',
privateKeyEncrypted: '',
},
ecc: {
privateKeyEncrypted: '',
publicKey: '',
},
kyber: {
publicKey: '',
privateKeyEncrypted: '',
},
};
return Promise.resolve(keys);
Expand Down Expand Up @@ -264,15 +260,13 @@ describe('# auth service tests', () => {
privateKeyEncrypted: 'priv',
publicKey: 'pub',
revocationCertificate: 'rev',
keys: {
ecc: {
privateKeyEncrypted: 'priv',
publicKey: 'pub',
},
kyber: {
publicKey: 'pubKyber',
privateKeyEncrypted: 'privKyber',
},
ecc: {
privateKeyEncrypted: 'priv',
publicKey: 'pub',
},
kyber: {
publicKey: 'pubKyber',
privateKeyEncrypted: 'privKyber',
},
};
return Promise.resolve(keys);
Expand Down Expand Up @@ -342,15 +336,13 @@ describe('# auth service tests', () => {
privateKeyEncrypted: 'prik',
publicKey: 'pubk',
revocationCertificate: 'crt',
keys: {
ecc: {
privateKeyEncrypted: 'prik',
publicKey: 'pubk',
},
kyber: {
publicKey: 'pubKyber',
privateKeyEncrypted: 'privKyber',
},
ecc: {
privateKeyEncrypted: 'prik',
publicKey: 'pubk',
},
kyber: {
publicKey: 'pubKyber',
privateKeyEncrypted: 'privKyber',
},
};
const axiosStub = sinon.stub(httpClient, 'patch').resolves({});
Expand Down
16 changes: 7 additions & 9 deletions test/auth/registerDetails.mother.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ export function emptyRegisterDetails(): RegisterDetails {
privateKeyEncrypted: '',
publicKey: '',
revocationCertificate: '',
keys: {
ecc: {
publicKey: '',
privateKeyEncrypted: '',
},
kyber: {
publicKey: '',
privateKeyEncrypted: '',
},
ecc: {
publicKey: '',
privateKeyEncrypted: '',
},
kyber: {
publicKey: '',
privateKeyEncrypted: '',
},
};
return {
Expand Down

0 comments on commit 1cf9599

Please sign in to comment.