@asgardeo/react
Version:
React implementation of Asgardeo JavaScript SDK.
67 lines (66 loc) • 3.82 kB
TypeScript
/**
* Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. 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 { AsgardeoBrowserClient, UserProfile, SignInOptions, SignOutOptions, User, EmbeddedFlowExecuteResponse, SignUpOptions, EmbeddedFlowExecuteRequestPayload, EmbeddedSignInFlowHandleRequestPayload, Organization, IdToken, EmbeddedFlowExecuteRequestConfig, AllOrganizationsApiResponse, TokenResponse, HttpRequestConfig, HttpResponse, Storage, TokenExchangeRequestConfig } from '@asgardeo/browser';
import { AsgardeoReactConfig } from './models/config';
/**
* Client for mplementing Asgardeo in React applications.
* This class provides the core functionality for managing user authentication and sessions.
*
* @typeParam T - Configuration type that extends AsgardeoReactConfig.
*/
declare class AsgardeoReactClient<T extends AsgardeoReactConfig = AsgardeoReactConfig> extends AsgardeoBrowserClient<T> {
private asgardeo;
private _isLoading;
constructor();
/**
* Set the loading state of the client
* @param loading - Boolean indicating if the client is in a loading state
*/
private setLoading;
/**
* Wrap async operations with loading state management
* @param operation - The async operation to execute
* @returns Promise with the result of the operation
*/
private withLoading;
initialize(config: AsgardeoReactConfig, storage?: Storage): Promise<boolean>;
updateUserProfile(payload: any, userId?: string): Promise<User>;
getUser(options?: any): Promise<User>;
getDecodedIdToken(sessionId?: string): Promise<IdToken>;
getUserProfile(options?: any): Promise<UserProfile>;
getMyOrganizations(options?: any, sessionId?: string): Promise<Organization[]>;
getAllOrganizations(options?: any, sessionId?: string): Promise<AllOrganizationsApiResponse>;
getCurrentOrganization(): Promise<Organization | null>;
switchOrganization(organization: Organization, sessionId?: string): Promise<TokenResponse | Response>;
isLoading(): boolean;
isInitialized(): Promise<boolean>;
isSignedIn(): Promise<boolean>;
getConfiguration(): T;
exchangeToken(config: TokenExchangeRequestConfig, sessionId?: string): Promise<TokenResponse | Response>;
signIn(options?: SignInOptions, sessionId?: string, onSignInSuccess?: (afterSignInUrl: string) => void): Promise<User>;
signIn(payload: EmbeddedSignInFlowHandleRequestPayload, request: EmbeddedFlowExecuteRequestConfig, sessionId?: string, onSignInSuccess?: (afterSignInUrl: string) => void): Promise<User>;
signInSilently(options?: SignInOptions): Promise<User | boolean>;
signOut(options?: SignOutOptions, afterSignOut?: (afterSignOutUrl: string) => void): Promise<string>;
signOut(options?: SignOutOptions, sessionId?: string, afterSignOut?: (afterSignOutUrl: string) => void): Promise<string>;
signUp(options?: SignUpOptions): Promise<void>;
signUp(payload: EmbeddedFlowExecuteRequestPayload): Promise<EmbeddedFlowExecuteResponse>;
request(requestConfig?: HttpRequestConfig): Promise<HttpResponse<any>>;
requestAll(requestConfigs?: HttpRequestConfig[]): Promise<HttpResponse<any>[]>;
getAccessToken(sessionId?: string): Promise<string>;
}
export default AsgardeoReactClient;