@asgardeo/javascript 0.1.1 → 0.1.3
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.
- package/dist/AsgardeoJavaScriptClient.d.ts +9 -5
- package/dist/api/getAllOrganizations.d.ts +2 -11
- package/dist/api/getBrandingPreference.d.ts +103 -0
- package/dist/cjs/index.js +690 -62
- package/dist/cjs/index.js.map +4 -4
- package/dist/index.d.ts +8 -2
- package/dist/index.js +686 -62
- package/dist/index.js.map +4 -4
- package/dist/models/branding-preference.d.ts +248 -0
- package/dist/models/client.d.ts +10 -6
- package/dist/models/config.d.ts +18 -0
- package/dist/models/i18n.d.ts +10 -0
- package/dist/models/organization.d.ts +9 -0
- package/dist/theme/createTheme.d.ts +17 -1
- package/dist/theme/types.d.ts +212 -1
- package/dist/utils/deriveOrganizationHandleFromBaseUrl.d.ts +47 -0
- package/dist/utils/processUsername.d.ts +73 -0
- package/dist/utils/transformBrandingPreferenceToTheme.d.ts +48 -0
- package/package.json +1 -1
|
@@ -15,10 +15,12 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
+
import { AllOrganizationsApiResponse } from './models/organization';
|
|
18
19
|
import { AsgardeoClient, SignInOptions, SignOutOptions, SignUpOptions } from './models/client';
|
|
19
20
|
import { Config } from './models/config';
|
|
20
21
|
import { EmbeddedFlowExecuteRequestPayload, EmbeddedFlowExecuteResponse } from './models/embedded-flow';
|
|
21
22
|
import { EmbeddedSignInFlowHandleRequestPayload } from './models/embedded-signin-flow';
|
|
23
|
+
import { TokenResponse } from './models/token';
|
|
22
24
|
import { Organization } from './models/organization';
|
|
23
25
|
import { User, UserProfile } from './models/user';
|
|
24
26
|
/**
|
|
@@ -28,14 +30,16 @@ import { User, UserProfile } from './models/user';
|
|
|
28
30
|
* @typeParam T - Configuration type that extends Config.
|
|
29
31
|
*/
|
|
30
32
|
declare abstract class AsgardeoJavaScriptClient<T = Config> implements AsgardeoClient<T> {
|
|
31
|
-
abstract switchOrganization(organization: Organization): Promise<
|
|
33
|
+
abstract switchOrganization(organization: Organization, sessionId?: string): Promise<TokenResponse | Response>;
|
|
32
34
|
abstract initialize(config: T): Promise<boolean>;
|
|
33
|
-
abstract getUser(): Promise<User>;
|
|
34
|
-
abstract
|
|
35
|
-
abstract
|
|
36
|
-
abstract
|
|
35
|
+
abstract getUser(options?: any): Promise<User>;
|
|
36
|
+
abstract getAllOrganizations(options?: any, sessionId?: string): Promise<AllOrganizationsApiResponse>;
|
|
37
|
+
abstract getMyOrganizations(options?: any, sessionId?: string): Promise<Organization[]>;
|
|
38
|
+
abstract getCurrentOrganization(sessionId?: string): Promise<Organization | null>;
|
|
39
|
+
abstract getUserProfile(options?: any): Promise<UserProfile>;
|
|
37
40
|
abstract isLoading(): boolean;
|
|
38
41
|
abstract isSignedIn(): Promise<boolean>;
|
|
42
|
+
abstract updateUserProfile(payload: any, userId?: string): Promise<User>;
|
|
39
43
|
abstract getConfiguration(): T;
|
|
40
44
|
abstract signIn(options?: SignInOptions, sessionId?: string, onSignInSuccess?: (afterSignInUrl: string) => void): Promise<User>;
|
|
41
45
|
abstract signIn(payload: EmbeddedSignInFlowHandleRequestPayload, request: Request, sessionId?: string, onSignInSuccess?: (afterSignInUrl: string) => void): Promise<User>;
|
|
@@ -15,16 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import {
|
|
19
|
-
/**
|
|
20
|
-
* Interface for paginated organization response.
|
|
21
|
-
*/
|
|
22
|
-
export interface PaginatedOrganizationsResponse {
|
|
23
|
-
hasMore?: boolean;
|
|
24
|
-
nextCursor?: string;
|
|
25
|
-
organizations: Organization[];
|
|
26
|
-
totalCount?: number;
|
|
27
|
-
}
|
|
18
|
+
import { AllOrganizationsApiResponse } from '../models/organization';
|
|
28
19
|
/**
|
|
29
20
|
* Configuration for the getAllOrganizations request
|
|
30
21
|
*/
|
|
@@ -108,5 +99,5 @@ export interface GetAllOrganizationsConfig extends Omit<RequestInit, 'method'> {
|
|
|
108
99
|
* }
|
|
109
100
|
* ```
|
|
110
101
|
*/
|
|
111
|
-
declare const getAllOrganizations: ({ baseUrl, filter, limit, recursive, fetcher, ...requestConfig }: GetAllOrganizationsConfig) => Promise<
|
|
102
|
+
declare const getAllOrganizations: ({ baseUrl, filter, limit, recursive, fetcher, ...requestConfig }: GetAllOrganizationsConfig) => Promise<AllOrganizationsApiResponse>;
|
|
112
103
|
export default getAllOrganizations;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025, 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 { BrandingPreference } from '../models/branding-preference';
|
|
19
|
+
/**
|
|
20
|
+
* Configuration for the getBrandingPreference request
|
|
21
|
+
*/
|
|
22
|
+
export interface GetBrandingPreferenceConfig extends Omit<RequestInit, 'method'> {
|
|
23
|
+
/**
|
|
24
|
+
* The base URL for the API endpoint.
|
|
25
|
+
*/
|
|
26
|
+
baseUrl: string;
|
|
27
|
+
/**
|
|
28
|
+
* Locale for the branding preference
|
|
29
|
+
*/
|
|
30
|
+
locale?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Name of the branding preference
|
|
33
|
+
*/
|
|
34
|
+
name?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Type of the branding preference
|
|
37
|
+
*/
|
|
38
|
+
type?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Optional custom fetcher function.
|
|
41
|
+
* If not provided, native fetch will be used
|
|
42
|
+
*/
|
|
43
|
+
fetcher?: (url: string, config: RequestInit) => Promise<Response>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves branding preference configuration.
|
|
47
|
+
*
|
|
48
|
+
* @param config - Configuration object containing baseUrl, optional query parameters, and request config.
|
|
49
|
+
* @returns A promise that resolves with the branding preference information.
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* // Using default fetch
|
|
53
|
+
* try {
|
|
54
|
+
* const response = await getBrandingPreference({
|
|
55
|
+
* baseUrl: "https://api.asgardeo.io/t/<ORGANIZATION>",
|
|
56
|
+
* locale: "en-US",
|
|
57
|
+
* name: "my-branding",
|
|
58
|
+
* type: "org"
|
|
59
|
+
* });
|
|
60
|
+
* console.log(response.theme);
|
|
61
|
+
* } catch (error) {
|
|
62
|
+
* if (error instanceof AsgardeoAPIError) {
|
|
63
|
+
* console.error('Failed to get branding preference:', error.message);
|
|
64
|
+
* }
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* // Using custom fetcher (e.g., axios-based httpClient)
|
|
71
|
+
* try {
|
|
72
|
+
* const response = await getBrandingPreference({
|
|
73
|
+
* baseUrl: "https://api.asgardeo.io/t/<ORGANIZATION>",
|
|
74
|
+
* locale: "en-US",
|
|
75
|
+
* name: "my-branding",
|
|
76
|
+
* type: "org",
|
|
77
|
+
* fetcher: async (url, config) => {
|
|
78
|
+
* const response = await httpClient({
|
|
79
|
+
* url,
|
|
80
|
+
* method: config.method,
|
|
81
|
+
* headers: config.headers,
|
|
82
|
+
* ...config
|
|
83
|
+
* });
|
|
84
|
+
* // Convert axios-like response to fetch-like Response
|
|
85
|
+
* return {
|
|
86
|
+
* ok: response.status >= 200 && response.status < 300,
|
|
87
|
+
* status: response.status,
|
|
88
|
+
* statusText: response.statusText,
|
|
89
|
+
* json: () => Promise.resolve(response.data),
|
|
90
|
+
* text: () => Promise.resolve(typeof response.data === 'string' ? response.data : JSON.stringify(response.data))
|
|
91
|
+
* } as Response;
|
|
92
|
+
* }
|
|
93
|
+
* });
|
|
94
|
+
* console.log(response.theme);
|
|
95
|
+
* } catch (error) {
|
|
96
|
+
* if (error instanceof AsgardeoAPIError) {
|
|
97
|
+
* console.error('Failed to get branding preference:', error.message);
|
|
98
|
+
* }
|
|
99
|
+
* }
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
declare const getBrandingPreference: ({ baseUrl, locale, name, type, fetcher, ...requestConfig }: GetBrandingPreferenceConfig) => Promise<BrandingPreference>;
|
|
103
|
+
export default getBrandingPreference;
|