diff --git a/src/keystore.ts b/src/keystore.ts index e933a0d..c61b051 100644 --- a/src/keystore.ts +++ b/src/keystore.ts @@ -40,23 +40,19 @@ export class KeyStore { constructor(opts?: KeyStoreOpts) { opts = opts || {} - if (opts.encryption) { - if (!Array.isArray(opts.encryption.keys) || opts.encryption.keys.length === 0) { - throw new Error("keys are required for encryption") - } - } - if (opts.signing) { - if (!Array.isArray(opts.signing.keys) || opts.signing.keys.length === 0) { - throw new Error("keys are required for signing") - } - } + this.encryption = Object.assign({ algorithm: 'aes-192-ccm', authTagLength: 16, - encoding: 'hex', keys: [] + encoding: 'hex', + keys: [] }, opts.encryption || {} as any) - this.signing = Object.assign({encoding: 'base64', algorithm: 'sha1', keys: []}, opts.signing || {} as any) + this.signing = Object.assign({ + encoding: 'base64', + algorithm: 'sha1', + keys: [] + }, opts.signing || {} as any) } diff --git a/tests/keystore.spec.ts b/tests/keystore.spec.ts index a26289a..71c51a1 100644 --- a/tests/keystore.spec.ts +++ b/tests/keystore.spec.ts @@ -13,38 +13,6 @@ describe('[constructor]', () => { new KeyStore(null) }) - it('should check encryption keys', () => { - expect(() => { - // @ts-expect-error - new KeyStore({encryption: {}}) - }).toThrow(Error) - - expect(() => { - new KeyStore({encryption: {keys: []}}) - }).toThrow(Error) - - expect(() => { - // @ts-expect-error - new KeyStore({encryption: {keys: {}}}) - }).toThrow(Error) - }) - - it('should check signing keys', () => { - expect(() => { - // @ts-expect-error - new KeyStore({signing: {}}) - }).toThrow(Error) - - expect(() => { - new KeyStore({signing: {keys: []}}) - }).toThrow(Error) - - expect(() => { - // @ts-expect-error - new KeyStore({signing: {keys: {}}}) - }).toThrow(Error) - }) - it('should assign encryption defaults', () => { const ks = new KeyStore({encryption: {keys: [genRandom()]}})