@asgardeo/javascript 0.7.1 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AsgardeoJavaScriptClient.d.ts +3 -4
- package/dist/IsomorphicCrypto.d.ts +2 -2
- package/dist/StorageManager.d.ts +6 -8
- package/dist/__legacy__/client.d.ts +15 -15
- package/dist/__legacy__/helpers/authentication-helper.d.ts +5 -5
- package/dist/__legacy__/models/client-config.d.ts +14 -14
- package/dist/api/createOrganization.d.ts +8 -8
- package/dist/api/getAllOrganizations.d.ts +5 -5
- package/dist/api/getBrandingPreference.d.ts +5 -5
- package/dist/api/getMeOrganizations.d.ts +9 -9
- package/dist/api/getOrganization.d.ts +4 -4
- package/dist/api/getSchemas.d.ts +4 -4
- package/dist/api/getScim2Me.d.ts +4 -4
- package/dist/api/updateMeProfile.d.ts +7 -7
- package/dist/api/updateOrganization.d.ts +5 -5
- package/dist/api/v2/executeEmbeddedUserOnboardingFlowV2.d.ts +16 -16
- package/dist/cjs/index.js +1183 -1186
- package/dist/cjs/index.js.map +4 -4
- package/dist/constants/ApplicationNativeAuthenticationConstants.d.ts +14 -14
- package/dist/constants/OIDCDiscoveryConstants.d.ts +17 -106
- package/dist/constants/OIDCRequestConstants.d.ts +6 -44
- package/dist/constants/PKCEConstants.d.ts +3 -18
- package/dist/constants/TokenConstants.d.ts +2 -31
- package/dist/constants/TokenExchangeConstants.d.ts +5 -30
- package/dist/index.js +1184 -1187
- package/dist/index.js.map +4 -4
- package/dist/models/branding-preference.d.ts +5 -5
- package/dist/models/client.d.ts +57 -58
- package/dist/models/config.d.ts +48 -48
- package/dist/models/crypto.d.ts +11 -11
- package/dist/models/embedded-flow.d.ts +10 -10
- package/dist/models/field.d.ts +8 -8
- package/dist/models/oidc-discovery.d.ts +161 -161
- package/dist/models/oidc-endpoints.d.ts +15 -15
- package/dist/models/platforms.d.ts +2 -2
- package/dist/models/scim2-schema.d.ts +17 -17
- package/dist/models/session.d.ts +4 -4
- package/dist/models/store.d.ts +9 -9
- package/dist/models/user.d.ts +5 -5
- package/dist/models/v2/embedded-flow-v2.d.ts +86 -86
- package/dist/models/v2/embedded-signin-flow-v2.d.ts +39 -39
- package/dist/models/v2/embedded-signup-flow-v2.d.ts +42 -42
- package/dist/theme/types.d.ts +133 -133
- package/dist/utils/getAuthorizeRequestUrlParams.d.ts +4 -3
- package/dist/utils/logger.d.ts +6 -6
- package/dist/utils/processUsername.d.ts +1 -1
- package/package.json +1 -1
- package/dist/utils/cryptoUtils.d.ts +0 -0
package/dist/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,
|
|
@@ -585,417 +840,176 @@ var IsomorphicCrypto = class {
|
|
|
585
840
|
return Promise.resolve(true);
|
|
586
841
|
}
|
|
587
842
|
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."
|
|
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
|
-
const tokenResponse = {
|
|
987
|
-
accessToken: parsedResponse.access_token,
|
|
988
|
-
createdAt: parsedResponse.created_at,
|
|
989
|
-
expiresIn: parsedResponse.expires_in,
|
|
990
|
-
idToken: parsedResponse.id_token,
|
|
991
|
-
refreshToken: parsedResponse.refresh_token,
|
|
992
|
-
scope: parsedResponse.scope,
|
|
993
|
-
tokenType: parsedResponse.token_type
|
|
994
|
-
};
|
|
995
|
-
await this._storageManager.setSessionData(parsedResponse, userId);
|
|
996
|
-
return Promise.resolve(tokenResponse);
|
|
997
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);
|
|
1003
|
+
}
|
|
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}`;
|
|
998
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,18 +1061,22 @@ 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
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
const AUTH_INSTANCE_PREFIX = "instance_";
|
|
1071
|
+
let customStateValue = "";
|
|
1072
|
+
if (options.instanceId) {
|
|
1073
|
+
customStateValue = AUTH_INSTANCE_PREFIX + options.instanceId;
|
|
1074
|
+
} else if (customParams) {
|
|
1075
|
+
customStateValue = customParams[OIDCRequestConstants_default.Params.STATE]?.toString() ?? "";
|
|
1055
1076
|
}
|
|
1056
1077
|
authorizeRequestParams.set(
|
|
1057
1078
|
OIDCRequestConstants_default.Params.STATE,
|
|
1058
|
-
generateStateParamForRequestCorrelation_default(
|
|
1059
|
-
pkceKey,
|
|
1060
|
-
customParams ? customParams[OIDCRequestConstants_default.Params.STATE]?.toString() : ""
|
|
1061
|
-
)
|
|
1079
|
+
generateStateParamForRequestCorrelation_default(pkceKey, customStateValue)
|
|
1062
1080
|
);
|
|
1063
1081
|
return authorizeRequestParams;
|
|
1064
1082
|
};
|
|
@@ -1066,16 +1084,16 @@ var getAuthorizeRequestUrlParams_default = getAuthorizeRequestUrlParams;
|
|
|
1066
1084
|
|
|
1067
1085
|
// src/__legacy__/client.ts
|
|
1068
1086
|
var DefaultConfig = {
|
|
1087
|
+
enablePKCE: true,
|
|
1088
|
+
responseMode: "query",
|
|
1089
|
+
sendCookiesInRequests: true,
|
|
1069
1090
|
tokenValidation: {
|
|
1070
1091
|
idToken: {
|
|
1092
|
+
clockTolerance: 300,
|
|
1071
1093
|
validate: true,
|
|
1072
|
-
validateIssuer: true
|
|
1073
|
-
clockTolerance: 300
|
|
1094
|
+
validateIssuer: true
|
|
1074
1095
|
}
|
|
1075
|
-
}
|
|
1076
|
-
enablePKCE: true,
|
|
1077
|
-
responseMode: "query",
|
|
1078
|
-
sendCookiesInRequests: true
|
|
1096
|
+
}
|
|
1079
1097
|
};
|
|
1080
1098
|
var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
1081
1099
|
/**
|
|
@@ -1094,12 +1112,13 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1094
1112
|
* @preserve
|
|
1095
1113
|
*/
|
|
1096
1114
|
constructor() {
|
|
1097
|
-
__publicField(this, "
|
|
1098
|
-
__publicField(this, "
|
|
1099
|
-
__publicField(this, "
|
|
1100
|
-
__publicField(this, "
|
|
1101
|
-
__publicField(this, "
|
|
1102
|
-
__publicField(this, "
|
|
1115
|
+
__publicField(this, "storageManager");
|
|
1116
|
+
__publicField(this, "configProvider");
|
|
1117
|
+
__publicField(this, "oidcProviderMetaDataProvider");
|
|
1118
|
+
__publicField(this, "authHelper");
|
|
1119
|
+
__publicField(this, "cryptoUtils");
|
|
1120
|
+
__publicField(this, "cryptoHelper");
|
|
1121
|
+
__publicField(this, "instanceIdValue");
|
|
1103
1122
|
}
|
|
1104
1123
|
/**
|
|
1105
1124
|
*
|
|
@@ -1120,28 +1139,28 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1120
1139
|
*
|
|
1121
1140
|
* @preserve
|
|
1122
1141
|
*/
|
|
1123
|
-
async initialize(config, store,
|
|
1124
|
-
const clientId = config
|
|
1125
|
-
if (!
|
|
1126
|
-
|
|
1142
|
+
async initialize(config, store, inputCryptoUtils, instanceID) {
|
|
1143
|
+
const { clientId } = config;
|
|
1144
|
+
if (!this.instanceIdValue) {
|
|
1145
|
+
this.instanceIdValue = 0;
|
|
1127
1146
|
} else {
|
|
1128
|
-
|
|
1147
|
+
this.instanceIdValue += 1;
|
|
1129
1148
|
}
|
|
1130
1149
|
if (instanceID) {
|
|
1131
|
-
|
|
1150
|
+
this.instanceIdValue = instanceID;
|
|
1132
1151
|
}
|
|
1133
1152
|
if (!clientId) {
|
|
1134
|
-
this.
|
|
1153
|
+
this.storageManager = new StorageManager_default(`instance_${this.instanceIdValue}`, store);
|
|
1135
1154
|
} else {
|
|
1136
|
-
this.
|
|
1155
|
+
this.storageManager = new StorageManager_default(`instance_${this.instanceIdValue}-${clientId}`, store);
|
|
1137
1156
|
}
|
|
1138
|
-
this.
|
|
1139
|
-
this.
|
|
1140
|
-
this.
|
|
1141
|
-
this.
|
|
1142
|
-
this.
|
|
1143
|
-
_AsgardeoAuthClient.
|
|
1144
|
-
await this.
|
|
1157
|
+
this.cryptoUtils = inputCryptoUtils;
|
|
1158
|
+
this.cryptoHelper = new IsomorphicCrypto(inputCryptoUtils);
|
|
1159
|
+
this.authHelper = new AuthenticationHelper(this.storageManager, this.cryptoHelper);
|
|
1160
|
+
this.configProvider = async () => this.storageManager.getConfigData();
|
|
1161
|
+
this.oidcProviderMetaDataProvider = async () => this.storageManager.loadOpenIDProviderConfiguration();
|
|
1162
|
+
_AsgardeoAuthClient.authHelperInstance = this.authHelper;
|
|
1163
|
+
await this.storageManager.setConfigData({
|
|
1145
1164
|
...DefaultConfig,
|
|
1146
1165
|
...config,
|
|
1147
1166
|
scope: processOpenIDScopes_default(config.scopes)
|
|
@@ -1162,7 +1181,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1162
1181
|
* @preserve
|
|
1163
1182
|
*/
|
|
1164
1183
|
getStorageManager() {
|
|
1165
|
-
return this.
|
|
1184
|
+
return this.storageManager;
|
|
1166
1185
|
}
|
|
1167
1186
|
/**
|
|
1168
1187
|
* This method returns the `instanceID` variable of the given instance.
|
|
@@ -1176,8 +1195,9 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1176
1195
|
*
|
|
1177
1196
|
* @preserve
|
|
1178
1197
|
*/
|
|
1198
|
+
// eslint-disable-next-line class-methods-use-this
|
|
1179
1199
|
getInstanceId() {
|
|
1180
|
-
return
|
|
1200
|
+
return this.instanceIdValue;
|
|
1181
1201
|
}
|
|
1182
1202
|
/**
|
|
1183
1203
|
* This is an async method that returns a Promise that resolves with the authorization URL.
|
|
@@ -1205,8 +1225,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1205
1225
|
async getSignInUrl(requestConfig, userId) {
|
|
1206
1226
|
const authRequestConfig = { ...requestConfig };
|
|
1207
1227
|
delete authRequestConfig?.forceInit;
|
|
1208
|
-
const
|
|
1209
|
-
const authorizeEndpoint = await this.
|
|
1228
|
+
const buildSignInUrl = async () => {
|
|
1229
|
+
const authorizeEndpoint = await this.storageManager.getOIDCProviderMetaDataParameter(
|
|
1210
1230
|
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.AUTHORIZATION
|
|
1211
1231
|
);
|
|
1212
1232
|
if (!authorizeEndpoint || authorizeEndpoint.trim().length === 0) {
|
|
@@ -1217,45 +1237,44 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1217
1237
|
);
|
|
1218
1238
|
}
|
|
1219
1239
|
const authorizeRequest = new URL(authorizeEndpoint);
|
|
1220
|
-
const configData = await this.
|
|
1221
|
-
const tempStore = await this.
|
|
1240
|
+
const configData = await this.configProvider();
|
|
1241
|
+
const tempStore = await this.storageManager.getTemporaryData(userId);
|
|
1222
1242
|
const pkceKey = await generatePkceStorageKey_default(tempStore);
|
|
1223
1243
|
let codeVerifier;
|
|
1224
1244
|
let codeChallenge;
|
|
1225
1245
|
if (configData.enablePKCE) {
|
|
1226
|
-
codeVerifier = this.
|
|
1227
|
-
codeChallenge = this.
|
|
1228
|
-
await this.
|
|
1246
|
+
codeVerifier = this.cryptoHelper?.getCodeVerifier();
|
|
1247
|
+
codeChallenge = this.cryptoHelper?.getCodeChallenge(codeVerifier);
|
|
1248
|
+
await this.storageManager.setTemporaryDataParameter(pkceKey, codeVerifier, userId);
|
|
1229
1249
|
}
|
|
1230
1250
|
if (authRequestConfig["client_secret"]) {
|
|
1231
1251
|
authRequestConfig["client_secret"] = configData.clientSecret;
|
|
1232
1252
|
}
|
|
1233
1253
|
const authorizeRequestParams = getAuthorizeRequestUrlParams_default(
|
|
1234
1254
|
{
|
|
1235
|
-
redirectUri: configData.afterSignInUrl,
|
|
1236
1255
|
clientId: configData.clientId,
|
|
1237
|
-
scopes: processOpenIDScopes_default(configData.scopes),
|
|
1238
|
-
responseMode: configData.responseMode,
|
|
1239
|
-
codeChallengeMethod: PKCEConstants_default.DEFAULT_CODE_CHALLENGE_METHOD,
|
|
1240
1256
|
codeChallenge,
|
|
1241
|
-
|
|
1257
|
+
codeChallengeMethod: PKCEConstants_default.DEFAULT_CODE_CHALLENGE_METHOD,
|
|
1258
|
+
instanceId: this.getInstanceId().toString(),
|
|
1259
|
+
prompt: configData.prompt,
|
|
1260
|
+
redirectUri: configData.afterSignInUrl,
|
|
1261
|
+
responseMode: configData.responseMode,
|
|
1262
|
+
scopes: processOpenIDScopes_default(configData.scopes)
|
|
1242
1263
|
},
|
|
1243
1264
|
{ key: pkceKey },
|
|
1244
1265
|
authRequestConfig
|
|
1245
1266
|
);
|
|
1246
|
-
|
|
1247
|
-
authorizeRequest.searchParams.append(
|
|
1248
|
-
}
|
|
1267
|
+
Array.from(authorizeRequestParams.entries()).forEach(([paramKey, paramValue]) => {
|
|
1268
|
+
authorizeRequest.searchParams.append(paramKey, paramValue);
|
|
1269
|
+
});
|
|
1249
1270
|
return authorizeRequest.toString();
|
|
1250
1271
|
};
|
|
1251
|
-
if (await this.
|
|
1272
|
+
if (await this.storageManager.getTemporaryDataParameter(
|
|
1252
1273
|
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED
|
|
1253
1274
|
)) {
|
|
1254
|
-
return
|
|
1275
|
+
return buildSignInUrl();
|
|
1255
1276
|
}
|
|
1256
|
-
return this.loadOpenIDProviderConfiguration(requestConfig?.forceInit).then(() =>
|
|
1257
|
-
return __TODO__();
|
|
1258
|
-
});
|
|
1277
|
+
return this.loadOpenIDProviderConfiguration(requestConfig?.forceInit).then(() => buildSignInUrl());
|
|
1259
1278
|
}
|
|
1260
1279
|
/**
|
|
1261
1280
|
* This is an async method that sends a request to obtain the access token and returns a Promise
|
|
@@ -1283,9 +1302,9 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1283
1302
|
* @preserve
|
|
1284
1303
|
*/
|
|
1285
1304
|
async requestAccessToken(authorizationCode, sessionState, state, userId, tokenRequestConfig) {
|
|
1286
|
-
const
|
|
1287
|
-
const tokenEndpoint = (await this.
|
|
1288
|
-
const configData = await this.
|
|
1305
|
+
const performTokenRequest = async () => {
|
|
1306
|
+
const tokenEndpoint = (await this.oidcProviderMetaDataProvider()).token_endpoint;
|
|
1307
|
+
const configData = await this.configProvider();
|
|
1289
1308
|
if (!tokenEndpoint || tokenEndpoint.trim().length === 0) {
|
|
1290
1309
|
throw new AsgardeoAuthException(
|
|
1291
1310
|
"JS-AUTH_CORE-RAT1-NF01",
|
|
@@ -1293,11 +1312,13 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1293
1312
|
"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
1313
|
);
|
|
1295
1314
|
}
|
|
1296
|
-
sessionState
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1315
|
+
if (sessionState) {
|
|
1316
|
+
await this.storageManager.setSessionDataParameter(
|
|
1317
|
+
OIDCRequestConstants_default.Params.SESSION_STATE,
|
|
1318
|
+
sessionState,
|
|
1319
|
+
userId
|
|
1320
|
+
);
|
|
1321
|
+
}
|
|
1301
1322
|
const body = new URLSearchParams();
|
|
1302
1323
|
body.set("client_id", configData.clientId);
|
|
1303
1324
|
if (configData.clientSecret && configData.clientSecret.trim().length > 0) {
|
|
@@ -1315,9 +1336,9 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1315
1336
|
if (configData.enablePKCE) {
|
|
1316
1337
|
body.set(
|
|
1317
1338
|
"code_verifier",
|
|
1318
|
-
`${await this.
|
|
1339
|
+
`${await this.storageManager.getTemporaryDataParameter(extractPkceStorageKeyFromState_default(state), userId)}`
|
|
1319
1340
|
);
|
|
1320
|
-
await this.
|
|
1341
|
+
await this.storageManager.removeTemporaryDataParameter(extractPkceStorageKeyFromState_default(state), userId);
|
|
1321
1342
|
}
|
|
1322
1343
|
let tokenResponse;
|
|
1323
1344
|
try {
|
|
@@ -1344,25 +1365,23 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1344
1365
|
await tokenResponse.json()
|
|
1345
1366
|
);
|
|
1346
1367
|
}
|
|
1347
|
-
return
|
|
1368
|
+
return this.authHelper.handleTokenResponse(tokenResponse, userId);
|
|
1348
1369
|
};
|
|
1349
|
-
if (await this.
|
|
1370
|
+
if (await this.storageManager.getTemporaryDataParameter(
|
|
1350
1371
|
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED
|
|
1351
1372
|
)) {
|
|
1352
|
-
return
|
|
1373
|
+
return performTokenRequest();
|
|
1353
1374
|
}
|
|
1354
|
-
return this.loadOpenIDProviderConfiguration(false).then(() =>
|
|
1355
|
-
return __TODO__();
|
|
1356
|
-
});
|
|
1375
|
+
return this.loadOpenIDProviderConfiguration(false).then(() => performTokenRequest());
|
|
1357
1376
|
}
|
|
1358
1377
|
async loadOpenIDProviderConfiguration(forceInit) {
|
|
1359
|
-
const configData = await this.
|
|
1360
|
-
if (!forceInit && await this.
|
|
1378
|
+
const configData = await this.configProvider();
|
|
1379
|
+
if (!forceInit && await this.storageManager.getTemporaryDataParameter(
|
|
1361
1380
|
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED
|
|
1362
1381
|
)) {
|
|
1363
1382
|
return Promise.resolve();
|
|
1364
1383
|
}
|
|
1365
|
-
const wellKnownEndpoint = configData
|
|
1384
|
+
const { wellKnownEndpoint } = configData;
|
|
1366
1385
|
if (wellKnownEndpoint) {
|
|
1367
1386
|
let response;
|
|
1368
1387
|
try {
|
|
@@ -1377,19 +1396,16 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1377
1396
|
"The well known endpoint response has been failed with an error."
|
|
1378
1397
|
);
|
|
1379
1398
|
}
|
|
1380
|
-
await this.
|
|
1381
|
-
|
|
1382
|
-
);
|
|
1383
|
-
await this._storageManager.setTemporaryDataParameter(
|
|
1399
|
+
await this.storageManager.setOIDCProviderMetaData(await this.authHelper.resolveEndpoints(await response.json()));
|
|
1400
|
+
await this.storageManager.setTemporaryDataParameter(
|
|
1384
1401
|
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,
|
|
1385
1402
|
true
|
|
1386
1403
|
);
|
|
1387
1404
|
return Promise.resolve();
|
|
1388
|
-
}
|
|
1405
|
+
}
|
|
1406
|
+
if (configData.baseUrl) {
|
|
1389
1407
|
try {
|
|
1390
|
-
await this.
|
|
1391
|
-
await this._authenticationHelper.resolveEndpointsByBaseURL()
|
|
1392
|
-
);
|
|
1408
|
+
await this.storageManager.setOIDCProviderMetaData(await this.authHelper.resolveEndpointsByBaseURL());
|
|
1393
1409
|
} catch (error2) {
|
|
1394
1410
|
throw new AsgardeoAuthException(
|
|
1395
1411
|
"JS-AUTH_CORE-GOPMD-IV02",
|
|
@@ -1397,19 +1413,18 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1397
1413
|
error2 ?? "Resolving endpoints by base url failed."
|
|
1398
1414
|
);
|
|
1399
1415
|
}
|
|
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(
|
|
1416
|
+
await this.storageManager.setTemporaryDataParameter(
|
|
1408
1417
|
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,
|
|
1409
1418
|
true
|
|
1410
1419
|
);
|
|
1411
1420
|
return Promise.resolve();
|
|
1412
1421
|
}
|
|
1422
|
+
await this.storageManager.setOIDCProviderMetaData(await this.authHelper.resolveEndpointsExplicitly());
|
|
1423
|
+
await this.storageManager.setTemporaryDataParameter(
|
|
1424
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,
|
|
1425
|
+
true
|
|
1426
|
+
);
|
|
1427
|
+
return Promise.resolve();
|
|
1413
1428
|
}
|
|
1414
1429
|
/**
|
|
1415
1430
|
* This method returns the sign-out URL.
|
|
@@ -1431,8 +1446,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1431
1446
|
* @preserve
|
|
1432
1447
|
*/
|
|
1433
1448
|
async getSignOutUrl(userId) {
|
|
1434
|
-
const logoutEndpoint = (await this.
|
|
1435
|
-
const configData = await this.
|
|
1449
|
+
const logoutEndpoint = (await this.oidcProviderMetaDataProvider())?.end_session_endpoint;
|
|
1450
|
+
const configData = await this.configProvider();
|
|
1436
1451
|
if (!logoutEndpoint || logoutEndpoint.trim().length === 0) {
|
|
1437
1452
|
throw new AsgardeoAuthException(
|
|
1438
1453
|
"JS-AUTH_CORE-GSOU-NF01",
|
|
@@ -1451,7 +1466,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1451
1466
|
const queryParams = new URLSearchParams();
|
|
1452
1467
|
queryParams.set("post_logout_redirect_uri", callbackURL);
|
|
1453
1468
|
if (configData.sendIdTokenInLogoutRequest) {
|
|
1454
|
-
const idToken = (await this.
|
|
1469
|
+
const idToken = (await this.storageManager.getSessionData(userId))?.id_token;
|
|
1455
1470
|
if (!idToken || idToken.trim().length === 0) {
|
|
1456
1471
|
throw new AsgardeoAuthException(
|
|
1457
1472
|
"JS-AUTH_CORE-GSOU-NF02",
|
|
@@ -1481,7 +1496,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1481
1496
|
* @preserve
|
|
1482
1497
|
*/
|
|
1483
1498
|
async getOpenIDProviderEndpoints() {
|
|
1484
|
-
const oidcProviderMetaData = await this.
|
|
1499
|
+
const oidcProviderMetaData = await this.oidcProviderMetaDataProvider();
|
|
1485
1500
|
return {
|
|
1486
1501
|
authorizationEndpoint: oidcProviderMetaData.authorization_endpoint ?? "",
|
|
1487
1502
|
checkSessionIframe: oidcProviderMetaData.check_session_iframe ?? "",
|
|
@@ -1507,7 +1522,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1507
1522
|
* ```
|
|
1508
1523
|
*/
|
|
1509
1524
|
async decodeJwtToken(token) {
|
|
1510
|
-
return this.
|
|
1525
|
+
return this.cryptoHelper.decodeJwtToken(token);
|
|
1511
1526
|
}
|
|
1512
1527
|
/**
|
|
1513
1528
|
* This method decodes the payload of the ID token and returns it.
|
|
@@ -1527,8 +1542,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1527
1542
|
* @preserve
|
|
1528
1543
|
*/
|
|
1529
1544
|
async getDecodedIdToken(userId, idToken) {
|
|
1530
|
-
const
|
|
1531
|
-
const payload = this.
|
|
1545
|
+
const storedIdToken = (await this.storageManager.getSessionData(userId)).id_token;
|
|
1546
|
+
const payload = this.cryptoHelper.decodeJwtToken(storedIdToken ?? idToken);
|
|
1532
1547
|
return payload;
|
|
1533
1548
|
}
|
|
1534
1549
|
/**
|
|
@@ -1549,7 +1564,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1549
1564
|
* @preserve
|
|
1550
1565
|
*/
|
|
1551
1566
|
async getIdToken(userId) {
|
|
1552
|
-
return (await this.
|
|
1567
|
+
return (await this.storageManager.getSessionData(userId)).id_token;
|
|
1553
1568
|
}
|
|
1554
1569
|
/**
|
|
1555
1570
|
* This method returns the basic user information obtained from the ID token.
|
|
@@ -1569,8 +1584,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1569
1584
|
* @preserve
|
|
1570
1585
|
*/
|
|
1571
1586
|
async getUser(userId) {
|
|
1572
|
-
const sessionData = await this.
|
|
1573
|
-
const authenticatedUser = this.
|
|
1587
|
+
const sessionData = await this.storageManager.getSessionData(userId);
|
|
1588
|
+
const authenticatedUser = this.authHelper.getAuthenticatedUserInfo(sessionData?.id_token);
|
|
1574
1589
|
Object.keys(authenticatedUser).forEach((key) => {
|
|
1575
1590
|
if (authenticatedUser[key] === void 0 || authenticatedUser[key] === "" || authenticatedUser[key] === null) {
|
|
1576
1591
|
delete authenticatedUser[key];
|
|
@@ -1579,7 +1594,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1579
1594
|
return authenticatedUser;
|
|
1580
1595
|
}
|
|
1581
1596
|
async getUserSession(userId) {
|
|
1582
|
-
const sessionData = await this.
|
|
1597
|
+
const sessionData = await this.storageManager.getSessionData(userId);
|
|
1583
1598
|
return {
|
|
1584
1599
|
scopes: sessionData?.scope?.split(" "),
|
|
1585
1600
|
sessionState: sessionData?.session_state ?? ""
|
|
@@ -1600,7 +1615,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1600
1615
|
* @preserve
|
|
1601
1616
|
*/
|
|
1602
1617
|
async getCrypto() {
|
|
1603
|
-
return this.
|
|
1618
|
+
return this.cryptoHelper;
|
|
1604
1619
|
}
|
|
1605
1620
|
/**
|
|
1606
1621
|
* This method revokes the access token.
|
|
@@ -1626,8 +1641,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1626
1641
|
* @preserve
|
|
1627
1642
|
*/
|
|
1628
1643
|
async revokeAccessToken(userId) {
|
|
1629
|
-
const revokeTokenEndpoint = (await this.
|
|
1630
|
-
const configData = await this.
|
|
1644
|
+
const revokeTokenEndpoint = (await this.oidcProviderMetaDataProvider()).revocation_endpoint;
|
|
1645
|
+
const configData = await this.configProvider();
|
|
1631
1646
|
if (!revokeTokenEndpoint || revokeTokenEndpoint.trim().length === 0) {
|
|
1632
1647
|
throw new AsgardeoAuthException(
|
|
1633
1648
|
"JS-AUTH_CORE-RAT3-NF01",
|
|
@@ -1637,7 +1652,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1637
1652
|
}
|
|
1638
1653
|
const body = [];
|
|
1639
1654
|
body.push(`client_id=${configData.clientId}`);
|
|
1640
|
-
body.push(`token=${(await this.
|
|
1655
|
+
body.push(`token=${(await this.storageManager.getSessionData(userId)).access_token}`);
|
|
1641
1656
|
body.push("token_type_hint=access_token");
|
|
1642
1657
|
if (configData.clientSecret && configData.clientSecret.trim().length > 0) {
|
|
1643
1658
|
body.push(`client_secret=${configData.clientSecret}`);
|
|
@@ -1667,7 +1682,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1667
1682
|
await response.json()
|
|
1668
1683
|
);
|
|
1669
1684
|
}
|
|
1670
|
-
this.
|
|
1685
|
+
this.authHelper.clearSession(userId);
|
|
1671
1686
|
return Promise.resolve(response);
|
|
1672
1687
|
}
|
|
1673
1688
|
/**
|
|
@@ -1693,9 +1708,9 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1693
1708
|
* @preserve
|
|
1694
1709
|
*/
|
|
1695
1710
|
async refreshAccessToken(userId) {
|
|
1696
|
-
const tokenEndpoint = (await this.
|
|
1697
|
-
const configData = await this.
|
|
1698
|
-
const sessionData = await this.
|
|
1711
|
+
const tokenEndpoint = (await this.oidcProviderMetaDataProvider()).token_endpoint;
|
|
1712
|
+
const configData = await this.configProvider();
|
|
1713
|
+
const sessionData = await this.storageManager.getSessionData(userId);
|
|
1699
1714
|
if (!sessionData.refresh_token) {
|
|
1700
1715
|
throw new AsgardeoAuthException(
|
|
1701
1716
|
"JS-AUTH_CORE-RAT2-NF01",
|
|
@@ -1742,7 +1757,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1742
1757
|
await tokenResponse.json()
|
|
1743
1758
|
);
|
|
1744
1759
|
}
|
|
1745
|
-
return this.
|
|
1760
|
+
return this.authHelper.handleTokenResponse(tokenResponse, userId);
|
|
1746
1761
|
}
|
|
1747
1762
|
/**
|
|
1748
1763
|
* This method returns the access token.
|
|
@@ -1762,7 +1777,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1762
1777
|
* @preserve
|
|
1763
1778
|
*/
|
|
1764
1779
|
async getAccessToken(userId) {
|
|
1765
|
-
return (await this.
|
|
1780
|
+
return (await this.storageManager.getSessionData(userId))?.access_token;
|
|
1766
1781
|
}
|
|
1767
1782
|
/**
|
|
1768
1783
|
* This method sends a custom-grant request and returns a Promise that resolves with the response
|
|
@@ -1803,8 +1818,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1803
1818
|
* @preserve
|
|
1804
1819
|
*/
|
|
1805
1820
|
async exchangeToken(config, userId) {
|
|
1806
|
-
const oidcProviderMetadata = await this.
|
|
1807
|
-
const configData = await this.
|
|
1821
|
+
const oidcProviderMetadata = await this.oidcProviderMetaDataProvider();
|
|
1822
|
+
const configData = await this.configProvider();
|
|
1808
1823
|
let tokenEndpoint;
|
|
1809
1824
|
if (config.tokenEndpoint && config.tokenEndpoint.trim().length !== 0) {
|
|
1810
1825
|
tokenEndpoint = config.tokenEndpoint;
|
|
@@ -1820,10 +1835,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1820
1835
|
}
|
|
1821
1836
|
const data = await Promise.all(
|
|
1822
1837
|
Object.entries(config.data).map(async ([key, value]) => {
|
|
1823
|
-
const newValue = await this.
|
|
1824
|
-
value,
|
|
1825
|
-
userId
|
|
1826
|
-
);
|
|
1838
|
+
const newValue = await this.authHelper.replaceCustomGrantTemplateTags(value, userId);
|
|
1827
1839
|
return `${key}=${newValue}`;
|
|
1828
1840
|
})
|
|
1829
1841
|
);
|
|
@@ -1834,7 +1846,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1834
1846
|
if (config.attachToken) {
|
|
1835
1847
|
requestHeaders = {
|
|
1836
1848
|
...requestHeaders,
|
|
1837
|
-
Authorization: `Bearer ${(await this.
|
|
1849
|
+
Authorization: `Bearer ${(await this.storageManager.getSessionData(userId)).access_token}`
|
|
1838
1850
|
};
|
|
1839
1851
|
}
|
|
1840
1852
|
const requestConfig = {
|
|
@@ -1861,10 +1873,9 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1861
1873
|
);
|
|
1862
1874
|
}
|
|
1863
1875
|
if (config.returnsSession) {
|
|
1864
|
-
return this.
|
|
1865
|
-
} else {
|
|
1866
|
-
return Promise.resolve(await response.json());
|
|
1876
|
+
return this.authHelper.handleTokenResponse(response, userId);
|
|
1867
1877
|
}
|
|
1878
|
+
return Promise.resolve(await response.json());
|
|
1868
1879
|
}
|
|
1869
1880
|
/**
|
|
1870
1881
|
* This method returns if the user is authenticated or not.
|
|
@@ -1885,12 +1896,12 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1885
1896
|
*/
|
|
1886
1897
|
async isSignedIn(userId) {
|
|
1887
1898
|
const isAccessTokenAvailable = Boolean(await this.getAccessToken(userId));
|
|
1888
|
-
const createdAt = (await this.
|
|
1889
|
-
const expiresInString = (await this.
|
|
1899
|
+
const createdAt = (await this.storageManager.getSessionData(userId))?.created_at;
|
|
1900
|
+
const expiresInString = (await this.storageManager.getSessionData(userId))?.expires_in;
|
|
1890
1901
|
if (!expiresInString) {
|
|
1891
1902
|
return false;
|
|
1892
1903
|
}
|
|
1893
|
-
const expiresIn = parseInt(expiresInString) * 1e3;
|
|
1904
|
+
const expiresIn = parseInt(expiresInString, 10) * 1e3;
|
|
1894
1905
|
const currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
1895
1906
|
const isAccessTokenValid = createdAt + expiresIn > currentTime;
|
|
1896
1907
|
const isSignedIn = isAccessTokenAvailable && isAccessTokenValid;
|
|
@@ -1915,7 +1926,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1915
1926
|
* @preserve
|
|
1916
1927
|
*/
|
|
1917
1928
|
async getPKCECode(state, userId) {
|
|
1918
|
-
return await this.
|
|
1929
|
+
return await this.storageManager.getTemporaryDataParameter(
|
|
1919
1930
|
extractPkceStorageKeyFromState_default(state),
|
|
1920
1931
|
userId
|
|
1921
1932
|
);
|
|
@@ -1938,7 +1949,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1938
1949
|
* @preserve
|
|
1939
1950
|
*/
|
|
1940
1951
|
async setPKCECode(pkce, state, userId) {
|
|
1941
|
-
return
|
|
1952
|
+
return this.storageManager.setTemporaryDataParameter(extractPkceStorageKeyFromState_default(state), pkce, userId);
|
|
1942
1953
|
}
|
|
1943
1954
|
/**
|
|
1944
1955
|
* This method returns if the sign-out is successful or not.
|
|
@@ -2000,17 +2011,16 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
2000
2011
|
* @preserve
|
|
2001
2012
|
*/
|
|
2002
2013
|
async reInitialize(config) {
|
|
2003
|
-
await this.
|
|
2014
|
+
await this.storageManager.setConfigData(config);
|
|
2004
2015
|
await this.loadOpenIDProviderConfiguration(true);
|
|
2005
2016
|
}
|
|
2006
2017
|
static async clearSession(userId) {
|
|
2007
|
-
await this.
|
|
2018
|
+
await this.authHelperInstance.clearSession(userId);
|
|
2008
2019
|
}
|
|
2009
2020
|
};
|
|
2010
|
-
__publicField(_AsgardeoAuthClient, "_instanceID");
|
|
2011
2021
|
// FIXME: Validate this.
|
|
2012
2022
|
// Ref: https://github.com/asgardeo/asgardeo-auth-js-core/pull/205
|
|
2013
|
-
__publicField(_AsgardeoAuthClient, "
|
|
2023
|
+
__publicField(_AsgardeoAuthClient, "authHelperInstance");
|
|
2014
2024
|
var AsgardeoAuthClient = _AsgardeoAuthClient;
|
|
2015
2025
|
|
|
2016
2026
|
// src/errors/AsgardeoAPIError.ts
|
|
@@ -2030,8 +2040,8 @@ var AsgardeoAPIError = class extends AsgardeoError {
|
|
|
2030
2040
|
this.statusCode = statusCode;
|
|
2031
2041
|
this.statusText = statusText;
|
|
2032
2042
|
Object.defineProperty(this, "name", {
|
|
2033
|
-
value: "AsgardeoAPIError",
|
|
2034
2043
|
configurable: true,
|
|
2044
|
+
value: "AsgardeoAPIError",
|
|
2035
2045
|
writable: true
|
|
2036
2046
|
});
|
|
2037
2047
|
}
|
|
@@ -2082,13 +2092,13 @@ var initializeEmbeddedSignInFlow = async ({
|
|
|
2082
2092
|
try {
|
|
2083
2093
|
const response = await fetch(url ?? `${baseUrl}/oauth2/authorize`, {
|
|
2084
2094
|
...requestConfig,
|
|
2085
|
-
|
|
2095
|
+
body: searchParams.toString(),
|
|
2086
2096
|
headers: {
|
|
2087
2097
|
...requestConfig.headers,
|
|
2088
|
-
|
|
2089
|
-
|
|
2098
|
+
Accept: "application/json",
|
|
2099
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
2090
2100
|
},
|
|
2091
|
-
|
|
2101
|
+
method: requestConfig.method || "POST"
|
|
2092
2102
|
});
|
|
2093
2103
|
if (!response.ok) {
|
|
2094
2104
|
const errorText = await response.text();
|
|
@@ -2146,13 +2156,13 @@ var executeEmbeddedSignInFlow = async ({
|
|
|
2146
2156
|
try {
|
|
2147
2157
|
const response = await fetch(url ?? `${baseUrl}/oauth2/authn`, {
|
|
2148
2158
|
...requestConfig,
|
|
2149
|
-
|
|
2159
|
+
body: JSON.stringify(payload),
|
|
2150
2160
|
headers: {
|
|
2151
|
-
"Content-Type": "application/json",
|
|
2152
2161
|
Accept: "application/json",
|
|
2162
|
+
"Content-Type": "application/json",
|
|
2153
2163
|
...requestConfig.headers
|
|
2154
2164
|
},
|
|
2155
|
-
|
|
2165
|
+
method: requestConfig.method || "POST"
|
|
2156
2166
|
});
|
|
2157
2167
|
if (!response.ok) {
|
|
2158
2168
|
const errorText = await response.text();
|
|
@@ -2240,16 +2250,16 @@ var executeEmbeddedSignUpFlow = async ({
|
|
|
2240
2250
|
try {
|
|
2241
2251
|
const response = await fetch(url ?? `${baseUrl}/api/server/v1/flow/execute`, {
|
|
2242
2252
|
...requestConfig,
|
|
2243
|
-
method: requestConfig.method || "POST",
|
|
2244
|
-
headers: {
|
|
2245
|
-
"Content-Type": "application/json",
|
|
2246
|
-
Accept: "application/json",
|
|
2247
|
-
...requestConfig.headers
|
|
2248
|
-
},
|
|
2249
2253
|
body: JSON.stringify({
|
|
2250
2254
|
...payload ?? {},
|
|
2251
2255
|
flowType: "REGISTRATION" /* Registration */
|
|
2252
|
-
})
|
|
2256
|
+
}),
|
|
2257
|
+
headers: {
|
|
2258
|
+
Accept: "application/json",
|
|
2259
|
+
"Content-Type": "application/json",
|
|
2260
|
+
...requestConfig.headers
|
|
2261
|
+
},
|
|
2262
|
+
method: requestConfig.method || "POST"
|
|
2253
2263
|
});
|
|
2254
2264
|
if (!response.ok) {
|
|
2255
2265
|
const errorText = await response.text();
|
|
@@ -2293,12 +2303,12 @@ var getUserInfo = async ({ url, ...requestConfig }) => {
|
|
|
2293
2303
|
try {
|
|
2294
2304
|
const response = await fetch(url, {
|
|
2295
2305
|
...requestConfig,
|
|
2296
|
-
method: "GET",
|
|
2297
2306
|
headers: {
|
|
2298
|
-
"Content-Type": "application/json",
|
|
2299
2307
|
Accept: "application/json",
|
|
2308
|
+
"Content-Type": "application/json",
|
|
2300
2309
|
...requestConfig.headers
|
|
2301
|
-
}
|
|
2310
|
+
},
|
|
2311
|
+
method: "GET"
|
|
2302
2312
|
});
|
|
2303
2313
|
if (!response.ok) {
|
|
2304
2314
|
const errorText = await response.text();
|
|
@@ -2369,12 +2379,12 @@ var getScim2Me = async ({ url, baseUrl, fetcher, ...requestConfig }) => {
|
|
|
2369
2379
|
const resolvedUrl = url ?? `${baseUrl}/scim2/Me`;
|
|
2370
2380
|
const requestInit = {
|
|
2371
2381
|
...requestConfig,
|
|
2372
|
-
method: "GET",
|
|
2373
2382
|
headers: {
|
|
2374
|
-
"Content-Type": "application/scim+json",
|
|
2375
2383
|
Accept: "application/json",
|
|
2384
|
+
"Content-Type": "application/scim+json",
|
|
2376
2385
|
...requestConfig.headers
|
|
2377
|
-
}
|
|
2386
|
+
},
|
|
2387
|
+
method: "GET"
|
|
2378
2388
|
};
|
|
2379
2389
|
try {
|
|
2380
2390
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2422,12 +2432,12 @@ var getSchemas = async ({ url, baseUrl, fetcher, ...requestConfig }) => {
|
|
|
2422
2432
|
const resolvedUrl = url ?? `${baseUrl}/scim2/Schemas`;
|
|
2423
2433
|
const requestInit = {
|
|
2424
2434
|
...requestConfig,
|
|
2425
|
-
method: "GET",
|
|
2426
2435
|
headers: {
|
|
2427
|
-
"Content-Type": "application/json",
|
|
2428
2436
|
Accept: "application/json",
|
|
2437
|
+
"Content-Type": "application/json",
|
|
2429
2438
|
...requestConfig.headers
|
|
2430
|
-
}
|
|
2439
|
+
},
|
|
2440
|
+
method: "GET"
|
|
2431
2441
|
};
|
|
2432
2442
|
try {
|
|
2433
2443
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2490,12 +2500,12 @@ var getAllOrganizations = async ({
|
|
|
2490
2500
|
const resolvedUrl = `${baseUrl}/api/server/v1/organizations?${queryParams.toString()}`;
|
|
2491
2501
|
const requestInit = {
|
|
2492
2502
|
...requestConfig,
|
|
2493
|
-
method: "GET",
|
|
2494
2503
|
headers: {
|
|
2495
2504
|
...requestConfig.headers,
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
}
|
|
2505
|
+
Accept: "application/json",
|
|
2506
|
+
"Content-Type": "application/json"
|
|
2507
|
+
},
|
|
2508
|
+
method: "GET"
|
|
2499
2509
|
};
|
|
2500
2510
|
try {
|
|
2501
2511
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2566,13 +2576,13 @@ var createOrganization = async ({
|
|
|
2566
2576
|
const resolvedUrl = `${baseUrl}/api/server/v1/organizations`;
|
|
2567
2577
|
const requestInit = {
|
|
2568
2578
|
...requestConfig,
|
|
2569
|
-
|
|
2579
|
+
body: JSON.stringify(organizationPayload),
|
|
2570
2580
|
headers: {
|
|
2571
|
-
"Content-Type": "application/json",
|
|
2572
2581
|
Accept: "application/json",
|
|
2582
|
+
"Content-Type": "application/json",
|
|
2573
2583
|
...requestConfig.headers
|
|
2574
2584
|
},
|
|
2575
|
-
|
|
2585
|
+
method: "POST"
|
|
2576
2586
|
};
|
|
2577
2587
|
try {
|
|
2578
2588
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2641,12 +2651,12 @@ var getMeOrganizations = async ({
|
|
|
2641
2651
|
const resolvedUrl = `${baseUrl}/api/users/v1/me/organizations?${queryParams.toString()}`;
|
|
2642
2652
|
const requestInit = {
|
|
2643
2653
|
...requestConfig,
|
|
2644
|
-
method: "GET",
|
|
2645
2654
|
headers: {
|
|
2646
|
-
"Content-Type": "application/json",
|
|
2647
2655
|
Accept: "application/json",
|
|
2656
|
+
"Content-Type": "application/json",
|
|
2648
2657
|
...requestConfig.headers
|
|
2649
|
-
}
|
|
2658
|
+
},
|
|
2659
|
+
method: "GET"
|
|
2650
2660
|
};
|
|
2651
2661
|
try {
|
|
2652
2662
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2661,7 +2671,7 @@ var getMeOrganizations = async ({
|
|
|
2661
2671
|
);
|
|
2662
2672
|
}
|
|
2663
2673
|
const data = await response.json();
|
|
2664
|
-
return data
|
|
2674
|
+
return data["organizations"] || [];
|
|
2665
2675
|
} catch (error2) {
|
|
2666
2676
|
if (error2 instanceof AsgardeoAPIError) {
|
|
2667
2677
|
throw error2;
|
|
@@ -2708,12 +2718,12 @@ var getOrganization = async ({
|
|
|
2708
2718
|
const resolvedUrl = `${baseUrl}/api/server/v1/organizations/${organizationId}`;
|
|
2709
2719
|
const requestInit = {
|
|
2710
2720
|
...requestConfig,
|
|
2711
|
-
method: "GET",
|
|
2712
2721
|
headers: {
|
|
2713
|
-
"Content-Type": "application/json",
|
|
2714
2722
|
Accept: "application/json",
|
|
2723
|
+
"Content-Type": "application/json",
|
|
2715
2724
|
...requestConfig.headers
|
|
2716
|
-
}
|
|
2725
|
+
},
|
|
2726
|
+
method: "GET"
|
|
2717
2727
|
};
|
|
2718
2728
|
try {
|
|
2719
2729
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2802,13 +2812,13 @@ var updateOrganization = async ({
|
|
|
2802
2812
|
const resolvedUrl = `${baseUrl}/api/server/v1/organizations/${organizationId}`;
|
|
2803
2813
|
const requestInit = {
|
|
2804
2814
|
...requestConfig,
|
|
2805
|
-
|
|
2815
|
+
body: JSON.stringify(operations),
|
|
2806
2816
|
headers: {
|
|
2807
|
-
"Content-Type": "application/json",
|
|
2808
2817
|
Accept: "application/json",
|
|
2818
|
+
"Content-Type": "application/json",
|
|
2809
2819
|
...requestConfig.headers
|
|
2810
2820
|
},
|
|
2811
|
-
|
|
2821
|
+
method: "PATCH"
|
|
2812
2822
|
};
|
|
2813
2823
|
try {
|
|
2814
2824
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2836,21 +2846,19 @@ var updateOrganization = async ({
|
|
|
2836
2846
|
);
|
|
2837
2847
|
}
|
|
2838
2848
|
};
|
|
2839
|
-
var createPatchOperations = (payload) => {
|
|
2840
|
-
|
|
2841
|
-
if (isEmpty_default(value)) {
|
|
2842
|
-
return {
|
|
2843
|
-
operation: "REMOVE",
|
|
2844
|
-
path: `/${key}`
|
|
2845
|
-
};
|
|
2846
|
-
}
|
|
2849
|
+
var createPatchOperations = (payload) => Object.entries(payload).map(([key, value]) => {
|
|
2850
|
+
if (isEmpty_default(value)) {
|
|
2847
2851
|
return {
|
|
2848
|
-
operation: "
|
|
2849
|
-
path: `/${key}
|
|
2850
|
-
value
|
|
2852
|
+
operation: "REMOVE",
|
|
2853
|
+
path: `/${key}`
|
|
2851
2854
|
};
|
|
2852
|
-
}
|
|
2853
|
-
|
|
2855
|
+
}
|
|
2856
|
+
return {
|
|
2857
|
+
operation: "REPLACE",
|
|
2858
|
+
path: `/${key}`,
|
|
2859
|
+
value
|
|
2860
|
+
};
|
|
2861
|
+
});
|
|
2854
2862
|
var updateOrganization_default = updateOrganization;
|
|
2855
2863
|
|
|
2856
2864
|
// src/api/updateMeProfile.ts
|
|
@@ -2886,12 +2894,12 @@ var updateMeProfile = async ({
|
|
|
2886
2894
|
const requestInit = {
|
|
2887
2895
|
method: "PATCH",
|
|
2888
2896
|
...requestConfig,
|
|
2897
|
+
body: JSON.stringify(data),
|
|
2889
2898
|
headers: {
|
|
2890
2899
|
...requestConfig.headers,
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
}
|
|
2894
|
-
body: JSON.stringify(data)
|
|
2900
|
+
Accept: "application/json",
|
|
2901
|
+
"Content-Type": "application/scim+json"
|
|
2902
|
+
}
|
|
2895
2903
|
};
|
|
2896
2904
|
try {
|
|
2897
2905
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2954,12 +2962,12 @@ var getBrandingPreference = async ({
|
|
|
2954
2962
|
const resolvedUrl = `${baseUrl}/api/server/v1/branding-preference/resolve${queryParams.toString() ? `?${queryParams.toString()}` : ""}`;
|
|
2955
2963
|
const requestInit = {
|
|
2956
2964
|
...requestConfig,
|
|
2957
|
-
method: "GET",
|
|
2958
2965
|
headers: {
|
|
2959
|
-
"Content-Type": "application/json",
|
|
2960
2966
|
Accept: "application/json",
|
|
2967
|
+
"Content-Type": "application/json",
|
|
2961
2968
|
...requestConfig.headers
|
|
2962
|
-
}
|
|
2969
|
+
},
|
|
2970
|
+
method: "GET"
|
|
2963
2971
|
};
|
|
2964
2972
|
try {
|
|
2965
2973
|
const response = await fetchFn(resolvedUrl, requestInit);
|
|
@@ -2993,8 +3001,8 @@ var getBrandingPreference_default = getBrandingPreference;
|
|
|
2993
3001
|
// src/models/v2/embedded-signin-flow-v2.ts
|
|
2994
3002
|
var EmbeddedSignInFlowStatus = /* @__PURE__ */ ((EmbeddedSignInFlowStatus3) => {
|
|
2995
3003
|
EmbeddedSignInFlowStatus3["Complete"] = "COMPLETE";
|
|
2996
|
-
EmbeddedSignInFlowStatus3["Incomplete"] = "INCOMPLETE";
|
|
2997
3004
|
EmbeddedSignInFlowStatus3["Error"] = "ERROR";
|
|
3005
|
+
EmbeddedSignInFlowStatus3["Incomplete"] = "INCOMPLETE";
|
|
2998
3006
|
return EmbeddedSignInFlowStatus3;
|
|
2999
3007
|
})(EmbeddedSignInFlowStatus || {});
|
|
3000
3008
|
var EmbeddedSignInFlowType = /* @__PURE__ */ ((EmbeddedSignInFlowType3) => {
|
|
@@ -3020,20 +3028,20 @@ var executeEmbeddedSignInFlowV2 = async ({
|
|
|
3020
3028
|
"If an authorization payload is not provided, the request cannot be constructed correctly."
|
|
3021
3029
|
);
|
|
3022
3030
|
}
|
|
3023
|
-
|
|
3031
|
+
const endpoint = url ?? `${baseUrl}/flow/execute`;
|
|
3024
3032
|
const cleanPayload = typeof payload === "object" && payload !== null ? Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "verbose")) : payload;
|
|
3025
3033
|
const hasOnlyAppIdAndFlowType = typeof cleanPayload === "object" && cleanPayload !== null && "applicationId" in cleanPayload && "flowType" in cleanPayload && Object.keys(cleanPayload).length === 2;
|
|
3026
3034
|
const hasOnlyFlowId = typeof cleanPayload === "object" && cleanPayload !== null && "flowId" in cleanPayload && Object.keys(cleanPayload).length === 1;
|
|
3027
3035
|
const requestPayload = hasOnlyAppIdAndFlowType || hasOnlyFlowId ? { ...cleanPayload, verbose: true } : cleanPayload;
|
|
3028
3036
|
const response = await fetch(endpoint, {
|
|
3029
3037
|
...requestConfig,
|
|
3030
|
-
|
|
3038
|
+
body: JSON.stringify(requestPayload),
|
|
3031
3039
|
headers: {
|
|
3032
|
-
"Content-Type": "application/json",
|
|
3033
3040
|
Accept: "application/json",
|
|
3041
|
+
"Content-Type": "application/json",
|
|
3034
3042
|
...requestConfig.headers
|
|
3035
3043
|
},
|
|
3036
|
-
|
|
3044
|
+
method: requestConfig.method || "POST"
|
|
3037
3045
|
});
|
|
3038
3046
|
if (!response.ok) {
|
|
3039
3047
|
const errorText = await response.text();
|
|
@@ -3049,17 +3057,17 @@ var executeEmbeddedSignInFlowV2 = async ({
|
|
|
3049
3057
|
if (flowResponse.flowStatus === "COMPLETE" /* Complete */ && flowResponse.assertion && authId) {
|
|
3050
3058
|
try {
|
|
3051
3059
|
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
3060
|
body: JSON.stringify({
|
|
3059
3061
|
assertion: flowResponse.assertion,
|
|
3060
3062
|
authId
|
|
3061
3063
|
}),
|
|
3062
|
-
credentials: "include"
|
|
3064
|
+
credentials: "include",
|
|
3065
|
+
headers: {
|
|
3066
|
+
Accept: "application/json",
|
|
3067
|
+
"Content-Type": "application/json",
|
|
3068
|
+
...requestConfig.headers
|
|
3069
|
+
},
|
|
3070
|
+
method: "POST"
|
|
3063
3071
|
});
|
|
3064
3072
|
if (!oauth2Response.ok) {
|
|
3065
3073
|
const oauth2ErrorText = await oauth2Response.text();
|
|
@@ -3074,7 +3082,7 @@ var executeEmbeddedSignInFlowV2 = async ({
|
|
|
3074
3082
|
const oauth2Result = await oauth2Response.json();
|
|
3075
3083
|
return {
|
|
3076
3084
|
flowStatus: flowResponse.flowStatus,
|
|
3077
|
-
redirectUrl: oauth2Result
|
|
3085
|
+
redirectUrl: oauth2Result["redirect_uri"]
|
|
3078
3086
|
};
|
|
3079
3087
|
} catch (authError) {
|
|
3080
3088
|
throw new AsgardeoAPIError(
|
|
@@ -3093,8 +3101,8 @@ var executeEmbeddedSignInFlowV2_default = executeEmbeddedSignInFlowV2;
|
|
|
3093
3101
|
// src/models/v2/embedded-signup-flow-v2.ts
|
|
3094
3102
|
var EmbeddedSignUpFlowStatus = /* @__PURE__ */ ((EmbeddedSignUpFlowStatus2) => {
|
|
3095
3103
|
EmbeddedSignUpFlowStatus2["Complete"] = "COMPLETE";
|
|
3096
|
-
EmbeddedSignUpFlowStatus2["Incomplete"] = "INCOMPLETE";
|
|
3097
3104
|
EmbeddedSignUpFlowStatus2["Error"] = "ERROR";
|
|
3105
|
+
EmbeddedSignUpFlowStatus2["Incomplete"] = "INCOMPLETE";
|
|
3098
3106
|
return EmbeddedSignUpFlowStatus2;
|
|
3099
3107
|
})(EmbeddedSignUpFlowStatus || {});
|
|
3100
3108
|
var EmbeddedSignUpFlowType = /* @__PURE__ */ ((EmbeddedSignUpFlowType2) => {
|
|
@@ -3120,20 +3128,20 @@ var executeEmbeddedSignUpFlowV2 = async ({
|
|
|
3120
3128
|
"If a registration payload is not provided, the request cannot be constructed correctly."
|
|
3121
3129
|
);
|
|
3122
3130
|
}
|
|
3123
|
-
|
|
3131
|
+
const endpoint = url ?? `${baseUrl}/flow/execute`;
|
|
3124
3132
|
const cleanPayload = typeof payload === "object" && payload !== null ? Object.fromEntries(Object.entries(payload).filter(([key]) => key !== "verbose")) : payload;
|
|
3125
3133
|
const hasOnlyAppIdAndFlowType = typeof cleanPayload === "object" && cleanPayload !== null && "applicationId" in cleanPayload && "flowType" in cleanPayload && Object.keys(cleanPayload).length === 2;
|
|
3126
3134
|
const hasOnlyFlowId = typeof cleanPayload === "object" && cleanPayload !== null && "flowId" in cleanPayload && Object.keys(cleanPayload).length === 1;
|
|
3127
3135
|
const requestPayload = hasOnlyAppIdAndFlowType || hasOnlyFlowId ? { ...cleanPayload, verbose: true } : cleanPayload;
|
|
3128
3136
|
const response = await fetch(endpoint, {
|
|
3129
3137
|
...requestConfig,
|
|
3130
|
-
|
|
3138
|
+
body: JSON.stringify(requestPayload),
|
|
3131
3139
|
headers: {
|
|
3132
|
-
"Content-Type": "application/json",
|
|
3133
3140
|
Accept: "application/json",
|
|
3141
|
+
"Content-Type": "application/json",
|
|
3134
3142
|
...requestConfig.headers
|
|
3135
3143
|
},
|
|
3136
|
-
|
|
3144
|
+
method: requestConfig.method || "POST"
|
|
3137
3145
|
});
|
|
3138
3146
|
if (!response.ok) {
|
|
3139
3147
|
const errorText = await response.text();
|
|
@@ -3149,17 +3157,17 @@ var executeEmbeddedSignUpFlowV2 = async ({
|
|
|
3149
3157
|
if (flowResponse.flowStatus === "COMPLETE" /* Complete */ && flowResponse.assertion && authId) {
|
|
3150
3158
|
try {
|
|
3151
3159
|
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
3160
|
body: JSON.stringify({
|
|
3159
3161
|
assertion: flowResponse.assertion,
|
|
3160
3162
|
authId
|
|
3161
3163
|
}),
|
|
3162
|
-
credentials: "include"
|
|
3164
|
+
credentials: "include",
|
|
3165
|
+
headers: {
|
|
3166
|
+
Accept: "application/json",
|
|
3167
|
+
"Content-Type": "application/json",
|
|
3168
|
+
...requestConfig.headers
|
|
3169
|
+
},
|
|
3170
|
+
method: "POST"
|
|
3163
3171
|
});
|
|
3164
3172
|
if (!oauth2Response.ok) {
|
|
3165
3173
|
const oauth2ErrorText = await oauth2Response.text();
|
|
@@ -3174,7 +3182,7 @@ var executeEmbeddedSignUpFlowV2 = async ({
|
|
|
3174
3182
|
const oauth2Result = await oauth2Response.json();
|
|
3175
3183
|
return {
|
|
3176
3184
|
flowStatus: flowResponse.flowStatus,
|
|
3177
|
-
redirectUrl: oauth2Result
|
|
3185
|
+
redirectUrl: oauth2Result["redirect_uri"]
|
|
3178
3186
|
};
|
|
3179
3187
|
} catch (authError) {
|
|
3180
3188
|
throw new AsgardeoAPIError(
|
|
@@ -3217,13 +3225,13 @@ var executeEmbeddedUserOnboardingFlowV2 = async ({
|
|
|
3217
3225
|
}
|
|
3218
3226
|
const response = await fetch(endpoint, {
|
|
3219
3227
|
...requestConfig,
|
|
3220
|
-
|
|
3228
|
+
body: JSON.stringify(requestPayload),
|
|
3221
3229
|
headers: {
|
|
3222
|
-
"Content-Type": "application/json",
|
|
3223
3230
|
Accept: "application/json",
|
|
3231
|
+
"Content-Type": "application/json",
|
|
3224
3232
|
...requestConfig.headers
|
|
3225
3233
|
},
|
|
3226
|
-
|
|
3234
|
+
method: requestConfig.method || "POST"
|
|
3227
3235
|
});
|
|
3228
3236
|
if (!response.ok) {
|
|
3229
3237
|
const errorText = await response.text();
|
|
@@ -3243,20 +3251,20 @@ var executeEmbeddedUserOnboardingFlowV2_default = executeEmbeddedUserOnboardingF
|
|
|
3243
3251
|
// src/constants/ApplicationNativeAuthenticationConstants.ts
|
|
3244
3252
|
var ApplicationNativeAuthenticationConstants = {
|
|
3245
3253
|
SupportedAuthenticators: {
|
|
3246
|
-
IdentifierFirst: "SWRlbnRpZmllckV4ZWN1dG9yOkxPQ0FM",
|
|
3247
3254
|
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
3255
|
Facebook: "RmFjZWJvb2tBdXRoZW50aWNhdG9yOkZhY2Vib29r",
|
|
3256
|
+
GitHub: "R2l0aHViQXV0aGVudGljYXRvcjpHaXRIdWI",
|
|
3257
|
+
Google: "R29vZ2xlT0lEQ0F1dGhlbnRpY2F0b3I6R29vZ2xl",
|
|
3258
|
+
IdentifierFirst: "SWRlbnRpZmllckV4ZWN1dG9yOkxPQ0FM",
|
|
3258
3259
|
LinkedIn: "TGlua2VkSW5PSURDOkxpbmtlZElu",
|
|
3259
|
-
|
|
3260
|
+
MagicLink: "TWFnaWNMaW5rQXV0aGVudGljYXRvcjpMT0NBTA",
|
|
3261
|
+
Microsoft: "T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I6TWljcm9zb2Z0",
|
|
3262
|
+
Passkey: "RklET0F1dGhlbnRpY2F0b3I6TE9DQUw",
|
|
3263
|
+
PushNotification: "cHVzaC1ub3RpZmljYXRpb24tYXV0aGVudGljYXRvcjpMT0NBTA",
|
|
3264
|
+
SignInWithEthereum: "T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I6U2lnbiBJbiBXaXRoIEV0aGVyZXVt",
|
|
3265
|
+
SmsOtp: "c21zLW90cC1hdXRoZW50aWNhdG9yOkxPQ0FM",
|
|
3266
|
+
Totp: "dG90cDpMT0NBTA",
|
|
3267
|
+
UsernamePassword: "QmFzaWNBdXRoZW50aWNhdG9yOkxPQ0FM"
|
|
3260
3268
|
}
|
|
3261
3269
|
};
|
|
3262
3270
|
var ApplicationNativeAuthenticationConstants_default = ApplicationNativeAuthenticationConstants;
|
|
@@ -3306,53 +3314,53 @@ var EmbeddedSignInFlowAuthenticatorPromptType = /* @__PURE__ */ ((EmbeddedSignIn
|
|
|
3306
3314
|
|
|
3307
3315
|
// src/models/v2/embedded-flow-v2.ts
|
|
3308
3316
|
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
3317
|
EmbeddedFlowComponentType3["Action"] = "ACTION";
|
|
3316
3318
|
EmbeddedFlowComponentType3["Block"] = "BLOCK";
|
|
3317
3319
|
EmbeddedFlowComponentType3["Divider"] = "DIVIDER";
|
|
3320
|
+
EmbeddedFlowComponentType3["EmailInput"] = "EMAIL_INPUT";
|
|
3321
|
+
EmbeddedFlowComponentType3["OtpInput"] = "OTP_INPUT";
|
|
3322
|
+
EmbeddedFlowComponentType3["PasswordInput"] = "PASSWORD_INPUT";
|
|
3323
|
+
EmbeddedFlowComponentType3["PhoneInput"] = "PHONE_INPUT";
|
|
3318
3324
|
EmbeddedFlowComponentType3["Select"] = "SELECT";
|
|
3325
|
+
EmbeddedFlowComponentType3["Text"] = "TEXT";
|
|
3326
|
+
EmbeddedFlowComponentType3["TextInput"] = "TEXT_INPUT";
|
|
3319
3327
|
return EmbeddedFlowComponentType3;
|
|
3320
3328
|
})(EmbeddedFlowComponentType2 || {});
|
|
3321
3329
|
var EmbeddedFlowActionVariant = /* @__PURE__ */ ((EmbeddedFlowActionVariant2) => {
|
|
3322
|
-
EmbeddedFlowActionVariant2["Primary"] = "PRIMARY";
|
|
3323
|
-
EmbeddedFlowActionVariant2["Secondary"] = "SECONDARY";
|
|
3324
|
-
EmbeddedFlowActionVariant2["Tertiary"] = "TERTIARY";
|
|
3325
3330
|
EmbeddedFlowActionVariant2["Danger"] = "DANGER";
|
|
3326
|
-
EmbeddedFlowActionVariant2["Success"] = "SUCCESS";
|
|
3327
3331
|
EmbeddedFlowActionVariant2["Info"] = "INFO";
|
|
3328
|
-
EmbeddedFlowActionVariant2["Warning"] = "WARNING";
|
|
3329
3332
|
EmbeddedFlowActionVariant2["Link"] = "LINK";
|
|
3333
|
+
EmbeddedFlowActionVariant2["Primary"] = "PRIMARY";
|
|
3334
|
+
EmbeddedFlowActionVariant2["Secondary"] = "SECONDARY";
|
|
3330
3335
|
EmbeddedFlowActionVariant2["Social"] = "SOCIAL";
|
|
3336
|
+
EmbeddedFlowActionVariant2["Success"] = "SUCCESS";
|
|
3337
|
+
EmbeddedFlowActionVariant2["Tertiary"] = "TERTIARY";
|
|
3338
|
+
EmbeddedFlowActionVariant2["Warning"] = "WARNING";
|
|
3331
3339
|
return EmbeddedFlowActionVariant2;
|
|
3332
3340
|
})(EmbeddedFlowActionVariant || {});
|
|
3333
3341
|
var EmbeddedFlowTextVariant = /* @__PURE__ */ ((EmbeddedFlowTextVariant2) => {
|
|
3342
|
+
EmbeddedFlowTextVariant2["Body1"] = "BODY_1";
|
|
3343
|
+
EmbeddedFlowTextVariant2["Body2"] = "BODY_2";
|
|
3344
|
+
EmbeddedFlowTextVariant2["ButtonText"] = "BUTTON_TEXT";
|
|
3345
|
+
EmbeddedFlowTextVariant2["Caption"] = "CAPTION";
|
|
3334
3346
|
EmbeddedFlowTextVariant2["Heading1"] = "HEADING_1";
|
|
3335
3347
|
EmbeddedFlowTextVariant2["Heading2"] = "HEADING_2";
|
|
3336
3348
|
EmbeddedFlowTextVariant2["Heading3"] = "HEADING_3";
|
|
3337
3349
|
EmbeddedFlowTextVariant2["Heading4"] = "HEADING_4";
|
|
3338
3350
|
EmbeddedFlowTextVariant2["Heading5"] = "HEADING_5";
|
|
3339
3351
|
EmbeddedFlowTextVariant2["Heading6"] = "HEADING_6";
|
|
3352
|
+
EmbeddedFlowTextVariant2["Overline"] = "OVERLINE";
|
|
3340
3353
|
EmbeddedFlowTextVariant2["Subtitle1"] = "SUBTITLE_1";
|
|
3341
3354
|
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
3355
|
return EmbeddedFlowTextVariant2;
|
|
3348
3356
|
})(EmbeddedFlowTextVariant || {});
|
|
3349
3357
|
var EmbeddedFlowEventType = /* @__PURE__ */ ((EmbeddedFlowEventType2) => {
|
|
3350
|
-
EmbeddedFlowEventType2["
|
|
3351
|
-
EmbeddedFlowEventType2["Submit"] = "SUBMIT";
|
|
3352
|
-
EmbeddedFlowEventType2["Navigate"] = "NAVIGATE";
|
|
3358
|
+
EmbeddedFlowEventType2["Back"] = "BACK";
|
|
3353
3359
|
EmbeddedFlowEventType2["Cancel"] = "CANCEL";
|
|
3360
|
+
EmbeddedFlowEventType2["Navigate"] = "NAVIGATE";
|
|
3354
3361
|
EmbeddedFlowEventType2["Reset"] = "RESET";
|
|
3355
|
-
EmbeddedFlowEventType2["
|
|
3362
|
+
EmbeddedFlowEventType2["Submit"] = "SUBMIT";
|
|
3363
|
+
EmbeddedFlowEventType2["Trigger"] = "TRIGGER";
|
|
3356
3364
|
return EmbeddedFlowEventType2;
|
|
3357
3365
|
})(EmbeddedFlowEventType || {});
|
|
3358
3366
|
|
|
@@ -3366,26 +3374,26 @@ var FlowMode = /* @__PURE__ */ ((FlowMode2) => {
|
|
|
3366
3374
|
// src/models/scim2-schema.ts
|
|
3367
3375
|
var WellKnownSchemaIds = /* @__PURE__ */ ((WellKnownSchemaIds2) => {
|
|
3368
3376
|
WellKnownSchemaIds2["Core"] = "urn:ietf:params:scim:schemas:core:2.0";
|
|
3369
|
-
WellKnownSchemaIds2["
|
|
3377
|
+
WellKnownSchemaIds2["CustomUser"] = "urn:scim:schemas:extension:custom:User";
|
|
3370
3378
|
WellKnownSchemaIds2["EnterpriseUser"] = "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User";
|
|
3371
3379
|
WellKnownSchemaIds2["SystemUser"] = "urn:scim:wso2:schema";
|
|
3372
|
-
WellKnownSchemaIds2["
|
|
3380
|
+
WellKnownSchemaIds2["User"] = "urn:ietf:params:scim:schemas:core:2.0:User";
|
|
3373
3381
|
return WellKnownSchemaIds2;
|
|
3374
3382
|
})(WellKnownSchemaIds || {});
|
|
3375
3383
|
|
|
3376
3384
|
// src/models/field.ts
|
|
3377
3385
|
var FieldType = /* @__PURE__ */ ((FieldType2) => {
|
|
3378
|
-
FieldType2["
|
|
3379
|
-
FieldType2["
|
|
3386
|
+
FieldType2["Checkbox"] = "CHECKBOX";
|
|
3387
|
+
FieldType2["Date"] = "DATE";
|
|
3380
3388
|
FieldType2["Email"] = "EMAIL";
|
|
3381
3389
|
FieldType2["Number"] = "NUMBER";
|
|
3382
|
-
FieldType2["Select"] = "SELECT";
|
|
3383
|
-
FieldType2["Checkbox"] = "CHECKBOX";
|
|
3384
|
-
FieldType2["Radio"] = "RADIO";
|
|
3385
3390
|
FieldType2["Otp"] = "OTP";
|
|
3386
|
-
FieldType2["
|
|
3387
|
-
FieldType2["
|
|
3391
|
+
FieldType2["Password"] = "PASSWORD";
|
|
3392
|
+
FieldType2["Radio"] = "RADIO";
|
|
3393
|
+
FieldType2["Select"] = "SELECT";
|
|
3394
|
+
FieldType2["Text"] = "TEXT";
|
|
3388
3395
|
FieldType2["Textarea"] = "TEXTAREA";
|
|
3396
|
+
FieldType2["Time"] = "TIME";
|
|
3389
3397
|
return FieldType2;
|
|
3390
3398
|
})(FieldType || {});
|
|
3391
3399
|
|
|
@@ -3396,221 +3404,221 @@ var AsgardeoJavaScriptClient_default = AsgardeoJavaScriptClient;
|
|
|
3396
3404
|
|
|
3397
3405
|
// src/theme/createTheme.ts
|
|
3398
3406
|
var lightTheme = {
|
|
3407
|
+
borderRadius: {
|
|
3408
|
+
large: "16px",
|
|
3409
|
+
medium: "8px",
|
|
3410
|
+
small: "4px"
|
|
3411
|
+
},
|
|
3399
3412
|
colors: {
|
|
3400
3413
|
action: {
|
|
3414
|
+
activatedOpacity: 0.12,
|
|
3401
3415
|
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
3416
|
disabled: "rgba(0, 0, 0, 0.26)",
|
|
3407
3417
|
disabledBackground: "rgba(0, 0, 0, 0.12)",
|
|
3408
3418
|
disabledOpacity: 0.38,
|
|
3409
3419
|
focus: "rgba(0, 0, 0, 0.12)",
|
|
3410
3420
|
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"
|
|
3421
|
+
hover: "rgba(0, 0, 0, 0.04)",
|
|
3422
|
+
hoverOpacity: 0.04,
|
|
3423
|
+
selected: "rgba(0, 0, 0, 0.08)",
|
|
3424
|
+
selectedOpacity: 0.08
|
|
3422
3425
|
},
|
|
3423
3426
|
background: {
|
|
3424
|
-
surface: "#ffffff",
|
|
3425
|
-
disabled: "#f0f0f0",
|
|
3426
|
-
dark: "#212121",
|
|
3427
3427
|
body: {
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
}
|
|
3428
|
+
dark: "#212121",
|
|
3429
|
+
main: "#1a1a1a"
|
|
3430
|
+
},
|
|
3431
|
+
dark: "#212121",
|
|
3432
|
+
disabled: "#f0f0f0",
|
|
3433
|
+
surface: "#ffffff"
|
|
3431
3434
|
},
|
|
3435
|
+
border: "#e0e0e0",
|
|
3432
3436
|
error: {
|
|
3433
|
-
main: "#d32f2f",
|
|
3434
3437
|
contrastText: "#d52828",
|
|
3435
|
-
dark: "#b71c1c"
|
|
3438
|
+
dark: "#b71c1c",
|
|
3439
|
+
main: "#d32f2f"
|
|
3436
3440
|
},
|
|
3437
3441
|
info: {
|
|
3438
|
-
main: "#bbebff",
|
|
3439
3442
|
contrastText: "#43aeda",
|
|
3440
|
-
dark: "#01579b"
|
|
3443
|
+
dark: "#01579b",
|
|
3444
|
+
main: "#bbebff"
|
|
3445
|
+
},
|
|
3446
|
+
primary: {
|
|
3447
|
+
contrastText: "#ffffff",
|
|
3448
|
+
dark: "#174ea6",
|
|
3449
|
+
main: "#1a73e8"
|
|
3450
|
+
},
|
|
3451
|
+
secondary: {
|
|
3452
|
+
contrastText: "#ffffff",
|
|
3453
|
+
dark: "#212121",
|
|
3454
|
+
main: "#424242"
|
|
3441
3455
|
},
|
|
3442
3456
|
success: {
|
|
3443
|
-
main: "#4caf50",
|
|
3444
3457
|
contrastText: "#00a807",
|
|
3445
|
-
dark: "#388e3c"
|
|
3446
|
-
|
|
3447
|
-
warning: {
|
|
3448
|
-
main: "#ff9800",
|
|
3449
|
-
contrastText: "#be7100",
|
|
3450
|
-
dark: "#f57c00"
|
|
3458
|
+
dark: "#388e3c",
|
|
3459
|
+
main: "#4caf50"
|
|
3451
3460
|
},
|
|
3452
3461
|
text: {
|
|
3462
|
+
dark: "#212121",
|
|
3453
3463
|
primary: "#1a1a1a",
|
|
3454
|
-
secondary: "#666666"
|
|
3455
|
-
dark: "#212121"
|
|
3464
|
+
secondary: "#666666"
|
|
3456
3465
|
},
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3466
|
+
warning: {
|
|
3467
|
+
contrastText: "#be7100",
|
|
3468
|
+
dark: "#f57c00",
|
|
3469
|
+
main: "#ff9800"
|
|
3470
|
+
}
|
|
3461
3471
|
},
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
large: "16px"
|
|
3472
|
+
images: {
|
|
3473
|
+
favicon: {},
|
|
3474
|
+
logo: {}
|
|
3466
3475
|
},
|
|
3467
3476
|
shadows: {
|
|
3468
|
-
|
|
3477
|
+
large: "0 8px 32px rgba(0, 0, 0, 0.2)",
|
|
3469
3478
|
medium: "0 4px 16px rgba(0, 0, 0, 0.15)",
|
|
3470
|
-
|
|
3479
|
+
small: "0 2px 8px rgba(0, 0, 0, 0.1)"
|
|
3480
|
+
},
|
|
3481
|
+
spacing: {
|
|
3482
|
+
unit: 8
|
|
3471
3483
|
},
|
|
3472
3484
|
typography: {
|
|
3473
3485
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
|
|
3474
3486
|
fontSizes: {
|
|
3475
|
-
|
|
3476
|
-
//
|
|
3477
|
-
|
|
3478
|
-
//
|
|
3479
|
-
md: "1rem",
|
|
3480
|
-
// 16px
|
|
3487
|
+
"2xl": "1.5rem",
|
|
3488
|
+
// 24px
|
|
3489
|
+
"3xl": "2.125rem",
|
|
3490
|
+
// 34px
|
|
3481
3491
|
lg: "1.125rem",
|
|
3482
3492
|
// 18px
|
|
3493
|
+
md: "1rem",
|
|
3494
|
+
// 16px
|
|
3495
|
+
sm: "0.875rem",
|
|
3496
|
+
// 14px
|
|
3483
3497
|
xl: "1.25rem",
|
|
3484
3498
|
// 20px
|
|
3485
|
-
|
|
3486
|
-
//
|
|
3487
|
-
"3xl": "2.125rem"
|
|
3488
|
-
// 34px
|
|
3499
|
+
xs: "0.75rem"
|
|
3500
|
+
// 12px
|
|
3489
3501
|
},
|
|
3490
3502
|
fontWeights: {
|
|
3491
|
-
|
|
3503
|
+
bold: 700,
|
|
3492
3504
|
medium: 500,
|
|
3493
|
-
|
|
3494
|
-
|
|
3505
|
+
normal: 400,
|
|
3506
|
+
semibold: 600
|
|
3495
3507
|
},
|
|
3496
3508
|
lineHeights: {
|
|
3497
|
-
tight: 1.2,
|
|
3498
3509
|
normal: 1.4,
|
|
3499
|
-
relaxed: 1.6
|
|
3510
|
+
relaxed: 1.6,
|
|
3511
|
+
tight: 1.2
|
|
3500
3512
|
}
|
|
3501
|
-
},
|
|
3502
|
-
images: {
|
|
3503
|
-
favicon: {},
|
|
3504
|
-
logo: {}
|
|
3505
3513
|
}
|
|
3506
3514
|
};
|
|
3507
3515
|
var darkTheme = {
|
|
3516
|
+
borderRadius: {
|
|
3517
|
+
large: "16px",
|
|
3518
|
+
medium: "8px",
|
|
3519
|
+
small: "4px"
|
|
3520
|
+
},
|
|
3508
3521
|
colors: {
|
|
3509
3522
|
action: {
|
|
3523
|
+
activatedOpacity: 0.12,
|
|
3510
3524
|
active: "#1c1c1c",
|
|
3511
|
-
hover: "#1c1c1c",
|
|
3512
|
-
hoverOpacity: 0.04,
|
|
3513
|
-
selected: "#1c1c1c",
|
|
3514
|
-
selectedOpacity: 0.08,
|
|
3515
3525
|
disabled: "rgba(255, 255, 255, 0.26)",
|
|
3516
3526
|
disabledBackground: "rgba(255, 255, 255, 0.12)",
|
|
3517
3527
|
disabledOpacity: 0.38,
|
|
3518
3528
|
focus: "#1c1c1c",
|
|
3519
3529
|
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"
|
|
3530
|
+
hover: "#1c1c1c",
|
|
3531
|
+
hoverOpacity: 0.04,
|
|
3532
|
+
selected: "#1c1c1c",
|
|
3533
|
+
selectedOpacity: 0.08
|
|
3531
3534
|
},
|
|
3532
3535
|
background: {
|
|
3533
|
-
surface: "#121212",
|
|
3534
|
-
disabled: "#1f1f1f",
|
|
3535
|
-
dark: "#212121",
|
|
3536
3536
|
body: {
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
}
|
|
3537
|
+
dark: "#212121",
|
|
3538
|
+
main: "#ffffff"
|
|
3539
|
+
},
|
|
3540
|
+
dark: "#212121",
|
|
3541
|
+
disabled: "#1f1f1f",
|
|
3542
|
+
surface: "#121212"
|
|
3540
3543
|
},
|
|
3544
|
+
border: "#404040",
|
|
3541
3545
|
error: {
|
|
3542
|
-
main: "#d32f2f",
|
|
3543
3546
|
contrastText: "#d52828",
|
|
3544
|
-
dark: "#b71c1c"
|
|
3547
|
+
dark: "#b71c1c",
|
|
3548
|
+
main: "#d32f2f"
|
|
3545
3549
|
},
|
|
3546
3550
|
info: {
|
|
3547
|
-
main: "#bbebff",
|
|
3548
3551
|
contrastText: "#43aeda",
|
|
3549
|
-
dark: "#01579b"
|
|
3552
|
+
dark: "#01579b",
|
|
3553
|
+
main: "#bbebff"
|
|
3554
|
+
},
|
|
3555
|
+
primary: {
|
|
3556
|
+
contrastText: "#ffffff",
|
|
3557
|
+
dark: "#174ea6",
|
|
3558
|
+
main: "#1a73e8"
|
|
3559
|
+
},
|
|
3560
|
+
secondary: {
|
|
3561
|
+
contrastText: "#ffffff",
|
|
3562
|
+
dark: "#212121",
|
|
3563
|
+
main: "#8b8b8b"
|
|
3550
3564
|
},
|
|
3551
3565
|
success: {
|
|
3552
|
-
main: "#4caf50",
|
|
3553
3566
|
contrastText: "#00a807",
|
|
3554
|
-
dark: "#388e3c"
|
|
3555
|
-
|
|
3556
|
-
warning: {
|
|
3557
|
-
main: "#ff9800",
|
|
3558
|
-
contrastText: "#be7100",
|
|
3559
|
-
dark: "#f57c00"
|
|
3567
|
+
dark: "#388e3c",
|
|
3568
|
+
main: "#4caf50"
|
|
3560
3569
|
},
|
|
3561
3570
|
text: {
|
|
3571
|
+
dark: "#212121",
|
|
3562
3572
|
primary: "#ffffff",
|
|
3563
|
-
secondary: "#b3b3b3"
|
|
3564
|
-
dark: "#212121"
|
|
3573
|
+
secondary: "#b3b3b3"
|
|
3565
3574
|
},
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3575
|
+
warning: {
|
|
3576
|
+
contrastText: "#be7100",
|
|
3577
|
+
dark: "#f57c00",
|
|
3578
|
+
main: "#ff9800"
|
|
3579
|
+
}
|
|
3570
3580
|
},
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
large: "16px"
|
|
3581
|
+
images: {
|
|
3582
|
+
favicon: {},
|
|
3583
|
+
logo: {}
|
|
3575
3584
|
},
|
|
3576
3585
|
shadows: {
|
|
3577
|
-
|
|
3586
|
+
large: "0 8px 32px rgba(0, 0, 0, 0.5)",
|
|
3578
3587
|
medium: "0 4px 16px rgba(0, 0, 0, 0.4)",
|
|
3579
|
-
|
|
3588
|
+
small: "0 2px 8px rgba(0, 0, 0, 0.3)"
|
|
3589
|
+
},
|
|
3590
|
+
spacing: {
|
|
3591
|
+
unit: 8
|
|
3580
3592
|
},
|
|
3581
3593
|
typography: {
|
|
3582
3594
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
|
|
3583
3595
|
fontSizes: {
|
|
3584
|
-
|
|
3585
|
-
//
|
|
3586
|
-
|
|
3587
|
-
//
|
|
3588
|
-
md: "1rem",
|
|
3589
|
-
// 16px
|
|
3596
|
+
"2xl": "1.5rem",
|
|
3597
|
+
// 24px
|
|
3598
|
+
"3xl": "2.125rem",
|
|
3599
|
+
// 34px
|
|
3590
3600
|
lg: "1.125rem",
|
|
3591
3601
|
// 18px
|
|
3602
|
+
md: "1rem",
|
|
3603
|
+
// 16px
|
|
3604
|
+
sm: "0.875rem",
|
|
3605
|
+
// 14px
|
|
3592
3606
|
xl: "1.25rem",
|
|
3593
3607
|
// 20px
|
|
3594
|
-
|
|
3595
|
-
//
|
|
3596
|
-
"3xl": "2.125rem"
|
|
3597
|
-
// 34px
|
|
3608
|
+
xs: "0.75rem"
|
|
3609
|
+
// 12px
|
|
3598
3610
|
},
|
|
3599
3611
|
fontWeights: {
|
|
3600
|
-
|
|
3612
|
+
bold: 700,
|
|
3601
3613
|
medium: 500,
|
|
3602
|
-
|
|
3603
|
-
|
|
3614
|
+
normal: 400,
|
|
3615
|
+
semibold: 600
|
|
3604
3616
|
},
|
|
3605
3617
|
lineHeights: {
|
|
3606
|
-
tight: 1.2,
|
|
3607
3618
|
normal: 1.4,
|
|
3608
|
-
relaxed: 1.6
|
|
3619
|
+
relaxed: 1.6,
|
|
3620
|
+
tight: 1.2
|
|
3609
3621
|
}
|
|
3610
|
-
},
|
|
3611
|
-
images: {
|
|
3612
|
-
favicon: {},
|
|
3613
|
-
logo: {}
|
|
3614
3622
|
}
|
|
3615
3623
|
};
|
|
3616
3624
|
var toCssVariables = (theme) => {
|
|
@@ -3809,91 +3817,91 @@ var toThemeVars = (theme) => {
|
|
|
3809
3817
|
};
|
|
3810
3818
|
}
|
|
3811
3819
|
const themeVars = {
|
|
3820
|
+
borderRadius: {
|
|
3821
|
+
large: `var(--${prefix}-border-radius-large)`,
|
|
3822
|
+
medium: `var(--${prefix}-border-radius-medium)`,
|
|
3823
|
+
small: `var(--${prefix}-border-radius-small)`
|
|
3824
|
+
},
|
|
3812
3825
|
colors: {
|
|
3813
3826
|
action: {
|
|
3827
|
+
activatedOpacity: `var(--${prefix}-color-action-activatedOpacity)`,
|
|
3814
3828
|
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
3829
|
disabled: `var(--${prefix}-color-action-disabled)`,
|
|
3820
3830
|
disabledBackground: `var(--${prefix}-color-action-disabledBackground)`,
|
|
3821
3831
|
disabledOpacity: `var(--${prefix}-color-action-disabledOpacity)`,
|
|
3822
3832
|
focus: `var(--${prefix}-color-action-focus)`,
|
|
3823
3833
|
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)`
|
|
3834
|
+
hover: `var(--${prefix}-color-action-hover)`,
|
|
3835
|
+
hoverOpacity: `var(--${prefix}-color-action-hoverOpacity)`,
|
|
3836
|
+
selected: `var(--${prefix}-color-action-selected)`,
|
|
3837
|
+
selectedOpacity: `var(--${prefix}-color-action-selectedOpacity)`
|
|
3833
3838
|
},
|
|
3834
3839
|
background: {
|
|
3835
|
-
surface: `var(--${prefix}-color-background-surface)`,
|
|
3836
|
-
disabled: `var(--${prefix}-color-background-disabled)`,
|
|
3837
3840
|
body: {
|
|
3838
3841
|
main: `var(--${prefix}-color-background-body-main)`
|
|
3839
|
-
}
|
|
3842
|
+
},
|
|
3843
|
+
disabled: `var(--${prefix}-color-background-disabled)`,
|
|
3844
|
+
surface: `var(--${prefix}-color-background-surface)`
|
|
3840
3845
|
},
|
|
3846
|
+
border: `var(--${prefix}-color-border)`,
|
|
3841
3847
|
error: {
|
|
3842
|
-
|
|
3843
|
-
|
|
3848
|
+
contrastText: `var(--${prefix}-color-error-contrastText)`,
|
|
3849
|
+
main: `var(--${prefix}-color-error-main)`
|
|
3844
3850
|
},
|
|
3845
3851
|
info: {
|
|
3846
3852
|
contrastText: `var(--${prefix}-color-info-contrastText)`,
|
|
3847
3853
|
main: `var(--${prefix}-color-info-main)`
|
|
3848
3854
|
},
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3855
|
+
primary: {
|
|
3856
|
+
contrastText: `var(--${prefix}-color-primary-contrastText)`,
|
|
3857
|
+
main: `var(--${prefix}-color-primary-main)`
|
|
3852
3858
|
},
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3859
|
+
secondary: {
|
|
3860
|
+
contrastText: `var(--${prefix}-color-secondary-contrastText)`,
|
|
3861
|
+
main: `var(--${prefix}-color-secondary-main)`
|
|
3862
|
+
},
|
|
3863
|
+
success: {
|
|
3864
|
+
contrastText: `var(--${prefix}-color-success-contrastText)`,
|
|
3865
|
+
main: `var(--${prefix}-color-success-main)`
|
|
3856
3866
|
},
|
|
3857
3867
|
text: {
|
|
3858
3868
|
primary: `var(--${prefix}-color-text-primary)`,
|
|
3859
3869
|
secondary: `var(--${prefix}-color-text-secondary)`
|
|
3860
3870
|
},
|
|
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)`
|
|
3871
|
+
warning: {
|
|
3872
|
+
contrastText: `var(--${prefix}-color-warning-contrastText)`,
|
|
3873
|
+
main: `var(--${prefix}-color-warning-main)`
|
|
3874
|
+
}
|
|
3870
3875
|
},
|
|
3871
3876
|
shadows: {
|
|
3872
|
-
|
|
3877
|
+
large: `var(--${prefix}-shadow-large)`,
|
|
3873
3878
|
medium: `var(--${prefix}-shadow-medium)`,
|
|
3874
|
-
|
|
3879
|
+
small: `var(--${prefix}-shadow-small)`
|
|
3880
|
+
},
|
|
3881
|
+
spacing: {
|
|
3882
|
+
unit: `var(--${prefix}-spacing-unit)`
|
|
3875
3883
|
},
|
|
3876
3884
|
typography: {
|
|
3877
3885
|
fontFamily: `var(--${prefix}-typography-fontFamily)`,
|
|
3878
3886
|
fontSizes: {
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
md: `var(--${prefix}-typography-fontSize-md)`,
|
|
3887
|
+
"2xl": `var(--${prefix}-typography-fontSize-2xl)`,
|
|
3888
|
+
"3xl": `var(--${prefix}-typography-fontSize-3xl)`,
|
|
3882
3889
|
lg: `var(--${prefix}-typography-fontSize-lg)`,
|
|
3890
|
+
md: `var(--${prefix}-typography-fontSize-md)`,
|
|
3891
|
+
sm: `var(--${prefix}-typography-fontSize-sm)`,
|
|
3883
3892
|
xl: `var(--${prefix}-typography-fontSize-xl)`,
|
|
3884
|
-
|
|
3885
|
-
"3xl": `var(--${prefix}-typography-fontSize-3xl)`
|
|
3893
|
+
xs: `var(--${prefix}-typography-fontSize-xs)`
|
|
3886
3894
|
},
|
|
3887
3895
|
fontWeights: {
|
|
3888
|
-
|
|
3896
|
+
bold: `var(--${prefix}-typography-fontWeight-bold)`,
|
|
3889
3897
|
medium: `var(--${prefix}-typography-fontWeight-medium)`,
|
|
3890
|
-
|
|
3891
|
-
|
|
3898
|
+
normal: `var(--${prefix}-typography-fontWeight-normal)`,
|
|
3899
|
+
semibold: `var(--${prefix}-typography-fontWeight-semibold)`
|
|
3892
3900
|
},
|
|
3893
3901
|
lineHeights: {
|
|
3894
|
-
tight: `var(--${prefix}-typography-lineHeight-tight)`,
|
|
3895
3902
|
normal: `var(--${prefix}-typography-lineHeight-normal)`,
|
|
3896
|
-
relaxed: `var(--${prefix}-typography-lineHeight-relaxed)
|
|
3903
|
+
relaxed: `var(--${prefix}-typography-lineHeight-relaxed)`,
|
|
3904
|
+
tight: `var(--${prefix}-typography-lineHeight-tight)`
|
|
3897
3905
|
}
|
|
3898
3906
|
}
|
|
3899
3907
|
};
|
|
@@ -3902,9 +3910,9 @@ var toThemeVars = (theme) => {
|
|
|
3902
3910
|
Object.keys(theme.images).forEach((imageKey) => {
|
|
3903
3911
|
const imageConfig = theme.images[imageKey];
|
|
3904
3912
|
themeVars.images[imageKey] = {
|
|
3905
|
-
|
|
3913
|
+
alt: imageConfig?.alt ? `var(--${prefix}-image-${imageKey}-alt)` : void 0,
|
|
3906
3914
|
title: imageConfig?.title ? `var(--${prefix}-image-${imageKey}-title)` : void 0,
|
|
3907
|
-
|
|
3915
|
+
url: imageConfig?.url ? `var(--${prefix}-image-${imageKey}-url)` : void 0
|
|
3908
3916
|
};
|
|
3909
3917
|
});
|
|
3910
3918
|
}
|
|
@@ -3918,6 +3926,10 @@ var createTheme = (config = {}, isDark = false) => {
|
|
|
3918
3926
|
const mergedConfig = {
|
|
3919
3927
|
...baseTheme,
|
|
3920
3928
|
...config,
|
|
3929
|
+
borderRadius: {
|
|
3930
|
+
...baseTheme.borderRadius,
|
|
3931
|
+
...config.borderRadius
|
|
3932
|
+
},
|
|
3921
3933
|
colors: {
|
|
3922
3934
|
...baseTheme.colors,
|
|
3923
3935
|
...config.colors,
|
|
@@ -3930,18 +3942,18 @@ var createTheme = (config = {}, isDark = false) => {
|
|
|
3930
3942
|
...config.colors?.secondary || {}
|
|
3931
3943
|
}
|
|
3932
3944
|
},
|
|
3933
|
-
|
|
3934
|
-
...baseTheme.
|
|
3935
|
-
...config.
|
|
3936
|
-
},
|
|
3937
|
-
borderRadius: {
|
|
3938
|
-
...baseTheme.borderRadius,
|
|
3939
|
-
...config.borderRadius
|
|
3945
|
+
images: {
|
|
3946
|
+
...baseTheme.images,
|
|
3947
|
+
...config.images
|
|
3940
3948
|
},
|
|
3941
3949
|
shadows: {
|
|
3942
3950
|
...baseTheme.shadows,
|
|
3943
3951
|
...config.shadows
|
|
3944
3952
|
},
|
|
3953
|
+
spacing: {
|
|
3954
|
+
...baseTheme.spacing,
|
|
3955
|
+
...config.spacing
|
|
3956
|
+
},
|
|
3945
3957
|
typography: {
|
|
3946
3958
|
...baseTheme.typography,
|
|
3947
3959
|
...config.typography,
|
|
@@ -3957,10 +3969,6 @@ var createTheme = (config = {}, isDark = false) => {
|
|
|
3957
3969
|
...baseTheme.typography.lineHeights,
|
|
3958
3970
|
...config.typography?.lineHeights || {}
|
|
3959
3971
|
}
|
|
3960
|
-
},
|
|
3961
|
-
images: {
|
|
3962
|
-
...baseTheme.images,
|
|
3963
|
-
...config.images
|
|
3964
3972
|
}
|
|
3965
3973
|
};
|
|
3966
3974
|
return {
|
|
@@ -3976,7 +3984,7 @@ var createTheme_default = createTheme;
|
|
|
3976
3984
|
var arrayBufferToBase64url = (buffer) => {
|
|
3977
3985
|
const bytes = new Uint8Array(buffer);
|
|
3978
3986
|
let binary = "";
|
|
3979
|
-
for (let i = 0; i < bytes.byteLength; i
|
|
3987
|
+
for (let i = 0; i < bytes.byteLength; i += 1) {
|
|
3980
3988
|
binary += String.fromCharCode(bytes[i]);
|
|
3981
3989
|
}
|
|
3982
3990
|
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
@@ -3989,7 +3997,7 @@ var base64urlToArrayBuffer = (base64url) => {
|
|
|
3989
3997
|
const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/") + padding;
|
|
3990
3998
|
const binaryString = atob(base64);
|
|
3991
3999
|
const bytes = new Uint8Array(binaryString.length);
|
|
3992
|
-
for (let i = 0; i < binaryString.length; i
|
|
4000
|
+
for (let i = 0; i < binaryString.length; i += 1) {
|
|
3993
4001
|
bytes[i] = binaryString.charCodeAt(i);
|
|
3994
4002
|
}
|
|
3995
4003
|
return bytes.buffer;
|
|
@@ -4014,9 +4022,9 @@ var formatDate = (dateString) => {
|
|
|
4014
4022
|
if (!dateString) return "-";
|
|
4015
4023
|
try {
|
|
4016
4024
|
return new Date(dateString).toLocaleDateString("en-US", {
|
|
4017
|
-
|
|
4025
|
+
day: "numeric",
|
|
4018
4026
|
month: "long",
|
|
4019
|
-
|
|
4027
|
+
year: "numeric"
|
|
4020
4028
|
});
|
|
4021
4029
|
} catch {
|
|
4022
4030
|
return dateString;
|
|
@@ -4025,9 +4033,7 @@ var formatDate = (dateString) => {
|
|
|
4025
4033
|
var formatDate_default = formatDate;
|
|
4026
4034
|
|
|
4027
4035
|
// 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
|
-
};
|
|
4036
|
+
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
4037
|
var deepMerge = (target, ...sources) => {
|
|
4032
4038
|
if (!target || typeof target !== "object") {
|
|
4033
4039
|
throw new Error("Target must be an object");
|
|
@@ -4051,95 +4057,48 @@ var deepMerge = (target, ...sources) => {
|
|
|
4051
4057
|
};
|
|
4052
4058
|
var deepMerge_default = deepMerge;
|
|
4053
4059
|
|
|
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
4060
|
// src/utils/logger.ts
|
|
4104
4061
|
var PREFIX = "\u{1F6E1}\uFE0F Asgardeo";
|
|
4105
4062
|
var DEFAULT_CONFIG = {
|
|
4106
4063
|
level: "info",
|
|
4107
4064
|
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;
|
|
4065
|
+
showLevel: true,
|
|
4066
|
+
timestamps: true
|
|
4116
4067
|
};
|
|
4068
|
+
var isBrowser = () => (
|
|
4069
|
+
/* @ts-ignore */
|
|
4070
|
+
typeof window !== "undefined" && typeof window.document !== "undefined"
|
|
4071
|
+
);
|
|
4072
|
+
var isNode = () => (
|
|
4073
|
+
/* @ts-ignore */
|
|
4074
|
+
typeof process !== "undefined" && process.versions && process.versions.node
|
|
4075
|
+
);
|
|
4117
4076
|
var COLORS = {
|
|
4118
|
-
|
|
4077
|
+
blue: "\x1B[34m",
|
|
4119
4078
|
bright: "\x1B[1m",
|
|
4079
|
+
cyan: "\x1B[36m",
|
|
4120
4080
|
dim: "\x1B[2m",
|
|
4121
|
-
|
|
4081
|
+
gray: "\x1B[90m",
|
|
4122
4082
|
green: "\x1B[32m",
|
|
4123
|
-
yellow: "\x1B[33m",
|
|
4124
|
-
blue: "\x1B[34m",
|
|
4125
4083
|
magenta: "\x1B[35m",
|
|
4126
|
-
|
|
4084
|
+
red: "\x1B[31m",
|
|
4085
|
+
reset: "\x1B[0m",
|
|
4127
4086
|
white: "\x1B[37m",
|
|
4128
|
-
|
|
4087
|
+
yellow: "\x1B[33m"
|
|
4129
4088
|
};
|
|
4130
4089
|
var BROWSER_STYLES = {
|
|
4131
4090
|
debug: "color: #6b7280; font-weight: normal;",
|
|
4132
|
-
info: "color: #2563eb; font-weight: bold;",
|
|
4133
|
-
warn: "color: #d97706; font-weight: bold;",
|
|
4134
4091
|
error: "color: #dc2626; font-weight: bold;",
|
|
4092
|
+
info: "color: #2563eb; font-weight: bold;",
|
|
4135
4093
|
prefix: "color: #7c3aed; font-weight: bold;",
|
|
4136
|
-
timestamp: "color: #6b7280; font-size: 0.9em;"
|
|
4094
|
+
timestamp: "color: #6b7280; font-size: 0.9em;",
|
|
4095
|
+
warn: "color: #d97706; font-weight: bold;"
|
|
4137
4096
|
};
|
|
4138
4097
|
var LOG_LEVEL_ORDER = {
|
|
4139
4098
|
debug: 0,
|
|
4099
|
+
error: 3,
|
|
4140
4100
|
info: 1,
|
|
4141
|
-
warn: 2
|
|
4142
|
-
error: 3
|
|
4101
|
+
warn: 2
|
|
4143
4102
|
};
|
|
4144
4103
|
var Logger = class _Logger {
|
|
4145
4104
|
constructor(config = {}) {
|
|
@@ -4167,13 +4126,13 @@ var Logger = class _Logger {
|
|
|
4167
4126
|
/**
|
|
4168
4127
|
* Get timestamp string
|
|
4169
4128
|
*/
|
|
4170
|
-
getTimestamp() {
|
|
4129
|
+
static getTimestamp() {
|
|
4171
4130
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
4172
4131
|
}
|
|
4173
4132
|
/**
|
|
4174
4133
|
* Get log level string
|
|
4175
4134
|
*/
|
|
4176
|
-
getLevelString(level) {
|
|
4135
|
+
static getLevelString(level) {
|
|
4177
4136
|
switch (level) {
|
|
4178
4137
|
case "debug":
|
|
4179
4138
|
return "DEBUG";
|
|
@@ -4193,13 +4152,13 @@ var Logger = class _Logger {
|
|
|
4193
4152
|
formatForNode(level, message) {
|
|
4194
4153
|
const parts = [];
|
|
4195
4154
|
if (this.config.timestamps) {
|
|
4196
|
-
parts.push(`${COLORS.gray}[${
|
|
4155
|
+
parts.push(`${COLORS.gray}[${_Logger.getTimestamp()}]${COLORS.reset}`);
|
|
4197
4156
|
}
|
|
4198
4157
|
if (this.config.prefix) {
|
|
4199
4158
|
parts.push(`${COLORS.magenta}${this.config.prefix}${COLORS.reset}`);
|
|
4200
4159
|
}
|
|
4201
4160
|
if (this.config.showLevel) {
|
|
4202
|
-
const levelStr =
|
|
4161
|
+
const levelStr = _Logger.getLevelString(level);
|
|
4203
4162
|
let coloredLevel;
|
|
4204
4163
|
switch (level) {
|
|
4205
4164
|
case "debug":
|
|
@@ -4248,7 +4207,7 @@ var Logger = class _Logger {
|
|
|
4248
4207
|
const parts = [];
|
|
4249
4208
|
const styles = [];
|
|
4250
4209
|
if (this.config.timestamps) {
|
|
4251
|
-
parts.push(`%c[${
|
|
4210
|
+
parts.push(`%c[${_Logger.getTimestamp()}]`);
|
|
4252
4211
|
styles.push(BROWSER_STYLES.timestamp);
|
|
4253
4212
|
}
|
|
4254
4213
|
if (this.config.prefix) {
|
|
@@ -4256,7 +4215,7 @@ var Logger = class _Logger {
|
|
|
4256
4215
|
styles.push(BROWSER_STYLES.prefix);
|
|
4257
4216
|
}
|
|
4258
4217
|
if (this.config.showLevel) {
|
|
4259
|
-
const levelStr =
|
|
4218
|
+
const levelStr = _Logger.getLevelString(level);
|
|
4260
4219
|
parts.push(`%c[${levelStr}]`);
|
|
4261
4220
|
switch (level) {
|
|
4262
4221
|
case "debug":
|
|
@@ -4365,31 +4324,74 @@ var Logger = class _Logger {
|
|
|
4365
4324
|
}
|
|
4366
4325
|
};
|
|
4367
4326
|
var logger = new Logger();
|
|
4368
|
-
var createLogger = (config) =>
|
|
4369
|
-
return new Logger(config);
|
|
4370
|
-
};
|
|
4327
|
+
var createLogger = (config) => new Logger(config);
|
|
4371
4328
|
var logger_default = logger;
|
|
4372
4329
|
var debug = (message, ...args) => logger.debug(message, ...args);
|
|
4373
4330
|
var info = (message, ...args) => logger.info(message, ...args);
|
|
4374
4331
|
var warn = (message, ...args) => logger.warn(message, ...args);
|
|
4375
4332
|
var error = (message, ...args) => logger.error(message, ...args);
|
|
4376
4333
|
var configure = (config) => logger.configure(config);
|
|
4377
|
-
var createComponentLogger = (component) =>
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
timestamps: true,
|
|
4385
|
-
showLevel: true
|
|
4386
|
-
});
|
|
4387
|
-
};
|
|
4334
|
+
var createComponentLogger = (component) => logger.child(component);
|
|
4335
|
+
var createPackageLogger = (packageName) => createLogger({
|
|
4336
|
+
level: "info",
|
|
4337
|
+
prefix: `${PREFIX} - ${packageName}`,
|
|
4338
|
+
showLevel: true,
|
|
4339
|
+
timestamps: true
|
|
4340
|
+
});
|
|
4388
4341
|
var createPackageComponentLogger = (packageName, component) => {
|
|
4389
4342
|
const packageLogger = createPackageLogger(packageName);
|
|
4390
4343
|
return packageLogger.child(component);
|
|
4391
4344
|
};
|
|
4392
4345
|
|
|
4346
|
+
// src/utils/deriveOrganizationHandleFromBaseUrl.ts
|
|
4347
|
+
var deriveOrganizationHandleFromBaseUrl = (baseUrl) => {
|
|
4348
|
+
if (!baseUrl) {
|
|
4349
|
+
throw new AsgardeoRuntimeError(
|
|
4350
|
+
"Base URL is required to derive organization handle.",
|
|
4351
|
+
"javascript-deriveOrganizationHandleFromBaseUrl-ValidationError-001",
|
|
4352
|
+
"javascript",
|
|
4353
|
+
"A valid base URL must be provided to extract the organization handle."
|
|
4354
|
+
);
|
|
4355
|
+
}
|
|
4356
|
+
let parsedUrl;
|
|
4357
|
+
try {
|
|
4358
|
+
parsedUrl = new URL(baseUrl);
|
|
4359
|
+
} catch (error2) {
|
|
4360
|
+
throw new AsgardeoRuntimeError(
|
|
4361
|
+
`Invalid base URL format: ${baseUrl}`,
|
|
4362
|
+
"javascript-deriveOrganizationHandleFromBaseUrl-ValidationError-002",
|
|
4363
|
+
"javascript",
|
|
4364
|
+
"The provided base URL does not conform to valid URL syntax."
|
|
4365
|
+
);
|
|
4366
|
+
}
|
|
4367
|
+
const pathSegments = parsedUrl.pathname?.split("/")?.filter((segment) => segment?.length > 0);
|
|
4368
|
+
if (pathSegments.length < 2 || pathSegments[0] !== "t") {
|
|
4369
|
+
logger_default.warn(
|
|
4370
|
+
new AsgardeoRuntimeError(
|
|
4371
|
+
"Organization handle is required since a custom domain is configured.",
|
|
4372
|
+
"javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-002",
|
|
4373
|
+
"javascript",
|
|
4374
|
+
"The provided base URL does not follow the expected URL pattern (/t/{orgHandle}). Please provide the organizationHandle explicitly in the configuration."
|
|
4375
|
+
).toString()
|
|
4376
|
+
);
|
|
4377
|
+
return "";
|
|
4378
|
+
}
|
|
4379
|
+
const organizationHandle = pathSegments[1];
|
|
4380
|
+
if (!organizationHandle || organizationHandle.trim().length === 0) {
|
|
4381
|
+
logger_default.warn(
|
|
4382
|
+
new AsgardeoRuntimeError(
|
|
4383
|
+
"Organization handle is required since a custom domain is configured.",
|
|
4384
|
+
"javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-003",
|
|
4385
|
+
"javascript",
|
|
4386
|
+
"The organization handle could not be extracted from the base URL. Please provide the organizationHandle explicitly in the configuration."
|
|
4387
|
+
).toString()
|
|
4388
|
+
);
|
|
4389
|
+
return "";
|
|
4390
|
+
}
|
|
4391
|
+
return organizationHandle;
|
|
4392
|
+
};
|
|
4393
|
+
var deriveOrganizationHandleFromBaseUrl_default = deriveOrganizationHandleFromBaseUrl;
|
|
4394
|
+
|
|
4393
4395
|
// src/utils/isRecognizedBaseUrlPattern.ts
|
|
4394
4396
|
var isRecognizedBaseUrlPattern = (baseUrl) => {
|
|
4395
4397
|
if (!baseUrl) {
|
|
@@ -4413,7 +4415,9 @@ var isRecognizedBaseUrlPattern = (baseUrl) => {
|
|
|
4413
4415
|
}
|
|
4414
4416
|
const pathSegments = parsedUrl.pathname?.split("/")?.filter((segment) => segment?.length > 0);
|
|
4415
4417
|
if (pathSegments.length < 2 || pathSegments[0] !== "t") {
|
|
4416
|
-
logger_default.warn(
|
|
4418
|
+
logger_default.warn(
|
|
4419
|
+
"[isRecognizedBaseUrlPattern] The provided base URL does not follow the expected URL pattern (/t/{orgHandle})."
|
|
4420
|
+
);
|
|
4417
4421
|
return false;
|
|
4418
4422
|
}
|
|
4419
4423
|
return true;
|
|
@@ -4451,9 +4455,7 @@ var flattenUserSchema_default = flattenUserSchema;
|
|
|
4451
4455
|
var get = (object, path, defaultValue) => {
|
|
4452
4456
|
if (!object || !path) return defaultValue;
|
|
4453
4457
|
const pathArray = Array.isArray(path) ? path : path.split(".");
|
|
4454
|
-
const result = pathArray.reduce((current, key) =>
|
|
4455
|
-
return current?.[key];
|
|
4456
|
-
}, object);
|
|
4458
|
+
const result = pathArray.reduce((current, key) => current?.[key], object);
|
|
4457
4459
|
return result !== void 0 ? result : defaultValue;
|
|
4458
4460
|
};
|
|
4459
4461
|
var get_default = get;
|
|
@@ -4466,11 +4468,9 @@ var set = (object, path, value) => {
|
|
|
4466
4468
|
pathArray.reduce((current, key, index) => {
|
|
4467
4469
|
if (index === lastIndex) {
|
|
4468
4470
|
current[key] = value;
|
|
4469
|
-
} else {
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
current[key] = /^\d+$/.test(nextKey) ? [] : {};
|
|
4473
|
-
}
|
|
4471
|
+
} else if (!(key in current) || typeof current[key] !== "object" || current[key] === null) {
|
|
4472
|
+
const nextKey = pathArray[index + 1];
|
|
4473
|
+
current[key] = /^\d+$/.test(nextKey) ? [] : {};
|
|
4474
4474
|
}
|
|
4475
4475
|
return current[key];
|
|
4476
4476
|
}, object);
|
|
@@ -4489,14 +4489,12 @@ var generateUserProfile = (meResponse, processedSchemas) => {
|
|
|
4489
4489
|
if (multiValued && !Array.isArray(value)) {
|
|
4490
4490
|
value = [value];
|
|
4491
4491
|
}
|
|
4492
|
+
} else if (multiValued) {
|
|
4493
|
+
value = void 0;
|
|
4494
|
+
} else if (type === "STRING") {
|
|
4495
|
+
value = "";
|
|
4492
4496
|
} else {
|
|
4493
|
-
|
|
4494
|
-
value = void 0;
|
|
4495
|
-
} else if (type === "STRING") {
|
|
4496
|
-
value = "";
|
|
4497
|
-
} else {
|
|
4498
|
-
value = void 0;
|
|
4499
|
-
}
|
|
4497
|
+
value = void 0;
|
|
4500
4498
|
}
|
|
4501
4499
|
set_default(profile, name, value);
|
|
4502
4500
|
});
|
|
@@ -4640,7 +4638,7 @@ var getRedirectBasedSignUpUrl = (config) => {
|
|
|
4640
4638
|
);
|
|
4641
4639
|
}
|
|
4642
4640
|
}
|
|
4643
|
-
const url = new URL(signUpBaseUrl
|
|
4641
|
+
const url = new URL(`${signUpBaseUrl}/accountrecoveryendpoint/register.do`);
|
|
4644
4642
|
if (config.clientId) {
|
|
4645
4643
|
url.searchParams.set("client_id", config.clientId);
|
|
4646
4644
|
}
|
|
@@ -4661,13 +4659,14 @@ var resolveFieldType = (field) => {
|
|
|
4661
4659
|
if (field.type === "STRING" /* String */) {
|
|
4662
4660
|
if (field.param === "OTPCode" /* Otp */) {
|
|
4663
4661
|
return "OTP" /* Otp */;
|
|
4664
|
-
}
|
|
4662
|
+
}
|
|
4663
|
+
if (field?.confidential) {
|
|
4665
4664
|
return "PASSWORD" /* Password */;
|
|
4666
4665
|
}
|
|
4667
4666
|
return "TEXT" /* Text */;
|
|
4668
4667
|
}
|
|
4669
4668
|
throw new AsgardeoRuntimeError(
|
|
4670
|
-
|
|
4669
|
+
`Field type is not supported: ${field.type}`,
|
|
4671
4670
|
"resolveFieldType-Invalid-001",
|
|
4672
4671
|
"javascript",
|
|
4673
4672
|
"The provided field type is not supported. Please check the field configuration."
|
|
@@ -4700,85 +4699,83 @@ var extractColorValue = (colorVariant, preferDark = false) => {
|
|
|
4700
4699
|
}
|
|
4701
4700
|
return colorVariant?.main;
|
|
4702
4701
|
};
|
|
4703
|
-
var extractContrastText = (colorVariant) =>
|
|
4704
|
-
return colorVariant?.contrastText;
|
|
4705
|
-
};
|
|
4702
|
+
var extractContrastText = (colorVariant) => colorVariant?.contrastText;
|
|
4706
4703
|
var transformThemeVariant = (themeVariant, isDark = false) => {
|
|
4707
|
-
const
|
|
4708
|
-
const
|
|
4709
|
-
const
|
|
4710
|
-
const
|
|
4704
|
+
const { buttons } = themeVariant;
|
|
4705
|
+
const { colors } = themeVariant;
|
|
4706
|
+
const { images } = themeVariant;
|
|
4707
|
+
const { inputs } = themeVariant;
|
|
4711
4708
|
const config = {
|
|
4712
4709
|
colors: {
|
|
4713
4710
|
action: {
|
|
4711
|
+
activatedOpacity: 0.12,
|
|
4714
4712
|
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
4713
|
disabled: isDark ? "rgba(255, 255, 255, 0.26)" : "rgba(0, 0, 0, 0.26)",
|
|
4720
4714
|
disabledBackground: isDark ? "rgba(255, 255, 255, 0.12)" : "rgba(0, 0, 0, 0.12)",
|
|
4721
4715
|
disabledOpacity: 0.38,
|
|
4722
4716
|
focus: isDark ? "rgba(255, 255, 255, 0.12)" : "rgba(0, 0, 0, 0.12)",
|
|
4723
4717
|
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
|
|
4718
|
+
hover: isDark ? "rgba(255, 255, 255, 0.04)" : "rgba(0, 0, 0, 0.04)",
|
|
4719
|
+
hoverOpacity: 0.04,
|
|
4720
|
+
selected: isDark ? "rgba(255, 255, 255, 0.08)" : "rgba(0, 0, 0, 0.08)",
|
|
4721
|
+
selectedOpacity: 0.08
|
|
4735
4722
|
},
|
|
4736
4723
|
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
4724
|
body: {
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
}
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
secondary: colors?.text?.secondary,
|
|
4748
|
-
dark: colors?.text?.dark || colors?.text?.primary
|
|
4725
|
+
dark: colors?.background?.body?.dark || colors?.background?.body?.main,
|
|
4726
|
+
main: extractColorValue(colors?.background?.body, isDark)
|
|
4727
|
+
},
|
|
4728
|
+
dark: colors?.background?.surface?.dark || colors?.background?.surface?.main,
|
|
4729
|
+
disabled: extractColorValue(colors?.background?.surface, isDark),
|
|
4730
|
+
surface: extractColorValue(colors?.background?.surface, isDark)
|
|
4749
4731
|
},
|
|
4750
4732
|
border: colors?.outlined?.default,
|
|
4751
4733
|
error: {
|
|
4752
|
-
main: extractColorValue(colors?.alerts?.error, isDark),
|
|
4753
4734
|
contrastText: extractContrastText(colors?.alerts?.error),
|
|
4754
|
-
dark: colors?.alerts?.error?.dark || colors?.alerts?.error?.main
|
|
4735
|
+
dark: colors?.alerts?.error?.dark || colors?.alerts?.error?.main,
|
|
4736
|
+
main: extractColorValue(colors?.alerts?.error, isDark)
|
|
4755
4737
|
},
|
|
4756
4738
|
info: {
|
|
4757
|
-
main: extractColorValue(colors?.alerts?.info, isDark),
|
|
4758
4739
|
contrastText: extractContrastText(colors?.alerts?.info),
|
|
4759
|
-
dark: colors?.alerts?.info?.dark || colors?.alerts?.info?.main
|
|
4740
|
+
dark: colors?.alerts?.info?.dark || colors?.alerts?.info?.main,
|
|
4741
|
+
main: extractColorValue(colors?.alerts?.info, isDark)
|
|
4742
|
+
},
|
|
4743
|
+
primary: {
|
|
4744
|
+
contrastText: extractContrastText(colors?.primary),
|
|
4745
|
+
dark: colors?.primary?.dark || colors?.primary?.main,
|
|
4746
|
+
main: extractColorValue(colors?.primary, isDark)
|
|
4747
|
+
},
|
|
4748
|
+
secondary: {
|
|
4749
|
+
contrastText: extractContrastText(colors?.secondary),
|
|
4750
|
+
dark: colors?.secondary?.dark || colors?.secondary?.main,
|
|
4751
|
+
main: extractColorValue(colors?.secondary, isDark)
|
|
4760
4752
|
},
|
|
4761
4753
|
success: {
|
|
4762
|
-
main: extractColorValue(colors?.alerts?.neutral, isDark),
|
|
4763
4754
|
contrastText: extractContrastText(colors?.alerts?.neutral),
|
|
4764
|
-
dark: colors?.alerts?.neutral?.dark || colors?.alerts?.neutral?.main
|
|
4755
|
+
dark: colors?.alerts?.neutral?.dark || colors?.alerts?.neutral?.main,
|
|
4756
|
+
main: extractColorValue(colors?.alerts?.neutral, isDark)
|
|
4757
|
+
},
|
|
4758
|
+
text: {
|
|
4759
|
+
dark: colors?.text?.dark || colors?.text?.primary,
|
|
4760
|
+
primary: colors?.text?.primary,
|
|
4761
|
+
secondary: colors?.text?.secondary
|
|
4765
4762
|
},
|
|
4766
4763
|
warning: {
|
|
4767
|
-
main: extractColorValue(colors?.alerts?.warning, isDark),
|
|
4768
4764
|
contrastText: extractContrastText(colors?.alerts?.warning),
|
|
4769
|
-
dark: colors?.alerts?.warning?.dark || colors?.alerts?.warning?.main
|
|
4765
|
+
dark: colors?.alerts?.warning?.dark || colors?.alerts?.warning?.main,
|
|
4766
|
+
main: extractColorValue(colors?.alerts?.warning, isDark)
|
|
4770
4767
|
}
|
|
4771
4768
|
},
|
|
4772
4769
|
images: {
|
|
4773
4770
|
favicon: images?.favicon ? {
|
|
4774
|
-
|
|
4771
|
+
alt: images.favicon.altText,
|
|
4775
4772
|
title: images.favicon.title,
|
|
4776
|
-
|
|
4773
|
+
url: images.favicon.imgURL
|
|
4777
4774
|
} : void 0,
|
|
4778
4775
|
logo: images?.logo ? {
|
|
4779
|
-
|
|
4776
|
+
alt: images.logo.altText,
|
|
4780
4777
|
title: images.logo.title,
|
|
4781
|
-
|
|
4778
|
+
url: images.logo.imgURL
|
|
4782
4779
|
} : void 0
|
|
4783
4780
|
}
|
|
4784
4781
|
};
|