MCPcopy Create free account
hub / github.com/PIKACHUIM/CFWorkerACME / createSignedHmacBody

Method createSignedHmacBody

src/http.js:220–228  ·  view source on GitHub ↗

* 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} = {})

Source from the content-addressed store, hash-verified

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

Callers 1

signedRequestMethod · 0.95

Calls 2

prepareSignedBodyMethod · 0.95
updateMethod · 0.45

Tested by

no test coverage detected