@asgardeo/javascript 0.1.1 → 0.1.2
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 +5 -4
- package/dist/api/getBrandingPreference.d.ts +103 -0
- package/dist/cjs/index.js +156 -33
- package/dist/cjs/index.js.map +3 -3
- package/dist/index.d.ts +4 -1
- package/dist/index.js +154 -33
- package/dist/index.js.map +3 -3
- package/dist/models/branding-preference.d.ts +248 -0
- package/dist/models/client.d.ts +5 -4
- package/dist/models/config.d.ts +18 -0
- package/dist/theme/types.d.ts +13 -1
- package/dist/utils/deriveOrganizationHandleFromBaseUrl.d.ts +47 -0
- package/package.json +1 -1
|
@@ -30,12 +30,13 @@ import { User, UserProfile } from './models/user';
|
|
|
30
30
|
declare abstract class AsgardeoJavaScriptClient<T = Config> implements AsgardeoClient<T> {
|
|
31
31
|
abstract switchOrganization(organization: Organization): Promise<void>;
|
|
32
32
|
abstract initialize(config: T): Promise<boolean>;
|
|
33
|
-
abstract getUser(): Promise<User>;
|
|
34
|
-
abstract getOrganizations(): Promise<Organization[]>;
|
|
35
|
-
abstract getCurrentOrganization(): Promise<Organization | null>;
|
|
36
|
-
abstract getUserProfile(): Promise<UserProfile>;
|
|
33
|
+
abstract getUser(options?: any): Promise<User>;
|
|
34
|
+
abstract getOrganizations(options?: any): Promise<Organization[]>;
|
|
35
|
+
abstract getCurrentOrganization(sessionId?: string): Promise<Organization | null>;
|
|
36
|
+
abstract getUserProfile(options?: any): Promise<UserProfile>;
|
|
37
37
|
abstract isLoading(): boolean;
|
|
38
38
|
abstract isSignedIn(): Promise<boolean>;
|
|
39
|
+
abstract updateUserProfile(payload: any, userId?: string): Promise<User>;
|
|
39
40
|
abstract getConfiguration(): T;
|
|
40
41
|
abstract signIn(options?: SignInOptions, sessionId?: string, onSignInSuccess?: (afterSignInUrl: string) => void): Promise<User>;
|
|
41
42
|
abstract signIn(payload: EmbeddedSignInFlowHandleRequestPayload, request: Request, sessionId?: string, onSignInSuccess?: (afterSignInUrl: string) => void): Promise<User>;
|
|
@@ -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;
|
package/dist/cjs/index.js
CHANGED
|
@@ -50,6 +50,7 @@ __export(index_exports, {
|
|
|
50
50
|
createPatchOperations: () => createPatchOperations,
|
|
51
51
|
createTheme: () => createTheme_default,
|
|
52
52
|
deepMerge: () => deepMerge_default,
|
|
53
|
+
deriveOrganizationHandleFromBaseUrl: () => deriveOrganizationHandleFromBaseUrl_default,
|
|
53
54
|
executeEmbeddedSignInFlow: () => executeEmbeddedSignInFlow_default,
|
|
54
55
|
executeEmbeddedSignUpFlow: () => executeEmbeddedSignUpFlow_default,
|
|
55
56
|
extractPkceStorageKeyFromState: () => extractPkceStorageKeyFromState_default,
|
|
@@ -59,6 +60,7 @@ __export(index_exports, {
|
|
|
59
60
|
generateUserProfile: () => generateUserProfile_default,
|
|
60
61
|
get: () => get_default,
|
|
61
62
|
getAllOrganizations: () => getAllOrganizations_default,
|
|
63
|
+
getBrandingPreference: () => getBrandingPreference_default,
|
|
62
64
|
getI18nBundles: () => getI18nBundles_default,
|
|
63
65
|
getLatestStateParam: () => getLatestStateParam_default,
|
|
64
66
|
getMeOrganizations: () => getMeOrganizations_default,
|
|
@@ -2022,16 +2024,15 @@ var initializeEmbeddedSignInFlow = async ({
|
|
|
2022
2024
|
searchParams.append(key, String(value));
|
|
2023
2025
|
}
|
|
2024
2026
|
});
|
|
2025
|
-
const { headers: customHeaders, ...otherConfig } = requestConfig;
|
|
2026
2027
|
const response = await fetch(url ?? `${baseUrl}/oauth2/authorize`, {
|
|
2028
|
+
...requestConfig,
|
|
2027
2029
|
method: requestConfig.method || "POST",
|
|
2028
2030
|
headers: {
|
|
2029
2031
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
2030
2032
|
Accept: "application/json",
|
|
2031
|
-
...
|
|
2033
|
+
...requestConfig.headers
|
|
2032
2034
|
},
|
|
2033
|
-
body: searchParams.toString()
|
|
2034
|
-
...otherConfig
|
|
2035
|
+
body: searchParams.toString()
|
|
2035
2036
|
});
|
|
2036
2037
|
if (!response.ok) {
|
|
2037
2038
|
const errorText = await response.text();
|
|
@@ -2063,16 +2064,15 @@ var executeEmbeddedSignInFlow = async ({
|
|
|
2063
2064
|
"If an authorization payload is not provided, the request cannot be constructed correctly."
|
|
2064
2065
|
);
|
|
2065
2066
|
}
|
|
2066
|
-
const { headers: customHeaders, ...otherConfig } = requestConfig;
|
|
2067
2067
|
const response = await fetch(url ?? `${baseUrl}/oauth2/authn`, {
|
|
2068
|
+
...requestConfig,
|
|
2068
2069
|
method: requestConfig.method || "POST",
|
|
2069
2070
|
headers: {
|
|
2070
2071
|
"Content-Type": "application/json",
|
|
2071
2072
|
Accept: "application/json",
|
|
2072
|
-
...
|
|
2073
|
+
...requestConfig.headers
|
|
2073
2074
|
},
|
|
2074
|
-
body: JSON.stringify(payload)
|
|
2075
|
-
...otherConfig
|
|
2075
|
+
body: JSON.stringify(payload)
|
|
2076
2076
|
});
|
|
2077
2077
|
if (!response.ok) {
|
|
2078
2078
|
const errorText = await response.text();
|
|
@@ -2132,19 +2132,18 @@ var executeEmbeddedSignUpFlow = async ({
|
|
|
2132
2132
|
"At least one of the baseUrl or url must be provided to execute the embedded sign up flow."
|
|
2133
2133
|
);
|
|
2134
2134
|
}
|
|
2135
|
-
const { headers: customHeaders, ...otherConfig } = requestConfig;
|
|
2136
2135
|
const response = await fetch(url ?? `${baseUrl}/api/server/v1/flow/execute`, {
|
|
2136
|
+
...requestConfig,
|
|
2137
2137
|
method: requestConfig.method || "POST",
|
|
2138
2138
|
headers: {
|
|
2139
2139
|
"Content-Type": "application/json",
|
|
2140
2140
|
Accept: "application/json",
|
|
2141
|
-
...
|
|
2141
|
+
...requestConfig.headers
|
|
2142
2142
|
},
|
|
2143
2143
|
body: JSON.stringify({
|
|
2144
2144
|
...payload ?? {},
|
|
2145
2145
|
flowType: "REGISTRATION" /* Registration */
|
|
2146
|
-
})
|
|
2147
|
-
...otherConfig
|
|
2146
|
+
})
|
|
2148
2147
|
});
|
|
2149
2148
|
if (!response.ok) {
|
|
2150
2149
|
const errorText = await response.text();
|
|
@@ -2174,12 +2173,13 @@ var getUserInfo = async ({ url, ...requestConfig }) => {
|
|
|
2174
2173
|
);
|
|
2175
2174
|
}
|
|
2176
2175
|
const response = await fetch(url, {
|
|
2176
|
+
...requestConfig,
|
|
2177
2177
|
method: "GET",
|
|
2178
2178
|
headers: {
|
|
2179
2179
|
"Content-Type": "application/json",
|
|
2180
|
-
Accept: "application/json"
|
|
2181
|
-
|
|
2182
|
-
|
|
2180
|
+
Accept: "application/json",
|
|
2181
|
+
...requestConfig.headers
|
|
2182
|
+
}
|
|
2183
2183
|
});
|
|
2184
2184
|
if (!response.ok) {
|
|
2185
2185
|
const errorText = await response.text();
|
|
@@ -2211,13 +2211,13 @@ var getScim2Me = async ({ url, baseUrl, fetcher, ...requestConfig }) => {
|
|
|
2211
2211
|
const fetchFn = fetcher || fetch;
|
|
2212
2212
|
const resolvedUrl = url ?? `${baseUrl}/scim2/Me`;
|
|
2213
2213
|
const requestInit = {
|
|
2214
|
+
...requestConfig,
|
|
2214
2215
|
method: "GET",
|
|
2215
2216
|
headers: {
|
|
2216
2217
|
"Content-Type": "application/scim+json",
|
|
2217
2218
|
Accept: "application/json",
|
|
2218
2219
|
...requestConfig.headers
|
|
2219
|
-
}
|
|
2220
|
-
...requestConfig
|
|
2220
|
+
}
|
|
2221
2221
|
};
|
|
2222
2222
|
try {
|
|
2223
2223
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2263,13 +2263,13 @@ var getSchemas = async ({ url, baseUrl, fetcher, ...requestConfig }) => {
|
|
|
2263
2263
|
const fetchFn = fetcher || fetch;
|
|
2264
2264
|
const resolvedUrl = url ?? `${baseUrl}/scim2/Schemas`;
|
|
2265
2265
|
const requestInit = {
|
|
2266
|
+
...requestConfig,
|
|
2266
2267
|
method: "GET",
|
|
2267
2268
|
headers: {
|
|
2268
2269
|
"Content-Type": "application/json",
|
|
2269
2270
|
Accept: "application/json",
|
|
2270
2271
|
...requestConfig.headers
|
|
2271
|
-
}
|
|
2272
|
-
...requestConfig
|
|
2272
|
+
}
|
|
2273
2273
|
};
|
|
2274
2274
|
try {
|
|
2275
2275
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2331,13 +2331,13 @@ var getAllOrganizations = async ({
|
|
|
2331
2331
|
const fetchFn = fetcher || fetch;
|
|
2332
2332
|
const resolvedUrl = `${baseUrl}/api/server/v1/organizations?${queryParams.toString()}`;
|
|
2333
2333
|
const requestInit = {
|
|
2334
|
+
...requestConfig,
|
|
2334
2335
|
method: "GET",
|
|
2335
2336
|
headers: {
|
|
2336
2337
|
"Content-Type": "application/json",
|
|
2337
2338
|
Accept: "application/json",
|
|
2338
2339
|
...requestConfig.headers
|
|
2339
|
-
}
|
|
2340
|
-
...requestConfig
|
|
2340
|
+
}
|
|
2341
2341
|
};
|
|
2342
2342
|
try {
|
|
2343
2343
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2407,14 +2407,14 @@ var createOrganization = async ({
|
|
|
2407
2407
|
const fetchFn = fetcher || fetch;
|
|
2408
2408
|
const resolvedUrl = `${baseUrl}/api/server/v1/organizations`;
|
|
2409
2409
|
const requestInit = {
|
|
2410
|
+
...requestConfig,
|
|
2410
2411
|
method: "POST",
|
|
2411
2412
|
headers: {
|
|
2412
2413
|
"Content-Type": "application/json",
|
|
2413
2414
|
Accept: "application/json",
|
|
2414
2415
|
...requestConfig.headers
|
|
2415
2416
|
},
|
|
2416
|
-
body: JSON.stringify(organizationPayload)
|
|
2417
|
-
...requestConfig
|
|
2417
|
+
body: JSON.stringify(organizationPayload)
|
|
2418
2418
|
};
|
|
2419
2419
|
try {
|
|
2420
2420
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2482,13 +2482,13 @@ var getMeOrganizations = async ({
|
|
|
2482
2482
|
const fetchFn = fetcher || fetch;
|
|
2483
2483
|
const resolvedUrl = `${baseUrl}/api/users/v1/me/organizations?${queryParams.toString()}`;
|
|
2484
2484
|
const requestInit = {
|
|
2485
|
+
...requestConfig,
|
|
2485
2486
|
method: "GET",
|
|
2486
2487
|
headers: {
|
|
2487
2488
|
"Content-Type": "application/json",
|
|
2488
2489
|
Accept: "application/json",
|
|
2489
2490
|
...requestConfig.headers
|
|
2490
|
-
}
|
|
2491
|
-
...requestConfig
|
|
2491
|
+
}
|
|
2492
2492
|
};
|
|
2493
2493
|
try {
|
|
2494
2494
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2549,13 +2549,13 @@ var getOrganization = async ({
|
|
|
2549
2549
|
const fetchFn = fetcher || fetch;
|
|
2550
2550
|
const resolvedUrl = `${baseUrl}/api/server/v1/organizations/${organizationId}`;
|
|
2551
2551
|
const requestInit = {
|
|
2552
|
+
...requestConfig,
|
|
2552
2553
|
method: "GET",
|
|
2553
2554
|
headers: {
|
|
2554
2555
|
"Content-Type": "application/json",
|
|
2555
2556
|
Accept: "application/json",
|
|
2556
2557
|
...requestConfig.headers
|
|
2557
|
-
}
|
|
2558
|
-
...requestConfig
|
|
2558
|
+
}
|
|
2559
2559
|
};
|
|
2560
2560
|
try {
|
|
2561
2561
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2643,14 +2643,14 @@ var updateOrganization = async ({
|
|
|
2643
2643
|
const fetchFn = fetcher || fetch;
|
|
2644
2644
|
const resolvedUrl = `${baseUrl}/api/server/v1/organizations/${organizationId}`;
|
|
2645
2645
|
const requestInit = {
|
|
2646
|
+
...requestConfig,
|
|
2646
2647
|
method: "PATCH",
|
|
2647
2648
|
headers: {
|
|
2648
2649
|
"Content-Type": "application/json",
|
|
2649
2650
|
Accept: "application/json",
|
|
2650
2651
|
...requestConfig.headers
|
|
2651
2652
|
},
|
|
2652
|
-
body: JSON.stringify(operations)
|
|
2653
|
-
...requestConfig
|
|
2653
|
+
body: JSON.stringify(operations)
|
|
2654
2654
|
};
|
|
2655
2655
|
try {
|
|
2656
2656
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2727,13 +2727,13 @@ var updateMeProfile = async ({
|
|
|
2727
2727
|
const resolvedUrl = url ?? `${baseUrl}/scim2/Me`;
|
|
2728
2728
|
const requestInit = {
|
|
2729
2729
|
method: "PATCH",
|
|
2730
|
+
...requestConfig,
|
|
2730
2731
|
headers: {
|
|
2732
|
+
...requestConfig.headers,
|
|
2731
2733
|
"Content-Type": "application/scim+json",
|
|
2732
|
-
Accept: "application/json"
|
|
2733
|
-
...requestConfig.headers
|
|
2734
|
+
Accept: "application/json"
|
|
2734
2735
|
},
|
|
2735
|
-
body: JSON.stringify(data)
|
|
2736
|
-
...requestConfig
|
|
2736
|
+
body: JSON.stringify(data)
|
|
2737
2737
|
};
|
|
2738
2738
|
try {
|
|
2739
2739
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2763,6 +2763,75 @@ var updateMeProfile = async ({
|
|
|
2763
2763
|
};
|
|
2764
2764
|
var updateMeProfile_default = updateMeProfile;
|
|
2765
2765
|
|
|
2766
|
+
// src/api/getBrandingPreference.ts
|
|
2767
|
+
var getBrandingPreference = async ({
|
|
2768
|
+
baseUrl,
|
|
2769
|
+
locale,
|
|
2770
|
+
name,
|
|
2771
|
+
type,
|
|
2772
|
+
fetcher,
|
|
2773
|
+
...requestConfig
|
|
2774
|
+
}) => {
|
|
2775
|
+
try {
|
|
2776
|
+
new URL(baseUrl);
|
|
2777
|
+
} catch (error) {
|
|
2778
|
+
throw new AsgardeoAPIError(
|
|
2779
|
+
`Invalid base URL provided. ${error?.toString()}`,
|
|
2780
|
+
"getBrandingPreference-ValidationError-001",
|
|
2781
|
+
"javascript",
|
|
2782
|
+
400,
|
|
2783
|
+
"The provided `baseUrl` does not adhere to the URL schema."
|
|
2784
|
+
);
|
|
2785
|
+
}
|
|
2786
|
+
const queryParams = new URLSearchParams(
|
|
2787
|
+
Object.fromEntries(
|
|
2788
|
+
Object.entries({
|
|
2789
|
+
locale: locale || "",
|
|
2790
|
+
name: name || "",
|
|
2791
|
+
type: type || ""
|
|
2792
|
+
}).filter(([, value]) => Boolean(value))
|
|
2793
|
+
)
|
|
2794
|
+
);
|
|
2795
|
+
const fetchFn = fetcher || fetch;
|
|
2796
|
+
const resolvedUrl = `${baseUrl}/api/server/v1/branding-preference${queryParams.toString() ? `?${queryParams.toString()}` : ""}`;
|
|
2797
|
+
const requestInit = {
|
|
2798
|
+
...requestConfig,
|
|
2799
|
+
method: "GET",
|
|
2800
|
+
headers: {
|
|
2801
|
+
"Content-Type": "application/json",
|
|
2802
|
+
Accept: "application/json",
|
|
2803
|
+
...requestConfig.headers
|
|
2804
|
+
}
|
|
2805
|
+
};
|
|
2806
|
+
try {
|
|
2807
|
+
const response = await fetchFn(resolvedUrl, requestInit);
|
|
2808
|
+
if (!response?.ok) {
|
|
2809
|
+
const errorText = await response.text();
|
|
2810
|
+
throw new AsgardeoAPIError(
|
|
2811
|
+
`Failed to get branding preference: ${errorText}`,
|
|
2812
|
+
"getBrandingPreference-ResponseError-001",
|
|
2813
|
+
"javascript",
|
|
2814
|
+
response.status,
|
|
2815
|
+
response.statusText
|
|
2816
|
+
);
|
|
2817
|
+
}
|
|
2818
|
+
const data = await response.json();
|
|
2819
|
+
return data;
|
|
2820
|
+
} catch (error) {
|
|
2821
|
+
if (error instanceof AsgardeoAPIError) {
|
|
2822
|
+
throw error;
|
|
2823
|
+
}
|
|
2824
|
+
throw new AsgardeoAPIError(
|
|
2825
|
+
`Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
2826
|
+
"getBrandingPreference-NetworkError-001",
|
|
2827
|
+
"javascript",
|
|
2828
|
+
0,
|
|
2829
|
+
"Network Error"
|
|
2830
|
+
);
|
|
2831
|
+
}
|
|
2832
|
+
};
|
|
2833
|
+
var getBrandingPreference_default = getBrandingPreference;
|
|
2834
|
+
|
|
2766
2835
|
// src/constants/ApplicationNativeAuthenticationConstants.ts
|
|
2767
2836
|
var ApplicationNativeAuthenticationConstants = {
|
|
2768
2837
|
SupportedAuthenticators: {
|
|
@@ -3051,6 +3120,58 @@ var deepMerge = (target, ...sources) => {
|
|
|
3051
3120
|
};
|
|
3052
3121
|
var deepMerge_default = deepMerge;
|
|
3053
3122
|
|
|
3123
|
+
// src/utils/deriveOrganizationHandleFromBaseUrl.ts
|
|
3124
|
+
var deriveOrganizationHandleFromBaseUrl = (baseUrl) => {
|
|
3125
|
+
if (!baseUrl) {
|
|
3126
|
+
throw new AsgardeoRuntimeError(
|
|
3127
|
+
"Base URL is required to derive organization handle.",
|
|
3128
|
+
"javascript-deriveOrganizationHandleFromBaseUrl-ValidationError-001",
|
|
3129
|
+
"javascript",
|
|
3130
|
+
"A valid base URL must be provided to extract the organization handle."
|
|
3131
|
+
);
|
|
3132
|
+
}
|
|
3133
|
+
let parsedUrl;
|
|
3134
|
+
try {
|
|
3135
|
+
parsedUrl = new URL(baseUrl);
|
|
3136
|
+
} catch (error) {
|
|
3137
|
+
throw new AsgardeoRuntimeError(
|
|
3138
|
+
`Invalid base URL format: ${baseUrl}`,
|
|
3139
|
+
"javascript-deriveOrganizationHandleFromBaseUrl-ValidationError-002",
|
|
3140
|
+
"javascript",
|
|
3141
|
+
"The provided base URL does not conform to valid URL syntax."
|
|
3142
|
+
);
|
|
3143
|
+
}
|
|
3144
|
+
const hostname = parsedUrl.hostname.toLowerCase();
|
|
3145
|
+
if (!hostname.endsWith(".asgardeo.io")) {
|
|
3146
|
+
throw new AsgardeoRuntimeError(
|
|
3147
|
+
"Organization handle is required since a custom domain is configured.",
|
|
3148
|
+
"javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-001",
|
|
3149
|
+
"javascript",
|
|
3150
|
+
"The provided base URL uses a custom domain. Please provide the organizationHandle explicitly in the configuration."
|
|
3151
|
+
);
|
|
3152
|
+
}
|
|
3153
|
+
const pathSegments = parsedUrl.pathname.split("/").filter((segment) => segment.length > 0);
|
|
3154
|
+
if (pathSegments.length < 2 || pathSegments[0] !== "t") {
|
|
3155
|
+
throw new AsgardeoRuntimeError(
|
|
3156
|
+
"Organization handle is required since a custom domain is configured.",
|
|
3157
|
+
"javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-002",
|
|
3158
|
+
"javascript",
|
|
3159
|
+
"The provided base URL does not follow the expected Asgardeo URL pattern (/t/{orgHandle}). Please provide the organizationHandle explicitly in the configuration."
|
|
3160
|
+
);
|
|
3161
|
+
}
|
|
3162
|
+
const organizationHandle = pathSegments[1];
|
|
3163
|
+
if (!organizationHandle || organizationHandle.trim().length === 0) {
|
|
3164
|
+
throw new AsgardeoRuntimeError(
|
|
3165
|
+
"Organization handle is required since a custom domain is configured.",
|
|
3166
|
+
"javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-003",
|
|
3167
|
+
"javascript",
|
|
3168
|
+
"The organization handle could not be extracted from the base URL. Please provide the organizationHandle explicitly in the configuration."
|
|
3169
|
+
);
|
|
3170
|
+
}
|
|
3171
|
+
return organizationHandle;
|
|
3172
|
+
};
|
|
3173
|
+
var deriveOrganizationHandleFromBaseUrl_default = deriveOrganizationHandleFromBaseUrl;
|
|
3174
|
+
|
|
3054
3175
|
// src/utils/flattenUserSchema.ts
|
|
3055
3176
|
var flattenUserSchema = (schemas) => {
|
|
3056
3177
|
const flattenedAttributes = [];
|
|
@@ -3410,6 +3531,7 @@ var withVendorCSSClassPrefix_default = withVendorCSSClassPrefix;
|
|
|
3410
3531
|
createPatchOperations,
|
|
3411
3532
|
createTheme,
|
|
3412
3533
|
deepMerge,
|
|
3534
|
+
deriveOrganizationHandleFromBaseUrl,
|
|
3413
3535
|
executeEmbeddedSignInFlow,
|
|
3414
3536
|
executeEmbeddedSignUpFlow,
|
|
3415
3537
|
extractPkceStorageKeyFromState,
|
|
@@ -3419,6 +3541,7 @@ var withVendorCSSClassPrefix_default = withVendorCSSClassPrefix;
|
|
|
3419
3541
|
generateUserProfile,
|
|
3420
3542
|
get,
|
|
3421
3543
|
getAllOrganizations,
|
|
3544
|
+
getBrandingPreference,
|
|
3422
3545
|
getI18nBundles,
|
|
3423
3546
|
getLatestStateParam,
|
|
3424
3547
|
getMeOrganizations,
|