Sign in

Class: MonoCloudCoreClient

Constructors

Constructor

new MonoCloudCoreClient(partialOptions?: MonoCloudOptions): MonoCloudCoreClient

Parameters

ParameterType
partialOptions?MonoCloudOptions

Returns

MonoCloudCoreClient

Properties

PropertyType
oidcClientMonoCloudOidcClient

Methods

backChannelLogout()

backChannelLogout(request: MonoCloudRequest, response: MonoCloudResponse): Promise<any>

Handles Back-Channel Logout notifications from the identity provider.

Validates the Logout Token and triggers the onBackChannelLogout callback defined in options.

Parameters

ParameterTypeDescription
requestMonoCloudRequestMonoCloud request object.
responseMonoCloudResponseMonoCloud response object.

Returns

Promise<any>

A promise that resolves when the logout notification has been processed.

Throws

MonoCloudValidationError If the logout token is missing or invalid.


callback()

callback(request: MonoCloudRequest, response: MonoCloudResponse, callbackOptions?: CallbackOptions): Promise<any>

Handles the OpenID callback after the user authenticates with MonoCloud.

Processes the authorization code, validates the state and nonce, exchanges the code for tokens, initializes the user session, and performs the final redirect to the application's return URL.

Parameters

ParameterTypeDescription
requestMonoCloudRequestMonoCloud request object.
responseMonoCloudResponseMonoCloud response object.
callbackOptions?CallbackOptionsOptional configuration for the callback handler.

Returns

Promise<any>

A promise that resolves when the callback processing and redirection are complete.

Throws

MonoCloudValidationError If the state is mismatched or tokens are invalid.


destroySession()

destroySession(request: IMonoCloudCookieRequest, response: IMonoCloudCookieResponse): Promise<void>

Destroys the local user session.

Parameters

ParameterTypeDescription
requestIMonoCloudCookieRequestMonoCloud cookie request object.
responseIMonoCloudCookieResponseMonoCloud cookie response object.

Returns

Promise<void>

Remarks

This does not perform federated sign-out. For identity provider sign-out, use signOut handler.


getOptions()

getOptions(): MonoCloudOptionsBase

Returns a copy of the current client configuration options.

Returns

MonoCloudOptionsBase

A copy of the initialized configuration.


getSession()

getSession(request: IMonoCloudCookieRequest, response: IMonoCloudCookieResponse, options?: GetSessionOptions): Promise<MonoCloudSession | undefined>

Retrieves the current user's session data.

Parameters

ParameterTypeDescription
requestIMonoCloudCookieRequestMonoCloud cookie request object.
responseIMonoCloudCookieResponseMonoCloud cookie response object.
options?GetSessionOptionsOptional configuration to control session retrieval behavior.

Returns

Promise<MonoCloudSession | undefined>

Session or undefined.


getTokens()

getTokens(request: IMonoCloudCookieRequest, response: IMonoCloudCookieResponse, options?: GetTokensOptions): Promise<MonoCloudTokens>

Retrieves active tokens (Access, ID, Refresh), performing a refresh if they are expired or missing.

Parameters

ParameterTypeDescription
requestIMonoCloudCookieRequestMonoCloud cookie request object.
responseIMonoCloudCookieResponseMonoCloud cookie response object.
options?GetTokensOptionsConfiguration for token retrieval (force refresh, specific scopes/resources).

Returns

Promise<MonoCloudTokens>

Fetched tokens.

Throws

MonoCloudValidationError If the session does not exist or tokens cannot be found/refreshed.


isAuthenticated()

isAuthenticated(request: IMonoCloudCookieRequest, response: IMonoCloudCookieResponse): Promise<boolean>

Checks if the current request has an active and authenticated session.

Parameters

ParameterTypeDescription
requestIMonoCloudCookieRequestMonoCloud cookie request object.
responseIMonoCloudCookieResponseMonoCloud cookie response object.

Returns

Promise<boolean>

true if a valid session with user data exists, false otherwise.


isUserInGroup()

isUserInGroup(request: IMonoCloudCookieRequest, response: IMonoCloudCookieResponse, groups: string[], groupsClaim?: string, matchAll?: boolean): Promise<boolean>

Checks if the current session user belongs to the specified groups.

Parameters

ParameterTypeDescription
requestIMonoCloudCookieRequestMonoCloud cookie request object.
responseIMonoCloudCookieResponseMonoCloud cookie response object.
groupsstring[]List of group names or IDs to check.
groupsClaim?stringOptional claim name that holds groups. Defaults to "groups".
matchAll?booleanIf true, requires membership in all groups; otherwise any one group is sufficient.

Returns

Promise<boolean>

true if the user satisfies the group condition, false otherwise.


signIn()

signIn(request: MonoCloudRequest, response: MonoCloudResponse, signInOptions?: SignInOptions): Promise<any>

Initiates the sign-in flow by redirecting the user to the MonoCloud authorization endpoint.

This method handles scope and resource merging, state generation (nonce, state, PKCE), and constructing the final authorization URL.

Parameters

ParameterTypeDescription
requestMonoCloudRequestMonoCloud request object.
responseMonoCloudResponseMonoCloud response object.
signInOptions?SignInOptionsConfiguration to customize the sign-in behavior.

Returns

Promise<any>

A promise that resolves when the callback processing and redirection are complete.

Throws

MonoCloudValidationError When validation of parameters or state fails.


signOut()

signOut(request: MonoCloudRequest, response: MonoCloudResponse, signOutOptions?: SignOutOptions): Promise<any>

Initiates the sign-out flow, destroying the local session and optionally performing federated sign-out.

Parameters

ParameterTypeDescription
requestMonoCloudRequestMonoCloud request object.
responseMonoCloudResponseMonoCloud response object.
signOutOptions?SignOutOptionsConfiguration for post-logout behavior and federated sign-out.

Returns

Promise<any>

A promise that resolves when the sign-out redirection is initiated.


updateSession()

updateSession(request: IMonoCloudCookieRequest, response: IMonoCloudCookieResponse, session: MonoCloudSession): Promise<void>

Updates the current user's session with new data.

Parameters

ParameterTypeDescription
requestIMonoCloudCookieRequestMonoCloud cookie request object.
responseIMonoCloudCookieResponseMonoCloud cookie response object.
sessionMonoCloudSessionThe updated session object to persist.

Returns

Promise<void>


userInfo()

userInfo(request: MonoCloudRequest, response: MonoCloudResponse, userinfoOptions?: UserInfoOptions): Promise<any>

Retrieves user information, optionally refetching fresh data from the UserInfo endpoint.

Parameters

ParameterTypeDescription
requestMonoCloudRequestMonoCloud request object.
responseMonoCloudResponseMonoCloud response object.
userinfoOptions?UserInfoOptionsConfiguration to control refetching and error handling.

Returns

Promise<any>

A promise that resolves with the user information sent as a JSON response.

Remarks

If refresh is true, the session is updated with fresh claims from the identity provider.

© 2024 MonoCloud. All rights reserved.