diff --git a/types/openid-client/index.d.ts b/types/openid-client/index.d.ts index 46db7f9513..820cf947cc 100644 --- a/types/openid-client/index.d.ts +++ b/types/openid-client/index.d.ts @@ -11,7 +11,7 @@ import { IncomingMessage } from 'http'; import { GotOptions } from 'got'; -export { }; // Disable automatic export of all module members (make it explicit) +export {}; // Disable automatic export of all module members (make it explicit) // @@ -19,7 +19,7 @@ type HttpRequestOptions = GotOptions; type CustomHttpOptionsProvider = (options: HttpRequestOptions) => HttpRequestOptions; export const custom: { - readonly http_options: unique symbol, + readonly http_options: unique symbol; }; // https://github.com/panva/node-openid-client/tree/master/docs#issuer @@ -119,6 +119,11 @@ export interface RevokeRequestOptions { readonly clientAssertionPayload?: object; } +export interface RefreshRequestOptions { + readonly exchangeBody?: { readonly [key: string]: string }; + readonly clientAssertionPayload?: { readonly [key: string]: string }; +} + export class Client { static [custom.http_options]: CustomHttpOptionsProvider; @@ -143,7 +148,7 @@ export class Client { readonly nonce?: string; readonly code_verifier?: string; readonly max_age?: number; - } + }, ): Promise; userinfo(accessToken: string | TokenSet): Promise<{ readonly [name: string]: {} | null | undefined }>; @@ -156,7 +161,7 @@ export class Client { introspect( token: string, tokenTypeHint?: string, - extras?: { readonly introspectBody?: object } + extras?: { readonly introspectBody?: object }, ): Promise; /** @@ -167,6 +172,13 @@ export class Client { * @param extras Additional revoke options */ revoke(token: string, tokenTypeHint: string, extras?: RevokeRequestOptions): Promise; + + /** + * Refresh your active token + * @param refreshToken The refresh token + * @param opts Additional options + */ + refresh(refreshToken: string, opts?: RefreshRequestOptions): Promise; } export class TokenSet { @@ -174,6 +186,9 @@ export class TokenSet { readonly token_type?: string; readonly id_token?: string; readonly refresh_token?: string; + readonly expires_at?: number; + readonly expires_in?: number; + readonly [key: string]: unknown; expired(): boolean; diff --git a/types/openid-client/openid-client-tests.ts b/types/openid-client/openid-client-tests.ts index e5587c643b..5b43efd3fb 100644 --- a/types/openid-client/openid-client-tests.ts +++ b/types/openid-client/openid-client-tests.ts @@ -1,9 +1,5 @@ import { IncomingMessage } from 'http'; -import { - custom, - generators, - Issuer, -} from 'openid-client'; +import { custom, generators, Issuer } from 'openid-client'; async (req: IncomingMessage) => { // Custom HTTP options on the `Issuer` _c'tor_ (e.g. used for `Issuer.discover()`): @@ -111,4 +107,8 @@ async (req: IncomingMessage) => { await client.revoke('token', 'hint'); client.revoke('token', 'hint', {}); client.revoke('token', 'hint', { revokeBody: {}, clientAssertionPayload: {} }); + + await client.refresh('token'); + await client.refresh('token', {}); + await client.refresh('token', { exchangeBody: {}, clientAssertionPayload: {} }); };