diff --git a/src/auth/index.ts b/src/auth/index.ts index 1bf278c7..db313a5e 100644 --- a/src/auth/index.ts +++ b/src/auth/index.ts @@ -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, @@ -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, @@ -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, } }, }, @@ -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, } }, }, diff --git a/src/auth/types.ts b/src/auth/types.ts index cb182283..ab9c250d 100644 --- a/src/auth/types.ts +++ b/src/auth/types.ts @@ -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; }; } diff --git a/test/auth/index.test.ts b/test/auth/index.test.ts index 3b4c4246..4418cac4 100644 --- a/test/auth/index.test.ts +++ b/test/auth/index.test.ts @@ -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'; @@ -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, @@ -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'; @@ -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, @@ -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); @@ -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); @@ -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); @@ -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({}); diff --git a/test/auth/registerDetails.mother.ts b/test/auth/registerDetails.mother.ts index 6c107d5c..92805e3a 100644 --- a/test/auth/registerDetails.mother.ts +++ b/test/auth/registerDetails.mother.ts @@ -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 {