@microsoft/useragent-sdk
Version:
SDK for building decentralized identity wallets and enterprise agents.
37 lines (36 loc) • 1.59 kB
TypeScript
import CryptoFactory from '../plugin/CryptoFactory';
import PublicKey from '../keys/PublicKey';
import { CryptoAlgorithm } from '../keyStore/IKeyStore';
import { SubtleCrypto } from 'webcrypto-core';
/**
* Crypto helpers support for plugable crypto layer
*/
export default class CryptoHelpers {
/**
* The API which implements the requested algorithm
* @param cryptoFactory Crypto suite
* @param algorithmName Requested algorithm
* @param hash Optional hash for the algorithm
*/
static getSubtleCryptoForAlgorithm(cryptoFactory: CryptoFactory, algorithm: any): SubtleCrypto;
/**
* Map the JWA algorithm to the W3C crypto API algorithm.
* The method restricts the supported algorithms. This can easily be extended.
* Based on https://www.w3.org/TR/WebCryptoAPI/ A. Mapping between JSON Web Key / JSON Web Algorithm
* @param jwaAlgorithmName Requested algorithm
*/
static jwaToWebCrypto(jwa: string, ...args: any): any;
/**
* Maps the subtle crypto algorithm name to the JWA name
* @param algorithmName Requested algorithm
* @param hash Optional hash for the algorithm
*/
static webCryptoToJwa(algorithm: any): string;
/**
* Derive the key import algorithm
* @param algorithm used for signature
*/
static getKeyImportAlgorithm(algorithm: CryptoAlgorithm, jwk: PublicKey | JsonWebKey): string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams;
private static getHash;
private static getRegexMatch;
}