@asgardeo/javascript 0.0.1 → 0.1.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.
- package/README.md +3 -3
- package/dist/AsgardeoJavaScriptClient.d.ts +17 -50
- package/dist/IsomorphicCrypto.d.ts +4 -4
- package/dist/{__legacy__/data/data-layer.d.ts → StorageManager.d.ts} +27 -26
- package/dist/__legacy__/client.d.ts +82 -98
- package/dist/__legacy__/helpers/authentication-helper.d.ts +9 -9
- package/dist/__legacy__/models/client-config.d.ts +6 -6
- package/dist/__legacy__/models/index.d.ts +0 -5
- package/dist/api/createOrganization.d.ts +129 -0
- package/dist/api/executeEmbeddedSignInFlow.d.ts +21 -0
- package/dist/api/executeEmbeddedSignUpFlow.d.ts +44 -0
- package/dist/api/getAllOrganizations.d.ts +112 -0
- package/dist/api/getMeOrganizations.d.ts +119 -0
- package/dist/api/getOrganization.d.ts +109 -0
- package/dist/api/getSchemas.d.ts +89 -0
- package/dist/api/getScim2Me.d.ts +89 -0
- package/dist/api/{oidc/getUserInfo.d.ts → getUserInfo.d.ts} +1 -1
- package/dist/api/initializeEmbeddedSignInFlow.d.ts +51 -0
- package/dist/api/updateMeProfile.d.ts +82 -0
- package/dist/api/updateOrganization.d.ts +118 -0
- package/dist/cjs/index.js +2437 -1224
- package/dist/cjs/index.js.map +4 -4
- package/dist/constants/ApplicationNativeAuthenticationConstants.d.ts +39 -0
- package/dist/constants/OIDCRequestConstants.d.ts +14 -0
- package/dist/constants/PKCEConstants.d.ts +1 -0
- package/dist/constants/ScopeConstants.d.ts +3 -6
- package/dist/constants/TokenExchangeConstants.d.ts +3 -3
- package/dist/constants/VendorConstants.d.ts +31 -0
- package/dist/{__legacy__/exception → errors}/exception.d.ts +3 -0
- package/dist/{__legacy__/data/index.d.ts → i18n/en-US.d.ts} +4 -2
- package/dist/{__legacy__/exception → i18n}/index.d.ts +2 -2
- package/dist/index.d.ts +44 -11
- package/dist/index.js +2399 -1219
- package/dist/index.js.map +4 -4
- package/dist/models/client.d.ts +60 -5
- package/dist/models/config.d.ts +51 -2
- package/dist/models/crypto.d.ts +2 -2
- package/dist/models/embedded-flow.d.ts +66 -0
- package/dist/models/embedded-signin-flow.d.ts +99 -0
- package/dist/{__legacy__/models/custom-grant.d.ts → models/field.d.ts} +13 -9
- package/dist/models/flow.d.ts +30 -0
- package/dist/models/i18n.d.ts +90 -0
- package/dist/{__legacy__/models/authorization-url.d.ts → models/oauth-request.d.ts} +3 -3
- package/dist/models/oauth-response.d.ts +1 -17
- package/dist/models/organization.d.ts +24 -0
- package/dist/models/scim2-schema.d.ts +3 -0
- package/dist/{__legacy__/models/data.d.ts → models/session.d.ts} +4 -0
- package/dist/models/store.d.ts +1 -1
- package/dist/models/token.d.ts +79 -20
- package/dist/models/user.d.ts +11 -84
- package/dist/theme/createTheme.d.ts +1 -1
- package/dist/theme/types.d.ts +29 -17
- package/dist/utils/deepMerge.d.ts +44 -0
- package/dist/utils/extractTenantDomainFromIdTokenPayload.d.ts +2 -2
- package/dist/utils/extractUserClaimsFromIdToken.d.ts +2 -2
- package/dist/utils/flattenUserSchema.d.ts +64 -0
- package/dist/utils/generateFlattenedUserProfile.d.ts +53 -0
- package/dist/utils/generateUserProfile.d.ts +55 -0
- package/dist/utils/get.d.ts +29 -0
- package/dist/utils/getAuthorizeRequestUrlParams.d.ts +59 -0
- package/dist/utils/getI18nBundles.d.ts +26 -0
- package/dist/utils/getLatestStateParam.d.ts +40 -0
- package/dist/utils/isEmpty.d.ts +48 -0
- package/dist/utils/processOpenIDScopes.d.ts +36 -0
- package/dist/{__legacy__/core/index.d.ts → utils/resolveFieldName.d.ts} +3 -2
- package/dist/utils/resolveFieldType.d.ts +20 -0
- package/dist/utils/set.d.ts +30 -0
- package/dist/utils/withVendorCSSClassPrefix.d.ts +32 -0
- package/package.json +4 -4
- package/dist/__legacy__/core/authentication-core.d.ts +0 -51
- package/dist/__legacy__/models/fetch.d.ts +0 -55
- package/dist/__legacy__/models/user.d.ts +0 -85
- package/dist/models/id-token.d.ts +0 -55
package/dist/models/token.d.ts
CHANGED
|
@@ -31,11 +31,11 @@ export interface TokenResponse {
|
|
|
31
31
|
*/
|
|
32
32
|
accessToken: string;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
34
|
+
* Unix timestamp (in seconds) when the token was created.
|
|
35
|
+
* Used in combination with expiresIn to determine when
|
|
36
|
+
* the token needs to be refreshed.
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
createdAt: number;
|
|
39
39
|
/**
|
|
40
40
|
* Duration in seconds until the access token expires.
|
|
41
41
|
* Applications should refresh the token before this time
|
|
@@ -43,29 +43,29 @@ export interface TokenResponse {
|
|
|
43
43
|
*/
|
|
44
44
|
expiresIn: string;
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
46
|
+
* JSON Web Token (JWT) containing user identity information.
|
|
47
|
+
* This token can be decoded to access user claims and metadata
|
|
48
|
+
* without additional server requests.
|
|
49
49
|
*/
|
|
50
|
-
|
|
50
|
+
idToken: string;
|
|
51
51
|
/**
|
|
52
52
|
* Token used to obtain new access tokens without re-authentication.
|
|
53
53
|
* Store this securely as it enables long-term access to the user's
|
|
54
54
|
* account through the refresh flow.
|
|
55
55
|
*/
|
|
56
56
|
refreshToken: string;
|
|
57
|
+
/**
|
|
58
|
+
* Space-separated list of OAuth scopes granted to the application.
|
|
59
|
+
* These scopes determine what resources and actions the application
|
|
60
|
+
* has permission to access.
|
|
61
|
+
*/
|
|
62
|
+
scope: string;
|
|
57
63
|
/**
|
|
58
64
|
* The type of token issued, typically "Bearer".
|
|
59
65
|
* This indicates how the token should be used in
|
|
60
66
|
* API request Authorization headers.
|
|
61
67
|
*/
|
|
62
68
|
tokenType: string;
|
|
63
|
-
/**
|
|
64
|
-
* Unix timestamp (in seconds) when the token was created.
|
|
65
|
-
* Used in combination with expiresIn to determine when
|
|
66
|
-
* the token needs to be refreshed.
|
|
67
|
-
*/
|
|
68
|
-
createdAt: number;
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
71
|
* Represents the raw token response received directly from the authentication server.
|
|
@@ -82,18 +82,18 @@ export interface AccessTokenApiResponse {
|
|
|
82
82
|
* before any processing or validation.
|
|
83
83
|
*/
|
|
84
84
|
access_token: string;
|
|
85
|
-
/**
|
|
86
|
-
* Raw expiration time in seconds.
|
|
87
|
-
* Indicates how long the access token will be valid
|
|
88
|
-
* from the time it was issued.
|
|
89
|
-
*/
|
|
90
|
-
expires_in: string;
|
|
91
85
|
/**
|
|
92
86
|
* Server-provided creation timestamp in Unix seconds.
|
|
93
87
|
* Used to track when the token was originally issued
|
|
94
88
|
* and calculate absolute expiration time.
|
|
95
89
|
*/
|
|
96
90
|
created_at: number;
|
|
91
|
+
/**
|
|
92
|
+
* Raw expiration time in seconds.
|
|
93
|
+
* Indicates how long the access token will be valid
|
|
94
|
+
* from the time it was issued.
|
|
95
|
+
*/
|
|
96
|
+
expires_in: string;
|
|
97
97
|
/**
|
|
98
98
|
* Raw ID token string containing encoded user information.
|
|
99
99
|
* This JWT can be decoded to access standardized claims
|
|
@@ -119,3 +119,62 @@ export interface AccessTokenApiResponse {
|
|
|
119
119
|
*/
|
|
120
120
|
token_type: string;
|
|
121
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Interface for the standard (required) claims of an ID Token payload.
|
|
124
|
+
*/
|
|
125
|
+
export interface KnownIdToken {
|
|
126
|
+
/**
|
|
127
|
+
* The audience for which this token is intended.
|
|
128
|
+
*/
|
|
129
|
+
aud: string | string[];
|
|
130
|
+
/**
|
|
131
|
+
* The email of the user.
|
|
132
|
+
*/
|
|
133
|
+
email?: string;
|
|
134
|
+
/**
|
|
135
|
+
* The issuer identifier for the issuer of the response.
|
|
136
|
+
*/
|
|
137
|
+
iss: string;
|
|
138
|
+
/**
|
|
139
|
+
* The unique human readable slug of the organization to which the user belongs.
|
|
140
|
+
*/
|
|
141
|
+
org_handle?: string;
|
|
142
|
+
/**
|
|
143
|
+
* The unique identifier of the organization to which the user belongs.
|
|
144
|
+
*/
|
|
145
|
+
org_id?: string;
|
|
146
|
+
/**
|
|
147
|
+
* The human readable name of the organization to which the user belongs.
|
|
148
|
+
*/
|
|
149
|
+
org_name?: string;
|
|
150
|
+
/**
|
|
151
|
+
* The username the user prefers to be called.
|
|
152
|
+
*/
|
|
153
|
+
preferred_username?: string;
|
|
154
|
+
/**
|
|
155
|
+
* The unique identifier of the user to whom the ID token belongs.
|
|
156
|
+
*/
|
|
157
|
+
sub: string;
|
|
158
|
+
/**
|
|
159
|
+
* The tenant domain of the user.
|
|
160
|
+
*/
|
|
161
|
+
tenant_domain?: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Interface for ID Token payload including custom claims.
|
|
165
|
+
*/
|
|
166
|
+
export interface IdToken extends KnownIdToken {
|
|
167
|
+
/**
|
|
168
|
+
* Other custom claims.
|
|
169
|
+
*/
|
|
170
|
+
[claim: string]: any;
|
|
171
|
+
}
|
|
172
|
+
export interface TokenExchangeRequestConfig {
|
|
173
|
+
attachToken: boolean;
|
|
174
|
+
data: any;
|
|
175
|
+
id: string;
|
|
176
|
+
returnsSession: boolean;
|
|
177
|
+
shouldReplayAfterRefresh?: boolean;
|
|
178
|
+
signInRequired: boolean;
|
|
179
|
+
tokenEndpoint?: string;
|
|
180
|
+
}
|
package/dist/models/user.d.ts
CHANGED
|
@@ -16,91 +16,18 @@
|
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
18
|
import { Schema } from './scim2-schema';
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
lastModified: string;
|
|
26
|
-
resourceType: string;
|
|
19
|
+
export interface KnownUser {
|
|
20
|
+
username?: string;
|
|
21
|
+
email?: string;
|
|
22
|
+
givenName?: string;
|
|
23
|
+
familyName?: string;
|
|
24
|
+
displayName?: string;
|
|
27
25
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
*/
|
|
31
|
-
export interface UserRole {
|
|
32
|
-
audienceValue: string;
|
|
33
|
-
display: string;
|
|
34
|
-
audienceType: string;
|
|
35
|
-
value: string;
|
|
36
|
-
$ref: string;
|
|
37
|
-
audienceDisplay: string;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Type for the Name object in SCIM2 responses
|
|
41
|
-
*/
|
|
42
|
-
export interface UserName {
|
|
43
|
-
formatted: string;
|
|
44
|
-
givenName: string;
|
|
45
|
-
familyName: string;
|
|
26
|
+
export interface User extends KnownUser {
|
|
27
|
+
[key: string]: any;
|
|
46
28
|
}
|
|
47
|
-
|
|
48
|
-
* Represents a user in the Asgardeo system.
|
|
49
|
-
*
|
|
50
|
-
* @remarks
|
|
51
|
-
* This interface defines the user properties based on the SCIM2 schema.
|
|
52
|
-
* WSO2 specific properties are flattened to the root level for easier access.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```typescript
|
|
56
|
-
* const user: User = {
|
|
57
|
-
* emails: ["user@example.com"],
|
|
58
|
-
* profileUrl: "https://gravatar.com/avatar/123",
|
|
59
|
-
* meta: {
|
|
60
|
-
* created: "2021-06-21T11:28:21.800618Z",
|
|
61
|
-
* location: "https://api.asgardeo.io/scim2/Users/123",
|
|
62
|
-
* lastModified: "2025-04-30T06:46:48.520896Z",
|
|
63
|
-
* resourceType: "User"
|
|
64
|
-
* },
|
|
65
|
-
* name: {
|
|
66
|
-
* formatted: "John Smith",
|
|
67
|
-
* givenName: "John",
|
|
68
|
-
* familyName: "Smith"
|
|
69
|
-
* },
|
|
70
|
-
* userName: "john@example.com",
|
|
71
|
-
* id: "123",
|
|
72
|
-
* // Flattened WSO2 schema properties
|
|
73
|
-
* accountState: "UNLOCKED",
|
|
74
|
-
* accountLocked: "false",
|
|
75
|
-
* photoUrl: "https://gravatar.com/avatar/123",
|
|
76
|
-
* emailVerified: "true",
|
|
77
|
-
* lastLogonTime: "1749098996152"
|
|
78
|
-
* };
|
|
79
|
-
* ```
|
|
80
|
-
*/
|
|
81
|
-
export interface User {
|
|
82
|
-
emails: string[];
|
|
83
|
-
profileUrl?: string;
|
|
84
|
-
meta: UserMeta;
|
|
29
|
+
export interface UserProfile {
|
|
85
30
|
schemas: Schema[];
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
id: string;
|
|
89
|
-
userName: string;
|
|
90
|
-
accountState?: string;
|
|
91
|
-
accountLocked?: string;
|
|
92
|
-
failedLoginLockoutCount?: string;
|
|
93
|
-
failedTOTPAttempts?: string;
|
|
94
|
-
failedLoginAttempts?: string;
|
|
95
|
-
totpEnabled?: string;
|
|
96
|
-
photoUrl?: string;
|
|
97
|
-
emailVerified?: string;
|
|
98
|
-
backupCodeEnabled?: string;
|
|
99
|
-
lastLogonTime?: string;
|
|
100
|
-
signedUpRegion?: string;
|
|
101
|
-
unlockTime?: string;
|
|
102
|
-
isReadOnlyUser?: string;
|
|
103
|
-
failedLoginAttemptsBeforeSuccess?: string;
|
|
104
|
-
[key: string]: any;
|
|
31
|
+
profile: User;
|
|
32
|
+
flattenedProfile: User;
|
|
105
33
|
}
|
|
106
|
-
export default User;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import { RecursivePartial } from '../models/utility-types';
|
|
19
18
|
import { Theme, ThemeConfig } from './types';
|
|
19
|
+
import { RecursivePartial } from '../models/utility-types';
|
|
20
20
|
declare const createTheme: (config?: RecursivePartial<ThemeConfig>, isDark?: boolean) => Theme;
|
|
21
21
|
export default createTheme;
|
package/dist/theme/types.d.ts
CHANGED
|
@@ -16,41 +16,53 @@
|
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
18
|
export interface ThemeColors {
|
|
19
|
-
|
|
19
|
+
background: {
|
|
20
|
+
body: {
|
|
21
|
+
main: string;
|
|
22
|
+
};
|
|
23
|
+
disabled: string;
|
|
24
|
+
surface: string;
|
|
25
|
+
};
|
|
26
|
+
border: string;
|
|
27
|
+
error: {
|
|
28
|
+
contrastText: string;
|
|
20
29
|
main: string;
|
|
30
|
+
};
|
|
31
|
+
primary: {
|
|
21
32
|
contrastText: string;
|
|
33
|
+
main: string;
|
|
22
34
|
};
|
|
23
35
|
secondary: {
|
|
24
|
-
main: string;
|
|
25
36
|
contrastText: string;
|
|
37
|
+
main: string;
|
|
26
38
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
body: {
|
|
31
|
-
main: string;
|
|
32
|
-
};
|
|
39
|
+
success: {
|
|
40
|
+
contrastText: string;
|
|
41
|
+
main: string;
|
|
33
42
|
};
|
|
34
|
-
surface: string;
|
|
35
43
|
text: {
|
|
36
44
|
primary: string;
|
|
37
45
|
secondary: string;
|
|
38
46
|
};
|
|
39
|
-
|
|
40
|
-
error: {
|
|
41
|
-
main: string;
|
|
47
|
+
warning: {
|
|
42
48
|
contrastText: string;
|
|
49
|
+
main: string;
|
|
43
50
|
};
|
|
44
51
|
}
|
|
45
52
|
export interface ThemeConfig {
|
|
46
|
-
colors: ThemeColors;
|
|
47
|
-
spacing: {
|
|
48
|
-
unit: number;
|
|
49
|
-
};
|
|
50
53
|
borderRadius: {
|
|
51
|
-
|
|
54
|
+
large: string;
|
|
52
55
|
medium: string;
|
|
56
|
+
small: string;
|
|
57
|
+
};
|
|
58
|
+
colors: ThemeColors;
|
|
59
|
+
shadows: {
|
|
53
60
|
large: string;
|
|
61
|
+
medium: string;
|
|
62
|
+
small: string;
|
|
63
|
+
};
|
|
64
|
+
spacing: {
|
|
65
|
+
unit: number;
|
|
54
66
|
};
|
|
55
67
|
}
|
|
56
68
|
export interface Theme extends ThemeConfig {
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
* Recursively merges the properties of source objects into a target object.
|
|
20
|
+
* Similar to Lodash's merge function, this creates a deep copy and merges
|
|
21
|
+
* nested objects recursively. Arrays and non-plain objects are replaced entirely.
|
|
22
|
+
*
|
|
23
|
+
* @param target - The target object to merge into
|
|
24
|
+
* @param sources - One or more source objects to merge from
|
|
25
|
+
* @returns A new object with merged properties
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const obj1 = { a: 1, b: { x: 1, y: 2 } };
|
|
30
|
+
* const obj2 = { b: { y: 3, z: 4 }, c: 3 };
|
|
31
|
+
* const result = deepMerge(obj1, obj2);
|
|
32
|
+
* // Result: { a: 1, b: { x: 1, y: 3, z: 4 }, c: 3 }
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const config = { theme: { colors: { primary: 'blue' } } };
|
|
38
|
+
* const userPrefs = { theme: { colors: { secondary: 'red' } } };
|
|
39
|
+
* const merged = deepMerge(config, userPrefs);
|
|
40
|
+
* // Result: { theme: { colors: { primary: 'blue', secondary: 'red' } } }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare const deepMerge: <T extends Record<string, any>>(target: T, ...sources: Array<Record<string, any> | undefined | null>) => T;
|
|
44
|
+
export default deepMerge;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import {
|
|
18
|
+
import { IdToken } from '../models/token';
|
|
19
19
|
/**
|
|
20
20
|
* Extracts the tenant domain from the ID token payload.
|
|
21
21
|
*
|
|
@@ -27,5 +27,5 @@ import { IdTokenPayload } from '../models/id-token';
|
|
|
27
27
|
*
|
|
28
28
|
* Consider extracting the tenant domain using a dedicated claim (e.g., `tenant_domain`) when available.
|
|
29
29
|
*/
|
|
30
|
-
declare const extractTenantDomainFromIdTokenPayload: (payload:
|
|
30
|
+
declare const extractTenantDomainFromIdTokenPayload: (payload: IdToken, subjectSeparator?: string) => string;
|
|
31
31
|
export default extractTenantDomainFromIdTokenPayload;
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* specific language governing permissions and limitations
|
|
16
16
|
* under the License.
|
|
17
17
|
*/
|
|
18
|
-
import {
|
|
18
|
+
import { IdToken } from '../models/token';
|
|
19
19
|
/**
|
|
20
20
|
* Removes standard protocol-specific claims from the ID token payload
|
|
21
21
|
* and returns a camelCased object of user-specific claims.
|
|
@@ -40,5 +40,5 @@ import { IdTokenPayload } from '../models/id-token';
|
|
|
40
40
|
* // }
|
|
41
41
|
* ```
|
|
42
42
|
*/
|
|
43
|
-
declare const extractUserClaimsFromIdToken: (payload:
|
|
43
|
+
declare const extractUserClaimsFromIdToken: (payload: IdToken) => Record<string, unknown>;
|
|
44
44
|
export default extractUserClaimsFromIdToken;
|
|
@@ -0,0 +1,64 @@
|
|
|
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 { Schema, FlattenedSchema } from '../models/scim2-schema';
|
|
19
|
+
/**
|
|
20
|
+
* Flattens nested schema attributes into a flat structure for easier processing
|
|
21
|
+
*
|
|
22
|
+
* This function processes SCIM2 schemas and creates a flattened representation by:
|
|
23
|
+
* - Processing sub-attributes and creating dot-notation names (e.g., 'name.givenName')
|
|
24
|
+
* - Adding schema ID reference to each flattened attribute
|
|
25
|
+
* - Preserving all original attribute properties while adding schema context
|
|
26
|
+
* - Only including leaf-level attributes (sub-attributes) and top-level simple attributes
|
|
27
|
+
*
|
|
28
|
+
* @param schemas - Array of SCIM2 schemas containing nested attribute structures
|
|
29
|
+
* @returns Array of flattened schema attributes with dot-notation names and schema references
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const schemas = [
|
|
34
|
+
* {
|
|
35
|
+
* id: 'urn:ietf:params:scim:schemas:core:2.0:User',
|
|
36
|
+
* attributes: [
|
|
37
|
+
* {
|
|
38
|
+
* name: 'userName',
|
|
39
|
+
* type: 'string',
|
|
40
|
+
* multiValued: false
|
|
41
|
+
* },
|
|
42
|
+
* {
|
|
43
|
+
* name: 'name',
|
|
44
|
+
* type: 'complex',
|
|
45
|
+
* multiValued: false,
|
|
46
|
+
* subAttributes: [
|
|
47
|
+
* { name: 'givenName', type: 'string', multiValued: false },
|
|
48
|
+
* { name: 'familyName', type: 'string', multiValued: false }
|
|
49
|
+
* ]
|
|
50
|
+
* }
|
|
51
|
+
* ]
|
|
52
|
+
* }
|
|
53
|
+
* ];
|
|
54
|
+
*
|
|
55
|
+
* const flattened = flattenUserSchema(schemas);
|
|
56
|
+
* // Result: [
|
|
57
|
+
* // { name: 'userName', type: 'string', multiValued: false, schemaId: 'urn:ietf:params:scim:schemas:core:2.0:User' },
|
|
58
|
+
* // { name: 'name.givenName', type: 'string', multiValued: false, schemaId: 'urn:ietf:params:scim:schemas:core:2.0:User' },
|
|
59
|
+
* // { name: 'name.familyName', type: 'string', multiValued: false, schemaId: 'urn:ietf:params:scim:schemas:core:2.0:User' }
|
|
60
|
+
* // ]
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
declare const flattenUserSchema: (schemas: Schema[]) => FlattenedSchema[];
|
|
64
|
+
export default flattenUserSchema;
|
|
@@ -0,0 +1,53 @@
|
|
|
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 { User } from '../models/user';
|
|
19
|
+
/**
|
|
20
|
+
* Generates a flattened user profile from a response object and schema definitions.
|
|
21
|
+
*
|
|
22
|
+
* This function processes user data according to schema specifications, creating
|
|
23
|
+
* a flat object with dot notation keys instead of nested objects. Multi-valued
|
|
24
|
+
* properties and type-specific defaults are handled appropriately.
|
|
25
|
+
*
|
|
26
|
+
* Additionally, any fields present in the response but not defined in the schema
|
|
27
|
+
* will be included to ensure no user data is lost during flattening.
|
|
28
|
+
*
|
|
29
|
+
* @param meResponse - The response object containing user data
|
|
30
|
+
* @param processedSchemas - Array of schema objects defining field properties
|
|
31
|
+
* @param processedSchemas[].name - The field name/path for the property
|
|
32
|
+
* @param processedSchemas[].type - The data type of the field (e.g., 'STRING')
|
|
33
|
+
* @param processedSchemas[].multiValued - Whether the field can contain multiple values
|
|
34
|
+
*
|
|
35
|
+
* @returns A flattened user profile object with dot notation keys
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const schemas = [
|
|
40
|
+
* { name: 'name.givenName', type: 'STRING', multiValued: false },
|
|
41
|
+
* { name: 'emails', type: 'STRING', multiValued: true }
|
|
42
|
+
* ];
|
|
43
|
+
* const response = {
|
|
44
|
+
* name: { givenName: 'John' },
|
|
45
|
+
* emails: 'john@example.com',
|
|
46
|
+
* country: 'US' // This will be included even if not in schema
|
|
47
|
+
* };
|
|
48
|
+
* const profile = generateFlattenedUserProfile(response, schemas);
|
|
49
|
+
* // Result: { "name.givenName": 'John', emails: ['john@example.com'], country: 'US' }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
declare const generateFlattenedUserProfile: (meResponse: any, processedSchemas: any[]) => User;
|
|
53
|
+
export default generateFlattenedUserProfile;
|
|
@@ -0,0 +1,55 @@
|
|
|
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 { User } from '../models/user';
|
|
19
|
+
/**
|
|
20
|
+
* Creates a profile structure from ME response based on processed schemas
|
|
21
|
+
*
|
|
22
|
+
* This function processes each schema attribute and populates the profile dynamically by:
|
|
23
|
+
* - Extracting values from the ME response using the schema attribute names
|
|
24
|
+
* - Handling multi-valued attributes by converting single values to arrays when needed
|
|
25
|
+
* - Setting appropriate default values based on schema type and multiValued properties
|
|
26
|
+
* - Using dynamic property setting to build the final profile object
|
|
27
|
+
*
|
|
28
|
+
* @param meResponse - The ME API response containing user data
|
|
29
|
+
* @param processedSchemas - The processed and flattened schemas with name, type, and multiValued properties
|
|
30
|
+
* @returns Flat profile object with dynamically populated user attributes
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const meResponse = {
|
|
35
|
+
* userName: 'john.doe',
|
|
36
|
+
* emails: ['john@example.com', 'john.doe@work.com'],
|
|
37
|
+
* name: { givenName: 'John', familyName: 'Doe' }
|
|
38
|
+
* };
|
|
39
|
+
*
|
|
40
|
+
* const schemas = [
|
|
41
|
+
* { name: 'userName', type: 'STRING', multiValued: false },
|
|
42
|
+
* { name: 'emails', type: 'STRING', multiValued: true },
|
|
43
|
+
* { name: 'name.givenName', type: 'STRING', multiValued: false }
|
|
44
|
+
* ];
|
|
45
|
+
*
|
|
46
|
+
* const profile = generateUserProfile(meResponse, schemas);
|
|
47
|
+
* // Result: {
|
|
48
|
+
* // userName: 'john.doe',
|
|
49
|
+
* // emails: ['john@example.com', 'john.doe@work.com'],
|
|
50
|
+
* // 'name.givenName': 'John'
|
|
51
|
+
* // }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
declare const generateUserProfile: (meResponse: any, processedSchemas: any[]) => User;
|
|
55
|
+
export default generateUserProfile;
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
* Gets the value at path of object. If the resolved value is undefined,
|
|
20
|
+
* the defaultValue is returned in its place.
|
|
21
|
+
* Similar to Lodash's get() function
|
|
22
|
+
*
|
|
23
|
+
* @param object - The object to query
|
|
24
|
+
* @param path - The path of the property to get
|
|
25
|
+
* @param defaultValue - The value returned for undefined resolved values
|
|
26
|
+
* @returns The resolved value
|
|
27
|
+
*/
|
|
28
|
+
declare const get: (object: any, path: string | string[], defaultValue?: any) => any;
|
|
29
|
+
export default get;
|
|
@@ -0,0 +1,59 @@
|
|
|
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 { ExtendedAuthorizeRequestUrlParams } from '../models/oauth-request';
|
|
19
|
+
/**
|
|
20
|
+
* Generates a map of authorization request URL parameters for OIDC authorization requests.
|
|
21
|
+
*
|
|
22
|
+
* This utility ensures the `openid` scope is always included, handles both string and array forms of the `scope` parameter,
|
|
23
|
+
* and supports PKCE and custom parameters. Throws if a code challenge is provided without a code challenge method.
|
|
24
|
+
*
|
|
25
|
+
* @param options - The main options for the authorization request, including redirectUri, clientId, scope, responseMode, codeChallenge, codeChallengeMethod, and prompt.
|
|
26
|
+
* @param pkceOptions - PKCE options, including the PKCE key for state correlation.
|
|
27
|
+
* @param customParams - Optional custom parameters to include in the request (excluding the `state` param, which is handled separately).
|
|
28
|
+
* @returns A Map of key-value pairs representing the authorization request URL parameters.
|
|
29
|
+
*
|
|
30
|
+
* @throws {AsgardeoRuntimeError} If a code challenge is provided without a code challenge method.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* const params = getAuthorizeRequestUrlParams({
|
|
34
|
+
* options: {
|
|
35
|
+
* redirectUri: 'https://app/callback',
|
|
36
|
+
* clientId: 'client123',
|
|
37
|
+
* scope: ['openid', 'profile'],
|
|
38
|
+
* responseMode: 'query',
|
|
39
|
+
* codeChallenge: 'abc',
|
|
40
|
+
* codeChallengeMethod: 'S256',
|
|
41
|
+
* prompt: 'login'
|
|
42
|
+
* },
|
|
43
|
+
* pkceOptions: { key: 'pkce_code_verifier_1' },
|
|
44
|
+
* customParams: { foo: 'bar' }
|
|
45
|
+
* });
|
|
46
|
+
* // Returns a Map with all required OIDC params, PKCE, and custom params.
|
|
47
|
+
*/
|
|
48
|
+
declare const getAuthorizeRequestUrlParams: (options: {
|
|
49
|
+
redirectUri: string;
|
|
50
|
+
clientId: string;
|
|
51
|
+
scopes?: string;
|
|
52
|
+
responseMode?: string;
|
|
53
|
+
codeChallenge?: string;
|
|
54
|
+
codeChallengeMethod?: string;
|
|
55
|
+
prompt?: string;
|
|
56
|
+
} & ExtendedAuthorizeRequestUrlParams, pkceOptions: {
|
|
57
|
+
key: string;
|
|
58
|
+
}, customParams: Record<string, string | number | boolean>) => Map<string, string>;
|
|
59
|
+
export default getAuthorizeRequestUrlParams;
|