@asgardeo/javascript 0.7.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AsgardeoJavaScriptClient.d.ts +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 +1176 -1184
- 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 +1177 -1185
- 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 +3 -3
- package/dist/utils/logger.d.ts +6 -6
- package/dist/utils/processUsername.d.ts +1 -1
- package/package.json +2 -2
- package/dist/utils/cryptoUtils.d.ts +0 -0
package/dist/cjs/index.js
CHANGED
|
@@ -112,144 +112,6 @@ __export(index_exports, {
|
|
|
112
112
|
});
|
|
113
113
|
module.exports = __toCommonJS(index_exports);
|
|
114
114
|
|
|
115
|
-
// src/StorageManager.ts
|
|
116
|
-
var ASGARDEO_SESSION_ACTIVE = "asgardeo-session-active";
|
|
117
|
-
var StorageManager = class {
|
|
118
|
-
constructor(instanceID, store) {
|
|
119
|
-
__publicField(this, "_id");
|
|
120
|
-
__publicField(this, "_store");
|
|
121
|
-
this._id = instanceID;
|
|
122
|
-
this._store = store;
|
|
123
|
-
}
|
|
124
|
-
async setDataInBulk(key, data) {
|
|
125
|
-
const existingDataJSON = await this._store.getData(key) ?? null;
|
|
126
|
-
const existingData = existingDataJSON && JSON.parse(existingDataJSON);
|
|
127
|
-
const dataToBeSaved = { ...existingData, ...data };
|
|
128
|
-
const dataToBeSavedJSON = JSON.stringify(dataToBeSaved);
|
|
129
|
-
await this._store.setData(key, dataToBeSavedJSON);
|
|
130
|
-
}
|
|
131
|
-
async setValue(key, attribute, value) {
|
|
132
|
-
const existingDataJSON = await this._store.getData(key) ?? null;
|
|
133
|
-
const existingData = existingDataJSON && JSON.parse(existingDataJSON);
|
|
134
|
-
const dataToBeSaved = { ...existingData, [attribute]: value };
|
|
135
|
-
const dataToBeSavedJSON = JSON.stringify(dataToBeSaved);
|
|
136
|
-
await this._store.setData(key, dataToBeSavedJSON);
|
|
137
|
-
}
|
|
138
|
-
async removeValue(key, attribute) {
|
|
139
|
-
const existingDataJSON = await this._store.getData(key) ?? null;
|
|
140
|
-
const existingData = existingDataJSON && JSON.parse(existingDataJSON);
|
|
141
|
-
const dataToBeSaved = { ...existingData };
|
|
142
|
-
delete dataToBeSaved[attribute];
|
|
143
|
-
const dataToBeSavedJSON = JSON.stringify(dataToBeSaved);
|
|
144
|
-
await this._store.setData(key, dataToBeSavedJSON);
|
|
145
|
-
}
|
|
146
|
-
_resolveKey(store, userId) {
|
|
147
|
-
return userId ? `${store}-${this._id}-${userId}` : `${store}-${this._id}`;
|
|
148
|
-
}
|
|
149
|
-
isLocalStorageAvailable() {
|
|
150
|
-
try {
|
|
151
|
-
const testValue = "__ASGARDEO_AUTH_CORE_LOCAL_STORAGE_TEST__";
|
|
152
|
-
localStorage.setItem(testValue, testValue);
|
|
153
|
-
localStorage.removeItem(testValue);
|
|
154
|
-
return true;
|
|
155
|
-
} catch (error2) {
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
async setConfigData(config) {
|
|
160
|
-
await this.setDataInBulk(this._resolveKey("config_data" /* ConfigData */), config);
|
|
161
|
-
}
|
|
162
|
-
async setOIDCProviderMetaData(oidcProviderMetaData) {
|
|
163
|
-
this.setDataInBulk(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), oidcProviderMetaData);
|
|
164
|
-
}
|
|
165
|
-
async setTemporaryData(temporaryData, userId) {
|
|
166
|
-
this.setDataInBulk(this._resolveKey("temporary_data" /* TemporaryData */, userId), temporaryData);
|
|
167
|
-
}
|
|
168
|
-
async setSessionData(sessionData, userId) {
|
|
169
|
-
this.setDataInBulk(this._resolveKey("session_data" /* SessionData */, userId), sessionData);
|
|
170
|
-
}
|
|
171
|
-
async setCustomData(key, customData, userId) {
|
|
172
|
-
this.setDataInBulk(this._resolveKey(key, userId), customData);
|
|
173
|
-
}
|
|
174
|
-
async getConfigData(userId) {
|
|
175
|
-
return JSON.parse(await this._store.getData(this._resolveKey("config_data" /* ConfigData */, userId)) ?? null);
|
|
176
|
-
}
|
|
177
|
-
async loadOpenIDProviderConfiguration() {
|
|
178
|
-
return JSON.parse(await this._store.getData(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */)) ?? null);
|
|
179
|
-
}
|
|
180
|
-
async getTemporaryData(userId) {
|
|
181
|
-
return JSON.parse(await this._store.getData(this._resolveKey("temporary_data" /* TemporaryData */, userId)) ?? null);
|
|
182
|
-
}
|
|
183
|
-
async getSessionData(userId) {
|
|
184
|
-
return JSON.parse(await this._store.getData(this._resolveKey("session_data" /* SessionData */, userId)) ?? null);
|
|
185
|
-
}
|
|
186
|
-
async getCustomData(key, userId) {
|
|
187
|
-
return JSON.parse(await this._store.getData(this._resolveKey(key, userId)) ?? null);
|
|
188
|
-
}
|
|
189
|
-
setSessionStatus(status) {
|
|
190
|
-
this.isLocalStorageAvailable() && localStorage.setItem(`${ASGARDEO_SESSION_ACTIVE}`, status);
|
|
191
|
-
}
|
|
192
|
-
getSessionStatus() {
|
|
193
|
-
return this.isLocalStorageAvailable() ? localStorage.getItem(`${ASGARDEO_SESSION_ACTIVE}`) ?? "" : "";
|
|
194
|
-
}
|
|
195
|
-
removeSessionStatus() {
|
|
196
|
-
this.isLocalStorageAvailable() && localStorage.removeItem(`${ASGARDEO_SESSION_ACTIVE}`);
|
|
197
|
-
}
|
|
198
|
-
async removeConfigData() {
|
|
199
|
-
await this._store.removeData(this._resolveKey("config_data" /* ConfigData */));
|
|
200
|
-
}
|
|
201
|
-
async removeOIDCProviderMetaData() {
|
|
202
|
-
await this._store.removeData(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */));
|
|
203
|
-
}
|
|
204
|
-
async removeTemporaryData(userId) {
|
|
205
|
-
await this._store.removeData(this._resolveKey("temporary_data" /* TemporaryData */, userId));
|
|
206
|
-
}
|
|
207
|
-
async removeSessionData(userId) {
|
|
208
|
-
await this._store.removeData(this._resolveKey("session_data" /* SessionData */, userId));
|
|
209
|
-
}
|
|
210
|
-
async getConfigDataParameter(key) {
|
|
211
|
-
const data = await this._store.getData(this._resolveKey("config_data" /* ConfigData */));
|
|
212
|
-
return data && JSON.parse(data)[key];
|
|
213
|
-
}
|
|
214
|
-
async getOIDCProviderMetaDataParameter(key) {
|
|
215
|
-
const data = await this._store.getData(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */));
|
|
216
|
-
return data && JSON.parse(data)[key];
|
|
217
|
-
}
|
|
218
|
-
async getTemporaryDataParameter(key, userId) {
|
|
219
|
-
const data = await this._store.getData(this._resolveKey("temporary_data" /* TemporaryData */, userId));
|
|
220
|
-
return data && JSON.parse(data)[key];
|
|
221
|
-
}
|
|
222
|
-
async getSessionDataParameter(key, userId) {
|
|
223
|
-
const data = await this._store.getData(this._resolveKey("session_data" /* SessionData */, userId));
|
|
224
|
-
return data && JSON.parse(data)[key];
|
|
225
|
-
}
|
|
226
|
-
async setConfigDataParameter(key, value) {
|
|
227
|
-
await this.setValue(this._resolveKey("config_data" /* ConfigData */), key, value);
|
|
228
|
-
}
|
|
229
|
-
async setOIDCProviderMetaDataParameter(key, value) {
|
|
230
|
-
await this.setValue(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), key, value);
|
|
231
|
-
}
|
|
232
|
-
async setTemporaryDataParameter(key, value, userId) {
|
|
233
|
-
await this.setValue(this._resolveKey("temporary_data" /* TemporaryData */, userId), key, value);
|
|
234
|
-
}
|
|
235
|
-
async setSessionDataParameter(key, value, userId) {
|
|
236
|
-
await this.setValue(this._resolveKey("session_data" /* SessionData */, userId), key, value);
|
|
237
|
-
}
|
|
238
|
-
async removeConfigDataParameter(key) {
|
|
239
|
-
await this.removeValue(this._resolveKey("config_data" /* ConfigData */), key);
|
|
240
|
-
}
|
|
241
|
-
async removeOIDCProviderMetaDataParameter(key) {
|
|
242
|
-
await this.removeValue(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), key);
|
|
243
|
-
}
|
|
244
|
-
async removeTemporaryDataParameter(key, userId) {
|
|
245
|
-
await this.removeValue(this._resolveKey("temporary_data" /* TemporaryData */, userId), key);
|
|
246
|
-
}
|
|
247
|
-
async removeSessionDataParameter(key, userId) {
|
|
248
|
-
await this.removeValue(this._resolveKey("session_data" /* SessionData */, userId), key);
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
|
-
var StorageManager_default = StorageManager;
|
|
252
|
-
|
|
253
115
|
// src/constants/OIDCDiscoveryConstants.ts
|
|
254
116
|
var OIDCDiscoveryConstants = {
|
|
255
117
|
/**
|
|
@@ -263,11 +125,6 @@ var OIDCDiscoveryConstants = {
|
|
|
263
125
|
* This endpoint is used to request authorization and receive an authorization code.
|
|
264
126
|
*/
|
|
265
127
|
AUTHORIZATION: "/oauth2/authorize",
|
|
266
|
-
/**
|
|
267
|
-
* Session check iframe endpoint for session management.
|
|
268
|
-
* Used to monitor the user's session state through a hidden iframe.
|
|
269
|
-
*/
|
|
270
|
-
SESSION_IFRAME: "/oidc/checksession",
|
|
271
128
|
/**
|
|
272
129
|
* End session endpoint for logout functionality.
|
|
273
130
|
* Used to terminate the user's session and perform logout operations.
|
|
@@ -288,6 +145,11 @@ var OIDCDiscoveryConstants = {
|
|
|
288
145
|
* Used to invalidate access or refresh tokens before they expire.
|
|
289
146
|
*/
|
|
290
147
|
REVOCATION: "/oauth2/revoke",
|
|
148
|
+
/**
|
|
149
|
+
* Session check iframe endpoint for session management.
|
|
150
|
+
* Used to monitor the user's session state through a hidden iframe.
|
|
151
|
+
*/
|
|
152
|
+
SESSION_IFRAME: "/oidc/checksession",
|
|
291
153
|
/**
|
|
292
154
|
* Token endpoint for obtaining access tokens.
|
|
293
155
|
* Used to exchange authorization codes for access tokens and refresh tokens.
|
|
@@ -322,36 +184,36 @@ var OIDCDiscoveryConstants = {
|
|
|
322
184
|
* Used to store the URL where authorization requests should be sent.
|
|
323
185
|
*/
|
|
324
186
|
AUTHORIZATION: "authorization_endpoint",
|
|
325
|
-
/**
|
|
326
|
-
* Storage key for the token endpoint URL.
|
|
327
|
-
* Used to store the URL where token requests should be sent.
|
|
328
|
-
*/
|
|
329
|
-
TOKEN: "token_endpoint",
|
|
330
|
-
/**
|
|
331
|
-
* Storage key for the revocation endpoint URL.
|
|
332
|
-
* Used to store the URL where token revocation requests should be sent.
|
|
333
|
-
*/
|
|
334
|
-
REVOCATION: "revocation_endpoint",
|
|
335
187
|
/**
|
|
336
188
|
* Storage key for the end session endpoint URL.
|
|
337
189
|
* Used to store the URL where logout requests should be sent.
|
|
338
190
|
*/
|
|
339
191
|
END_SESSION: "end_session_endpoint",
|
|
192
|
+
/**
|
|
193
|
+
* Storage key for the issuer identifier URL.
|
|
194
|
+
* Used to store the URL that identifies the OpenID Provider.
|
|
195
|
+
*/
|
|
196
|
+
ISSUER: "issuer",
|
|
340
197
|
/**
|
|
341
198
|
* Storage key for the JWKS URI endpoint URL.
|
|
342
199
|
* Used to store the URL where JSON Web Key Sets can be retrieved.
|
|
343
200
|
*/
|
|
344
201
|
JWKS: "jwks_uri",
|
|
202
|
+
/**
|
|
203
|
+
* Storage key for the revocation endpoint URL.
|
|
204
|
+
* Used to store the URL where token revocation requests should be sent.
|
|
205
|
+
*/
|
|
206
|
+
REVOCATION: "revocation_endpoint",
|
|
345
207
|
/**
|
|
346
208
|
* Storage key for the session check iframe URL.
|
|
347
209
|
* Used to store the URL of the iframe used for session state monitoring.
|
|
348
210
|
*/
|
|
349
211
|
SESSION_IFRAME: "check_session_iframe",
|
|
350
212
|
/**
|
|
351
|
-
* Storage key for the
|
|
352
|
-
* Used to store the URL
|
|
213
|
+
* Storage key for the token endpoint URL.
|
|
214
|
+
* Used to store the URL where token requests should be sent.
|
|
353
215
|
*/
|
|
354
|
-
|
|
216
|
+
TOKEN: "token_endpoint",
|
|
355
217
|
/**
|
|
356
218
|
* Storage key for the userinfo endpoint URL.
|
|
357
219
|
* Used to store the URL where user information can be retrieved.
|
|
@@ -369,6 +231,93 @@ var OIDCDiscoveryConstants = {
|
|
|
369
231
|
};
|
|
370
232
|
var OIDCDiscoveryConstants_default = OIDCDiscoveryConstants;
|
|
371
233
|
|
|
234
|
+
// src/constants/TokenExchangeConstants.ts
|
|
235
|
+
var TokenExchangeConstants = {
|
|
236
|
+
/**
|
|
237
|
+
* Collection of placeholder strings used in token exchange operations.
|
|
238
|
+
* These placeholders are replaced with actual values when processing
|
|
239
|
+
* token exchange requests.
|
|
240
|
+
*/
|
|
241
|
+
Placeholders: {
|
|
242
|
+
/**
|
|
243
|
+
* Placeholder for the token value in exchange requests.
|
|
244
|
+
* Usually replaced with an access token or refresh token.
|
|
245
|
+
*/
|
|
246
|
+
ACCESS_TOKEN: "{{accessToken}}",
|
|
247
|
+
/**
|
|
248
|
+
* Placeholder for client ID in token exchange operations.
|
|
249
|
+
* Required for client authentication.
|
|
250
|
+
*/
|
|
251
|
+
CLIENT_ID: "{{clientId}}",
|
|
252
|
+
/**
|
|
253
|
+
* Placeholder for client secret in token exchange operations.
|
|
254
|
+
* Used for client authentication in confidential client flows.
|
|
255
|
+
*/
|
|
256
|
+
CLIENT_SECRET: "{{clientSecret}}",
|
|
257
|
+
/**
|
|
258
|
+
* Placeholder for OAuth scopes in token exchange requests.
|
|
259
|
+
* Replaced with space-separated scope strings.
|
|
260
|
+
*/
|
|
261
|
+
SCOPES: "{{scopes}}",
|
|
262
|
+
/**
|
|
263
|
+
* Placeholder for the username in token exchange operations.
|
|
264
|
+
* Used when user identity needs to be included in the exchange.
|
|
265
|
+
*/
|
|
266
|
+
USERNAME: "{{username}}"
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
var TokenExchangeConstants_default = TokenExchangeConstants;
|
|
270
|
+
|
|
271
|
+
// src/errors/exception.ts
|
|
272
|
+
var AsgardeoAuthException = class {
|
|
273
|
+
constructor(code, name, message) {
|
|
274
|
+
__publicField(this, "name");
|
|
275
|
+
__publicField(this, "code");
|
|
276
|
+
__publicField(this, "message");
|
|
277
|
+
this.message = message;
|
|
278
|
+
this.name = name;
|
|
279
|
+
this.code = code;
|
|
280
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
// src/models/platforms.ts
|
|
285
|
+
var Platform = /* @__PURE__ */ ((Platform2) => {
|
|
286
|
+
Platform2["Asgardeo"] = "ASGARDEO";
|
|
287
|
+
Platform2["AsgardeoV2"] = "AsgardeoV2";
|
|
288
|
+
Platform2["IdentityServer"] = "IDENTITY_SERVER";
|
|
289
|
+
Platform2["Unknown"] = "UNKNOWN";
|
|
290
|
+
return Platform2;
|
|
291
|
+
})(Platform || {});
|
|
292
|
+
|
|
293
|
+
// src/utils/extractUserClaimsFromIdToken.ts
|
|
294
|
+
var extractUserClaimsFromIdToken = (payload) => {
|
|
295
|
+
const filteredPayload = { ...payload };
|
|
296
|
+
const protocolClaims = [
|
|
297
|
+
"iss",
|
|
298
|
+
"aud",
|
|
299
|
+
"exp",
|
|
300
|
+
"iat",
|
|
301
|
+
"acr",
|
|
302
|
+
"amr",
|
|
303
|
+
"azp",
|
|
304
|
+
"auth_time",
|
|
305
|
+
"nonce",
|
|
306
|
+
"c_hash",
|
|
307
|
+
"at_hash",
|
|
308
|
+
"nbf",
|
|
309
|
+
"isk",
|
|
310
|
+
"sid",
|
|
311
|
+
"jti",
|
|
312
|
+
"sub"
|
|
313
|
+
];
|
|
314
|
+
protocolClaims.forEach((claim) => {
|
|
315
|
+
delete filteredPayload[claim];
|
|
316
|
+
});
|
|
317
|
+
return filteredPayload;
|
|
318
|
+
};
|
|
319
|
+
var extractUserClaimsFromIdToken_default = extractUserClaimsFromIdToken;
|
|
320
|
+
|
|
372
321
|
// src/constants/ScopeConstants.ts
|
|
373
322
|
var ScopeConstants = {
|
|
374
323
|
/**
|
|
@@ -404,16 +353,16 @@ var OIDCRequestConstants = {
|
|
|
404
353
|
* Session state parameter used for session management between the client and the OP.
|
|
405
354
|
*/
|
|
406
355
|
SESSION_STATE: "session_state",
|
|
407
|
-
/**
|
|
408
|
-
* State parameter used to maintain state between the request and the callback.
|
|
409
|
-
* Helps in preventing CSRF attacks.
|
|
410
|
-
*/
|
|
411
|
-
STATE: "state",
|
|
412
356
|
/**
|
|
413
357
|
* Indicates whether sign-out was successful during the end-session flow.
|
|
414
358
|
* May be returned by the OP after a logout request.
|
|
415
359
|
*/
|
|
416
|
-
SIGN_OUT_SUCCESS: "sign_out_success"
|
|
360
|
+
SIGN_OUT_SUCCESS: "sign_out_success",
|
|
361
|
+
/**
|
|
362
|
+
* State parameter used to maintain state between the request and the callback.
|
|
363
|
+
* Helps in preventing CSRF attacks.
|
|
364
|
+
*/
|
|
365
|
+
STATE: "state"
|
|
417
366
|
},
|
|
418
367
|
/**
|
|
419
368
|
* Constants related to the OpenID Connect (OIDC) sign-in flow.
|
|
@@ -453,22 +402,327 @@ var OIDCRequestConstants = {
|
|
|
453
402
|
};
|
|
454
403
|
var OIDCRequestConstants_default = OIDCRequestConstants;
|
|
455
404
|
|
|
456
|
-
// src/errors/
|
|
457
|
-
var
|
|
458
|
-
constructor(
|
|
459
|
-
|
|
405
|
+
// src/errors/AsgardeoError.ts
|
|
406
|
+
var AsgardeoError = class _AsgardeoError extends Error {
|
|
407
|
+
constructor(message, code, origin) {
|
|
408
|
+
const resolvedOrigin = _AsgardeoError.resolveOrigin(origin);
|
|
409
|
+
super(message);
|
|
460
410
|
__publicField(this, "code");
|
|
461
|
-
__publicField(this, "
|
|
462
|
-
this.
|
|
463
|
-
this.name = name;
|
|
411
|
+
__publicField(this, "origin");
|
|
412
|
+
this.name = new.target.name;
|
|
464
413
|
this.code = code;
|
|
465
|
-
|
|
414
|
+
this.origin = resolvedOrigin;
|
|
415
|
+
if (Error.captureStackTrace) {
|
|
416
|
+
Error.captureStackTrace(this, new.target);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
static resolveOrigin(origin) {
|
|
420
|
+
if (!origin) {
|
|
421
|
+
return "@asgardeo/javascript";
|
|
422
|
+
}
|
|
423
|
+
return `@asgardeo/${origin}`;
|
|
424
|
+
}
|
|
425
|
+
toString() {
|
|
426
|
+
const prefix = `\u{1F6E1}\uFE0F Asgardeo - ${this.origin}:`;
|
|
427
|
+
return `[${this.name}]
|
|
428
|
+
${prefix} ${this.message}
|
|
429
|
+
(code="${this.code}")`;
|
|
466
430
|
}
|
|
467
431
|
};
|
|
468
432
|
|
|
469
|
-
// src/
|
|
470
|
-
var
|
|
471
|
-
/**
|
|
433
|
+
// src/errors/AsgardeoRuntimeError.ts
|
|
434
|
+
var AsgardeoRuntimeError = class extends AsgardeoError {
|
|
435
|
+
/**
|
|
436
|
+
* Creates an instance of AsgardeoRuntimeError.
|
|
437
|
+
*
|
|
438
|
+
* @param message - Human-readable description of the error
|
|
439
|
+
* @param code - A unique error code that identifies the error type
|
|
440
|
+
* @param details - Additional details about the error that might be helpful for debugging
|
|
441
|
+
* @param origin - Optional. The SDK origin (e.g. 'react', 'vue'). Defaults to generic 'Asgardeo'
|
|
442
|
+
* @constructor
|
|
443
|
+
*/
|
|
444
|
+
constructor(message, code, origin, details) {
|
|
445
|
+
super(message, code, origin);
|
|
446
|
+
this.details = details;
|
|
447
|
+
Object.defineProperty(this, "name", {
|
|
448
|
+
configurable: true,
|
|
449
|
+
value: "AsgardeoRuntimeError",
|
|
450
|
+
writable: true
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Returns a string representation of the runtime error
|
|
455
|
+
* @returns Formatted error string with name, code, details, and message
|
|
456
|
+
*/
|
|
457
|
+
toString() {
|
|
458
|
+
const details = this.details ? `
|
|
459
|
+
Details: ${JSON.stringify(this.details, null, 2)}` : "";
|
|
460
|
+
return `[${this.name}] (code="${this.code}")${details}
|
|
461
|
+
Message: ${this.message}`;
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
// src/utils/processOpenIDScopes.ts
|
|
466
|
+
var processOpenIDScopes = (scopes) => {
|
|
467
|
+
let processedScopes = [];
|
|
468
|
+
if (scopes) {
|
|
469
|
+
if (Array.isArray(scopes)) {
|
|
470
|
+
processedScopes = scopes;
|
|
471
|
+
} else if (typeof scopes === "string") {
|
|
472
|
+
processedScopes = scopes.split(" ");
|
|
473
|
+
} else {
|
|
474
|
+
throw new AsgardeoRuntimeError(
|
|
475
|
+
"Scopes must be a string or an array of strings.",
|
|
476
|
+
"processOpenIDScopes-Invalid-001",
|
|
477
|
+
"javascript",
|
|
478
|
+
"The provided scopes are not in the expected format. Please provide a string or an array of strings."
|
|
479
|
+
);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
OIDCRequestConstants_default.SignIn.Payload.DEFAULT_SCOPES.forEach((defaultScope) => {
|
|
483
|
+
if (!processedScopes.includes(defaultScope)) {
|
|
484
|
+
processedScopes.push(defaultScope);
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
return processedScopes.join(" ");
|
|
488
|
+
};
|
|
489
|
+
var processOpenIDScopes_default = processOpenIDScopes;
|
|
490
|
+
|
|
491
|
+
// src/__legacy__/helpers/authentication-helper.ts
|
|
492
|
+
var AuthenticationHelper = class {
|
|
493
|
+
constructor(storageManagerInstance, cryptoHelperInstance) {
|
|
494
|
+
__publicField(this, "storageManager");
|
|
495
|
+
__publicField(this, "config");
|
|
496
|
+
__publicField(this, "oidcProviderMetaData");
|
|
497
|
+
__publicField(this, "cryptoHelper");
|
|
498
|
+
this.storageManager = storageManagerInstance;
|
|
499
|
+
this.config = async () => this.storageManager.getConfigData();
|
|
500
|
+
this.oidcProviderMetaData = async () => this.storageManager.loadOpenIDProviderConfiguration();
|
|
501
|
+
this.cryptoHelper = cryptoHelperInstance;
|
|
502
|
+
}
|
|
503
|
+
async resolveEndpoints(response) {
|
|
504
|
+
const oidcProviderMetaData = {};
|
|
505
|
+
const configData = await this.config();
|
|
506
|
+
if (configData.endpoints) {
|
|
507
|
+
Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
508
|
+
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
509
|
+
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
return { ...response, ...oidcProviderMetaData };
|
|
513
|
+
}
|
|
514
|
+
async resolveEndpointsExplicitly() {
|
|
515
|
+
const oidcProviderMetaData = {};
|
|
516
|
+
const configData = await this.config();
|
|
517
|
+
const requiredEndpoints = [
|
|
518
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.AUTHORIZATION,
|
|
519
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.END_SESSION,
|
|
520
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.JWKS,
|
|
521
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.SESSION_IFRAME,
|
|
522
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.REVOCATION,
|
|
523
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.TOKEN,
|
|
524
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.ISSUER,
|
|
525
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.USERINFO
|
|
526
|
+
];
|
|
527
|
+
const isRequiredEndpointsContains = configData.endpoints ? requiredEndpoints.every(
|
|
528
|
+
(reqEndpointName) => configData.endpoints ? Object.keys(configData.endpoints).some((endpointName) => {
|
|
529
|
+
const snakeCasedName = endpointName.replace(
|
|
530
|
+
/[A-Z]/g,
|
|
531
|
+
(letter) => `_${letter.toLowerCase()}`
|
|
532
|
+
);
|
|
533
|
+
return snakeCasedName === reqEndpointName;
|
|
534
|
+
}) : false
|
|
535
|
+
) : false;
|
|
536
|
+
if (!isRequiredEndpointsContains) {
|
|
537
|
+
throw new AsgardeoAuthException(
|
|
538
|
+
"JS-AUTH_HELPER-REE-NF01",
|
|
539
|
+
"Required endpoints missing",
|
|
540
|
+
"Some or all of the required endpoints are missing in the object passed to the `endpoints` attribute of the`AuthConfig` object."
|
|
541
|
+
);
|
|
542
|
+
}
|
|
543
|
+
if (configData.endpoints) {
|
|
544
|
+
Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
545
|
+
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
546
|
+
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
return { ...oidcProviderMetaData };
|
|
550
|
+
}
|
|
551
|
+
async resolveEndpointsByBaseURL() {
|
|
552
|
+
const oidcProviderMetaData = {};
|
|
553
|
+
const configData = await this.config();
|
|
554
|
+
const { baseUrl } = configData;
|
|
555
|
+
if (!baseUrl) {
|
|
556
|
+
throw new AsgardeoAuthException(
|
|
557
|
+
"JS-AUTH_HELPER_REBO-NF01",
|
|
558
|
+
"Base URL not defined.",
|
|
559
|
+
"Base URL is not defined in AuthClient config."
|
|
560
|
+
);
|
|
561
|
+
}
|
|
562
|
+
if (configData.endpoints) {
|
|
563
|
+
Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
564
|
+
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
565
|
+
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
const endpointKeys = OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints;
|
|
569
|
+
const endpointPaths = OIDCDiscoveryConstants_default.Endpoints;
|
|
570
|
+
const defaultEndpoints = {
|
|
571
|
+
[endpointKeys.AUTHORIZATION]: `${baseUrl}${endpointPaths.AUTHORIZATION}`,
|
|
572
|
+
[endpointKeys.END_SESSION]: `${baseUrl}${endpointPaths.END_SESSION}`,
|
|
573
|
+
[endpointKeys.ISSUER]: `${baseUrl}${endpointPaths.ISSUER}`,
|
|
574
|
+
[endpointKeys.JWKS]: `${baseUrl}${endpointPaths.JWKS}`,
|
|
575
|
+
[endpointKeys.SESSION_IFRAME]: `${baseUrl}${endpointPaths.SESSION_IFRAME}`,
|
|
576
|
+
[endpointKeys.REVOCATION]: `${baseUrl}${endpointPaths.REVOCATION}`,
|
|
577
|
+
[endpointKeys.TOKEN]: `${baseUrl}${endpointPaths.TOKEN}`,
|
|
578
|
+
[endpointKeys.USERINFO]: `${baseUrl}${endpointPaths.USERINFO}`
|
|
579
|
+
};
|
|
580
|
+
if (configData.platform === "AsgardeoV2" /* AsgardeoV2 */) {
|
|
581
|
+
defaultEndpoints[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.ISSUER] = `${baseUrl}`;
|
|
582
|
+
}
|
|
583
|
+
return { ...defaultEndpoints, ...oidcProviderMetaData };
|
|
584
|
+
}
|
|
585
|
+
async validateIdToken(idToken) {
|
|
586
|
+
const jwksEndpoint = (await this.storageManager.loadOpenIDProviderConfiguration()).jwks_uri;
|
|
587
|
+
const configData = await this.config();
|
|
588
|
+
if (!jwksEndpoint || jwksEndpoint.trim().length === 0) {
|
|
589
|
+
throw new AsgardeoAuthException(
|
|
590
|
+
"JS_AUTH_HELPER-VIT-NF01",
|
|
591
|
+
"JWKS endpoint not found.",
|
|
592
|
+
"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."
|
|
593
|
+
);
|
|
594
|
+
}
|
|
595
|
+
let response;
|
|
596
|
+
try {
|
|
597
|
+
response = await fetch(jwksEndpoint, {
|
|
598
|
+
credentials: configData.sendCookiesInRequests ? "include" : "same-origin"
|
|
599
|
+
});
|
|
600
|
+
} catch (error2) {
|
|
601
|
+
throw new AsgardeoAuthException(
|
|
602
|
+
"JS-AUTH_HELPER-VIT-NE02",
|
|
603
|
+
"Request to jwks endpoint failed.",
|
|
604
|
+
error2 ?? "The request sent to get the jwks from the server failed."
|
|
605
|
+
);
|
|
606
|
+
}
|
|
607
|
+
if (response.status !== 200 || !response.ok) {
|
|
608
|
+
throw new AsgardeoAuthException(
|
|
609
|
+
"JS-AUTH_HELPER-VIT-HE03",
|
|
610
|
+
`Invalid response status received for jwks request (${response.statusText}).`,
|
|
611
|
+
await response.json()
|
|
612
|
+
);
|
|
613
|
+
}
|
|
614
|
+
const { issuer } = await this.oidcProviderMetaData();
|
|
615
|
+
const { keys } = await response.json();
|
|
616
|
+
const jwk = await this.cryptoHelper.getJWKForTheIdToken(idToken.split(".")[0], keys);
|
|
617
|
+
return this.cryptoHelper.isValidIdToken(
|
|
618
|
+
idToken,
|
|
619
|
+
jwk,
|
|
620
|
+
(await this.config()).clientId,
|
|
621
|
+
issuer ?? "",
|
|
622
|
+
this.cryptoHelper.decodeJwtToken(idToken).sub,
|
|
623
|
+
(await this.config()).tokenValidation?.idToken?.clockTolerance,
|
|
624
|
+
(await this.config()).tokenValidation?.idToken?.validateIssuer ?? true
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
getAuthenticatedUserInfo(idToken) {
|
|
628
|
+
const payload = this.cryptoHelper.decodeJwtToken(idToken);
|
|
629
|
+
const username = payload?.["username"] ?? "";
|
|
630
|
+
const givenName = payload?.["given_name"] ?? "";
|
|
631
|
+
const familyName = payload?.["family_name"] ?? "";
|
|
632
|
+
const fullName = givenName && familyName ? `${givenName} ${familyName}` : givenName || familyName || "";
|
|
633
|
+
const displayName = payload.preferred_username ?? fullName;
|
|
634
|
+
return {
|
|
635
|
+
displayName,
|
|
636
|
+
username,
|
|
637
|
+
...extractUserClaimsFromIdToken_default(payload)
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
async replaceCustomGrantTemplateTags(text, userId) {
|
|
641
|
+
const configData = await this.config();
|
|
642
|
+
const sessionData = await this.storageManager.getSessionData(userId);
|
|
643
|
+
const scope = processOpenIDScopes_default(configData.scopes);
|
|
644
|
+
if (typeof text !== "string") {
|
|
645
|
+
return text;
|
|
646
|
+
}
|
|
647
|
+
return text.replace(TokenExchangeConstants_default.Placeholders.ACCESS_TOKEN, sessionData.access_token).replace(
|
|
648
|
+
TokenExchangeConstants_default.Placeholders.USERNAME,
|
|
649
|
+
this.getAuthenticatedUserInfo(sessionData.id_token).username
|
|
650
|
+
).replace(TokenExchangeConstants_default.Placeholders.SCOPES, scope).replace(TokenExchangeConstants_default.Placeholders.CLIENT_ID, configData.clientId).replace(TokenExchangeConstants_default.Placeholders.CLIENT_SECRET, configData.clientSecret ?? "");
|
|
651
|
+
}
|
|
652
|
+
async clearSession(userId) {
|
|
653
|
+
await this.storageManager.removeTemporaryData(userId);
|
|
654
|
+
await this.storageManager.removeSessionData(userId);
|
|
655
|
+
}
|
|
656
|
+
async handleTokenResponse(response, userId) {
|
|
657
|
+
if (response.status !== 200 || !response.ok) {
|
|
658
|
+
throw new AsgardeoAuthException(
|
|
659
|
+
"JS-AUTH_HELPER-HTR-NE01",
|
|
660
|
+
`Invalid response status received for token request (${response.statusText}).`,
|
|
661
|
+
await response.json()
|
|
662
|
+
);
|
|
663
|
+
}
|
|
664
|
+
const parsedResponse = await response.json();
|
|
665
|
+
parsedResponse.created_at = (/* @__PURE__ */ new Date()).getTime();
|
|
666
|
+
const shouldValidateIdToken = (await this.config()).tokenValidation?.idToken?.validate;
|
|
667
|
+
if (shouldValidateIdToken) {
|
|
668
|
+
return this.validateIdToken(parsedResponse.id_token).then(async () => {
|
|
669
|
+
await this.storageManager.setSessionData(parsedResponse, userId);
|
|
670
|
+
const tokenResponse2 = {
|
|
671
|
+
accessToken: parsedResponse.access_token,
|
|
672
|
+
createdAt: parsedResponse.created_at,
|
|
673
|
+
expiresIn: parsedResponse.expires_in,
|
|
674
|
+
idToken: parsedResponse.id_token,
|
|
675
|
+
refreshToken: parsedResponse.refresh_token,
|
|
676
|
+
scope: parsedResponse.scope,
|
|
677
|
+
tokenType: parsedResponse.token_type
|
|
678
|
+
};
|
|
679
|
+
return Promise.resolve(tokenResponse2);
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
const tokenResponse = {
|
|
683
|
+
accessToken: parsedResponse.access_token,
|
|
684
|
+
createdAt: parsedResponse.created_at,
|
|
685
|
+
expiresIn: parsedResponse.expires_in,
|
|
686
|
+
idToken: parsedResponse.id_token,
|
|
687
|
+
refreshToken: parsedResponse.refresh_token,
|
|
688
|
+
scope: parsedResponse.scope,
|
|
689
|
+
tokenType: parsedResponse.token_type
|
|
690
|
+
};
|
|
691
|
+
await this.storageManager.setSessionData(parsedResponse, userId);
|
|
692
|
+
return Promise.resolve(tokenResponse);
|
|
693
|
+
}
|
|
694
|
+
};
|
|
695
|
+
|
|
696
|
+
// src/constants/PKCEConstants.ts
|
|
697
|
+
var PKCEConstants = {
|
|
698
|
+
DEFAULT_CODE_CHALLENGE_METHOD: "S256",
|
|
699
|
+
/**
|
|
700
|
+
* Storage-related constants for managing PKCE state
|
|
701
|
+
*/
|
|
702
|
+
Storage: {
|
|
703
|
+
/**
|
|
704
|
+
* Collection of storage keys used in PKCE implementation
|
|
705
|
+
*/
|
|
706
|
+
StorageKeys: {
|
|
707
|
+
/**
|
|
708
|
+
* Key used to store the PKCE code verifier in temporary storage.
|
|
709
|
+
* The code verifier is a cryptographically random string that is
|
|
710
|
+
* used to generate the code challenge.
|
|
711
|
+
*/
|
|
712
|
+
CODE_VERIFIER: "pkce_code_verifier",
|
|
713
|
+
/**
|
|
714
|
+
* Separator used in storage keys to create unique identifiers
|
|
715
|
+
* by combining different parts of the key.
|
|
716
|
+
*/
|
|
717
|
+
SEPARATOR: "#"
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
};
|
|
721
|
+
var PKCEConstants_default = PKCEConstants;
|
|
722
|
+
|
|
723
|
+
// src/constants/TokenConstants.ts
|
|
724
|
+
var TokenConstants = {
|
|
725
|
+
/**
|
|
472
726
|
* Token signature validation constants.
|
|
473
727
|
* Contains configurations related to token signature verification.
|
|
474
728
|
*/
|
|
@@ -511,8 +765,8 @@ var TokenConstants_default = TokenConstants;
|
|
|
511
765
|
// src/IsomorphicCrypto.ts
|
|
512
766
|
var IsomorphicCrypto = class {
|
|
513
767
|
constructor(cryptoUtils) {
|
|
514
|
-
__publicField(this, "
|
|
515
|
-
this.
|
|
768
|
+
__publicField(this, "cryptoUtils");
|
|
769
|
+
this.cryptoUtils = cryptoUtils;
|
|
516
770
|
}
|
|
517
771
|
/**
|
|
518
772
|
* Generate code verifier.
|
|
@@ -520,7 +774,7 @@ var IsomorphicCrypto = class {
|
|
|
520
774
|
* @returns code verifier.
|
|
521
775
|
*/
|
|
522
776
|
getCodeVerifier() {
|
|
523
|
-
return this.
|
|
777
|
+
return this.cryptoUtils.base64URLEncode(this.cryptoUtils.generateRandomBytes(32));
|
|
524
778
|
}
|
|
525
779
|
/**
|
|
526
780
|
* Derive code challenge from the code verifier.
|
|
@@ -530,7 +784,7 @@ var IsomorphicCrypto = class {
|
|
|
530
784
|
* @returns - code challenge.
|
|
531
785
|
*/
|
|
532
786
|
getCodeChallenge(verifier) {
|
|
533
|
-
return this.
|
|
787
|
+
return this.cryptoUtils.base64URLEncode(this.cryptoUtils.hashSha256(verifier));
|
|
534
788
|
}
|
|
535
789
|
/**
|
|
536
790
|
* Get JWK used for the id_token
|
|
@@ -544,16 +798,17 @@ var IsomorphicCrypto = class {
|
|
|
544
798
|
*/
|
|
545
799
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
546
800
|
getJWKForTheIdToken(jwtHeader, keys) {
|
|
547
|
-
const headerJSON = JSON.parse(this.
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
801
|
+
const headerJSON = JSON.parse(this.cryptoUtils.base64URLDecode(jwtHeader));
|
|
802
|
+
const matchingKey = keys.find(
|
|
803
|
+
(key) => headerJSON["kid"] === key.kid
|
|
804
|
+
);
|
|
805
|
+
if (matchingKey) {
|
|
806
|
+
return matchingKey;
|
|
552
807
|
}
|
|
553
808
|
throw new AsgardeoAuthException(
|
|
554
809
|
"JS-CRYPTO_UTIL-GJFTIT-IV01",
|
|
555
810
|
"kid not found.",
|
|
556
|
-
|
|
811
|
+
`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(", ")}`
|
|
557
812
|
);
|
|
558
813
|
}
|
|
559
814
|
/**
|
|
@@ -571,7 +826,7 @@ var IsomorphicCrypto = class {
|
|
|
571
826
|
* @throws
|
|
572
827
|
*/
|
|
573
828
|
isValidIdToken(idToken, jwk, clientId, issuer, username, clockTolerance, validateJwtIssuer) {
|
|
574
|
-
return this.
|
|
829
|
+
return this.cryptoUtils.verifyJwt(
|
|
575
830
|
idToken,
|
|
576
831
|
jwk,
|
|
577
832
|
TokenConstants_default.SignatureValidation.SUPPORTED_ALGORITHMS,
|
|
@@ -583,419 +838,178 @@ var IsomorphicCrypto = class {
|
|
|
583
838
|
).then((response) => {
|
|
584
839
|
if (response) {
|
|
585
840
|
return Promise.resolve(true);
|
|
586
|
-
}
|
|
587
|
-
return Promise.reject(
|
|
588
|
-
new AsgardeoAuthException(
|
|
589
|
-
"JS-CRYPTO_HELPER-IVIT-IV01",
|
|
590
|
-
"Invalid ID token.",
|
|
591
|
-
"ID token validation returned false"
|
|
592
|
-
)
|
|
593
|
-
);
|
|
594
|
-
}).catch((error2) => {
|
|
595
|
-
return Promise.reject(error2);
|
|
596
|
-
});
|
|
597
|
-
}
|
|
598
|
-
decodeJwtToken(token) {
|
|
599
|
-
try {
|
|
600
|
-
const utf8String = this._cryptoUtils.base64URLDecode(token?.split(".")[1]);
|
|
601
|
-
const payload = JSON.parse(utf8String);
|
|
602
|
-
return payload;
|
|
603
|
-
} catch (error2) {
|
|
604
|
-
throw new AsgardeoAuthException("JS-CRYPTO_UTIL-DIT-IV02", "Decoding token failed.", error2);
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
};
|
|
608
|
-
|
|
609
|
-
// src/constants/PKCEConstants.ts
|
|
610
|
-
var PKCEConstants = {
|
|
611
|
-
DEFAULT_CODE_CHALLENGE_METHOD: "S256",
|
|
612
|
-
/**
|
|
613
|
-
* Storage-related constants for managing PKCE state
|
|
614
|
-
*/
|
|
615
|
-
Storage: {
|
|
616
|
-
/**
|
|
617
|
-
* Collection of storage keys used in PKCE implementation
|
|
618
|
-
*/
|
|
619
|
-
StorageKeys: {
|
|
620
|
-
/**
|
|
621
|
-
* Key used to store the PKCE code verifier in temporary storage.
|
|
622
|
-
* The code verifier is a cryptographically random string that is
|
|
623
|
-
* used to generate the code challenge.
|
|
624
|
-
*/
|
|
625
|
-
CODE_VERIFIER: "pkce_code_verifier",
|
|
626
|
-
/**
|
|
627
|
-
* Separator used in storage keys to create unique identifiers
|
|
628
|
-
* by combining different parts of the key.
|
|
629
|
-
*/
|
|
630
|
-
SEPARATOR: "#"
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
};
|
|
634
|
-
var PKCEConstants_default = PKCEConstants;
|
|
635
|
-
|
|
636
|
-
// src/utils/extractPkceStorageKeyFromState.ts
|
|
637
|
-
var extractPkceStorageKeyFromState = (state) => {
|
|
638
|
-
const index = parseInt(state.split("request_")[1]);
|
|
639
|
-
return `${PKCEConstants_default.Storage.StorageKeys.CODE_VERIFIER}${PKCEConstants_default.Storage.StorageKeys.SEPARATOR}${index}`;
|
|
640
|
-
};
|
|
641
|
-
var extractPkceStorageKeyFromState_default = extractPkceStorageKeyFromState;
|
|
642
|
-
|
|
643
|
-
// src/constants/TokenExchangeConstants.ts
|
|
644
|
-
var TokenExchangeConstants = {
|
|
645
|
-
/**
|
|
646
|
-
* Collection of placeholder strings used in token exchange operations.
|
|
647
|
-
* These placeholders are replaced with actual values when processing
|
|
648
|
-
* token exchange requests.
|
|
649
|
-
*/
|
|
650
|
-
Placeholders: {
|
|
651
|
-
/**
|
|
652
|
-
* Placeholder for the token value in exchange requests.
|
|
653
|
-
* Usually replaced with an access token or refresh token.
|
|
654
|
-
*/
|
|
655
|
-
ACCESS_TOKEN: "{{accessToken}}",
|
|
656
|
-
/**
|
|
657
|
-
* Placeholder for the username in token exchange operations.
|
|
658
|
-
* Used when user identity needs to be included in the exchange.
|
|
659
|
-
*/
|
|
660
|
-
USERNAME: "{{username}}",
|
|
661
|
-
/**
|
|
662
|
-
* Placeholder for OAuth scopes in token exchange requests.
|
|
663
|
-
* Replaced with space-separated scope strings.
|
|
664
|
-
*/
|
|
665
|
-
SCOPES: "{{scopes}}",
|
|
666
|
-
/**
|
|
667
|
-
* Placeholder for client ID in token exchange operations.
|
|
668
|
-
* Required for client authentication.
|
|
669
|
-
*/
|
|
670
|
-
CLIENT_ID: "{{clientId}}",
|
|
671
|
-
/**
|
|
672
|
-
* Placeholder for client secret in token exchange operations.
|
|
673
|
-
* Used for client authentication in confidential client flows.
|
|
674
|
-
*/
|
|
675
|
-
CLIENT_SECRET: "{{clientSecret}}"
|
|
676
|
-
}
|
|
677
|
-
};
|
|
678
|
-
var TokenExchangeConstants_default = TokenExchangeConstants;
|
|
679
|
-
|
|
680
|
-
// src/models/platforms.ts
|
|
681
|
-
var Platform = /* @__PURE__ */ ((Platform2) => {
|
|
682
|
-
Platform2["Asgardeo"] = "ASGARDEO";
|
|
683
|
-
Platform2["IdentityServer"] = "IDENTITY_SERVER";
|
|
684
|
-
Platform2["AsgardeoV2"] = "AsgardeoV2";
|
|
685
|
-
Platform2["Unknown"] = "UNKNOWN";
|
|
686
|
-
return Platform2;
|
|
687
|
-
})(Platform || {});
|
|
688
|
-
|
|
689
|
-
// src/utils/extractUserClaimsFromIdToken.ts
|
|
690
|
-
var extractUserClaimsFromIdToken = (payload) => {
|
|
691
|
-
const filteredPayload = { ...payload };
|
|
692
|
-
const protocolClaims = [
|
|
693
|
-
"iss",
|
|
694
|
-
"aud",
|
|
695
|
-
"exp",
|
|
696
|
-
"iat",
|
|
697
|
-
"acr",
|
|
698
|
-
"amr",
|
|
699
|
-
"azp",
|
|
700
|
-
"auth_time",
|
|
701
|
-
"nonce",
|
|
702
|
-
"c_hash",
|
|
703
|
-
"at_hash",
|
|
704
|
-
"nbf",
|
|
705
|
-
"isk",
|
|
706
|
-
"sid",
|
|
707
|
-
"jti",
|
|
708
|
-
"sub"
|
|
709
|
-
];
|
|
710
|
-
protocolClaims.forEach((claim) => {
|
|
711
|
-
delete filteredPayload[claim];
|
|
712
|
-
});
|
|
713
|
-
return filteredPayload;
|
|
714
|
-
};
|
|
715
|
-
var extractUserClaimsFromIdToken_default = extractUserClaimsFromIdToken;
|
|
716
|
-
|
|
717
|
-
// src/errors/AsgardeoError.ts
|
|
718
|
-
var AsgardeoError = class _AsgardeoError extends Error {
|
|
719
|
-
constructor(message, code, origin) {
|
|
720
|
-
const _origin = _AsgardeoError.resolveOrigin(origin);
|
|
721
|
-
super(message);
|
|
722
|
-
__publicField(this, "code");
|
|
723
|
-
__publicField(this, "origin");
|
|
724
|
-
this.name = new.target.name;
|
|
725
|
-
this.code = code;
|
|
726
|
-
this.origin = _origin;
|
|
727
|
-
if (Error.captureStackTrace) {
|
|
728
|
-
Error.captureStackTrace(this, new.target);
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
static resolveOrigin(origin) {
|
|
732
|
-
if (!origin) {
|
|
733
|
-
return "@asgardeo/javascript";
|
|
734
|
-
}
|
|
735
|
-
return `@asgardeo/${origin}`;
|
|
736
|
-
}
|
|
737
|
-
toString() {
|
|
738
|
-
const prefix = `\u{1F6E1}\uFE0F Asgardeo - ${this.origin}:`;
|
|
739
|
-
return `[${this.name}]
|
|
740
|
-
${prefix} ${this.message}
|
|
741
|
-
(code="${this.code}")`;
|
|
742
|
-
}
|
|
743
|
-
};
|
|
744
|
-
|
|
745
|
-
// src/errors/AsgardeoRuntimeError.ts
|
|
746
|
-
var AsgardeoRuntimeError = class extends AsgardeoError {
|
|
747
|
-
/**
|
|
748
|
-
* Creates an instance of AsgardeoRuntimeError.
|
|
749
|
-
*
|
|
750
|
-
* @param message - Human-readable description of the error
|
|
751
|
-
* @param code - A unique error code that identifies the error type
|
|
752
|
-
* @param details - Additional details about the error that might be helpful for debugging
|
|
753
|
-
* @param origin - Optional. The SDK origin (e.g. 'react', 'vue'). Defaults to generic 'Asgardeo'
|
|
754
|
-
* @constructor
|
|
755
|
-
*/
|
|
756
|
-
constructor(message, code, origin, details) {
|
|
757
|
-
super(message, code, origin);
|
|
758
|
-
this.details = details;
|
|
759
|
-
Object.defineProperty(this, "name", {
|
|
760
|
-
value: "AsgardeoRuntimeError",
|
|
761
|
-
configurable: true,
|
|
762
|
-
writable: true
|
|
763
|
-
});
|
|
764
|
-
}
|
|
765
|
-
/**
|
|
766
|
-
* Returns a string representation of the runtime error
|
|
767
|
-
* @returns Formatted error string with name, code, details, and message
|
|
768
|
-
*/
|
|
769
|
-
toString() {
|
|
770
|
-
const details = this.details ? `
|
|
771
|
-
Details: ${JSON.stringify(this.details, null, 2)}` : "";
|
|
772
|
-
return `[${this.name}] (code="${this.code}")${details}
|
|
773
|
-
Message: ${this.message}`;
|
|
774
|
-
}
|
|
775
|
-
};
|
|
776
|
-
|
|
777
|
-
// src/utils/processOpenIDScopes.ts
|
|
778
|
-
var processOpenIDScopes = (scopes) => {
|
|
779
|
-
let processedScopes = [];
|
|
780
|
-
if (scopes) {
|
|
781
|
-
if (Array.isArray(scopes)) {
|
|
782
|
-
processedScopes = scopes;
|
|
783
|
-
} else if (typeof scopes === "string") {
|
|
784
|
-
processedScopes = scopes.split(" ");
|
|
785
|
-
} else {
|
|
786
|
-
throw new AsgardeoRuntimeError(
|
|
787
|
-
"Scopes must be a string or an array of strings.",
|
|
788
|
-
"processOpenIDScopes-Invalid-001",
|
|
789
|
-
"javascript",
|
|
790
|
-
"The provided scopes are not in the expected format. Please provide a string or an array of strings."
|
|
791
|
-
);
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
OIDCRequestConstants_default.SignIn.Payload.DEFAULT_SCOPES.forEach((defaultScope) => {
|
|
795
|
-
if (!processedScopes.includes(defaultScope)) {
|
|
796
|
-
processedScopes.push(defaultScope);
|
|
797
|
-
}
|
|
798
|
-
});
|
|
799
|
-
return processedScopes.join(" ");
|
|
800
|
-
};
|
|
801
|
-
var processOpenIDScopes_default = processOpenIDScopes;
|
|
802
|
-
|
|
803
|
-
// src/__legacy__/helpers/authentication-helper.ts
|
|
804
|
-
var AuthenticationHelper = class {
|
|
805
|
-
constructor(storageManager, cryptoHelper) {
|
|
806
|
-
__publicField(this, "_storageManager");
|
|
807
|
-
__publicField(this, "_config");
|
|
808
|
-
__publicField(this, "_oidcProviderMetaData");
|
|
809
|
-
__publicField(this, "_cryptoHelper");
|
|
810
|
-
this._storageManager = storageManager;
|
|
811
|
-
this._config = async () => this._storageManager.getConfigData();
|
|
812
|
-
this._oidcProviderMetaData = async () => this._storageManager.loadOpenIDProviderConfiguration();
|
|
813
|
-
this._cryptoHelper = cryptoHelper;
|
|
814
|
-
}
|
|
815
|
-
async resolveEndpoints(response) {
|
|
816
|
-
const oidcProviderMetaData = {};
|
|
817
|
-
const configData = await this._config();
|
|
818
|
-
configData.endpoints && Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
819
|
-
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
820
|
-
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
821
|
-
});
|
|
822
|
-
return { ...response, ...oidcProviderMetaData };
|
|
823
|
-
}
|
|
824
|
-
async resolveEndpointsExplicitly() {
|
|
825
|
-
const oidcProviderMetaData = {};
|
|
826
|
-
const configData = await this._config();
|
|
827
|
-
const requiredEndpoints = [
|
|
828
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.AUTHORIZATION,
|
|
829
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.END_SESSION,
|
|
830
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.JWKS,
|
|
831
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.SESSION_IFRAME,
|
|
832
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.REVOCATION,
|
|
833
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.TOKEN,
|
|
834
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.ISSUER,
|
|
835
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.USERINFO
|
|
836
|
-
];
|
|
837
|
-
const isRequiredEndpointsContains = configData.endpoints ? requiredEndpoints.every(
|
|
838
|
-
(reqEndpointName) => configData.endpoints ? Object.keys(configData.endpoints).some((endpointName) => {
|
|
839
|
-
const snakeCasedName = endpointName.replace(
|
|
840
|
-
/[A-Z]/g,
|
|
841
|
-
(letter) => `_${letter.toLowerCase()}`
|
|
842
|
-
);
|
|
843
|
-
return snakeCasedName === reqEndpointName;
|
|
844
|
-
}) : false
|
|
845
|
-
) : false;
|
|
846
|
-
if (!isRequiredEndpointsContains) {
|
|
847
|
-
throw new AsgardeoAuthException(
|
|
848
|
-
"JS-AUTH_HELPER-REE-NF01",
|
|
849
|
-
"Required endpoints missing",
|
|
850
|
-
"Some or all of the required endpoints are missing in the object passed to the `endpoints` attribute of the`AuthConfig` object."
|
|
841
|
+
}
|
|
842
|
+
return Promise.reject(
|
|
843
|
+
new AsgardeoAuthException(
|
|
844
|
+
"JS-CRYPTO_HELPER-IVIT-IV01",
|
|
845
|
+
"Invalid ID token.",
|
|
846
|
+
"ID token validation returned false"
|
|
847
|
+
)
|
|
851
848
|
);
|
|
852
|
-
}
|
|
853
|
-
configData.endpoints && Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
854
|
-
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
855
|
-
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
856
|
-
});
|
|
857
|
-
return { ...oidcProviderMetaData };
|
|
849
|
+
}).catch((error2) => Promise.reject(error2));
|
|
858
850
|
}
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
"Base URL not defined.",
|
|
867
|
-
"Base URL is not defined in AuthClient config."
|
|
868
|
-
);
|
|
869
|
-
}
|
|
870
|
-
configData.endpoints && Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
871
|
-
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
872
|
-
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
873
|
-
});
|
|
874
|
-
const defaultEndpoints = {
|
|
875
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.AUTHORIZATION]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.AUTHORIZATION}`,
|
|
876
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.END_SESSION]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.END_SESSION}`,
|
|
877
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.ISSUER]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.ISSUER}`,
|
|
878
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.JWKS]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.JWKS}`,
|
|
879
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.SESSION_IFRAME]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.SESSION_IFRAME}`,
|
|
880
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.REVOCATION]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.REVOCATION}`,
|
|
881
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.TOKEN]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.TOKEN}`,
|
|
882
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.USERINFO]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.USERINFO}`
|
|
883
|
-
};
|
|
884
|
-
if (configData.platform === "AsgardeoV2" /* AsgardeoV2 */) {
|
|
885
|
-
defaultEndpoints[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.ISSUER] = `${baseUrl}`;
|
|
851
|
+
decodeJwtToken(token) {
|
|
852
|
+
try {
|
|
853
|
+
const utf8String = this.cryptoUtils.base64URLDecode(token?.split(".")[1]);
|
|
854
|
+
const payload = JSON.parse(utf8String);
|
|
855
|
+
return payload;
|
|
856
|
+
} catch (error2) {
|
|
857
|
+
throw new AsgardeoAuthException("JS-CRYPTO_UTIL-DIT-IV02", "Decoding token failed.", error2);
|
|
886
858
|
}
|
|
887
|
-
return { ...defaultEndpoints, ...oidcProviderMetaData };
|
|
888
859
|
}
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
860
|
+
};
|
|
861
|
+
|
|
862
|
+
// src/StorageManager.ts
|
|
863
|
+
var ASGARDEO_SESSION_ACTIVE = "asgardeo-session-active";
|
|
864
|
+
var StorageManager = class _StorageManager {
|
|
865
|
+
constructor(instanceID, store) {
|
|
866
|
+
__publicField(this, "id");
|
|
867
|
+
__publicField(this, "store");
|
|
868
|
+
this.id = instanceID;
|
|
869
|
+
this.store = store;
|
|
870
|
+
}
|
|
871
|
+
async setDataInBulk(key, data) {
|
|
872
|
+
const existingDataJSON = await this.store.getData(key) ?? null;
|
|
873
|
+
const existingData = existingDataJSON && JSON.parse(existingDataJSON);
|
|
874
|
+
const dataToBeSaved = { ...existingData, ...data };
|
|
875
|
+
const dataToBeSavedJSON = JSON.stringify(dataToBeSaved);
|
|
876
|
+
await this.store.setData(key, dataToBeSavedJSON);
|
|
877
|
+
}
|
|
878
|
+
async setValue(key, attribute, value) {
|
|
879
|
+
const existingDataJSON = await this.store.getData(key) ?? null;
|
|
880
|
+
const existingData = existingDataJSON && JSON.parse(existingDataJSON);
|
|
881
|
+
const dataToBeSaved = { ...existingData, [attribute]: value };
|
|
882
|
+
const dataToBeSavedJSON = JSON.stringify(dataToBeSaved);
|
|
883
|
+
await this.store.setData(key, dataToBeSavedJSON);
|
|
884
|
+
}
|
|
885
|
+
async removeValue(key, attribute) {
|
|
886
|
+
const existingDataJSON = await this.store.getData(key) ?? null;
|
|
887
|
+
const existingData = existingDataJSON && JSON.parse(existingDataJSON);
|
|
888
|
+
const dataToBeSaved = { ...existingData };
|
|
889
|
+
delete dataToBeSaved[attribute];
|
|
890
|
+
const dataToBeSavedJSON = JSON.stringify(dataToBeSaved);
|
|
891
|
+
await this.store.setData(key, dataToBeSavedJSON);
|
|
892
|
+
}
|
|
893
|
+
resolveKey(store, userId) {
|
|
894
|
+
return userId ? `${store}-${this.id}-${userId}` : `${store}-${this.id}`;
|
|
895
|
+
}
|
|
896
|
+
static isLocalStorageAvailable() {
|
|
900
897
|
try {
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
898
|
+
const testValue = "__ASGARDEO_AUTH_CORE_LOCAL_STORAGE_TEST__";
|
|
899
|
+
localStorage.setItem(testValue, testValue);
|
|
900
|
+
localStorage.removeItem(testValue);
|
|
901
|
+
return true;
|
|
904
902
|
} catch (error2) {
|
|
905
|
-
|
|
906
|
-
"JS-AUTH_HELPER-VIT-NE02",
|
|
907
|
-
"Request to jwks endpoint failed.",
|
|
908
|
-
error2 ?? "The request sent to get the jwks from the server failed."
|
|
909
|
-
);
|
|
910
|
-
}
|
|
911
|
-
if (response.status !== 200 || !response.ok) {
|
|
912
|
-
throw new AsgardeoAuthException(
|
|
913
|
-
"JS-AUTH_HELPER-VIT-HE03",
|
|
914
|
-
`Invalid response status received for jwks request (${response.statusText}).`,
|
|
915
|
-
await response.json()
|
|
916
|
-
);
|
|
903
|
+
return false;
|
|
917
904
|
}
|
|
918
|
-
const { issuer } = await this._oidcProviderMetaData();
|
|
919
|
-
const { keys } = await response.json();
|
|
920
|
-
const jwk = await this._cryptoHelper.getJWKForTheIdToken(idToken.split(".")[0], keys);
|
|
921
|
-
return this._cryptoHelper.isValidIdToken(
|
|
922
|
-
idToken,
|
|
923
|
-
jwk,
|
|
924
|
-
(await this._config()).clientId,
|
|
925
|
-
issuer ?? "",
|
|
926
|
-
this._cryptoHelper.decodeJwtToken(idToken).sub,
|
|
927
|
-
(await this._config()).tokenValidation?.idToken?.clockTolerance,
|
|
928
|
-
(await this._config()).tokenValidation?.idToken?.validateIssuer ?? true
|
|
929
|
-
);
|
|
930
905
|
}
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
const username = payload?.["username"] ?? "";
|
|
934
|
-
const givenName = payload?.["given_name"] ?? "";
|
|
935
|
-
const familyName = payload?.["family_name"] ?? "";
|
|
936
|
-
const fullName = givenName && familyName ? `${givenName} ${familyName}` : givenName || familyName || "";
|
|
937
|
-
const displayName = payload.preferred_username ?? fullName;
|
|
938
|
-
return {
|
|
939
|
-
displayName,
|
|
940
|
-
username,
|
|
941
|
-
...extractUserClaimsFromIdToken_default(payload)
|
|
942
|
-
};
|
|
906
|
+
async setConfigData(config) {
|
|
907
|
+
await this.setDataInBulk(this.resolveKey("config_data" /* ConfigData */), config);
|
|
943
908
|
}
|
|
944
|
-
async
|
|
945
|
-
|
|
946
|
-
const sessionData = await this._storageManager.getSessionData(userId);
|
|
947
|
-
const scope = processOpenIDScopes_default(configData.scopes);
|
|
948
|
-
if (typeof text !== "string") {
|
|
949
|
-
return text;
|
|
950
|
-
}
|
|
951
|
-
return text.replace(TokenExchangeConstants_default.Placeholders.ACCESS_TOKEN, sessionData.access_token).replace(
|
|
952
|
-
TokenExchangeConstants_default.Placeholders.USERNAME,
|
|
953
|
-
this.getAuthenticatedUserInfo(sessionData.id_token).username
|
|
954
|
-
).replace(TokenExchangeConstants_default.Placeholders.SCOPES, scope).replace(TokenExchangeConstants_default.Placeholders.CLIENT_ID, configData.clientId).replace(TokenExchangeConstants_default.Placeholders.CLIENT_SECRET, configData.clientSecret ?? "");
|
|
909
|
+
async setOIDCProviderMetaData(oidcProviderMetaData) {
|
|
910
|
+
this.setDataInBulk(this.resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), oidcProviderMetaData);
|
|
955
911
|
}
|
|
956
|
-
async
|
|
957
|
-
|
|
958
|
-
await this._storageManager.removeSessionData(userId);
|
|
912
|
+
async setTemporaryData(temporaryData, userId) {
|
|
913
|
+
this.setDataInBulk(this.resolveKey("temporary_data" /* TemporaryData */, userId), temporaryData);
|
|
959
914
|
}
|
|
960
|
-
async
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
915
|
+
async setSessionData(sessionData, userId) {
|
|
916
|
+
this.setDataInBulk(this.resolveKey("session_data" /* SessionData */, userId), sessionData);
|
|
917
|
+
}
|
|
918
|
+
async setCustomData(key, customData, userId) {
|
|
919
|
+
this.setDataInBulk(this.resolveKey(key, userId), customData);
|
|
920
|
+
}
|
|
921
|
+
async getConfigData(userId) {
|
|
922
|
+
return JSON.parse(await this.store.getData(this.resolveKey("config_data" /* ConfigData */, userId)) ?? null);
|
|
923
|
+
}
|
|
924
|
+
async loadOpenIDProviderConfiguration() {
|
|
925
|
+
return JSON.parse(await this.store.getData(this.resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */)) ?? null);
|
|
926
|
+
}
|
|
927
|
+
async getTemporaryData(userId) {
|
|
928
|
+
return JSON.parse(await this.store.getData(this.resolveKey("temporary_data" /* TemporaryData */, userId)) ?? null);
|
|
929
|
+
}
|
|
930
|
+
async getSessionData(userId) {
|
|
931
|
+
return JSON.parse(await this.store.getData(this.resolveKey("session_data" /* SessionData */, userId)) ?? null);
|
|
932
|
+
}
|
|
933
|
+
async getCustomData(key, userId) {
|
|
934
|
+
return JSON.parse(await this.store.getData(this.resolveKey(key, userId)) ?? null);
|
|
935
|
+
}
|
|
936
|
+
// eslint-disable-next-line class-methods-use-this
|
|
937
|
+
setSessionStatus(status) {
|
|
938
|
+
if (_StorageManager.isLocalStorageAvailable()) {
|
|
939
|
+
localStorage.setItem(`${ASGARDEO_SESSION_ACTIVE}`, status);
|
|
967
940
|
}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
expiresIn: parsedResponse.expires_in,
|
|
978
|
-
idToken: parsedResponse.id_token,
|
|
979
|
-
refreshToken: parsedResponse.refresh_token,
|
|
980
|
-
scope: parsedResponse.scope,
|
|
981
|
-
tokenType: parsedResponse.token_type
|
|
982
|
-
};
|
|
983
|
-
return Promise.resolve(tokenResponse2);
|
|
984
|
-
});
|
|
941
|
+
}
|
|
942
|
+
// eslint-disable-next-line class-methods-use-this
|
|
943
|
+
getSessionStatus() {
|
|
944
|
+
return _StorageManager.isLocalStorageAvailable() ? localStorage.getItem(`${ASGARDEO_SESSION_ACTIVE}`) ?? "" : "";
|
|
945
|
+
}
|
|
946
|
+
// eslint-disable-next-line class-methods-use-this
|
|
947
|
+
removeSessionStatus() {
|
|
948
|
+
if (_StorageManager.isLocalStorageAvailable()) {
|
|
949
|
+
localStorage.removeItem(`${ASGARDEO_SESSION_ACTIVE}`);
|
|
985
950
|
}
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
951
|
+
}
|
|
952
|
+
async removeConfigData() {
|
|
953
|
+
await this.store.removeData(this.resolveKey("config_data" /* ConfigData */));
|
|
954
|
+
}
|
|
955
|
+
async removeOIDCProviderMetaData() {
|
|
956
|
+
await this.store.removeData(this.resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */));
|
|
957
|
+
}
|
|
958
|
+
async removeTemporaryData(userId) {
|
|
959
|
+
await this.store.removeData(this.resolveKey("temporary_data" /* TemporaryData */, userId));
|
|
960
|
+
}
|
|
961
|
+
async removeSessionData(userId) {
|
|
962
|
+
await this.store.removeData(this.resolveKey("session_data" /* SessionData */, userId));
|
|
963
|
+
}
|
|
964
|
+
async getConfigDataParameter(key) {
|
|
965
|
+
const data = await this.store.getData(this.resolveKey("config_data" /* ConfigData */));
|
|
966
|
+
return data && JSON.parse(data)[key];
|
|
967
|
+
}
|
|
968
|
+
async getOIDCProviderMetaDataParameter(key) {
|
|
969
|
+
const data = await this.store.getData(this.resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */));
|
|
970
|
+
return data && JSON.parse(data)[key];
|
|
971
|
+
}
|
|
972
|
+
async getTemporaryDataParameter(key, userId) {
|
|
973
|
+
const data = await this.store.getData(this.resolveKey("temporary_data" /* TemporaryData */, userId));
|
|
974
|
+
return data && JSON.parse(data)[key];
|
|
975
|
+
}
|
|
976
|
+
async getSessionDataParameter(key, userId) {
|
|
977
|
+
const data = await this.store.getData(this.resolveKey("session_data" /* SessionData */, userId));
|
|
978
|
+
return data && JSON.parse(data)[key];
|
|
979
|
+
}
|
|
980
|
+
async setConfigDataParameter(key, value) {
|
|
981
|
+
await this.setValue(this.resolveKey("config_data" /* ConfigData */), key, value);
|
|
982
|
+
}
|
|
983
|
+
async setOIDCProviderMetaDataParameter(key, value) {
|
|
984
|
+
await this.setValue(this.resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), key, value);
|
|
985
|
+
}
|
|
986
|
+
async setTemporaryDataParameter(key, value, userId) {
|
|
987
|
+
await this.setValue(this.resolveKey("temporary_data" /* TemporaryData */, userId), key, value);
|
|
988
|
+
}
|
|
989
|
+
async setSessionDataParameter(key, value, userId) {
|
|
990
|
+
await this.setValue(this.resolveKey("session_data" /* SessionData */, userId), key, value);
|
|
991
|
+
}
|
|
992
|
+
async removeConfigDataParameter(key) {
|
|
993
|
+
await this.removeValue(this.resolveKey("config_data" /* ConfigData */), key);
|
|
994
|
+
}
|
|
995
|
+
async removeOIDCProviderMetaDataParameter(key) {
|
|
996
|
+
await this.removeValue(this.resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), key);
|
|
997
|
+
}
|
|
998
|
+
async removeTemporaryDataParameter(key, userId) {
|
|
999
|
+
await this.removeValue(this.resolveKey("temporary_data" /* TemporaryData */, userId), key);
|
|
1000
|
+
}
|
|
1001
|
+
async removeSessionDataParameter(key, userId) {
|
|
1002
|
+
await this.removeValue(this.resolveKey("session_data" /* SessionData */, userId), key);
|
|
997
1003
|
}
|
|
998
1004
|
};
|
|
1005
|
+
var StorageManager_default = StorageManager;
|
|
1006
|
+
|
|
1007
|
+
// src/utils/extractPkceStorageKeyFromState.ts
|
|
1008
|
+
var extractPkceStorageKeyFromState = (state) => {
|
|
1009
|
+
const index = parseInt(state.split("request_")[1], 10);
|
|
1010
|
+
return `${PKCEConstants_default.Storage.StorageKeys.CODE_VERIFIER}${PKCEConstants_default.Storage.StorageKeys.SEPARATOR}${index}`;
|
|
1011
|
+
};
|
|
1012
|
+
var extractPkceStorageKeyFromState_default = extractPkceStorageKeyFromState;
|
|
999
1013
|
|
|
1000
1014
|
// src/utils/generatePkceStorageKey.ts
|
|
1001
1015
|
var generatePkceStorageKey = (tempStore) => {
|
|
@@ -1006,21 +1020,21 @@ var generatePkceStorageKey = (tempStore) => {
|
|
|
1006
1020
|
}
|
|
1007
1021
|
});
|
|
1008
1022
|
const lastKey = keys.sort().pop();
|
|
1009
|
-
const index = parseInt(lastKey?.split(PKCEConstants_default.Storage.StorageKeys.SEPARATOR)[1] ?? "-1");
|
|
1023
|
+
const index = parseInt(lastKey?.split(PKCEConstants_default.Storage.StorageKeys.SEPARATOR)[1] ?? "-1", 10);
|
|
1010
1024
|
return `${PKCEConstants_default.Storage.StorageKeys.CODE_VERIFIER}${PKCEConstants_default.Storage.StorageKeys.SEPARATOR}${index + 1}`;
|
|
1011
1025
|
};
|
|
1012
1026
|
var generatePkceStorageKey_default = generatePkceStorageKey;
|
|
1013
1027
|
|
|
1014
1028
|
// src/utils/generateStateParamForRequestCorrelation.ts
|
|
1015
1029
|
var generateStateParamForRequestCorrelation = (pkceKey, state) => {
|
|
1016
|
-
const index = parseInt(pkceKey.split(PKCEConstants_default.Storage.StorageKeys.SEPARATOR)[1]);
|
|
1030
|
+
const index = parseInt(pkceKey.split(PKCEConstants_default.Storage.StorageKeys.SEPARATOR)[1], 10);
|
|
1017
1031
|
return state ? `${state}_request_${index}` : `request_${index}`;
|
|
1018
1032
|
};
|
|
1019
1033
|
var generateStateParamForRequestCorrelation_default = generateStateParamForRequestCorrelation;
|
|
1020
1034
|
|
|
1021
1035
|
// src/utils/getAuthorizeRequestUrlParams.ts
|
|
1022
1036
|
var getAuthorizeRequestUrlParams = (options, pkceOptions, customParams) => {
|
|
1023
|
-
const { redirectUri, clientId,
|
|
1037
|
+
const { redirectUri, clientId, scopes, responseMode, codeChallenge, codeChallengeMethod, prompt } = options;
|
|
1024
1038
|
const authorizeRequestParams = /* @__PURE__ */ new Map();
|
|
1025
1039
|
authorizeRequestParams.set("response_type", "code");
|
|
1026
1040
|
authorizeRequestParams.set("client_id", clientId);
|
|
@@ -1047,11 +1061,11 @@ var getAuthorizeRequestUrlParams = (options, pkceOptions, customParams) => {
|
|
|
1047
1061
|
authorizeRequestParams.set("prompt", prompt);
|
|
1048
1062
|
}
|
|
1049
1063
|
if (customParams) {
|
|
1050
|
-
|
|
1064
|
+
Object.entries(customParams).forEach(([key, value]) => {
|
|
1051
1065
|
if (key !== "" && value !== "" && key !== OIDCRequestConstants_default.Params.STATE) {
|
|
1052
1066
|
authorizeRequestParams.set(key, value.toString());
|
|
1053
1067
|
}
|
|
1054
|
-
}
|
|
1068
|
+
});
|
|
1055
1069
|
}
|
|
1056
1070
|
authorizeRequestParams.set(
|
|
1057
1071
|
OIDCRequestConstants_default.Params.STATE,
|
|
@@ -1066,16 +1080,16 @@ var getAuthorizeRequestUrlParams_default = getAuthorizeRequestUrlParams;
|
|
|
1066
1080
|
|
|
1067
1081
|
// src/__legacy__/client.ts
|
|
1068
1082
|
var DefaultConfig = {
|
|
1083
|
+
enablePKCE: true,
|
|
1084
|
+
responseMode: "query",
|
|
1085
|
+
sendCookiesInRequests: true,
|
|
1069
1086
|
tokenValidation: {
|
|
1070
1087
|
idToken: {
|
|
1088
|
+
clockTolerance: 300,
|
|
1071
1089
|
validate: true,
|
|
1072
|
-
validateIssuer: true
|
|
1073
|
-
clockTolerance: 300
|
|
1090
|
+
validateIssuer: true
|
|
1074
1091
|
}
|
|
1075
|
-
}
|
|
1076
|
-
enablePKCE: true,
|
|
1077
|
-
responseMode: "query",
|
|
1078
|
-
sendCookiesInRequests: true
|
|
1092
|
+
}
|
|
1079
1093
|
};
|
|
1080
1094
|
var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
1081
1095
|
/**
|
|
@@ -1094,12 +1108,12 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1094
1108
|
* @preserve
|
|
1095
1109
|
*/
|
|
1096
1110
|
constructor() {
|
|
1097
|
-
__publicField(this, "
|
|
1098
|
-
__publicField(this, "
|
|
1099
|
-
__publicField(this, "
|
|
1100
|
-
__publicField(this, "
|
|
1101
|
-
__publicField(this, "
|
|
1102
|
-
__publicField(this, "
|
|
1111
|
+
__publicField(this, "storageManager");
|
|
1112
|
+
__publicField(this, "configProvider");
|
|
1113
|
+
__publicField(this, "oidcProviderMetaDataProvider");
|
|
1114
|
+
__publicField(this, "authHelper");
|
|
1115
|
+
__publicField(this, "cryptoUtils");
|
|
1116
|
+
__publicField(this, "cryptoHelper");
|
|
1103
1117
|
}
|
|
1104
1118
|
/**
|
|
1105
1119
|
*
|
|
@@ -1120,28 +1134,28 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1120
1134
|
*
|
|
1121
1135
|
* @preserve
|
|
1122
1136
|
*/
|
|
1123
|
-
async initialize(config, store,
|
|
1124
|
-
const clientId = config
|
|
1125
|
-
if (!_AsgardeoAuthClient.
|
|
1126
|
-
_AsgardeoAuthClient.
|
|
1137
|
+
async initialize(config, store, inputCryptoUtils, instanceID) {
|
|
1138
|
+
const { clientId } = config;
|
|
1139
|
+
if (!_AsgardeoAuthClient.instanceIdValue) {
|
|
1140
|
+
_AsgardeoAuthClient.instanceIdValue = 0;
|
|
1127
1141
|
} else {
|
|
1128
|
-
_AsgardeoAuthClient.
|
|
1142
|
+
_AsgardeoAuthClient.instanceIdValue += 1;
|
|
1129
1143
|
}
|
|
1130
1144
|
if (instanceID) {
|
|
1131
|
-
_AsgardeoAuthClient.
|
|
1145
|
+
_AsgardeoAuthClient.instanceIdValue = instanceID;
|
|
1132
1146
|
}
|
|
1133
1147
|
if (!clientId) {
|
|
1134
|
-
this.
|
|
1148
|
+
this.storageManager = new StorageManager_default(`instance_${_AsgardeoAuthClient.instanceIdValue}`, store);
|
|
1135
1149
|
} else {
|
|
1136
|
-
this.
|
|
1150
|
+
this.storageManager = new StorageManager_default(`instance_${_AsgardeoAuthClient.instanceIdValue}-${clientId}`, store);
|
|
1137
1151
|
}
|
|
1138
|
-
this.
|
|
1139
|
-
this.
|
|
1140
|
-
this.
|
|
1141
|
-
this.
|
|
1142
|
-
this.
|
|
1143
|
-
_AsgardeoAuthClient.
|
|
1144
|
-
await this.
|
|
1152
|
+
this.cryptoUtils = inputCryptoUtils;
|
|
1153
|
+
this.cryptoHelper = new IsomorphicCrypto(inputCryptoUtils);
|
|
1154
|
+
this.authHelper = new AuthenticationHelper(this.storageManager, this.cryptoHelper);
|
|
1155
|
+
this.configProvider = async () => this.storageManager.getConfigData();
|
|
1156
|
+
this.oidcProviderMetaDataProvider = async () => this.storageManager.loadOpenIDProviderConfiguration();
|
|
1157
|
+
_AsgardeoAuthClient.authHelperInstance = this.authHelper;
|
|
1158
|
+
await this.storageManager.setConfigData({
|
|
1145
1159
|
...DefaultConfig,
|
|
1146
1160
|
...config,
|
|
1147
1161
|
scope: processOpenIDScopes_default(config.scopes)
|
|
@@ -1162,7 +1176,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1162
1176
|
* @preserve
|
|
1163
1177
|
*/
|
|
1164
1178
|
getStorageManager() {
|
|
1165
|
-
return this.
|
|
1179
|
+
return this.storageManager;
|
|
1166
1180
|
}
|
|
1167
1181
|
/**
|
|
1168
1182
|
* This method returns the `instanceID` variable of the given instance.
|
|
@@ -1176,8 +1190,9 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1176
1190
|
*
|
|
1177
1191
|
* @preserve
|
|
1178
1192
|
*/
|
|
1193
|
+
// eslint-disable-next-line class-methods-use-this
|
|
1179
1194
|
getInstanceId() {
|
|
1180
|
-
return _AsgardeoAuthClient.
|
|
1195
|
+
return _AsgardeoAuthClient.instanceIdValue;
|
|
1181
1196
|
}
|
|
1182
1197
|
/**
|
|
1183
1198
|
* This is an async method that returns a Promise that resolves with the authorization URL.
|
|
@@ -1205,8 +1220,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1205
1220
|
async getSignInUrl(requestConfig, userId) {
|
|
1206
1221
|
const authRequestConfig = { ...requestConfig };
|
|
1207
1222
|
delete authRequestConfig?.forceInit;
|
|
1208
|
-
const
|
|
1209
|
-
const authorizeEndpoint = await this.
|
|
1223
|
+
const buildSignInUrl = async () => {
|
|
1224
|
+
const authorizeEndpoint = await this.storageManager.getOIDCProviderMetaDataParameter(
|
|
1210
1225
|
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.AUTHORIZATION
|
|
1211
1226
|
);
|
|
1212
1227
|
if (!authorizeEndpoint || authorizeEndpoint.trim().length === 0) {
|
|
@@ -1217,45 +1232,43 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1217
1232
|
);
|
|
1218
1233
|
}
|
|
1219
1234
|
const authorizeRequest = new URL(authorizeEndpoint);
|
|
1220
|
-
const configData = await this.
|
|
1221
|
-
const tempStore = await this.
|
|
1235
|
+
const configData = await this.configProvider();
|
|
1236
|
+
const tempStore = await this.storageManager.getTemporaryData(userId);
|
|
1222
1237
|
const pkceKey = await generatePkceStorageKey_default(tempStore);
|
|
1223
1238
|
let codeVerifier;
|
|
1224
1239
|
let codeChallenge;
|
|
1225
1240
|
if (configData.enablePKCE) {
|
|
1226
|
-
codeVerifier = this.
|
|
1227
|
-
codeChallenge = this.
|
|
1228
|
-
await this.
|
|
1241
|
+
codeVerifier = this.cryptoHelper?.getCodeVerifier();
|
|
1242
|
+
codeChallenge = this.cryptoHelper?.getCodeChallenge(codeVerifier);
|
|
1243
|
+
await this.storageManager.setTemporaryDataParameter(pkceKey, codeVerifier, userId);
|
|
1229
1244
|
}
|
|
1230
1245
|
if (authRequestConfig["client_secret"]) {
|
|
1231
1246
|
authRequestConfig["client_secret"] = configData.clientSecret;
|
|
1232
1247
|
}
|
|
1233
1248
|
const authorizeRequestParams = getAuthorizeRequestUrlParams_default(
|
|
1234
1249
|
{
|
|
1235
|
-
redirectUri: configData.afterSignInUrl,
|
|
1236
1250
|
clientId: configData.clientId,
|
|
1237
|
-
scopes: processOpenIDScopes_default(configData.scopes),
|
|
1238
|
-
responseMode: configData.responseMode,
|
|
1239
|
-
codeChallengeMethod: PKCEConstants_default.DEFAULT_CODE_CHALLENGE_METHOD,
|
|
1240
1251
|
codeChallenge,
|
|
1241
|
-
|
|
1252
|
+
codeChallengeMethod: PKCEConstants_default.DEFAULT_CODE_CHALLENGE_METHOD,
|
|
1253
|
+
prompt: configData.prompt,
|
|
1254
|
+
redirectUri: configData.afterSignInUrl,
|
|
1255
|
+
responseMode: configData.responseMode,
|
|
1256
|
+
scopes: processOpenIDScopes_default(configData.scopes)
|
|
1242
1257
|
},
|
|
1243
1258
|
{ key: pkceKey },
|
|
1244
1259
|
authRequestConfig
|
|
1245
1260
|
);
|
|
1246
|
-
|
|
1247
|
-
authorizeRequest.searchParams.append(
|
|
1248
|
-
}
|
|
1261
|
+
Array.from(authorizeRequestParams.entries()).forEach(([paramKey, paramValue]) => {
|
|
1262
|
+
authorizeRequest.searchParams.append(paramKey, paramValue);
|
|
1263
|
+
});
|
|
1249
1264
|
return authorizeRequest.toString();
|
|
1250
1265
|
};
|
|
1251
|
-
if (await this.
|
|
1266
|
+
if (await this.storageManager.getTemporaryDataParameter(
|
|
1252
1267
|
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED
|
|
1253
1268
|
)) {
|
|
1254
|
-
return
|
|
1269
|
+
return buildSignInUrl();
|
|
1255
1270
|
}
|
|
1256
|
-
return this.loadOpenIDProviderConfiguration(requestConfig?.forceInit).then(() =>
|
|
1257
|
-
return __TODO__();
|
|
1258
|
-
});
|
|
1271
|
+
return this.loadOpenIDProviderConfiguration(requestConfig?.forceInit).then(() => buildSignInUrl());
|
|
1259
1272
|
}
|
|
1260
1273
|
/**
|
|
1261
1274
|
* This is an async method that sends a request to obtain the access token and returns a Promise
|
|
@@ -1283,9 +1296,9 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1283
1296
|
* @preserve
|
|
1284
1297
|
*/
|
|
1285
1298
|
async requestAccessToken(authorizationCode, sessionState, state, userId, tokenRequestConfig) {
|
|
1286
|
-
const
|
|
1287
|
-
const tokenEndpoint = (await this.
|
|
1288
|
-
const configData = await this.
|
|
1299
|
+
const performTokenRequest = async () => {
|
|
1300
|
+
const tokenEndpoint = (await this.oidcProviderMetaDataProvider()).token_endpoint;
|
|
1301
|
+
const configData = await this.configProvider();
|
|
1289
1302
|
if (!tokenEndpoint || tokenEndpoint.trim().length === 0) {
|
|
1290
1303
|
throw new AsgardeoAuthException(
|
|
1291
1304
|
"JS-AUTH_CORE-RAT1-NF01",
|
|
@@ -1293,11 +1306,13 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1293
1306
|
"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."
|
|
1294
1307
|
);
|
|
1295
1308
|
}
|
|
1296
|
-
sessionState
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1309
|
+
if (sessionState) {
|
|
1310
|
+
await this.storageManager.setSessionDataParameter(
|
|
1311
|
+
OIDCRequestConstants_default.Params.SESSION_STATE,
|
|
1312
|
+
sessionState,
|
|
1313
|
+
userId
|
|
1314
|
+
);
|
|
1315
|
+
}
|
|
1301
1316
|
const body = new URLSearchParams();
|
|
1302
1317
|
body.set("client_id", configData.clientId);
|
|
1303
1318
|
if (configData.clientSecret && configData.clientSecret.trim().length > 0) {
|
|
@@ -1315,9 +1330,9 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1315
1330
|
if (configData.enablePKCE) {
|
|
1316
1331
|
body.set(
|
|
1317
1332
|
"code_verifier",
|
|
1318
|
-
`${await this.
|
|
1333
|
+
`${await this.storageManager.getTemporaryDataParameter(extractPkceStorageKeyFromState_default(state), userId)}`
|
|
1319
1334
|
);
|
|
1320
|
-
await this.
|
|
1335
|
+
await this.storageManager.removeTemporaryDataParameter(extractPkceStorageKeyFromState_default(state), userId);
|
|
1321
1336
|
}
|
|
1322
1337
|
let tokenResponse;
|
|
1323
1338
|
try {
|
|
@@ -1344,25 +1359,23 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1344
1359
|
await tokenResponse.json()
|
|
1345
1360
|
);
|
|
1346
1361
|
}
|
|
1347
|
-
return
|
|
1362
|
+
return this.authHelper.handleTokenResponse(tokenResponse, userId);
|
|
1348
1363
|
};
|
|
1349
|
-
if (await this.
|
|
1364
|
+
if (await this.storageManager.getTemporaryDataParameter(
|
|
1350
1365
|
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED
|
|
1351
1366
|
)) {
|
|
1352
|
-
return
|
|
1367
|
+
return performTokenRequest();
|
|
1353
1368
|
}
|
|
1354
|
-
return this.loadOpenIDProviderConfiguration(false).then(() =>
|
|
1355
|
-
return __TODO__();
|
|
1356
|
-
});
|
|
1369
|
+
return this.loadOpenIDProviderConfiguration(false).then(() => performTokenRequest());
|
|
1357
1370
|
}
|
|
1358
1371
|
async loadOpenIDProviderConfiguration(forceInit) {
|
|
1359
|
-
const configData = await this.
|
|
1360
|
-
if (!forceInit && await this.
|
|
1372
|
+
const configData = await this.configProvider();
|
|
1373
|
+
if (!forceInit && await this.storageManager.getTemporaryDataParameter(
|
|
1361
1374
|
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED
|
|
1362
1375
|
)) {
|
|
1363
1376
|
return Promise.resolve();
|
|
1364
1377
|
}
|
|
1365
|
-
const wellKnownEndpoint = configData
|
|
1378
|
+
const { wellKnownEndpoint } = configData;
|
|
1366
1379
|
if (wellKnownEndpoint) {
|
|
1367
1380
|
let response;
|
|
1368
1381
|
try {
|
|
@@ -1377,19 +1390,16 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1377
1390
|
"The well known endpoint response has been failed with an error."
|
|
1378
1391
|
);
|
|
1379
1392
|
}
|
|
1380
|
-
await this.
|
|
1381
|
-
|
|
1382
|
-
);
|
|
1383
|
-
await this._storageManager.setTemporaryDataParameter(
|
|
1393
|
+
await this.storageManager.setOIDCProviderMetaData(await this.authHelper.resolveEndpoints(await response.json()));
|
|
1394
|
+
await this.storageManager.setTemporaryDataParameter(
|
|
1384
1395
|
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,
|
|
1385
1396
|
true
|
|
1386
1397
|
);
|
|
1387
1398
|
return Promise.resolve();
|
|
1388
|
-
}
|
|
1399
|
+
}
|
|
1400
|
+
if (configData.baseUrl) {
|
|
1389
1401
|
try {
|
|
1390
|
-
await this.
|
|
1391
|
-
await this._authenticationHelper.resolveEndpointsByBaseURL()
|
|
1392
|
-
);
|
|
1402
|
+
await this.storageManager.setOIDCProviderMetaData(await this.authHelper.resolveEndpointsByBaseURL());
|
|
1393
1403
|
} catch (error2) {
|
|
1394
1404
|
throw new AsgardeoAuthException(
|
|
1395
1405
|
"JS-AUTH_CORE-GOPMD-IV02",
|
|
@@ -1397,19 +1407,18 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1397
1407
|
error2 ?? "Resolving endpoints by base url failed."
|
|
1398
1408
|
);
|
|
1399
1409
|
}
|
|
1400
|
-
await this.
|
|
1401
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,
|
|
1402
|
-
true
|
|
1403
|
-
);
|
|
1404
|
-
return Promise.resolve();
|
|
1405
|
-
} else {
|
|
1406
|
-
await this._storageManager.setOIDCProviderMetaData(await this._authenticationHelper.resolveEndpointsExplicitly());
|
|
1407
|
-
await this._storageManager.setTemporaryDataParameter(
|
|
1410
|
+
await this.storageManager.setTemporaryDataParameter(
|
|
1408
1411
|
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,
|
|
1409
1412
|
true
|
|
1410
1413
|
);
|
|
1411
1414
|
return Promise.resolve();
|
|
1412
1415
|
}
|
|
1416
|
+
await this.storageManager.setOIDCProviderMetaData(await this.authHelper.resolveEndpointsExplicitly());
|
|
1417
|
+
await this.storageManager.setTemporaryDataParameter(
|
|
1418
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,
|
|
1419
|
+
true
|
|
1420
|
+
);
|
|
1421
|
+
return Promise.resolve();
|
|
1413
1422
|
}
|
|
1414
1423
|
/**
|
|
1415
1424
|
* This method returns the sign-out URL.
|
|
@@ -1431,8 +1440,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1431
1440
|
* @preserve
|
|
1432
1441
|
*/
|
|
1433
1442
|
async getSignOutUrl(userId) {
|
|
1434
|
-
const logoutEndpoint = (await this.
|
|
1435
|
-
const configData = await this.
|
|
1443
|
+
const logoutEndpoint = (await this.oidcProviderMetaDataProvider())?.end_session_endpoint;
|
|
1444
|
+
const configData = await this.configProvider();
|
|
1436
1445
|
if (!logoutEndpoint || logoutEndpoint.trim().length === 0) {
|
|
1437
1446
|
throw new AsgardeoAuthException(
|
|
1438
1447
|
"JS-AUTH_CORE-GSOU-NF01",
|
|
@@ -1451,7 +1460,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1451
1460
|
const queryParams = new URLSearchParams();
|
|
1452
1461
|
queryParams.set("post_logout_redirect_uri", callbackURL);
|
|
1453
1462
|
if (configData.sendIdTokenInLogoutRequest) {
|
|
1454
|
-
const idToken = (await this.
|
|
1463
|
+
const idToken = (await this.storageManager.getSessionData(userId))?.id_token;
|
|
1455
1464
|
if (!idToken || idToken.trim().length === 0) {
|
|
1456
1465
|
throw new AsgardeoAuthException(
|
|
1457
1466
|
"JS-AUTH_CORE-GSOU-NF02",
|
|
@@ -1481,7 +1490,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1481
1490
|
* @preserve
|
|
1482
1491
|
*/
|
|
1483
1492
|
async getOpenIDProviderEndpoints() {
|
|
1484
|
-
const oidcProviderMetaData = await this.
|
|
1493
|
+
const oidcProviderMetaData = await this.oidcProviderMetaDataProvider();
|
|
1485
1494
|
return {
|
|
1486
1495
|
authorizationEndpoint: oidcProviderMetaData.authorization_endpoint ?? "",
|
|
1487
1496
|
checkSessionIframe: oidcProviderMetaData.check_session_iframe ?? "",
|
|
@@ -1507,7 +1516,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1507
1516
|
* ```
|
|
1508
1517
|
*/
|
|
1509
1518
|
async decodeJwtToken(token) {
|
|
1510
|
-
return this.
|
|
1519
|
+
return this.cryptoHelper.decodeJwtToken(token);
|
|
1511
1520
|
}
|
|
1512
1521
|
/**
|
|
1513
1522
|
* This method decodes the payload of the ID token and returns it.
|
|
@@ -1527,8 +1536,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1527
1536
|
* @preserve
|
|
1528
1537
|
*/
|
|
1529
1538
|
async getDecodedIdToken(userId, idToken) {
|
|
1530
|
-
const
|
|
1531
|
-
const payload = this.
|
|
1539
|
+
const storedIdToken = (await this.storageManager.getSessionData(userId)).id_token;
|
|
1540
|
+
const payload = this.cryptoHelper.decodeJwtToken(storedIdToken ?? idToken);
|
|
1532
1541
|
return payload;
|
|
1533
1542
|
}
|
|
1534
1543
|
/**
|
|
@@ -1549,7 +1558,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1549
1558
|
* @preserve
|
|
1550
1559
|
*/
|
|
1551
1560
|
async getIdToken(userId) {
|
|
1552
|
-
return (await this.
|
|
1561
|
+
return (await this.storageManager.getSessionData(userId)).id_token;
|
|
1553
1562
|
}
|
|
1554
1563
|
/**
|
|
1555
1564
|
* This method returns the basic user information obtained from the ID token.
|
|
@@ -1569,8 +1578,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1569
1578
|
* @preserve
|
|
1570
1579
|
*/
|
|
1571
1580
|
async getUser(userId) {
|
|
1572
|
-
const sessionData = await this.
|
|
1573
|
-
const authenticatedUser = this.
|
|
1581
|
+
const sessionData = await this.storageManager.getSessionData(userId);
|
|
1582
|
+
const authenticatedUser = this.authHelper.getAuthenticatedUserInfo(sessionData?.id_token);
|
|
1574
1583
|
Object.keys(authenticatedUser).forEach((key) => {
|
|
1575
1584
|
if (authenticatedUser[key] === void 0 || authenticatedUser[key] === "" || authenticatedUser[key] === null) {
|
|
1576
1585
|
delete authenticatedUser[key];
|
|
@@ -1579,7 +1588,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1579
1588
|
return authenticatedUser;
|
|
1580
1589
|
}
|
|
1581
1590
|
async getUserSession(userId) {
|
|
1582
|
-
const sessionData = await this.
|
|
1591
|
+
const sessionData = await this.storageManager.getSessionData(userId);
|
|
1583
1592
|
return {
|
|
1584
1593
|
scopes: sessionData?.scope?.split(" "),
|
|
1585
1594
|
sessionState: sessionData?.session_state ?? ""
|
|
@@ -1600,7 +1609,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1600
1609
|
* @preserve
|
|
1601
1610
|
*/
|
|
1602
1611
|
async getCrypto() {
|
|
1603
|
-
return this.
|
|
1612
|
+
return this.cryptoHelper;
|
|
1604
1613
|
}
|
|
1605
1614
|
/**
|
|
1606
1615
|
* This method revokes the access token.
|
|
@@ -1626,8 +1635,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1626
1635
|
* @preserve
|
|
1627
1636
|
*/
|
|
1628
1637
|
async revokeAccessToken(userId) {
|
|
1629
|
-
const revokeTokenEndpoint = (await this.
|
|
1630
|
-
const configData = await this.
|
|
1638
|
+
const revokeTokenEndpoint = (await this.oidcProviderMetaDataProvider()).revocation_endpoint;
|
|
1639
|
+
const configData = await this.configProvider();
|
|
1631
1640
|
if (!revokeTokenEndpoint || revokeTokenEndpoint.trim().length === 0) {
|
|
1632
1641
|
throw new AsgardeoAuthException(
|
|
1633
1642
|
"JS-AUTH_CORE-RAT3-NF01",
|
|
@@ -1637,7 +1646,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1637
1646
|
}
|
|
1638
1647
|
const body = [];
|
|
1639
1648
|
body.push(`client_id=${configData.clientId}`);
|
|
1640
|
-
body.push(`token=${(await this.
|
|
1649
|
+
body.push(`token=${(await this.storageManager.getSessionData(userId)).access_token}`);
|
|
1641
1650
|
body.push("token_type_hint=access_token");
|
|
1642
1651
|
if (configData.clientSecret && configData.clientSecret.trim().length > 0) {
|
|
1643
1652
|
body.push(`client_secret=${configData.clientSecret}`);
|
|
@@ -1667,7 +1676,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1667
1676
|
await response.json()
|
|
1668
1677
|
);
|
|
1669
1678
|
}
|
|
1670
|
-
this.
|
|
1679
|
+
this.authHelper.clearSession(userId);
|
|
1671
1680
|
return Promise.resolve(response);
|
|
1672
1681
|
}
|
|
1673
1682
|
/**
|
|
@@ -1693,9 +1702,9 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1693
1702
|
* @preserve
|
|
1694
1703
|
*/
|
|
1695
1704
|
async refreshAccessToken(userId) {
|
|
1696
|
-
const tokenEndpoint = (await this.
|
|
1697
|
-
const configData = await this.
|
|
1698
|
-
const sessionData = await this.
|
|
1705
|
+
const tokenEndpoint = (await this.oidcProviderMetaDataProvider()).token_endpoint;
|
|
1706
|
+
const configData = await this.configProvider();
|
|
1707
|
+
const sessionData = await this.storageManager.getSessionData(userId);
|
|
1699
1708
|
if (!sessionData.refresh_token) {
|
|
1700
1709
|
throw new AsgardeoAuthException(
|
|
1701
1710
|
"JS-AUTH_CORE-RAT2-NF01",
|
|
@@ -1742,7 +1751,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1742
1751
|
await tokenResponse.json()
|
|
1743
1752
|
);
|
|
1744
1753
|
}
|
|
1745
|
-
return this.
|
|
1754
|
+
return this.authHelper.handleTokenResponse(tokenResponse, userId);
|
|
1746
1755
|
}
|
|
1747
1756
|
/**
|
|
1748
1757
|
* This method returns the access token.
|
|
@@ -1762,7 +1771,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1762
1771
|
* @preserve
|
|
1763
1772
|
*/
|
|
1764
1773
|
async getAccessToken(userId) {
|
|
1765
|
-
return (await this.
|
|
1774
|
+
return (await this.storageManager.getSessionData(userId))?.access_token;
|
|
1766
1775
|
}
|
|
1767
1776
|
/**
|
|
1768
1777
|
* This method sends a custom-grant request and returns a Promise that resolves with the response
|
|
@@ -1803,8 +1812,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1803
1812
|
* @preserve
|
|
1804
1813
|
*/
|
|
1805
1814
|
async exchangeToken(config, userId) {
|
|
1806
|
-
const oidcProviderMetadata = await this.
|
|
1807
|
-
const configData = await this.
|
|
1815
|
+
const oidcProviderMetadata = await this.oidcProviderMetaDataProvider();
|
|
1816
|
+
const configData = await this.configProvider();
|
|
1808
1817
|
let tokenEndpoint;
|
|
1809
1818
|
if (config.tokenEndpoint && config.tokenEndpoint.trim().length !== 0) {
|
|
1810
1819
|
tokenEndpoint = config.tokenEndpoint;
|
|
@@ -1820,10 +1829,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1820
1829
|
}
|
|
1821
1830
|
const data = await Promise.all(
|
|
1822
1831
|
Object.entries(config.data).map(async ([key, value]) => {
|
|
1823
|
-
const newValue = await this.
|
|
1824
|
-
value,
|
|
1825
|
-
userId
|
|
1826
|
-
);
|
|
1832
|
+
const newValue = await this.authHelper.replaceCustomGrantTemplateTags(value, userId);
|
|
1827
1833
|
return `${key}=${newValue}`;
|
|
1828
1834
|
})
|
|
1829
1835
|
);
|
|
@@ -1834,7 +1840,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1834
1840
|
if (config.attachToken) {
|
|
1835
1841
|
requestHeaders = {
|
|
1836
1842
|
...requestHeaders,
|
|
1837
|
-
Authorization: `Bearer ${(await this.
|
|
1843
|
+
Authorization: `Bearer ${(await this.storageManager.getSessionData(userId)).access_token}`
|
|
1838
1844
|
};
|
|
1839
1845
|
}
|
|
1840
1846
|
const requestConfig = {
|
|
@@ -1861,10 +1867,9 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1861
1867
|
);
|
|
1862
1868
|
}
|
|
1863
1869
|
if (config.returnsSession) {
|
|
1864
|
-
return this.
|
|
1865
|
-
} else {
|
|
1866
|
-
return Promise.resolve(await response.json());
|
|
1870
|
+
return this.authHelper.handleTokenResponse(response, userId);
|
|
1867
1871
|
}
|
|
1872
|
+
return Promise.resolve(await response.json());
|
|
1868
1873
|
}
|
|
1869
1874
|
/**
|
|
1870
1875
|
* This method returns if the user is authenticated or not.
|
|
@@ -1885,12 +1890,12 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1885
1890
|
*/
|
|
1886
1891
|
async isSignedIn(userId) {
|
|
1887
1892
|
const isAccessTokenAvailable = Boolean(await this.getAccessToken(userId));
|
|
1888
|
-
const createdAt = (await this.
|
|
1889
|
-
const expiresInString = (await this.
|
|
1893
|
+
const createdAt = (await this.storageManager.getSessionData(userId))?.created_at;
|
|
1894
|
+
const expiresInString = (await this.storageManager.getSessionData(userId))?.expires_in;
|
|
1890
1895
|
if (!expiresInString) {
|
|
1891
1896
|
return false;
|
|
1892
1897
|
}
|
|
1893
|
-
const expiresIn = parseInt(expiresInString) * 1e3;
|
|
1898
|
+
const expiresIn = parseInt(expiresInString, 10) * 1e3;
|
|
1894
1899
|
const currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
1895
1900
|
const isAccessTokenValid = createdAt + expiresIn > currentTime;
|
|
1896
1901
|
const isSignedIn = isAccessTokenAvailable && isAccessTokenValid;
|
|
@@ -1915,7 +1920,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1915
1920
|
* @preserve
|
|
1916
1921
|
*/
|
|
1917
1922
|
async getPKCECode(state, userId) {
|
|
1918
|
-
return await this.
|
|
1923
|
+
return await this.storageManager.getTemporaryDataParameter(
|
|
1919
1924
|
extractPkceStorageKeyFromState_default(state),
|
|
1920
1925
|
userId
|
|
1921
1926
|
);
|
|
@@ -1938,7 +1943,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1938
1943
|
* @preserve
|
|
1939
1944
|
*/
|
|
1940
1945
|
async setPKCECode(pkce, state, userId) {
|
|
1941
|
-
return
|
|
1946
|
+
return this.storageManager.setTemporaryDataParameter(extractPkceStorageKeyFromState_default(state), pkce, userId);
|
|
1942
1947
|
}
|
|
1943
1948
|
/**
|
|
1944
1949
|
* This method returns if the sign-out is successful or not.
|
|
@@ -2000,17 +2005,17 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
2000
2005
|
* @preserve
|
|
2001
2006
|
*/
|
|
2002
2007
|
async reInitialize(config) {
|
|
2003
|
-
await this.
|
|
2008
|
+
await this.storageManager.setConfigData(config);
|
|
2004
2009
|
await this.loadOpenIDProviderConfiguration(true);
|
|
2005
2010
|
}
|
|
2006
2011
|
static async clearSession(userId) {
|
|
2007
|
-
await this.
|
|
2012
|
+
await this.authHelperInstance.clearSession(userId);
|
|
2008
2013
|
}
|
|
2009
2014
|
};
|
|
2010
|
-
__publicField(_AsgardeoAuthClient, "
|
|
2015
|
+
__publicField(_AsgardeoAuthClient, "instanceIdValue");
|
|
2011
2016
|
// FIXME: Validate this.
|
|
2012
2017
|
// Ref: https://github.com/asgardeo/asgardeo-auth-js-core/pull/205
|
|
2013
|
-
__publicField(_AsgardeoAuthClient, "
|
|
2018
|
+
__publicField(_AsgardeoAuthClient, "authHelperInstance");
|
|
2014
2019
|
var AsgardeoAuthClient = _AsgardeoAuthClient;
|
|
2015
2020
|
|
|
2016
2021
|
// src/errors/AsgardeoAPIError.ts
|
|
@@ -2030,8 +2035,8 @@ var AsgardeoAPIError = class extends AsgardeoError {
|
|
|
2030
2035
|
this.statusCode = statusCode;
|
|
2031
2036
|
this.statusText = statusText;
|
|
2032
2037
|
Object.defineProperty(this, "name", {
|
|
2033
|
-
value: "AsgardeoAPIError",
|
|
2034
2038
|
configurable: true,
|
|
2039
|
+
value: "AsgardeoAPIError",
|
|
2035
2040
|
writable: true
|
|
2036
2041
|
});
|
|
2037
2042
|
}
|
|
@@ -2082,13 +2087,13 @@ var initializeEmbeddedSignInFlow = async ({
|
|
|
2082
2087
|
try {
|
|
2083
2088
|
const response = await fetch(url ?? `${baseUrl}/oauth2/authorize`, {
|
|
2084
2089
|
...requestConfig,
|
|
2085
|
-
|
|
2090
|
+
body: searchParams.toString(),
|
|
2086
2091
|
headers: {
|
|
2087
2092
|
...requestConfig.headers,
|
|
2088
|
-
|
|
2089
|
-
|
|
2093
|
+
Accept: "application/json",
|
|
2094
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
2090
2095
|
},
|
|
2091
|
-
|
|
2096
|
+
method: requestConfig.method || "POST"
|
|
2092
2097
|
});
|
|
2093
2098
|
if (!response.ok) {
|
|
2094
2099
|
const errorText = await response.text();
|
|
@@ -2146,13 +2151,13 @@ var executeEmbeddedSignInFlow = async ({
|
|
|
2146
2151
|
try {
|
|
2147
2152
|
const response = await fetch(url ?? `${baseUrl}/oauth2/authn`, {
|
|
2148
2153
|
...requestConfig,
|
|
2149
|
-
|
|
2154
|
+
body: JSON.stringify(payload),
|
|
2150
2155
|
headers: {
|
|
2151
|
-
"Content-Type": "application/json",
|
|
2152
2156
|
Accept: "application/json",
|
|
2157
|
+
"Content-Type": "application/json",
|
|
2153
2158
|
...requestConfig.headers
|
|
2154
2159
|
},
|
|
2155
|
-
|
|
2160
|
+
method: requestConfig.method || "POST"
|
|
2156
2161
|
});
|
|
2157
2162
|
if (!response.ok) {
|
|
2158
2163
|
const errorText = await response.text();
|
|
@@ -2240,16 +2245,16 @@ var executeEmbeddedSignUpFlow = async ({
|
|
|
2240
2245
|
try {
|
|
2241
2246
|
const response = await fetch(url ?? `${baseUrl}/api/server/v1/flow/execute`, {
|
|
2242
2247
|
...requestConfig,
|
|
2243
|
-
method: requestConfig.method || "POST",
|
|
2244
|
-
headers: {
|
|
2245
|
-
"Content-Type": "application/json",
|
|
2246
|
-
Accept: "application/json",
|
|
2247
|
-
...requestConfig.headers
|
|
2248
|
-
},
|
|
2249
2248
|
body: JSON.stringify({
|
|
2250
2249
|
...payload ?? {},
|
|
2251
2250
|
flowType: "REGISTRATION" /* Registration */
|
|
2252
|
-
})
|
|
2251
|
+
}),
|
|
2252
|
+
headers: {
|
|
2253
|
+
Accept: "application/json",
|
|
2254
|
+
"Content-Type": "application/json",
|
|
2255
|
+
...requestConfig.headers
|
|
2256
|
+
},
|
|
2257
|
+
method: requestConfig.method || "POST"
|
|
2253
2258
|
});
|
|
2254
2259
|
if (!response.ok) {
|
|
2255
2260
|
const errorText = await response.text();
|
|
@@ -2293,12 +2298,12 @@ var getUserInfo = async ({ url, ...requestConfig }) => {
|
|
|
2293
2298
|
try {
|
|
2294
2299
|
const response = await fetch(url, {
|
|
2295
2300
|
...requestConfig,
|
|
2296
|
-
method: "GET",
|
|
2297
2301
|
headers: {
|
|
2298
|
-
"Content-Type": "application/json",
|
|
2299
2302
|
Accept: "application/json",
|
|
2303
|
+
"Content-Type": "application/json",
|
|
2300
2304
|
...requestConfig.headers
|
|
2301
|
-
}
|
|
2305
|
+
},
|
|
2306
|
+
method: "GET"
|
|
2302
2307
|
});
|
|
2303
2308
|
if (!response.ok) {
|
|
2304
2309
|
const errorText = await response.text();
|
|
@@ -2369,12 +2374,12 @@ var getScim2Me = async ({ url, baseUrl, fetcher, ...requestConfig }) => {
|
|
|
2369
2374
|
const resolvedUrl = url ?? `${baseUrl}/scim2/Me`;
|
|
2370
2375
|
const requestInit = {
|
|
2371
2376
|
...requestConfig,
|
|
2372
|
-
method: "GET",
|
|
2373
2377
|
headers: {
|
|
2374
|
-
"Content-Type": "application/scim+json",
|
|
2375
2378
|
Accept: "application/json",
|
|
2379
|
+
"Content-Type": "application/scim+json",
|
|
2376
2380
|
...requestConfig.headers
|
|
2377
|
-
}
|
|
2381
|
+
},
|
|
2382
|
+
method: "GET"
|
|
2378
2383
|
};
|
|
2379
2384
|
try {
|
|
2380
2385
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2422,12 +2427,12 @@ var getSchemas = async ({ url, baseUrl, fetcher, ...requestConfig }) => {
|
|
|
2422
2427
|
const resolvedUrl = url ?? `${baseUrl}/scim2/Schemas`;
|
|
2423
2428
|
const requestInit = {
|
|
2424
2429
|
...requestConfig,
|
|
2425
|
-
method: "GET",
|
|
2426
2430
|
headers: {
|
|
2427
|
-
"Content-Type": "application/json",
|
|
2428
2431
|
Accept: "application/json",
|
|
2432
|
+
"Content-Type": "application/json",
|
|
2429
2433
|
...requestConfig.headers
|
|
2430
|
-
}
|
|
2434
|
+
},
|
|
2435
|
+
method: "GET"
|
|
2431
2436
|
};
|
|
2432
2437
|
try {
|
|
2433
2438
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2490,12 +2495,12 @@ var getAllOrganizations = async ({
|
|
|
2490
2495
|
const resolvedUrl = `${baseUrl}/api/server/v1/organizations?${queryParams.toString()}`;
|
|
2491
2496
|
const requestInit = {
|
|
2492
2497
|
...requestConfig,
|
|
2493
|
-
method: "GET",
|
|
2494
2498
|
headers: {
|
|
2495
2499
|
...requestConfig.headers,
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
}
|
|
2500
|
+
Accept: "application/json",
|
|
2501
|
+
"Content-Type": "application/json"
|
|
2502
|
+
},
|
|
2503
|
+
method: "GET"
|
|
2499
2504
|
};
|
|
2500
2505
|
try {
|
|
2501
2506
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2566,13 +2571,13 @@ var createOrganization = async ({
|
|
|
2566
2571
|
const resolvedUrl = `${baseUrl}/api/server/v1/organizations`;
|
|
2567
2572
|
const requestInit = {
|
|
2568
2573
|
...requestConfig,
|
|
2569
|
-
|
|
2574
|
+
body: JSON.stringify(organizationPayload),
|
|
2570
2575
|
headers: {
|
|
2571
|
-
"Content-Type": "application/json",
|
|
2572
2576
|
Accept: "application/json",
|
|
2577
|
+
"Content-Type": "application/json",
|
|
2573
2578
|
...requestConfig.headers
|
|
2574
2579
|
},
|
|
2575
|
-
|
|
2580
|
+
method: "POST"
|
|
2576
2581
|
};
|
|
2577
2582
|
try {
|
|
2578
2583
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2641,12 +2646,12 @@ var getMeOrganizations = async ({
|
|
|
2641
2646
|
const resolvedUrl = `${baseUrl}/api/users/v1/me/organizations?${queryParams.toString()}`;
|
|
2642
2647
|
const requestInit = {
|
|
2643
2648
|
...requestConfig,
|
|
2644
|
-
method: "GET",
|
|
2645
2649
|
headers: {
|
|
2646
|
-
"Content-Type": "application/json",
|
|
2647
2650
|
Accept: "application/json",
|
|
2651
|
+
"Content-Type": "application/json",
|
|
2648
2652
|
...requestConfig.headers
|
|
2649
|
-
}
|
|
2653
|
+
},
|
|
2654
|
+
method: "GET"
|
|
2650
2655
|
};
|
|
2651
2656
|
try {
|
|
2652
2657
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2661,7 +2666,7 @@ var getMeOrganizations = async ({
|
|
|
2661
2666
|
);
|
|
2662
2667
|
}
|
|
2663
2668
|
const data = await response.json();
|
|
2664
|
-
return data
|
|
2669
|
+
return data["organizations"] || [];
|
|
2665
2670
|
} catch (error2) {
|
|
2666
2671
|
if (error2 instanceof AsgardeoAPIError) {
|
|
2667
2672
|
throw error2;
|
|
@@ -2708,12 +2713,12 @@ var getOrganization = async ({
|
|
|
2708
2713
|
const resolvedUrl = `${baseUrl}/api/server/v1/organizations/${organizationId}`;
|
|
2709
2714
|
const requestInit = {
|
|
2710
2715
|
...requestConfig,
|
|
2711
|
-
method: "GET",
|
|
2712
2716
|
headers: {
|
|
2713
|
-
"Content-Type": "application/json",
|
|
2714
2717
|
Accept: "application/json",
|
|
2718
|
+
"Content-Type": "application/json",
|
|
2715
2719
|
...requestConfig.headers
|
|
2716
|
-
}
|
|
2720
|
+
},
|
|
2721
|
+
method: "GET"
|
|
2717
2722
|
};
|
|
2718
2723
|
try {
|
|
2719
2724
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2802,13 +2807,13 @@ var updateOrganization = async ({
|
|
|
2802
2807
|
const resolvedUrl = `${baseUrl}/api/server/v1/organizations/${organizationId}`;
|
|
2803
2808
|
const requestInit = {
|
|
2804
2809
|
...requestConfig,
|
|
2805
|
-
|
|
2810
|
+
body: JSON.stringify(operations),
|
|
2806
2811
|
headers: {
|
|
2807
|
-
"Content-Type": "application/json",
|
|
2808
2812
|
Accept: "application/json",
|
|
2813
|
+
"Content-Type": "application/json",
|
|
2809
2814
|
...requestConfig.headers
|
|
2810
2815
|
},
|
|
2811
|
-
|
|
2816
|
+
method: "PATCH"
|
|
2812
2817
|
};
|
|
2813
2818
|
try {
|
|
2814
2819
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2836,21 +2841,19 @@ var updateOrganization = async ({
|
|
|
2836
2841
|
);
|
|
2837
2842
|
}
|
|
2838
2843
|
};
|
|
2839
|
-
var createPatchOperations = (payload) => {
|
|
2840
|
-
|
|
2841
|
-
if (isEmpty_default(value)) {
|
|
2842
|
-
return {
|
|
2843
|
-
operation: "REMOVE",
|
|
2844
|
-
path: `/${key}`
|
|
2845
|
-
};
|
|
2846
|
-
}
|
|
2844
|
+
var createPatchOperations = (payload) => Object.entries(payload).map(([key, value]) => {
|
|
2845
|
+
if (isEmpty_default(value)) {
|
|
2847
2846
|
return {
|
|
2848
|
-
operation: "
|
|
2849
|
-
path: `/${key}
|
|
2850
|
-
value
|
|
2847
|
+
operation: "REMOVE",
|
|
2848
|
+
path: `/${key}`
|
|
2851
2849
|
};
|
|
2852
|
-
}
|
|
2853
|
-
|
|
2850
|
+
}
|
|
2851
|
+
return {
|
|
2852
|
+
operation: "REPLACE",
|
|
2853
|
+
path: `/${key}`,
|
|
2854
|
+
value
|
|
2855
|
+
};
|
|
2856
|
+
});
|
|
2854
2857
|
var updateOrganization_default = updateOrganization;
|
|
2855
2858
|
|
|
2856
2859
|
// src/api/updateMeProfile.ts
|
|
@@ -2886,12 +2889,12 @@ var updateMeProfile = async ({
|
|
|
2886
2889
|
const requestInit = {
|
|
2887
2890
|
method: "PATCH",
|
|
2888
2891
|
...requestConfig,
|
|
2892
|
+
body: JSON.stringify(data),
|
|
2889
2893
|
headers: {
|
|
2890
2894
|
...requestConfig.headers,
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
}
|
|
2894
|
-
body: JSON.stringify(data)
|
|
2895
|
+
Accept: "application/json",
|
|
2896
|
+
"Content-Type": "application/scim+json"
|
|
2897
|
+
}
|
|
2895
2898
|
};
|
|
2896
2899
|
try {
|
|
2897
2900
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2954,12 +2957,12 @@ var getBrandingPreference = async ({
|
|
|
2954
2957
|
const resolvedUrl = `${baseUrl}/api/server/v1/branding-preference/resolve${queryParams.toString() ? `?${queryParams.toString()}` : ""}`;
|
|
2955
2958
|
const requestInit = {
|
|
2956
2959
|
...requestConfig,
|
|
2957
|
-
method: "GET",
|
|
2958
2960
|
headers: {
|
|
2959
|
-
"Content-Type": "application/json",
|
|
2960
2961
|
Accept: "application/json",
|
|
2962
|
+
"Content-Type": "application/json",
|
|
2961
2963
|
...requestConfig.headers
|
|
2962
|
-
}
|
|
2964
|
+
},
|
|
2965
|
+
method: "GET"
|
|
2963
2966
|
};
|
|
2964
2967
|
try {
|
|
2965
2968
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2993,8 +2996,8 @@ var getBrandingPreference_default = getBrandingPreference;
|
|
|
2993
2996
|
// src/models/v2/embedded-signin-flow-v2.ts
|
|
2994
2997
|
var EmbeddedSignInFlowStatus = /* @__PURE__ */ ((EmbeddedSignInFlowStatus3) => {
|
|
2995
2998
|
EmbeddedSignInFlowStatus3["Complete"] = "COMPLETE";
|
|
2996
|
-
EmbeddedSignInFlowStatus3["Incomplete"] = "INCOMPLETE";
|
|
2997
2999
|
EmbeddedSignInFlowStatus3["Error"] = "ERROR";
|
|
3000
|
+
EmbeddedSignInFlowStatus3["Incomplete"] = "INCOMPLETE";
|
|
2998
3001
|
return EmbeddedSignInFlowStatus3;
|
|
2999
3002
|
})(EmbeddedSignInFlowStatus || {});
|
|
3000
3003
|
var EmbeddedSignInFlowType = /* @__PURE__ */ ((EmbeddedSignInFlowType3) => {
|
|
@@ -3020,20 +3023,20 @@ var executeEmbeddedSignInFlowV2 = async ({
|
|
|
3020
3023
|
"If an authorization payload is not provided, the request cannot be constructed correctly."
|
|
3021
3024
|
);
|
|
3022
3025
|
}
|
|
3023
|
-
|
|
3026
|
+
const endpoint = url ?? `${baseUrl}/flow/execute`;
|
|
3024
3027
|
const cleanPayload = typeof payload === "object" && payload !== null ? Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "verbose")) : payload;
|
|
3025
3028
|
const hasOnlyAppIdAndFlowType = typeof cleanPayload === "object" && cleanPayload !== null && "applicationId" in cleanPayload && "flowType" in cleanPayload && Object.keys(cleanPayload).length === 2;
|
|
3026
3029
|
const hasOnlyFlowId = typeof cleanPayload === "object" && cleanPayload !== null && "flowId" in cleanPayload && Object.keys(cleanPayload).length === 1;
|
|
3027
3030
|
const requestPayload = hasOnlyAppIdAndFlowType || hasOnlyFlowId ? { ...cleanPayload, verbose: true } : cleanPayload;
|
|
3028
3031
|
const response = await fetch(endpoint, {
|
|
3029
3032
|
...requestConfig,
|
|
3030
|
-
|
|
3033
|
+
body: JSON.stringify(requestPayload),
|
|
3031
3034
|
headers: {
|
|
3032
|
-
"Content-Type": "application/json",
|
|
3033
3035
|
Accept: "application/json",
|
|
3036
|
+
"Content-Type": "application/json",
|
|
3034
3037
|
...requestConfig.headers
|
|
3035
3038
|
},
|
|
3036
|
-
|
|
3039
|
+
method: requestConfig.method || "POST"
|
|
3037
3040
|
});
|
|
3038
3041
|
if (!response.ok) {
|
|
3039
3042
|
const errorText = await response.text();
|
|
@@ -3049,17 +3052,17 @@ var executeEmbeddedSignInFlowV2 = async ({
|
|
|
3049
3052
|
if (flowResponse.flowStatus === "COMPLETE" /* Complete */ && flowResponse.assertion && authId) {
|
|
3050
3053
|
try {
|
|
3051
3054
|
const oauth2Response = await fetch(`${baseUrl}/oauth2/auth/callback`, {
|
|
3052
|
-
method: "POST",
|
|
3053
|
-
headers: {
|
|
3054
|
-
"Content-Type": "application/json",
|
|
3055
|
-
Accept: "application/json",
|
|
3056
|
-
...requestConfig.headers
|
|
3057
|
-
},
|
|
3058
3055
|
body: JSON.stringify({
|
|
3059
3056
|
assertion: flowResponse.assertion,
|
|
3060
3057
|
authId
|
|
3061
3058
|
}),
|
|
3062
|
-
credentials: "include"
|
|
3059
|
+
credentials: "include",
|
|
3060
|
+
headers: {
|
|
3061
|
+
Accept: "application/json",
|
|
3062
|
+
"Content-Type": "application/json",
|
|
3063
|
+
...requestConfig.headers
|
|
3064
|
+
},
|
|
3065
|
+
method: "POST"
|
|
3063
3066
|
});
|
|
3064
3067
|
if (!oauth2Response.ok) {
|
|
3065
3068
|
const oauth2ErrorText = await oauth2Response.text();
|
|
@@ -3074,7 +3077,7 @@ var executeEmbeddedSignInFlowV2 = async ({
|
|
|
3074
3077
|
const oauth2Result = await oauth2Response.json();
|
|
3075
3078
|
return {
|
|
3076
3079
|
flowStatus: flowResponse.flowStatus,
|
|
3077
|
-
redirectUrl: oauth2Result
|
|
3080
|
+
redirectUrl: oauth2Result["redirect_uri"]
|
|
3078
3081
|
};
|
|
3079
3082
|
} catch (authError) {
|
|
3080
3083
|
throw new AsgardeoAPIError(
|
|
@@ -3093,8 +3096,8 @@ var executeEmbeddedSignInFlowV2_default = executeEmbeddedSignInFlowV2;
|
|
|
3093
3096
|
// src/models/v2/embedded-signup-flow-v2.ts
|
|
3094
3097
|
var EmbeddedSignUpFlowStatus = /* @__PURE__ */ ((EmbeddedSignUpFlowStatus2) => {
|
|
3095
3098
|
EmbeddedSignUpFlowStatus2["Complete"] = "COMPLETE";
|
|
3096
|
-
EmbeddedSignUpFlowStatus2["Incomplete"] = "INCOMPLETE";
|
|
3097
3099
|
EmbeddedSignUpFlowStatus2["Error"] = "ERROR";
|
|
3100
|
+
EmbeddedSignUpFlowStatus2["Incomplete"] = "INCOMPLETE";
|
|
3098
3101
|
return EmbeddedSignUpFlowStatus2;
|
|
3099
3102
|
})(EmbeddedSignUpFlowStatus || {});
|
|
3100
3103
|
var EmbeddedSignUpFlowType = /* @__PURE__ */ ((EmbeddedSignUpFlowType2) => {
|
|
@@ -3120,20 +3123,20 @@ var executeEmbeddedSignUpFlowV2 = async ({
|
|
|
3120
3123
|
"If a registration payload is not provided, the request cannot be constructed correctly."
|
|
3121
3124
|
);
|
|
3122
3125
|
}
|
|
3123
|
-
|
|
3126
|
+
const endpoint = url ?? `${baseUrl}/flow/execute`;
|
|
3124
3127
|
const cleanPayload = typeof payload === "object" && payload !== null ? Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "verbose")) : payload;
|
|
3125
3128
|
const hasOnlyAppIdAndFlowType = typeof cleanPayload === "object" && cleanPayload !== null && "applicationId" in cleanPayload && "flowType" in cleanPayload && Object.keys(cleanPayload).length === 2;
|
|
3126
3129
|
const hasOnlyFlowId = typeof cleanPayload === "object" && cleanPayload !== null && "flowId" in cleanPayload && Object.keys(cleanPayload).length === 1;
|
|
3127
3130
|
const requestPayload = hasOnlyAppIdAndFlowType || hasOnlyFlowId ? { ...cleanPayload, verbose: true } : cleanPayload;
|
|
3128
3131
|
const response = await fetch(endpoint, {
|
|
3129
3132
|
...requestConfig,
|
|
3130
|
-
|
|
3133
|
+
body: JSON.stringify(requestPayload),
|
|
3131
3134
|
headers: {
|
|
3132
|
-
"Content-Type": "application/json",
|
|
3133
3135
|
Accept: "application/json",
|
|
3136
|
+
"Content-Type": "application/json",
|
|
3134
3137
|
...requestConfig.headers
|
|
3135
3138
|
},
|
|
3136
|
-
|
|
3139
|
+
method: requestConfig.method || "POST"
|
|
3137
3140
|
});
|
|
3138
3141
|
if (!response.ok) {
|
|
3139
3142
|
const errorText = await response.text();
|
|
@@ -3149,17 +3152,17 @@ var executeEmbeddedSignUpFlowV2 = async ({
|
|
|
3149
3152
|
if (flowResponse.flowStatus === "COMPLETE" /* Complete */ && flowResponse.assertion && authId) {
|
|
3150
3153
|
try {
|
|
3151
3154
|
const oauth2Response = await fetch(`${baseUrl}/oauth2/auth/callback`, {
|
|
3152
|
-
method: "POST",
|
|
3153
|
-
headers: {
|
|
3154
|
-
"Content-Type": "application/json",
|
|
3155
|
-
Accept: "application/json",
|
|
3156
|
-
...requestConfig.headers
|
|
3157
|
-
},
|
|
3158
3155
|
body: JSON.stringify({
|
|
3159
3156
|
assertion: flowResponse.assertion,
|
|
3160
3157
|
authId
|
|
3161
3158
|
}),
|
|
3162
|
-
credentials: "include"
|
|
3159
|
+
credentials: "include",
|
|
3160
|
+
headers: {
|
|
3161
|
+
Accept: "application/json",
|
|
3162
|
+
"Content-Type": "application/json",
|
|
3163
|
+
...requestConfig.headers
|
|
3164
|
+
},
|
|
3165
|
+
method: "POST"
|
|
3163
3166
|
});
|
|
3164
3167
|
if (!oauth2Response.ok) {
|
|
3165
3168
|
const oauth2ErrorText = await oauth2Response.text();
|
|
@@ -3174,7 +3177,7 @@ var executeEmbeddedSignUpFlowV2 = async ({
|
|
|
3174
3177
|
const oauth2Result = await oauth2Response.json();
|
|
3175
3178
|
return {
|
|
3176
3179
|
flowStatus: flowResponse.flowStatus,
|
|
3177
|
-
redirectUrl: oauth2Result
|
|
3180
|
+
redirectUrl: oauth2Result["redirect_uri"]
|
|
3178
3181
|
};
|
|
3179
3182
|
} catch (authError) {
|
|
3180
3183
|
throw new AsgardeoAPIError(
|
|
@@ -3217,13 +3220,13 @@ var executeEmbeddedUserOnboardingFlowV2 = async ({
|
|
|
3217
3220
|
}
|
|
3218
3221
|
const response = await fetch(endpoint, {
|
|
3219
3222
|
...requestConfig,
|
|
3220
|
-
|
|
3223
|
+
body: JSON.stringify(requestPayload),
|
|
3221
3224
|
headers: {
|
|
3222
|
-
"Content-Type": "application/json",
|
|
3223
3225
|
Accept: "application/json",
|
|
3226
|
+
"Content-Type": "application/json",
|
|
3224
3227
|
...requestConfig.headers
|
|
3225
3228
|
},
|
|
3226
|
-
|
|
3229
|
+
method: requestConfig.method || "POST"
|
|
3227
3230
|
});
|
|
3228
3231
|
if (!response.ok) {
|
|
3229
3232
|
const errorText = await response.text();
|
|
@@ -3243,20 +3246,20 @@ var executeEmbeddedUserOnboardingFlowV2_default = executeEmbeddedUserOnboardingF
|
|
|
3243
3246
|
// src/constants/ApplicationNativeAuthenticationConstants.ts
|
|
3244
3247
|
var ApplicationNativeAuthenticationConstants = {
|
|
3245
3248
|
SupportedAuthenticators: {
|
|
3246
|
-
IdentifierFirst: "SWRlbnRpZmllckV4ZWN1dG9yOkxPQ0FM",
|
|
3247
3249
|
EmailOtp: "ZW1haWwtb3RwLWF1dGhlbnRpY2F0b3I6TE9DQUw",
|
|
3248
|
-
Totp: "dG90cDpMT0NBTA",
|
|
3249
|
-
UsernamePassword: "QmFzaWNBdXRoZW50aWNhdG9yOkxPQ0FM",
|
|
3250
|
-
PushNotification: "cHVzaC1ub3RpZmljYXRpb24tYXV0aGVudGljYXRvcjpMT0NBTA",
|
|
3251
|
-
Passkey: "RklET0F1dGhlbnRpY2F0b3I6TE9DQUw",
|
|
3252
|
-
SmsOtp: "c21zLW90cC1hdXRoZW50aWNhdG9yOkxPQ0FM",
|
|
3253
|
-
MagicLink: "TWFnaWNMaW5rQXV0aGVudGljYXRvcjpMT0NBTA",
|
|
3254
|
-
Google: "R29vZ2xlT0lEQ0F1dGhlbnRpY2F0b3I6R29vZ2xl",
|
|
3255
|
-
GitHub: "R2l0aHViQXV0aGVudGljYXRvcjpHaXRIdWI",
|
|
3256
|
-
Microsoft: "T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I6TWljcm9zb2Z0",
|
|
3257
3250
|
Facebook: "RmFjZWJvb2tBdXRoZW50aWNhdG9yOkZhY2Vib29r",
|
|
3251
|
+
GitHub: "R2l0aHViQXV0aGVudGljYXRvcjpHaXRIdWI",
|
|
3252
|
+
Google: "R29vZ2xlT0lEQ0F1dGhlbnRpY2F0b3I6R29vZ2xl",
|
|
3253
|
+
IdentifierFirst: "SWRlbnRpZmllckV4ZWN1dG9yOkxPQ0FM",
|
|
3258
3254
|
LinkedIn: "TGlua2VkSW5PSURDOkxpbmtlZElu",
|
|
3259
|
-
|
|
3255
|
+
MagicLink: "TWFnaWNMaW5rQXV0aGVudGljYXRvcjpMT0NBTA",
|
|
3256
|
+
Microsoft: "T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I6TWljcm9zb2Z0",
|
|
3257
|
+
Passkey: "RklET0F1dGhlbnRpY2F0b3I6TE9DQUw",
|
|
3258
|
+
PushNotification: "cHVzaC1ub3RpZmljYXRpb24tYXV0aGVudGljYXRvcjpMT0NBTA",
|
|
3259
|
+
SignInWithEthereum: "T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I6U2lnbiBJbiBXaXRoIEV0aGVyZXVt",
|
|
3260
|
+
SmsOtp: "c21zLW90cC1hdXRoZW50aWNhdG9yOkxPQ0FM",
|
|
3261
|
+
Totp: "dG90cDpMT0NBTA",
|
|
3262
|
+
UsernamePassword: "QmFzaWNBdXRoZW50aWNhdG9yOkxPQ0FM"
|
|
3260
3263
|
}
|
|
3261
3264
|
};
|
|
3262
3265
|
var ApplicationNativeAuthenticationConstants_default = ApplicationNativeAuthenticationConstants;
|
|
@@ -3306,53 +3309,53 @@ var EmbeddedSignInFlowAuthenticatorPromptType = /* @__PURE__ */ ((EmbeddedSignIn
|
|
|
3306
3309
|
|
|
3307
3310
|
// src/models/v2/embedded-flow-v2.ts
|
|
3308
3311
|
var EmbeddedFlowComponentType2 = /* @__PURE__ */ ((EmbeddedFlowComponentType3) => {
|
|
3309
|
-
EmbeddedFlowComponentType3["TextInput"] = "TEXT_INPUT";
|
|
3310
|
-
EmbeddedFlowComponentType3["PasswordInput"] = "PASSWORD_INPUT";
|
|
3311
|
-
EmbeddedFlowComponentType3["EmailInput"] = "EMAIL_INPUT";
|
|
3312
|
-
EmbeddedFlowComponentType3["OtpInput"] = "OTP_INPUT";
|
|
3313
|
-
EmbeddedFlowComponentType3["PhoneInput"] = "PHONE_INPUT";
|
|
3314
|
-
EmbeddedFlowComponentType3["Text"] = "TEXT";
|
|
3315
3312
|
EmbeddedFlowComponentType3["Action"] = "ACTION";
|
|
3316
3313
|
EmbeddedFlowComponentType3["Block"] = "BLOCK";
|
|
3317
3314
|
EmbeddedFlowComponentType3["Divider"] = "DIVIDER";
|
|
3315
|
+
EmbeddedFlowComponentType3["EmailInput"] = "EMAIL_INPUT";
|
|
3316
|
+
EmbeddedFlowComponentType3["OtpInput"] = "OTP_INPUT";
|
|
3317
|
+
EmbeddedFlowComponentType3["PasswordInput"] = "PASSWORD_INPUT";
|
|
3318
|
+
EmbeddedFlowComponentType3["PhoneInput"] = "PHONE_INPUT";
|
|
3318
3319
|
EmbeddedFlowComponentType3["Select"] = "SELECT";
|
|
3320
|
+
EmbeddedFlowComponentType3["Text"] = "TEXT";
|
|
3321
|
+
EmbeddedFlowComponentType3["TextInput"] = "TEXT_INPUT";
|
|
3319
3322
|
return EmbeddedFlowComponentType3;
|
|
3320
3323
|
})(EmbeddedFlowComponentType2 || {});
|
|
3321
3324
|
var EmbeddedFlowActionVariant = /* @__PURE__ */ ((EmbeddedFlowActionVariant2) => {
|
|
3322
|
-
EmbeddedFlowActionVariant2["Primary"] = "PRIMARY";
|
|
3323
|
-
EmbeddedFlowActionVariant2["Secondary"] = "SECONDARY";
|
|
3324
|
-
EmbeddedFlowActionVariant2["Tertiary"] = "TERTIARY";
|
|
3325
3325
|
EmbeddedFlowActionVariant2["Danger"] = "DANGER";
|
|
3326
|
-
EmbeddedFlowActionVariant2["Success"] = "SUCCESS";
|
|
3327
3326
|
EmbeddedFlowActionVariant2["Info"] = "INFO";
|
|
3328
|
-
EmbeddedFlowActionVariant2["Warning"] = "WARNING";
|
|
3329
3327
|
EmbeddedFlowActionVariant2["Link"] = "LINK";
|
|
3328
|
+
EmbeddedFlowActionVariant2["Primary"] = "PRIMARY";
|
|
3329
|
+
EmbeddedFlowActionVariant2["Secondary"] = "SECONDARY";
|
|
3330
3330
|
EmbeddedFlowActionVariant2["Social"] = "SOCIAL";
|
|
3331
|
+
EmbeddedFlowActionVariant2["Success"] = "SUCCESS";
|
|
3332
|
+
EmbeddedFlowActionVariant2["Tertiary"] = "TERTIARY";
|
|
3333
|
+
EmbeddedFlowActionVariant2["Warning"] = "WARNING";
|
|
3331
3334
|
return EmbeddedFlowActionVariant2;
|
|
3332
3335
|
})(EmbeddedFlowActionVariant || {});
|
|
3333
3336
|
var EmbeddedFlowTextVariant = /* @__PURE__ */ ((EmbeddedFlowTextVariant2) => {
|
|
3337
|
+
EmbeddedFlowTextVariant2["Body1"] = "BODY_1";
|
|
3338
|
+
EmbeddedFlowTextVariant2["Body2"] = "BODY_2";
|
|
3339
|
+
EmbeddedFlowTextVariant2["ButtonText"] = "BUTTON_TEXT";
|
|
3340
|
+
EmbeddedFlowTextVariant2["Caption"] = "CAPTION";
|
|
3334
3341
|
EmbeddedFlowTextVariant2["Heading1"] = "HEADING_1";
|
|
3335
3342
|
EmbeddedFlowTextVariant2["Heading2"] = "HEADING_2";
|
|
3336
3343
|
EmbeddedFlowTextVariant2["Heading3"] = "HEADING_3";
|
|
3337
3344
|
EmbeddedFlowTextVariant2["Heading4"] = "HEADING_4";
|
|
3338
3345
|
EmbeddedFlowTextVariant2["Heading5"] = "HEADING_5";
|
|
3339
3346
|
EmbeddedFlowTextVariant2["Heading6"] = "HEADING_6";
|
|
3347
|
+
EmbeddedFlowTextVariant2["Overline"] = "OVERLINE";
|
|
3340
3348
|
EmbeddedFlowTextVariant2["Subtitle1"] = "SUBTITLE_1";
|
|
3341
3349
|
EmbeddedFlowTextVariant2["Subtitle2"] = "SUBTITLE_2";
|
|
3342
|
-
EmbeddedFlowTextVariant2["Body1"] = "BODY_1";
|
|
3343
|
-
EmbeddedFlowTextVariant2["Body2"] = "BODY_2";
|
|
3344
|
-
EmbeddedFlowTextVariant2["Caption"] = "CAPTION";
|
|
3345
|
-
EmbeddedFlowTextVariant2["Overline"] = "OVERLINE";
|
|
3346
|
-
EmbeddedFlowTextVariant2["ButtonText"] = "BUTTON_TEXT";
|
|
3347
3350
|
return EmbeddedFlowTextVariant2;
|
|
3348
3351
|
})(EmbeddedFlowTextVariant || {});
|
|
3349
3352
|
var EmbeddedFlowEventType = /* @__PURE__ */ ((EmbeddedFlowEventType2) => {
|
|
3350
|
-
EmbeddedFlowEventType2["
|
|
3351
|
-
EmbeddedFlowEventType2["Submit"] = "SUBMIT";
|
|
3352
|
-
EmbeddedFlowEventType2["Navigate"] = "NAVIGATE";
|
|
3353
|
+
EmbeddedFlowEventType2["Back"] = "BACK";
|
|
3353
3354
|
EmbeddedFlowEventType2["Cancel"] = "CANCEL";
|
|
3355
|
+
EmbeddedFlowEventType2["Navigate"] = "NAVIGATE";
|
|
3354
3356
|
EmbeddedFlowEventType2["Reset"] = "RESET";
|
|
3355
|
-
EmbeddedFlowEventType2["
|
|
3357
|
+
EmbeddedFlowEventType2["Submit"] = "SUBMIT";
|
|
3358
|
+
EmbeddedFlowEventType2["Trigger"] = "TRIGGER";
|
|
3356
3359
|
return EmbeddedFlowEventType2;
|
|
3357
3360
|
})(EmbeddedFlowEventType || {});
|
|
3358
3361
|
|
|
@@ -3366,26 +3369,26 @@ var FlowMode = /* @__PURE__ */ ((FlowMode2) => {
|
|
|
3366
3369
|
// src/models/scim2-schema.ts
|
|
3367
3370
|
var WellKnownSchemaIds = /* @__PURE__ */ ((WellKnownSchemaIds2) => {
|
|
3368
3371
|
WellKnownSchemaIds2["Core"] = "urn:ietf:params:scim:schemas:core:2.0";
|
|
3369
|
-
WellKnownSchemaIds2["
|
|
3372
|
+
WellKnownSchemaIds2["CustomUser"] = "urn:scim:schemas:extension:custom:User";
|
|
3370
3373
|
WellKnownSchemaIds2["EnterpriseUser"] = "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User";
|
|
3371
3374
|
WellKnownSchemaIds2["SystemUser"] = "urn:scim:wso2:schema";
|
|
3372
|
-
WellKnownSchemaIds2["
|
|
3375
|
+
WellKnownSchemaIds2["User"] = "urn:ietf:params:scim:schemas:core:2.0:User";
|
|
3373
3376
|
return WellKnownSchemaIds2;
|
|
3374
3377
|
})(WellKnownSchemaIds || {});
|
|
3375
3378
|
|
|
3376
3379
|
// src/models/field.ts
|
|
3377
3380
|
var FieldType = /* @__PURE__ */ ((FieldType2) => {
|
|
3378
|
-
FieldType2["
|
|
3379
|
-
FieldType2["
|
|
3381
|
+
FieldType2["Checkbox"] = "CHECKBOX";
|
|
3382
|
+
FieldType2["Date"] = "DATE";
|
|
3380
3383
|
FieldType2["Email"] = "EMAIL";
|
|
3381
3384
|
FieldType2["Number"] = "NUMBER";
|
|
3382
|
-
FieldType2["Select"] = "SELECT";
|
|
3383
|
-
FieldType2["Checkbox"] = "CHECKBOX";
|
|
3384
|
-
FieldType2["Radio"] = "RADIO";
|
|
3385
3385
|
FieldType2["Otp"] = "OTP";
|
|
3386
|
-
FieldType2["
|
|
3387
|
-
FieldType2["
|
|
3386
|
+
FieldType2["Password"] = "PASSWORD";
|
|
3387
|
+
FieldType2["Radio"] = "RADIO";
|
|
3388
|
+
FieldType2["Select"] = "SELECT";
|
|
3389
|
+
FieldType2["Text"] = "TEXT";
|
|
3388
3390
|
FieldType2["Textarea"] = "TEXTAREA";
|
|
3391
|
+
FieldType2["Time"] = "TIME";
|
|
3389
3392
|
return FieldType2;
|
|
3390
3393
|
})(FieldType || {});
|
|
3391
3394
|
|
|
@@ -3396,221 +3399,221 @@ var AsgardeoJavaScriptClient_default = AsgardeoJavaScriptClient;
|
|
|
3396
3399
|
|
|
3397
3400
|
// src/theme/createTheme.ts
|
|
3398
3401
|
var lightTheme = {
|
|
3402
|
+
borderRadius: {
|
|
3403
|
+
large: "16px",
|
|
3404
|
+
medium: "8px",
|
|
3405
|
+
small: "4px"
|
|
3406
|
+
},
|
|
3399
3407
|
colors: {
|
|
3400
3408
|
action: {
|
|
3409
|
+
activatedOpacity: 0.12,
|
|
3401
3410
|
active: "rgba(0, 0, 0, 0.54)",
|
|
3402
|
-
hover: "rgba(0, 0, 0, 0.04)",
|
|
3403
|
-
hoverOpacity: 0.04,
|
|
3404
|
-
selected: "rgba(0, 0, 0, 0.08)",
|
|
3405
|
-
selectedOpacity: 0.08,
|
|
3406
3411
|
disabled: "rgba(0, 0, 0, 0.26)",
|
|
3407
3412
|
disabledBackground: "rgba(0, 0, 0, 0.12)",
|
|
3408
3413
|
disabledOpacity: 0.38,
|
|
3409
3414
|
focus: "rgba(0, 0, 0, 0.12)",
|
|
3410
3415
|
focusOpacity: 0.12,
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
contrastText: "#ffffff",
|
|
3416
|
-
dark: "#174ea6"
|
|
3417
|
-
},
|
|
3418
|
-
secondary: {
|
|
3419
|
-
main: "#424242",
|
|
3420
|
-
contrastText: "#ffffff",
|
|
3421
|
-
dark: "#212121"
|
|
3416
|
+
hover: "rgba(0, 0, 0, 0.04)",
|
|
3417
|
+
hoverOpacity: 0.04,
|
|
3418
|
+
selected: "rgba(0, 0, 0, 0.08)",
|
|
3419
|
+
selectedOpacity: 0.08
|
|
3422
3420
|
},
|
|
3423
3421
|
background: {
|
|
3424
|
-
surface: "#ffffff",
|
|
3425
|
-
disabled: "#f0f0f0",
|
|
3426
|
-
dark: "#212121",
|
|
3427
3422
|
body: {
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
}
|
|
3423
|
+
dark: "#212121",
|
|
3424
|
+
main: "#1a1a1a"
|
|
3425
|
+
},
|
|
3426
|
+
dark: "#212121",
|
|
3427
|
+
disabled: "#f0f0f0",
|
|
3428
|
+
surface: "#ffffff"
|
|
3431
3429
|
},
|
|
3430
|
+
border: "#e0e0e0",
|
|
3432
3431
|
error: {
|
|
3433
|
-
main: "#d32f2f",
|
|
3434
3432
|
contrastText: "#d52828",
|
|
3435
|
-
dark: "#b71c1c"
|
|
3433
|
+
dark: "#b71c1c",
|
|
3434
|
+
main: "#d32f2f"
|
|
3436
3435
|
},
|
|
3437
3436
|
info: {
|
|
3438
|
-
main: "#bbebff",
|
|
3439
3437
|
contrastText: "#43aeda",
|
|
3440
|
-
dark: "#01579b"
|
|
3438
|
+
dark: "#01579b",
|
|
3439
|
+
main: "#bbebff"
|
|
3440
|
+
},
|
|
3441
|
+
primary: {
|
|
3442
|
+
contrastText: "#ffffff",
|
|
3443
|
+
dark: "#174ea6",
|
|
3444
|
+
main: "#1a73e8"
|
|
3445
|
+
},
|
|
3446
|
+
secondary: {
|
|
3447
|
+
contrastText: "#ffffff",
|
|
3448
|
+
dark: "#212121",
|
|
3449
|
+
main: "#424242"
|
|
3441
3450
|
},
|
|
3442
3451
|
success: {
|
|
3443
|
-
main: "#4caf50",
|
|
3444
3452
|
contrastText: "#00a807",
|
|
3445
|
-
dark: "#388e3c"
|
|
3446
|
-
|
|
3447
|
-
warning: {
|
|
3448
|
-
main: "#ff9800",
|
|
3449
|
-
contrastText: "#be7100",
|
|
3450
|
-
dark: "#f57c00"
|
|
3453
|
+
dark: "#388e3c",
|
|
3454
|
+
main: "#4caf50"
|
|
3451
3455
|
},
|
|
3452
3456
|
text: {
|
|
3457
|
+
dark: "#212121",
|
|
3453
3458
|
primary: "#1a1a1a",
|
|
3454
|
-
secondary: "#666666"
|
|
3455
|
-
dark: "#212121"
|
|
3459
|
+
secondary: "#666666"
|
|
3456
3460
|
},
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
+
warning: {
|
|
3462
|
+
contrastText: "#be7100",
|
|
3463
|
+
dark: "#f57c00",
|
|
3464
|
+
main: "#ff9800"
|
|
3465
|
+
}
|
|
3461
3466
|
},
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
large: "16px"
|
|
3467
|
+
images: {
|
|
3468
|
+
favicon: {},
|
|
3469
|
+
logo: {}
|
|
3466
3470
|
},
|
|
3467
3471
|
shadows: {
|
|
3468
|
-
|
|
3472
|
+
large: "0 8px 32px rgba(0, 0, 0, 0.2)",
|
|
3469
3473
|
medium: "0 4px 16px rgba(0, 0, 0, 0.15)",
|
|
3470
|
-
|
|
3474
|
+
small: "0 2px 8px rgba(0, 0, 0, 0.1)"
|
|
3475
|
+
},
|
|
3476
|
+
spacing: {
|
|
3477
|
+
unit: 8
|
|
3471
3478
|
},
|
|
3472
3479
|
typography: {
|
|
3473
3480
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
|
|
3474
3481
|
fontSizes: {
|
|
3475
|
-
|
|
3476
|
-
//
|
|
3477
|
-
|
|
3478
|
-
//
|
|
3479
|
-
md: "1rem",
|
|
3480
|
-
// 16px
|
|
3482
|
+
"2xl": "1.5rem",
|
|
3483
|
+
// 24px
|
|
3484
|
+
"3xl": "2.125rem",
|
|
3485
|
+
// 34px
|
|
3481
3486
|
lg: "1.125rem",
|
|
3482
3487
|
// 18px
|
|
3488
|
+
md: "1rem",
|
|
3489
|
+
// 16px
|
|
3490
|
+
sm: "0.875rem",
|
|
3491
|
+
// 14px
|
|
3483
3492
|
xl: "1.25rem",
|
|
3484
3493
|
// 20px
|
|
3485
|
-
|
|
3486
|
-
//
|
|
3487
|
-
"3xl": "2.125rem"
|
|
3488
|
-
// 34px
|
|
3494
|
+
xs: "0.75rem"
|
|
3495
|
+
// 12px
|
|
3489
3496
|
},
|
|
3490
3497
|
fontWeights: {
|
|
3491
|
-
|
|
3498
|
+
bold: 700,
|
|
3492
3499
|
medium: 500,
|
|
3493
|
-
|
|
3494
|
-
|
|
3500
|
+
normal: 400,
|
|
3501
|
+
semibold: 600
|
|
3495
3502
|
},
|
|
3496
3503
|
lineHeights: {
|
|
3497
|
-
tight: 1.2,
|
|
3498
3504
|
normal: 1.4,
|
|
3499
|
-
relaxed: 1.6
|
|
3505
|
+
relaxed: 1.6,
|
|
3506
|
+
tight: 1.2
|
|
3500
3507
|
}
|
|
3501
|
-
},
|
|
3502
|
-
images: {
|
|
3503
|
-
favicon: {},
|
|
3504
|
-
logo: {}
|
|
3505
3508
|
}
|
|
3506
3509
|
};
|
|
3507
3510
|
var darkTheme = {
|
|
3511
|
+
borderRadius: {
|
|
3512
|
+
large: "16px",
|
|
3513
|
+
medium: "8px",
|
|
3514
|
+
small: "4px"
|
|
3515
|
+
},
|
|
3508
3516
|
colors: {
|
|
3509
3517
|
action: {
|
|
3518
|
+
activatedOpacity: 0.12,
|
|
3510
3519
|
active: "#1c1c1c",
|
|
3511
|
-
hover: "#1c1c1c",
|
|
3512
|
-
hoverOpacity: 0.04,
|
|
3513
|
-
selected: "#1c1c1c",
|
|
3514
|
-
selectedOpacity: 0.08,
|
|
3515
3520
|
disabled: "rgba(255, 255, 255, 0.26)",
|
|
3516
3521
|
disabledBackground: "rgba(255, 255, 255, 0.12)",
|
|
3517
3522
|
disabledOpacity: 0.38,
|
|
3518
3523
|
focus: "#1c1c1c",
|
|
3519
3524
|
focusOpacity: 0.12,
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
contrastText: "#ffffff",
|
|
3525
|
-
dark: "#174ea6"
|
|
3526
|
-
},
|
|
3527
|
-
secondary: {
|
|
3528
|
-
main: "#8b8b8b",
|
|
3529
|
-
contrastText: "#ffffff",
|
|
3530
|
-
dark: "#212121"
|
|
3525
|
+
hover: "#1c1c1c",
|
|
3526
|
+
hoverOpacity: 0.04,
|
|
3527
|
+
selected: "#1c1c1c",
|
|
3528
|
+
selectedOpacity: 0.08
|
|
3531
3529
|
},
|
|
3532
3530
|
background: {
|
|
3533
|
-
surface: "#121212",
|
|
3534
|
-
disabled: "#1f1f1f",
|
|
3535
|
-
dark: "#212121",
|
|
3536
3531
|
body: {
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
}
|
|
3532
|
+
dark: "#212121",
|
|
3533
|
+
main: "#ffffff"
|
|
3534
|
+
},
|
|
3535
|
+
dark: "#212121",
|
|
3536
|
+
disabled: "#1f1f1f",
|
|
3537
|
+
surface: "#121212"
|
|
3540
3538
|
},
|
|
3539
|
+
border: "#404040",
|
|
3541
3540
|
error: {
|
|
3542
|
-
main: "#d32f2f",
|
|
3543
3541
|
contrastText: "#d52828",
|
|
3544
|
-
dark: "#b71c1c"
|
|
3542
|
+
dark: "#b71c1c",
|
|
3543
|
+
main: "#d32f2f"
|
|
3545
3544
|
},
|
|
3546
3545
|
info: {
|
|
3547
|
-
main: "#bbebff",
|
|
3548
3546
|
contrastText: "#43aeda",
|
|
3549
|
-
dark: "#01579b"
|
|
3547
|
+
dark: "#01579b",
|
|
3548
|
+
main: "#bbebff"
|
|
3549
|
+
},
|
|
3550
|
+
primary: {
|
|
3551
|
+
contrastText: "#ffffff",
|
|
3552
|
+
dark: "#174ea6",
|
|
3553
|
+
main: "#1a73e8"
|
|
3554
|
+
},
|
|
3555
|
+
secondary: {
|
|
3556
|
+
contrastText: "#ffffff",
|
|
3557
|
+
dark: "#212121",
|
|
3558
|
+
main: "#8b8b8b"
|
|
3550
3559
|
},
|
|
3551
3560
|
success: {
|
|
3552
|
-
main: "#4caf50",
|
|
3553
3561
|
contrastText: "#00a807",
|
|
3554
|
-
dark: "#388e3c"
|
|
3555
|
-
|
|
3556
|
-
warning: {
|
|
3557
|
-
main: "#ff9800",
|
|
3558
|
-
contrastText: "#be7100",
|
|
3559
|
-
dark: "#f57c00"
|
|
3562
|
+
dark: "#388e3c",
|
|
3563
|
+
main: "#4caf50"
|
|
3560
3564
|
},
|
|
3561
3565
|
text: {
|
|
3566
|
+
dark: "#212121",
|
|
3562
3567
|
primary: "#ffffff",
|
|
3563
|
-
secondary: "#b3b3b3"
|
|
3564
|
-
dark: "#212121"
|
|
3568
|
+
secondary: "#b3b3b3"
|
|
3565
3569
|
},
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
+
warning: {
|
|
3571
|
+
contrastText: "#be7100",
|
|
3572
|
+
dark: "#f57c00",
|
|
3573
|
+
main: "#ff9800"
|
|
3574
|
+
}
|
|
3570
3575
|
},
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
large: "16px"
|
|
3576
|
+
images: {
|
|
3577
|
+
favicon: {},
|
|
3578
|
+
logo: {}
|
|
3575
3579
|
},
|
|
3576
3580
|
shadows: {
|
|
3577
|
-
|
|
3581
|
+
large: "0 8px 32px rgba(0, 0, 0, 0.5)",
|
|
3578
3582
|
medium: "0 4px 16px rgba(0, 0, 0, 0.4)",
|
|
3579
|
-
|
|
3583
|
+
small: "0 2px 8px rgba(0, 0, 0, 0.3)"
|
|
3584
|
+
},
|
|
3585
|
+
spacing: {
|
|
3586
|
+
unit: 8
|
|
3580
3587
|
},
|
|
3581
3588
|
typography: {
|
|
3582
3589
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
|
|
3583
3590
|
fontSizes: {
|
|
3584
|
-
|
|
3585
|
-
//
|
|
3586
|
-
|
|
3587
|
-
//
|
|
3588
|
-
md: "1rem",
|
|
3589
|
-
// 16px
|
|
3591
|
+
"2xl": "1.5rem",
|
|
3592
|
+
// 24px
|
|
3593
|
+
"3xl": "2.125rem",
|
|
3594
|
+
// 34px
|
|
3590
3595
|
lg: "1.125rem",
|
|
3591
3596
|
// 18px
|
|
3597
|
+
md: "1rem",
|
|
3598
|
+
// 16px
|
|
3599
|
+
sm: "0.875rem",
|
|
3600
|
+
// 14px
|
|
3592
3601
|
xl: "1.25rem",
|
|
3593
3602
|
// 20px
|
|
3594
|
-
|
|
3595
|
-
//
|
|
3596
|
-
"3xl": "2.125rem"
|
|
3597
|
-
// 34px
|
|
3603
|
+
xs: "0.75rem"
|
|
3604
|
+
// 12px
|
|
3598
3605
|
},
|
|
3599
3606
|
fontWeights: {
|
|
3600
|
-
|
|
3607
|
+
bold: 700,
|
|
3601
3608
|
medium: 500,
|
|
3602
|
-
|
|
3603
|
-
|
|
3609
|
+
normal: 400,
|
|
3610
|
+
semibold: 600
|
|
3604
3611
|
},
|
|
3605
3612
|
lineHeights: {
|
|
3606
|
-
tight: 1.2,
|
|
3607
3613
|
normal: 1.4,
|
|
3608
|
-
relaxed: 1.6
|
|
3614
|
+
relaxed: 1.6,
|
|
3615
|
+
tight: 1.2
|
|
3609
3616
|
}
|
|
3610
|
-
},
|
|
3611
|
-
images: {
|
|
3612
|
-
favicon: {},
|
|
3613
|
-
logo: {}
|
|
3614
3617
|
}
|
|
3615
3618
|
};
|
|
3616
3619
|
var toCssVariables = (theme) => {
|
|
@@ -3809,91 +3812,91 @@ var toThemeVars = (theme) => {
|
|
|
3809
3812
|
};
|
|
3810
3813
|
}
|
|
3811
3814
|
const themeVars = {
|
|
3815
|
+
borderRadius: {
|
|
3816
|
+
large: `var(--${prefix}-border-radius-large)`,
|
|
3817
|
+
medium: `var(--${prefix}-border-radius-medium)`,
|
|
3818
|
+
small: `var(--${prefix}-border-radius-small)`
|
|
3819
|
+
},
|
|
3812
3820
|
colors: {
|
|
3813
3821
|
action: {
|
|
3822
|
+
activatedOpacity: `var(--${prefix}-color-action-activatedOpacity)`,
|
|
3814
3823
|
active: `var(--${prefix}-color-action-active)`,
|
|
3815
|
-
hover: `var(--${prefix}-color-action-hover)`,
|
|
3816
|
-
hoverOpacity: `var(--${prefix}-color-action-hoverOpacity)`,
|
|
3817
|
-
selected: `var(--${prefix}-color-action-selected)`,
|
|
3818
|
-
selectedOpacity: `var(--${prefix}-color-action-selectedOpacity)`,
|
|
3819
3824
|
disabled: `var(--${prefix}-color-action-disabled)`,
|
|
3820
3825
|
disabledBackground: `var(--${prefix}-color-action-disabledBackground)`,
|
|
3821
3826
|
disabledOpacity: `var(--${prefix}-color-action-disabledOpacity)`,
|
|
3822
3827
|
focus: `var(--${prefix}-color-action-focus)`,
|
|
3823
3828
|
focusOpacity: `var(--${prefix}-color-action-focusOpacity)`,
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
contrastText: `var(--${prefix}-color-primary-contrastText)`
|
|
3829
|
-
},
|
|
3830
|
-
secondary: {
|
|
3831
|
-
main: `var(--${prefix}-color-secondary-main)`,
|
|
3832
|
-
contrastText: `var(--${prefix}-color-secondary-contrastText)`
|
|
3829
|
+
hover: `var(--${prefix}-color-action-hover)`,
|
|
3830
|
+
hoverOpacity: `var(--${prefix}-color-action-hoverOpacity)`,
|
|
3831
|
+
selected: `var(--${prefix}-color-action-selected)`,
|
|
3832
|
+
selectedOpacity: `var(--${prefix}-color-action-selectedOpacity)`
|
|
3833
3833
|
},
|
|
3834
3834
|
background: {
|
|
3835
|
-
surface: `var(--${prefix}-color-background-surface)`,
|
|
3836
|
-
disabled: `var(--${prefix}-color-background-disabled)`,
|
|
3837
3835
|
body: {
|
|
3838
3836
|
main: `var(--${prefix}-color-background-body-main)`
|
|
3839
|
-
}
|
|
3837
|
+
},
|
|
3838
|
+
disabled: `var(--${prefix}-color-background-disabled)`,
|
|
3839
|
+
surface: `var(--${prefix}-color-background-surface)`
|
|
3840
3840
|
},
|
|
3841
|
+
border: `var(--${prefix}-color-border)`,
|
|
3841
3842
|
error: {
|
|
3842
|
-
|
|
3843
|
-
|
|
3843
|
+
contrastText: `var(--${prefix}-color-error-contrastText)`,
|
|
3844
|
+
main: `var(--${prefix}-color-error-main)`
|
|
3844
3845
|
},
|
|
3845
3846
|
info: {
|
|
3846
3847
|
contrastText: `var(--${prefix}-color-info-contrastText)`,
|
|
3847
3848
|
main: `var(--${prefix}-color-info-main)`
|
|
3848
3849
|
},
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3850
|
+
primary: {
|
|
3851
|
+
contrastText: `var(--${prefix}-color-primary-contrastText)`,
|
|
3852
|
+
main: `var(--${prefix}-color-primary-main)`
|
|
3852
3853
|
},
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3854
|
+
secondary: {
|
|
3855
|
+
contrastText: `var(--${prefix}-color-secondary-contrastText)`,
|
|
3856
|
+
main: `var(--${prefix}-color-secondary-main)`
|
|
3857
|
+
},
|
|
3858
|
+
success: {
|
|
3859
|
+
contrastText: `var(--${prefix}-color-success-contrastText)`,
|
|
3860
|
+
main: `var(--${prefix}-color-success-main)`
|
|
3856
3861
|
},
|
|
3857
3862
|
text: {
|
|
3858
3863
|
primary: `var(--${prefix}-color-text-primary)`,
|
|
3859
3864
|
secondary: `var(--${prefix}-color-text-secondary)`
|
|
3860
3865
|
},
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
},
|
|
3866
|
-
borderRadius: {
|
|
3867
|
-
small: `var(--${prefix}-border-radius-small)`,
|
|
3868
|
-
medium: `var(--${prefix}-border-radius-medium)`,
|
|
3869
|
-
large: `var(--${prefix}-border-radius-large)`
|
|
3866
|
+
warning: {
|
|
3867
|
+
contrastText: `var(--${prefix}-color-warning-contrastText)`,
|
|
3868
|
+
main: `var(--${prefix}-color-warning-main)`
|
|
3869
|
+
}
|
|
3870
3870
|
},
|
|
3871
3871
|
shadows: {
|
|
3872
|
-
|
|
3872
|
+
large: `var(--${prefix}-shadow-large)`,
|
|
3873
3873
|
medium: `var(--${prefix}-shadow-medium)`,
|
|
3874
|
-
|
|
3874
|
+
small: `var(--${prefix}-shadow-small)`
|
|
3875
|
+
},
|
|
3876
|
+
spacing: {
|
|
3877
|
+
unit: `var(--${prefix}-spacing-unit)`
|
|
3875
3878
|
},
|
|
3876
3879
|
typography: {
|
|
3877
3880
|
fontFamily: `var(--${prefix}-typography-fontFamily)`,
|
|
3878
3881
|
fontSizes: {
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
md: `var(--${prefix}-typography-fontSize-md)`,
|
|
3882
|
+
"2xl": `var(--${prefix}-typography-fontSize-2xl)`,
|
|
3883
|
+
"3xl": `var(--${prefix}-typography-fontSize-3xl)`,
|
|
3882
3884
|
lg: `var(--${prefix}-typography-fontSize-lg)`,
|
|
3885
|
+
md: `var(--${prefix}-typography-fontSize-md)`,
|
|
3886
|
+
sm: `var(--${prefix}-typography-fontSize-sm)`,
|
|
3883
3887
|
xl: `var(--${prefix}-typography-fontSize-xl)`,
|
|
3884
|
-
|
|
3885
|
-
"3xl": `var(--${prefix}-typography-fontSize-3xl)`
|
|
3888
|
+
xs: `var(--${prefix}-typography-fontSize-xs)`
|
|
3886
3889
|
},
|
|
3887
3890
|
fontWeights: {
|
|
3888
|
-
|
|
3891
|
+
bold: `var(--${prefix}-typography-fontWeight-bold)`,
|
|
3889
3892
|
medium: `var(--${prefix}-typography-fontWeight-medium)`,
|
|
3890
|
-
|
|
3891
|
-
|
|
3893
|
+
normal: `var(--${prefix}-typography-fontWeight-normal)`,
|
|
3894
|
+
semibold: `var(--${prefix}-typography-fontWeight-semibold)`
|
|
3892
3895
|
},
|
|
3893
3896
|
lineHeights: {
|
|
3894
|
-
tight: `var(--${prefix}-typography-lineHeight-tight)`,
|
|
3895
3897
|
normal: `var(--${prefix}-typography-lineHeight-normal)`,
|
|
3896
|
-
relaxed: `var(--${prefix}-typography-lineHeight-relaxed)
|
|
3898
|
+
relaxed: `var(--${prefix}-typography-lineHeight-relaxed)`,
|
|
3899
|
+
tight: `var(--${prefix}-typography-lineHeight-tight)`
|
|
3897
3900
|
}
|
|
3898
3901
|
}
|
|
3899
3902
|
};
|
|
@@ -3902,9 +3905,9 @@ var toThemeVars = (theme) => {
|
|
|
3902
3905
|
Object.keys(theme.images).forEach((imageKey) => {
|
|
3903
3906
|
const imageConfig = theme.images[imageKey];
|
|
3904
3907
|
themeVars.images[imageKey] = {
|
|
3905
|
-
|
|
3908
|
+
alt: imageConfig?.alt ? `var(--${prefix}-image-${imageKey}-alt)` : void 0,
|
|
3906
3909
|
title: imageConfig?.title ? `var(--${prefix}-image-${imageKey}-title)` : void 0,
|
|
3907
|
-
|
|
3910
|
+
url: imageConfig?.url ? `var(--${prefix}-image-${imageKey}-url)` : void 0
|
|
3908
3911
|
};
|
|
3909
3912
|
});
|
|
3910
3913
|
}
|
|
@@ -3918,6 +3921,10 @@ var createTheme = (config = {}, isDark = false) => {
|
|
|
3918
3921
|
const mergedConfig = {
|
|
3919
3922
|
...baseTheme,
|
|
3920
3923
|
...config,
|
|
3924
|
+
borderRadius: {
|
|
3925
|
+
...baseTheme.borderRadius,
|
|
3926
|
+
...config.borderRadius
|
|
3927
|
+
},
|
|
3921
3928
|
colors: {
|
|
3922
3929
|
...baseTheme.colors,
|
|
3923
3930
|
...config.colors,
|
|
@@ -3930,18 +3937,18 @@ var createTheme = (config = {}, isDark = false) => {
|
|
|
3930
3937
|
...config.colors?.secondary || {}
|
|
3931
3938
|
}
|
|
3932
3939
|
},
|
|
3933
|
-
|
|
3934
|
-
...baseTheme.
|
|
3935
|
-
...config.
|
|
3936
|
-
},
|
|
3937
|
-
borderRadius: {
|
|
3938
|
-
...baseTheme.borderRadius,
|
|
3939
|
-
...config.borderRadius
|
|
3940
|
+
images: {
|
|
3941
|
+
...baseTheme.images,
|
|
3942
|
+
...config.images
|
|
3940
3943
|
},
|
|
3941
3944
|
shadows: {
|
|
3942
3945
|
...baseTheme.shadows,
|
|
3943
3946
|
...config.shadows
|
|
3944
3947
|
},
|
|
3948
|
+
spacing: {
|
|
3949
|
+
...baseTheme.spacing,
|
|
3950
|
+
...config.spacing
|
|
3951
|
+
},
|
|
3945
3952
|
typography: {
|
|
3946
3953
|
...baseTheme.typography,
|
|
3947
3954
|
...config.typography,
|
|
@@ -3957,10 +3964,6 @@ var createTheme = (config = {}, isDark = false) => {
|
|
|
3957
3964
|
...baseTheme.typography.lineHeights,
|
|
3958
3965
|
...config.typography?.lineHeights || {}
|
|
3959
3966
|
}
|
|
3960
|
-
},
|
|
3961
|
-
images: {
|
|
3962
|
-
...baseTheme.images,
|
|
3963
|
-
...config.images
|
|
3964
3967
|
}
|
|
3965
3968
|
};
|
|
3966
3969
|
return {
|
|
@@ -3976,7 +3979,7 @@ var createTheme_default = createTheme;
|
|
|
3976
3979
|
var arrayBufferToBase64url = (buffer) => {
|
|
3977
3980
|
const bytes = new Uint8Array(buffer);
|
|
3978
3981
|
let binary = "";
|
|
3979
|
-
for (let i = 0; i < bytes.byteLength; i
|
|
3982
|
+
for (let i = 0; i < bytes.byteLength; i += 1) {
|
|
3980
3983
|
binary += String.fromCharCode(bytes[i]);
|
|
3981
3984
|
}
|
|
3982
3985
|
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
@@ -3989,7 +3992,7 @@ var base64urlToArrayBuffer = (base64url) => {
|
|
|
3989
3992
|
const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/") + padding;
|
|
3990
3993
|
const binaryString = atob(base64);
|
|
3991
3994
|
const bytes = new Uint8Array(binaryString.length);
|
|
3992
|
-
for (let i = 0; i < binaryString.length; i
|
|
3995
|
+
for (let i = 0; i < binaryString.length; i += 1) {
|
|
3993
3996
|
bytes[i] = binaryString.charCodeAt(i);
|
|
3994
3997
|
}
|
|
3995
3998
|
return bytes.buffer;
|
|
@@ -4014,9 +4017,9 @@ var formatDate = (dateString) => {
|
|
|
4014
4017
|
if (!dateString) return "-";
|
|
4015
4018
|
try {
|
|
4016
4019
|
return new Date(dateString).toLocaleDateString("en-US", {
|
|
4017
|
-
|
|
4020
|
+
day: "numeric",
|
|
4018
4021
|
month: "long",
|
|
4019
|
-
|
|
4022
|
+
year: "numeric"
|
|
4020
4023
|
});
|
|
4021
4024
|
} catch {
|
|
4022
4025
|
return dateString;
|
|
@@ -4025,9 +4028,7 @@ var formatDate = (dateString) => {
|
|
|
4025
4028
|
var formatDate_default = formatDate;
|
|
4026
4029
|
|
|
4027
4030
|
// src/utils/deepMerge.ts
|
|
4028
|
-
var isPlainObject = (value) =>
|
|
4029
|
-
return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof RegExp) && Object.prototype.toString.call(value) === "[object Object]";
|
|
4030
|
-
};
|
|
4031
|
+
var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof RegExp) && Object.prototype.toString.call(value) === "[object Object]";
|
|
4031
4032
|
var deepMerge = (target, ...sources) => {
|
|
4032
4033
|
if (!target || typeof target !== "object") {
|
|
4033
4034
|
throw new Error("Target must be an object");
|
|
@@ -4051,95 +4052,48 @@ var deepMerge = (target, ...sources) => {
|
|
|
4051
4052
|
};
|
|
4052
4053
|
var deepMerge_default = deepMerge;
|
|
4053
4054
|
|
|
4054
|
-
// src/utils/deriveOrganizationHandleFromBaseUrl.ts
|
|
4055
|
-
var deriveOrganizationHandleFromBaseUrl = (baseUrl) => {
|
|
4056
|
-
if (!baseUrl) {
|
|
4057
|
-
throw new AsgardeoRuntimeError(
|
|
4058
|
-
"Base URL is required to derive organization handle.",
|
|
4059
|
-
"javascript-deriveOrganizationHandleFromBaseUrl-ValidationError-001",
|
|
4060
|
-
"javascript",
|
|
4061
|
-
"A valid base URL must be provided to extract the organization handle."
|
|
4062
|
-
);
|
|
4063
|
-
}
|
|
4064
|
-
let parsedUrl;
|
|
4065
|
-
try {
|
|
4066
|
-
parsedUrl = new URL(baseUrl);
|
|
4067
|
-
} catch (error2) {
|
|
4068
|
-
throw new AsgardeoRuntimeError(
|
|
4069
|
-
`Invalid base URL format: ${baseUrl}`,
|
|
4070
|
-
"javascript-deriveOrganizationHandleFromBaseUrl-ValidationError-002",
|
|
4071
|
-
"javascript",
|
|
4072
|
-
"The provided base URL does not conform to valid URL syntax."
|
|
4073
|
-
);
|
|
4074
|
-
}
|
|
4075
|
-
const pathSegments = parsedUrl.pathname?.split("/")?.filter((segment) => segment?.length > 0);
|
|
4076
|
-
if (pathSegments.length < 2 || pathSegments[0] !== "t") {
|
|
4077
|
-
console.warn(
|
|
4078
|
-
new AsgardeoRuntimeError(
|
|
4079
|
-
"Organization handle is required since a custom domain is configured.",
|
|
4080
|
-
"javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-002",
|
|
4081
|
-
"javascript",
|
|
4082
|
-
"The provided base URL does not follow the expected URL pattern (/t/{orgHandle}). Please provide the organizationHandle explicitly in the configuration."
|
|
4083
|
-
).toString()
|
|
4084
|
-
);
|
|
4085
|
-
return "";
|
|
4086
|
-
}
|
|
4087
|
-
const organizationHandle = pathSegments[1];
|
|
4088
|
-
if (!organizationHandle || organizationHandle.trim().length === 0) {
|
|
4089
|
-
console.warn(
|
|
4090
|
-
new AsgardeoRuntimeError(
|
|
4091
|
-
"Organization handle is required since a custom domain is configured.",
|
|
4092
|
-
"javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-003",
|
|
4093
|
-
"javascript",
|
|
4094
|
-
"The organization handle could not be extracted from the base URL. Please provide the organizationHandle explicitly in the configuration."
|
|
4095
|
-
).toString()
|
|
4096
|
-
);
|
|
4097
|
-
return "";
|
|
4098
|
-
}
|
|
4099
|
-
return organizationHandle;
|
|
4100
|
-
};
|
|
4101
|
-
var deriveOrganizationHandleFromBaseUrl_default = deriveOrganizationHandleFromBaseUrl;
|
|
4102
|
-
|
|
4103
4055
|
// src/utils/logger.ts
|
|
4104
4056
|
var PREFIX = "\u{1F6E1}\uFE0F Asgardeo";
|
|
4105
4057
|
var DEFAULT_CONFIG = {
|
|
4106
4058
|
level: "info",
|
|
4107
4059
|
prefix: `${PREFIX}`,
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
};
|
|
4111
|
-
var isBrowser = () => {
|
|
4112
|
-
return typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
4113
|
-
};
|
|
4114
|
-
var isNode = () => {
|
|
4115
|
-
return typeof process !== "undefined" && process.versions && process.versions.node;
|
|
4060
|
+
showLevel: true,
|
|
4061
|
+
timestamps: true
|
|
4116
4062
|
};
|
|
4063
|
+
var isBrowser = () => (
|
|
4064
|
+
/* @ts-ignore */
|
|
4065
|
+
typeof window !== "undefined" && typeof window.document !== "undefined"
|
|
4066
|
+
);
|
|
4067
|
+
var isNode = () => (
|
|
4068
|
+
/* @ts-ignore */
|
|
4069
|
+
typeof process !== "undefined" && process.versions && process.versions.node
|
|
4070
|
+
);
|
|
4117
4071
|
var COLORS = {
|
|
4118
|
-
|
|
4072
|
+
blue: "\x1B[34m",
|
|
4119
4073
|
bright: "\x1B[1m",
|
|
4074
|
+
cyan: "\x1B[36m",
|
|
4120
4075
|
dim: "\x1B[2m",
|
|
4121
|
-
|
|
4076
|
+
gray: "\x1B[90m",
|
|
4122
4077
|
green: "\x1B[32m",
|
|
4123
|
-
yellow: "\x1B[33m",
|
|
4124
|
-
blue: "\x1B[34m",
|
|
4125
4078
|
magenta: "\x1B[35m",
|
|
4126
|
-
|
|
4079
|
+
red: "\x1B[31m",
|
|
4080
|
+
reset: "\x1B[0m",
|
|
4127
4081
|
white: "\x1B[37m",
|
|
4128
|
-
|
|
4082
|
+
yellow: "\x1B[33m"
|
|
4129
4083
|
};
|
|
4130
4084
|
var BROWSER_STYLES = {
|
|
4131
4085
|
debug: "color: #6b7280; font-weight: normal;",
|
|
4132
|
-
info: "color: #2563eb; font-weight: bold;",
|
|
4133
|
-
warn: "color: #d97706; font-weight: bold;",
|
|
4134
4086
|
error: "color: #dc2626; font-weight: bold;",
|
|
4087
|
+
info: "color: #2563eb; font-weight: bold;",
|
|
4135
4088
|
prefix: "color: #7c3aed; font-weight: bold;",
|
|
4136
|
-
timestamp: "color: #6b7280; font-size: 0.9em;"
|
|
4089
|
+
timestamp: "color: #6b7280; font-size: 0.9em;",
|
|
4090
|
+
warn: "color: #d97706; font-weight: bold;"
|
|
4137
4091
|
};
|
|
4138
4092
|
var LOG_LEVEL_ORDER = {
|
|
4139
4093
|
debug: 0,
|
|
4094
|
+
error: 3,
|
|
4140
4095
|
info: 1,
|
|
4141
|
-
warn: 2
|
|
4142
|
-
error: 3
|
|
4096
|
+
warn: 2
|
|
4143
4097
|
};
|
|
4144
4098
|
var Logger = class _Logger {
|
|
4145
4099
|
constructor(config = {}) {
|
|
@@ -4167,13 +4121,13 @@ var Logger = class _Logger {
|
|
|
4167
4121
|
/**
|
|
4168
4122
|
* Get timestamp string
|
|
4169
4123
|
*/
|
|
4170
|
-
getTimestamp() {
|
|
4124
|
+
static getTimestamp() {
|
|
4171
4125
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
4172
4126
|
}
|
|
4173
4127
|
/**
|
|
4174
4128
|
* Get log level string
|
|
4175
4129
|
*/
|
|
4176
|
-
getLevelString(level) {
|
|
4130
|
+
static getLevelString(level) {
|
|
4177
4131
|
switch (level) {
|
|
4178
4132
|
case "debug":
|
|
4179
4133
|
return "DEBUG";
|
|
@@ -4193,13 +4147,13 @@ var Logger = class _Logger {
|
|
|
4193
4147
|
formatForNode(level, message) {
|
|
4194
4148
|
const parts = [];
|
|
4195
4149
|
if (this.config.timestamps) {
|
|
4196
|
-
parts.push(`${COLORS.gray}[${
|
|
4150
|
+
parts.push(`${COLORS.gray}[${_Logger.getTimestamp()}]${COLORS.reset}`);
|
|
4197
4151
|
}
|
|
4198
4152
|
if (this.config.prefix) {
|
|
4199
4153
|
parts.push(`${COLORS.magenta}${this.config.prefix}${COLORS.reset}`);
|
|
4200
4154
|
}
|
|
4201
4155
|
if (this.config.showLevel) {
|
|
4202
|
-
const levelStr =
|
|
4156
|
+
const levelStr = _Logger.getLevelString(level);
|
|
4203
4157
|
let coloredLevel;
|
|
4204
4158
|
switch (level) {
|
|
4205
4159
|
case "debug":
|
|
@@ -4248,7 +4202,7 @@ var Logger = class _Logger {
|
|
|
4248
4202
|
const parts = [];
|
|
4249
4203
|
const styles = [];
|
|
4250
4204
|
if (this.config.timestamps) {
|
|
4251
|
-
parts.push(`%c[${
|
|
4205
|
+
parts.push(`%c[${_Logger.getTimestamp()}]`);
|
|
4252
4206
|
styles.push(BROWSER_STYLES.timestamp);
|
|
4253
4207
|
}
|
|
4254
4208
|
if (this.config.prefix) {
|
|
@@ -4256,7 +4210,7 @@ var Logger = class _Logger {
|
|
|
4256
4210
|
styles.push(BROWSER_STYLES.prefix);
|
|
4257
4211
|
}
|
|
4258
4212
|
if (this.config.showLevel) {
|
|
4259
|
-
const levelStr =
|
|
4213
|
+
const levelStr = _Logger.getLevelString(level);
|
|
4260
4214
|
parts.push(`%c[${levelStr}]`);
|
|
4261
4215
|
switch (level) {
|
|
4262
4216
|
case "debug":
|
|
@@ -4365,31 +4319,74 @@ var Logger = class _Logger {
|
|
|
4365
4319
|
}
|
|
4366
4320
|
};
|
|
4367
4321
|
var logger = new Logger();
|
|
4368
|
-
var createLogger = (config) =>
|
|
4369
|
-
return new Logger(config);
|
|
4370
|
-
};
|
|
4322
|
+
var createLogger = (config) => new Logger(config);
|
|
4371
4323
|
var logger_default = logger;
|
|
4372
4324
|
var debug = (message, ...args) => logger.debug(message, ...args);
|
|
4373
4325
|
var info = (message, ...args) => logger.info(message, ...args);
|
|
4374
4326
|
var warn = (message, ...args) => logger.warn(message, ...args);
|
|
4375
4327
|
var error = (message, ...args) => logger.error(message, ...args);
|
|
4376
4328
|
var configure = (config) => logger.configure(config);
|
|
4377
|
-
var createComponentLogger = (component) =>
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
timestamps: true,
|
|
4385
|
-
showLevel: true
|
|
4386
|
-
});
|
|
4387
|
-
};
|
|
4329
|
+
var createComponentLogger = (component) => logger.child(component);
|
|
4330
|
+
var createPackageLogger = (packageName) => createLogger({
|
|
4331
|
+
level: "info",
|
|
4332
|
+
prefix: `${PREFIX} - ${packageName}`,
|
|
4333
|
+
showLevel: true,
|
|
4334
|
+
timestamps: true
|
|
4335
|
+
});
|
|
4388
4336
|
var createPackageComponentLogger = (packageName, component) => {
|
|
4389
4337
|
const packageLogger = createPackageLogger(packageName);
|
|
4390
4338
|
return packageLogger.child(component);
|
|
4391
4339
|
};
|
|
4392
4340
|
|
|
4341
|
+
// src/utils/deriveOrganizationHandleFromBaseUrl.ts
|
|
4342
|
+
var deriveOrganizationHandleFromBaseUrl = (baseUrl) => {
|
|
4343
|
+
if (!baseUrl) {
|
|
4344
|
+
throw new AsgardeoRuntimeError(
|
|
4345
|
+
"Base URL is required to derive organization handle.",
|
|
4346
|
+
"javascript-deriveOrganizationHandleFromBaseUrl-ValidationError-001",
|
|
4347
|
+
"javascript",
|
|
4348
|
+
"A valid base URL must be provided to extract the organization handle."
|
|
4349
|
+
);
|
|
4350
|
+
}
|
|
4351
|
+
let parsedUrl;
|
|
4352
|
+
try {
|
|
4353
|
+
parsedUrl = new URL(baseUrl);
|
|
4354
|
+
} catch (error2) {
|
|
4355
|
+
throw new AsgardeoRuntimeError(
|
|
4356
|
+
`Invalid base URL format: ${baseUrl}`,
|
|
4357
|
+
"javascript-deriveOrganizationHandleFromBaseUrl-ValidationError-002",
|
|
4358
|
+
"javascript",
|
|
4359
|
+
"The provided base URL does not conform to valid URL syntax."
|
|
4360
|
+
);
|
|
4361
|
+
}
|
|
4362
|
+
const pathSegments = parsedUrl.pathname?.split("/")?.filter((segment) => segment?.length > 0);
|
|
4363
|
+
if (pathSegments.length < 2 || pathSegments[0] !== "t") {
|
|
4364
|
+
logger_default.warn(
|
|
4365
|
+
new AsgardeoRuntimeError(
|
|
4366
|
+
"Organization handle is required since a custom domain is configured.",
|
|
4367
|
+
"javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-002",
|
|
4368
|
+
"javascript",
|
|
4369
|
+
"The provided base URL does not follow the expected URL pattern (/t/{orgHandle}). Please provide the organizationHandle explicitly in the configuration."
|
|
4370
|
+
).toString()
|
|
4371
|
+
);
|
|
4372
|
+
return "";
|
|
4373
|
+
}
|
|
4374
|
+
const organizationHandle = pathSegments[1];
|
|
4375
|
+
if (!organizationHandle || organizationHandle.trim().length === 0) {
|
|
4376
|
+
logger_default.warn(
|
|
4377
|
+
new AsgardeoRuntimeError(
|
|
4378
|
+
"Organization handle is required since a custom domain is configured.",
|
|
4379
|
+
"javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-003",
|
|
4380
|
+
"javascript",
|
|
4381
|
+
"The organization handle could not be extracted from the base URL. Please provide the organizationHandle explicitly in the configuration."
|
|
4382
|
+
).toString()
|
|
4383
|
+
);
|
|
4384
|
+
return "";
|
|
4385
|
+
}
|
|
4386
|
+
return organizationHandle;
|
|
4387
|
+
};
|
|
4388
|
+
var deriveOrganizationHandleFromBaseUrl_default = deriveOrganizationHandleFromBaseUrl;
|
|
4389
|
+
|
|
4393
4390
|
// src/utils/isRecognizedBaseUrlPattern.ts
|
|
4394
4391
|
var isRecognizedBaseUrlPattern = (baseUrl) => {
|
|
4395
4392
|
if (!baseUrl) {
|
|
@@ -4413,7 +4410,9 @@ var isRecognizedBaseUrlPattern = (baseUrl) => {
|
|
|
4413
4410
|
}
|
|
4414
4411
|
const pathSegments = parsedUrl.pathname?.split("/")?.filter((segment) => segment?.length > 0);
|
|
4415
4412
|
if (pathSegments.length < 2 || pathSegments[0] !== "t") {
|
|
4416
|
-
logger_default.warn(
|
|
4413
|
+
logger_default.warn(
|
|
4414
|
+
"[isRecognizedBaseUrlPattern] The provided base URL does not follow the expected URL pattern (/t/{orgHandle})."
|
|
4415
|
+
);
|
|
4417
4416
|
return false;
|
|
4418
4417
|
}
|
|
4419
4418
|
return true;
|
|
@@ -4451,9 +4450,7 @@ var flattenUserSchema_default = flattenUserSchema;
|
|
|
4451
4450
|
var get = (object, path, defaultValue) => {
|
|
4452
4451
|
if (!object || !path) return defaultValue;
|
|
4453
4452
|
const pathArray = Array.isArray(path) ? path : path.split(".");
|
|
4454
|
-
const result = pathArray.reduce((current, key) =>
|
|
4455
|
-
return current?.[key];
|
|
4456
|
-
}, object);
|
|
4453
|
+
const result = pathArray.reduce((current, key) => current?.[key], object);
|
|
4457
4454
|
return result !== void 0 ? result : defaultValue;
|
|
4458
4455
|
};
|
|
4459
4456
|
var get_default = get;
|
|
@@ -4466,11 +4463,9 @@ var set = (object, path, value) => {
|
|
|
4466
4463
|
pathArray.reduce((current, key, index) => {
|
|
4467
4464
|
if (index === lastIndex) {
|
|
4468
4465
|
current[key] = value;
|
|
4469
|
-
} else {
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
current[key] = /^\d+$/.test(nextKey) ? [] : {};
|
|
4473
|
-
}
|
|
4466
|
+
} else if (!(key in current) || typeof current[key] !== "object" || current[key] === null) {
|
|
4467
|
+
const nextKey = pathArray[index + 1];
|
|
4468
|
+
current[key] = /^\d+$/.test(nextKey) ? [] : {};
|
|
4474
4469
|
}
|
|
4475
4470
|
return current[key];
|
|
4476
4471
|
}, object);
|
|
@@ -4489,14 +4484,12 @@ var generateUserProfile = (meResponse, processedSchemas) => {
|
|
|
4489
4484
|
if (multiValued && !Array.isArray(value)) {
|
|
4490
4485
|
value = [value];
|
|
4491
4486
|
}
|
|
4487
|
+
} else if (multiValued) {
|
|
4488
|
+
value = void 0;
|
|
4489
|
+
} else if (type === "STRING") {
|
|
4490
|
+
value = "";
|
|
4492
4491
|
} else {
|
|
4493
|
-
|
|
4494
|
-
value = void 0;
|
|
4495
|
-
} else if (type === "STRING") {
|
|
4496
|
-
value = "";
|
|
4497
|
-
} else {
|
|
4498
|
-
value = void 0;
|
|
4499
|
-
}
|
|
4492
|
+
value = void 0;
|
|
4500
4493
|
}
|
|
4501
4494
|
set_default(profile, name, value);
|
|
4502
4495
|
});
|
|
@@ -4640,7 +4633,7 @@ var getRedirectBasedSignUpUrl = (config) => {
|
|
|
4640
4633
|
);
|
|
4641
4634
|
}
|
|
4642
4635
|
}
|
|
4643
|
-
const url = new URL(signUpBaseUrl
|
|
4636
|
+
const url = new URL(`${signUpBaseUrl}/accountrecoveryendpoint/register.do`);
|
|
4644
4637
|
if (config.clientId) {
|
|
4645
4638
|
url.searchParams.set("client_id", config.clientId);
|
|
4646
4639
|
}
|
|
@@ -4661,13 +4654,14 @@ var resolveFieldType = (field) => {
|
|
|
4661
4654
|
if (field.type === "STRING" /* String */) {
|
|
4662
4655
|
if (field.param === "OTPCode" /* Otp */) {
|
|
4663
4656
|
return "OTP" /* Otp */;
|
|
4664
|
-
}
|
|
4657
|
+
}
|
|
4658
|
+
if (field?.confidential) {
|
|
4665
4659
|
return "PASSWORD" /* Password */;
|
|
4666
4660
|
}
|
|
4667
4661
|
return "TEXT" /* Text */;
|
|
4668
4662
|
}
|
|
4669
4663
|
throw new AsgardeoRuntimeError(
|
|
4670
|
-
|
|
4664
|
+
`Field type is not supported: ${field.type}`,
|
|
4671
4665
|
"resolveFieldType-Invalid-001",
|
|
4672
4666
|
"javascript",
|
|
4673
4667
|
"The provided field type is not supported. Please check the field configuration."
|
|
@@ -4700,85 +4694,83 @@ var extractColorValue = (colorVariant, preferDark = false) => {
|
|
|
4700
4694
|
}
|
|
4701
4695
|
return colorVariant?.main;
|
|
4702
4696
|
};
|
|
4703
|
-
var extractContrastText = (colorVariant) =>
|
|
4704
|
-
return colorVariant?.contrastText;
|
|
4705
|
-
};
|
|
4697
|
+
var extractContrastText = (colorVariant) => colorVariant?.contrastText;
|
|
4706
4698
|
var transformThemeVariant = (themeVariant, isDark = false) => {
|
|
4707
|
-
const
|
|
4708
|
-
const
|
|
4709
|
-
const
|
|
4710
|
-
const
|
|
4699
|
+
const { buttons } = themeVariant;
|
|
4700
|
+
const { colors } = themeVariant;
|
|
4701
|
+
const { images } = themeVariant;
|
|
4702
|
+
const { inputs } = themeVariant;
|
|
4711
4703
|
const config = {
|
|
4712
4704
|
colors: {
|
|
4713
4705
|
action: {
|
|
4706
|
+
activatedOpacity: 0.12,
|
|
4714
4707
|
active: isDark ? "rgba(255, 255, 255, 0.70)" : "rgba(0, 0, 0, 0.54)",
|
|
4715
|
-
hover: isDark ? "rgba(255, 255, 255, 0.04)" : "rgba(0, 0, 0, 0.04)",
|
|
4716
|
-
hoverOpacity: 0.04,
|
|
4717
|
-
selected: isDark ? "rgba(255, 255, 255, 0.08)" : "rgba(0, 0, 0, 0.08)",
|
|
4718
|
-
selectedOpacity: 0.08,
|
|
4719
4708
|
disabled: isDark ? "rgba(255, 255, 255, 0.26)" : "rgba(0, 0, 0, 0.26)",
|
|
4720
4709
|
disabledBackground: isDark ? "rgba(255, 255, 255, 0.12)" : "rgba(0, 0, 0, 0.12)",
|
|
4721
4710
|
disabledOpacity: 0.38,
|
|
4722
4711
|
focus: isDark ? "rgba(255, 255, 255, 0.12)" : "rgba(0, 0, 0, 0.12)",
|
|
4723
4712
|
focusOpacity: 0.12,
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
contrastText: extractContrastText(colors?.primary),
|
|
4729
|
-
dark: colors?.primary?.dark || colors?.primary?.main
|
|
4730
|
-
},
|
|
4731
|
-
secondary: {
|
|
4732
|
-
main: extractColorValue(colors?.secondary, isDark),
|
|
4733
|
-
contrastText: extractContrastText(colors?.secondary),
|
|
4734
|
-
dark: colors?.secondary?.dark || colors?.secondary?.main
|
|
4713
|
+
hover: isDark ? "rgba(255, 255, 255, 0.04)" : "rgba(0, 0, 0, 0.04)",
|
|
4714
|
+
hoverOpacity: 0.04,
|
|
4715
|
+
selected: isDark ? "rgba(255, 255, 255, 0.08)" : "rgba(0, 0, 0, 0.08)",
|
|
4716
|
+
selectedOpacity: 0.08
|
|
4735
4717
|
},
|
|
4736
4718
|
background: {
|
|
4737
|
-
surface: extractColorValue(colors?.background?.surface, isDark),
|
|
4738
|
-
disabled: extractColorValue(colors?.background?.surface, isDark),
|
|
4739
|
-
dark: colors?.background?.surface?.dark || colors?.background?.surface?.main,
|
|
4740
4719
|
body: {
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
}
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
secondary: colors?.text?.secondary,
|
|
4748
|
-
dark: colors?.text?.dark || colors?.text?.primary
|
|
4720
|
+
dark: colors?.background?.body?.dark || colors?.background?.body?.main,
|
|
4721
|
+
main: extractColorValue(colors?.background?.body, isDark)
|
|
4722
|
+
},
|
|
4723
|
+
dark: colors?.background?.surface?.dark || colors?.background?.surface?.main,
|
|
4724
|
+
disabled: extractColorValue(colors?.background?.surface, isDark),
|
|
4725
|
+
surface: extractColorValue(colors?.background?.surface, isDark)
|
|
4749
4726
|
},
|
|
4750
4727
|
border: colors?.outlined?.default,
|
|
4751
4728
|
error: {
|
|
4752
|
-
main: extractColorValue(colors?.alerts?.error, isDark),
|
|
4753
4729
|
contrastText: extractContrastText(colors?.alerts?.error),
|
|
4754
|
-
dark: colors?.alerts?.error?.dark || colors?.alerts?.error?.main
|
|
4730
|
+
dark: colors?.alerts?.error?.dark || colors?.alerts?.error?.main,
|
|
4731
|
+
main: extractColorValue(colors?.alerts?.error, isDark)
|
|
4755
4732
|
},
|
|
4756
4733
|
info: {
|
|
4757
|
-
main: extractColorValue(colors?.alerts?.info, isDark),
|
|
4758
4734
|
contrastText: extractContrastText(colors?.alerts?.info),
|
|
4759
|
-
dark: colors?.alerts?.info?.dark || colors?.alerts?.info?.main
|
|
4735
|
+
dark: colors?.alerts?.info?.dark || colors?.alerts?.info?.main,
|
|
4736
|
+
main: extractColorValue(colors?.alerts?.info, isDark)
|
|
4737
|
+
},
|
|
4738
|
+
primary: {
|
|
4739
|
+
contrastText: extractContrastText(colors?.primary),
|
|
4740
|
+
dark: colors?.primary?.dark || colors?.primary?.main,
|
|
4741
|
+
main: extractColorValue(colors?.primary, isDark)
|
|
4742
|
+
},
|
|
4743
|
+
secondary: {
|
|
4744
|
+
contrastText: extractContrastText(colors?.secondary),
|
|
4745
|
+
dark: colors?.secondary?.dark || colors?.secondary?.main,
|
|
4746
|
+
main: extractColorValue(colors?.secondary, isDark)
|
|
4760
4747
|
},
|
|
4761
4748
|
success: {
|
|
4762
|
-
main: extractColorValue(colors?.alerts?.neutral, isDark),
|
|
4763
4749
|
contrastText: extractContrastText(colors?.alerts?.neutral),
|
|
4764
|
-
dark: colors?.alerts?.neutral?.dark || colors?.alerts?.neutral?.main
|
|
4750
|
+
dark: colors?.alerts?.neutral?.dark || colors?.alerts?.neutral?.main,
|
|
4751
|
+
main: extractColorValue(colors?.alerts?.neutral, isDark)
|
|
4752
|
+
},
|
|
4753
|
+
text: {
|
|
4754
|
+
dark: colors?.text?.dark || colors?.text?.primary,
|
|
4755
|
+
primary: colors?.text?.primary,
|
|
4756
|
+
secondary: colors?.text?.secondary
|
|
4765
4757
|
},
|
|
4766
4758
|
warning: {
|
|
4767
|
-
main: extractColorValue(colors?.alerts?.warning, isDark),
|
|
4768
4759
|
contrastText: extractContrastText(colors?.alerts?.warning),
|
|
4769
|
-
dark: colors?.alerts?.warning?.dark || colors?.alerts?.warning?.main
|
|
4760
|
+
dark: colors?.alerts?.warning?.dark || colors?.alerts?.warning?.main,
|
|
4761
|
+
main: extractColorValue(colors?.alerts?.warning, isDark)
|
|
4770
4762
|
}
|
|
4771
4763
|
},
|
|
4772
4764
|
images: {
|
|
4773
4765
|
favicon: images?.favicon ? {
|
|
4774
|
-
|
|
4766
|
+
alt: images.favicon.altText,
|
|
4775
4767
|
title: images.favicon.title,
|
|
4776
|
-
|
|
4768
|
+
url: images.favicon.imgURL
|
|
4777
4769
|
} : void 0,
|
|
4778
4770
|
logo: images?.logo ? {
|
|
4779
|
-
|
|
4771
|
+
alt: images.logo.altText,
|
|
4780
4772
|
title: images.logo.title,
|
|
4781
|
-
|
|
4773
|
+
url: images.logo.imgURL
|
|
4782
4774
|
} : void 0
|
|
4783
4775
|
}
|
|
4784
4776
|
};
|