@asgardeo/javascript 0.1.2 → 0.1.4
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 +6 -2
- package/dist/api/getAllOrganizations.d.ts +2 -11
- package/dist/cjs/index.js +536 -31
- package/dist/cjs/index.js.map +4 -4
- package/dist/index.d.ts +4 -1
- package/dist/index.js +534 -31
- package/dist/index.js.map +4 -4
- package/dist/models/client.d.ts +16 -3
- 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 +199 -0
- package/dist/utils/processUsername.d.ts +73 -0
- package/dist/utils/transformBrandingPreferenceToTheme.d.ts +48 -0
- package/package.json +1 -1
package/dist/models/client.d.ts
CHANGED
|
@@ -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 { EmbeddedFlowExecuteRequestConfig, EmbeddedFlowExecuteRequestPayload, EmbeddedFlowExecuteResponse } from './embedded-flow';
|
|
19
20
|
import { EmbeddedSignInFlowHandleRequestPayload } from './embedded-signin-flow';
|
|
20
21
|
import { Organization } from './organization';
|
|
21
22
|
import { User, UserProfile } from './user';
|
|
23
|
+
import { TokenResponse } from './token';
|
|
22
24
|
export type SignInOptions = Record<string, unknown>;
|
|
23
25
|
export type SignOutOptions = Record<string, unknown>;
|
|
24
26
|
export type SignUpOptions = Record<string, unknown>;
|
|
@@ -34,11 +36,12 @@ export type SignUpOptions = Record<string, unknown>;
|
|
|
34
36
|
*/
|
|
35
37
|
export interface AsgardeoClient<T> {
|
|
36
38
|
/**
|
|
37
|
-
* Gets the
|
|
39
|
+
* Gets the current signed-in user's associated organizations.
|
|
38
40
|
*
|
|
39
41
|
* @returns Associated organizations.
|
|
40
42
|
*/
|
|
41
|
-
|
|
43
|
+
getMyOrganizations(options?: any, sessionId?: string): Promise<Organization[]>;
|
|
44
|
+
getAllOrganizations(options?: any, sessionId?: string): Promise<AllOrganizationsApiResponse>;
|
|
42
45
|
/**
|
|
43
46
|
* Gets the current organization of the user.
|
|
44
47
|
*
|
|
@@ -50,7 +53,7 @@ export interface AsgardeoClient<T> {
|
|
|
50
53
|
* @param organization - The organization to switch to.
|
|
51
54
|
* @returns A promise that resolves when the switch is complete.
|
|
52
55
|
*/
|
|
53
|
-
switchOrganization(organization: Organization): Promise<
|
|
56
|
+
switchOrganization(organization: Organization, sessionId?: string): Promise<TokenResponse | Response>;
|
|
54
57
|
getConfiguration(): T;
|
|
55
58
|
updateUserProfile(payload: any, userId?: string): Promise<User>;
|
|
56
59
|
/**
|
|
@@ -105,6 +108,16 @@ export interface AsgardeoClient<T> {
|
|
|
105
108
|
* @returns A promise that resolves to an EmbeddedFlowExecuteResponse containing the flow execution details.
|
|
106
109
|
*/
|
|
107
110
|
signIn(payload: EmbeddedSignInFlowHandleRequestPayload, request: EmbeddedFlowExecuteRequestConfig<EmbeddedSignInFlowHandleRequestPayload>, sessionId?: string, onSignInSuccess?: (afterSignInUrl: string) => void): Promise<User>;
|
|
111
|
+
/**
|
|
112
|
+
* Try signing in silently in the background without any user interactions.
|
|
113
|
+
*
|
|
114
|
+
* @remarks This approach uses a passive auth request (prompt=none) sent from an iframe which might pose issues in cross-origin scenarios.
|
|
115
|
+
* Make sure you are aware of the limitations and browser compatibility issues.
|
|
116
|
+
*
|
|
117
|
+
* @param options - Optional sign-in options like additional parameters to be sent in the authorize request, etc.
|
|
118
|
+
* @returns A promise that resolves to the user if sign-in is successful, or false if not.
|
|
119
|
+
*/
|
|
120
|
+
signInSilently(options?: SignInOptions): Promise<User | boolean>;
|
|
108
121
|
/**
|
|
109
122
|
* Signs out the currently signed-in user.
|
|
110
123
|
*
|
package/dist/models/i18n.d.ts
CHANGED
|
@@ -55,6 +55,16 @@ export interface I18nTranslations {
|
|
|
55
55
|
'organization.switcher.create.organization': string;
|
|
56
56
|
'organization.switcher.manage.organizations': string;
|
|
57
57
|
'organization.switcher.manage.button': string;
|
|
58
|
+
'organization.switcher.organizations.title': string;
|
|
59
|
+
'organization.switcher.switch.button': string;
|
|
60
|
+
'organization.switcher.no.access': string;
|
|
61
|
+
'organization.switcher.status.label': string;
|
|
62
|
+
'organization.switcher.showing.count': string;
|
|
63
|
+
'organization.switcher.refresh.button': string;
|
|
64
|
+
'organization.switcher.load.more': string;
|
|
65
|
+
'organization.switcher.loading.more': string;
|
|
66
|
+
'organization.switcher.no.organizations': string;
|
|
67
|
+
'organization.switcher.error.prefix': string;
|
|
58
68
|
'organization.profile.title': string;
|
|
59
69
|
'organization.profile.loading': string;
|
|
60
70
|
'organization.profile.error': string;
|
|
@@ -22,3 +22,12 @@ export interface Organization {
|
|
|
22
22
|
ref?: string;
|
|
23
23
|
status?: string;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Interface for paginated organization response.
|
|
27
|
+
*/
|
|
28
|
+
export interface AllOrganizationsApiResponse {
|
|
29
|
+
hasMore?: boolean;
|
|
30
|
+
nextCursor?: string;
|
|
31
|
+
organizations: Organization[];
|
|
32
|
+
totalCount?: number;
|
|
33
|
+
}
|
|
@@ -4,7 +4,23 @@
|
|
|
4
4
|
* WSO2 LLC. licenses this file to you under the Apache License,
|
|
5
5
|
* Version 2.0 (the "License"); you may not use this file except
|
|
6
6
|
* in compliance with the License.
|
|
7
|
-
* You may obtain a
|
|
7
|
+
* You may obtain a cop // Shadows
|
|
8
|
+
if (theme.shadows?.small) {
|
|
9
|
+
cssVars[`--${prefix}-shadow-small`] = theme.shadows.small;
|
|
10
|
+
}
|
|
11
|
+
if (theme.shadows?.medium) {
|
|
12
|
+
cssVars[`--${prefix}-shadow-medium`] = theme.shadows.medium;
|
|
13
|
+
}
|
|
14
|
+
if (theme.shadows?.large) {
|
|
15
|
+
cssVars[`--${prefix}-shadow-large`] = theme.shadows.large;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Typography - Font Family
|
|
19
|
+
if (theme.typography?.fontFamily) {
|
|
20
|
+
cssVars[`--${prefix}-typography-fontFamily`] = theme.typography.fontFamily;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Typography - Font Sizesense at
|
|
8
24
|
*
|
|
9
25
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
26
|
*
|
package/dist/theme/types.d.ts
CHANGED
|
@@ -15,7 +15,43 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
+
export interface ThemeTypography {
|
|
19
|
+
fontFamily: string;
|
|
20
|
+
fontSizes: {
|
|
21
|
+
xs: string;
|
|
22
|
+
sm: string;
|
|
23
|
+
md: string;
|
|
24
|
+
lg: string;
|
|
25
|
+
xl: string;
|
|
26
|
+
'2xl': string;
|
|
27
|
+
'3xl': string;
|
|
28
|
+
};
|
|
29
|
+
fontWeights: {
|
|
30
|
+
normal: number;
|
|
31
|
+
medium: number;
|
|
32
|
+
semibold: number;
|
|
33
|
+
bold: number;
|
|
34
|
+
};
|
|
35
|
+
lineHeights: {
|
|
36
|
+
tight: number;
|
|
37
|
+
normal: number;
|
|
38
|
+
relaxed: number;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
18
41
|
export interface ThemeColors {
|
|
42
|
+
action: {
|
|
43
|
+
active: string;
|
|
44
|
+
hover: string;
|
|
45
|
+
hoverOpacity: number;
|
|
46
|
+
selected: string;
|
|
47
|
+
selectedOpacity: number;
|
|
48
|
+
disabled: string;
|
|
49
|
+
disabledBackground: string;
|
|
50
|
+
disabledOpacity: number;
|
|
51
|
+
focus: string;
|
|
52
|
+
focusOpacity: number;
|
|
53
|
+
activatedOpacity: number;
|
|
54
|
+
};
|
|
19
55
|
background: {
|
|
20
56
|
body: {
|
|
21
57
|
main: string;
|
|
@@ -64,9 +100,144 @@ export interface ThemeConfig {
|
|
|
64
100
|
spacing: {
|
|
65
101
|
unit: number;
|
|
66
102
|
};
|
|
103
|
+
typography: {
|
|
104
|
+
fontFamily: string;
|
|
105
|
+
fontSizes: {
|
|
106
|
+
xs: string;
|
|
107
|
+
sm: string;
|
|
108
|
+
md: string;
|
|
109
|
+
lg: string;
|
|
110
|
+
xl: string;
|
|
111
|
+
'2xl': string;
|
|
112
|
+
'3xl': string;
|
|
113
|
+
};
|
|
114
|
+
fontWeights: {
|
|
115
|
+
normal: number;
|
|
116
|
+
medium: number;
|
|
117
|
+
semibold: number;
|
|
118
|
+
bold: number;
|
|
119
|
+
};
|
|
120
|
+
lineHeights: {
|
|
121
|
+
tight: number;
|
|
122
|
+
normal: number;
|
|
123
|
+
relaxed: number;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Image assets configuration
|
|
128
|
+
*/
|
|
129
|
+
images?: ThemeImages;
|
|
130
|
+
/**
|
|
131
|
+
* The prefix used for CSS variables.
|
|
132
|
+
* @default 'asgardeo' (from VendorConstants.VENDOR_PREFIX)
|
|
133
|
+
*/
|
|
134
|
+
cssVarPrefix?: string;
|
|
135
|
+
}
|
|
136
|
+
export interface ThemeVars {
|
|
137
|
+
colors: {
|
|
138
|
+
action: {
|
|
139
|
+
active: string;
|
|
140
|
+
hover: string;
|
|
141
|
+
hoverOpacity: string;
|
|
142
|
+
selected: string;
|
|
143
|
+
selectedOpacity: string;
|
|
144
|
+
disabled: string;
|
|
145
|
+
disabledBackground: string;
|
|
146
|
+
disabledOpacity: string;
|
|
147
|
+
focus: string;
|
|
148
|
+
focusOpacity: string;
|
|
149
|
+
activatedOpacity: string;
|
|
150
|
+
};
|
|
151
|
+
primary: {
|
|
152
|
+
main: string;
|
|
153
|
+
contrastText: string;
|
|
154
|
+
};
|
|
155
|
+
secondary: {
|
|
156
|
+
main: string;
|
|
157
|
+
contrastText: string;
|
|
158
|
+
};
|
|
159
|
+
background: {
|
|
160
|
+
surface: string;
|
|
161
|
+
disabled: string;
|
|
162
|
+
body: {
|
|
163
|
+
main: string;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
error: {
|
|
167
|
+
main: string;
|
|
168
|
+
contrastText: string;
|
|
169
|
+
};
|
|
170
|
+
success: {
|
|
171
|
+
main: string;
|
|
172
|
+
contrastText: string;
|
|
173
|
+
};
|
|
174
|
+
warning: {
|
|
175
|
+
main: string;
|
|
176
|
+
contrastText: string;
|
|
177
|
+
};
|
|
178
|
+
text: {
|
|
179
|
+
primary: string;
|
|
180
|
+
secondary: string;
|
|
181
|
+
};
|
|
182
|
+
border: string;
|
|
183
|
+
};
|
|
184
|
+
spacing: {
|
|
185
|
+
unit: string;
|
|
186
|
+
};
|
|
187
|
+
borderRadius: {
|
|
188
|
+
small: string;
|
|
189
|
+
medium: string;
|
|
190
|
+
large: string;
|
|
191
|
+
};
|
|
192
|
+
shadows: {
|
|
193
|
+
small: string;
|
|
194
|
+
medium: string;
|
|
195
|
+
large: string;
|
|
196
|
+
};
|
|
197
|
+
typography: {
|
|
198
|
+
fontFamily: string;
|
|
199
|
+
fontSizes: {
|
|
200
|
+
xs: string;
|
|
201
|
+
sm: string;
|
|
202
|
+
md: string;
|
|
203
|
+
lg: string;
|
|
204
|
+
xl: string;
|
|
205
|
+
'2xl': string;
|
|
206
|
+
'3xl': string;
|
|
207
|
+
};
|
|
208
|
+
fontWeights: {
|
|
209
|
+
normal: string;
|
|
210
|
+
medium: string;
|
|
211
|
+
semibold: string;
|
|
212
|
+
bold: string;
|
|
213
|
+
};
|
|
214
|
+
lineHeights: {
|
|
215
|
+
tight: string;
|
|
216
|
+
normal: string;
|
|
217
|
+
relaxed: string;
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
images?: {
|
|
221
|
+
favicon?: {
|
|
222
|
+
url?: string;
|
|
223
|
+
title?: string;
|
|
224
|
+
alt?: string;
|
|
225
|
+
};
|
|
226
|
+
logo?: {
|
|
227
|
+
url?: string;
|
|
228
|
+
title?: string;
|
|
229
|
+
alt?: string;
|
|
230
|
+
};
|
|
231
|
+
[key: string]: {
|
|
232
|
+
url?: string;
|
|
233
|
+
title?: string;
|
|
234
|
+
alt?: string;
|
|
235
|
+
} | undefined;
|
|
236
|
+
};
|
|
67
237
|
}
|
|
68
238
|
export interface Theme extends ThemeConfig {
|
|
69
239
|
cssVariables: Record<string, string>;
|
|
240
|
+
vars: ThemeVars;
|
|
70
241
|
}
|
|
71
242
|
export type ThemeMode = 'light' | 'dark' | 'system' | 'class';
|
|
72
243
|
export interface ThemeDetection {
|
|
@@ -81,3 +252,31 @@ export interface ThemeDetection {
|
|
|
81
252
|
*/
|
|
82
253
|
lightClass?: string;
|
|
83
254
|
}
|
|
255
|
+
export interface ThemeImage {
|
|
256
|
+
/**
|
|
257
|
+
* The URL of the image
|
|
258
|
+
*/
|
|
259
|
+
url?: string;
|
|
260
|
+
/**
|
|
261
|
+
* The title/alt text for the image
|
|
262
|
+
*/
|
|
263
|
+
title?: string;
|
|
264
|
+
/**
|
|
265
|
+
* Alternative text for accessibility
|
|
266
|
+
*/
|
|
267
|
+
alt?: string;
|
|
268
|
+
}
|
|
269
|
+
export interface ThemeImages {
|
|
270
|
+
/**
|
|
271
|
+
* Favicon configuration
|
|
272
|
+
*/
|
|
273
|
+
favicon?: ThemeImage;
|
|
274
|
+
/**
|
|
275
|
+
* Logo configuration
|
|
276
|
+
*/
|
|
277
|
+
logo?: ThemeImage;
|
|
278
|
+
/**
|
|
279
|
+
* Allow for additional custom images
|
|
280
|
+
*/
|
|
281
|
+
[key: string]: ThemeImage | undefined;
|
|
282
|
+
}
|
|
@@ -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;
|