CryptoProvider class

This class implements MSAL node's crypto interface, which allows it to perform base64 encoding and decoding, generating cryptographically random GUIDs and implementing Proof Key for Code Exchange specs for the OAuth Authorization Code Flow using PKCE (rfc here: https://tools.ietf.org/html/rfc7636).

Constructors

CryptoProvider()

Methods

base64Decode(string)

Decodes input string from base64.

base64Encode(string)

Encodes input string to base64.

clearKeystore()

Removes all cryptographic keys from Keystore

createNewGuid()

Creates a new random GUID - used to populate state and nonce.

generatePkceCodes()

Generates PKCE codes used in Authorization Code Flow.

getPublicKeyThumbprint()

Generates a keypair, stores it and returns a thumbprint - not yet implemented for node

hashString(string)

Returns the SHA-256 hash of an input string

removeTokenBindingKey()

Removes cryptographic keypair from key store matching the keyId passed in

signJwt()

Signs the given object as a jwt payload with private key retrieved by given kid - currently not implemented for node

Constructor Details

CryptoProvider()

new CryptoProvider()

Method Details

base64Decode(string)

Decodes input string from base64.

function base64Decode(input: string): string

Parameters

input

string

string to be decoded

Returns

string

base64Encode(string)

Encodes input string to base64.

function base64Encode(input: string): string

Parameters

input

string

string to be encoded

Returns

string

clearKeystore()

Removes all cryptographic keys from Keystore

function clearKeystore(): Promise<boolean>

Returns

Promise<boolean>

createNewGuid()

Creates a new random GUID - used to populate state and nonce.

function createNewGuid(): string

Returns

string

string (GUID)

generatePkceCodes()

Generates PKCE codes used in Authorization Code Flow.

function generatePkceCodes(): Promise<PkceCodes>

Returns

Promise<PkceCodes>

getPublicKeyThumbprint()

Generates a keypair, stores it and returns a thumbprint - not yet implemented for node

function getPublicKeyThumbprint(): Promise<string>

Returns

Promise<string>

hashString(string)

Returns the SHA-256 hash of an input string

function hashString(plainText: string): Promise<string>

Parameters

plainText

string

Returns

Promise<string>

removeTokenBindingKey()

Removes cryptographic keypair from key store matching the keyId passed in

function removeTokenBindingKey(): Promise<boolean>

Returns

Promise<boolean>

signJwt()

Signs the given object as a jwt payload with private key retrieved by given kid - currently not implemented for node

function signJwt(): Promise<string>

Returns

Promise<string>