@asgardeo/javascript 0.7.1 → 0.7.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 +3 -4
- package/dist/IsomorphicCrypto.d.ts +2 -2
- package/dist/StorageManager.d.ts +6 -8
- package/dist/__legacy__/client.d.ts +15 -15
- package/dist/__legacy__/helpers/authentication-helper.d.ts +5 -5
- package/dist/__legacy__/models/client-config.d.ts +14 -14
- package/dist/api/createOrganization.d.ts +8 -8
- package/dist/api/getAllOrganizations.d.ts +5 -5
- package/dist/api/getBrandingPreference.d.ts +5 -5
- package/dist/api/getMeOrganizations.d.ts +9 -9
- package/dist/api/getOrganization.d.ts +4 -4
- package/dist/api/getSchemas.d.ts +4 -4
- package/dist/api/getScim2Me.d.ts +4 -4
- package/dist/api/updateMeProfile.d.ts +7 -7
- package/dist/api/updateOrganization.d.ts +5 -5
- package/dist/api/v2/executeEmbeddedUserOnboardingFlowV2.d.ts +16 -16
- package/dist/cjs/index.js +1183 -1186
- package/dist/cjs/index.js.map +4 -4
- package/dist/constants/ApplicationNativeAuthenticationConstants.d.ts +14 -14
- package/dist/constants/OIDCDiscoveryConstants.d.ts +17 -106
- package/dist/constants/OIDCRequestConstants.d.ts +6 -44
- package/dist/constants/PKCEConstants.d.ts +3 -18
- package/dist/constants/TokenConstants.d.ts +2 -31
- package/dist/constants/TokenExchangeConstants.d.ts +5 -30
- package/dist/index.js +1184 -1187
- package/dist/index.js.map +4 -4
- package/dist/models/branding-preference.d.ts +5 -5
- package/dist/models/client.d.ts +57 -58
- package/dist/models/config.d.ts +48 -48
- package/dist/models/crypto.d.ts +11 -11
- package/dist/models/embedded-flow.d.ts +10 -10
- package/dist/models/field.d.ts +8 -8
- package/dist/models/oidc-discovery.d.ts +161 -161
- package/dist/models/oidc-endpoints.d.ts +15 -15
- package/dist/models/platforms.d.ts +2 -2
- package/dist/models/scim2-schema.d.ts +17 -17
- package/dist/models/session.d.ts +4 -4
- package/dist/models/store.d.ts +9 -9
- package/dist/models/user.d.ts +5 -5
- package/dist/models/v2/embedded-flow-v2.d.ts +86 -86
- package/dist/models/v2/embedded-signin-flow-v2.d.ts +39 -39
- package/dist/models/v2/embedded-signup-flow-v2.d.ts +42 -42
- package/dist/theme/types.d.ts +133 -133
- package/dist/utils/getAuthorizeRequestUrlParams.d.ts +4 -3
- package/dist/utils/logger.d.ts +6 -6
- package/dist/utils/processUsername.d.ts +1 -1
- package/package.json +1 -1
- package/dist/utils/cryptoUtils.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -2,144 +2,6 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
|
|
5
|
-
// src/StorageManager.ts
|
|
6
|
-
var ASGARDEO_SESSION_ACTIVE = "asgardeo-session-active";
|
|
7
|
-
var StorageManager = class {
|
|
8
|
-
constructor(instanceID, store) {
|
|
9
|
-
__publicField(this, "_id");
|
|
10
|
-
__publicField(this, "_store");
|
|
11
|
-
this._id = instanceID;
|
|
12
|
-
this._store = store;
|
|
13
|
-
}
|
|
14
|
-
async setDataInBulk(key, data) {
|
|
15
|
-
const existingDataJSON = await this._store.getData(key) ?? null;
|
|
16
|
-
const existingData = existingDataJSON && JSON.parse(existingDataJSON);
|
|
17
|
-
const dataToBeSaved = { ...existingData, ...data };
|
|
18
|
-
const dataToBeSavedJSON = JSON.stringify(dataToBeSaved);
|
|
19
|
-
await this._store.setData(key, dataToBeSavedJSON);
|
|
20
|
-
}
|
|
21
|
-
async setValue(key, attribute, value) {
|
|
22
|
-
const existingDataJSON = await this._store.getData(key) ?? null;
|
|
23
|
-
const existingData = existingDataJSON && JSON.parse(existingDataJSON);
|
|
24
|
-
const dataToBeSaved = { ...existingData, [attribute]: value };
|
|
25
|
-
const dataToBeSavedJSON = JSON.stringify(dataToBeSaved);
|
|
26
|
-
await this._store.setData(key, dataToBeSavedJSON);
|
|
27
|
-
}
|
|
28
|
-
async removeValue(key, attribute) {
|
|
29
|
-
const existingDataJSON = await this._store.getData(key) ?? null;
|
|
30
|
-
const existingData = existingDataJSON && JSON.parse(existingDataJSON);
|
|
31
|
-
const dataToBeSaved = { ...existingData };
|
|
32
|
-
delete dataToBeSaved[attribute];
|
|
33
|
-
const dataToBeSavedJSON = JSON.stringify(dataToBeSaved);
|
|
34
|
-
await this._store.setData(key, dataToBeSavedJSON);
|
|
35
|
-
}
|
|
36
|
-
_resolveKey(store, userId) {
|
|
37
|
-
return userId ? `${store}-${this._id}-${userId}` : `${store}-${this._id}`;
|
|
38
|
-
}
|
|
39
|
-
isLocalStorageAvailable() {
|
|
40
|
-
try {
|
|
41
|
-
const testValue = "__ASGARDEO_AUTH_CORE_LOCAL_STORAGE_TEST__";
|
|
42
|
-
localStorage.setItem(testValue, testValue);
|
|
43
|
-
localStorage.removeItem(testValue);
|
|
44
|
-
return true;
|
|
45
|
-
} catch (error2) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
async setConfigData(config) {
|
|
50
|
-
await this.setDataInBulk(this._resolveKey("config_data" /* ConfigData */), config);
|
|
51
|
-
}
|
|
52
|
-
async setOIDCProviderMetaData(oidcProviderMetaData) {
|
|
53
|
-
this.setDataInBulk(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), oidcProviderMetaData);
|
|
54
|
-
}
|
|
55
|
-
async setTemporaryData(temporaryData, userId) {
|
|
56
|
-
this.setDataInBulk(this._resolveKey("temporary_data" /* TemporaryData */, userId), temporaryData);
|
|
57
|
-
}
|
|
58
|
-
async setSessionData(sessionData, userId) {
|
|
59
|
-
this.setDataInBulk(this._resolveKey("session_data" /* SessionData */, userId), sessionData);
|
|
60
|
-
}
|
|
61
|
-
async setCustomData(key, customData, userId) {
|
|
62
|
-
this.setDataInBulk(this._resolveKey(key, userId), customData);
|
|
63
|
-
}
|
|
64
|
-
async getConfigData(userId) {
|
|
65
|
-
return JSON.parse(await this._store.getData(this._resolveKey("config_data" /* ConfigData */, userId)) ?? null);
|
|
66
|
-
}
|
|
67
|
-
async loadOpenIDProviderConfiguration() {
|
|
68
|
-
return JSON.parse(await this._store.getData(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */)) ?? null);
|
|
69
|
-
}
|
|
70
|
-
async getTemporaryData(userId) {
|
|
71
|
-
return JSON.parse(await this._store.getData(this._resolveKey("temporary_data" /* TemporaryData */, userId)) ?? null);
|
|
72
|
-
}
|
|
73
|
-
async getSessionData(userId) {
|
|
74
|
-
return JSON.parse(await this._store.getData(this._resolveKey("session_data" /* SessionData */, userId)) ?? null);
|
|
75
|
-
}
|
|
76
|
-
async getCustomData(key, userId) {
|
|
77
|
-
return JSON.parse(await this._store.getData(this._resolveKey(key, userId)) ?? null);
|
|
78
|
-
}
|
|
79
|
-
setSessionStatus(status) {
|
|
80
|
-
this.isLocalStorageAvailable() && localStorage.setItem(`${ASGARDEO_SESSION_ACTIVE}`, status);
|
|
81
|
-
}
|
|
82
|
-
getSessionStatus() {
|
|
83
|
-
return this.isLocalStorageAvailable() ? localStorage.getItem(`${ASGARDEO_SESSION_ACTIVE}`) ?? "" : "";
|
|
84
|
-
}
|
|
85
|
-
removeSessionStatus() {
|
|
86
|
-
this.isLocalStorageAvailable() && localStorage.removeItem(`${ASGARDEO_SESSION_ACTIVE}`);
|
|
87
|
-
}
|
|
88
|
-
async removeConfigData() {
|
|
89
|
-
await this._store.removeData(this._resolveKey("config_data" /* ConfigData */));
|
|
90
|
-
}
|
|
91
|
-
async removeOIDCProviderMetaData() {
|
|
92
|
-
await this._store.removeData(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */));
|
|
93
|
-
}
|
|
94
|
-
async removeTemporaryData(userId) {
|
|
95
|
-
await this._store.removeData(this._resolveKey("temporary_data" /* TemporaryData */, userId));
|
|
96
|
-
}
|
|
97
|
-
async removeSessionData(userId) {
|
|
98
|
-
await this._store.removeData(this._resolveKey("session_data" /* SessionData */, userId));
|
|
99
|
-
}
|
|
100
|
-
async getConfigDataParameter(key) {
|
|
101
|
-
const data = await this._store.getData(this._resolveKey("config_data" /* ConfigData */));
|
|
102
|
-
return data && JSON.parse(data)[key];
|
|
103
|
-
}
|
|
104
|
-
async getOIDCProviderMetaDataParameter(key) {
|
|
105
|
-
const data = await this._store.getData(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */));
|
|
106
|
-
return data && JSON.parse(data)[key];
|
|
107
|
-
}
|
|
108
|
-
async getTemporaryDataParameter(key, userId) {
|
|
109
|
-
const data = await this._store.getData(this._resolveKey("temporary_data" /* TemporaryData */, userId));
|
|
110
|
-
return data && JSON.parse(data)[key];
|
|
111
|
-
}
|
|
112
|
-
async getSessionDataParameter(key, userId) {
|
|
113
|
-
const data = await this._store.getData(this._resolveKey("session_data" /* SessionData */, userId));
|
|
114
|
-
return data && JSON.parse(data)[key];
|
|
115
|
-
}
|
|
116
|
-
async setConfigDataParameter(key, value) {
|
|
117
|
-
await this.setValue(this._resolveKey("config_data" /* ConfigData */), key, value);
|
|
118
|
-
}
|
|
119
|
-
async setOIDCProviderMetaDataParameter(key, value) {
|
|
120
|
-
await this.setValue(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), key, value);
|
|
121
|
-
}
|
|
122
|
-
async setTemporaryDataParameter(key, value, userId) {
|
|
123
|
-
await this.setValue(this._resolveKey("temporary_data" /* TemporaryData */, userId), key, value);
|
|
124
|
-
}
|
|
125
|
-
async setSessionDataParameter(key, value, userId) {
|
|
126
|
-
await this.setValue(this._resolveKey("session_data" /* SessionData */, userId), key, value);
|
|
127
|
-
}
|
|
128
|
-
async removeConfigDataParameter(key) {
|
|
129
|
-
await this.removeValue(this._resolveKey("config_data" /* ConfigData */), key);
|
|
130
|
-
}
|
|
131
|
-
async removeOIDCProviderMetaDataParameter(key) {
|
|
132
|
-
await this.removeValue(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), key);
|
|
133
|
-
}
|
|
134
|
-
async removeTemporaryDataParameter(key, userId) {
|
|
135
|
-
await this.removeValue(this._resolveKey("temporary_data" /* TemporaryData */, userId), key);
|
|
136
|
-
}
|
|
137
|
-
async removeSessionDataParameter(key, userId) {
|
|
138
|
-
await this.removeValue(this._resolveKey("session_data" /* SessionData */, userId), key);
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
var StorageManager_default = StorageManager;
|
|
142
|
-
|
|
143
5
|
// src/constants/OIDCDiscoveryConstants.ts
|
|
144
6
|
var OIDCDiscoveryConstants = {
|
|
145
7
|
/**
|
|
@@ -153,11 +15,6 @@ var OIDCDiscoveryConstants = {
|
|
|
153
15
|
* This endpoint is used to request authorization and receive an authorization code.
|
|
154
16
|
*/
|
|
155
17
|
AUTHORIZATION: "/oauth2/authorize",
|
|
156
|
-
/**
|
|
157
|
-
* Session check iframe endpoint for session management.
|
|
158
|
-
* Used to monitor the user's session state through a hidden iframe.
|
|
159
|
-
*/
|
|
160
|
-
SESSION_IFRAME: "/oidc/checksession",
|
|
161
18
|
/**
|
|
162
19
|
* End session endpoint for logout functionality.
|
|
163
20
|
* Used to terminate the user's session and perform logout operations.
|
|
@@ -178,6 +35,11 @@ var OIDCDiscoveryConstants = {
|
|
|
178
35
|
* Used to invalidate access or refresh tokens before they expire.
|
|
179
36
|
*/
|
|
180
37
|
REVOCATION: "/oauth2/revoke",
|
|
38
|
+
/**
|
|
39
|
+
* Session check iframe endpoint for session management.
|
|
40
|
+
* Used to monitor the user's session state through a hidden iframe.
|
|
41
|
+
*/
|
|
42
|
+
SESSION_IFRAME: "/oidc/checksession",
|
|
181
43
|
/**
|
|
182
44
|
* Token endpoint for obtaining access tokens.
|
|
183
45
|
* Used to exchange authorization codes for access tokens and refresh tokens.
|
|
@@ -212,36 +74,36 @@ var OIDCDiscoveryConstants = {
|
|
|
212
74
|
* Used to store the URL where authorization requests should be sent.
|
|
213
75
|
*/
|
|
214
76
|
AUTHORIZATION: "authorization_endpoint",
|
|
215
|
-
/**
|
|
216
|
-
* Storage key for the token endpoint URL.
|
|
217
|
-
* Used to store the URL where token requests should be sent.
|
|
218
|
-
*/
|
|
219
|
-
TOKEN: "token_endpoint",
|
|
220
|
-
/**
|
|
221
|
-
* Storage key for the revocation endpoint URL.
|
|
222
|
-
* Used to store the URL where token revocation requests should be sent.
|
|
223
|
-
*/
|
|
224
|
-
REVOCATION: "revocation_endpoint",
|
|
225
77
|
/**
|
|
226
78
|
* Storage key for the end session endpoint URL.
|
|
227
79
|
* Used to store the URL where logout requests should be sent.
|
|
228
80
|
*/
|
|
229
81
|
END_SESSION: "end_session_endpoint",
|
|
82
|
+
/**
|
|
83
|
+
* Storage key for the issuer identifier URL.
|
|
84
|
+
* Used to store the URL that identifies the OpenID Provider.
|
|
85
|
+
*/
|
|
86
|
+
ISSUER: "issuer",
|
|
230
87
|
/**
|
|
231
88
|
* Storage key for the JWKS URI endpoint URL.
|
|
232
89
|
* Used to store the URL where JSON Web Key Sets can be retrieved.
|
|
233
90
|
*/
|
|
234
91
|
JWKS: "jwks_uri",
|
|
92
|
+
/**
|
|
93
|
+
* Storage key for the revocation endpoint URL.
|
|
94
|
+
* Used to store the URL where token revocation requests should be sent.
|
|
95
|
+
*/
|
|
96
|
+
REVOCATION: "revocation_endpoint",
|
|
235
97
|
/**
|
|
236
98
|
* Storage key for the session check iframe URL.
|
|
237
99
|
* Used to store the URL of the iframe used for session state monitoring.
|
|
238
100
|
*/
|
|
239
101
|
SESSION_IFRAME: "check_session_iframe",
|
|
240
102
|
/**
|
|
241
|
-
* Storage key for the
|
|
242
|
-
* Used to store the URL
|
|
103
|
+
* Storage key for the token endpoint URL.
|
|
104
|
+
* Used to store the URL where token requests should be sent.
|
|
243
105
|
*/
|
|
244
|
-
|
|
106
|
+
TOKEN: "token_endpoint",
|
|
245
107
|
/**
|
|
246
108
|
* Storage key for the userinfo endpoint URL.
|
|
247
109
|
* Used to store the URL where user information can be retrieved.
|
|
@@ -259,6 +121,93 @@ var OIDCDiscoveryConstants = {
|
|
|
259
121
|
};
|
|
260
122
|
var OIDCDiscoveryConstants_default = OIDCDiscoveryConstants;
|
|
261
123
|
|
|
124
|
+
// src/constants/TokenExchangeConstants.ts
|
|
125
|
+
var TokenExchangeConstants = {
|
|
126
|
+
/**
|
|
127
|
+
* Collection of placeholder strings used in token exchange operations.
|
|
128
|
+
* These placeholders are replaced with actual values when processing
|
|
129
|
+
* token exchange requests.
|
|
130
|
+
*/
|
|
131
|
+
Placeholders: {
|
|
132
|
+
/**
|
|
133
|
+
* Placeholder for the token value in exchange requests.
|
|
134
|
+
* Usually replaced with an access token or refresh token.
|
|
135
|
+
*/
|
|
136
|
+
ACCESS_TOKEN: "{{accessToken}}",
|
|
137
|
+
/**
|
|
138
|
+
* Placeholder for client ID in token exchange operations.
|
|
139
|
+
* Required for client authentication.
|
|
140
|
+
*/
|
|
141
|
+
CLIENT_ID: "{{clientId}}",
|
|
142
|
+
/**
|
|
143
|
+
* Placeholder for client secret in token exchange operations.
|
|
144
|
+
* Used for client authentication in confidential client flows.
|
|
145
|
+
*/
|
|
146
|
+
CLIENT_SECRET: "{{clientSecret}}",
|
|
147
|
+
/**
|
|
148
|
+
* Placeholder for OAuth scopes in token exchange requests.
|
|
149
|
+
* Replaced with space-separated scope strings.
|
|
150
|
+
*/
|
|
151
|
+
SCOPES: "{{scopes}}",
|
|
152
|
+
/**
|
|
153
|
+
* Placeholder for the username in token exchange operations.
|
|
154
|
+
* Used when user identity needs to be included in the exchange.
|
|
155
|
+
*/
|
|
156
|
+
USERNAME: "{{username}}"
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
var TokenExchangeConstants_default = TokenExchangeConstants;
|
|
160
|
+
|
|
161
|
+
// src/errors/exception.ts
|
|
162
|
+
var AsgardeoAuthException = class {
|
|
163
|
+
constructor(code, name, message) {
|
|
164
|
+
__publicField(this, "name");
|
|
165
|
+
__publicField(this, "code");
|
|
166
|
+
__publicField(this, "message");
|
|
167
|
+
this.message = message;
|
|
168
|
+
this.name = name;
|
|
169
|
+
this.code = code;
|
|
170
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// src/models/platforms.ts
|
|
175
|
+
var Platform = /* @__PURE__ */ ((Platform2) => {
|
|
176
|
+
Platform2["Asgardeo"] = "ASGARDEO";
|
|
177
|
+
Platform2["AsgardeoV2"] = "AsgardeoV2";
|
|
178
|
+
Platform2["IdentityServer"] = "IDENTITY_SERVER";
|
|
179
|
+
Platform2["Unknown"] = "UNKNOWN";
|
|
180
|
+
return Platform2;
|
|
181
|
+
})(Platform || {});
|
|
182
|
+
|
|
183
|
+
// src/utils/extractUserClaimsFromIdToken.ts
|
|
184
|
+
var extractUserClaimsFromIdToken = (payload) => {
|
|
185
|
+
const filteredPayload = { ...payload };
|
|
186
|
+
const protocolClaims = [
|
|
187
|
+
"iss",
|
|
188
|
+
"aud",
|
|
189
|
+
"exp",
|
|
190
|
+
"iat",
|
|
191
|
+
"acr",
|
|
192
|
+
"amr",
|
|
193
|
+
"azp",
|
|
194
|
+
"auth_time",
|
|
195
|
+
"nonce",
|
|
196
|
+
"c_hash",
|
|
197
|
+
"at_hash",
|
|
198
|
+
"nbf",
|
|
199
|
+
"isk",
|
|
200
|
+
"sid",
|
|
201
|
+
"jti",
|
|
202
|
+
"sub"
|
|
203
|
+
];
|
|
204
|
+
protocolClaims.forEach((claim) => {
|
|
205
|
+
delete filteredPayload[claim];
|
|
206
|
+
});
|
|
207
|
+
return filteredPayload;
|
|
208
|
+
};
|
|
209
|
+
var extractUserClaimsFromIdToken_default = extractUserClaimsFromIdToken;
|
|
210
|
+
|
|
262
211
|
// src/constants/ScopeConstants.ts
|
|
263
212
|
var ScopeConstants = {
|
|
264
213
|
/**
|
|
@@ -294,16 +243,16 @@ var OIDCRequestConstants = {
|
|
|
294
243
|
* Session state parameter used for session management between the client and the OP.
|
|
295
244
|
*/
|
|
296
245
|
SESSION_STATE: "session_state",
|
|
297
|
-
/**
|
|
298
|
-
* State parameter used to maintain state between the request and the callback.
|
|
299
|
-
* Helps in preventing CSRF attacks.
|
|
300
|
-
*/
|
|
301
|
-
STATE: "state",
|
|
302
246
|
/**
|
|
303
247
|
* Indicates whether sign-out was successful during the end-session flow.
|
|
304
248
|
* May be returned by the OP after a logout request.
|
|
305
249
|
*/
|
|
306
|
-
SIGN_OUT_SUCCESS: "sign_out_success"
|
|
250
|
+
SIGN_OUT_SUCCESS: "sign_out_success",
|
|
251
|
+
/**
|
|
252
|
+
* State parameter used to maintain state between the request and the callback.
|
|
253
|
+
* Helps in preventing CSRF attacks.
|
|
254
|
+
*/
|
|
255
|
+
STATE: "state"
|
|
307
256
|
},
|
|
308
257
|
/**
|
|
309
258
|
* Constants related to the OpenID Connect (OIDC) sign-in flow.
|
|
@@ -343,22 +292,327 @@ var OIDCRequestConstants = {
|
|
|
343
292
|
};
|
|
344
293
|
var OIDCRequestConstants_default = OIDCRequestConstants;
|
|
345
294
|
|
|
346
|
-
// src/errors/
|
|
347
|
-
var
|
|
348
|
-
constructor(
|
|
349
|
-
|
|
295
|
+
// src/errors/AsgardeoError.ts
|
|
296
|
+
var AsgardeoError = class _AsgardeoError extends Error {
|
|
297
|
+
constructor(message, code, origin) {
|
|
298
|
+
const resolvedOrigin = _AsgardeoError.resolveOrigin(origin);
|
|
299
|
+
super(message);
|
|
350
300
|
__publicField(this, "code");
|
|
351
|
-
__publicField(this, "
|
|
352
|
-
this.
|
|
353
|
-
this.name = name;
|
|
301
|
+
__publicField(this, "origin");
|
|
302
|
+
this.name = new.target.name;
|
|
354
303
|
this.code = code;
|
|
355
|
-
|
|
304
|
+
this.origin = resolvedOrigin;
|
|
305
|
+
if (Error.captureStackTrace) {
|
|
306
|
+
Error.captureStackTrace(this, new.target);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
static resolveOrigin(origin) {
|
|
310
|
+
if (!origin) {
|
|
311
|
+
return "@asgardeo/javascript";
|
|
312
|
+
}
|
|
313
|
+
return `@asgardeo/${origin}`;
|
|
314
|
+
}
|
|
315
|
+
toString() {
|
|
316
|
+
const prefix = `\u{1F6E1}\uFE0F Asgardeo - ${this.origin}:`;
|
|
317
|
+
return `[${this.name}]
|
|
318
|
+
${prefix} ${this.message}
|
|
319
|
+
(code="${this.code}")`;
|
|
356
320
|
}
|
|
357
321
|
};
|
|
358
322
|
|
|
359
|
-
// src/
|
|
360
|
-
var
|
|
361
|
-
/**
|
|
323
|
+
// src/errors/AsgardeoRuntimeError.ts
|
|
324
|
+
var AsgardeoRuntimeError = class extends AsgardeoError {
|
|
325
|
+
/**
|
|
326
|
+
* Creates an instance of AsgardeoRuntimeError.
|
|
327
|
+
*
|
|
328
|
+
* @param message - Human-readable description of the error
|
|
329
|
+
* @param code - A unique error code that identifies the error type
|
|
330
|
+
* @param details - Additional details about the error that might be helpful for debugging
|
|
331
|
+
* @param origin - Optional. The SDK origin (e.g. 'react', 'vue'). Defaults to generic 'Asgardeo'
|
|
332
|
+
* @constructor
|
|
333
|
+
*/
|
|
334
|
+
constructor(message, code, origin, details) {
|
|
335
|
+
super(message, code, origin);
|
|
336
|
+
this.details = details;
|
|
337
|
+
Object.defineProperty(this, "name", {
|
|
338
|
+
configurable: true,
|
|
339
|
+
value: "AsgardeoRuntimeError",
|
|
340
|
+
writable: true
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Returns a string representation of the runtime error
|
|
345
|
+
* @returns Formatted error string with name, code, details, and message
|
|
346
|
+
*/
|
|
347
|
+
toString() {
|
|
348
|
+
const details = this.details ? `
|
|
349
|
+
Details: ${JSON.stringify(this.details, null, 2)}` : "";
|
|
350
|
+
return `[${this.name}] (code="${this.code}")${details}
|
|
351
|
+
Message: ${this.message}`;
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
// src/utils/processOpenIDScopes.ts
|
|
356
|
+
var processOpenIDScopes = (scopes) => {
|
|
357
|
+
let processedScopes = [];
|
|
358
|
+
if (scopes) {
|
|
359
|
+
if (Array.isArray(scopes)) {
|
|
360
|
+
processedScopes = scopes;
|
|
361
|
+
} else if (typeof scopes === "string") {
|
|
362
|
+
processedScopes = scopes.split(" ");
|
|
363
|
+
} else {
|
|
364
|
+
throw new AsgardeoRuntimeError(
|
|
365
|
+
"Scopes must be a string or an array of strings.",
|
|
366
|
+
"processOpenIDScopes-Invalid-001",
|
|
367
|
+
"javascript",
|
|
368
|
+
"The provided scopes are not in the expected format. Please provide a string or an array of strings."
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
OIDCRequestConstants_default.SignIn.Payload.DEFAULT_SCOPES.forEach((defaultScope) => {
|
|
373
|
+
if (!processedScopes.includes(defaultScope)) {
|
|
374
|
+
processedScopes.push(defaultScope);
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
return processedScopes.join(" ");
|
|
378
|
+
};
|
|
379
|
+
var processOpenIDScopes_default = processOpenIDScopes;
|
|
380
|
+
|
|
381
|
+
// src/__legacy__/helpers/authentication-helper.ts
|
|
382
|
+
var AuthenticationHelper = class {
|
|
383
|
+
constructor(storageManagerInstance, cryptoHelperInstance) {
|
|
384
|
+
__publicField(this, "storageManager");
|
|
385
|
+
__publicField(this, "config");
|
|
386
|
+
__publicField(this, "oidcProviderMetaData");
|
|
387
|
+
__publicField(this, "cryptoHelper");
|
|
388
|
+
this.storageManager = storageManagerInstance;
|
|
389
|
+
this.config = async () => this.storageManager.getConfigData();
|
|
390
|
+
this.oidcProviderMetaData = async () => this.storageManager.loadOpenIDProviderConfiguration();
|
|
391
|
+
this.cryptoHelper = cryptoHelperInstance;
|
|
392
|
+
}
|
|
393
|
+
async resolveEndpoints(response) {
|
|
394
|
+
const oidcProviderMetaData = {};
|
|
395
|
+
const configData = await this.config();
|
|
396
|
+
if (configData.endpoints) {
|
|
397
|
+
Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
398
|
+
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
399
|
+
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
return { ...response, ...oidcProviderMetaData };
|
|
403
|
+
}
|
|
404
|
+
async resolveEndpointsExplicitly() {
|
|
405
|
+
const oidcProviderMetaData = {};
|
|
406
|
+
const configData = await this.config();
|
|
407
|
+
const requiredEndpoints = [
|
|
408
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.AUTHORIZATION,
|
|
409
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.END_SESSION,
|
|
410
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.JWKS,
|
|
411
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.SESSION_IFRAME,
|
|
412
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.REVOCATION,
|
|
413
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.TOKEN,
|
|
414
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.ISSUER,
|
|
415
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.USERINFO
|
|
416
|
+
];
|
|
417
|
+
const isRequiredEndpointsContains = configData.endpoints ? requiredEndpoints.every(
|
|
418
|
+
(reqEndpointName) => configData.endpoints ? Object.keys(configData.endpoints).some((endpointName) => {
|
|
419
|
+
const snakeCasedName = endpointName.replace(
|
|
420
|
+
/[A-Z]/g,
|
|
421
|
+
(letter) => `_${letter.toLowerCase()}`
|
|
422
|
+
);
|
|
423
|
+
return snakeCasedName === reqEndpointName;
|
|
424
|
+
}) : false
|
|
425
|
+
) : false;
|
|
426
|
+
if (!isRequiredEndpointsContains) {
|
|
427
|
+
throw new AsgardeoAuthException(
|
|
428
|
+
"JS-AUTH_HELPER-REE-NF01",
|
|
429
|
+
"Required endpoints missing",
|
|
430
|
+
"Some or all of the required endpoints are missing in the object passed to the `endpoints` attribute of the`AuthConfig` object."
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
if (configData.endpoints) {
|
|
434
|
+
Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
435
|
+
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
436
|
+
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
return { ...oidcProviderMetaData };
|
|
440
|
+
}
|
|
441
|
+
async resolveEndpointsByBaseURL() {
|
|
442
|
+
const oidcProviderMetaData = {};
|
|
443
|
+
const configData = await this.config();
|
|
444
|
+
const { baseUrl } = configData;
|
|
445
|
+
if (!baseUrl) {
|
|
446
|
+
throw new AsgardeoAuthException(
|
|
447
|
+
"JS-AUTH_HELPER_REBO-NF01",
|
|
448
|
+
"Base URL not defined.",
|
|
449
|
+
"Base URL is not defined in AuthClient config."
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
if (configData.endpoints) {
|
|
453
|
+
Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
454
|
+
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
455
|
+
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
const endpointKeys = OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints;
|
|
459
|
+
const endpointPaths = OIDCDiscoveryConstants_default.Endpoints;
|
|
460
|
+
const defaultEndpoints = {
|
|
461
|
+
[endpointKeys.AUTHORIZATION]: `${baseUrl}${endpointPaths.AUTHORIZATION}`,
|
|
462
|
+
[endpointKeys.END_SESSION]: `${baseUrl}${endpointPaths.END_SESSION}`,
|
|
463
|
+
[endpointKeys.ISSUER]: `${baseUrl}${endpointPaths.ISSUER}`,
|
|
464
|
+
[endpointKeys.JWKS]: `${baseUrl}${endpointPaths.JWKS}`,
|
|
465
|
+
[endpointKeys.SESSION_IFRAME]: `${baseUrl}${endpointPaths.SESSION_IFRAME}`,
|
|
466
|
+
[endpointKeys.REVOCATION]: `${baseUrl}${endpointPaths.REVOCATION}`,
|
|
467
|
+
[endpointKeys.TOKEN]: `${baseUrl}${endpointPaths.TOKEN}`,
|
|
468
|
+
[endpointKeys.USERINFO]: `${baseUrl}${endpointPaths.USERINFO}`
|
|
469
|
+
};
|
|
470
|
+
if (configData.platform === "AsgardeoV2" /* AsgardeoV2 */) {
|
|
471
|
+
defaultEndpoints[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.ISSUER] = `${baseUrl}`;
|
|
472
|
+
}
|
|
473
|
+
return { ...defaultEndpoints, ...oidcProviderMetaData };
|
|
474
|
+
}
|
|
475
|
+
async validateIdToken(idToken) {
|
|
476
|
+
const jwksEndpoint = (await this.storageManager.loadOpenIDProviderConfiguration()).jwks_uri;
|
|
477
|
+
const configData = await this.config();
|
|
478
|
+
if (!jwksEndpoint || jwksEndpoint.trim().length === 0) {
|
|
479
|
+
throw new AsgardeoAuthException(
|
|
480
|
+
"JS_AUTH_HELPER-VIT-NF01",
|
|
481
|
+
"JWKS endpoint not found.",
|
|
482
|
+
"No JWKS endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the JWKS endpoint passed to the SDK is empty."
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
let response;
|
|
486
|
+
try {
|
|
487
|
+
response = await fetch(jwksEndpoint, {
|
|
488
|
+
credentials: configData.sendCookiesInRequests ? "include" : "same-origin"
|
|
489
|
+
});
|
|
490
|
+
} catch (error2) {
|
|
491
|
+
throw new AsgardeoAuthException(
|
|
492
|
+
"JS-AUTH_HELPER-VIT-NE02",
|
|
493
|
+
"Request to jwks endpoint failed.",
|
|
494
|
+
error2 ?? "The request sent to get the jwks from the server failed."
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
if (response.status !== 200 || !response.ok) {
|
|
498
|
+
throw new AsgardeoAuthException(
|
|
499
|
+
"JS-AUTH_HELPER-VIT-HE03",
|
|
500
|
+
`Invalid response status received for jwks request (${response.statusText}).`,
|
|
501
|
+
await response.json()
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
const { issuer } = await this.oidcProviderMetaData();
|
|
505
|
+
const { keys } = await response.json();
|
|
506
|
+
const jwk = await this.cryptoHelper.getJWKForTheIdToken(idToken.split(".")[0], keys);
|
|
507
|
+
return this.cryptoHelper.isValidIdToken(
|
|
508
|
+
idToken,
|
|
509
|
+
jwk,
|
|
510
|
+
(await this.config()).clientId,
|
|
511
|
+
issuer ?? "",
|
|
512
|
+
this.cryptoHelper.decodeJwtToken(idToken).sub,
|
|
513
|
+
(await this.config()).tokenValidation?.idToken?.clockTolerance,
|
|
514
|
+
(await this.config()).tokenValidation?.idToken?.validateIssuer ?? true
|
|
515
|
+
);
|
|
516
|
+
}
|
|
517
|
+
getAuthenticatedUserInfo(idToken) {
|
|
518
|
+
const payload = this.cryptoHelper.decodeJwtToken(idToken);
|
|
519
|
+
const username = payload?.["username"] ?? "";
|
|
520
|
+
const givenName = payload?.["given_name"] ?? "";
|
|
521
|
+
const familyName = payload?.["family_name"] ?? "";
|
|
522
|
+
const fullName = givenName && familyName ? `${givenName} ${familyName}` : givenName || familyName || "";
|
|
523
|
+
const displayName = payload.preferred_username ?? fullName;
|
|
524
|
+
return {
|
|
525
|
+
displayName,
|
|
526
|
+
username,
|
|
527
|
+
...extractUserClaimsFromIdToken_default(payload)
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
async replaceCustomGrantTemplateTags(text, userId) {
|
|
531
|
+
const configData = await this.config();
|
|
532
|
+
const sessionData = await this.storageManager.getSessionData(userId);
|
|
533
|
+
const scope = processOpenIDScopes_default(configData.scopes);
|
|
534
|
+
if (typeof text !== "string") {
|
|
535
|
+
return text;
|
|
536
|
+
}
|
|
537
|
+
return text.replace(TokenExchangeConstants_default.Placeholders.ACCESS_TOKEN, sessionData.access_token).replace(
|
|
538
|
+
TokenExchangeConstants_default.Placeholders.USERNAME,
|
|
539
|
+
this.getAuthenticatedUserInfo(sessionData.id_token).username
|
|
540
|
+
).replace(TokenExchangeConstants_default.Placeholders.SCOPES, scope).replace(TokenExchangeConstants_default.Placeholders.CLIENT_ID, configData.clientId).replace(TokenExchangeConstants_default.Placeholders.CLIENT_SECRET, configData.clientSecret ?? "");
|
|
541
|
+
}
|
|
542
|
+
async clearSession(userId) {
|
|
543
|
+
await this.storageManager.removeTemporaryData(userId);
|
|
544
|
+
await this.storageManager.removeSessionData(userId);
|
|
545
|
+
}
|
|
546
|
+
async handleTokenResponse(response, userId) {
|
|
547
|
+
if (response.status !== 200 || !response.ok) {
|
|
548
|
+
throw new AsgardeoAuthException(
|
|
549
|
+
"JS-AUTH_HELPER-HTR-NE01",
|
|
550
|
+
`Invalid response status received for token request (${response.statusText}).`,
|
|
551
|
+
await response.json()
|
|
552
|
+
);
|
|
553
|
+
}
|
|
554
|
+
const parsedResponse = await response.json();
|
|
555
|
+
parsedResponse.created_at = (/* @__PURE__ */ new Date()).getTime();
|
|
556
|
+
const shouldValidateIdToken = (await this.config()).tokenValidation?.idToken?.validate;
|
|
557
|
+
if (shouldValidateIdToken) {
|
|
558
|
+
return this.validateIdToken(parsedResponse.id_token).then(async () => {
|
|
559
|
+
await this.storageManager.setSessionData(parsedResponse, userId);
|
|
560
|
+
const tokenResponse2 = {
|
|
561
|
+
accessToken: parsedResponse.access_token,
|
|
562
|
+
createdAt: parsedResponse.created_at,
|
|
563
|
+
expiresIn: parsedResponse.expires_in,
|
|
564
|
+
idToken: parsedResponse.id_token,
|
|
565
|
+
refreshToken: parsedResponse.refresh_token,
|
|
566
|
+
scope: parsedResponse.scope,
|
|
567
|
+
tokenType: parsedResponse.token_type
|
|
568
|
+
};
|
|
569
|
+
return Promise.resolve(tokenResponse2);
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
const tokenResponse = {
|
|
573
|
+
accessToken: parsedResponse.access_token,
|
|
574
|
+
createdAt: parsedResponse.created_at,
|
|
575
|
+
expiresIn: parsedResponse.expires_in,
|
|
576
|
+
idToken: parsedResponse.id_token,
|
|
577
|
+
refreshToken: parsedResponse.refresh_token,
|
|
578
|
+
scope: parsedResponse.scope,
|
|
579
|
+
tokenType: parsedResponse.token_type
|
|
580
|
+
};
|
|
581
|
+
await this.storageManager.setSessionData(parsedResponse, userId);
|
|
582
|
+
return Promise.resolve(tokenResponse);
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
|
|
586
|
+
// src/constants/PKCEConstants.ts
|
|
587
|
+
var PKCEConstants = {
|
|
588
|
+
DEFAULT_CODE_CHALLENGE_METHOD: "S256",
|
|
589
|
+
/**
|
|
590
|
+
* Storage-related constants for managing PKCE state
|
|
591
|
+
*/
|
|
592
|
+
Storage: {
|
|
593
|
+
/**
|
|
594
|
+
* Collection of storage keys used in PKCE implementation
|
|
595
|
+
*/
|
|
596
|
+
StorageKeys: {
|
|
597
|
+
/**
|
|
598
|
+
* Key used to store the PKCE code verifier in temporary storage.
|
|
599
|
+
* The code verifier is a cryptographically random string that is
|
|
600
|
+
* used to generate the code challenge.
|
|
601
|
+
*/
|
|
602
|
+
CODE_VERIFIER: "pkce_code_verifier",
|
|
603
|
+
/**
|
|
604
|
+
* Separator used in storage keys to create unique identifiers
|
|
605
|
+
* by combining different parts of the key.
|
|
606
|
+
*/
|
|
607
|
+
SEPARATOR: "#"
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
var PKCEConstants_default = PKCEConstants;
|
|
612
|
+
|
|
613
|
+
// src/constants/TokenConstants.ts
|
|
614
|
+
var TokenConstants = {
|
|
615
|
+
/**
|
|
362
616
|
* Token signature validation constants.
|
|
363
617
|
* Contains configurations related to token signature verification.
|
|
364
618
|
*/
|
|
@@ -401,8 +655,8 @@ var TokenConstants_default = TokenConstants;
|
|
|
401
655
|
// src/IsomorphicCrypto.ts
|
|
402
656
|
var IsomorphicCrypto = class {
|
|
403
657
|
constructor(cryptoUtils) {
|
|
404
|
-
__publicField(this, "
|
|
405
|
-
this.
|
|
658
|
+
__publicField(this, "cryptoUtils");
|
|
659
|
+
this.cryptoUtils = cryptoUtils;
|
|
406
660
|
}
|
|
407
661
|
/**
|
|
408
662
|
* Generate code verifier.
|
|
@@ -410,7 +664,7 @@ var IsomorphicCrypto = class {
|
|
|
410
664
|
* @returns code verifier.
|
|
411
665
|
*/
|
|
412
666
|
getCodeVerifier() {
|
|
413
|
-
return this.
|
|
667
|
+
return this.cryptoUtils.base64URLEncode(this.cryptoUtils.generateRandomBytes(32));
|
|
414
668
|
}
|
|
415
669
|
/**
|
|
416
670
|
* Derive code challenge from the code verifier.
|
|
@@ -420,7 +674,7 @@ var IsomorphicCrypto = class {
|
|
|
420
674
|
* @returns - code challenge.
|
|
421
675
|
*/
|
|
422
676
|
getCodeChallenge(verifier) {
|
|
423
|
-
return this.
|
|
677
|
+
return this.cryptoUtils.base64URLEncode(this.cryptoUtils.hashSha256(verifier));
|
|
424
678
|
}
|
|
425
679
|
/**
|
|
426
680
|
* Get JWK used for the id_token
|
|
@@ -434,16 +688,17 @@ var IsomorphicCrypto = class {
|
|
|
434
688
|
*/
|
|
435
689
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
436
690
|
getJWKForTheIdToken(jwtHeader, keys) {
|
|
437
|
-
const headerJSON = JSON.parse(this.
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
691
|
+
const headerJSON = JSON.parse(this.cryptoUtils.base64URLDecode(jwtHeader));
|
|
692
|
+
const matchingKey = keys.find(
|
|
693
|
+
(key) => headerJSON["kid"] === key.kid
|
|
694
|
+
);
|
|
695
|
+
if (matchingKey) {
|
|
696
|
+
return matchingKey;
|
|
442
697
|
}
|
|
443
698
|
throw new AsgardeoAuthException(
|
|
444
699
|
"JS-CRYPTO_UTIL-GJFTIT-IV01",
|
|
445
700
|
"kid not found.",
|
|
446
|
-
|
|
701
|
+
`Failed to find the 'kid' specified in the id_token. 'kid' found in the header : ${headerJSON["kid"]}, Expected values: ${keys.map((key) => key.kid).join(", ")}`
|
|
447
702
|
);
|
|
448
703
|
}
|
|
449
704
|
/**
|
|
@@ -461,7 +716,7 @@ var IsomorphicCrypto = class {
|
|
|
461
716
|
* @throws
|
|
462
717
|
*/
|
|
463
718
|
isValidIdToken(idToken, jwk, clientId, issuer, username, clockTolerance, validateJwtIssuer) {
|
|
464
|
-
return this.
|
|
719
|
+
return this.cryptoUtils.verifyJwt(
|
|
465
720
|
idToken,
|
|
466
721
|
jwk,
|
|
467
722
|
TokenConstants_default.SignatureValidation.SUPPORTED_ALGORITHMS,
|
|
@@ -475,417 +730,176 @@ var IsomorphicCrypto = class {
|
|
|
475
730
|
return Promise.resolve(true);
|
|
476
731
|
}
|
|
477
732
|
return Promise.reject(
|
|
478
|
-
new AsgardeoAuthException(
|
|
479
|
-
"JS-CRYPTO_HELPER-IVIT-IV01",
|
|
480
|
-
"Invalid ID token.",
|
|
481
|
-
"ID token validation returned false"
|
|
482
|
-
)
|
|
483
|
-
);
|
|
484
|
-
}).catch((error2) => {
|
|
485
|
-
return Promise.reject(error2);
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
decodeJwtToken(token) {
|
|
489
|
-
try {
|
|
490
|
-
const utf8String = this._cryptoUtils.base64URLDecode(token?.split(".")[1]);
|
|
491
|
-
const payload = JSON.parse(utf8String);
|
|
492
|
-
return payload;
|
|
493
|
-
} catch (error2) {
|
|
494
|
-
throw new AsgardeoAuthException("JS-CRYPTO_UTIL-DIT-IV02", "Decoding token failed.", error2);
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
};
|
|
498
|
-
|
|
499
|
-
// src/constants/PKCEConstants.ts
|
|
500
|
-
var PKCEConstants = {
|
|
501
|
-
DEFAULT_CODE_CHALLENGE_METHOD: "S256",
|
|
502
|
-
/**
|
|
503
|
-
* Storage-related constants for managing PKCE state
|
|
504
|
-
*/
|
|
505
|
-
Storage: {
|
|
506
|
-
/**
|
|
507
|
-
* Collection of storage keys used in PKCE implementation
|
|
508
|
-
*/
|
|
509
|
-
StorageKeys: {
|
|
510
|
-
/**
|
|
511
|
-
* Key used to store the PKCE code verifier in temporary storage.
|
|
512
|
-
* The code verifier is a cryptographically random string that is
|
|
513
|
-
* used to generate the code challenge.
|
|
514
|
-
*/
|
|
515
|
-
CODE_VERIFIER: "pkce_code_verifier",
|
|
516
|
-
/**
|
|
517
|
-
* Separator used in storage keys to create unique identifiers
|
|
518
|
-
* by combining different parts of the key.
|
|
519
|
-
*/
|
|
520
|
-
SEPARATOR: "#"
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
};
|
|
524
|
-
var PKCEConstants_default = PKCEConstants;
|
|
525
|
-
|
|
526
|
-
// src/utils/extractPkceStorageKeyFromState.ts
|
|
527
|
-
var extractPkceStorageKeyFromState = (state) => {
|
|
528
|
-
const index = parseInt(state.split("request_")[1]);
|
|
529
|
-
return `${PKCEConstants_default.Storage.StorageKeys.CODE_VERIFIER}${PKCEConstants_default.Storage.StorageKeys.SEPARATOR}${index}`;
|
|
530
|
-
};
|
|
531
|
-
var extractPkceStorageKeyFromState_default = extractPkceStorageKeyFromState;
|
|
532
|
-
|
|
533
|
-
// src/constants/TokenExchangeConstants.ts
|
|
534
|
-
var TokenExchangeConstants = {
|
|
535
|
-
/**
|
|
536
|
-
* Collection of placeholder strings used in token exchange operations.
|
|
537
|
-
* These placeholders are replaced with actual values when processing
|
|
538
|
-
* token exchange requests.
|
|
539
|
-
*/
|
|
540
|
-
Placeholders: {
|
|
541
|
-
/**
|
|
542
|
-
* Placeholder for the token value in exchange requests.
|
|
543
|
-
* Usually replaced with an access token or refresh token.
|
|
544
|
-
*/
|
|
545
|
-
ACCESS_TOKEN: "{{accessToken}}",
|
|
546
|
-
/**
|
|
547
|
-
* Placeholder for the username in token exchange operations.
|
|
548
|
-
* Used when user identity needs to be included in the exchange.
|
|
549
|
-
*/
|
|
550
|
-
USERNAME: "{{username}}",
|
|
551
|
-
/**
|
|
552
|
-
* Placeholder for OAuth scopes in token exchange requests.
|
|
553
|
-
* Replaced with space-separated scope strings.
|
|
554
|
-
*/
|
|
555
|
-
SCOPES: "{{scopes}}",
|
|
556
|
-
/**
|
|
557
|
-
* Placeholder for client ID in token exchange operations.
|
|
558
|
-
* Required for client authentication.
|
|
559
|
-
*/
|
|
560
|
-
CLIENT_ID: "{{clientId}}",
|
|
561
|
-
/**
|
|
562
|
-
* Placeholder for client secret in token exchange operations.
|
|
563
|
-
* Used for client authentication in confidential client flows.
|
|
564
|
-
*/
|
|
565
|
-
CLIENT_SECRET: "{{clientSecret}}"
|
|
566
|
-
}
|
|
567
|
-
};
|
|
568
|
-
var TokenExchangeConstants_default = TokenExchangeConstants;
|
|
569
|
-
|
|
570
|
-
// src/models/platforms.ts
|
|
571
|
-
var Platform = /* @__PURE__ */ ((Platform2) => {
|
|
572
|
-
Platform2["Asgardeo"] = "ASGARDEO";
|
|
573
|
-
Platform2["IdentityServer"] = "IDENTITY_SERVER";
|
|
574
|
-
Platform2["AsgardeoV2"] = "AsgardeoV2";
|
|
575
|
-
Platform2["Unknown"] = "UNKNOWN";
|
|
576
|
-
return Platform2;
|
|
577
|
-
})(Platform || {});
|
|
578
|
-
|
|
579
|
-
// src/utils/extractUserClaimsFromIdToken.ts
|
|
580
|
-
var extractUserClaimsFromIdToken = (payload) => {
|
|
581
|
-
const filteredPayload = { ...payload };
|
|
582
|
-
const protocolClaims = [
|
|
583
|
-
"iss",
|
|
584
|
-
"aud",
|
|
585
|
-
"exp",
|
|
586
|
-
"iat",
|
|
587
|
-
"acr",
|
|
588
|
-
"amr",
|
|
589
|
-
"azp",
|
|
590
|
-
"auth_time",
|
|
591
|
-
"nonce",
|
|
592
|
-
"c_hash",
|
|
593
|
-
"at_hash",
|
|
594
|
-
"nbf",
|
|
595
|
-
"isk",
|
|
596
|
-
"sid",
|
|
597
|
-
"jti",
|
|
598
|
-
"sub"
|
|
599
|
-
];
|
|
600
|
-
protocolClaims.forEach((claim) => {
|
|
601
|
-
delete filteredPayload[claim];
|
|
602
|
-
});
|
|
603
|
-
return filteredPayload;
|
|
604
|
-
};
|
|
605
|
-
var extractUserClaimsFromIdToken_default = extractUserClaimsFromIdToken;
|
|
606
|
-
|
|
607
|
-
// src/errors/AsgardeoError.ts
|
|
608
|
-
var AsgardeoError = class _AsgardeoError extends Error {
|
|
609
|
-
constructor(message, code, origin) {
|
|
610
|
-
const _origin = _AsgardeoError.resolveOrigin(origin);
|
|
611
|
-
super(message);
|
|
612
|
-
__publicField(this, "code");
|
|
613
|
-
__publicField(this, "origin");
|
|
614
|
-
this.name = new.target.name;
|
|
615
|
-
this.code = code;
|
|
616
|
-
this.origin = _origin;
|
|
617
|
-
if (Error.captureStackTrace) {
|
|
618
|
-
Error.captureStackTrace(this, new.target);
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
static resolveOrigin(origin) {
|
|
622
|
-
if (!origin) {
|
|
623
|
-
return "@asgardeo/javascript";
|
|
624
|
-
}
|
|
625
|
-
return `@asgardeo/${origin}`;
|
|
626
|
-
}
|
|
627
|
-
toString() {
|
|
628
|
-
const prefix = `\u{1F6E1}\uFE0F Asgardeo - ${this.origin}:`;
|
|
629
|
-
return `[${this.name}]
|
|
630
|
-
${prefix} ${this.message}
|
|
631
|
-
(code="${this.code}")`;
|
|
632
|
-
}
|
|
633
|
-
};
|
|
634
|
-
|
|
635
|
-
// src/errors/AsgardeoRuntimeError.ts
|
|
636
|
-
var AsgardeoRuntimeError = class extends AsgardeoError {
|
|
637
|
-
/**
|
|
638
|
-
* Creates an instance of AsgardeoRuntimeError.
|
|
639
|
-
*
|
|
640
|
-
* @param message - Human-readable description of the error
|
|
641
|
-
* @param code - A unique error code that identifies the error type
|
|
642
|
-
* @param details - Additional details about the error that might be helpful for debugging
|
|
643
|
-
* @param origin - Optional. The SDK origin (e.g. 'react', 'vue'). Defaults to generic 'Asgardeo'
|
|
644
|
-
* @constructor
|
|
645
|
-
*/
|
|
646
|
-
constructor(message, code, origin, details) {
|
|
647
|
-
super(message, code, origin);
|
|
648
|
-
this.details = details;
|
|
649
|
-
Object.defineProperty(this, "name", {
|
|
650
|
-
value: "AsgardeoRuntimeError",
|
|
651
|
-
configurable: true,
|
|
652
|
-
writable: true
|
|
653
|
-
});
|
|
654
|
-
}
|
|
655
|
-
/**
|
|
656
|
-
* Returns a string representation of the runtime error
|
|
657
|
-
* @returns Formatted error string with name, code, details, and message
|
|
658
|
-
*/
|
|
659
|
-
toString() {
|
|
660
|
-
const details = this.details ? `
|
|
661
|
-
Details: ${JSON.stringify(this.details, null, 2)}` : "";
|
|
662
|
-
return `[${this.name}] (code="${this.code}")${details}
|
|
663
|
-
Message: ${this.message}`;
|
|
664
|
-
}
|
|
665
|
-
};
|
|
666
|
-
|
|
667
|
-
// src/utils/processOpenIDScopes.ts
|
|
668
|
-
var processOpenIDScopes = (scopes) => {
|
|
669
|
-
let processedScopes = [];
|
|
670
|
-
if (scopes) {
|
|
671
|
-
if (Array.isArray(scopes)) {
|
|
672
|
-
processedScopes = scopes;
|
|
673
|
-
} else if (typeof scopes === "string") {
|
|
674
|
-
processedScopes = scopes.split(" ");
|
|
675
|
-
} else {
|
|
676
|
-
throw new AsgardeoRuntimeError(
|
|
677
|
-
"Scopes must be a string or an array of strings.",
|
|
678
|
-
"processOpenIDScopes-Invalid-001",
|
|
679
|
-
"javascript",
|
|
680
|
-
"The provided scopes are not in the expected format. Please provide a string or an array of strings."
|
|
681
|
-
);
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
OIDCRequestConstants_default.SignIn.Payload.DEFAULT_SCOPES.forEach((defaultScope) => {
|
|
685
|
-
if (!processedScopes.includes(defaultScope)) {
|
|
686
|
-
processedScopes.push(defaultScope);
|
|
687
|
-
}
|
|
688
|
-
});
|
|
689
|
-
return processedScopes.join(" ");
|
|
690
|
-
};
|
|
691
|
-
var processOpenIDScopes_default = processOpenIDScopes;
|
|
692
|
-
|
|
693
|
-
// src/__legacy__/helpers/authentication-helper.ts
|
|
694
|
-
var AuthenticationHelper = class {
|
|
695
|
-
constructor(storageManager, cryptoHelper) {
|
|
696
|
-
__publicField(this, "_storageManager");
|
|
697
|
-
__publicField(this, "_config");
|
|
698
|
-
__publicField(this, "_oidcProviderMetaData");
|
|
699
|
-
__publicField(this, "_cryptoHelper");
|
|
700
|
-
this._storageManager = storageManager;
|
|
701
|
-
this._config = async () => this._storageManager.getConfigData();
|
|
702
|
-
this._oidcProviderMetaData = async () => this._storageManager.loadOpenIDProviderConfiguration();
|
|
703
|
-
this._cryptoHelper = cryptoHelper;
|
|
704
|
-
}
|
|
705
|
-
async resolveEndpoints(response) {
|
|
706
|
-
const oidcProviderMetaData = {};
|
|
707
|
-
const configData = await this._config();
|
|
708
|
-
configData.endpoints && Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
709
|
-
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
710
|
-
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
711
|
-
});
|
|
712
|
-
return { ...response, ...oidcProviderMetaData };
|
|
713
|
-
}
|
|
714
|
-
async resolveEndpointsExplicitly() {
|
|
715
|
-
const oidcProviderMetaData = {};
|
|
716
|
-
const configData = await this._config();
|
|
717
|
-
const requiredEndpoints = [
|
|
718
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.AUTHORIZATION,
|
|
719
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.END_SESSION,
|
|
720
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.JWKS,
|
|
721
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.SESSION_IFRAME,
|
|
722
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.REVOCATION,
|
|
723
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.TOKEN,
|
|
724
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.ISSUER,
|
|
725
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.USERINFO
|
|
726
|
-
];
|
|
727
|
-
const isRequiredEndpointsContains = configData.endpoints ? requiredEndpoints.every(
|
|
728
|
-
(reqEndpointName) => configData.endpoints ? Object.keys(configData.endpoints).some((endpointName) => {
|
|
729
|
-
const snakeCasedName = endpointName.replace(
|
|
730
|
-
/[A-Z]/g,
|
|
731
|
-
(letter) => `_${letter.toLowerCase()}`
|
|
732
|
-
);
|
|
733
|
-
return snakeCasedName === reqEndpointName;
|
|
734
|
-
}) : false
|
|
735
|
-
) : false;
|
|
736
|
-
if (!isRequiredEndpointsContains) {
|
|
737
|
-
throw new AsgardeoAuthException(
|
|
738
|
-
"JS-AUTH_HELPER-REE-NF01",
|
|
739
|
-
"Required endpoints missing",
|
|
740
|
-
"Some or all of the required endpoints are missing in the object passed to the `endpoints` attribute of the`AuthConfig` object."
|
|
733
|
+
new AsgardeoAuthException(
|
|
734
|
+
"JS-CRYPTO_HELPER-IVIT-IV01",
|
|
735
|
+
"Invalid ID token.",
|
|
736
|
+
"ID token validation returned false"
|
|
737
|
+
)
|
|
741
738
|
);
|
|
742
|
-
}
|
|
743
|
-
configData.endpoints && Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
744
|
-
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
745
|
-
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
746
|
-
});
|
|
747
|
-
return { ...oidcProviderMetaData };
|
|
739
|
+
}).catch((error2) => Promise.reject(error2));
|
|
748
740
|
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
"Base URL not defined.",
|
|
757
|
-
"Base URL is not defined in AuthClient config."
|
|
758
|
-
);
|
|
759
|
-
}
|
|
760
|
-
configData.endpoints && Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
761
|
-
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
762
|
-
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
763
|
-
});
|
|
764
|
-
const defaultEndpoints = {
|
|
765
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.AUTHORIZATION]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.AUTHORIZATION}`,
|
|
766
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.END_SESSION]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.END_SESSION}`,
|
|
767
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.ISSUER]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.ISSUER}`,
|
|
768
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.JWKS]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.JWKS}`,
|
|
769
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.SESSION_IFRAME]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.SESSION_IFRAME}`,
|
|
770
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.REVOCATION]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.REVOCATION}`,
|
|
771
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.TOKEN]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.TOKEN}`,
|
|
772
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.USERINFO]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.USERINFO}`
|
|
773
|
-
};
|
|
774
|
-
if (configData.platform === "AsgardeoV2" /* AsgardeoV2 */) {
|
|
775
|
-
defaultEndpoints[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.ISSUER] = `${baseUrl}`;
|
|
741
|
+
decodeJwtToken(token) {
|
|
742
|
+
try {
|
|
743
|
+
const utf8String = this.cryptoUtils.base64URLDecode(token?.split(".")[1]);
|
|
744
|
+
const payload = JSON.parse(utf8String);
|
|
745
|
+
return payload;
|
|
746
|
+
} catch (error2) {
|
|
747
|
+
throw new AsgardeoAuthException("JS-CRYPTO_UTIL-DIT-IV02", "Decoding token failed.", error2);
|
|
776
748
|
}
|
|
777
|
-
return { ...defaultEndpoints, ...oidcProviderMetaData };
|
|
778
749
|
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
750
|
+
};
|
|
751
|
+
|
|
752
|
+
// src/StorageManager.ts
|
|
753
|
+
var ASGARDEO_SESSION_ACTIVE = "asgardeo-session-active";
|
|
754
|
+
var StorageManager = class _StorageManager {
|
|
755
|
+
constructor(instanceID, store) {
|
|
756
|
+
__publicField(this, "id");
|
|
757
|
+
__publicField(this, "store");
|
|
758
|
+
this.id = instanceID;
|
|
759
|
+
this.store = store;
|
|
760
|
+
}
|
|
761
|
+
async setDataInBulk(key, data) {
|
|
762
|
+
const existingDataJSON = await this.store.getData(key) ?? null;
|
|
763
|
+
const existingData = existingDataJSON && JSON.parse(existingDataJSON);
|
|
764
|
+
const dataToBeSaved = { ...existingData, ...data };
|
|
765
|
+
const dataToBeSavedJSON = JSON.stringify(dataToBeSaved);
|
|
766
|
+
await this.store.setData(key, dataToBeSavedJSON);
|
|
767
|
+
}
|
|
768
|
+
async setValue(key, attribute, value) {
|
|
769
|
+
const existingDataJSON = await this.store.getData(key) ?? null;
|
|
770
|
+
const existingData = existingDataJSON && JSON.parse(existingDataJSON);
|
|
771
|
+
const dataToBeSaved = { ...existingData, [attribute]: value };
|
|
772
|
+
const dataToBeSavedJSON = JSON.stringify(dataToBeSaved);
|
|
773
|
+
await this.store.setData(key, dataToBeSavedJSON);
|
|
774
|
+
}
|
|
775
|
+
async removeValue(key, attribute) {
|
|
776
|
+
const existingDataJSON = await this.store.getData(key) ?? null;
|
|
777
|
+
const existingData = existingDataJSON && JSON.parse(existingDataJSON);
|
|
778
|
+
const dataToBeSaved = { ...existingData };
|
|
779
|
+
delete dataToBeSaved[attribute];
|
|
780
|
+
const dataToBeSavedJSON = JSON.stringify(dataToBeSaved);
|
|
781
|
+
await this.store.setData(key, dataToBeSavedJSON);
|
|
782
|
+
}
|
|
783
|
+
resolveKey(store, userId) {
|
|
784
|
+
return userId ? `${store}-${this.id}-${userId}` : `${store}-${this.id}`;
|
|
785
|
+
}
|
|
786
|
+
static isLocalStorageAvailable() {
|
|
790
787
|
try {
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
788
|
+
const testValue = "__ASGARDEO_AUTH_CORE_LOCAL_STORAGE_TEST__";
|
|
789
|
+
localStorage.setItem(testValue, testValue);
|
|
790
|
+
localStorage.removeItem(testValue);
|
|
791
|
+
return true;
|
|
794
792
|
} catch (error2) {
|
|
795
|
-
|
|
796
|
-
"JS-AUTH_HELPER-VIT-NE02",
|
|
797
|
-
"Request to jwks endpoint failed.",
|
|
798
|
-
error2 ?? "The request sent to get the jwks from the server failed."
|
|
799
|
-
);
|
|
800
|
-
}
|
|
801
|
-
if (response.status !== 200 || !response.ok) {
|
|
802
|
-
throw new AsgardeoAuthException(
|
|
803
|
-
"JS-AUTH_HELPER-VIT-HE03",
|
|
804
|
-
`Invalid response status received for jwks request (${response.statusText}).`,
|
|
805
|
-
await response.json()
|
|
806
|
-
);
|
|
793
|
+
return false;
|
|
807
794
|
}
|
|
808
|
-
const { issuer } = await this._oidcProviderMetaData();
|
|
809
|
-
const { keys } = await response.json();
|
|
810
|
-
const jwk = await this._cryptoHelper.getJWKForTheIdToken(idToken.split(".")[0], keys);
|
|
811
|
-
return this._cryptoHelper.isValidIdToken(
|
|
812
|
-
idToken,
|
|
813
|
-
jwk,
|
|
814
|
-
(await this._config()).clientId,
|
|
815
|
-
issuer ?? "",
|
|
816
|
-
this._cryptoHelper.decodeJwtToken(idToken).sub,
|
|
817
|
-
(await this._config()).tokenValidation?.idToken?.clockTolerance,
|
|
818
|
-
(await this._config()).tokenValidation?.idToken?.validateIssuer ?? true
|
|
819
|
-
);
|
|
820
795
|
}
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
const username = payload?.["username"] ?? "";
|
|
824
|
-
const givenName = payload?.["given_name"] ?? "";
|
|
825
|
-
const familyName = payload?.["family_name"] ?? "";
|
|
826
|
-
const fullName = givenName && familyName ? `${givenName} ${familyName}` : givenName || familyName || "";
|
|
827
|
-
const displayName = payload.preferred_username ?? fullName;
|
|
828
|
-
return {
|
|
829
|
-
displayName,
|
|
830
|
-
username,
|
|
831
|
-
...extractUserClaimsFromIdToken_default(payload)
|
|
832
|
-
};
|
|
796
|
+
async setConfigData(config) {
|
|
797
|
+
await this.setDataInBulk(this.resolveKey("config_data" /* ConfigData */), config);
|
|
833
798
|
}
|
|
834
|
-
async
|
|
835
|
-
|
|
836
|
-
const sessionData = await this._storageManager.getSessionData(userId);
|
|
837
|
-
const scope = processOpenIDScopes_default(configData.scopes);
|
|
838
|
-
if (typeof text !== "string") {
|
|
839
|
-
return text;
|
|
840
|
-
}
|
|
841
|
-
return text.replace(TokenExchangeConstants_default.Placeholders.ACCESS_TOKEN, sessionData.access_token).replace(
|
|
842
|
-
TokenExchangeConstants_default.Placeholders.USERNAME,
|
|
843
|
-
this.getAuthenticatedUserInfo(sessionData.id_token).username
|
|
844
|
-
).replace(TokenExchangeConstants_default.Placeholders.SCOPES, scope).replace(TokenExchangeConstants_default.Placeholders.CLIENT_ID, configData.clientId).replace(TokenExchangeConstants_default.Placeholders.CLIENT_SECRET, configData.clientSecret ?? "");
|
|
799
|
+
async setOIDCProviderMetaData(oidcProviderMetaData) {
|
|
800
|
+
this.setDataInBulk(this.resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), oidcProviderMetaData);
|
|
845
801
|
}
|
|
846
|
-
async
|
|
847
|
-
|
|
848
|
-
await this._storageManager.removeSessionData(userId);
|
|
802
|
+
async setTemporaryData(temporaryData, userId) {
|
|
803
|
+
this.setDataInBulk(this.resolveKey("temporary_data" /* TemporaryData */, userId), temporaryData);
|
|
849
804
|
}
|
|
850
|
-
async
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
805
|
+
async setSessionData(sessionData, userId) {
|
|
806
|
+
this.setDataInBulk(this.resolveKey("session_data" /* SessionData */, userId), sessionData);
|
|
807
|
+
}
|
|
808
|
+
async setCustomData(key, customData, userId) {
|
|
809
|
+
this.setDataInBulk(this.resolveKey(key, userId), customData);
|
|
810
|
+
}
|
|
811
|
+
async getConfigData(userId) {
|
|
812
|
+
return JSON.parse(await this.store.getData(this.resolveKey("config_data" /* ConfigData */, userId)) ?? null);
|
|
813
|
+
}
|
|
814
|
+
async loadOpenIDProviderConfiguration() {
|
|
815
|
+
return JSON.parse(await this.store.getData(this.resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */)) ?? null);
|
|
816
|
+
}
|
|
817
|
+
async getTemporaryData(userId) {
|
|
818
|
+
return JSON.parse(await this.store.getData(this.resolveKey("temporary_data" /* TemporaryData */, userId)) ?? null);
|
|
819
|
+
}
|
|
820
|
+
async getSessionData(userId) {
|
|
821
|
+
return JSON.parse(await this.store.getData(this.resolveKey("session_data" /* SessionData */, userId)) ?? null);
|
|
822
|
+
}
|
|
823
|
+
async getCustomData(key, userId) {
|
|
824
|
+
return JSON.parse(await this.store.getData(this.resolveKey(key, userId)) ?? null);
|
|
825
|
+
}
|
|
826
|
+
// eslint-disable-next-line class-methods-use-this
|
|
827
|
+
setSessionStatus(status) {
|
|
828
|
+
if (_StorageManager.isLocalStorageAvailable()) {
|
|
829
|
+
localStorage.setItem(`${ASGARDEO_SESSION_ACTIVE}`, status);
|
|
857
830
|
}
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
expiresIn: parsedResponse.expires_in,
|
|
868
|
-
idToken: parsedResponse.id_token,
|
|
869
|
-
refreshToken: parsedResponse.refresh_token,
|
|
870
|
-
scope: parsedResponse.scope,
|
|
871
|
-
tokenType: parsedResponse.token_type
|
|
872
|
-
};
|
|
873
|
-
return Promise.resolve(tokenResponse2);
|
|
874
|
-
});
|
|
831
|
+
}
|
|
832
|
+
// eslint-disable-next-line class-methods-use-this
|
|
833
|
+
getSessionStatus() {
|
|
834
|
+
return _StorageManager.isLocalStorageAvailable() ? localStorage.getItem(`${ASGARDEO_SESSION_ACTIVE}`) ?? "" : "";
|
|
835
|
+
}
|
|
836
|
+
// eslint-disable-next-line class-methods-use-this
|
|
837
|
+
removeSessionStatus() {
|
|
838
|
+
if (_StorageManager.isLocalStorageAvailable()) {
|
|
839
|
+
localStorage.removeItem(`${ASGARDEO_SESSION_ACTIVE}`);
|
|
875
840
|
}
|
|
876
|
-
const tokenResponse = {
|
|
877
|
-
accessToken: parsedResponse.access_token,
|
|
878
|
-
createdAt: parsedResponse.created_at,
|
|
879
|
-
expiresIn: parsedResponse.expires_in,
|
|
880
|
-
idToken: parsedResponse.id_token,
|
|
881
|
-
refreshToken: parsedResponse.refresh_token,
|
|
882
|
-
scope: parsedResponse.scope,
|
|
883
|
-
tokenType: parsedResponse.token_type
|
|
884
|
-
};
|
|
885
|
-
await this._storageManager.setSessionData(parsedResponse, userId);
|
|
886
|
-
return Promise.resolve(tokenResponse);
|
|
887
841
|
}
|
|
842
|
+
async removeConfigData() {
|
|
843
|
+
await this.store.removeData(this.resolveKey("config_data" /* ConfigData */));
|
|
844
|
+
}
|
|
845
|
+
async removeOIDCProviderMetaData() {
|
|
846
|
+
await this.store.removeData(this.resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */));
|
|
847
|
+
}
|
|
848
|
+
async removeTemporaryData(userId) {
|
|
849
|
+
await this.store.removeData(this.resolveKey("temporary_data" /* TemporaryData */, userId));
|
|
850
|
+
}
|
|
851
|
+
async removeSessionData(userId) {
|
|
852
|
+
await this.store.removeData(this.resolveKey("session_data" /* SessionData */, userId));
|
|
853
|
+
}
|
|
854
|
+
async getConfigDataParameter(key) {
|
|
855
|
+
const data = await this.store.getData(this.resolveKey("config_data" /* ConfigData */));
|
|
856
|
+
return data && JSON.parse(data)[key];
|
|
857
|
+
}
|
|
858
|
+
async getOIDCProviderMetaDataParameter(key) {
|
|
859
|
+
const data = await this.store.getData(this.resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */));
|
|
860
|
+
return data && JSON.parse(data)[key];
|
|
861
|
+
}
|
|
862
|
+
async getTemporaryDataParameter(key, userId) {
|
|
863
|
+
const data = await this.store.getData(this.resolveKey("temporary_data" /* TemporaryData */, userId));
|
|
864
|
+
return data && JSON.parse(data)[key];
|
|
865
|
+
}
|
|
866
|
+
async getSessionDataParameter(key, userId) {
|
|
867
|
+
const data = await this.store.getData(this.resolveKey("session_data" /* SessionData */, userId));
|
|
868
|
+
return data && JSON.parse(data)[key];
|
|
869
|
+
}
|
|
870
|
+
async setConfigDataParameter(key, value) {
|
|
871
|
+
await this.setValue(this.resolveKey("config_data" /* ConfigData */), key, value);
|
|
872
|
+
}
|
|
873
|
+
async setOIDCProviderMetaDataParameter(key, value) {
|
|
874
|
+
await this.setValue(this.resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), key, value);
|
|
875
|
+
}
|
|
876
|
+
async setTemporaryDataParameter(key, value, userId) {
|
|
877
|
+
await this.setValue(this.resolveKey("temporary_data" /* TemporaryData */, userId), key, value);
|
|
878
|
+
}
|
|
879
|
+
async setSessionDataParameter(key, value, userId) {
|
|
880
|
+
await this.setValue(this.resolveKey("session_data" /* SessionData */, userId), key, value);
|
|
881
|
+
}
|
|
882
|
+
async removeConfigDataParameter(key) {
|
|
883
|
+
await this.removeValue(this.resolveKey("config_data" /* ConfigData */), key);
|
|
884
|
+
}
|
|
885
|
+
async removeOIDCProviderMetaDataParameter(key) {
|
|
886
|
+
await this.removeValue(this.resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), key);
|
|
887
|
+
}
|
|
888
|
+
async removeTemporaryDataParameter(key, userId) {
|
|
889
|
+
await this.removeValue(this.resolveKey("temporary_data" /* TemporaryData */, userId), key);
|
|
890
|
+
}
|
|
891
|
+
async removeSessionDataParameter(key, userId) {
|
|
892
|
+
await this.removeValue(this.resolveKey("session_data" /* SessionData */, userId), key);
|
|
893
|
+
}
|
|
894
|
+
};
|
|
895
|
+
var StorageManager_default = StorageManager;
|
|
896
|
+
|
|
897
|
+
// src/utils/extractPkceStorageKeyFromState.ts
|
|
898
|
+
var extractPkceStorageKeyFromState = (state) => {
|
|
899
|
+
const index = parseInt(state.split("request_")[1], 10);
|
|
900
|
+
return `${PKCEConstants_default.Storage.StorageKeys.CODE_VERIFIER}${PKCEConstants_default.Storage.StorageKeys.SEPARATOR}${index}`;
|
|
888
901
|
};
|
|
902
|
+
var extractPkceStorageKeyFromState_default = extractPkceStorageKeyFromState;
|
|
889
903
|
|
|
890
904
|
// src/utils/generatePkceStorageKey.ts
|
|
891
905
|
var generatePkceStorageKey = (tempStore) => {
|
|
@@ -896,21 +910,21 @@ var generatePkceStorageKey = (tempStore) => {
|
|
|
896
910
|
}
|
|
897
911
|
});
|
|
898
912
|
const lastKey = keys.sort().pop();
|
|
899
|
-
const index = parseInt(lastKey?.split(PKCEConstants_default.Storage.StorageKeys.SEPARATOR)[1] ?? "-1");
|
|
913
|
+
const index = parseInt(lastKey?.split(PKCEConstants_default.Storage.StorageKeys.SEPARATOR)[1] ?? "-1", 10);
|
|
900
914
|
return `${PKCEConstants_default.Storage.StorageKeys.CODE_VERIFIER}${PKCEConstants_default.Storage.StorageKeys.SEPARATOR}${index + 1}`;
|
|
901
915
|
};
|
|
902
916
|
var generatePkceStorageKey_default = generatePkceStorageKey;
|
|
903
917
|
|
|
904
918
|
// src/utils/generateStateParamForRequestCorrelation.ts
|
|
905
919
|
var generateStateParamForRequestCorrelation = (pkceKey, state) => {
|
|
906
|
-
const index = parseInt(pkceKey.split(PKCEConstants_default.Storage.StorageKeys.SEPARATOR)[1]);
|
|
920
|
+
const index = parseInt(pkceKey.split(PKCEConstants_default.Storage.StorageKeys.SEPARATOR)[1], 10);
|
|
907
921
|
return state ? `${state}_request_${index}` : `request_${index}`;
|
|
908
922
|
};
|
|
909
923
|
var generateStateParamForRequestCorrelation_default = generateStateParamForRequestCorrelation;
|
|
910
924
|
|
|
911
925
|
// src/utils/getAuthorizeRequestUrlParams.ts
|
|
912
926
|
var getAuthorizeRequestUrlParams = (options, pkceOptions, customParams) => {
|
|
913
|
-
const { redirectUri, clientId,
|
|
927
|
+
const { redirectUri, clientId, scopes, responseMode, codeChallenge, codeChallengeMethod, prompt } = options;
|
|
914
928
|
const authorizeRequestParams = /* @__PURE__ */ new Map();
|
|
915
929
|
authorizeRequestParams.set("response_type", "code");
|
|
916
930
|
authorizeRequestParams.set("client_id", clientId);
|
|
@@ -937,18 +951,22 @@ var getAuthorizeRequestUrlParams = (options, pkceOptions, customParams) => {
|
|
|
937
951
|
authorizeRequestParams.set("prompt", prompt);
|
|
938
952
|
}
|
|
939
953
|
if (customParams) {
|
|
940
|
-
|
|
954
|
+
Object.entries(customParams).forEach(([key, value]) => {
|
|
941
955
|
if (key !== "" && value !== "" && key !== OIDCRequestConstants_default.Params.STATE) {
|
|
942
956
|
authorizeRequestParams.set(key, value.toString());
|
|
943
957
|
}
|
|
944
|
-
}
|
|
958
|
+
});
|
|
959
|
+
}
|
|
960
|
+
const AUTH_INSTANCE_PREFIX = "instance_";
|
|
961
|
+
let customStateValue = "";
|
|
962
|
+
if (options.instanceId) {
|
|
963
|
+
customStateValue = AUTH_INSTANCE_PREFIX + options.instanceId;
|
|
964
|
+
} else if (customParams) {
|
|
965
|
+
customStateValue = customParams[OIDCRequestConstants_default.Params.STATE]?.toString() ?? "";
|
|
945
966
|
}
|
|
946
967
|
authorizeRequestParams.set(
|
|
947
968
|
OIDCRequestConstants_default.Params.STATE,
|
|
948
|
-
generateStateParamForRequestCorrelation_default(
|
|
949
|
-
pkceKey,
|
|
950
|
-
customParams ? customParams[OIDCRequestConstants_default.Params.STATE]?.toString() : ""
|
|
951
|
-
)
|
|
969
|
+
generateStateParamForRequestCorrelation_default(pkceKey, customStateValue)
|
|
952
970
|
);
|
|
953
971
|
return authorizeRequestParams;
|
|
954
972
|
};
|
|
@@ -956,16 +974,16 @@ var getAuthorizeRequestUrlParams_default = getAuthorizeRequestUrlParams;
|
|
|
956
974
|
|
|
957
975
|
// src/__legacy__/client.ts
|
|
958
976
|
var DefaultConfig = {
|
|
977
|
+
enablePKCE: true,
|
|
978
|
+
responseMode: "query",
|
|
979
|
+
sendCookiesInRequests: true,
|
|
959
980
|
tokenValidation: {
|
|
960
981
|
idToken: {
|
|
982
|
+
clockTolerance: 300,
|
|
961
983
|
validate: true,
|
|
962
|
-
validateIssuer: true
|
|
963
|
-
clockTolerance: 300
|
|
984
|
+
validateIssuer: true
|
|
964
985
|
}
|
|
965
|
-
}
|
|
966
|
-
enablePKCE: true,
|
|
967
|
-
responseMode: "query",
|
|
968
|
-
sendCookiesInRequests: true
|
|
986
|
+
}
|
|
969
987
|
};
|
|
970
988
|
var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
971
989
|
/**
|
|
@@ -984,12 +1002,13 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
984
1002
|
* @preserve
|
|
985
1003
|
*/
|
|
986
1004
|
constructor() {
|
|
987
|
-
__publicField(this, "
|
|
988
|
-
__publicField(this, "
|
|
989
|
-
__publicField(this, "
|
|
990
|
-
__publicField(this, "
|
|
991
|
-
__publicField(this, "
|
|
992
|
-
__publicField(this, "
|
|
1005
|
+
__publicField(this, "storageManager");
|
|
1006
|
+
__publicField(this, "configProvider");
|
|
1007
|
+
__publicField(this, "oidcProviderMetaDataProvider");
|
|
1008
|
+
__publicField(this, "authHelper");
|
|
1009
|
+
__publicField(this, "cryptoUtils");
|
|
1010
|
+
__publicField(this, "cryptoHelper");
|
|
1011
|
+
__publicField(this, "instanceIdValue");
|
|
993
1012
|
}
|
|
994
1013
|
/**
|
|
995
1014
|
*
|
|
@@ -1010,28 +1029,28 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1010
1029
|
*
|
|
1011
1030
|
* @preserve
|
|
1012
1031
|
*/
|
|
1013
|
-
async initialize(config, store,
|
|
1014
|
-
const clientId = config
|
|
1015
|
-
if (!
|
|
1016
|
-
|
|
1032
|
+
async initialize(config, store, inputCryptoUtils, instanceID) {
|
|
1033
|
+
const { clientId } = config;
|
|
1034
|
+
if (!this.instanceIdValue) {
|
|
1035
|
+
this.instanceIdValue = 0;
|
|
1017
1036
|
} else {
|
|
1018
|
-
|
|
1037
|
+
this.instanceIdValue += 1;
|
|
1019
1038
|
}
|
|
1020
1039
|
if (instanceID) {
|
|
1021
|
-
|
|
1040
|
+
this.instanceIdValue = instanceID;
|
|
1022
1041
|
}
|
|
1023
1042
|
if (!clientId) {
|
|
1024
|
-
this.
|
|
1043
|
+
this.storageManager = new StorageManager_default(`instance_${this.instanceIdValue}`, store);
|
|
1025
1044
|
} else {
|
|
1026
|
-
this.
|
|
1045
|
+
this.storageManager = new StorageManager_default(`instance_${this.instanceIdValue}-${clientId}`, store);
|
|
1027
1046
|
}
|
|
1028
|
-
this.
|
|
1029
|
-
this.
|
|
1030
|
-
this.
|
|
1031
|
-
this.
|
|
1032
|
-
this.
|
|
1033
|
-
_AsgardeoAuthClient.
|
|
1034
|
-
await this.
|
|
1047
|
+
this.cryptoUtils = inputCryptoUtils;
|
|
1048
|
+
this.cryptoHelper = new IsomorphicCrypto(inputCryptoUtils);
|
|
1049
|
+
this.authHelper = new AuthenticationHelper(this.storageManager, this.cryptoHelper);
|
|
1050
|
+
this.configProvider = async () => this.storageManager.getConfigData();
|
|
1051
|
+
this.oidcProviderMetaDataProvider = async () => this.storageManager.loadOpenIDProviderConfiguration();
|
|
1052
|
+
_AsgardeoAuthClient.authHelperInstance = this.authHelper;
|
|
1053
|
+
await this.storageManager.setConfigData({
|
|
1035
1054
|
...DefaultConfig,
|
|
1036
1055
|
...config,
|
|
1037
1056
|
scope: processOpenIDScopes_default(config.scopes)
|
|
@@ -1052,7 +1071,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1052
1071
|
* @preserve
|
|
1053
1072
|
*/
|
|
1054
1073
|
getStorageManager() {
|
|
1055
|
-
return this.
|
|
1074
|
+
return this.storageManager;
|
|
1056
1075
|
}
|
|
1057
1076
|
/**
|
|
1058
1077
|
* This method returns the `instanceID` variable of the given instance.
|
|
@@ -1066,8 +1085,9 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1066
1085
|
*
|
|
1067
1086
|
* @preserve
|
|
1068
1087
|
*/
|
|
1088
|
+
// eslint-disable-next-line class-methods-use-this
|
|
1069
1089
|
getInstanceId() {
|
|
1070
|
-
return
|
|
1090
|
+
return this.instanceIdValue;
|
|
1071
1091
|
}
|
|
1072
1092
|
/**
|
|
1073
1093
|
* This is an async method that returns a Promise that resolves with the authorization URL.
|
|
@@ -1095,8 +1115,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1095
1115
|
async getSignInUrl(requestConfig, userId) {
|
|
1096
1116
|
const authRequestConfig = { ...requestConfig };
|
|
1097
1117
|
delete authRequestConfig?.forceInit;
|
|
1098
|
-
const
|
|
1099
|
-
const authorizeEndpoint = await this.
|
|
1118
|
+
const buildSignInUrl = async () => {
|
|
1119
|
+
const authorizeEndpoint = await this.storageManager.getOIDCProviderMetaDataParameter(
|
|
1100
1120
|
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.AUTHORIZATION
|
|
1101
1121
|
);
|
|
1102
1122
|
if (!authorizeEndpoint || authorizeEndpoint.trim().length === 0) {
|
|
@@ -1107,45 +1127,44 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1107
1127
|
);
|
|
1108
1128
|
}
|
|
1109
1129
|
const authorizeRequest = new URL(authorizeEndpoint);
|
|
1110
|
-
const configData = await this.
|
|
1111
|
-
const tempStore = await this.
|
|
1130
|
+
const configData = await this.configProvider();
|
|
1131
|
+
const tempStore = await this.storageManager.getTemporaryData(userId);
|
|
1112
1132
|
const pkceKey = await generatePkceStorageKey_default(tempStore);
|
|
1113
1133
|
let codeVerifier;
|
|
1114
1134
|
let codeChallenge;
|
|
1115
1135
|
if (configData.enablePKCE) {
|
|
1116
|
-
codeVerifier = this.
|
|
1117
|
-
codeChallenge = this.
|
|
1118
|
-
await this.
|
|
1136
|
+
codeVerifier = this.cryptoHelper?.getCodeVerifier();
|
|
1137
|
+
codeChallenge = this.cryptoHelper?.getCodeChallenge(codeVerifier);
|
|
1138
|
+
await this.storageManager.setTemporaryDataParameter(pkceKey, codeVerifier, userId);
|
|
1119
1139
|
}
|
|
1120
1140
|
if (authRequestConfig["client_secret"]) {
|
|
1121
1141
|
authRequestConfig["client_secret"] = configData.clientSecret;
|
|
1122
1142
|
}
|
|
1123
1143
|
const authorizeRequestParams = getAuthorizeRequestUrlParams_default(
|
|
1124
1144
|
{
|
|
1125
|
-
redirectUri: configData.afterSignInUrl,
|
|
1126
1145
|
clientId: configData.clientId,
|
|
1127
|
-
scopes: processOpenIDScopes_default(configData.scopes),
|
|
1128
|
-
responseMode: configData.responseMode,
|
|
1129
|
-
codeChallengeMethod: PKCEConstants_default.DEFAULT_CODE_CHALLENGE_METHOD,
|
|
1130
1146
|
codeChallenge,
|
|
1131
|
-
|
|
1147
|
+
codeChallengeMethod: PKCEConstants_default.DEFAULT_CODE_CHALLENGE_METHOD,
|
|
1148
|
+
instanceId: this.getInstanceId().toString(),
|
|
1149
|
+
prompt: configData.prompt,
|
|
1150
|
+
redirectUri: configData.afterSignInUrl,
|
|
1151
|
+
responseMode: configData.responseMode,
|
|
1152
|
+
scopes: processOpenIDScopes_default(configData.scopes)
|
|
1132
1153
|
},
|
|
1133
1154
|
{ key: pkceKey },
|
|
1134
1155
|
authRequestConfig
|
|
1135
1156
|
);
|
|
1136
|
-
|
|
1137
|
-
authorizeRequest.searchParams.append(
|
|
1138
|
-
}
|
|
1157
|
+
Array.from(authorizeRequestParams.entries()).forEach(([paramKey, paramValue]) => {
|
|
1158
|
+
authorizeRequest.searchParams.append(paramKey, paramValue);
|
|
1159
|
+
});
|
|
1139
1160
|
return authorizeRequest.toString();
|
|
1140
1161
|
};
|
|
1141
|
-
if (await this.
|
|
1162
|
+
if (await this.storageManager.getTemporaryDataParameter(
|
|
1142
1163
|
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED
|
|
1143
1164
|
)) {
|
|
1144
|
-
return
|
|
1165
|
+
return buildSignInUrl();
|
|
1145
1166
|
}
|
|
1146
|
-
return this.loadOpenIDProviderConfiguration(requestConfig?.forceInit).then(() =>
|
|
1147
|
-
return __TODO__();
|
|
1148
|
-
});
|
|
1167
|
+
return this.loadOpenIDProviderConfiguration(requestConfig?.forceInit).then(() => buildSignInUrl());
|
|
1149
1168
|
}
|
|
1150
1169
|
/**
|
|
1151
1170
|
* This is an async method that sends a request to obtain the access token and returns a Promise
|
|
@@ -1173,9 +1192,9 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1173
1192
|
* @preserve
|
|
1174
1193
|
*/
|
|
1175
1194
|
async requestAccessToken(authorizationCode, sessionState, state, userId, tokenRequestConfig) {
|
|
1176
|
-
const
|
|
1177
|
-
const tokenEndpoint = (await this.
|
|
1178
|
-
const configData = await this.
|
|
1195
|
+
const performTokenRequest = async () => {
|
|
1196
|
+
const tokenEndpoint = (await this.oidcProviderMetaDataProvider()).token_endpoint;
|
|
1197
|
+
const configData = await this.configProvider();
|
|
1179
1198
|
if (!tokenEndpoint || tokenEndpoint.trim().length === 0) {
|
|
1180
1199
|
throw new AsgardeoAuthException(
|
|
1181
1200
|
"JS-AUTH_CORE-RAT1-NF01",
|
|
@@ -1183,11 +1202,13 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1183
1202
|
"No token endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the token endpoint passed to the SDK is empty."
|
|
1184
1203
|
);
|
|
1185
1204
|
}
|
|
1186
|
-
sessionState
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1205
|
+
if (sessionState) {
|
|
1206
|
+
await this.storageManager.setSessionDataParameter(
|
|
1207
|
+
OIDCRequestConstants_default.Params.SESSION_STATE,
|
|
1208
|
+
sessionState,
|
|
1209
|
+
userId
|
|
1210
|
+
);
|
|
1211
|
+
}
|
|
1191
1212
|
const body = new URLSearchParams();
|
|
1192
1213
|
body.set("client_id", configData.clientId);
|
|
1193
1214
|
if (configData.clientSecret && configData.clientSecret.trim().length > 0) {
|
|
@@ -1205,9 +1226,9 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1205
1226
|
if (configData.enablePKCE) {
|
|
1206
1227
|
body.set(
|
|
1207
1228
|
"code_verifier",
|
|
1208
|
-
`${await this.
|
|
1229
|
+
`${await this.storageManager.getTemporaryDataParameter(extractPkceStorageKeyFromState_default(state), userId)}`
|
|
1209
1230
|
);
|
|
1210
|
-
await this.
|
|
1231
|
+
await this.storageManager.removeTemporaryDataParameter(extractPkceStorageKeyFromState_default(state), userId);
|
|
1211
1232
|
}
|
|
1212
1233
|
let tokenResponse;
|
|
1213
1234
|
try {
|
|
@@ -1234,25 +1255,23 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1234
1255
|
await tokenResponse.json()
|
|
1235
1256
|
);
|
|
1236
1257
|
}
|
|
1237
|
-
return
|
|
1258
|
+
return this.authHelper.handleTokenResponse(tokenResponse, userId);
|
|
1238
1259
|
};
|
|
1239
|
-
if (await this.
|
|
1260
|
+
if (await this.storageManager.getTemporaryDataParameter(
|
|
1240
1261
|
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED
|
|
1241
1262
|
)) {
|
|
1242
|
-
return
|
|
1263
|
+
return performTokenRequest();
|
|
1243
1264
|
}
|
|
1244
|
-
return this.loadOpenIDProviderConfiguration(false).then(() =>
|
|
1245
|
-
return __TODO__();
|
|
1246
|
-
});
|
|
1265
|
+
return this.loadOpenIDProviderConfiguration(false).then(() => performTokenRequest());
|
|
1247
1266
|
}
|
|
1248
1267
|
async loadOpenIDProviderConfiguration(forceInit) {
|
|
1249
|
-
const configData = await this.
|
|
1250
|
-
if (!forceInit && await this.
|
|
1268
|
+
const configData = await this.configProvider();
|
|
1269
|
+
if (!forceInit && await this.storageManager.getTemporaryDataParameter(
|
|
1251
1270
|
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED
|
|
1252
1271
|
)) {
|
|
1253
1272
|
return Promise.resolve();
|
|
1254
1273
|
}
|
|
1255
|
-
const wellKnownEndpoint = configData
|
|
1274
|
+
const { wellKnownEndpoint } = configData;
|
|
1256
1275
|
if (wellKnownEndpoint) {
|
|
1257
1276
|
let response;
|
|
1258
1277
|
try {
|
|
@@ -1267,19 +1286,16 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1267
1286
|
"The well known endpoint response has been failed with an error."
|
|
1268
1287
|
);
|
|
1269
1288
|
}
|
|
1270
|
-
await this.
|
|
1271
|
-
|
|
1272
|
-
);
|
|
1273
|
-
await this._storageManager.setTemporaryDataParameter(
|
|
1289
|
+
await this.storageManager.setOIDCProviderMetaData(await this.authHelper.resolveEndpoints(await response.json()));
|
|
1290
|
+
await this.storageManager.setTemporaryDataParameter(
|
|
1274
1291
|
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,
|
|
1275
1292
|
true
|
|
1276
1293
|
);
|
|
1277
1294
|
return Promise.resolve();
|
|
1278
|
-
}
|
|
1295
|
+
}
|
|
1296
|
+
if (configData.baseUrl) {
|
|
1279
1297
|
try {
|
|
1280
|
-
await this.
|
|
1281
|
-
await this._authenticationHelper.resolveEndpointsByBaseURL()
|
|
1282
|
-
);
|
|
1298
|
+
await this.storageManager.setOIDCProviderMetaData(await this.authHelper.resolveEndpointsByBaseURL());
|
|
1283
1299
|
} catch (error2) {
|
|
1284
1300
|
throw new AsgardeoAuthException(
|
|
1285
1301
|
"JS-AUTH_CORE-GOPMD-IV02",
|
|
@@ -1287,19 +1303,18 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1287
1303
|
error2 ?? "Resolving endpoints by base url failed."
|
|
1288
1304
|
);
|
|
1289
1305
|
}
|
|
1290
|
-
await this.
|
|
1291
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,
|
|
1292
|
-
true
|
|
1293
|
-
);
|
|
1294
|
-
return Promise.resolve();
|
|
1295
|
-
} else {
|
|
1296
|
-
await this._storageManager.setOIDCProviderMetaData(await this._authenticationHelper.resolveEndpointsExplicitly());
|
|
1297
|
-
await this._storageManager.setTemporaryDataParameter(
|
|
1306
|
+
await this.storageManager.setTemporaryDataParameter(
|
|
1298
1307
|
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,
|
|
1299
1308
|
true
|
|
1300
1309
|
);
|
|
1301
1310
|
return Promise.resolve();
|
|
1302
1311
|
}
|
|
1312
|
+
await this.storageManager.setOIDCProviderMetaData(await this.authHelper.resolveEndpointsExplicitly());
|
|
1313
|
+
await this.storageManager.setTemporaryDataParameter(
|
|
1314
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,
|
|
1315
|
+
true
|
|
1316
|
+
);
|
|
1317
|
+
return Promise.resolve();
|
|
1303
1318
|
}
|
|
1304
1319
|
/**
|
|
1305
1320
|
* This method returns the sign-out URL.
|
|
@@ -1321,8 +1336,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1321
1336
|
* @preserve
|
|
1322
1337
|
*/
|
|
1323
1338
|
async getSignOutUrl(userId) {
|
|
1324
|
-
const logoutEndpoint = (await this.
|
|
1325
|
-
const configData = await this.
|
|
1339
|
+
const logoutEndpoint = (await this.oidcProviderMetaDataProvider())?.end_session_endpoint;
|
|
1340
|
+
const configData = await this.configProvider();
|
|
1326
1341
|
if (!logoutEndpoint || logoutEndpoint.trim().length === 0) {
|
|
1327
1342
|
throw new AsgardeoAuthException(
|
|
1328
1343
|
"JS-AUTH_CORE-GSOU-NF01",
|
|
@@ -1341,7 +1356,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1341
1356
|
const queryParams = new URLSearchParams();
|
|
1342
1357
|
queryParams.set("post_logout_redirect_uri", callbackURL);
|
|
1343
1358
|
if (configData.sendIdTokenInLogoutRequest) {
|
|
1344
|
-
const idToken = (await this.
|
|
1359
|
+
const idToken = (await this.storageManager.getSessionData(userId))?.id_token;
|
|
1345
1360
|
if (!idToken || idToken.trim().length === 0) {
|
|
1346
1361
|
throw new AsgardeoAuthException(
|
|
1347
1362
|
"JS-AUTH_CORE-GSOU-NF02",
|
|
@@ -1371,7 +1386,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1371
1386
|
* @preserve
|
|
1372
1387
|
*/
|
|
1373
1388
|
async getOpenIDProviderEndpoints() {
|
|
1374
|
-
const oidcProviderMetaData = await this.
|
|
1389
|
+
const oidcProviderMetaData = await this.oidcProviderMetaDataProvider();
|
|
1375
1390
|
return {
|
|
1376
1391
|
authorizationEndpoint: oidcProviderMetaData.authorization_endpoint ?? "",
|
|
1377
1392
|
checkSessionIframe: oidcProviderMetaData.check_session_iframe ?? "",
|
|
@@ -1397,7 +1412,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1397
1412
|
* ```
|
|
1398
1413
|
*/
|
|
1399
1414
|
async decodeJwtToken(token) {
|
|
1400
|
-
return this.
|
|
1415
|
+
return this.cryptoHelper.decodeJwtToken(token);
|
|
1401
1416
|
}
|
|
1402
1417
|
/**
|
|
1403
1418
|
* This method decodes the payload of the ID token and returns it.
|
|
@@ -1417,8 +1432,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1417
1432
|
* @preserve
|
|
1418
1433
|
*/
|
|
1419
1434
|
async getDecodedIdToken(userId, idToken) {
|
|
1420
|
-
const
|
|
1421
|
-
const payload = this.
|
|
1435
|
+
const storedIdToken = (await this.storageManager.getSessionData(userId)).id_token;
|
|
1436
|
+
const payload = this.cryptoHelper.decodeJwtToken(storedIdToken ?? idToken);
|
|
1422
1437
|
return payload;
|
|
1423
1438
|
}
|
|
1424
1439
|
/**
|
|
@@ -1439,7 +1454,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1439
1454
|
* @preserve
|
|
1440
1455
|
*/
|
|
1441
1456
|
async getIdToken(userId) {
|
|
1442
|
-
return (await this.
|
|
1457
|
+
return (await this.storageManager.getSessionData(userId)).id_token;
|
|
1443
1458
|
}
|
|
1444
1459
|
/**
|
|
1445
1460
|
* This method returns the basic user information obtained from the ID token.
|
|
@@ -1459,8 +1474,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1459
1474
|
* @preserve
|
|
1460
1475
|
*/
|
|
1461
1476
|
async getUser(userId) {
|
|
1462
|
-
const sessionData = await this.
|
|
1463
|
-
const authenticatedUser = this.
|
|
1477
|
+
const sessionData = await this.storageManager.getSessionData(userId);
|
|
1478
|
+
const authenticatedUser = this.authHelper.getAuthenticatedUserInfo(sessionData?.id_token);
|
|
1464
1479
|
Object.keys(authenticatedUser).forEach((key) => {
|
|
1465
1480
|
if (authenticatedUser[key] === void 0 || authenticatedUser[key] === "" || authenticatedUser[key] === null) {
|
|
1466
1481
|
delete authenticatedUser[key];
|
|
@@ -1469,7 +1484,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1469
1484
|
return authenticatedUser;
|
|
1470
1485
|
}
|
|
1471
1486
|
async getUserSession(userId) {
|
|
1472
|
-
const sessionData = await this.
|
|
1487
|
+
const sessionData = await this.storageManager.getSessionData(userId);
|
|
1473
1488
|
return {
|
|
1474
1489
|
scopes: sessionData?.scope?.split(" "),
|
|
1475
1490
|
sessionState: sessionData?.session_state ?? ""
|
|
@@ -1490,7 +1505,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1490
1505
|
* @preserve
|
|
1491
1506
|
*/
|
|
1492
1507
|
async getCrypto() {
|
|
1493
|
-
return this.
|
|
1508
|
+
return this.cryptoHelper;
|
|
1494
1509
|
}
|
|
1495
1510
|
/**
|
|
1496
1511
|
* This method revokes the access token.
|
|
@@ -1516,8 +1531,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1516
1531
|
* @preserve
|
|
1517
1532
|
*/
|
|
1518
1533
|
async revokeAccessToken(userId) {
|
|
1519
|
-
const revokeTokenEndpoint = (await this.
|
|
1520
|
-
const configData = await this.
|
|
1534
|
+
const revokeTokenEndpoint = (await this.oidcProviderMetaDataProvider()).revocation_endpoint;
|
|
1535
|
+
const configData = await this.configProvider();
|
|
1521
1536
|
if (!revokeTokenEndpoint || revokeTokenEndpoint.trim().length === 0) {
|
|
1522
1537
|
throw new AsgardeoAuthException(
|
|
1523
1538
|
"JS-AUTH_CORE-RAT3-NF01",
|
|
@@ -1527,7 +1542,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1527
1542
|
}
|
|
1528
1543
|
const body = [];
|
|
1529
1544
|
body.push(`client_id=${configData.clientId}`);
|
|
1530
|
-
body.push(`token=${(await this.
|
|
1545
|
+
body.push(`token=${(await this.storageManager.getSessionData(userId)).access_token}`);
|
|
1531
1546
|
body.push("token_type_hint=access_token");
|
|
1532
1547
|
if (configData.clientSecret && configData.clientSecret.trim().length > 0) {
|
|
1533
1548
|
body.push(`client_secret=${configData.clientSecret}`);
|
|
@@ -1557,7 +1572,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1557
1572
|
await response.json()
|
|
1558
1573
|
);
|
|
1559
1574
|
}
|
|
1560
|
-
this.
|
|
1575
|
+
this.authHelper.clearSession(userId);
|
|
1561
1576
|
return Promise.resolve(response);
|
|
1562
1577
|
}
|
|
1563
1578
|
/**
|
|
@@ -1583,9 +1598,9 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1583
1598
|
* @preserve
|
|
1584
1599
|
*/
|
|
1585
1600
|
async refreshAccessToken(userId) {
|
|
1586
|
-
const tokenEndpoint = (await this.
|
|
1587
|
-
const configData = await this.
|
|
1588
|
-
const sessionData = await this.
|
|
1601
|
+
const tokenEndpoint = (await this.oidcProviderMetaDataProvider()).token_endpoint;
|
|
1602
|
+
const configData = await this.configProvider();
|
|
1603
|
+
const sessionData = await this.storageManager.getSessionData(userId);
|
|
1589
1604
|
if (!sessionData.refresh_token) {
|
|
1590
1605
|
throw new AsgardeoAuthException(
|
|
1591
1606
|
"JS-AUTH_CORE-RAT2-NF01",
|
|
@@ -1632,7 +1647,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1632
1647
|
await tokenResponse.json()
|
|
1633
1648
|
);
|
|
1634
1649
|
}
|
|
1635
|
-
return this.
|
|
1650
|
+
return this.authHelper.handleTokenResponse(tokenResponse, userId);
|
|
1636
1651
|
}
|
|
1637
1652
|
/**
|
|
1638
1653
|
* This method returns the access token.
|
|
@@ -1652,7 +1667,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1652
1667
|
* @preserve
|
|
1653
1668
|
*/
|
|
1654
1669
|
async getAccessToken(userId) {
|
|
1655
|
-
return (await this.
|
|
1670
|
+
return (await this.storageManager.getSessionData(userId))?.access_token;
|
|
1656
1671
|
}
|
|
1657
1672
|
/**
|
|
1658
1673
|
* This method sends a custom-grant request and returns a Promise that resolves with the response
|
|
@@ -1693,8 +1708,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1693
1708
|
* @preserve
|
|
1694
1709
|
*/
|
|
1695
1710
|
async exchangeToken(config, userId) {
|
|
1696
|
-
const oidcProviderMetadata = await this.
|
|
1697
|
-
const configData = await this.
|
|
1711
|
+
const oidcProviderMetadata = await this.oidcProviderMetaDataProvider();
|
|
1712
|
+
const configData = await this.configProvider();
|
|
1698
1713
|
let tokenEndpoint;
|
|
1699
1714
|
if (config.tokenEndpoint && config.tokenEndpoint.trim().length !== 0) {
|
|
1700
1715
|
tokenEndpoint = config.tokenEndpoint;
|
|
@@ -1710,10 +1725,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1710
1725
|
}
|
|
1711
1726
|
const data = await Promise.all(
|
|
1712
1727
|
Object.entries(config.data).map(async ([key, value]) => {
|
|
1713
|
-
const newValue = await this.
|
|
1714
|
-
value,
|
|
1715
|
-
userId
|
|
1716
|
-
);
|
|
1728
|
+
const newValue = await this.authHelper.replaceCustomGrantTemplateTags(value, userId);
|
|
1717
1729
|
return `${key}=${newValue}`;
|
|
1718
1730
|
})
|
|
1719
1731
|
);
|
|
@@ -1724,7 +1736,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1724
1736
|
if (config.attachToken) {
|
|
1725
1737
|
requestHeaders = {
|
|
1726
1738
|
...requestHeaders,
|
|
1727
|
-
Authorization: `Bearer ${(await this.
|
|
1739
|
+
Authorization: `Bearer ${(await this.storageManager.getSessionData(userId)).access_token}`
|
|
1728
1740
|
};
|
|
1729
1741
|
}
|
|
1730
1742
|
const requestConfig = {
|
|
@@ -1751,10 +1763,9 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1751
1763
|
);
|
|
1752
1764
|
}
|
|
1753
1765
|
if (config.returnsSession) {
|
|
1754
|
-
return this.
|
|
1755
|
-
} else {
|
|
1756
|
-
return Promise.resolve(await response.json());
|
|
1766
|
+
return this.authHelper.handleTokenResponse(response, userId);
|
|
1757
1767
|
}
|
|
1768
|
+
return Promise.resolve(await response.json());
|
|
1758
1769
|
}
|
|
1759
1770
|
/**
|
|
1760
1771
|
* This method returns if the user is authenticated or not.
|
|
@@ -1775,12 +1786,12 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1775
1786
|
*/
|
|
1776
1787
|
async isSignedIn(userId) {
|
|
1777
1788
|
const isAccessTokenAvailable = Boolean(await this.getAccessToken(userId));
|
|
1778
|
-
const createdAt = (await this.
|
|
1779
|
-
const expiresInString = (await this.
|
|
1789
|
+
const createdAt = (await this.storageManager.getSessionData(userId))?.created_at;
|
|
1790
|
+
const expiresInString = (await this.storageManager.getSessionData(userId))?.expires_in;
|
|
1780
1791
|
if (!expiresInString) {
|
|
1781
1792
|
return false;
|
|
1782
1793
|
}
|
|
1783
|
-
const expiresIn = parseInt(expiresInString) * 1e3;
|
|
1794
|
+
const expiresIn = parseInt(expiresInString, 10) * 1e3;
|
|
1784
1795
|
const currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
1785
1796
|
const isAccessTokenValid = createdAt + expiresIn > currentTime;
|
|
1786
1797
|
const isSignedIn = isAccessTokenAvailable && isAccessTokenValid;
|
|
@@ -1805,7 +1816,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1805
1816
|
* @preserve
|
|
1806
1817
|
*/
|
|
1807
1818
|
async getPKCECode(state, userId) {
|
|
1808
|
-
return await this.
|
|
1819
|
+
return await this.storageManager.getTemporaryDataParameter(
|
|
1809
1820
|
extractPkceStorageKeyFromState_default(state),
|
|
1810
1821
|
userId
|
|
1811
1822
|
);
|
|
@@ -1828,7 +1839,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1828
1839
|
* @preserve
|
|
1829
1840
|
*/
|
|
1830
1841
|
async setPKCECode(pkce, state, userId) {
|
|
1831
|
-
return
|
|
1842
|
+
return this.storageManager.setTemporaryDataParameter(extractPkceStorageKeyFromState_default(state), pkce, userId);
|
|
1832
1843
|
}
|
|
1833
1844
|
/**
|
|
1834
1845
|
* This method returns if the sign-out is successful or not.
|
|
@@ -1890,17 +1901,16 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1890
1901
|
* @preserve
|
|
1891
1902
|
*/
|
|
1892
1903
|
async reInitialize(config) {
|
|
1893
|
-
await this.
|
|
1904
|
+
await this.storageManager.setConfigData(config);
|
|
1894
1905
|
await this.loadOpenIDProviderConfiguration(true);
|
|
1895
1906
|
}
|
|
1896
1907
|
static async clearSession(userId) {
|
|
1897
|
-
await this.
|
|
1908
|
+
await this.authHelperInstance.clearSession(userId);
|
|
1898
1909
|
}
|
|
1899
1910
|
};
|
|
1900
|
-
__publicField(_AsgardeoAuthClient, "_instanceID");
|
|
1901
1911
|
// FIXME: Validate this.
|
|
1902
1912
|
// Ref: https://github.com/asgardeo/asgardeo-auth-js-core/pull/205
|
|
1903
|
-
__publicField(_AsgardeoAuthClient, "
|
|
1913
|
+
__publicField(_AsgardeoAuthClient, "authHelperInstance");
|
|
1904
1914
|
var AsgardeoAuthClient = _AsgardeoAuthClient;
|
|
1905
1915
|
|
|
1906
1916
|
// src/errors/AsgardeoAPIError.ts
|
|
@@ -1920,8 +1930,8 @@ var AsgardeoAPIError = class extends AsgardeoError {
|
|
|
1920
1930
|
this.statusCode = statusCode;
|
|
1921
1931
|
this.statusText = statusText;
|
|
1922
1932
|
Object.defineProperty(this, "name", {
|
|
1923
|
-
value: "AsgardeoAPIError",
|
|
1924
1933
|
configurable: true,
|
|
1934
|
+
value: "AsgardeoAPIError",
|
|
1925
1935
|
writable: true
|
|
1926
1936
|
});
|
|
1927
1937
|
}
|
|
@@ -1972,13 +1982,13 @@ var initializeEmbeddedSignInFlow = async ({
|
|
|
1972
1982
|
try {
|
|
1973
1983
|
const response = await fetch(url ?? `${baseUrl}/oauth2/authorize`, {
|
|
1974
1984
|
...requestConfig,
|
|
1975
|
-
|
|
1985
|
+
body: searchParams.toString(),
|
|
1976
1986
|
headers: {
|
|
1977
1987
|
...requestConfig.headers,
|
|
1978
|
-
|
|
1979
|
-
|
|
1988
|
+
Accept: "application/json",
|
|
1989
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
1980
1990
|
},
|
|
1981
|
-
|
|
1991
|
+
method: requestConfig.method || "POST"
|
|
1982
1992
|
});
|
|
1983
1993
|
if (!response.ok) {
|
|
1984
1994
|
const errorText = await response.text();
|
|
@@ -2036,13 +2046,13 @@ var executeEmbeddedSignInFlow = async ({
|
|
|
2036
2046
|
try {
|
|
2037
2047
|
const response = await fetch(url ?? `${baseUrl}/oauth2/authn`, {
|
|
2038
2048
|
...requestConfig,
|
|
2039
|
-
|
|
2049
|
+
body: JSON.stringify(payload),
|
|
2040
2050
|
headers: {
|
|
2041
|
-
"Content-Type": "application/json",
|
|
2042
2051
|
Accept: "application/json",
|
|
2052
|
+
"Content-Type": "application/json",
|
|
2043
2053
|
...requestConfig.headers
|
|
2044
2054
|
},
|
|
2045
|
-
|
|
2055
|
+
method: requestConfig.method || "POST"
|
|
2046
2056
|
});
|
|
2047
2057
|
if (!response.ok) {
|
|
2048
2058
|
const errorText = await response.text();
|
|
@@ -2130,16 +2140,16 @@ var executeEmbeddedSignUpFlow = async ({
|
|
|
2130
2140
|
try {
|
|
2131
2141
|
const response = await fetch(url ?? `${baseUrl}/api/server/v1/flow/execute`, {
|
|
2132
2142
|
...requestConfig,
|
|
2133
|
-
method: requestConfig.method || "POST",
|
|
2134
|
-
headers: {
|
|
2135
|
-
"Content-Type": "application/json",
|
|
2136
|
-
Accept: "application/json",
|
|
2137
|
-
...requestConfig.headers
|
|
2138
|
-
},
|
|
2139
2143
|
body: JSON.stringify({
|
|
2140
2144
|
...payload ?? {},
|
|
2141
2145
|
flowType: "REGISTRATION" /* Registration */
|
|
2142
|
-
})
|
|
2146
|
+
}),
|
|
2147
|
+
headers: {
|
|
2148
|
+
Accept: "application/json",
|
|
2149
|
+
"Content-Type": "application/json",
|
|
2150
|
+
...requestConfig.headers
|
|
2151
|
+
},
|
|
2152
|
+
method: requestConfig.method || "POST"
|
|
2143
2153
|
});
|
|
2144
2154
|
if (!response.ok) {
|
|
2145
2155
|
const errorText = await response.text();
|
|
@@ -2183,12 +2193,12 @@ var getUserInfo = async ({ url, ...requestConfig }) => {
|
|
|
2183
2193
|
try {
|
|
2184
2194
|
const response = await fetch(url, {
|
|
2185
2195
|
...requestConfig,
|
|
2186
|
-
method: "GET",
|
|
2187
2196
|
headers: {
|
|
2188
|
-
"Content-Type": "application/json",
|
|
2189
2197
|
Accept: "application/json",
|
|
2198
|
+
"Content-Type": "application/json",
|
|
2190
2199
|
...requestConfig.headers
|
|
2191
|
-
}
|
|
2200
|
+
},
|
|
2201
|
+
method: "GET"
|
|
2192
2202
|
});
|
|
2193
2203
|
if (!response.ok) {
|
|
2194
2204
|
const errorText = await response.text();
|
|
@@ -2259,12 +2269,12 @@ var getScim2Me = async ({ url, baseUrl, fetcher, ...requestConfig }) => {
|
|
|
2259
2269
|
const resolvedUrl = url ?? `${baseUrl}/scim2/Me`;
|
|
2260
2270
|
const requestInit = {
|
|
2261
2271
|
...requestConfig,
|
|
2262
|
-
method: "GET",
|
|
2263
2272
|
headers: {
|
|
2264
|
-
"Content-Type": "application/scim+json",
|
|
2265
2273
|
Accept: "application/json",
|
|
2274
|
+
"Content-Type": "application/scim+json",
|
|
2266
2275
|
...requestConfig.headers
|
|
2267
|
-
}
|
|
2276
|
+
},
|
|
2277
|
+
method: "GET"
|
|
2268
2278
|
};
|
|
2269
2279
|
try {
|
|
2270
2280
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2312,12 +2322,12 @@ var getSchemas = async ({ url, baseUrl, fetcher, ...requestConfig }) => {
|
|
|
2312
2322
|
const resolvedUrl = url ?? `${baseUrl}/scim2/Schemas`;
|
|
2313
2323
|
const requestInit = {
|
|
2314
2324
|
...requestConfig,
|
|
2315
|
-
method: "GET",
|
|
2316
2325
|
headers: {
|
|
2317
|
-
"Content-Type": "application/json",
|
|
2318
2326
|
Accept: "application/json",
|
|
2327
|
+
"Content-Type": "application/json",
|
|
2319
2328
|
...requestConfig.headers
|
|
2320
|
-
}
|
|
2329
|
+
},
|
|
2330
|
+
method: "GET"
|
|
2321
2331
|
};
|
|
2322
2332
|
try {
|
|
2323
2333
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2380,12 +2390,12 @@ var getAllOrganizations = async ({
|
|
|
2380
2390
|
const resolvedUrl = `${baseUrl}/api/server/v1/organizations?${queryParams.toString()}`;
|
|
2381
2391
|
const requestInit = {
|
|
2382
2392
|
...requestConfig,
|
|
2383
|
-
method: "GET",
|
|
2384
2393
|
headers: {
|
|
2385
2394
|
...requestConfig.headers,
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
}
|
|
2395
|
+
Accept: "application/json",
|
|
2396
|
+
"Content-Type": "application/json"
|
|
2397
|
+
},
|
|
2398
|
+
method: "GET"
|
|
2389
2399
|
};
|
|
2390
2400
|
try {
|
|
2391
2401
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2456,13 +2466,13 @@ var createOrganization = async ({
|
|
|
2456
2466
|
const resolvedUrl = `${baseUrl}/api/server/v1/organizations`;
|
|
2457
2467
|
const requestInit = {
|
|
2458
2468
|
...requestConfig,
|
|
2459
|
-
|
|
2469
|
+
body: JSON.stringify(organizationPayload),
|
|
2460
2470
|
headers: {
|
|
2461
|
-
"Content-Type": "application/json",
|
|
2462
2471
|
Accept: "application/json",
|
|
2472
|
+
"Content-Type": "application/json",
|
|
2463
2473
|
...requestConfig.headers
|
|
2464
2474
|
},
|
|
2465
|
-
|
|
2475
|
+
method: "POST"
|
|
2466
2476
|
};
|
|
2467
2477
|
try {
|
|
2468
2478
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2531,12 +2541,12 @@ var getMeOrganizations = async ({
|
|
|
2531
2541
|
const resolvedUrl = `${baseUrl}/api/users/v1/me/organizations?${queryParams.toString()}`;
|
|
2532
2542
|
const requestInit = {
|
|
2533
2543
|
...requestConfig,
|
|
2534
|
-
method: "GET",
|
|
2535
2544
|
headers: {
|
|
2536
|
-
"Content-Type": "application/json",
|
|
2537
2545
|
Accept: "application/json",
|
|
2546
|
+
"Content-Type": "application/json",
|
|
2538
2547
|
...requestConfig.headers
|
|
2539
|
-
}
|
|
2548
|
+
},
|
|
2549
|
+
method: "GET"
|
|
2540
2550
|
};
|
|
2541
2551
|
try {
|
|
2542
2552
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2551,7 +2561,7 @@ var getMeOrganizations = async ({
|
|
|
2551
2561
|
);
|
|
2552
2562
|
}
|
|
2553
2563
|
const data = await response.json();
|
|
2554
|
-
return data
|
|
2564
|
+
return data["organizations"] || [];
|
|
2555
2565
|
} catch (error2) {
|
|
2556
2566
|
if (error2 instanceof AsgardeoAPIError) {
|
|
2557
2567
|
throw error2;
|
|
@@ -2598,12 +2608,12 @@ var getOrganization = async ({
|
|
|
2598
2608
|
const resolvedUrl = `${baseUrl}/api/server/v1/organizations/${organizationId}`;
|
|
2599
2609
|
const requestInit = {
|
|
2600
2610
|
...requestConfig,
|
|
2601
|
-
method: "GET",
|
|
2602
2611
|
headers: {
|
|
2603
|
-
"Content-Type": "application/json",
|
|
2604
2612
|
Accept: "application/json",
|
|
2613
|
+
"Content-Type": "application/json",
|
|
2605
2614
|
...requestConfig.headers
|
|
2606
|
-
}
|
|
2615
|
+
},
|
|
2616
|
+
method: "GET"
|
|
2607
2617
|
};
|
|
2608
2618
|
try {
|
|
2609
2619
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2692,13 +2702,13 @@ var updateOrganization = async ({
|
|
|
2692
2702
|
const resolvedUrl = `${baseUrl}/api/server/v1/organizations/${organizationId}`;
|
|
2693
2703
|
const requestInit = {
|
|
2694
2704
|
...requestConfig,
|
|
2695
|
-
|
|
2705
|
+
body: JSON.stringify(operations),
|
|
2696
2706
|
headers: {
|
|
2697
|
-
"Content-Type": "application/json",
|
|
2698
2707
|
Accept: "application/json",
|
|
2708
|
+
"Content-Type": "application/json",
|
|
2699
2709
|
...requestConfig.headers
|
|
2700
2710
|
},
|
|
2701
|
-
|
|
2711
|
+
method: "PATCH"
|
|
2702
2712
|
};
|
|
2703
2713
|
try {
|
|
2704
2714
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2726,21 +2736,19 @@ var updateOrganization = async ({
|
|
|
2726
2736
|
);
|
|
2727
2737
|
}
|
|
2728
2738
|
};
|
|
2729
|
-
var createPatchOperations = (payload) => {
|
|
2730
|
-
|
|
2731
|
-
if (isEmpty_default(value)) {
|
|
2732
|
-
return {
|
|
2733
|
-
operation: "REMOVE",
|
|
2734
|
-
path: `/${key}`
|
|
2735
|
-
};
|
|
2736
|
-
}
|
|
2739
|
+
var createPatchOperations = (payload) => Object.entries(payload).map(([key, value]) => {
|
|
2740
|
+
if (isEmpty_default(value)) {
|
|
2737
2741
|
return {
|
|
2738
|
-
operation: "
|
|
2739
|
-
path: `/${key}
|
|
2740
|
-
value
|
|
2742
|
+
operation: "REMOVE",
|
|
2743
|
+
path: `/${key}`
|
|
2741
2744
|
};
|
|
2742
|
-
}
|
|
2743
|
-
|
|
2745
|
+
}
|
|
2746
|
+
return {
|
|
2747
|
+
operation: "REPLACE",
|
|
2748
|
+
path: `/${key}`,
|
|
2749
|
+
value
|
|
2750
|
+
};
|
|
2751
|
+
});
|
|
2744
2752
|
var updateOrganization_default = updateOrganization;
|
|
2745
2753
|
|
|
2746
2754
|
// src/api/updateMeProfile.ts
|
|
@@ -2776,12 +2784,12 @@ var updateMeProfile = async ({
|
|
|
2776
2784
|
const requestInit = {
|
|
2777
2785
|
method: "PATCH",
|
|
2778
2786
|
...requestConfig,
|
|
2787
|
+
body: JSON.stringify(data),
|
|
2779
2788
|
headers: {
|
|
2780
2789
|
...requestConfig.headers,
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
}
|
|
2784
|
-
body: JSON.stringify(data)
|
|
2790
|
+
Accept: "application/json",
|
|
2791
|
+
"Content-Type": "application/scim+json"
|
|
2792
|
+
}
|
|
2785
2793
|
};
|
|
2786
2794
|
try {
|
|
2787
2795
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2844,12 +2852,12 @@ var getBrandingPreference = async ({
|
|
|
2844
2852
|
const resolvedUrl = `${baseUrl}/api/server/v1/branding-preference/resolve${queryParams.toString() ? `?${queryParams.toString()}` : ""}`;
|
|
2845
2853
|
const requestInit = {
|
|
2846
2854
|
...requestConfig,
|
|
2847
|
-
method: "GET",
|
|
2848
2855
|
headers: {
|
|
2849
|
-
"Content-Type": "application/json",
|
|
2850
2856
|
Accept: "application/json",
|
|
2857
|
+
"Content-Type": "application/json",
|
|
2851
2858
|
...requestConfig.headers
|
|
2852
|
-
}
|
|
2859
|
+
},
|
|
2860
|
+
method: "GET"
|
|
2853
2861
|
};
|
|
2854
2862
|
try {
|
|
2855
2863
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2883,8 +2891,8 @@ var getBrandingPreference_default = getBrandingPreference;
|
|
|
2883
2891
|
// src/models/v2/embedded-signin-flow-v2.ts
|
|
2884
2892
|
var EmbeddedSignInFlowStatus = /* @__PURE__ */ ((EmbeddedSignInFlowStatus3) => {
|
|
2885
2893
|
EmbeddedSignInFlowStatus3["Complete"] = "COMPLETE";
|
|
2886
|
-
EmbeddedSignInFlowStatus3["Incomplete"] = "INCOMPLETE";
|
|
2887
2894
|
EmbeddedSignInFlowStatus3["Error"] = "ERROR";
|
|
2895
|
+
EmbeddedSignInFlowStatus3["Incomplete"] = "INCOMPLETE";
|
|
2888
2896
|
return EmbeddedSignInFlowStatus3;
|
|
2889
2897
|
})(EmbeddedSignInFlowStatus || {});
|
|
2890
2898
|
var EmbeddedSignInFlowType = /* @__PURE__ */ ((EmbeddedSignInFlowType3) => {
|
|
@@ -2910,20 +2918,20 @@ var executeEmbeddedSignInFlowV2 = async ({
|
|
|
2910
2918
|
"If an authorization payload is not provided, the request cannot be constructed correctly."
|
|
2911
2919
|
);
|
|
2912
2920
|
}
|
|
2913
|
-
|
|
2921
|
+
const endpoint = url ?? `${baseUrl}/flow/execute`;
|
|
2914
2922
|
const cleanPayload = typeof payload === "object" && payload !== null ? Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "verbose")) : payload;
|
|
2915
2923
|
const hasOnlyAppIdAndFlowType = typeof cleanPayload === "object" && cleanPayload !== null && "applicationId" in cleanPayload && "flowType" in cleanPayload && Object.keys(cleanPayload).length === 2;
|
|
2916
2924
|
const hasOnlyFlowId = typeof cleanPayload === "object" && cleanPayload !== null && "flowId" in cleanPayload && Object.keys(cleanPayload).length === 1;
|
|
2917
2925
|
const requestPayload = hasOnlyAppIdAndFlowType || hasOnlyFlowId ? { ...cleanPayload, verbose: true } : cleanPayload;
|
|
2918
2926
|
const response = await fetch(endpoint, {
|
|
2919
2927
|
...requestConfig,
|
|
2920
|
-
|
|
2928
|
+
body: JSON.stringify(requestPayload),
|
|
2921
2929
|
headers: {
|
|
2922
|
-
"Content-Type": "application/json",
|
|
2923
2930
|
Accept: "application/json",
|
|
2931
|
+
"Content-Type": "application/json",
|
|
2924
2932
|
...requestConfig.headers
|
|
2925
2933
|
},
|
|
2926
|
-
|
|
2934
|
+
method: requestConfig.method || "POST"
|
|
2927
2935
|
});
|
|
2928
2936
|
if (!response.ok) {
|
|
2929
2937
|
const errorText = await response.text();
|
|
@@ -2939,17 +2947,17 @@ var executeEmbeddedSignInFlowV2 = async ({
|
|
|
2939
2947
|
if (flowResponse.flowStatus === "COMPLETE" /* Complete */ && flowResponse.assertion && authId) {
|
|
2940
2948
|
try {
|
|
2941
2949
|
const oauth2Response = await fetch(`${baseUrl}/oauth2/auth/callback`, {
|
|
2942
|
-
method: "POST",
|
|
2943
|
-
headers: {
|
|
2944
|
-
"Content-Type": "application/json",
|
|
2945
|
-
Accept: "application/json",
|
|
2946
|
-
...requestConfig.headers
|
|
2947
|
-
},
|
|
2948
2950
|
body: JSON.stringify({
|
|
2949
2951
|
assertion: flowResponse.assertion,
|
|
2950
2952
|
authId
|
|
2951
2953
|
}),
|
|
2952
|
-
credentials: "include"
|
|
2954
|
+
credentials: "include",
|
|
2955
|
+
headers: {
|
|
2956
|
+
Accept: "application/json",
|
|
2957
|
+
"Content-Type": "application/json",
|
|
2958
|
+
...requestConfig.headers
|
|
2959
|
+
},
|
|
2960
|
+
method: "POST"
|
|
2953
2961
|
});
|
|
2954
2962
|
if (!oauth2Response.ok) {
|
|
2955
2963
|
const oauth2ErrorText = await oauth2Response.text();
|
|
@@ -2964,7 +2972,7 @@ var executeEmbeddedSignInFlowV2 = async ({
|
|
|
2964
2972
|
const oauth2Result = await oauth2Response.json();
|
|
2965
2973
|
return {
|
|
2966
2974
|
flowStatus: flowResponse.flowStatus,
|
|
2967
|
-
redirectUrl: oauth2Result
|
|
2975
|
+
redirectUrl: oauth2Result["redirect_uri"]
|
|
2968
2976
|
};
|
|
2969
2977
|
} catch (authError) {
|
|
2970
2978
|
throw new AsgardeoAPIError(
|
|
@@ -2983,8 +2991,8 @@ var executeEmbeddedSignInFlowV2_default = executeEmbeddedSignInFlowV2;
|
|
|
2983
2991
|
// src/models/v2/embedded-signup-flow-v2.ts
|
|
2984
2992
|
var EmbeddedSignUpFlowStatus = /* @__PURE__ */ ((EmbeddedSignUpFlowStatus2) => {
|
|
2985
2993
|
EmbeddedSignUpFlowStatus2["Complete"] = "COMPLETE";
|
|
2986
|
-
EmbeddedSignUpFlowStatus2["Incomplete"] = "INCOMPLETE";
|
|
2987
2994
|
EmbeddedSignUpFlowStatus2["Error"] = "ERROR";
|
|
2995
|
+
EmbeddedSignUpFlowStatus2["Incomplete"] = "INCOMPLETE";
|
|
2988
2996
|
return EmbeddedSignUpFlowStatus2;
|
|
2989
2997
|
})(EmbeddedSignUpFlowStatus || {});
|
|
2990
2998
|
var EmbeddedSignUpFlowType = /* @__PURE__ */ ((EmbeddedSignUpFlowType2) => {
|
|
@@ -3010,20 +3018,20 @@ var executeEmbeddedSignUpFlowV2 = async ({
|
|
|
3010
3018
|
"If a registration payload is not provided, the request cannot be constructed correctly."
|
|
3011
3019
|
);
|
|
3012
3020
|
}
|
|
3013
|
-
|
|
3021
|
+
const endpoint = url ?? `${baseUrl}/flow/execute`;
|
|
3014
3022
|
const cleanPayload = typeof payload === "object" && payload !== null ? Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "verbose")) : payload;
|
|
3015
3023
|
const hasOnlyAppIdAndFlowType = typeof cleanPayload === "object" && cleanPayload !== null && "applicationId" in cleanPayload && "flowType" in cleanPayload && Object.keys(cleanPayload).length === 2;
|
|
3016
3024
|
const hasOnlyFlowId = typeof cleanPayload === "object" && cleanPayload !== null && "flowId" in cleanPayload && Object.keys(cleanPayload).length === 1;
|
|
3017
3025
|
const requestPayload = hasOnlyAppIdAndFlowType || hasOnlyFlowId ? { ...cleanPayload, verbose: true } : cleanPayload;
|
|
3018
3026
|
const response = await fetch(endpoint, {
|
|
3019
3027
|
...requestConfig,
|
|
3020
|
-
|
|
3028
|
+
body: JSON.stringify(requestPayload),
|
|
3021
3029
|
headers: {
|
|
3022
|
-
"Content-Type": "application/json",
|
|
3023
3030
|
Accept: "application/json",
|
|
3031
|
+
"Content-Type": "application/json",
|
|
3024
3032
|
...requestConfig.headers
|
|
3025
3033
|
},
|
|
3026
|
-
|
|
3034
|
+
method: requestConfig.method || "POST"
|
|
3027
3035
|
});
|
|
3028
3036
|
if (!response.ok) {
|
|
3029
3037
|
const errorText = await response.text();
|
|
@@ -3039,17 +3047,17 @@ var executeEmbeddedSignUpFlowV2 = async ({
|
|
|
3039
3047
|
if (flowResponse.flowStatus === "COMPLETE" /* Complete */ && flowResponse.assertion && authId) {
|
|
3040
3048
|
try {
|
|
3041
3049
|
const oauth2Response = await fetch(`${baseUrl}/oauth2/auth/callback`, {
|
|
3042
|
-
method: "POST",
|
|
3043
|
-
headers: {
|
|
3044
|
-
"Content-Type": "application/json",
|
|
3045
|
-
Accept: "application/json",
|
|
3046
|
-
...requestConfig.headers
|
|
3047
|
-
},
|
|
3048
3050
|
body: JSON.stringify({
|
|
3049
3051
|
assertion: flowResponse.assertion,
|
|
3050
3052
|
authId
|
|
3051
3053
|
}),
|
|
3052
|
-
credentials: "include"
|
|
3054
|
+
credentials: "include",
|
|
3055
|
+
headers: {
|
|
3056
|
+
Accept: "application/json",
|
|
3057
|
+
"Content-Type": "application/json",
|
|
3058
|
+
...requestConfig.headers
|
|
3059
|
+
},
|
|
3060
|
+
method: "POST"
|
|
3053
3061
|
});
|
|
3054
3062
|
if (!oauth2Response.ok) {
|
|
3055
3063
|
const oauth2ErrorText = await oauth2Response.text();
|
|
@@ -3064,7 +3072,7 @@ var executeEmbeddedSignUpFlowV2 = async ({
|
|
|
3064
3072
|
const oauth2Result = await oauth2Response.json();
|
|
3065
3073
|
return {
|
|
3066
3074
|
flowStatus: flowResponse.flowStatus,
|
|
3067
|
-
redirectUrl: oauth2Result
|
|
3075
|
+
redirectUrl: oauth2Result["redirect_uri"]
|
|
3068
3076
|
};
|
|
3069
3077
|
} catch (authError) {
|
|
3070
3078
|
throw new AsgardeoAPIError(
|
|
@@ -3107,13 +3115,13 @@ var executeEmbeddedUserOnboardingFlowV2 = async ({
|
|
|
3107
3115
|
}
|
|
3108
3116
|
const response = await fetch(endpoint, {
|
|
3109
3117
|
...requestConfig,
|
|
3110
|
-
|
|
3118
|
+
body: JSON.stringify(requestPayload),
|
|
3111
3119
|
headers: {
|
|
3112
|
-
"Content-Type": "application/json",
|
|
3113
3120
|
Accept: "application/json",
|
|
3121
|
+
"Content-Type": "application/json",
|
|
3114
3122
|
...requestConfig.headers
|
|
3115
3123
|
},
|
|
3116
|
-
|
|
3124
|
+
method: requestConfig.method || "POST"
|
|
3117
3125
|
});
|
|
3118
3126
|
if (!response.ok) {
|
|
3119
3127
|
const errorText = await response.text();
|
|
@@ -3133,20 +3141,20 @@ var executeEmbeddedUserOnboardingFlowV2_default = executeEmbeddedUserOnboardingF
|
|
|
3133
3141
|
// src/constants/ApplicationNativeAuthenticationConstants.ts
|
|
3134
3142
|
var ApplicationNativeAuthenticationConstants = {
|
|
3135
3143
|
SupportedAuthenticators: {
|
|
3136
|
-
IdentifierFirst: "SWRlbnRpZmllckV4ZWN1dG9yOkxPQ0FM",
|
|
3137
3144
|
EmailOtp: "ZW1haWwtb3RwLWF1dGhlbnRpY2F0b3I6TE9DQUw",
|
|
3138
|
-
Totp: "dG90cDpMT0NBTA",
|
|
3139
|
-
UsernamePassword: "QmFzaWNBdXRoZW50aWNhdG9yOkxPQ0FM",
|
|
3140
|
-
PushNotification: "cHVzaC1ub3RpZmljYXRpb24tYXV0aGVudGljYXRvcjpMT0NBTA",
|
|
3141
|
-
Passkey: "RklET0F1dGhlbnRpY2F0b3I6TE9DQUw",
|
|
3142
|
-
SmsOtp: "c21zLW90cC1hdXRoZW50aWNhdG9yOkxPQ0FM",
|
|
3143
|
-
MagicLink: "TWFnaWNMaW5rQXV0aGVudGljYXRvcjpMT0NBTA",
|
|
3144
|
-
Google: "R29vZ2xlT0lEQ0F1dGhlbnRpY2F0b3I6R29vZ2xl",
|
|
3145
|
-
GitHub: "R2l0aHViQXV0aGVudGljYXRvcjpHaXRIdWI",
|
|
3146
|
-
Microsoft: "T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I6TWljcm9zb2Z0",
|
|
3147
3145
|
Facebook: "RmFjZWJvb2tBdXRoZW50aWNhdG9yOkZhY2Vib29r",
|
|
3146
|
+
GitHub: "R2l0aHViQXV0aGVudGljYXRvcjpHaXRIdWI",
|
|
3147
|
+
Google: "R29vZ2xlT0lEQ0F1dGhlbnRpY2F0b3I6R29vZ2xl",
|
|
3148
|
+
IdentifierFirst: "SWRlbnRpZmllckV4ZWN1dG9yOkxPQ0FM",
|
|
3148
3149
|
LinkedIn: "TGlua2VkSW5PSURDOkxpbmtlZElu",
|
|
3149
|
-
|
|
3150
|
+
MagicLink: "TWFnaWNMaW5rQXV0aGVudGljYXRvcjpMT0NBTA",
|
|
3151
|
+
Microsoft: "T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I6TWljcm9zb2Z0",
|
|
3152
|
+
Passkey: "RklET0F1dGhlbnRpY2F0b3I6TE9DQUw",
|
|
3153
|
+
PushNotification: "cHVzaC1ub3RpZmljYXRpb24tYXV0aGVudGljYXRvcjpMT0NBTA",
|
|
3154
|
+
SignInWithEthereum: "T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I6U2lnbiBJbiBXaXRoIEV0aGVyZXVt",
|
|
3155
|
+
SmsOtp: "c21zLW90cC1hdXRoZW50aWNhdG9yOkxPQ0FM",
|
|
3156
|
+
Totp: "dG90cDpMT0NBTA",
|
|
3157
|
+
UsernamePassword: "QmFzaWNBdXRoZW50aWNhdG9yOkxPQ0FM"
|
|
3150
3158
|
}
|
|
3151
3159
|
};
|
|
3152
3160
|
var ApplicationNativeAuthenticationConstants_default = ApplicationNativeAuthenticationConstants;
|
|
@@ -3196,53 +3204,53 @@ var EmbeddedSignInFlowAuthenticatorPromptType = /* @__PURE__ */ ((EmbeddedSignIn
|
|
|
3196
3204
|
|
|
3197
3205
|
// src/models/v2/embedded-flow-v2.ts
|
|
3198
3206
|
var EmbeddedFlowComponentType2 = /* @__PURE__ */ ((EmbeddedFlowComponentType3) => {
|
|
3199
|
-
EmbeddedFlowComponentType3["TextInput"] = "TEXT_INPUT";
|
|
3200
|
-
EmbeddedFlowComponentType3["PasswordInput"] = "PASSWORD_INPUT";
|
|
3201
|
-
EmbeddedFlowComponentType3["EmailInput"] = "EMAIL_INPUT";
|
|
3202
|
-
EmbeddedFlowComponentType3["OtpInput"] = "OTP_INPUT";
|
|
3203
|
-
EmbeddedFlowComponentType3["PhoneInput"] = "PHONE_INPUT";
|
|
3204
|
-
EmbeddedFlowComponentType3["Text"] = "TEXT";
|
|
3205
3207
|
EmbeddedFlowComponentType3["Action"] = "ACTION";
|
|
3206
3208
|
EmbeddedFlowComponentType3["Block"] = "BLOCK";
|
|
3207
3209
|
EmbeddedFlowComponentType3["Divider"] = "DIVIDER";
|
|
3210
|
+
EmbeddedFlowComponentType3["EmailInput"] = "EMAIL_INPUT";
|
|
3211
|
+
EmbeddedFlowComponentType3["OtpInput"] = "OTP_INPUT";
|
|
3212
|
+
EmbeddedFlowComponentType3["PasswordInput"] = "PASSWORD_INPUT";
|
|
3213
|
+
EmbeddedFlowComponentType3["PhoneInput"] = "PHONE_INPUT";
|
|
3208
3214
|
EmbeddedFlowComponentType3["Select"] = "SELECT";
|
|
3215
|
+
EmbeddedFlowComponentType3["Text"] = "TEXT";
|
|
3216
|
+
EmbeddedFlowComponentType3["TextInput"] = "TEXT_INPUT";
|
|
3209
3217
|
return EmbeddedFlowComponentType3;
|
|
3210
3218
|
})(EmbeddedFlowComponentType2 || {});
|
|
3211
3219
|
var EmbeddedFlowActionVariant = /* @__PURE__ */ ((EmbeddedFlowActionVariant2) => {
|
|
3212
|
-
EmbeddedFlowActionVariant2["Primary"] = "PRIMARY";
|
|
3213
|
-
EmbeddedFlowActionVariant2["Secondary"] = "SECONDARY";
|
|
3214
|
-
EmbeddedFlowActionVariant2["Tertiary"] = "TERTIARY";
|
|
3215
3220
|
EmbeddedFlowActionVariant2["Danger"] = "DANGER";
|
|
3216
|
-
EmbeddedFlowActionVariant2["Success"] = "SUCCESS";
|
|
3217
3221
|
EmbeddedFlowActionVariant2["Info"] = "INFO";
|
|
3218
|
-
EmbeddedFlowActionVariant2["Warning"] = "WARNING";
|
|
3219
3222
|
EmbeddedFlowActionVariant2["Link"] = "LINK";
|
|
3223
|
+
EmbeddedFlowActionVariant2["Primary"] = "PRIMARY";
|
|
3224
|
+
EmbeddedFlowActionVariant2["Secondary"] = "SECONDARY";
|
|
3220
3225
|
EmbeddedFlowActionVariant2["Social"] = "SOCIAL";
|
|
3226
|
+
EmbeddedFlowActionVariant2["Success"] = "SUCCESS";
|
|
3227
|
+
EmbeddedFlowActionVariant2["Tertiary"] = "TERTIARY";
|
|
3228
|
+
EmbeddedFlowActionVariant2["Warning"] = "WARNING";
|
|
3221
3229
|
return EmbeddedFlowActionVariant2;
|
|
3222
3230
|
})(EmbeddedFlowActionVariant || {});
|
|
3223
3231
|
var EmbeddedFlowTextVariant = /* @__PURE__ */ ((EmbeddedFlowTextVariant2) => {
|
|
3232
|
+
EmbeddedFlowTextVariant2["Body1"] = "BODY_1";
|
|
3233
|
+
EmbeddedFlowTextVariant2["Body2"] = "BODY_2";
|
|
3234
|
+
EmbeddedFlowTextVariant2["ButtonText"] = "BUTTON_TEXT";
|
|
3235
|
+
EmbeddedFlowTextVariant2["Caption"] = "CAPTION";
|
|
3224
3236
|
EmbeddedFlowTextVariant2["Heading1"] = "HEADING_1";
|
|
3225
3237
|
EmbeddedFlowTextVariant2["Heading2"] = "HEADING_2";
|
|
3226
3238
|
EmbeddedFlowTextVariant2["Heading3"] = "HEADING_3";
|
|
3227
3239
|
EmbeddedFlowTextVariant2["Heading4"] = "HEADING_4";
|
|
3228
3240
|
EmbeddedFlowTextVariant2["Heading5"] = "HEADING_5";
|
|
3229
3241
|
EmbeddedFlowTextVariant2["Heading6"] = "HEADING_6";
|
|
3242
|
+
EmbeddedFlowTextVariant2["Overline"] = "OVERLINE";
|
|
3230
3243
|
EmbeddedFlowTextVariant2["Subtitle1"] = "SUBTITLE_1";
|
|
3231
3244
|
EmbeddedFlowTextVariant2["Subtitle2"] = "SUBTITLE_2";
|
|
3232
|
-
EmbeddedFlowTextVariant2["Body1"] = "BODY_1";
|
|
3233
|
-
EmbeddedFlowTextVariant2["Body2"] = "BODY_2";
|
|
3234
|
-
EmbeddedFlowTextVariant2["Caption"] = "CAPTION";
|
|
3235
|
-
EmbeddedFlowTextVariant2["Overline"] = "OVERLINE";
|
|
3236
|
-
EmbeddedFlowTextVariant2["ButtonText"] = "BUTTON_TEXT";
|
|
3237
3245
|
return EmbeddedFlowTextVariant2;
|
|
3238
3246
|
})(EmbeddedFlowTextVariant || {});
|
|
3239
3247
|
var EmbeddedFlowEventType = /* @__PURE__ */ ((EmbeddedFlowEventType2) => {
|
|
3240
|
-
EmbeddedFlowEventType2["
|
|
3241
|
-
EmbeddedFlowEventType2["Submit"] = "SUBMIT";
|
|
3242
|
-
EmbeddedFlowEventType2["Navigate"] = "NAVIGATE";
|
|
3248
|
+
EmbeddedFlowEventType2["Back"] = "BACK";
|
|
3243
3249
|
EmbeddedFlowEventType2["Cancel"] = "CANCEL";
|
|
3250
|
+
EmbeddedFlowEventType2["Navigate"] = "NAVIGATE";
|
|
3244
3251
|
EmbeddedFlowEventType2["Reset"] = "RESET";
|
|
3245
|
-
EmbeddedFlowEventType2["
|
|
3252
|
+
EmbeddedFlowEventType2["Submit"] = "SUBMIT";
|
|
3253
|
+
EmbeddedFlowEventType2["Trigger"] = "TRIGGER";
|
|
3246
3254
|
return EmbeddedFlowEventType2;
|
|
3247
3255
|
})(EmbeddedFlowEventType || {});
|
|
3248
3256
|
|
|
@@ -3256,26 +3264,26 @@ var FlowMode = /* @__PURE__ */ ((FlowMode2) => {
|
|
|
3256
3264
|
// src/models/scim2-schema.ts
|
|
3257
3265
|
var WellKnownSchemaIds = /* @__PURE__ */ ((WellKnownSchemaIds2) => {
|
|
3258
3266
|
WellKnownSchemaIds2["Core"] = "urn:ietf:params:scim:schemas:core:2.0";
|
|
3259
|
-
WellKnownSchemaIds2["
|
|
3267
|
+
WellKnownSchemaIds2["CustomUser"] = "urn:scim:schemas:extension:custom:User";
|
|
3260
3268
|
WellKnownSchemaIds2["EnterpriseUser"] = "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User";
|
|
3261
3269
|
WellKnownSchemaIds2["SystemUser"] = "urn:scim:wso2:schema";
|
|
3262
|
-
WellKnownSchemaIds2["
|
|
3270
|
+
WellKnownSchemaIds2["User"] = "urn:ietf:params:scim:schemas:core:2.0:User";
|
|
3263
3271
|
return WellKnownSchemaIds2;
|
|
3264
3272
|
})(WellKnownSchemaIds || {});
|
|
3265
3273
|
|
|
3266
3274
|
// src/models/field.ts
|
|
3267
3275
|
var FieldType = /* @__PURE__ */ ((FieldType2) => {
|
|
3268
|
-
FieldType2["
|
|
3269
|
-
FieldType2["
|
|
3276
|
+
FieldType2["Checkbox"] = "CHECKBOX";
|
|
3277
|
+
FieldType2["Date"] = "DATE";
|
|
3270
3278
|
FieldType2["Email"] = "EMAIL";
|
|
3271
3279
|
FieldType2["Number"] = "NUMBER";
|
|
3272
|
-
FieldType2["Select"] = "SELECT";
|
|
3273
|
-
FieldType2["Checkbox"] = "CHECKBOX";
|
|
3274
|
-
FieldType2["Radio"] = "RADIO";
|
|
3275
3280
|
FieldType2["Otp"] = "OTP";
|
|
3276
|
-
FieldType2["
|
|
3277
|
-
FieldType2["
|
|
3281
|
+
FieldType2["Password"] = "PASSWORD";
|
|
3282
|
+
FieldType2["Radio"] = "RADIO";
|
|
3283
|
+
FieldType2["Select"] = "SELECT";
|
|
3284
|
+
FieldType2["Text"] = "TEXT";
|
|
3278
3285
|
FieldType2["Textarea"] = "TEXTAREA";
|
|
3286
|
+
FieldType2["Time"] = "TIME";
|
|
3279
3287
|
return FieldType2;
|
|
3280
3288
|
})(FieldType || {});
|
|
3281
3289
|
|
|
@@ -3286,221 +3294,221 @@ var AsgardeoJavaScriptClient_default = AsgardeoJavaScriptClient;
|
|
|
3286
3294
|
|
|
3287
3295
|
// src/theme/createTheme.ts
|
|
3288
3296
|
var lightTheme = {
|
|
3297
|
+
borderRadius: {
|
|
3298
|
+
large: "16px",
|
|
3299
|
+
medium: "8px",
|
|
3300
|
+
small: "4px"
|
|
3301
|
+
},
|
|
3289
3302
|
colors: {
|
|
3290
3303
|
action: {
|
|
3304
|
+
activatedOpacity: 0.12,
|
|
3291
3305
|
active: "rgba(0, 0, 0, 0.54)",
|
|
3292
|
-
hover: "rgba(0, 0, 0, 0.04)",
|
|
3293
|
-
hoverOpacity: 0.04,
|
|
3294
|
-
selected: "rgba(0, 0, 0, 0.08)",
|
|
3295
|
-
selectedOpacity: 0.08,
|
|
3296
3306
|
disabled: "rgba(0, 0, 0, 0.26)",
|
|
3297
3307
|
disabledBackground: "rgba(0, 0, 0, 0.12)",
|
|
3298
3308
|
disabledOpacity: 0.38,
|
|
3299
3309
|
focus: "rgba(0, 0, 0, 0.12)",
|
|
3300
3310
|
focusOpacity: 0.12,
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
contrastText: "#ffffff",
|
|
3306
|
-
dark: "#174ea6"
|
|
3307
|
-
},
|
|
3308
|
-
secondary: {
|
|
3309
|
-
main: "#424242",
|
|
3310
|
-
contrastText: "#ffffff",
|
|
3311
|
-
dark: "#212121"
|
|
3311
|
+
hover: "rgba(0, 0, 0, 0.04)",
|
|
3312
|
+
hoverOpacity: 0.04,
|
|
3313
|
+
selected: "rgba(0, 0, 0, 0.08)",
|
|
3314
|
+
selectedOpacity: 0.08
|
|
3312
3315
|
},
|
|
3313
3316
|
background: {
|
|
3314
|
-
surface: "#ffffff",
|
|
3315
|
-
disabled: "#f0f0f0",
|
|
3316
|
-
dark: "#212121",
|
|
3317
3317
|
body: {
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
}
|
|
3318
|
+
dark: "#212121",
|
|
3319
|
+
main: "#1a1a1a"
|
|
3320
|
+
},
|
|
3321
|
+
dark: "#212121",
|
|
3322
|
+
disabled: "#f0f0f0",
|
|
3323
|
+
surface: "#ffffff"
|
|
3321
3324
|
},
|
|
3325
|
+
border: "#e0e0e0",
|
|
3322
3326
|
error: {
|
|
3323
|
-
main: "#d32f2f",
|
|
3324
3327
|
contrastText: "#d52828",
|
|
3325
|
-
dark: "#b71c1c"
|
|
3328
|
+
dark: "#b71c1c",
|
|
3329
|
+
main: "#d32f2f"
|
|
3326
3330
|
},
|
|
3327
3331
|
info: {
|
|
3328
|
-
main: "#bbebff",
|
|
3329
3332
|
contrastText: "#43aeda",
|
|
3330
|
-
dark: "#01579b"
|
|
3333
|
+
dark: "#01579b",
|
|
3334
|
+
main: "#bbebff"
|
|
3335
|
+
},
|
|
3336
|
+
primary: {
|
|
3337
|
+
contrastText: "#ffffff",
|
|
3338
|
+
dark: "#174ea6",
|
|
3339
|
+
main: "#1a73e8"
|
|
3340
|
+
},
|
|
3341
|
+
secondary: {
|
|
3342
|
+
contrastText: "#ffffff",
|
|
3343
|
+
dark: "#212121",
|
|
3344
|
+
main: "#424242"
|
|
3331
3345
|
},
|
|
3332
3346
|
success: {
|
|
3333
|
-
main: "#4caf50",
|
|
3334
3347
|
contrastText: "#00a807",
|
|
3335
|
-
dark: "#388e3c"
|
|
3336
|
-
|
|
3337
|
-
warning: {
|
|
3338
|
-
main: "#ff9800",
|
|
3339
|
-
contrastText: "#be7100",
|
|
3340
|
-
dark: "#f57c00"
|
|
3348
|
+
dark: "#388e3c",
|
|
3349
|
+
main: "#4caf50"
|
|
3341
3350
|
},
|
|
3342
3351
|
text: {
|
|
3352
|
+
dark: "#212121",
|
|
3343
3353
|
primary: "#1a1a1a",
|
|
3344
|
-
secondary: "#666666"
|
|
3345
|
-
dark: "#212121"
|
|
3354
|
+
secondary: "#666666"
|
|
3346
3355
|
},
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3356
|
+
warning: {
|
|
3357
|
+
contrastText: "#be7100",
|
|
3358
|
+
dark: "#f57c00",
|
|
3359
|
+
main: "#ff9800"
|
|
3360
|
+
}
|
|
3351
3361
|
},
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
large: "16px"
|
|
3362
|
+
images: {
|
|
3363
|
+
favicon: {},
|
|
3364
|
+
logo: {}
|
|
3356
3365
|
},
|
|
3357
3366
|
shadows: {
|
|
3358
|
-
|
|
3367
|
+
large: "0 8px 32px rgba(0, 0, 0, 0.2)",
|
|
3359
3368
|
medium: "0 4px 16px rgba(0, 0, 0, 0.15)",
|
|
3360
|
-
|
|
3369
|
+
small: "0 2px 8px rgba(0, 0, 0, 0.1)"
|
|
3370
|
+
},
|
|
3371
|
+
spacing: {
|
|
3372
|
+
unit: 8
|
|
3361
3373
|
},
|
|
3362
3374
|
typography: {
|
|
3363
3375
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
|
|
3364
3376
|
fontSizes: {
|
|
3365
|
-
|
|
3366
|
-
//
|
|
3367
|
-
|
|
3368
|
-
//
|
|
3369
|
-
md: "1rem",
|
|
3370
|
-
// 16px
|
|
3377
|
+
"2xl": "1.5rem",
|
|
3378
|
+
// 24px
|
|
3379
|
+
"3xl": "2.125rem",
|
|
3380
|
+
// 34px
|
|
3371
3381
|
lg: "1.125rem",
|
|
3372
3382
|
// 18px
|
|
3383
|
+
md: "1rem",
|
|
3384
|
+
// 16px
|
|
3385
|
+
sm: "0.875rem",
|
|
3386
|
+
// 14px
|
|
3373
3387
|
xl: "1.25rem",
|
|
3374
3388
|
// 20px
|
|
3375
|
-
|
|
3376
|
-
//
|
|
3377
|
-
"3xl": "2.125rem"
|
|
3378
|
-
// 34px
|
|
3389
|
+
xs: "0.75rem"
|
|
3390
|
+
// 12px
|
|
3379
3391
|
},
|
|
3380
3392
|
fontWeights: {
|
|
3381
|
-
|
|
3393
|
+
bold: 700,
|
|
3382
3394
|
medium: 500,
|
|
3383
|
-
|
|
3384
|
-
|
|
3395
|
+
normal: 400,
|
|
3396
|
+
semibold: 600
|
|
3385
3397
|
},
|
|
3386
3398
|
lineHeights: {
|
|
3387
|
-
tight: 1.2,
|
|
3388
3399
|
normal: 1.4,
|
|
3389
|
-
relaxed: 1.6
|
|
3400
|
+
relaxed: 1.6,
|
|
3401
|
+
tight: 1.2
|
|
3390
3402
|
}
|
|
3391
|
-
},
|
|
3392
|
-
images: {
|
|
3393
|
-
favicon: {},
|
|
3394
|
-
logo: {}
|
|
3395
3403
|
}
|
|
3396
3404
|
};
|
|
3397
3405
|
var darkTheme = {
|
|
3406
|
+
borderRadius: {
|
|
3407
|
+
large: "16px",
|
|
3408
|
+
medium: "8px",
|
|
3409
|
+
small: "4px"
|
|
3410
|
+
},
|
|
3398
3411
|
colors: {
|
|
3399
3412
|
action: {
|
|
3413
|
+
activatedOpacity: 0.12,
|
|
3400
3414
|
active: "#1c1c1c",
|
|
3401
|
-
hover: "#1c1c1c",
|
|
3402
|
-
hoverOpacity: 0.04,
|
|
3403
|
-
selected: "#1c1c1c",
|
|
3404
|
-
selectedOpacity: 0.08,
|
|
3405
3415
|
disabled: "rgba(255, 255, 255, 0.26)",
|
|
3406
3416
|
disabledBackground: "rgba(255, 255, 255, 0.12)",
|
|
3407
3417
|
disabledOpacity: 0.38,
|
|
3408
3418
|
focus: "#1c1c1c",
|
|
3409
3419
|
focusOpacity: 0.12,
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
contrastText: "#ffffff",
|
|
3415
|
-
dark: "#174ea6"
|
|
3416
|
-
},
|
|
3417
|
-
secondary: {
|
|
3418
|
-
main: "#8b8b8b",
|
|
3419
|
-
contrastText: "#ffffff",
|
|
3420
|
-
dark: "#212121"
|
|
3420
|
+
hover: "#1c1c1c",
|
|
3421
|
+
hoverOpacity: 0.04,
|
|
3422
|
+
selected: "#1c1c1c",
|
|
3423
|
+
selectedOpacity: 0.08
|
|
3421
3424
|
},
|
|
3422
3425
|
background: {
|
|
3423
|
-
surface: "#121212",
|
|
3424
|
-
disabled: "#1f1f1f",
|
|
3425
|
-
dark: "#212121",
|
|
3426
3426
|
body: {
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
}
|
|
3427
|
+
dark: "#212121",
|
|
3428
|
+
main: "#ffffff"
|
|
3429
|
+
},
|
|
3430
|
+
dark: "#212121",
|
|
3431
|
+
disabled: "#1f1f1f",
|
|
3432
|
+
surface: "#121212"
|
|
3430
3433
|
},
|
|
3434
|
+
border: "#404040",
|
|
3431
3435
|
error: {
|
|
3432
|
-
main: "#d32f2f",
|
|
3433
3436
|
contrastText: "#d52828",
|
|
3434
|
-
dark: "#b71c1c"
|
|
3437
|
+
dark: "#b71c1c",
|
|
3438
|
+
main: "#d32f2f"
|
|
3435
3439
|
},
|
|
3436
3440
|
info: {
|
|
3437
|
-
main: "#bbebff",
|
|
3438
3441
|
contrastText: "#43aeda",
|
|
3439
|
-
dark: "#01579b"
|
|
3442
|
+
dark: "#01579b",
|
|
3443
|
+
main: "#bbebff"
|
|
3440
3444
|
},
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
+
primary: {
|
|
3446
|
+
contrastText: "#ffffff",
|
|
3447
|
+
dark: "#174ea6",
|
|
3448
|
+
main: "#1a73e8"
|
|
3445
3449
|
},
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
+
secondary: {
|
|
3451
|
+
contrastText: "#ffffff",
|
|
3452
|
+
dark: "#212121",
|
|
3453
|
+
main: "#8b8b8b"
|
|
3454
|
+
},
|
|
3455
|
+
success: {
|
|
3456
|
+
contrastText: "#00a807",
|
|
3457
|
+
dark: "#388e3c",
|
|
3458
|
+
main: "#4caf50"
|
|
3450
3459
|
},
|
|
3451
3460
|
text: {
|
|
3461
|
+
dark: "#212121",
|
|
3452
3462
|
primary: "#ffffff",
|
|
3453
|
-
secondary: "#b3b3b3"
|
|
3454
|
-
dark: "#212121"
|
|
3463
|
+
secondary: "#b3b3b3"
|
|
3455
3464
|
},
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3465
|
+
warning: {
|
|
3466
|
+
contrastText: "#be7100",
|
|
3467
|
+
dark: "#f57c00",
|
|
3468
|
+
main: "#ff9800"
|
|
3469
|
+
}
|
|
3460
3470
|
},
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
large: "16px"
|
|
3471
|
+
images: {
|
|
3472
|
+
favicon: {},
|
|
3473
|
+
logo: {}
|
|
3465
3474
|
},
|
|
3466
3475
|
shadows: {
|
|
3467
|
-
|
|
3476
|
+
large: "0 8px 32px rgba(0, 0, 0, 0.5)",
|
|
3468
3477
|
medium: "0 4px 16px rgba(0, 0, 0, 0.4)",
|
|
3469
|
-
|
|
3478
|
+
small: "0 2px 8px rgba(0, 0, 0, 0.3)"
|
|
3479
|
+
},
|
|
3480
|
+
spacing: {
|
|
3481
|
+
unit: 8
|
|
3470
3482
|
},
|
|
3471
3483
|
typography: {
|
|
3472
3484
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
|
|
3473
3485
|
fontSizes: {
|
|
3474
|
-
|
|
3475
|
-
//
|
|
3476
|
-
|
|
3477
|
-
//
|
|
3478
|
-
md: "1rem",
|
|
3479
|
-
// 16px
|
|
3486
|
+
"2xl": "1.5rem",
|
|
3487
|
+
// 24px
|
|
3488
|
+
"3xl": "2.125rem",
|
|
3489
|
+
// 34px
|
|
3480
3490
|
lg: "1.125rem",
|
|
3481
3491
|
// 18px
|
|
3492
|
+
md: "1rem",
|
|
3493
|
+
// 16px
|
|
3494
|
+
sm: "0.875rem",
|
|
3495
|
+
// 14px
|
|
3482
3496
|
xl: "1.25rem",
|
|
3483
3497
|
// 20px
|
|
3484
|
-
|
|
3485
|
-
//
|
|
3486
|
-
"3xl": "2.125rem"
|
|
3487
|
-
// 34px
|
|
3498
|
+
xs: "0.75rem"
|
|
3499
|
+
// 12px
|
|
3488
3500
|
},
|
|
3489
3501
|
fontWeights: {
|
|
3490
|
-
|
|
3502
|
+
bold: 700,
|
|
3491
3503
|
medium: 500,
|
|
3492
|
-
|
|
3493
|
-
|
|
3504
|
+
normal: 400,
|
|
3505
|
+
semibold: 600
|
|
3494
3506
|
},
|
|
3495
3507
|
lineHeights: {
|
|
3496
|
-
tight: 1.2,
|
|
3497
3508
|
normal: 1.4,
|
|
3498
|
-
relaxed: 1.6
|
|
3509
|
+
relaxed: 1.6,
|
|
3510
|
+
tight: 1.2
|
|
3499
3511
|
}
|
|
3500
|
-
},
|
|
3501
|
-
images: {
|
|
3502
|
-
favicon: {},
|
|
3503
|
-
logo: {}
|
|
3504
3512
|
}
|
|
3505
3513
|
};
|
|
3506
3514
|
var toCssVariables = (theme) => {
|
|
@@ -3699,91 +3707,91 @@ var toThemeVars = (theme) => {
|
|
|
3699
3707
|
};
|
|
3700
3708
|
}
|
|
3701
3709
|
const themeVars = {
|
|
3710
|
+
borderRadius: {
|
|
3711
|
+
large: `var(--${prefix}-border-radius-large)`,
|
|
3712
|
+
medium: `var(--${prefix}-border-radius-medium)`,
|
|
3713
|
+
small: `var(--${prefix}-border-radius-small)`
|
|
3714
|
+
},
|
|
3702
3715
|
colors: {
|
|
3703
3716
|
action: {
|
|
3717
|
+
activatedOpacity: `var(--${prefix}-color-action-activatedOpacity)`,
|
|
3704
3718
|
active: `var(--${prefix}-color-action-active)`,
|
|
3705
|
-
hover: `var(--${prefix}-color-action-hover)`,
|
|
3706
|
-
hoverOpacity: `var(--${prefix}-color-action-hoverOpacity)`,
|
|
3707
|
-
selected: `var(--${prefix}-color-action-selected)`,
|
|
3708
|
-
selectedOpacity: `var(--${prefix}-color-action-selectedOpacity)`,
|
|
3709
3719
|
disabled: `var(--${prefix}-color-action-disabled)`,
|
|
3710
3720
|
disabledBackground: `var(--${prefix}-color-action-disabledBackground)`,
|
|
3711
3721
|
disabledOpacity: `var(--${prefix}-color-action-disabledOpacity)`,
|
|
3712
3722
|
focus: `var(--${prefix}-color-action-focus)`,
|
|
3713
3723
|
focusOpacity: `var(--${prefix}-color-action-focusOpacity)`,
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
contrastText: `var(--${prefix}-color-primary-contrastText)`
|
|
3719
|
-
},
|
|
3720
|
-
secondary: {
|
|
3721
|
-
main: `var(--${prefix}-color-secondary-main)`,
|
|
3722
|
-
contrastText: `var(--${prefix}-color-secondary-contrastText)`
|
|
3724
|
+
hover: `var(--${prefix}-color-action-hover)`,
|
|
3725
|
+
hoverOpacity: `var(--${prefix}-color-action-hoverOpacity)`,
|
|
3726
|
+
selected: `var(--${prefix}-color-action-selected)`,
|
|
3727
|
+
selectedOpacity: `var(--${prefix}-color-action-selectedOpacity)`
|
|
3723
3728
|
},
|
|
3724
3729
|
background: {
|
|
3725
|
-
surface: `var(--${prefix}-color-background-surface)`,
|
|
3726
|
-
disabled: `var(--${prefix}-color-background-disabled)`,
|
|
3727
3730
|
body: {
|
|
3728
3731
|
main: `var(--${prefix}-color-background-body-main)`
|
|
3729
|
-
}
|
|
3732
|
+
},
|
|
3733
|
+
disabled: `var(--${prefix}-color-background-disabled)`,
|
|
3734
|
+
surface: `var(--${prefix}-color-background-surface)`
|
|
3730
3735
|
},
|
|
3736
|
+
border: `var(--${prefix}-color-border)`,
|
|
3731
3737
|
error: {
|
|
3732
|
-
|
|
3733
|
-
|
|
3738
|
+
contrastText: `var(--${prefix}-color-error-contrastText)`,
|
|
3739
|
+
main: `var(--${prefix}-color-error-main)`
|
|
3734
3740
|
},
|
|
3735
3741
|
info: {
|
|
3736
3742
|
contrastText: `var(--${prefix}-color-info-contrastText)`,
|
|
3737
3743
|
main: `var(--${prefix}-color-info-main)`
|
|
3738
3744
|
},
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3745
|
+
primary: {
|
|
3746
|
+
contrastText: `var(--${prefix}-color-primary-contrastText)`,
|
|
3747
|
+
main: `var(--${prefix}-color-primary-main)`
|
|
3742
3748
|
},
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3749
|
+
secondary: {
|
|
3750
|
+
contrastText: `var(--${prefix}-color-secondary-contrastText)`,
|
|
3751
|
+
main: `var(--${prefix}-color-secondary-main)`
|
|
3752
|
+
},
|
|
3753
|
+
success: {
|
|
3754
|
+
contrastText: `var(--${prefix}-color-success-contrastText)`,
|
|
3755
|
+
main: `var(--${prefix}-color-success-main)`
|
|
3746
3756
|
},
|
|
3747
3757
|
text: {
|
|
3748
3758
|
primary: `var(--${prefix}-color-text-primary)`,
|
|
3749
3759
|
secondary: `var(--${prefix}-color-text-secondary)`
|
|
3750
3760
|
},
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
},
|
|
3756
|
-
borderRadius: {
|
|
3757
|
-
small: `var(--${prefix}-border-radius-small)`,
|
|
3758
|
-
medium: `var(--${prefix}-border-radius-medium)`,
|
|
3759
|
-
large: `var(--${prefix}-border-radius-large)`
|
|
3761
|
+
warning: {
|
|
3762
|
+
contrastText: `var(--${prefix}-color-warning-contrastText)`,
|
|
3763
|
+
main: `var(--${prefix}-color-warning-main)`
|
|
3764
|
+
}
|
|
3760
3765
|
},
|
|
3761
3766
|
shadows: {
|
|
3762
|
-
|
|
3767
|
+
large: `var(--${prefix}-shadow-large)`,
|
|
3763
3768
|
medium: `var(--${prefix}-shadow-medium)`,
|
|
3764
|
-
|
|
3769
|
+
small: `var(--${prefix}-shadow-small)`
|
|
3770
|
+
},
|
|
3771
|
+
spacing: {
|
|
3772
|
+
unit: `var(--${prefix}-spacing-unit)`
|
|
3765
3773
|
},
|
|
3766
3774
|
typography: {
|
|
3767
3775
|
fontFamily: `var(--${prefix}-typography-fontFamily)`,
|
|
3768
3776
|
fontSizes: {
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
md: `var(--${prefix}-typography-fontSize-md)`,
|
|
3777
|
+
"2xl": `var(--${prefix}-typography-fontSize-2xl)`,
|
|
3778
|
+
"3xl": `var(--${prefix}-typography-fontSize-3xl)`,
|
|
3772
3779
|
lg: `var(--${prefix}-typography-fontSize-lg)`,
|
|
3780
|
+
md: `var(--${prefix}-typography-fontSize-md)`,
|
|
3781
|
+
sm: `var(--${prefix}-typography-fontSize-sm)`,
|
|
3773
3782
|
xl: `var(--${prefix}-typography-fontSize-xl)`,
|
|
3774
|
-
|
|
3775
|
-
"3xl": `var(--${prefix}-typography-fontSize-3xl)`
|
|
3783
|
+
xs: `var(--${prefix}-typography-fontSize-xs)`
|
|
3776
3784
|
},
|
|
3777
3785
|
fontWeights: {
|
|
3778
|
-
|
|
3786
|
+
bold: `var(--${prefix}-typography-fontWeight-bold)`,
|
|
3779
3787
|
medium: `var(--${prefix}-typography-fontWeight-medium)`,
|
|
3780
|
-
|
|
3781
|
-
|
|
3788
|
+
normal: `var(--${prefix}-typography-fontWeight-normal)`,
|
|
3789
|
+
semibold: `var(--${prefix}-typography-fontWeight-semibold)`
|
|
3782
3790
|
},
|
|
3783
3791
|
lineHeights: {
|
|
3784
|
-
tight: `var(--${prefix}-typography-lineHeight-tight)`,
|
|
3785
3792
|
normal: `var(--${prefix}-typography-lineHeight-normal)`,
|
|
3786
|
-
relaxed: `var(--${prefix}-typography-lineHeight-relaxed)
|
|
3793
|
+
relaxed: `var(--${prefix}-typography-lineHeight-relaxed)`,
|
|
3794
|
+
tight: `var(--${prefix}-typography-lineHeight-tight)`
|
|
3787
3795
|
}
|
|
3788
3796
|
}
|
|
3789
3797
|
};
|
|
@@ -3792,9 +3800,9 @@ var toThemeVars = (theme) => {
|
|
|
3792
3800
|
Object.keys(theme.images).forEach((imageKey) => {
|
|
3793
3801
|
const imageConfig = theme.images[imageKey];
|
|
3794
3802
|
themeVars.images[imageKey] = {
|
|
3795
|
-
|
|
3803
|
+
alt: imageConfig?.alt ? `var(--${prefix}-image-${imageKey}-alt)` : void 0,
|
|
3796
3804
|
title: imageConfig?.title ? `var(--${prefix}-image-${imageKey}-title)` : void 0,
|
|
3797
|
-
|
|
3805
|
+
url: imageConfig?.url ? `var(--${prefix}-image-${imageKey}-url)` : void 0
|
|
3798
3806
|
};
|
|
3799
3807
|
});
|
|
3800
3808
|
}
|
|
@@ -3808,6 +3816,10 @@ var createTheme = (config = {}, isDark = false) => {
|
|
|
3808
3816
|
const mergedConfig = {
|
|
3809
3817
|
...baseTheme,
|
|
3810
3818
|
...config,
|
|
3819
|
+
borderRadius: {
|
|
3820
|
+
...baseTheme.borderRadius,
|
|
3821
|
+
...config.borderRadius
|
|
3822
|
+
},
|
|
3811
3823
|
colors: {
|
|
3812
3824
|
...baseTheme.colors,
|
|
3813
3825
|
...config.colors,
|
|
@@ -3820,18 +3832,18 @@ var createTheme = (config = {}, isDark = false) => {
|
|
|
3820
3832
|
...config.colors?.secondary || {}
|
|
3821
3833
|
}
|
|
3822
3834
|
},
|
|
3823
|
-
|
|
3824
|
-
...baseTheme.
|
|
3825
|
-
...config.
|
|
3826
|
-
},
|
|
3827
|
-
borderRadius: {
|
|
3828
|
-
...baseTheme.borderRadius,
|
|
3829
|
-
...config.borderRadius
|
|
3835
|
+
images: {
|
|
3836
|
+
...baseTheme.images,
|
|
3837
|
+
...config.images
|
|
3830
3838
|
},
|
|
3831
3839
|
shadows: {
|
|
3832
3840
|
...baseTheme.shadows,
|
|
3833
3841
|
...config.shadows
|
|
3834
3842
|
},
|
|
3843
|
+
spacing: {
|
|
3844
|
+
...baseTheme.spacing,
|
|
3845
|
+
...config.spacing
|
|
3846
|
+
},
|
|
3835
3847
|
typography: {
|
|
3836
3848
|
...baseTheme.typography,
|
|
3837
3849
|
...config.typography,
|
|
@@ -3847,10 +3859,6 @@ var createTheme = (config = {}, isDark = false) => {
|
|
|
3847
3859
|
...baseTheme.typography.lineHeights,
|
|
3848
3860
|
...config.typography?.lineHeights || {}
|
|
3849
3861
|
}
|
|
3850
|
-
},
|
|
3851
|
-
images: {
|
|
3852
|
-
...baseTheme.images,
|
|
3853
|
-
...config.images
|
|
3854
3862
|
}
|
|
3855
3863
|
};
|
|
3856
3864
|
return {
|
|
@@ -3866,7 +3874,7 @@ var createTheme_default = createTheme;
|
|
|
3866
3874
|
var arrayBufferToBase64url = (buffer) => {
|
|
3867
3875
|
const bytes = new Uint8Array(buffer);
|
|
3868
3876
|
let binary = "";
|
|
3869
|
-
for (let i = 0; i < bytes.byteLength; i
|
|
3877
|
+
for (let i = 0; i < bytes.byteLength; i += 1) {
|
|
3870
3878
|
binary += String.fromCharCode(bytes[i]);
|
|
3871
3879
|
}
|
|
3872
3880
|
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
@@ -3879,7 +3887,7 @@ var base64urlToArrayBuffer = (base64url) => {
|
|
|
3879
3887
|
const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/") + padding;
|
|
3880
3888
|
const binaryString = atob(base64);
|
|
3881
3889
|
const bytes = new Uint8Array(binaryString.length);
|
|
3882
|
-
for (let i = 0; i < binaryString.length; i
|
|
3890
|
+
for (let i = 0; i < binaryString.length; i += 1) {
|
|
3883
3891
|
bytes[i] = binaryString.charCodeAt(i);
|
|
3884
3892
|
}
|
|
3885
3893
|
return bytes.buffer;
|
|
@@ -3904,9 +3912,9 @@ var formatDate = (dateString) => {
|
|
|
3904
3912
|
if (!dateString) return "-";
|
|
3905
3913
|
try {
|
|
3906
3914
|
return new Date(dateString).toLocaleDateString("en-US", {
|
|
3907
|
-
|
|
3915
|
+
day: "numeric",
|
|
3908
3916
|
month: "long",
|
|
3909
|
-
|
|
3917
|
+
year: "numeric"
|
|
3910
3918
|
});
|
|
3911
3919
|
} catch {
|
|
3912
3920
|
return dateString;
|
|
@@ -3915,9 +3923,7 @@ var formatDate = (dateString) => {
|
|
|
3915
3923
|
var formatDate_default = formatDate;
|
|
3916
3924
|
|
|
3917
3925
|
// src/utils/deepMerge.ts
|
|
3918
|
-
var isPlainObject = (value) =>
|
|
3919
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof RegExp) && Object.prototype.toString.call(value) === "[object Object]";
|
|
3920
|
-
};
|
|
3926
|
+
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof RegExp) && Object.prototype.toString.call(value) === "[object Object]";
|
|
3921
3927
|
var deepMerge = (target, ...sources) => {
|
|
3922
3928
|
if (!target || typeof target !== "object") {
|
|
3923
3929
|
throw new Error("Target must be an object");
|
|
@@ -3941,95 +3947,48 @@ var deepMerge = (target, ...sources) => {
|
|
|
3941
3947
|
};
|
|
3942
3948
|
var deepMerge_default = deepMerge;
|
|
3943
3949
|
|
|
3944
|
-
// src/utils/deriveOrganizationHandleFromBaseUrl.ts
|
|
3945
|
-
var deriveOrganizationHandleFromBaseUrl = (baseUrl) => {
|
|
3946
|
-
if (!baseUrl) {
|
|
3947
|
-
throw new AsgardeoRuntimeError(
|
|
3948
|
-
"Base URL is required to derive organization handle.",
|
|
3949
|
-
"javascript-deriveOrganizationHandleFromBaseUrl-ValidationError-001",
|
|
3950
|
-
"javascript",
|
|
3951
|
-
"A valid base URL must be provided to extract the organization handle."
|
|
3952
|
-
);
|
|
3953
|
-
}
|
|
3954
|
-
let parsedUrl;
|
|
3955
|
-
try {
|
|
3956
|
-
parsedUrl = new URL(baseUrl);
|
|
3957
|
-
} catch (error2) {
|
|
3958
|
-
throw new AsgardeoRuntimeError(
|
|
3959
|
-
`Invalid base URL format: ${baseUrl}`,
|
|
3960
|
-
"javascript-deriveOrganizationHandleFromBaseUrl-ValidationError-002",
|
|
3961
|
-
"javascript",
|
|
3962
|
-
"The provided base URL does not conform to valid URL syntax."
|
|
3963
|
-
);
|
|
3964
|
-
}
|
|
3965
|
-
const pathSegments = parsedUrl.pathname?.split("/")?.filter((segment) => segment?.length > 0);
|
|
3966
|
-
if (pathSegments.length < 2 || pathSegments[0] !== "t") {
|
|
3967
|
-
console.warn(
|
|
3968
|
-
new AsgardeoRuntimeError(
|
|
3969
|
-
"Organization handle is required since a custom domain is configured.",
|
|
3970
|
-
"javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-002",
|
|
3971
|
-
"javascript",
|
|
3972
|
-
"The provided base URL does not follow the expected URL pattern (/t/{orgHandle}). Please provide the organizationHandle explicitly in the configuration."
|
|
3973
|
-
).toString()
|
|
3974
|
-
);
|
|
3975
|
-
return "";
|
|
3976
|
-
}
|
|
3977
|
-
const organizationHandle = pathSegments[1];
|
|
3978
|
-
if (!organizationHandle || organizationHandle.trim().length === 0) {
|
|
3979
|
-
console.warn(
|
|
3980
|
-
new AsgardeoRuntimeError(
|
|
3981
|
-
"Organization handle is required since a custom domain is configured.",
|
|
3982
|
-
"javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-003",
|
|
3983
|
-
"javascript",
|
|
3984
|
-
"The organization handle could not be extracted from the base URL. Please provide the organizationHandle explicitly in the configuration."
|
|
3985
|
-
).toString()
|
|
3986
|
-
);
|
|
3987
|
-
return "";
|
|
3988
|
-
}
|
|
3989
|
-
return organizationHandle;
|
|
3990
|
-
};
|
|
3991
|
-
var deriveOrganizationHandleFromBaseUrl_default = deriveOrganizationHandleFromBaseUrl;
|
|
3992
|
-
|
|
3993
3950
|
// src/utils/logger.ts
|
|
3994
3951
|
var PREFIX = "\u{1F6E1}\uFE0F Asgardeo";
|
|
3995
3952
|
var DEFAULT_CONFIG = {
|
|
3996
3953
|
level: "info",
|
|
3997
3954
|
prefix: `${PREFIX}`,
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
};
|
|
4001
|
-
var isBrowser = () => {
|
|
4002
|
-
return typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
4003
|
-
};
|
|
4004
|
-
var isNode = () => {
|
|
4005
|
-
return typeof process !== "undefined" && process.versions && process.versions.node;
|
|
3955
|
+
showLevel: true,
|
|
3956
|
+
timestamps: true
|
|
4006
3957
|
};
|
|
3958
|
+
var isBrowser = () => (
|
|
3959
|
+
/* @ts-ignore */
|
|
3960
|
+
typeof window !== "undefined" && typeof window.document !== "undefined"
|
|
3961
|
+
);
|
|
3962
|
+
var isNode = () => (
|
|
3963
|
+
/* @ts-ignore */
|
|
3964
|
+
typeof process !== "undefined" && process.versions && process.versions.node
|
|
3965
|
+
);
|
|
4007
3966
|
var COLORS = {
|
|
4008
|
-
|
|
3967
|
+
blue: "\x1B[34m",
|
|
4009
3968
|
bright: "\x1B[1m",
|
|
3969
|
+
cyan: "\x1B[36m",
|
|
4010
3970
|
dim: "\x1B[2m",
|
|
4011
|
-
|
|
3971
|
+
gray: "\x1B[90m",
|
|
4012
3972
|
green: "\x1B[32m",
|
|
4013
|
-
yellow: "\x1B[33m",
|
|
4014
|
-
blue: "\x1B[34m",
|
|
4015
3973
|
magenta: "\x1B[35m",
|
|
4016
|
-
|
|
3974
|
+
red: "\x1B[31m",
|
|
3975
|
+
reset: "\x1B[0m",
|
|
4017
3976
|
white: "\x1B[37m",
|
|
4018
|
-
|
|
3977
|
+
yellow: "\x1B[33m"
|
|
4019
3978
|
};
|
|
4020
3979
|
var BROWSER_STYLES = {
|
|
4021
3980
|
debug: "color: #6b7280; font-weight: normal;",
|
|
4022
|
-
info: "color: #2563eb; font-weight: bold;",
|
|
4023
|
-
warn: "color: #d97706; font-weight: bold;",
|
|
4024
3981
|
error: "color: #dc2626; font-weight: bold;",
|
|
3982
|
+
info: "color: #2563eb; font-weight: bold;",
|
|
4025
3983
|
prefix: "color: #7c3aed; font-weight: bold;",
|
|
4026
|
-
timestamp: "color: #6b7280; font-size: 0.9em;"
|
|
3984
|
+
timestamp: "color: #6b7280; font-size: 0.9em;",
|
|
3985
|
+
warn: "color: #d97706; font-weight: bold;"
|
|
4027
3986
|
};
|
|
4028
3987
|
var LOG_LEVEL_ORDER = {
|
|
4029
3988
|
debug: 0,
|
|
3989
|
+
error: 3,
|
|
4030
3990
|
info: 1,
|
|
4031
|
-
warn: 2
|
|
4032
|
-
error: 3
|
|
3991
|
+
warn: 2
|
|
4033
3992
|
};
|
|
4034
3993
|
var Logger = class _Logger {
|
|
4035
3994
|
constructor(config = {}) {
|
|
@@ -4057,13 +4016,13 @@ var Logger = class _Logger {
|
|
|
4057
4016
|
/**
|
|
4058
4017
|
* Get timestamp string
|
|
4059
4018
|
*/
|
|
4060
|
-
getTimestamp() {
|
|
4019
|
+
static getTimestamp() {
|
|
4061
4020
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
4062
4021
|
}
|
|
4063
4022
|
/**
|
|
4064
4023
|
* Get log level string
|
|
4065
4024
|
*/
|
|
4066
|
-
getLevelString(level) {
|
|
4025
|
+
static getLevelString(level) {
|
|
4067
4026
|
switch (level) {
|
|
4068
4027
|
case "debug":
|
|
4069
4028
|
return "DEBUG";
|
|
@@ -4083,13 +4042,13 @@ var Logger = class _Logger {
|
|
|
4083
4042
|
formatForNode(level, message) {
|
|
4084
4043
|
const parts = [];
|
|
4085
4044
|
if (this.config.timestamps) {
|
|
4086
|
-
parts.push(`${COLORS.gray}[${
|
|
4045
|
+
parts.push(`${COLORS.gray}[${_Logger.getTimestamp()}]${COLORS.reset}`);
|
|
4087
4046
|
}
|
|
4088
4047
|
if (this.config.prefix) {
|
|
4089
4048
|
parts.push(`${COLORS.magenta}${this.config.prefix}${COLORS.reset}`);
|
|
4090
4049
|
}
|
|
4091
4050
|
if (this.config.showLevel) {
|
|
4092
|
-
const levelStr =
|
|
4051
|
+
const levelStr = _Logger.getLevelString(level);
|
|
4093
4052
|
let coloredLevel;
|
|
4094
4053
|
switch (level) {
|
|
4095
4054
|
case "debug":
|
|
@@ -4138,7 +4097,7 @@ var Logger = class _Logger {
|
|
|
4138
4097
|
const parts = [];
|
|
4139
4098
|
const styles = [];
|
|
4140
4099
|
if (this.config.timestamps) {
|
|
4141
|
-
parts.push(`%c[${
|
|
4100
|
+
parts.push(`%c[${_Logger.getTimestamp()}]`);
|
|
4142
4101
|
styles.push(BROWSER_STYLES.timestamp);
|
|
4143
4102
|
}
|
|
4144
4103
|
if (this.config.prefix) {
|
|
@@ -4146,7 +4105,7 @@ var Logger = class _Logger {
|
|
|
4146
4105
|
styles.push(BROWSER_STYLES.prefix);
|
|
4147
4106
|
}
|
|
4148
4107
|
if (this.config.showLevel) {
|
|
4149
|
-
const levelStr =
|
|
4108
|
+
const levelStr = _Logger.getLevelString(level);
|
|
4150
4109
|
parts.push(`%c[${levelStr}]`);
|
|
4151
4110
|
switch (level) {
|
|
4152
4111
|
case "debug":
|
|
@@ -4255,31 +4214,74 @@ var Logger = class _Logger {
|
|
|
4255
4214
|
}
|
|
4256
4215
|
};
|
|
4257
4216
|
var logger = new Logger();
|
|
4258
|
-
var createLogger = (config) =>
|
|
4259
|
-
return new Logger(config);
|
|
4260
|
-
};
|
|
4217
|
+
var createLogger = (config) => new Logger(config);
|
|
4261
4218
|
var logger_default = logger;
|
|
4262
4219
|
var debug = (message, ...args) => logger.debug(message, ...args);
|
|
4263
4220
|
var info = (message, ...args) => logger.info(message, ...args);
|
|
4264
4221
|
var warn = (message, ...args) => logger.warn(message, ...args);
|
|
4265
4222
|
var error = (message, ...args) => logger.error(message, ...args);
|
|
4266
4223
|
var configure = (config) => logger.configure(config);
|
|
4267
|
-
var createComponentLogger = (component) =>
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
timestamps: true,
|
|
4275
|
-
showLevel: true
|
|
4276
|
-
});
|
|
4277
|
-
};
|
|
4224
|
+
var createComponentLogger = (component) => logger.child(component);
|
|
4225
|
+
var createPackageLogger = (packageName) => createLogger({
|
|
4226
|
+
level: "info",
|
|
4227
|
+
prefix: `${PREFIX} - ${packageName}`,
|
|
4228
|
+
showLevel: true,
|
|
4229
|
+
timestamps: true
|
|
4230
|
+
});
|
|
4278
4231
|
var createPackageComponentLogger = (packageName, component) => {
|
|
4279
4232
|
const packageLogger = createPackageLogger(packageName);
|
|
4280
4233
|
return packageLogger.child(component);
|
|
4281
4234
|
};
|
|
4282
4235
|
|
|
4236
|
+
// src/utils/deriveOrganizationHandleFromBaseUrl.ts
|
|
4237
|
+
var deriveOrganizationHandleFromBaseUrl = (baseUrl) => {
|
|
4238
|
+
if (!baseUrl) {
|
|
4239
|
+
throw new AsgardeoRuntimeError(
|
|
4240
|
+
"Base URL is required to derive organization handle.",
|
|
4241
|
+
"javascript-deriveOrganizationHandleFromBaseUrl-ValidationError-001",
|
|
4242
|
+
"javascript",
|
|
4243
|
+
"A valid base URL must be provided to extract the organization handle."
|
|
4244
|
+
);
|
|
4245
|
+
}
|
|
4246
|
+
let parsedUrl;
|
|
4247
|
+
try {
|
|
4248
|
+
parsedUrl = new URL(baseUrl);
|
|
4249
|
+
} catch (error2) {
|
|
4250
|
+
throw new AsgardeoRuntimeError(
|
|
4251
|
+
`Invalid base URL format: ${baseUrl}`,
|
|
4252
|
+
"javascript-deriveOrganizationHandleFromBaseUrl-ValidationError-002",
|
|
4253
|
+
"javascript",
|
|
4254
|
+
"The provided base URL does not conform to valid URL syntax."
|
|
4255
|
+
);
|
|
4256
|
+
}
|
|
4257
|
+
const pathSegments = parsedUrl.pathname?.split("/")?.filter((segment) => segment?.length > 0);
|
|
4258
|
+
if (pathSegments.length < 2 || pathSegments[0] !== "t") {
|
|
4259
|
+
logger_default.warn(
|
|
4260
|
+
new AsgardeoRuntimeError(
|
|
4261
|
+
"Organization handle is required since a custom domain is configured.",
|
|
4262
|
+
"javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-002",
|
|
4263
|
+
"javascript",
|
|
4264
|
+
"The provided base URL does not follow the expected URL pattern (/t/{orgHandle}). Please provide the organizationHandle explicitly in the configuration."
|
|
4265
|
+
).toString()
|
|
4266
|
+
);
|
|
4267
|
+
return "";
|
|
4268
|
+
}
|
|
4269
|
+
const organizationHandle = pathSegments[1];
|
|
4270
|
+
if (!organizationHandle || organizationHandle.trim().length === 0) {
|
|
4271
|
+
logger_default.warn(
|
|
4272
|
+
new AsgardeoRuntimeError(
|
|
4273
|
+
"Organization handle is required since a custom domain is configured.",
|
|
4274
|
+
"javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-003",
|
|
4275
|
+
"javascript",
|
|
4276
|
+
"The organization handle could not be extracted from the base URL. Please provide the organizationHandle explicitly in the configuration."
|
|
4277
|
+
).toString()
|
|
4278
|
+
);
|
|
4279
|
+
return "";
|
|
4280
|
+
}
|
|
4281
|
+
return organizationHandle;
|
|
4282
|
+
};
|
|
4283
|
+
var deriveOrganizationHandleFromBaseUrl_default = deriveOrganizationHandleFromBaseUrl;
|
|
4284
|
+
|
|
4283
4285
|
// src/utils/isRecognizedBaseUrlPattern.ts
|
|
4284
4286
|
var isRecognizedBaseUrlPattern = (baseUrl) => {
|
|
4285
4287
|
if (!baseUrl) {
|
|
@@ -4303,7 +4305,9 @@ var isRecognizedBaseUrlPattern = (baseUrl) => {
|
|
|
4303
4305
|
}
|
|
4304
4306
|
const pathSegments = parsedUrl.pathname?.split("/")?.filter((segment) => segment?.length > 0);
|
|
4305
4307
|
if (pathSegments.length < 2 || pathSegments[0] !== "t") {
|
|
4306
|
-
logger_default.warn(
|
|
4308
|
+
logger_default.warn(
|
|
4309
|
+
"[isRecognizedBaseUrlPattern] The provided base URL does not follow the expected URL pattern (/t/{orgHandle})."
|
|
4310
|
+
);
|
|
4307
4311
|
return false;
|
|
4308
4312
|
}
|
|
4309
4313
|
return true;
|
|
@@ -4341,9 +4345,7 @@ var flattenUserSchema_default = flattenUserSchema;
|
|
|
4341
4345
|
var get = (object, path, defaultValue) => {
|
|
4342
4346
|
if (!object || !path) return defaultValue;
|
|
4343
4347
|
const pathArray = Array.isArray(path) ? path : path.split(".");
|
|
4344
|
-
const result = pathArray.reduce((current, key) =>
|
|
4345
|
-
return current?.[key];
|
|
4346
|
-
}, object);
|
|
4348
|
+
const result = pathArray.reduce((current, key) => current?.[key], object);
|
|
4347
4349
|
return result !== void 0 ? result : defaultValue;
|
|
4348
4350
|
};
|
|
4349
4351
|
var get_default = get;
|
|
@@ -4356,11 +4358,9 @@ var set = (object, path, value) => {
|
|
|
4356
4358
|
pathArray.reduce((current, key, index) => {
|
|
4357
4359
|
if (index === lastIndex) {
|
|
4358
4360
|
current[key] = value;
|
|
4359
|
-
} else {
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
current[key] = /^\d+$/.test(nextKey) ? [] : {};
|
|
4363
|
-
}
|
|
4361
|
+
} else if (!(key in current) || typeof current[key] !== "object" || current[key] === null) {
|
|
4362
|
+
const nextKey = pathArray[index + 1];
|
|
4363
|
+
current[key] = /^\d+$/.test(nextKey) ? [] : {};
|
|
4364
4364
|
}
|
|
4365
4365
|
return current[key];
|
|
4366
4366
|
}, object);
|
|
@@ -4379,14 +4379,12 @@ var generateUserProfile = (meResponse, processedSchemas) => {
|
|
|
4379
4379
|
if (multiValued && !Array.isArray(value)) {
|
|
4380
4380
|
value = [value];
|
|
4381
4381
|
}
|
|
4382
|
+
} else if (multiValued) {
|
|
4383
|
+
value = void 0;
|
|
4384
|
+
} else if (type === "STRING") {
|
|
4385
|
+
value = "";
|
|
4382
4386
|
} else {
|
|
4383
|
-
|
|
4384
|
-
value = void 0;
|
|
4385
|
-
} else if (type === "STRING") {
|
|
4386
|
-
value = "";
|
|
4387
|
-
} else {
|
|
4388
|
-
value = void 0;
|
|
4389
|
-
}
|
|
4387
|
+
value = void 0;
|
|
4390
4388
|
}
|
|
4391
4389
|
set_default(profile, name, value);
|
|
4392
4390
|
});
|
|
@@ -4530,7 +4528,7 @@ var getRedirectBasedSignUpUrl = (config) => {
|
|
|
4530
4528
|
);
|
|
4531
4529
|
}
|
|
4532
4530
|
}
|
|
4533
|
-
const url = new URL(signUpBaseUrl
|
|
4531
|
+
const url = new URL(`${signUpBaseUrl}/accountrecoveryendpoint/register.do`);
|
|
4534
4532
|
if (config.clientId) {
|
|
4535
4533
|
url.searchParams.set("client_id", config.clientId);
|
|
4536
4534
|
}
|
|
@@ -4551,13 +4549,14 @@ var resolveFieldType = (field) => {
|
|
|
4551
4549
|
if (field.type === "STRING" /* String */) {
|
|
4552
4550
|
if (field.param === "OTPCode" /* Otp */) {
|
|
4553
4551
|
return "OTP" /* Otp */;
|
|
4554
|
-
}
|
|
4552
|
+
}
|
|
4553
|
+
if (field?.confidential) {
|
|
4555
4554
|
return "PASSWORD" /* Password */;
|
|
4556
4555
|
}
|
|
4557
4556
|
return "TEXT" /* Text */;
|
|
4558
4557
|
}
|
|
4559
4558
|
throw new AsgardeoRuntimeError(
|
|
4560
|
-
|
|
4559
|
+
`Field type is not supported: ${field.type}`,
|
|
4561
4560
|
"resolveFieldType-Invalid-001",
|
|
4562
4561
|
"javascript",
|
|
4563
4562
|
"The provided field type is not supported. Please check the field configuration."
|
|
@@ -4590,85 +4589,83 @@ var extractColorValue = (colorVariant, preferDark = false) => {
|
|
|
4590
4589
|
}
|
|
4591
4590
|
return colorVariant?.main;
|
|
4592
4591
|
};
|
|
4593
|
-
var extractContrastText = (colorVariant) =>
|
|
4594
|
-
return colorVariant?.contrastText;
|
|
4595
|
-
};
|
|
4592
|
+
var extractContrastText = (colorVariant) => colorVariant?.contrastText;
|
|
4596
4593
|
var transformThemeVariant = (themeVariant, isDark = false) => {
|
|
4597
|
-
const
|
|
4598
|
-
const
|
|
4599
|
-
const
|
|
4600
|
-
const
|
|
4594
|
+
const { buttons } = themeVariant;
|
|
4595
|
+
const { colors } = themeVariant;
|
|
4596
|
+
const { images } = themeVariant;
|
|
4597
|
+
const { inputs } = themeVariant;
|
|
4601
4598
|
const config = {
|
|
4602
4599
|
colors: {
|
|
4603
4600
|
action: {
|
|
4601
|
+
activatedOpacity: 0.12,
|
|
4604
4602
|
active: isDark ? "rgba(255, 255, 255, 0.70)" : "rgba(0, 0, 0, 0.54)",
|
|
4605
|
-
hover: isDark ? "rgba(255, 255, 255, 0.04)" : "rgba(0, 0, 0, 0.04)",
|
|
4606
|
-
hoverOpacity: 0.04,
|
|
4607
|
-
selected: isDark ? "rgba(255, 255, 255, 0.08)" : "rgba(0, 0, 0, 0.08)",
|
|
4608
|
-
selectedOpacity: 0.08,
|
|
4609
4603
|
disabled: isDark ? "rgba(255, 255, 255, 0.26)" : "rgba(0, 0, 0, 0.26)",
|
|
4610
4604
|
disabledBackground: isDark ? "rgba(255, 255, 255, 0.12)" : "rgba(0, 0, 0, 0.12)",
|
|
4611
4605
|
disabledOpacity: 0.38,
|
|
4612
4606
|
focus: isDark ? "rgba(255, 255, 255, 0.12)" : "rgba(0, 0, 0, 0.12)",
|
|
4613
4607
|
focusOpacity: 0.12,
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
contrastText: extractContrastText(colors?.primary),
|
|
4619
|
-
dark: colors?.primary?.dark || colors?.primary?.main
|
|
4620
|
-
},
|
|
4621
|
-
secondary: {
|
|
4622
|
-
main: extractColorValue(colors?.secondary, isDark),
|
|
4623
|
-
contrastText: extractContrastText(colors?.secondary),
|
|
4624
|
-
dark: colors?.secondary?.dark || colors?.secondary?.main
|
|
4608
|
+
hover: isDark ? "rgba(255, 255, 255, 0.04)" : "rgba(0, 0, 0, 0.04)",
|
|
4609
|
+
hoverOpacity: 0.04,
|
|
4610
|
+
selected: isDark ? "rgba(255, 255, 255, 0.08)" : "rgba(0, 0, 0, 0.08)",
|
|
4611
|
+
selectedOpacity: 0.08
|
|
4625
4612
|
},
|
|
4626
4613
|
background: {
|
|
4627
|
-
surface: extractColorValue(colors?.background?.surface, isDark),
|
|
4628
|
-
disabled: extractColorValue(colors?.background?.surface, isDark),
|
|
4629
|
-
dark: colors?.background?.surface?.dark || colors?.background?.surface?.main,
|
|
4630
4614
|
body: {
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
}
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
secondary: colors?.text?.secondary,
|
|
4638
|
-
dark: colors?.text?.dark || colors?.text?.primary
|
|
4615
|
+
dark: colors?.background?.body?.dark || colors?.background?.body?.main,
|
|
4616
|
+
main: extractColorValue(colors?.background?.body, isDark)
|
|
4617
|
+
},
|
|
4618
|
+
dark: colors?.background?.surface?.dark || colors?.background?.surface?.main,
|
|
4619
|
+
disabled: extractColorValue(colors?.background?.surface, isDark),
|
|
4620
|
+
surface: extractColorValue(colors?.background?.surface, isDark)
|
|
4639
4621
|
},
|
|
4640
4622
|
border: colors?.outlined?.default,
|
|
4641
4623
|
error: {
|
|
4642
|
-
main: extractColorValue(colors?.alerts?.error, isDark),
|
|
4643
4624
|
contrastText: extractContrastText(colors?.alerts?.error),
|
|
4644
|
-
dark: colors?.alerts?.error?.dark || colors?.alerts?.error?.main
|
|
4625
|
+
dark: colors?.alerts?.error?.dark || colors?.alerts?.error?.main,
|
|
4626
|
+
main: extractColorValue(colors?.alerts?.error, isDark)
|
|
4645
4627
|
},
|
|
4646
4628
|
info: {
|
|
4647
|
-
main: extractColorValue(colors?.alerts?.info, isDark),
|
|
4648
4629
|
contrastText: extractContrastText(colors?.alerts?.info),
|
|
4649
|
-
dark: colors?.alerts?.info?.dark || colors?.alerts?.info?.main
|
|
4630
|
+
dark: colors?.alerts?.info?.dark || colors?.alerts?.info?.main,
|
|
4631
|
+
main: extractColorValue(colors?.alerts?.info, isDark)
|
|
4632
|
+
},
|
|
4633
|
+
primary: {
|
|
4634
|
+
contrastText: extractContrastText(colors?.primary),
|
|
4635
|
+
dark: colors?.primary?.dark || colors?.primary?.main,
|
|
4636
|
+
main: extractColorValue(colors?.primary, isDark)
|
|
4637
|
+
},
|
|
4638
|
+
secondary: {
|
|
4639
|
+
contrastText: extractContrastText(colors?.secondary),
|
|
4640
|
+
dark: colors?.secondary?.dark || colors?.secondary?.main,
|
|
4641
|
+
main: extractColorValue(colors?.secondary, isDark)
|
|
4650
4642
|
},
|
|
4651
4643
|
success: {
|
|
4652
|
-
main: extractColorValue(colors?.alerts?.neutral, isDark),
|
|
4653
4644
|
contrastText: extractContrastText(colors?.alerts?.neutral),
|
|
4654
|
-
dark: colors?.alerts?.neutral?.dark || colors?.alerts?.neutral?.main
|
|
4645
|
+
dark: colors?.alerts?.neutral?.dark || colors?.alerts?.neutral?.main,
|
|
4646
|
+
main: extractColorValue(colors?.alerts?.neutral, isDark)
|
|
4647
|
+
},
|
|
4648
|
+
text: {
|
|
4649
|
+
dark: colors?.text?.dark || colors?.text?.primary,
|
|
4650
|
+
primary: colors?.text?.primary,
|
|
4651
|
+
secondary: colors?.text?.secondary
|
|
4655
4652
|
},
|
|
4656
4653
|
warning: {
|
|
4657
|
-
main: extractColorValue(colors?.alerts?.warning, isDark),
|
|
4658
4654
|
contrastText: extractContrastText(colors?.alerts?.warning),
|
|
4659
|
-
dark: colors?.alerts?.warning?.dark || colors?.alerts?.warning?.main
|
|
4655
|
+
dark: colors?.alerts?.warning?.dark || colors?.alerts?.warning?.main,
|
|
4656
|
+
main: extractColorValue(colors?.alerts?.warning, isDark)
|
|
4660
4657
|
}
|
|
4661
4658
|
},
|
|
4662
4659
|
images: {
|
|
4663
4660
|
favicon: images?.favicon ? {
|
|
4664
|
-
|
|
4661
|
+
alt: images.favicon.altText,
|
|
4665
4662
|
title: images.favicon.title,
|
|
4666
|
-
|
|
4663
|
+
url: images.favicon.imgURL
|
|
4667
4664
|
} : void 0,
|
|
4668
4665
|
logo: images?.logo ? {
|
|
4669
|
-
|
|
4666
|
+
alt: images.logo.altText,
|
|
4670
4667
|
title: images.logo.title,
|
|
4671
|
-
|
|
4668
|
+
url: images.logo.imgURL
|
|
4672
4669
|
} : void 0
|
|
4673
4670
|
}
|
|
4674
4671
|
};
|