UNPKG

@asgardeo/browser

Version:

Browser-specific implementation of Asgardeo JavaScript SDK.

59 lines (58 loc) 4.46 kB
/** * Copyright (c) 2022-2024, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import { AsgardeoAuthClient, AuthClientConfig, User, IsomorphicCrypto, TokenExchangeRequestConfig, StorageManager, IdToken, ExtendedAuthorizeRequestUrlParams, OIDCEndpoints } from '@asgardeo/javascript'; import { SPAHelper } from './spa-helper'; import { HttpClientInstance, HttpError, HttpRequestConfig, HttpRequestInterface, HttpResponse, MainThreadClientConfig, SessionManagementHelperInterface, WebWorkerClientConfig } from '../models'; import { SPACustomGrantConfig } from '../models/request-custom-grant'; export declare class AuthenticationHelper<T extends MainThreadClientConfig | WebWorkerClientConfig> { protected _authenticationClient: AsgardeoAuthClient<T>; protected _storageManager: StorageManager<T>; protected _spaHelper: SPAHelper<T>; protected _instanceID: number; protected _isTokenRefreshing: boolean; constructor(authClient: AsgardeoAuthClient<T>, spaHelper: SPAHelper<T>); enableHttpHandler(httpClient: HttpClientInstance): void; disableHttpHandler(httpClient: HttpClientInstance): void; initializeSessionManger(config: AuthClientConfig<T>, oidcEndpoints: OIDCEndpoints, getSessionState: () => Promise<string>, getAuthzURL: (params?: ExtendedAuthorizeRequestUrlParams) => Promise<string>, sessionManagementHelper: SessionManagementHelperInterface): void; exchangeToken(config: SPACustomGrantConfig, enableRetrievingSignOutURLFromSession?: (config: SPACustomGrantConfig) => void): Promise<User | Response>; getCustomGrantConfigData(): Promise<AuthClientConfig<TokenExchangeRequestConfig> | null>; refreshAccessToken(enableRetrievingSignOutURLFromSession?: (config: SPACustomGrantConfig) => void): Promise<User>; protected retryFailedRequests(failedRequest: HttpRequestInterface): Promise<HttpResponse>; httpRequest(httpClient: HttpClientInstance, requestConfig: HttpRequestConfig, isHttpHandlerEnabled?: boolean, httpErrorCallback?: (error: HttpError) => void | Promise<void>, httpFinishCallback?: () => void, enableRetrievingSignOutURLFromSession?: (config: SPACustomGrantConfig) => void): Promise<HttpResponse>; httpRequestAll(requestConfigs: HttpRequestConfig[], httpClient: HttpClientInstance, isHttpHandlerEnabled?: boolean, httpErrorCallback?: (error: HttpError) => void | Promise<void>, httpFinishCallback?: () => void): Promise<HttpResponse[] | undefined>; requestAccessToken(authorizationCode?: string, sessionState?: string, checkSession?: () => Promise<void>, pkce?: string, state?: string, tokenRequestConfig?: { params: Record<string, unknown>; }): Promise<User>; signInSilently(constructSilentSignInUrl: (additionalParams?: Record<string, string | boolean>) => Promise<string>, requestAccessToken: (authzCode: string, sessionState: string, state: string, tokenRequestConfig?: { params: Record<string, unknown>; }) => Promise<User>, sessionManagementHelper: SessionManagementHelperInterface, additionalParams?: Record<string, string | boolean>, tokenRequestConfig?: { params: Record<string, unknown>; }): Promise<User | boolean>; handleSignIn(shouldStopAuthn: () => Promise<boolean>, checkSession: () => Promise<void>, tryRetrievingUserInfo?: () => Promise<User | undefined>): Promise<User | undefined>; attachTokenToRequestConfig(request: HttpRequestConfig): Promise<void>; getUser(): Promise<User>; getDecodedIdToken(sessionId?: string): Promise<IdToken>; getDecodedIDPIDToken(): Promise<IdToken>; getCrypto(): Promise<IsomorphicCrypto>; getIdToken(): Promise<string>; getOpenIDProviderEndpoints(): Promise<OIDCEndpoints>; getAccessToken(sessionId?: string): Promise<string>; getIDPAccessToken(): Promise<string>; getStorageManager(): StorageManager<T>; isSignedIn(): Promise<boolean>; }