@openid4vc/oauth2 0.6.0-alpha-20260929114029 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -2047,7 +2047,7 @@ async function calculateCodeChallenge(options) {
2047
2047
  //#endregion
2048
2048
  //#region src/access-token/verify-access-token-request.ts
2049
2049
  async function verifyPreAuthorizedCodeAccessTokenRequest(options) {
2050
- if (options.pkce) await verifyAccessTokenRequestPkce(options.pkce, options.callbacks);
2050
+ await verifyAccessTokenRequestPkce(options.pkce, options.accessTokenRequest, options.callbacks);
2051
2051
  const dpopResult = options.dpop ? await verifyAccessTokenRequestDpop(options.dpop, options.request, options.callbacks) : void 0;
2052
2052
  const clientAttestationResult = options.clientAttestation ? await verifyAccessTokenRequestClientAttestation(options.clientAttestation, options.authorizationServerMetadata, options.callbacks, dpopResult?.jwkThumbprint, options.now) : void 0;
2053
2053
  if (options.grant.preAuthorizedCode !== options.expectedPreAuthorizedCode) throw new Oauth2ServerErrorResponseError({
@@ -2081,7 +2081,7 @@ async function verifyPreAuthorizedCodeAccessTokenRequest(options) {
2081
2081
  };
2082
2082
  }
2083
2083
  async function verifyAuthorizationCodeAccessTokenRequest(options) {
2084
- if (options.pkce) await verifyAccessTokenRequestPkce(options.pkce, options.callbacks);
2084
+ await verifyAccessTokenRequestPkce(options.pkce, options.accessTokenRequest, options.callbacks);
2085
2085
  const dpopResult = options.dpop ? await verifyAccessTokenRequestDpop(options.dpop, options.request, options.callbacks) : void 0;
2086
2086
  const clientAttestationResult = options.clientAttestation ? await verifyAccessTokenRequestClientAttestation(options.clientAttestation, options.authorizationServerMetadata, options.callbacks, dpopResult?.jwkThumbprint, options.now) : void 0;
2087
2087
  if (options.grant.code !== options.expectedCode) throw new Oauth2ServerErrorResponseError({
@@ -2101,7 +2101,7 @@ async function verifyAuthorizationCodeAccessTokenRequest(options) {
2101
2101
  };
2102
2102
  }
2103
2103
  async function verifyRefreshTokenAccessTokenRequest(options) {
2104
- if (options.pkce) await verifyAccessTokenRequestPkce(options.pkce, options.callbacks);
2104
+ await verifyAccessTokenRequestPkce(options.pkce, options.accessTokenRequest, options.callbacks);
2105
2105
  const dpopResult = options.dpop ? await verifyAccessTokenRequestDpop(options.dpop, options.request, options.callbacks) : void 0;
2106
2106
  const clientAttestationResult = options.clientAttestation ? await verifyAccessTokenRequestClientAttestation(options.clientAttestation, options.authorizationServerMetadata, options.callbacks, dpopResult?.jwkThumbprint, options.now) : void 0;
2107
2107
  if (options.grant.refreshToken !== options.expectedRefreshToken) throw new Oauth2ServerErrorResponseError({
@@ -2212,9 +2212,16 @@ async function verifyAccessTokenRequestDpop(options, request, callbacks) {
2212
2212
  jwkThumbprint
2213
2213
  };
2214
2214
  }
2215
- async function verifyAccessTokenRequestPkce(options, callbacks) {
2215
+ async function verifyAccessTokenRequestPkce(options, accessTokenRequest, callbacks) {
2216
+ if (!options) {
2217
+ if (accessTokenRequest.code_verifier) throw new Oauth2ServerErrorResponseError({
2218
+ error: "invalid_grant",
2219
+ error_description: `Unexpected 'code_verifier' in access token request, no code challenge is bound to the grant`
2220
+ });
2221
+ return null;
2222
+ }
2216
2223
  if (options.codeChallenge && !options.codeVerifier) throw new Oauth2ServerErrorResponseError({
2217
- error: "invalid_request",
2224
+ error: "invalid_grant",
2218
2225
  error_description: `Missing required 'code_verifier' in access token request`
2219
2226
  });
2220
2227
  if (!options.codeVerifier) return null;