Skip to content

Commit

Permalink
Merge pull request #1258 from MathiasRossen/main
Browse files Browse the repository at this point in the history
Added extraTokenParams to UserManager.signinSilent
  • Loading branch information
pamapa authored Nov 24, 2023
2 parents 3fcc66b + 35faeef commit 8dc1495
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 4 additions & 2 deletions docs/oidc-client-ts.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ export class OidcClient {
// (undocumented)
protected readonly _tokenClient: TokenClient;
// (undocumented)
useRefreshToken({ state, timeoutInSeconds, }: UseRefreshTokenArgs): Promise<SigninResponse>;
useRefreshToken({ state, timeoutInSeconds, extraTokenParams, }: UseRefreshTokenArgs): Promise<SigninResponse>;
// Warning: (ae-forgotten-export) The symbol "ResponseValidator" needs to be exported by the entry point index.d.ts
//
// (undocumented)
Expand Down Expand Up @@ -926,6 +926,8 @@ export class User {

// @public (undocumented)
export interface UseRefreshTokenArgs {
// (undocumented)
extraTokenParams?: Record<string, unknown>;
// (undocumented)
state: RefreshState;
// (undocumented)
Expand Down Expand Up @@ -1003,7 +1005,7 @@ export class UserManager {
// (undocumented)
storeUser(user: User | null): Promise<void>;
// (undocumented)
protected _useRefreshToken(state: RefreshState): Promise<User>;
protected _useRefreshToken(args: UseRefreshTokenArgs): Promise<User>;
// (undocumented)
protected get _userStoreKey(): string;
}
Expand Down
3 changes: 3 additions & 0 deletions src/OidcClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export interface CreateSigninRequestArgs
export interface UseRefreshTokenArgs {
state: RefreshState;
timeoutInSeconds?: number;
extraTokenParams?: Record<string, unknown>;
}

/**
Expand Down Expand Up @@ -185,6 +186,7 @@ export class OidcClient {
public async useRefreshToken({
state,
timeoutInSeconds,
extraTokenParams,
}: UseRefreshTokenArgs): Promise<SigninResponse> {
const logger = this._logger.create("useRefreshToken");

Expand All @@ -207,6 +209,7 @@ export class OidcClient {
// provide the (possible filtered) scope list
scope,
timeoutInSeconds,
...extraTokenParams,
});
const response = new SigninResponse(new URLSearchParams());
Object.assign(response, result);
Expand Down
10 changes: 5 additions & 5 deletions src/UserManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { Logger } from "./utils";
import { ErrorResponse } from "./errors";
import { type NavigateResponse, type PopupWindowParams, type IWindow, type IFrameWindowParams, type RedirectParams, RedirectNavigator, PopupNavigator, IFrameNavigator, type INavigator } from "./navigators";
import { OidcClient, type CreateSigninRequestArgs, type CreateSignoutRequestArgs, type ProcessResourceOwnerPasswordCredentialsArgs } from "./OidcClient";
import { OidcClient, type CreateSigninRequestArgs, type CreateSignoutRequestArgs, type ProcessResourceOwnerPasswordCredentialsArgs, type UseRefreshTokenArgs } from "./OidcClient";
import { type UserManagerSettings, UserManagerSettingsStore } from "./UserManagerSettings";
import { User } from "./User";
import { UserManagerEvents } from "./UserManagerEvents";
Expand Down Expand Up @@ -290,7 +290,7 @@ export class UserManager {
if (user?.refresh_token) {
logger.debug("using refresh token");
const state = new RefreshState(user as Required<User>, resource);
return await this._useRefreshToken(state);
return await this._useRefreshToken({ state, extraTokenParams: requestArgs.extraTokenParams });
}

const url = this.settings.silent_redirect_uri;
Expand Down Expand Up @@ -324,12 +324,12 @@ export class UserManager {
return user;
}

protected async _useRefreshToken(state: RefreshState): Promise<User> {
protected async _useRefreshToken(args: UseRefreshTokenArgs): Promise<User> {
const response = await this._client.useRefreshToken({
state,
...args,
timeoutInSeconds: this.settings.silentRequestTimeoutInSeconds,
});
const user = new User({ ...state, ...response });
const user = new User({ ...args.state, ...response });

await this.storeUser(user);
this._events.load(user);
Expand Down

0 comments on commit 8dc1495

Please sign in to comment.