@azure/msal-browser
Version:
Microsoft Authentication Library for js
144 lines • 5.5 kB
TypeScript
import { IPerformanceClient, Logger } from "@azure/msal-common/browser";
export declare const RSA_KEYGEN_ALGORITHM_OPTIONS: RsaHashedKeyGenParams;
export declare const RSA_SIGN_ALGORITHM_OPTIONS: Algorithm;
export declare const ECDSA_P256_KEYGEN_ALGORITHM_OPTIONS: EcKeyGenParams;
export declare const ECDSA_SHA256_SIGN_ALGORITHM_OPTIONS: EcdsaParams;
/**
* Check whether browser crypto is available.
*/
export declare function validateCryptoAvailable(skipValidateSubtleCrypto: boolean): void;
/**
* Returns a sha-256 hash of the given dataString as an ArrayBuffer.
* @param dataString {string} data string
* @param performanceClient {?IPerformanceClient}
* @param correlationId {?string} correlation id
*/
export declare function sha256Digest(dataString: string): Promise<ArrayBuffer>;
/**
* Populates buffer with cryptographically random values.
* @param dataBuffer
*/
export declare function getRandomValues(dataBuffer: Uint8Array): Uint8Array;
/**
* Creates a UUID v7 from the current timestamp.
* Implementation relies on the system clock to guarantee increasing order of generated identifiers.
* @returns {number}
*/
export declare function createNewGuid(): string;
/**
* Generates a keypair based on the provided algorithm config.
* @param extractable
* @param usages
* @param algorithm
*/
export declare function generateKeyPair(extractable: boolean, usages: Array<KeyUsage>, algorithm: AlgorithmIdentifier): Promise<CryptoKeyPair>;
/**
* Export key as Json Web Key (JWK)
* @param key
*/
export declare function exportJwk(key: CryptoKey): Promise<JsonWebKey>;
/**
* Imports key as Json Web Key (JWK), can set extractable and usages.
* @param key
* @param extractable
* @param usages
* @param algorithm
*/
export declare function importJwk(key: JsonWebKey, extractable: boolean, usages: Array<KeyUsage>, algorithm: AlgorithmIdentifier): Promise<CryptoKey>;
/**
* Signs given data with given key.
* @param key
* @param data
* @param algorithm
*/
export declare function sign(key: CryptoKey, data: BufferSource, algorithm: AlgorithmIdentifier): Promise<ArrayBuffer>;
/**
* Generates Base64 encoded jwk used in the Encrypted Authorize Response (EAR) flow
*/
export declare function generateEarKey(): Promise<string>;
/**
* Local asymmetric EAR key material, separate from serializable request metadata.
* @internal
*/
export type AsymmetricEarKey = {
privateJwk: JsonWebKey;
publicJwk: JsonWebKey;
};
/**
* Generates P-384 ECDH keys for request-scoped private sessionStorage and public wire metadata.
* @internal
*/
export declare function generateAsymmetricEarKey(): Promise<AsymmetricEarKey>;
/**
* Restores a private EAR key as non-exportable. The serialized sessionStorage copy remains exportable.
* @internal
*/
export declare function importAsymmetricEarKey(privateJwk: JsonWebKey, correlationId?: string): Promise<CryptoKey>;
/**
* Encodes the EAR client party information with a fresh 192-bit nonce.
* @internal
*/
export declare function generateAsymmetricEarApv(publicJwk: JsonWebKey): string;
/**
* Authenticates and decrypts direct ECDH-ES/P-384/A256GCM using JOSE Concat KDF.
* Party information is used byte-for-byte; the service need not echo the request APV.
* @internal
*/
export declare function decryptAsymmetricEarResponse(privateJwk: JsonWebKey, apv: string, earJwe: string, requestApv?: string, telemetry?: {
logger: Logger;
performanceClient: IPerformanceClient;
correlationId: string;
}): Promise<string>;
/**
* Parses earJwk for encryption key and returns CryptoKey object
* @param earJwk
* @returns
*/
export declare function importEarKey(earJwk: string): Promise<CryptoKey>;
/**
* Decrypt ear_jwe response returned in the Encrypted Authorize Response (EAR) flow
* @param earJwk
* @param earJwe
* @returns
*/
export declare function decryptEarResponse(earJwk: string, earJwe: string): Promise<string>;
/**
* Generates symmetric base encryption key. This may be stored as all encryption/decryption keys will be derived from this one.
*/
export declare function generateBaseKey(): Promise<ArrayBuffer>;
/**
* Returns the raw key to be passed into the key derivation function
* @param baseKey
* @returns
*/
export declare function generateHKDF(baseKey: ArrayBuffer): Promise<CryptoKey>;
/**
* Encrypt the given data given a base key. Returns encrypted data and a nonce that must be provided during decryption
* @param key
* @param rawData
*/
export declare function encrypt(baseKey: CryptoKey, rawData: string, context: string): Promise<{
data: string;
nonce: string;
}>;
/**
* Decrypt data with the given key and nonce
* @param key
* @param nonce
* @param encryptedData
* @returns
*/
export declare function decrypt(baseKey: CryptoKey, nonce: string, context: string, encryptedData: string): Promise<string>;
/**
* Returns the SHA-256 hash of an input string
* @param plainText
*/
export declare function hashString(plainText: string): Promise<string>;
/**
* Computes an RFC 7638 JWK thumbprint for a public key.
* The required members for the JWK key type are serialised in lexicographic order
* and the SHA-256 digest is returned as a base64url string.
* @internal
*/
export declare function computeJwkThumbprint(publicJwk: JsonWebKey, correlationId: string): Promise<string>;
//# sourceMappingURL=BrowserCrypto.d.ts.map