Skip to content

Commit

Permalink
fix(oidc-mock-provider): Include nonce in token if present in request M…
Browse files Browse the repository at this point in the history
  • Loading branch information
nirinchev authored Nov 14, 2024
1 parent 29ceeb5 commit 7af0e11
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/oidc-mock-provider/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface TokenMetadata {
// parameters that are defined this way.
client_id: string;
scope: string;
nonce?: string;
}

export type MaybePromise<T> = T | PromiseLike<T>;
Expand Down Expand Up @@ -205,6 +206,7 @@ export class OIDCMockProvider {
code_challenge,
code_challenge_method,
state,
nonce,
} = Object.fromEntries(url.searchParams);
if (response_type !== 'code') {
throw new Error(`unknown response_type ${response_type}`);
Expand All @@ -216,6 +218,7 @@ export class OIDCMockProvider {
scope,
code_challenge,
code_challenge_method,
nonce,
}),
state,
}).toString();
Expand All @@ -235,6 +238,7 @@ export class OIDCMockProvider {
code_challenge,
code_challenge_method,
isDeviceCode,
nonce,
} = this.retrieveFromStorage(device_code ?? code);

if (!isDeviceCode) {
Expand Down Expand Up @@ -267,6 +271,7 @@ export class OIDCMockProvider {
const { access_token, id_token, expires_in } = await this.issueToken({
client_id,
scope,
nonce,
});

// Issue a token response:
Expand Down Expand Up @@ -344,6 +349,7 @@ export class OIDCMockProvider {
scope: metadata.scope,
iss: this.issuer,
aud: metadata.client_id,
nonce: metadata.nonce,
...payload,
};
const makeToken = (payload: Record<string, unknown>) => {
Expand Down

0 comments on commit 7af0e11

Please sign in to comment.