UNPKG

@microsoft/useragent-sdk

Version:

SDK for building decentralized identity wallets and enterprise agents.

35 lines (28 loc) 1.5 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ // tslint:disable-next-line: import-name import KeyUseFactory, { KeyUse } from '../../../src/crypto/keys/KeyUseFactory'; describe('KeyUseFactory', () => { it(`should return the key use of signature for 'hmac'`, () => { const alg = { name: 'hmac' }; expect(KeyUseFactory.createViaWebCrypto(alg)).toBe(KeyUse.Signature); }); it(`should return the key use of signature for 'ecdsa'`, () => { const alg = { name: 'ecdsa' }; expect(KeyUseFactory.createViaWebCrypto(alg)).toBe(KeyUse.Signature); }); it(`should return the key use of encryption for 'ecdh'`, () => { const alg = { name: 'ecdh' }; expect(KeyUseFactory.createViaWebCrypto(alg)).toBe(KeyUse.Encryption); }); it(`should return the key use of signature for 'rsassa-pkcs1-v1_5'`, () => { const alg = { name: 'rsassa-pkcs1-v1_5' }; expect(KeyUseFactory.createViaWebCrypto(alg)).toBe(KeyUse.Signature); }); it('should throw on unsupported algorithm', () => { const alg = { name: 'xxx' }; expect(() => KeyUseFactory.createViaWebCrypto(alg)).toThrowError(`The algorithm 'xxx' is not supported`); }); });