@microsoft/useragent-sdk
Version:
SDK for building decentralized identity wallets and enterprise agents.
31 lines • 1.79 kB
JavaScript
;
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
// tslint:disable-next-line: import-name
const KeyUseFactory_1 = require("../../../src/crypto/keys/KeyUseFactory");
describe('KeyUseFactory', () => {
it(`should return the key use of signature for 'hmac'`, () => {
const alg = { name: 'hmac' };
expect(KeyUseFactory_1.default.createViaWebCrypto(alg)).toBe(KeyUseFactory_1.KeyUse.Signature);
});
it(`should return the key use of signature for 'ecdsa'`, () => {
const alg = { name: 'ecdsa' };
expect(KeyUseFactory_1.default.createViaWebCrypto(alg)).toBe(KeyUseFactory_1.KeyUse.Signature);
});
it(`should return the key use of encryption for 'ecdh'`, () => {
const alg = { name: 'ecdh' };
expect(KeyUseFactory_1.default.createViaWebCrypto(alg)).toBe(KeyUseFactory_1.KeyUse.Encryption);
});
it(`should return the key use of signature for 'rsassa-pkcs1-v1_5'`, () => {
const alg = { name: 'rsassa-pkcs1-v1_5' };
expect(KeyUseFactory_1.default.createViaWebCrypto(alg)).toBe(KeyUseFactory_1.KeyUse.Signature);
});
it('should throw on unsupported algorithm', () => {
const alg = { name: 'xxx' };
expect(() => KeyUseFactory_1.default.createViaWebCrypto(alg)).toThrowError(`The algorithm 'xxx' is not supported`);
});
});
//# sourceMappingURL=KeyUseFactory.spec.js.map