Sign in

Class: MonoCloudOidcClientBase

Constructors

Constructor

new MonoCloudOidcClientBase(tenantDomain: string, metadataCacheDuration?: number, jwksCacheDuration?: number, fetcher?: {(input: URL | RequestInfo, init?: RequestInit): Promise<Response>; (input: string | URL | Request, init?: RequestInit): Promise<Response>; }): MonoCloudOidcClientBase

Creates a new instance of MonoCloudOidcClientBase.

Parameters

ParameterTypeDescription
tenantDomainstringThe tenant domain URL.
metadataCacheDuration?numberDuration (in seconds) to cache OpenID Connect discovery metadata. Defaults to 300 (5 minutes).
jwksCacheDuration?numberDuration (in seconds) to cache the JSON Web Key Set (JWKS). Defaults to 300 (5 minutes).
fetcher?{(input: URL | RequestInfo, init?: RequestInit): Promise<Response>; (input: string | URL | Request, init?: RequestInit): Promise<Response>; }Custom fetch implementation used for making HTTP requests. Falls back to the global fetch if not provided.

Returns

MonoCloudOidcClientBase

Properties

PropertyTypeDescription
fetcher?{(input: URL | RequestInfo, init?: RequestInit): Promise<Response>; (input: string | URL | Request, init?: RequestInit): Promise<Response>; }Custom fetch implementation used for making HTTP requests. Falls back to the global fetch if not provided.
jwks?JwksCached JSON Web Key Set retrieved from the issuer's JWKS endpoint.
jwksCacheDurationnumberDuration (in seconds) for which the JWKS is cached. Defaults to 300 (5 minutes).
jwksCacheExpirynumberTimestamp (in seconds) when the cached JWKS expires.
metadata?IssuerMetadataCached issuer metadata retrieved from the OpenID Connect discovery endpoint.
metadataCacheDurationnumberDuration (in seconds) for which the metadata is cached. Defaults to 300 (5 minutes).
metadataCacheExpirynumberTimestamp (in seconds) when the cached metadata expires.
tenantDomainstringThe normalized tenant domain URL used as the base for discovery endpoints.

Methods

decodeJwt()

static decodeJwt(jwt: string): JwtClaims

Decodes the payload of a JSON Web Token (JWT) and returns it as an object.

Note: THIS METHOD DOES NOT VERIFY JWT TOKENS.

Parameters

ParameterTypeDescription
jwtstringJWT to decode.

Returns

JwtClaims

Decoded payload.

Throws

MonoCloudTokenError - If decoding fails


getJwks()

getJwks(forceRefresh: boolean): Promise<Jwks>

Fetches the JSON Web Keys used to sign the ID token. The JWKS is cached for 5 minutes by default.

Parameters

ParameterTypeDescription
forceRefreshbooleanIf true, bypasses the cache and fetches fresh set of JWKS from the server.

Returns

Promise<Jwks>

The JSON Web Key Set containing the public keys for token verification.

Throws

MonoCloudHttpError - Thrown if there is a network error during the request or unexpected status code during the request or a serialization error while processing the response.


getMetadata()

getMetadata(forceRefresh: boolean): Promise<IssuerMetadata>

Fetches the authorization server metadata from the .well-known endpoint. The metadata is cached for 5 minutes by default.

Parameters

ParameterTypeDescription
forceRefreshbooleanIf true, bypasses the cache and fetches fresh metadata from the server.

Returns

Promise<IssuerMetadata>

The issuer metadata for the tenant, retrieved from the OpenID Connect discovery endpoint.

Throws

MonoCloudHttpError - Thrown if there is a network error during the request or unexpected status code during the request or a serialization error while processing the response.

© 2024 MonoCloud. All rights reserved.