UNPKG

expresspayments

Version:
32 lines (31 loc) 1.47 kB
/** * Interface encapsulating the various crypto computations used by the library, * allowing pluggable underlying crypto implementations. */ export class CryptoProvider { /** * Computes an SHA-256 HMAC given a secret and a payload (encoded in UTF-8). * The output HMAC should be encoded in hexadecimal. * * Sample values for implementations: * - computeHMACSignature('', 'test_secret') => 'f7f9bd47fb987337b5796fdc1fdb9ba221d0d5396814bfcaf9521f43fd8927fd' * - computeHMACSignature('\ud83d\ude00', 'test_secret') => '837da296d05c4fe31f61d5d7ead035099d9585a5bcde87de952012a78f0b0c43 */ computeHMACSignature(payload, secret) { throw new Error('computeHMACSignature not implemented.'); } /** * Asynchronous version of `computeHMACSignature`. Some implementations may * only allow support async signature computation. * * Computes an SHA-256 HMAC given a secret and a payload (encoded in UTF-8). * The output HMAC should be encoded in hexadecimal. * * Sample values for implementations: * - computeHMACSignature('', 'test_secret') => 'f7f9bd47fb987337b5796fdc1fdb9ba221d0d5396814bfcaf9521f43fd8927fd' * - computeHMACSignature('\ud83d\ude00', 'test_secret') => '837da296d05c4fe31f61d5d7ead035099d9585a5bcde87de952012a78f0b0c43 */ computeHMACSignatureAsync(payload, secret) { throw new Error('computeHMACSignatureAsync not implemented.'); } }