Skip to content

Commit 23f7b49

Browse files
committed
fix: include DPoP Proof "htm" in requestResource if GET is defaulted to
1 parent a917cb6 commit 23f7b49

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/helpers/request.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ module.exports = async function request(options, { accessToken, mTLS = false, DP
7979
opts.headers.DPoP = await this.dpopProof(
8080
{
8181
htu: `${url.origin}${url.pathname}`,
82-
htm: options.method,
82+
htm: options.method || 'GET',
8383
nonce: nonces.get(nonceKey),
8484
},
8585
DPoP,

test/client/dpop.test.js

+21
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,27 @@ describe('DPoP', () => {
418418
const proof = this.httpOpts.headers.DPoP;
419419
const proofJWT = jose.decodeJwt(proof);
420420
expect(proofJWT).to.have.property('ath');
421+
expect(proofJWT).to.have.property('htm', 'POST');
422+
});
423+
424+
it('includes htm when GET is defaulted to', async function () {
425+
const { privateKey } = await jose.generateKeyPair('ES256', { extractable: true });
426+
nock('https://rs.example.com')
427+
.matchHeader('Transfer-Encoding', isUndefined)
428+
.matchHeader('Content-Length', isUndefined)
429+
.get('/resource')
430+
.reply(200, { sub: 'foo' });
431+
432+
await this.client.requestResource('https://rs.example.com/resource', 'foo', {
433+
DPoP: privateKey,
434+
});
435+
436+
expect(this.httpOpts).to.have.nested.property('headers.DPoP');
437+
438+
const proof = this.httpOpts.headers.DPoP;
439+
const proofJWT = jose.decodeJwt(proof);
440+
expect(proofJWT).to.have.property('ath');
441+
expect(proofJWT).to.have.property('htm', 'GET');
421442
});
422443

423444
it('is enabled for grant', async function () {

0 commit comments

Comments
 (0)