@microsoft/useragent-sdk
Version:
SDK for building decentralized identity wallets and enterprise agents.
84 lines (83 loc) • 2.75 kB
TypeScript
import { CryptoSuiteMap } from './CryptoOperations';
import IKeyStore from '../keyStore/IKeyStore';
import { SubtleCrypto } from 'webcrypto-core';
/**
* Utility class to handle all CryptoSuite dependency injection
*/
export default class CryptoFactory {
/**
* The key encryptors
*/
keyEncrypters: CryptoSuiteMap;
/**
* The shared key encryptors
*/
sharedKeyEncrypters: CryptoSuiteMap;
/**
* The symmetric content encryptors
*/
symmetricEncrypter: CryptoSuiteMap;
/**
* The message signer
*/
messageSigners: CryptoSuiteMap;
/**
* The hmac operations
*/
messageAuthenticationCodeSigners: CryptoSuiteMap;
/**
* The digest operations
*/
messageDigests: CryptoSuiteMap;
/**
* Key store used by the CryptoFactory
*/
keyStore: IKeyStore;
/**
* Label for default algorithm
*/
private readonly defaultAlgorithm;
/**
* Constructs a new CryptoRegistry
* @param keyStore used to store private keys
* @param crypto The default subtle crypto for the environment used for dependency injection
*/
constructor(keyStore: IKeyStore, crypto: SubtleCrypto);
/**
* Gets the key encrypter object given the encryption algorithm's name
* @param name The name of the algorithm
* @returns The corresponding crypto API
*/
getKeyEncrypter(name: string): SubtleCrypto;
/**
* Gets the shared key encrypter object given the encryption algorithm's name
* Used for DH algorithms
* @param name The name of the algorithm
* @returns The corresponding crypto API
*/
getSharedKeyEncrypter(name: string): SubtleCrypto;
/**
* Gets the SymmetricEncrypter object given the symmetric encryption algorithm's name
* @param name The name of the algorithm
* @returns The corresponding crypto API
*/
getSymmetricEncrypter(name: string): SubtleCrypto;
/**
* Gets the message signer object given the signing algorithm's name
* @param name The name of the algorithm
* @returns The corresponding crypto API
*/
getMessageSigner(name: string): SubtleCrypto;
/**
* Gets the mac signer object given the signing algorithm's name
* @param name The name of the algorithm
* @returns The corresponding crypto API
*/
getMessageAuthenticationCodeSigners(name: string): SubtleCrypto;
/**
* Gets the message digest object given the digest algorithm's name
* @param name The name of the algorithm
* @returns The corresponding crypto API
*/
getMessageDigest(name: string): SubtleCrypto;
}