Skip to content

Commit 4491f70

Browse files
committed
refactor(passport): allow dpop handle to be retrieved with an async function
1 parent b536d0a commit 4491f70

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/passport.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ export type VerifyFunctionWithRequest = (
2626
/**
2727
* Retrieve an openid-client DPoPHandle for a given request.
2828
*/
29-
export type getDPoPHandle = (req: express.Request) => client.DPoPHandle
29+
export type getDPoPHandle = (
30+
req: express.Request,
31+
) => Promise<client.DPoPHandle | undefined> | client.DPoPHandle | undefined
3032

3133
interface StrategyOptionsBase {
3234
/**
@@ -256,7 +258,7 @@ export class Strategy implements passport.Strategy {
256258
redirectTo.searchParams.set('scope', this._scope)
257259
}
258260

259-
const DPoP = this._DPoP?.(req)
261+
const DPoP = await this._DPoP?.(req)
260262

261263
if (DPoP && !redirectTo.searchParams.has('dpop_jkt')) {
262264
redirectTo.searchParams.set(
@@ -366,7 +368,7 @@ export class Strategy implements passport.Strategy {
366368
maxAge: stateData.max_age,
367369
},
368370
this.authorizationCodeGrantParameters(req, options),
369-
{ DPoP: this._DPoP?.(req) },
371+
{ DPoP: await this._DPoP?.(req) },
370372
)
371373

372374
const verified: passport.AuthenticateCallback = (err, user, info) => {

0 commit comments

Comments
 (0)