@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
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
/**
|
|
19
|
+
* Removes userstore prefixes from a username if they exist.
|
|
20
|
+
* This is commonly used to clean usernames returned from SCIM2 endpoints
|
|
21
|
+
* that include userstore prefixes like "DEFAULT/", "ASGARDEO_USER/", "PRIMARY/", etc.
|
|
22
|
+
*
|
|
23
|
+
* @param username - The username string to process
|
|
24
|
+
* @returns The username without the userstore prefix, or the original username if no prefix exists
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const cleanUsername = removeUserstorePrefix("DEFAULT/john.doe");
|
|
29
|
+
* console.log(cleanUsername); // "john.doe"
|
|
30
|
+
*
|
|
31
|
+
* const asgardeoUser = removeUserstorePrefix("ASGARDEO_USER/jane.doe");
|
|
32
|
+
* console.log(asgardeoUser); // "jane.doe"
|
|
33
|
+
*
|
|
34
|
+
* const primaryUser = removeUserstorePrefix("PRIMARY/admin");
|
|
35
|
+
* console.log(primaryUser); // "admin"
|
|
36
|
+
*
|
|
37
|
+
* const alreadyClean = removeUserstorePrefix("user.name");
|
|
38
|
+
* console.log(alreadyClean); // "user.name"
|
|
39
|
+
*
|
|
40
|
+
* const emptyInput = removeUserstorePrefix("");
|
|
41
|
+
* console.log(emptyInput); // ""
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export declare const removeUserstorePrefix: (username?: string) => string;
|
|
45
|
+
/**
|
|
46
|
+
* Processes a user object to remove userstore prefixes from username fields.
|
|
47
|
+
* This is a helper function for processing user objects returned from SCIM2 endpoints.
|
|
48
|
+
* Handles various username field variations: username, userName, and user_name.
|
|
49
|
+
*
|
|
50
|
+
* @param user - The user object to process
|
|
51
|
+
* @returns The user object with processed username fields
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const user = { username: "DEFAULT/john.doe", email: "john@example.com" };
|
|
56
|
+
* const processedUser = processUserUsername(user);
|
|
57
|
+
* console.log(processedUser.username); // "john.doe"
|
|
58
|
+
*
|
|
59
|
+
* const camelCaseUser = { userName: "ASGARDEO_USER/jane.doe", email: "jane@example.com" };
|
|
60
|
+
* const processedCamelCaseUser = processUserUsername(camelCaseUser);
|
|
61
|
+
* console.log(processedCamelCaseUser.userName); // "jane.doe"
|
|
62
|
+
*
|
|
63
|
+
* const snakeCaseUser = { user_name: "PRIMARY/admin", email: "admin@example.com" };
|
|
64
|
+
* const processedSnakeCaseUser = processUserUsername(snakeCaseUser);
|
|
65
|
+
* console.log(processedSnakeCaseUser.user_name); // "admin"
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
declare const processUsername: <T extends {
|
|
69
|
+
username?: string;
|
|
70
|
+
userName?: string;
|
|
71
|
+
user_name?: string;
|
|
72
|
+
}>(user: T) => T;
|
|
73
|
+
export default processUsername;
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
import { Theme } from '../theme/types';
|
|
20
|
+
/**
|
|
21
|
+
* Transforms branding preference response to Theme object
|
|
22
|
+
*
|
|
23
|
+
* @param brandingPreference - The branding preference response from getBrandingPreference
|
|
24
|
+
* @param forceTheme - Optional parameter to force a specific theme ('light' or 'dark'),
|
|
25
|
+
* if not provided, will use the activeTheme from branding preference
|
|
26
|
+
* @returns Theme object that can be used with the theme system
|
|
27
|
+
*
|
|
28
|
+
* The function extracts the following from branding preference:
|
|
29
|
+
* - Colors (primary, secondary, background, text, alerts, etc.)
|
|
30
|
+
* - Border radius from buttons and inputs
|
|
31
|
+
* - Images (logo and favicon with their URLs, titles, and alt text)
|
|
32
|
+
* - Typography settings
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* const brandingPreference = await getBrandingPreference({ baseUrl: "..." });
|
|
37
|
+
* const theme = transformBrandingPreferenceToTheme(brandingPreference);
|
|
38
|
+
*
|
|
39
|
+
* // Access image URLs via CSS variables
|
|
40
|
+
* // Logo: var(--wso2-image-logo-url)
|
|
41
|
+
* // Favicon: var(--wso2-image-favicon-url)
|
|
42
|
+
*
|
|
43
|
+
* // Force light theme regardless of branding preference activeTheme
|
|
44
|
+
* const lightTheme = transformBrandingPreferenceToTheme(brandingPreference, 'light');
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export declare const transformBrandingPreferenceToTheme: (brandingPreference: BrandingPreference, forceTheme?: "light" | "dark") => Theme;
|
|
48
|
+
export default transformBrandingPreferenceToTheme;
|