UNPKG

@microsoft/useragent-sdk

Version:

SDK for building decentralized identity wallets and enterprise agents.

52 lines 2.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ const CryptoFactory_1 = require("./crypto/plugin/CryptoFactory"); const SubtleCryptoBrowser_1 = require("./crypto/plugin/SubtleCryptoBrowser"); const KeyStoreInMemory_1 = require("./crypto/keyStore/KeyStoreInMemory"); const JoseProtocol_1 = require("./crypto/protocols/jose/JoseProtocol"); const _1 = require("."); /** * Class used to model crypto options */ class CryptoOptions { /** * Instanciate a new instance of @class CrytoOptions * @param cryptoFactory Optional parameter specifying the crypto factory */ constructor(cryptoFactory) { this.subtle = () => { let subtleCrypto; try { subtleCrypto = SubtleCryptoBrowser_1.default.getSubtleCrypto(); } catch (_a) { subtleCrypto = _1.SubtleCryptoNode.getSubtleCrypto(); } return subtleCrypto; }; /** * Get or set the payload protection protocol. */ this.payloadProtection = new JoseProtocol_1.default(); /** * Get or set the signing algorithm. */ this.signingAlgorithm = 'ES256K'; /** * Get or set the encryption algorithm. */ this.encryptionAlgorithm = 'RSA-OAEP'; if (cryptoFactory) { this.cryptoFactory = cryptoFactory; } else { this.cryptoFactory = new CryptoFactory_1.default(new KeyStoreInMemory_1.default(), this.subtle()); } } } exports.default = CryptoOptions; //# sourceMappingURL=CryptoOptions.js.map