* Create JWS HTTP request body using HMAC * * @param {string} hmacKey HMAC key * @param {string} url Request URL * @param {object} [payload] Request payload * @param {object} [opts] * @param {string} [opts.nonce] JWS anti-replay nonce * @param {string} [opts.kid] J
(hmacKey, url, payload = null, {nonce = null, kid = null} = {})
| 218 | */ |
| 219 | |
| 220 | createSignedHmacBody(hmacKey, url, payload = null, {nonce = null, kid = null} = {}) { |
| 221 | const result = this.prepareSignedBody('HS256', url, payload, {nonce, kid}); |
| 222 | |
| 223 | /* Signature */ |
| 224 | const signer = createHmac('SHA256', Buffer.from(hmacKey, 'base64')).update(`${result.protected}.${result.payload}`, 'utf8'); |
| 225 | result.signature = signer.digest().toString('base64url'); |
| 226 | |
| 227 | return result; |
| 228 | } |
| 229 | |
| 230 | /** |
| 231 | * Create JWS HTTP request body using RSA or ECC |
no test coverage detected