@asgardeo/javascript 0.7.3 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,45 +15,48 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
+ import { AuthClientConfig } from './__legacy__/models/client-config';
19
+ import { AgentConfig } from './models/agent';
20
+ import { AuthCodeResponse } from './models/auth-code-response';
18
21
  import { AsgardeoClient } from './models/client';
19
22
  import { Config, SignInOptions, SignOutOptions, SignUpOptions } from './models/config';
23
+ import { Crypto } from './models/crypto';
20
24
  import { EmbeddedFlowExecuteRequestPayload, EmbeddedFlowExecuteResponse } from './models/embedded-flow';
21
- import { EmbeddedSignInFlowHandleRequestPayload } from './models/embedded-signin-flow';
22
25
  import { AllOrganizationsApiResponse, Organization } from './models/organization';
23
26
  import { Storage } from './models/store';
24
27
  import { TokenExchangeRequestConfig, TokenResponse } from './models/token';
25
28
  import { User, UserProfile } from './models/user';
26
- /**
27
- * Base class for implementing Asgardeo clients.
28
- * This class provides the core functionality for managing user authentication and sessions.
29
- *
30
- * @typeParam T - Configuration type that extends Config.
31
- */
32
- declare abstract class AsgardeoJavaScriptClient<T = Config> implements AsgardeoClient<T> {
33
- abstract switchOrganization(organization: Organization, sessionId?: string): Promise<TokenResponse | Response>;
34
- abstract initialize(config: T, storage?: Storage): Promise<boolean>;
35
- abstract reInitialize(config: Partial<T>): Promise<boolean>;
36
- abstract getUser(options?: any): Promise<User>;
37
- abstract getAllOrganizations(options?: any, sessionId?: string): Promise<AllOrganizationsApiResponse>;
38
- abstract getMyOrganizations(options?: any, sessionId?: string): Promise<Organization[]>;
39
- abstract getCurrentOrganization(sessionId?: string): Promise<Organization | null>;
40
- abstract getUserProfile(options?: any): Promise<UserProfile>;
41
- abstract isLoading(): boolean;
42
- abstract isSignedIn(): Promise<boolean>;
43
- abstract updateUserProfile(payload: any, userId?: string): Promise<User>;
44
- abstract getConfiguration(): T;
45
- abstract exchangeToken(config: TokenExchangeRequestConfig, sessionId?: string): Promise<TokenResponse | Response>;
46
- abstract signIn(options?: SignInOptions, sessionId?: string, onSignInSuccess?: (afterSignInUrl: string) => void): Promise<User>;
47
- abstract signIn(payload: EmbeddedSignInFlowHandleRequestPayload, request: Request, sessionId?: string, onSignInSuccess?: (afterSignInUrl: string) => void): Promise<User>;
48
- abstract signInSilently(options?: SignInOptions): Promise<User | boolean>;
49
- abstract signOut(options?: SignOutOptions, afterSignOut?: (afterSignOutUrl: string) => void): Promise<string>;
50
- abstract signOut(options?: SignOutOptions, sessionId?: string, afterSignOut?: (afterSignOutUrl: string) => void): Promise<string>;
51
- abstract signUp(options?: SignUpOptions): Promise<void>;
52
- abstract signUp(payload: EmbeddedFlowExecuteRequestPayload): Promise<EmbeddedFlowExecuteResponse>;
53
- abstract signUp(payload?: unknown): Promise<void> | Promise<EmbeddedFlowExecuteResponse>;
54
- abstract getAccessToken(sessionId?: string): Promise<string>;
55
- abstract clearSession(sessionId?: string): void;
56
- abstract setSession(sessionData: Record<string, unknown>, sessionId?: string): Promise<void>;
57
- abstract decodeJwtToken<R = Record<string, unknown>>(token: string): Promise<R>;
29
+ declare class AsgardeoJavaScriptClient<T = Config> implements AsgardeoClient<T> {
30
+ private cacheStore;
31
+ private cryptoUtils;
32
+ private auth;
33
+ private storageManager;
34
+ private baseURL;
35
+ constructor(config?: AuthClientConfig<T>, cacheStore?: Storage, cryptoUtils?: Crypto);
36
+ switchOrganization(_organization: Organization, _sessionId?: string): Promise<TokenResponse | Response>;
37
+ initialize(_config: T, _storage?: Storage): Promise<boolean>;
38
+ reInitialize(_config: Partial<T>): Promise<boolean>;
39
+ getUser(_options?: any): Promise<User>;
40
+ getAllOrganizations(_options?: any, _sessionId?: string): Promise<AllOrganizationsApiResponse>;
41
+ getMyOrganizations(_options?: any, _sessionId?: string): Promise<Organization[]>;
42
+ getCurrentOrganization(_sessionId?: string): Promise<Organization | null>;
43
+ getUserProfile(_options?: any): Promise<UserProfile>;
44
+ isLoading(): boolean;
45
+ isSignedIn(): Promise<boolean>;
46
+ updateUserProfile(_payload: any, _userId?: string): Promise<User>;
47
+ getConfiguration(): T;
48
+ exchangeToken(_config: TokenExchangeRequestConfig, _sessionId?: string): Promise<TokenResponse | Response>;
49
+ signInSilently(_options?: SignInOptions): Promise<User | boolean>;
50
+ getAccessToken(_sessionId?: string): Promise<string>;
51
+ clearSession(_sessionId?: string): void;
52
+ setSession(_sessionData: Record<string, unknown>, _sessionId?: string): Promise<void>;
53
+ decodeJwtToken<R = Record<string, unknown>>(_token: string): Promise<R>;
54
+ signIn(_options?: SignInOptions): Promise<User>;
55
+ signOut(_options?: SignOutOptions, _sessionIdOrAfterSignOut?: string | ((afterSignOutUrl: string) => void), _afterSignOut?: (afterSignOutUrl: string) => void): Promise<string>;
56
+ signUp(options?: SignUpOptions): Promise<void>;
57
+ signUp(payload: EmbeddedFlowExecuteRequestPayload): Promise<EmbeddedFlowExecuteResponse>;
58
+ getAgentToken(agentConfig: AgentConfig): Promise<TokenResponse>;
59
+ getOBOSignInURL(agentConfig: AgentConfig): Promise<string>;
60
+ getOBOToken(agentConfig: AgentConfig, authCodeResponse: AuthCodeResponse): Promise<TokenResponse>;
58
61
  }
59
62
  export default AsgardeoJavaScriptClient;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ export declare class DefaultCacheStore implements Storage {
19
+ private cache;
20
+ constructor();
21
+ get length(): number;
22
+ getItem(key: string): string | null;
23
+ setItem(key: string, value: string): void;
24
+ removeItem(key: string): void;
25
+ clear(): void;
26
+ key(index: number): string | null;
27
+ setData(key: string, value: string): Promise<void>;
28
+ getData(key: string): Promise<string>;
29
+ removeData(key: string): Promise<void>;
30
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ import { Crypto, JWKInterface } from './models/crypto';
19
+ /**
20
+ * Default implementation of the Crypto interface using the 'jose' library
21
+ * and the native Web Crypto API.
22
+ */
23
+ export declare class DefaultCrypto implements Crypto<Uint8Array> {
24
+ base64URLDecode(value: string): string;
25
+ base64URLEncode(value: Uint8Array): string;
26
+ generateRandomBytes(length: number): Uint8Array;
27
+ hashSha256(data: string): Promise<Uint8Array>;
28
+ verifyJwt(idToken: string, jwk: JWKInterface, algorithms: string[], clientId: string, issuer: string, subject: string, clockTolerance?: number, validateJwtIssuer?: boolean): Promise<boolean>;
29
+ }
@@ -32,7 +32,7 @@ export declare class IsomorphicCrypto<T = any> {
32
32
  *
33
33
  * @returns - code challenge.
34
34
  */
35
- getCodeChallenge(verifier: string): string;
35
+ getCodeChallenge(verifier: string): Promise<string>;
36
36
  /**
37
37
  * Get JWK used for the id_token
38
38
  *
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ import { FlowMetadataResponse, GetFlowMetaRequestConfig } from '../../models/v2/flow-meta-v2';
19
+ /**
20
+ * Fetches aggregated flow metadata from the `GET /flow/meta` endpoint.
21
+ *
22
+ * The response includes:
23
+ * - Application or OU details depending on the `type` parameter
24
+ * - Resolved design configuration (theme and layout)
25
+ * - i18n translations filtered by `language` and `namespace`
26
+ * - Registration flow enablement status
27
+ *
28
+ * @param config - Request configuration including `baseUrl`/`url`, `type`, `id`,
29
+ * and optional `language` / `namespace` filters.
30
+ * @returns A promise that resolves to the {@link FlowMetadataResponse}.
31
+ *
32
+ * @throws {AsgardeoAPIError} When required parameters are missing or the server
33
+ * returns a non-OK response.
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * import getFlowMetaV2 from './api/v2/getFlowMetaV2';
38
+ * import { FlowMetaType } from './models/v2/flow-meta-v2';
39
+ *
40
+ * const meta = await getFlowMetaV2({
41
+ * baseUrl: 'https://localhost:8090',
42
+ * type: FlowMetaType.App,
43
+ * id: '60a9b38b-6eba-9f9e-55f9-267067de4680',
44
+ * language: 'en',
45
+ * namespace: 'auth',
46
+ * });
47
+ *
48
+ * console.log(meta.application?.name);
49
+ * console.log(meta.i18n.translations);
50
+ * ```
51
+ *
52
+ * @experimental This function targets the Asgardeo V2 platform API
53
+ */
54
+ declare const getFlowMetaV2: ({ url, baseUrl, type, id, language, namespace, ...requestConfig }: GetFlowMetaRequestConfig) => Promise<FlowMetadataResponse>;
55
+ export default getFlowMetaV2;