@asgardeo/javascript 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/AsgardeoJavaScriptClient.d.ts +17 -50
- package/dist/IsomorphicCrypto.d.ts +4 -4
- package/dist/{__legacy__/data/data-layer.d.ts → StorageManager.d.ts} +27 -26
- package/dist/__legacy__/client.d.ts +82 -98
- package/dist/__legacy__/helpers/authentication-helper.d.ts +9 -9
- package/dist/__legacy__/models/client-config.d.ts +6 -6
- package/dist/__legacy__/models/index.d.ts +0 -5
- package/dist/api/createOrganization.d.ts +129 -0
- package/dist/api/executeEmbeddedSignInFlow.d.ts +21 -0
- package/dist/api/executeEmbeddedSignUpFlow.d.ts +44 -0
- package/dist/api/getAllOrganizations.d.ts +112 -0
- package/dist/api/getMeOrganizations.d.ts +119 -0
- package/dist/api/getOrganization.d.ts +109 -0
- package/dist/api/getSchemas.d.ts +89 -0
- package/dist/api/getScim2Me.d.ts +89 -0
- package/dist/api/{oidc/getUserInfo.d.ts → getUserInfo.d.ts} +1 -1
- package/dist/api/initializeEmbeddedSignInFlow.d.ts +51 -0
- package/dist/api/updateMeProfile.d.ts +82 -0
- package/dist/api/updateOrganization.d.ts +118 -0
- package/dist/cjs/index.js +2437 -1224
- package/dist/cjs/index.js.map +4 -4
- package/dist/constants/ApplicationNativeAuthenticationConstants.d.ts +39 -0
- package/dist/constants/OIDCRequestConstants.d.ts +14 -0
- package/dist/constants/PKCEConstants.d.ts +1 -0
- package/dist/constants/ScopeConstants.d.ts +3 -6
- package/dist/constants/TokenExchangeConstants.d.ts +3 -3
- package/dist/constants/VendorConstants.d.ts +31 -0
- package/dist/{__legacy__/exception → errors}/exception.d.ts +3 -0
- package/dist/{__legacy__/data/index.d.ts → i18n/en-US.d.ts} +4 -2
- package/dist/{__legacy__/exception → i18n}/index.d.ts +2 -2
- package/dist/index.d.ts +44 -11
- package/dist/index.js +2399 -1219
- package/dist/index.js.map +4 -4
- package/dist/models/client.d.ts +60 -5
- package/dist/models/config.d.ts +51 -2
- package/dist/models/crypto.d.ts +2 -2
- package/dist/models/embedded-flow.d.ts +66 -0
- package/dist/models/embedded-signin-flow.d.ts +99 -0
- package/dist/{__legacy__/models/custom-grant.d.ts → models/field.d.ts} +13 -9
- package/dist/models/flow.d.ts +30 -0
- package/dist/models/i18n.d.ts +90 -0
- package/dist/{__legacy__/models/authorization-url.d.ts → models/oauth-request.d.ts} +3 -3
- package/dist/models/oauth-response.d.ts +1 -17
- package/dist/models/organization.d.ts +24 -0
- package/dist/models/scim2-schema.d.ts +3 -0
- package/dist/{__legacy__/models/data.d.ts → models/session.d.ts} +4 -0
- package/dist/models/store.d.ts +1 -1
- package/dist/models/token.d.ts +79 -20
- package/dist/models/user.d.ts +11 -84
- package/dist/theme/createTheme.d.ts +1 -1
- package/dist/theme/types.d.ts +29 -17
- package/dist/utils/deepMerge.d.ts +44 -0
- package/dist/utils/extractTenantDomainFromIdTokenPayload.d.ts +2 -2
- package/dist/utils/extractUserClaimsFromIdToken.d.ts +2 -2
- package/dist/utils/flattenUserSchema.d.ts +64 -0
- package/dist/utils/generateFlattenedUserProfile.d.ts +53 -0
- package/dist/utils/generateUserProfile.d.ts +55 -0
- package/dist/utils/get.d.ts +29 -0
- package/dist/utils/getAuthorizeRequestUrlParams.d.ts +59 -0
- package/dist/utils/getI18nBundles.d.ts +26 -0
- package/dist/utils/getLatestStateParam.d.ts +40 -0
- package/dist/utils/isEmpty.d.ts +48 -0
- package/dist/utils/processOpenIDScopes.d.ts +36 -0
- package/dist/{__legacy__/core/index.d.ts → utils/resolveFieldName.d.ts} +3 -2
- package/dist/utils/resolveFieldType.d.ts +20 -0
- package/dist/utils/set.d.ts +30 -0
- package/dist/utils/withVendorCSSClassPrefix.d.ts +32 -0
- package/package.json +4 -4
- package/dist/__legacy__/core/authentication-core.d.ts +0 -51
- package/dist/__legacy__/models/fetch.d.ts +0 -55
- package/dist/__legacy__/models/user.d.ts +0 -85
- package/dist/models/id-token.d.ts +0 -55
package/dist/index.js
CHANGED
|
@@ -1,112 +1,148 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
|
+
};
|
|
3
7
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
8
|
|
|
5
|
-
// src/
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
9
|
+
// src/StorageManager.ts
|
|
10
|
+
var ASGARDEO_SESSION_ACTIVE = "asgardeo-session-active";
|
|
11
|
+
var StorageManager = class {
|
|
12
|
+
constructor(instanceID, store) {
|
|
13
|
+
__publicField(this, "_id");
|
|
14
|
+
__publicField(this, "_store");
|
|
15
|
+
this._id = instanceID;
|
|
16
|
+
this._store = store;
|
|
17
|
+
}
|
|
18
|
+
async setDataInBulk(key, data) {
|
|
19
|
+
const existingDataJSON = await this._store.getData(key) ?? null;
|
|
20
|
+
const existingData = existingDataJSON && JSON.parse(existingDataJSON);
|
|
21
|
+
const dataToBeSaved = { ...existingData, ...data };
|
|
22
|
+
const dataToBeSavedJSON = JSON.stringify(dataToBeSaved);
|
|
23
|
+
await this._store.setData(key, dataToBeSavedJSON);
|
|
24
|
+
}
|
|
25
|
+
async setValue(key, attribute, value) {
|
|
26
|
+
const existingDataJSON = await this._store.getData(key) ?? null;
|
|
27
|
+
const existingData = existingDataJSON && JSON.parse(existingDataJSON);
|
|
28
|
+
const dataToBeSaved = { ...existingData, [attribute]: value };
|
|
29
|
+
const dataToBeSavedJSON = JSON.stringify(dataToBeSaved);
|
|
30
|
+
await this._store.setData(key, dataToBeSavedJSON);
|
|
31
|
+
}
|
|
32
|
+
async removeValue(key, attribute) {
|
|
33
|
+
const existingDataJSON = await this._store.getData(key) ?? null;
|
|
34
|
+
const existingData = existingDataJSON && JSON.parse(existingDataJSON);
|
|
35
|
+
const dataToBeSaved = { ...existingData };
|
|
36
|
+
delete dataToBeSaved[attribute];
|
|
37
|
+
const dataToBeSavedJSON = JSON.stringify(dataToBeSaved);
|
|
38
|
+
await this._store.setData(key, dataToBeSavedJSON);
|
|
39
|
+
}
|
|
40
|
+
_resolveKey(store, userId) {
|
|
41
|
+
return userId ? `${store}-${this._id}-${userId}` : `${store}-${this._id}`;
|
|
42
|
+
}
|
|
43
|
+
isLocalStorageAvailable() {
|
|
44
|
+
try {
|
|
45
|
+
const testValue = "__ASGARDEO_AUTH_CORE_LOCAL_STORAGE_TEST__";
|
|
46
|
+
localStorage.setItem(testValue, testValue);
|
|
47
|
+
localStorage.removeItem(testValue);
|
|
48
|
+
return true;
|
|
49
|
+
} catch (error) {
|
|
50
|
+
return false;
|
|
26
51
|
}
|
|
27
52
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
this.
|
|
54
|
-
|
|
53
|
+
async setConfigData(config) {
|
|
54
|
+
await this.setDataInBulk(this._resolveKey("config_data" /* ConfigData */), config);
|
|
55
|
+
}
|
|
56
|
+
async setOIDCProviderMetaData(oidcProviderMetaData) {
|
|
57
|
+
this.setDataInBulk(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), oidcProviderMetaData);
|
|
58
|
+
}
|
|
59
|
+
async setTemporaryData(temporaryData, userId) {
|
|
60
|
+
this.setDataInBulk(this._resolveKey("temporary_data" /* TemporaryData */, userId), temporaryData);
|
|
61
|
+
}
|
|
62
|
+
async setSessionData(sessionData, userId) {
|
|
63
|
+
this.setDataInBulk(this._resolveKey("session_data" /* SessionData */, userId), sessionData);
|
|
64
|
+
}
|
|
65
|
+
async setCustomData(key, customData, userId) {
|
|
66
|
+
this.setDataInBulk(this._resolveKey(key, userId), customData);
|
|
67
|
+
}
|
|
68
|
+
async getConfigData(userId) {
|
|
69
|
+
return JSON.parse(await this._store.getData(this._resolveKey("config_data" /* ConfigData */, userId)) ?? null);
|
|
70
|
+
}
|
|
71
|
+
async loadOpenIDProviderConfiguration() {
|
|
72
|
+
return JSON.parse(await this._store.getData(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */)) ?? null);
|
|
73
|
+
}
|
|
74
|
+
async getTemporaryData(userId) {
|
|
75
|
+
return JSON.parse(await this._store.getData(this._resolveKey("temporary_data" /* TemporaryData */, userId)) ?? null);
|
|
76
|
+
}
|
|
77
|
+
async getSessionData(userId) {
|
|
78
|
+
return JSON.parse(await this._store.getData(this._resolveKey("session_data" /* SessionData */, userId)) ?? null);
|
|
79
|
+
}
|
|
80
|
+
async getCustomData(key, userId) {
|
|
81
|
+
return JSON.parse(await this._store.getData(this._resolveKey(key, userId)) ?? null);
|
|
82
|
+
}
|
|
83
|
+
setSessionStatus(status) {
|
|
84
|
+
this.isLocalStorageAvailable() && localStorage.setItem(`${ASGARDEO_SESSION_ACTIVE}`, status);
|
|
85
|
+
}
|
|
86
|
+
getSessionStatus() {
|
|
87
|
+
return this.isLocalStorageAvailable() ? localStorage.getItem(`${ASGARDEO_SESSION_ACTIVE}`) ?? "" : "";
|
|
88
|
+
}
|
|
89
|
+
removeSessionStatus() {
|
|
90
|
+
this.isLocalStorageAvailable() && localStorage.removeItem(`${ASGARDEO_SESSION_ACTIVE}`);
|
|
91
|
+
}
|
|
92
|
+
async removeConfigData() {
|
|
93
|
+
await this._store.removeData(this._resolveKey("config_data" /* ConfigData */));
|
|
94
|
+
}
|
|
95
|
+
async removeOIDCProviderMetaData() {
|
|
96
|
+
await this._store.removeData(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */));
|
|
97
|
+
}
|
|
98
|
+
async removeTemporaryData(userId) {
|
|
99
|
+
await this._store.removeData(this._resolveKey("temporary_data" /* TemporaryData */, userId));
|
|
100
|
+
}
|
|
101
|
+
async removeSessionData(userId) {
|
|
102
|
+
await this._store.removeData(this._resolveKey("session_data" /* SessionData */, userId));
|
|
103
|
+
}
|
|
104
|
+
async getConfigDataParameter(key) {
|
|
105
|
+
const data = await this._store.getData(this._resolveKey("config_data" /* ConfigData */));
|
|
106
|
+
return data && JSON.parse(data)[key];
|
|
107
|
+
}
|
|
108
|
+
async getOIDCProviderMetaDataParameter(key) {
|
|
109
|
+
const data = await this._store.getData(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */));
|
|
110
|
+
return data && JSON.parse(data)[key];
|
|
111
|
+
}
|
|
112
|
+
async getTemporaryDataParameter(key, userId) {
|
|
113
|
+
const data = await this._store.getData(this._resolveKey("temporary_data" /* TemporaryData */, userId));
|
|
114
|
+
return data && JSON.parse(data)[key];
|
|
115
|
+
}
|
|
116
|
+
async getSessionDataParameter(key, userId) {
|
|
117
|
+
const data = await this._store.getData(this._resolveKey("session_data" /* SessionData */, userId));
|
|
118
|
+
return data && JSON.parse(data)[key];
|
|
119
|
+
}
|
|
120
|
+
async setConfigDataParameter(key, value) {
|
|
121
|
+
await this.setValue(this._resolveKey("config_data" /* ConfigData */), key, value);
|
|
122
|
+
}
|
|
123
|
+
async setOIDCProviderMetaDataParameter(key, value) {
|
|
124
|
+
await this.setValue(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), key, value);
|
|
125
|
+
}
|
|
126
|
+
async setTemporaryDataParameter(key, value, userId) {
|
|
127
|
+
await this.setValue(this._resolveKey("temporary_data" /* TemporaryData */, userId), key, value);
|
|
128
|
+
}
|
|
129
|
+
async setSessionDataParameter(key, value, userId) {
|
|
130
|
+
await this.setValue(this._resolveKey("session_data" /* SessionData */, userId), key, value);
|
|
131
|
+
}
|
|
132
|
+
async removeConfigDataParameter(key) {
|
|
133
|
+
await this.removeValue(this._resolveKey("config_data" /* ConfigData */), key);
|
|
134
|
+
}
|
|
135
|
+
async removeOIDCProviderMetaDataParameter(key) {
|
|
136
|
+
await this.removeValue(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), key);
|
|
137
|
+
}
|
|
138
|
+
async removeTemporaryDataParameter(key, userId) {
|
|
139
|
+
await this.removeValue(this._resolveKey("temporary_data" /* TemporaryData */, userId), key);
|
|
140
|
+
}
|
|
141
|
+
async removeSessionDataParameter(key, userId) {
|
|
142
|
+
await this.removeValue(this._resolveKey("session_data" /* SessionData */, userId), key);
|
|
55
143
|
}
|
|
56
144
|
};
|
|
57
|
-
|
|
58
|
-
// src/utils/extractTenantDomainFromIdTokenPayload.ts
|
|
59
|
-
var extractTenantDomainFromIdTokenPayload = (payload, subjectSeparator = "@") => {
|
|
60
|
-
const uid = payload.sub;
|
|
61
|
-
if (!uid) return "";
|
|
62
|
-
const tokens = uid.split(subjectSeparator);
|
|
63
|
-
return tokens.length > 2 ? tokens[tokens.length - 1] : "";
|
|
64
|
-
};
|
|
65
|
-
var extractTenantDomainFromIdTokenPayload_default = extractTenantDomainFromIdTokenPayload;
|
|
66
|
-
|
|
67
|
-
// src/utils/extractUserClaimsFromIdToken.ts
|
|
68
|
-
var extractUserClaimsFromIdToken = (payload) => {
|
|
69
|
-
const filteredPayload = { ...payload };
|
|
70
|
-
const protocolClaims = [
|
|
71
|
-
"iss",
|
|
72
|
-
"aud",
|
|
73
|
-
"exp",
|
|
74
|
-
"iat",
|
|
75
|
-
"acr",
|
|
76
|
-
"amr",
|
|
77
|
-
"azp",
|
|
78
|
-
"auth_time",
|
|
79
|
-
"nonce",
|
|
80
|
-
"c_hash",
|
|
81
|
-
"at_hash",
|
|
82
|
-
"nbf",
|
|
83
|
-
"isk",
|
|
84
|
-
"sid",
|
|
85
|
-
"jti",
|
|
86
|
-
"sub"
|
|
87
|
-
];
|
|
88
|
-
protocolClaims.forEach((claim) => {
|
|
89
|
-
delete filteredPayload[claim];
|
|
90
|
-
});
|
|
91
|
-
const userClaims = {};
|
|
92
|
-
Object.entries(filteredPayload).forEach(([key, value]) => {
|
|
93
|
-
const camelCasedKey = key.split("_").map((part, i) => i === 0 ? part : part[0].toUpperCase() + part.slice(1)).join("");
|
|
94
|
-
userClaims[camelCasedKey] = value;
|
|
95
|
-
});
|
|
96
|
-
return userClaims;
|
|
97
|
-
};
|
|
98
|
-
var extractUserClaimsFromIdToken_default = extractUserClaimsFromIdToken;
|
|
99
|
-
|
|
100
|
-
// src/constants/ScopeConstants.ts
|
|
101
|
-
var ScopeConstants = {
|
|
102
|
-
/**
|
|
103
|
-
* The base OpenID Connect scope.
|
|
104
|
-
* Required for all OpenID Connect flows. Indicates that the client
|
|
105
|
-
* is initiating an OpenID Connect authentication request.
|
|
106
|
-
*/
|
|
107
|
-
OPENID: "openid"
|
|
108
|
-
};
|
|
109
|
-
var ScopeConstants_default = ScopeConstants;
|
|
145
|
+
var StorageManager_default = StorageManager;
|
|
110
146
|
|
|
111
147
|
// src/constants/OIDCDiscoveryConstants.ts
|
|
112
148
|
var OIDCDiscoveryConstants = {
|
|
@@ -227,279 +263,65 @@ var OIDCDiscoveryConstants = {
|
|
|
227
263
|
};
|
|
228
264
|
var OIDCDiscoveryConstants_default = OIDCDiscoveryConstants;
|
|
229
265
|
|
|
230
|
-
// src/constants/
|
|
231
|
-
var
|
|
266
|
+
// src/constants/ScopeConstants.ts
|
|
267
|
+
var ScopeConstants = {
|
|
232
268
|
/**
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
269
|
+
* The scope for accessing the user's profile information from SCIM.
|
|
270
|
+
* This scope allows the client to retrieve basic user information such as
|
|
271
|
+
* name, email, profile picture, etc.
|
|
236
272
|
*/
|
|
237
|
-
|
|
273
|
+
INTERNAL_LOGIN: "internal_login",
|
|
274
|
+
/**
|
|
275
|
+
* The base OpenID Connect scope.
|
|
276
|
+
* Required for all OpenID Connect flows. Indicates that the client
|
|
277
|
+
* is initiating an OpenID Connect authentication request.
|
|
278
|
+
*/
|
|
279
|
+
OPENID: "openid",
|
|
280
|
+
/**
|
|
281
|
+
* The OpenID Connect profile scope.
|
|
282
|
+
* This scope allows the client to access the user's profile information.
|
|
283
|
+
* It includes details such as the user's name, email, and other profile attributes.
|
|
284
|
+
*/
|
|
285
|
+
PROFILE: "profile"
|
|
286
|
+
};
|
|
287
|
+
var ScopeConstants_default = ScopeConstants;
|
|
288
|
+
|
|
289
|
+
// src/constants/OIDCRequestConstants.ts
|
|
290
|
+
var OIDCRequestConstants = {
|
|
291
|
+
Params: {
|
|
238
292
|
/**
|
|
239
|
-
*
|
|
240
|
-
*
|
|
293
|
+
* The authorization code returned from the authorization endpoint.
|
|
294
|
+
* Used in the authorization code flow.
|
|
241
295
|
*/
|
|
242
|
-
|
|
296
|
+
AUTHORIZATION_CODE: "code",
|
|
243
297
|
/**
|
|
244
|
-
*
|
|
245
|
-
* Used when user identity needs to be included in the exchange.
|
|
298
|
+
* Session state parameter used for session management between the client and the OP.
|
|
246
299
|
*/
|
|
247
|
-
|
|
300
|
+
SESSION_STATE: "session_state",
|
|
248
301
|
/**
|
|
249
|
-
*
|
|
250
|
-
*
|
|
302
|
+
* State parameter used to maintain state between the request and the callback.
|
|
303
|
+
* Helps in preventing CSRF attacks.
|
|
251
304
|
*/
|
|
252
|
-
|
|
305
|
+
STATE: "state",
|
|
253
306
|
/**
|
|
254
|
-
*
|
|
255
|
-
*
|
|
307
|
+
* Indicates whether sign-out was successful during the end-session flow.
|
|
308
|
+
* May be returned by the OP after a logout request.
|
|
256
309
|
*/
|
|
257
|
-
|
|
310
|
+
SIGN_OUT_SUCCESS: "sign_out_success"
|
|
311
|
+
},
|
|
312
|
+
/**
|
|
313
|
+
* Constants related to the OpenID Connect (OIDC) sign-in flow.
|
|
314
|
+
*/
|
|
315
|
+
SignIn: {
|
|
258
316
|
/**
|
|
259
|
-
*
|
|
260
|
-
* Used for client authentication in confidential client flows.
|
|
317
|
+
* Constants related to the payload of the OIDC sign-in request.
|
|
261
318
|
*/
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
// src/__legacy__/helpers/authentication-helper.ts
|
|
268
|
-
var AuthenticationHelper = class {
|
|
269
|
-
constructor(dataLayer, cryptoHelper) {
|
|
270
|
-
__publicField(this, "_dataLayer");
|
|
271
|
-
__publicField(this, "_config");
|
|
272
|
-
__publicField(this, "_oidcProviderMetaData");
|
|
273
|
-
__publicField(this, "_cryptoHelper");
|
|
274
|
-
this._dataLayer = dataLayer;
|
|
275
|
-
this._config = async () => await this._dataLayer.getConfigData();
|
|
276
|
-
this._oidcProviderMetaData = async () => await this._dataLayer.getOIDCProviderMetaData();
|
|
277
|
-
this._cryptoHelper = cryptoHelper;
|
|
278
|
-
}
|
|
279
|
-
async resolveEndpoints(response) {
|
|
280
|
-
const oidcProviderMetaData = {};
|
|
281
|
-
const configData = await this._config();
|
|
282
|
-
configData.endpoints && Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
283
|
-
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
284
|
-
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
285
|
-
});
|
|
286
|
-
return { ...response, ...oidcProviderMetaData };
|
|
287
|
-
}
|
|
288
|
-
async resolveEndpointsExplicitly() {
|
|
289
|
-
const oidcProviderMetaData = {};
|
|
290
|
-
const configData = await this._config();
|
|
291
|
-
const requiredEndpoints = [
|
|
292
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.AUTHORIZATION,
|
|
293
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.END_SESSION,
|
|
294
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.JWKS,
|
|
295
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.SESSION_IFRAME,
|
|
296
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.REVOCATION,
|
|
297
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.TOKEN,
|
|
298
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.ISSUER,
|
|
299
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.USERINFO
|
|
300
|
-
];
|
|
301
|
-
const isRequiredEndpointsContains = configData.endpoints ? requiredEndpoints.every((reqEndpointName) => {
|
|
302
|
-
return configData.endpoints ? Object.keys(configData.endpoints).some((endpointName) => {
|
|
303
|
-
const snakeCasedName = endpointName.replace(
|
|
304
|
-
/[A-Z]/g,
|
|
305
|
-
(letter) => `_${letter.toLowerCase()}`
|
|
306
|
-
);
|
|
307
|
-
return snakeCasedName === reqEndpointName;
|
|
308
|
-
}) : false;
|
|
309
|
-
}) : false;
|
|
310
|
-
if (!isRequiredEndpointsContains) {
|
|
311
|
-
throw new AsgardeoAuthException(
|
|
312
|
-
"JS-AUTH_HELPER-REE-NF01",
|
|
313
|
-
"Required endpoints missing",
|
|
314
|
-
"Some or all of the required endpoints are missing in the object passed to the `endpoints` attribute of the`AuthConfig` object."
|
|
315
|
-
);
|
|
316
|
-
}
|
|
317
|
-
configData.endpoints && Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
318
|
-
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
319
|
-
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
320
|
-
});
|
|
321
|
-
return { ...oidcProviderMetaData };
|
|
322
|
-
}
|
|
323
|
-
async resolveEndpointsByBaseURL() {
|
|
324
|
-
const oidcProviderMetaData = {};
|
|
325
|
-
const configData = await this._config();
|
|
326
|
-
const baseUrl = configData.baseUrl;
|
|
327
|
-
if (!baseUrl) {
|
|
328
|
-
throw new AsgardeoAuthException(
|
|
329
|
-
"JS-AUTH_HELPER_REBO-NF01",
|
|
330
|
-
"Base URL not defined.",
|
|
331
|
-
"Base URL is not defined in AuthClient config."
|
|
332
|
-
);
|
|
333
|
-
}
|
|
334
|
-
configData.endpoints && Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
335
|
-
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
336
|
-
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
337
|
-
});
|
|
338
|
-
const defaultEndpoints = {
|
|
339
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.AUTHORIZATION]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.AUTHORIZATION}`,
|
|
340
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.END_SESSION]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.END_SESSION}`,
|
|
341
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.ISSUER]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.ISSUER}`,
|
|
342
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.JWKS]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.JWKS}`,
|
|
343
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.SESSION_IFRAME]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.SESSION_IFRAME}`,
|
|
344
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.REVOCATION]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.REVOCATION}`,
|
|
345
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.TOKEN]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.TOKEN}`,
|
|
346
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.USERINFO]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.USERINFO}`
|
|
347
|
-
};
|
|
348
|
-
return { ...defaultEndpoints, ...oidcProviderMetaData };
|
|
349
|
-
}
|
|
350
|
-
async validateIdToken(idToken) {
|
|
351
|
-
const jwksEndpoint = (await this._dataLayer.getOIDCProviderMetaData()).jwks_uri;
|
|
352
|
-
const configData = await this._config();
|
|
353
|
-
if (!jwksEndpoint || jwksEndpoint.trim().length === 0) {
|
|
354
|
-
throw new AsgardeoAuthException(
|
|
355
|
-
"JS_AUTH_HELPER-VIT-NF01",
|
|
356
|
-
"JWKS endpoint not found.",
|
|
357
|
-
"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."
|
|
358
|
-
);
|
|
359
|
-
}
|
|
360
|
-
let response;
|
|
361
|
-
try {
|
|
362
|
-
response = await fetch(jwksEndpoint, {
|
|
363
|
-
credentials: configData.sendCookiesInRequests ? "include" : "same-origin"
|
|
364
|
-
});
|
|
365
|
-
} catch (error) {
|
|
366
|
-
throw new AsgardeoAuthException(
|
|
367
|
-
"JS-AUTH_HELPER-VIT-NE02",
|
|
368
|
-
"Request to jwks endpoint failed.",
|
|
369
|
-
error ?? "The request sent to get the jwks from the server failed."
|
|
370
|
-
);
|
|
371
|
-
}
|
|
372
|
-
if (response.status !== 200 || !response.ok) {
|
|
373
|
-
throw new AsgardeoAuthException(
|
|
374
|
-
"JS-AUTH_HELPER-VIT-HE03",
|
|
375
|
-
`Invalid response status received for jwks request (${response.statusText}).`,
|
|
376
|
-
await response.json()
|
|
377
|
-
);
|
|
378
|
-
}
|
|
379
|
-
const issuer = (await this._oidcProviderMetaData()).issuer;
|
|
380
|
-
const { keys } = await response.json();
|
|
381
|
-
const jwk = await this._cryptoHelper.getJWKForTheIdToken(idToken.split(".")[0], keys);
|
|
382
|
-
return this._cryptoHelper.isValidIdToken(
|
|
383
|
-
idToken,
|
|
384
|
-
jwk,
|
|
385
|
-
(await this._config()).clientID,
|
|
386
|
-
issuer ?? "",
|
|
387
|
-
this._cryptoHelper.decodeIDToken(idToken).sub,
|
|
388
|
-
(await this._config()).clockTolerance,
|
|
389
|
-
(await this._config()).validateIDTokenIssuer ?? true
|
|
390
|
-
);
|
|
391
|
-
}
|
|
392
|
-
getAuthenticatedUserInfo(idToken) {
|
|
393
|
-
const payload = this._cryptoHelper.decodeIDToken(idToken);
|
|
394
|
-
const tenantDomain = extractTenantDomainFromIdTokenPayload_default(payload);
|
|
395
|
-
const username = payload?.["username"] ?? "";
|
|
396
|
-
const givenName = payload?.["given_name"] ?? "";
|
|
397
|
-
const familyName = payload?.["family_name"] ?? "";
|
|
398
|
-
const fullName = givenName && familyName ? `${givenName} ${familyName}` : givenName ? givenName : familyName ? familyName : "";
|
|
399
|
-
const displayName = payload.preferred_username ?? fullName;
|
|
400
|
-
return {
|
|
401
|
-
displayName,
|
|
402
|
-
tenantDomain,
|
|
403
|
-
username,
|
|
404
|
-
...extractUserClaimsFromIdToken_default(payload)
|
|
405
|
-
};
|
|
406
|
-
}
|
|
407
|
-
async replaceCustomGrantTemplateTags(text, userID) {
|
|
408
|
-
let scope = ScopeConstants_default.OPENID;
|
|
409
|
-
const configData = await this._config();
|
|
410
|
-
const sessionData = await this._dataLayer.getSessionData(userID);
|
|
411
|
-
if (configData.scope && configData.scope.length > 0) {
|
|
412
|
-
if (!configData.scope.includes(ScopeConstants_default.OPENID)) {
|
|
413
|
-
configData.scope.push(ScopeConstants_default.OPENID);
|
|
414
|
-
}
|
|
415
|
-
scope = configData.scope.join(" ");
|
|
416
|
-
}
|
|
417
|
-
return text.replace(TokenExchangeConstants_default.Placeholders.TOKEN, sessionData.access_token).replace(
|
|
418
|
-
TokenExchangeConstants_default.Placeholders.USERNAME,
|
|
419
|
-
this.getAuthenticatedUserInfo(sessionData.id_token).username
|
|
420
|
-
).replace(TokenExchangeConstants_default.Placeholders.SCOPE, scope).replace(TokenExchangeConstants_default.Placeholders.CLIENT_ID, configData.clientID).replace(TokenExchangeConstants_default.Placeholders.CLIENT_SECRET, configData.clientSecret ?? "");
|
|
421
|
-
}
|
|
422
|
-
async clearUserSessionData(userID) {
|
|
423
|
-
await this._dataLayer.removeTemporaryData(userID);
|
|
424
|
-
await this._dataLayer.removeSessionData(userID);
|
|
425
|
-
}
|
|
426
|
-
async handleTokenResponse(response, userID) {
|
|
427
|
-
if (response.status !== 200 || !response.ok) {
|
|
428
|
-
throw new AsgardeoAuthException(
|
|
429
|
-
"JS-AUTH_HELPER-HTR-NE01",
|
|
430
|
-
`Invalid response status received for token request (${response.statusText}).`,
|
|
431
|
-
await response.json()
|
|
432
|
-
);
|
|
433
|
-
}
|
|
434
|
-
const parsedResponse = await response.json();
|
|
435
|
-
parsedResponse.created_at = (/* @__PURE__ */ new Date()).getTime();
|
|
436
|
-
const shouldValidateIdToken = (await this._config()).validateIDToken;
|
|
437
|
-
if (shouldValidateIdToken) {
|
|
438
|
-
return this.validateIdToken(parsedResponse.id_token).then(async () => {
|
|
439
|
-
await this._dataLayer.setSessionData(parsedResponse, userID);
|
|
440
|
-
const tokenResponse = {
|
|
441
|
-
accessToken: parsedResponse.access_token,
|
|
442
|
-
createdAt: parsedResponse.created_at,
|
|
443
|
-
expiresIn: parsedResponse.expires_in,
|
|
444
|
-
idToken: parsedResponse.id_token,
|
|
445
|
-
refreshToken: parsedResponse.refresh_token,
|
|
446
|
-
scope: parsedResponse.scope,
|
|
447
|
-
tokenType: parsedResponse.token_type
|
|
448
|
-
};
|
|
449
|
-
return Promise.resolve(tokenResponse);
|
|
450
|
-
});
|
|
451
|
-
} else {
|
|
452
|
-
const tokenResponse = {
|
|
453
|
-
accessToken: parsedResponse.access_token,
|
|
454
|
-
createdAt: parsedResponse.created_at,
|
|
455
|
-
expiresIn: parsedResponse.expires_in,
|
|
456
|
-
idToken: parsedResponse.id_token,
|
|
457
|
-
refreshToken: parsedResponse.refresh_token,
|
|
458
|
-
scope: parsedResponse.scope,
|
|
459
|
-
tokenType: parsedResponse.token_type
|
|
460
|
-
};
|
|
461
|
-
await this._dataLayer.setSessionData(parsedResponse, userID);
|
|
462
|
-
return Promise.resolve(tokenResponse);
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
};
|
|
466
|
-
|
|
467
|
-
// src/utils/generatePkceStorageKey.ts
|
|
468
|
-
var generatePkceStorageKey = (tempStore) => {
|
|
469
|
-
const keys = [];
|
|
470
|
-
Object.keys(tempStore).forEach((key) => {
|
|
471
|
-
if (key.startsWith(PKCEConstants_default.Storage.StorageKeys.CODE_VERIFIER)) {
|
|
472
|
-
keys.push(key);
|
|
319
|
+
Payload: {
|
|
320
|
+
/**
|
|
321
|
+
* The default scopes used in OIDC sign-in requests.
|
|
322
|
+
*/
|
|
323
|
+
DEFAULT_SCOPES: [ScopeConstants_default.OPENID, ScopeConstants_default.PROFILE, ScopeConstants_default.INTERNAL_LOGIN]
|
|
473
324
|
}
|
|
474
|
-
});
|
|
475
|
-
const lastKey = keys.sort().pop();
|
|
476
|
-
const index = parseInt(lastKey?.split(PKCEConstants_default.Storage.StorageKeys.SEPARATOR)[1] ?? "-1");
|
|
477
|
-
return `${PKCEConstants_default.Storage.StorageKeys.CODE_VERIFIER}${PKCEConstants_default.Storage.StorageKeys.SEPARATOR}${index + 1}`;
|
|
478
|
-
};
|
|
479
|
-
var generatePkceStorageKey_default = generatePkceStorageKey;
|
|
480
|
-
|
|
481
|
-
// src/constants/OIDCRequestConstants.ts
|
|
482
|
-
var OIDCRequestConstants = {
|
|
483
|
-
Params: {
|
|
484
|
-
/**
|
|
485
|
-
* The authorization code returned from the authorization endpoint.
|
|
486
|
-
* Used in the authorization code flow.
|
|
487
|
-
*/
|
|
488
|
-
AUTHORIZATION_CODE: "code",
|
|
489
|
-
/**
|
|
490
|
-
* Session state parameter used for session management between the client and the OP.
|
|
491
|
-
*/
|
|
492
|
-
SESSION_STATE: "session_state",
|
|
493
|
-
/**
|
|
494
|
-
* State parameter used to maintain state between the request and the callback.
|
|
495
|
-
* Helps in preventing CSRF attacks.
|
|
496
|
-
*/
|
|
497
|
-
STATE: "state",
|
|
498
|
-
/**
|
|
499
|
-
* Indicates whether sign-out was successful during the end-session flow.
|
|
500
|
-
* May be returned by the OP after a logout request.
|
|
501
|
-
*/
|
|
502
|
-
SIGN_OUT_SUCCESS: "sign_out_success"
|
|
503
325
|
},
|
|
504
326
|
/**
|
|
505
327
|
* Sign-out related constants for managing the end-session flow in OIDC.
|
|
@@ -525,6 +347,19 @@ var OIDCRequestConstants = {
|
|
|
525
347
|
};
|
|
526
348
|
var OIDCRequestConstants_default = OIDCRequestConstants;
|
|
527
349
|
|
|
350
|
+
// src/errors/exception.ts
|
|
351
|
+
var AsgardeoAuthException = class {
|
|
352
|
+
constructor(code, name, message) {
|
|
353
|
+
__publicField(this, "name");
|
|
354
|
+
__publicField(this, "code");
|
|
355
|
+
__publicField(this, "message");
|
|
356
|
+
this.message = message;
|
|
357
|
+
this.name = name;
|
|
358
|
+
this.code = code;
|
|
359
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
|
|
528
363
|
// src/constants/TokenConstants.ts
|
|
529
364
|
var TokenConstants = {
|
|
530
365
|
/**
|
|
@@ -620,7 +455,7 @@ var IsomorphicCrypto = class {
|
|
|
620
455
|
*
|
|
621
456
|
* @param idToken - id_token received from the IdP.
|
|
622
457
|
* @param jwk - public key used for signing.
|
|
623
|
-
* @param
|
|
458
|
+
* @param clientId - app identification.
|
|
624
459
|
* @param issuer - id_token issuer.
|
|
625
460
|
* @param username - Username.
|
|
626
461
|
* @param clockTolerance - Allowed leeway for id_tokens (in seconds).
|
|
@@ -629,12 +464,12 @@ var IsomorphicCrypto = class {
|
|
|
629
464
|
*
|
|
630
465
|
* @throws
|
|
631
466
|
*/
|
|
632
|
-
isValidIdToken(idToken, jwk,
|
|
467
|
+
isValidIdToken(idToken, jwk, clientId, issuer, username, clockTolerance, validateJwtIssuer) {
|
|
633
468
|
return this._cryptoUtils.verifyJwt(
|
|
634
469
|
idToken,
|
|
635
470
|
jwk,
|
|
636
471
|
TokenConstants_default.SignatureValidation.SUPPORTED_ALGORITHMS,
|
|
637
|
-
|
|
472
|
+
clientId,
|
|
638
473
|
issuer,
|
|
639
474
|
username,
|
|
640
475
|
clockTolerance,
|
|
@@ -661,9 +496,9 @@ var IsomorphicCrypto = class {
|
|
|
661
496
|
*
|
|
662
497
|
* @throws
|
|
663
498
|
*/
|
|
664
|
-
|
|
499
|
+
decodeIdToken(idToken) {
|
|
665
500
|
try {
|
|
666
|
-
const utf8String = this._cryptoUtils.base64URLDecode(idToken
|
|
501
|
+
const utf8String = this._cryptoUtils.base64URLDecode(idToken?.split(".")[1]);
|
|
667
502
|
const payload = JSON.parse(utf8String);
|
|
668
503
|
return payload;
|
|
669
504
|
} catch (error) {
|
|
@@ -672,644 +507,467 @@ var IsomorphicCrypto = class {
|
|
|
672
507
|
}
|
|
673
508
|
};
|
|
674
509
|
|
|
675
|
-
// src/
|
|
676
|
-
var
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
if (configData.scope && configData.scope.length > 0) {
|
|
698
|
-
if (!configData.scope.includes(ScopeConstants_default.OPENID)) {
|
|
699
|
-
configData.scope.push(ScopeConstants_default.OPENID);
|
|
700
|
-
}
|
|
701
|
-
scope = configData.scope.join(" ");
|
|
702
|
-
}
|
|
703
|
-
authorizeRequestParams.set("scope", scope);
|
|
704
|
-
authorizeRequestParams.set("redirect_uri", configData.signInRedirectURL);
|
|
705
|
-
if (configData.responseMode) {
|
|
706
|
-
authorizeRequestParams.set("response_mode", configData.responseMode);
|
|
707
|
-
}
|
|
708
|
-
const tempStore = await this._dataLayer.getTemporaryData(userID);
|
|
709
|
-
const pkceKey = await generatePkceStorageKey_default(tempStore);
|
|
710
|
-
if (configData.enablePKCE) {
|
|
711
|
-
const codeVerifier = this._cryptoHelper?.getCodeVerifier();
|
|
712
|
-
const codeChallenge = this._cryptoHelper?.getCodeChallenge(codeVerifier);
|
|
713
|
-
await this._dataLayer.setTemporaryDataParameter(pkceKey, codeVerifier, userID);
|
|
714
|
-
authorizeRequestParams.set("code_challenge_method", "S256");
|
|
715
|
-
authorizeRequestParams.set("code_challenge", codeChallenge);
|
|
716
|
-
}
|
|
717
|
-
if (configData.prompt) {
|
|
718
|
-
authorizeRequestParams.set("prompt", configData.prompt);
|
|
719
|
-
}
|
|
720
|
-
const customParams = config;
|
|
721
|
-
if (customParams) {
|
|
722
|
-
for (const [key, value] of Object.entries(customParams)) {
|
|
723
|
-
if (key != "" && value != "" && key !== OIDCRequestConstants_default.Params.STATE) {
|
|
724
|
-
authorizeRequestParams.set(key, value.toString());
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
authorizeRequestParams.set(
|
|
729
|
-
OIDCRequestConstants_default.Params.STATE,
|
|
730
|
-
generateStateParamForRequestCorrelation_default(
|
|
731
|
-
pkceKey,
|
|
732
|
-
customParams ? customParams[OIDCRequestConstants_default.Params.STATE]?.toString() : ""
|
|
733
|
-
)
|
|
734
|
-
);
|
|
735
|
-
return authorizeRequestParams;
|
|
736
|
-
}
|
|
737
|
-
async getAuthorizationURL(config, userID) {
|
|
738
|
-
const authorizeEndpoint = await this._dataLayer.getOIDCProviderMetaDataParameter(
|
|
739
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.AUTHORIZATION
|
|
740
|
-
);
|
|
741
|
-
if (!authorizeEndpoint || authorizeEndpoint.trim().length === 0) {
|
|
742
|
-
throw new AsgardeoAuthException(
|
|
743
|
-
"JS-AUTH_CORE-GAU-NF01",
|
|
744
|
-
"No authorization endpoint found.",
|
|
745
|
-
"No authorization endpoint was found in the OIDC provider meta data from the well-known endpoint or the authorization endpoint passed to the SDK is empty."
|
|
746
|
-
);
|
|
747
|
-
}
|
|
748
|
-
const authorizeRequest = new URL(authorizeEndpoint);
|
|
749
|
-
const authorizeRequestParams = await this.getAuthorizationURLParams(config, userID);
|
|
750
|
-
for (const [key, value] of authorizeRequestParams.entries()) {
|
|
751
|
-
authorizeRequest.searchParams.append(key, value);
|
|
510
|
+
// src/constants/PKCEConstants.ts
|
|
511
|
+
var PKCEConstants = {
|
|
512
|
+
DEFAULT_CODE_CHALLENGE_METHOD: "S256",
|
|
513
|
+
/**
|
|
514
|
+
* Storage-related constants for managing PKCE state
|
|
515
|
+
*/
|
|
516
|
+
Storage: {
|
|
517
|
+
/**
|
|
518
|
+
* Collection of storage keys used in PKCE implementation
|
|
519
|
+
*/
|
|
520
|
+
StorageKeys: {
|
|
521
|
+
/**
|
|
522
|
+
* Key used to store the PKCE code verifier in temporary storage.
|
|
523
|
+
* The code verifier is a cryptographically random string that is
|
|
524
|
+
* used to generate the code challenge.
|
|
525
|
+
*/
|
|
526
|
+
CODE_VERIFIER: "pkce_code_verifier",
|
|
527
|
+
/**
|
|
528
|
+
* Separator used in storage keys to create unique identifiers
|
|
529
|
+
* by combining different parts of the key.
|
|
530
|
+
*/
|
|
531
|
+
SEPARATOR: "#"
|
|
752
532
|
}
|
|
753
|
-
return authorizeRequest.toString();
|
|
754
533
|
}
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
534
|
+
};
|
|
535
|
+
var PKCEConstants_default = PKCEConstants;
|
|
536
|
+
|
|
537
|
+
// src/utils/extractPkceStorageKeyFromState.ts
|
|
538
|
+
var extractPkceStorageKeyFromState = (state) => {
|
|
539
|
+
const index = parseInt(state.split("request_")[1]);
|
|
540
|
+
return `${PKCEConstants_default.Storage.StorageKeys.CODE_VERIFIER}${PKCEConstants_default.Storage.StorageKeys.SEPARATOR}${index}`;
|
|
541
|
+
};
|
|
542
|
+
var extractPkceStorageKeyFromState_default = extractPkceStorageKeyFromState;
|
|
543
|
+
|
|
544
|
+
// src/constants/TokenExchangeConstants.ts
|
|
545
|
+
var TokenExchangeConstants = {
|
|
546
|
+
/**
|
|
547
|
+
* Collection of placeholder strings used in token exchange operations.
|
|
548
|
+
* These placeholders are replaced with actual values when processing
|
|
549
|
+
* token exchange requests.
|
|
550
|
+
*/
|
|
551
|
+
Placeholders: {
|
|
552
|
+
/**
|
|
553
|
+
* Placeholder for the token value in exchange requests.
|
|
554
|
+
* Usually replaced with an access token or refresh token.
|
|
555
|
+
*/
|
|
556
|
+
ACCESS_TOKEN: "{{accessToken}}",
|
|
557
|
+
/**
|
|
558
|
+
* Placeholder for the username in token exchange operations.
|
|
559
|
+
* Used when user identity needs to be included in the exchange.
|
|
560
|
+
*/
|
|
561
|
+
USERNAME: "{{username}}",
|
|
562
|
+
/**
|
|
563
|
+
* Placeholder for OAuth scopes in token exchange requests.
|
|
564
|
+
* Replaced with space-separated scope strings.
|
|
565
|
+
*/
|
|
566
|
+
SCOPES: "{{scopes}}",
|
|
567
|
+
/**
|
|
568
|
+
* Placeholder for client ID in token exchange operations.
|
|
569
|
+
* Required for client authentication.
|
|
570
|
+
*/
|
|
571
|
+
CLIENT_ID: "{{clientId}}",
|
|
572
|
+
/**
|
|
573
|
+
* Placeholder for client secret in token exchange operations.
|
|
574
|
+
* Used for client authentication in confidential client flows.
|
|
575
|
+
*/
|
|
576
|
+
CLIENT_SECRET: "{{clientSecret}}"
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
var TokenExchangeConstants_default = TokenExchangeConstants;
|
|
580
|
+
|
|
581
|
+
// src/utils/extractUserClaimsFromIdToken.ts
|
|
582
|
+
var extractUserClaimsFromIdToken = (payload) => {
|
|
583
|
+
const filteredPayload = { ...payload };
|
|
584
|
+
const protocolClaims = [
|
|
585
|
+
"iss",
|
|
586
|
+
"aud",
|
|
587
|
+
"exp",
|
|
588
|
+
"iat",
|
|
589
|
+
"acr",
|
|
590
|
+
"amr",
|
|
591
|
+
"azp",
|
|
592
|
+
"auth_time",
|
|
593
|
+
"nonce",
|
|
594
|
+
"c_hash",
|
|
595
|
+
"at_hash",
|
|
596
|
+
"nbf",
|
|
597
|
+
"isk",
|
|
598
|
+
"sid",
|
|
599
|
+
"jti",
|
|
600
|
+
"sub"
|
|
601
|
+
];
|
|
602
|
+
protocolClaims.forEach((claim) => {
|
|
603
|
+
delete filteredPayload[claim];
|
|
604
|
+
});
|
|
605
|
+
const userClaims = {};
|
|
606
|
+
Object.entries(filteredPayload).forEach(([key, value]) => {
|
|
607
|
+
const camelCasedKey = key.split("_").map((part, i) => i === 0 ? part : part[0].toUpperCase() + part.slice(1)).join("");
|
|
608
|
+
userClaims[camelCasedKey] = value;
|
|
609
|
+
});
|
|
610
|
+
return userClaims;
|
|
611
|
+
};
|
|
612
|
+
var extractUserClaimsFromIdToken_default = extractUserClaimsFromIdToken;
|
|
613
|
+
|
|
614
|
+
// src/errors/AsgardeoError.ts
|
|
615
|
+
var AsgardeoError = class _AsgardeoError extends Error {
|
|
616
|
+
constructor(message, code, origin) {
|
|
617
|
+
const _origin = _AsgardeoError.resolveOrigin(origin);
|
|
618
|
+
const prefix = `\u{1F6E1}\uFE0F Asgardeo - ${_origin}:`;
|
|
619
|
+
const regex = new RegExp(`\u{1F6E1}\uFE0F\\s*Asgardeo\\s*-\\s*${_origin}:`, "i");
|
|
620
|
+
const sanitized = message.replace(regex, "");
|
|
621
|
+
const _message = `${prefix} ${sanitized.trim()}
|
|
622
|
+
|
|
623
|
+
(code="${code}")
|
|
624
|
+
`;
|
|
625
|
+
super(_message);
|
|
626
|
+
__publicField(this, "code");
|
|
627
|
+
__publicField(this, "origin");
|
|
628
|
+
this.name = new.target.name;
|
|
629
|
+
this.code = code;
|
|
630
|
+
this.origin = _origin;
|
|
631
|
+
if (Error.captureStackTrace) {
|
|
632
|
+
Error.captureStackTrace(this, new.target);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
static resolveOrigin(origin) {
|
|
636
|
+
if (!origin) {
|
|
637
|
+
return "@asgardeo/javascript";
|
|
638
|
+
}
|
|
639
|
+
return `@asgardeo/${origin}`;
|
|
640
|
+
}
|
|
641
|
+
toString() {
|
|
642
|
+
return `[${this.name}]
|
|
643
|
+
Message: ${this.message}`;
|
|
644
|
+
}
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
// src/errors/AsgardeoRuntimeError.ts
|
|
648
|
+
var AsgardeoRuntimeError = class extends AsgardeoError {
|
|
649
|
+
/**
|
|
650
|
+
* Creates an instance of AsgardeoRuntimeError.
|
|
651
|
+
*
|
|
652
|
+
* @param message - Human-readable description of the error
|
|
653
|
+
* @param code - A unique error code that identifies the error type
|
|
654
|
+
* @param details - Additional details about the error that might be helpful for debugging
|
|
655
|
+
* @param origin - Optional. The SDK origin (e.g. 'react', 'vue'). Defaults to generic 'Asgardeo'
|
|
656
|
+
* @constructor
|
|
657
|
+
*/
|
|
658
|
+
constructor(message, code, origin, details) {
|
|
659
|
+
super(message, code, origin);
|
|
660
|
+
this.details = details;
|
|
661
|
+
Object.defineProperty(this, "name", {
|
|
662
|
+
value: "AsgardeoRuntimeError",
|
|
663
|
+
configurable: true,
|
|
664
|
+
writable: true
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Returns a string representation of the runtime error
|
|
669
|
+
* @returns Formatted error string with name, code, details, and message
|
|
670
|
+
*/
|
|
671
|
+
toString() {
|
|
672
|
+
const details = this.details ? `
|
|
673
|
+
Details: ${JSON.stringify(this.details, null, 2)}` : "";
|
|
674
|
+
return `[${this.name}] (code="${this.code}")${details}
|
|
675
|
+
Message: ${this.message}`;
|
|
676
|
+
}
|
|
677
|
+
};
|
|
678
|
+
|
|
679
|
+
// src/utils/processOpenIDScopes.ts
|
|
680
|
+
var processOpenIDScopes = (scopes) => {
|
|
681
|
+
let processedScopes = [];
|
|
682
|
+
if (scopes) {
|
|
683
|
+
if (Array.isArray(scopes)) {
|
|
684
|
+
processedScopes = scopes;
|
|
685
|
+
} else if (typeof scopes === "string") {
|
|
686
|
+
processedScopes = scopes.split(" ");
|
|
687
|
+
} else {
|
|
688
|
+
throw new AsgardeoRuntimeError(
|
|
689
|
+
"Scopes must be a string or an array of strings.",
|
|
690
|
+
"processOpenIDScopes-Invalid-001",
|
|
691
|
+
"javascript",
|
|
692
|
+
"The provided scopes are not in the expected format. Please provide a string or an array of strings."
|
|
807
693
|
);
|
|
808
694
|
}
|
|
809
|
-
|
|
695
|
+
}
|
|
696
|
+
OIDCRequestConstants_default.SignIn.Payload.DEFAULT_SCOPES.forEach((defaultScope) => {
|
|
697
|
+
if (!processedScopes.includes(defaultScope)) {
|
|
698
|
+
processedScopes.push(defaultScope);
|
|
699
|
+
}
|
|
700
|
+
});
|
|
701
|
+
return processedScopes.join(" ");
|
|
702
|
+
};
|
|
703
|
+
var processOpenIDScopes_default = processOpenIDScopes;
|
|
704
|
+
|
|
705
|
+
// src/__legacy__/helpers/authentication-helper.ts
|
|
706
|
+
var AuthenticationHelper = class {
|
|
707
|
+
constructor(storageManager, cryptoHelper) {
|
|
708
|
+
__publicField(this, "_storageManager");
|
|
709
|
+
__publicField(this, "_config");
|
|
710
|
+
__publicField(this, "_oidcProviderMetaData");
|
|
711
|
+
__publicField(this, "_cryptoHelper");
|
|
712
|
+
this._storageManager = storageManager;
|
|
713
|
+
this._config = async () => this._storageManager.getConfigData();
|
|
714
|
+
this._oidcProviderMetaData = async () => this._storageManager.loadOpenIDProviderConfiguration();
|
|
715
|
+
this._cryptoHelper = cryptoHelper;
|
|
716
|
+
}
|
|
717
|
+
async resolveEndpoints(response) {
|
|
718
|
+
const oidcProviderMetaData = {};
|
|
719
|
+
const configData = await this._config();
|
|
720
|
+
configData.endpoints && Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
721
|
+
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
722
|
+
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
723
|
+
});
|
|
724
|
+
return { ...response, ...oidcProviderMetaData };
|
|
725
|
+
}
|
|
726
|
+
async resolveEndpointsExplicitly() {
|
|
727
|
+
const oidcProviderMetaData = {};
|
|
728
|
+
const configData = await this._config();
|
|
729
|
+
const requiredEndpoints = [
|
|
730
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.AUTHORIZATION,
|
|
731
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.END_SESSION,
|
|
732
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.JWKS,
|
|
733
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.SESSION_IFRAME,
|
|
734
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.REVOCATION,
|
|
735
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.TOKEN,
|
|
736
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.ISSUER,
|
|
737
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.USERINFO
|
|
738
|
+
];
|
|
739
|
+
const isRequiredEndpointsContains = configData.endpoints ? requiredEndpoints.every(
|
|
740
|
+
(reqEndpointName) => configData.endpoints ? Object.keys(configData.endpoints).some((endpointName) => {
|
|
741
|
+
const snakeCasedName = endpointName.replace(
|
|
742
|
+
/[A-Z]/g,
|
|
743
|
+
(letter) => `_${letter.toLowerCase()}`
|
|
744
|
+
);
|
|
745
|
+
return snakeCasedName === reqEndpointName;
|
|
746
|
+
}) : false
|
|
747
|
+
) : false;
|
|
748
|
+
if (!isRequiredEndpointsContains) {
|
|
810
749
|
throw new AsgardeoAuthException(
|
|
811
|
-
"JS-
|
|
812
|
-
|
|
813
|
-
|
|
750
|
+
"JS-AUTH_HELPER-REE-NF01",
|
|
751
|
+
"Required endpoints missing",
|
|
752
|
+
"Some or all of the required endpoints are missing in the object passed to the `endpoints` attribute of the`AuthConfig` object."
|
|
814
753
|
);
|
|
815
754
|
}
|
|
816
|
-
|
|
755
|
+
configData.endpoints && Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
756
|
+
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
757
|
+
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
758
|
+
});
|
|
759
|
+
return { ...oidcProviderMetaData };
|
|
817
760
|
}
|
|
818
|
-
async
|
|
819
|
-
const
|
|
761
|
+
async resolveEndpointsByBaseURL() {
|
|
762
|
+
const oidcProviderMetaData = {};
|
|
820
763
|
const configData = await this._config();
|
|
821
|
-
const
|
|
822
|
-
if (!
|
|
764
|
+
const { baseUrl } = configData;
|
|
765
|
+
if (!baseUrl) {
|
|
823
766
|
throw new AsgardeoAuthException(
|
|
824
|
-
"JS-
|
|
825
|
-
"
|
|
826
|
-
"
|
|
767
|
+
"JS-AUTH_HELPER_REBO-NF01",
|
|
768
|
+
"Base URL not defined.",
|
|
769
|
+
"Base URL is not defined in AuthClient config."
|
|
827
770
|
);
|
|
828
771
|
}
|
|
829
|
-
|
|
772
|
+
configData.endpoints && Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
773
|
+
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
774
|
+
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
775
|
+
});
|
|
776
|
+
const defaultEndpoints = {
|
|
777
|
+
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.AUTHORIZATION]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.AUTHORIZATION}`,
|
|
778
|
+
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.END_SESSION]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.END_SESSION}`,
|
|
779
|
+
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.ISSUER]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.ISSUER}`,
|
|
780
|
+
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.JWKS]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.JWKS}`,
|
|
781
|
+
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.SESSION_IFRAME]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.SESSION_IFRAME}`,
|
|
782
|
+
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.REVOCATION]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.REVOCATION}`,
|
|
783
|
+
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.TOKEN]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.TOKEN}`,
|
|
784
|
+
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.USERINFO]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.USERINFO}`
|
|
785
|
+
};
|
|
786
|
+
return { ...defaultEndpoints, ...oidcProviderMetaData };
|
|
787
|
+
}
|
|
788
|
+
async validateIdToken(idToken) {
|
|
789
|
+
const jwksEndpoint = (await this._storageManager.loadOpenIDProviderConfiguration()).jwks_uri;
|
|
790
|
+
const configData = await this._config();
|
|
791
|
+
if (!jwksEndpoint || jwksEndpoint.trim().length === 0) {
|
|
830
792
|
throw new AsgardeoAuthException(
|
|
831
|
-
"
|
|
832
|
-
"
|
|
833
|
-
"No
|
|
793
|
+
"JS_AUTH_HELPER-VIT-NF01",
|
|
794
|
+
"JWKS endpoint not found.",
|
|
795
|
+
"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."
|
|
834
796
|
);
|
|
835
797
|
}
|
|
836
|
-
|
|
837
|
-
body.push(`client_id=${configData.clientID}`);
|
|
838
|
-
body.push(`refresh_token=${sessionData.refresh_token}`);
|
|
839
|
-
body.push("grant_type=refresh_token");
|
|
840
|
-
if (configData.clientSecret && configData.clientSecret.trim().length > 0) {
|
|
841
|
-
body.push(`client_secret=${configData.clientSecret}`);
|
|
842
|
-
}
|
|
843
|
-
let tokenResponse;
|
|
798
|
+
let response;
|
|
844
799
|
try {
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
credentials: configData.sendCookiesInRequests ? "include" : "same-origin",
|
|
848
|
-
headers: {
|
|
849
|
-
Accept: "application/json",
|
|
850
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
851
|
-
},
|
|
852
|
-
method: "POST"
|
|
800
|
+
response = await fetch(jwksEndpoint, {
|
|
801
|
+
credentials: configData.sendCookiesInRequests ? "include" : "same-origin"
|
|
853
802
|
});
|
|
854
803
|
} catch (error) {
|
|
855
804
|
throw new AsgardeoAuthException(
|
|
856
|
-
"JS-
|
|
857
|
-
"
|
|
858
|
-
error ?? "The request to
|
|
805
|
+
"JS-AUTH_HELPER-VIT-NE02",
|
|
806
|
+
"Request to jwks endpoint failed.",
|
|
807
|
+
error ?? "The request sent to get the jwks from the server failed."
|
|
859
808
|
);
|
|
860
809
|
}
|
|
861
|
-
if (!
|
|
810
|
+
if (response.status !== 200 || !response.ok) {
|
|
862
811
|
throw new AsgardeoAuthException(
|
|
863
|
-
"JS-
|
|
864
|
-
`
|
|
865
|
-
await tokenResponse.json()
|
|
866
|
-
);
|
|
867
|
-
}
|
|
868
|
-
return this._authenticationHelper.handleTokenResponse(tokenResponse, userID);
|
|
869
|
-
}
|
|
870
|
-
async revokeAccessToken(userID) {
|
|
871
|
-
const revokeTokenEndpoint = (await this._oidcProviderMetaData()).revocation_endpoint;
|
|
872
|
-
const configData = await this._config();
|
|
873
|
-
if (!revokeTokenEndpoint || revokeTokenEndpoint.trim().length === 0) {
|
|
874
|
-
throw new AsgardeoAuthException(
|
|
875
|
-
"JS-AUTH_CORE-RAT3-NF01",
|
|
876
|
-
"No revoke access token endpoint found.",
|
|
877
|
-
"No revoke access token endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the revoke access token endpoint passed to the SDK is empty."
|
|
878
|
-
);
|
|
879
|
-
}
|
|
880
|
-
const body = [];
|
|
881
|
-
body.push(`client_id=${configData.clientID}`);
|
|
882
|
-
body.push(`token=${(await this._dataLayer.getSessionData(userID)).access_token}`);
|
|
883
|
-
body.push("token_type_hint=access_token");
|
|
884
|
-
if (configData.clientSecret && configData.clientSecret.trim().length > 0) {
|
|
885
|
-
body.push(`client_secret=${configData.clientSecret}`);
|
|
886
|
-
}
|
|
887
|
-
let response;
|
|
888
|
-
try {
|
|
889
|
-
response = await fetch(revokeTokenEndpoint, {
|
|
890
|
-
body: body.join("&"),
|
|
891
|
-
credentials: configData.sendCookiesInRequests ? "include" : "same-origin",
|
|
892
|
-
headers: {
|
|
893
|
-
Accept: "application/json",
|
|
894
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
895
|
-
},
|
|
896
|
-
method: "POST"
|
|
897
|
-
});
|
|
898
|
-
} catch (error) {
|
|
899
|
-
throw new AsgardeoAuthException(
|
|
900
|
-
"JS-AUTH_CORE-RAT3-NE02",
|
|
901
|
-
"The request to revoke access token failed.",
|
|
902
|
-
error ?? "The request sent to revoke the access token failed."
|
|
903
|
-
);
|
|
904
|
-
}
|
|
905
|
-
if (response.status !== 200 || !response.ok) {
|
|
906
|
-
throw new AsgardeoAuthException(
|
|
907
|
-
"JS-AUTH_CORE-RAT3-HE03",
|
|
908
|
-
`Invalid response status received for revoke access token request (${response.statusText}).`,
|
|
812
|
+
"JS-AUTH_HELPER-VIT-HE03",
|
|
813
|
+
`Invalid response status received for jwks request (${response.statusText}).`,
|
|
909
814
|
await response.json()
|
|
910
815
|
);
|
|
911
816
|
}
|
|
912
|
-
this.
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
}
|
|
924
|
-
if (!tokenEndpoint || tokenEndpoint.trim().length === 0) {
|
|
925
|
-
throw new AsgardeoAuthException(
|
|
926
|
-
"JS-AUTH_CORE-RCG-NF01",
|
|
927
|
-
"Token endpoint not found.",
|
|
928
|
-
"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."
|
|
929
|
-
);
|
|
930
|
-
}
|
|
931
|
-
const data = await Promise.all(
|
|
932
|
-
Object.entries(customGrantParams.data).map(async ([key, value]) => {
|
|
933
|
-
const newValue = await this._authenticationHelper.replaceCustomGrantTemplateTags(
|
|
934
|
-
value,
|
|
935
|
-
userID
|
|
936
|
-
);
|
|
937
|
-
return `${key}=${newValue}`;
|
|
938
|
-
})
|
|
817
|
+
const { issuer } = await this._oidcProviderMetaData();
|
|
818
|
+
const { keys } = await response.json();
|
|
819
|
+
const jwk = await this._cryptoHelper.getJWKForTheIdToken(idToken.split(".")[0], keys);
|
|
820
|
+
return this._cryptoHelper.isValidIdToken(
|
|
821
|
+
idToken,
|
|
822
|
+
jwk,
|
|
823
|
+
(await this._config()).clientId,
|
|
824
|
+
issuer ?? "",
|
|
825
|
+
this._cryptoHelper.decodeIdToken(idToken).sub,
|
|
826
|
+
(await this._config()).clockTolerance,
|
|
827
|
+
(await this._config()).validateIDTokenIssuer ?? true
|
|
939
828
|
);
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
credentials: configData.sendCookiesInRequests ? "include" : "same-origin",
|
|
953
|
-
headers: new Headers(requestHeaders),
|
|
954
|
-
method: "POST"
|
|
829
|
+
}
|
|
830
|
+
getAuthenticatedUserInfo(idToken) {
|
|
831
|
+
const payload = this._cryptoHelper.decodeIdToken(idToken);
|
|
832
|
+
const username = payload?.["username"] ?? "";
|
|
833
|
+
const givenName = payload?.["given_name"] ?? "";
|
|
834
|
+
const familyName = payload?.["family_name"] ?? "";
|
|
835
|
+
const fullName = givenName && familyName ? `${givenName} ${familyName}` : givenName || familyName || "";
|
|
836
|
+
const displayName = payload.preferred_username ?? fullName;
|
|
837
|
+
return {
|
|
838
|
+
displayName,
|
|
839
|
+
username,
|
|
840
|
+
...extractUserClaimsFromIdToken_default(payload)
|
|
955
841
|
};
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
error ?? "The request sent to get the custom grant failed."
|
|
964
|
-
);
|
|
842
|
+
}
|
|
843
|
+
async replaceCustomGrantTemplateTags(text, userId) {
|
|
844
|
+
const configData = await this._config();
|
|
845
|
+
const sessionData = await this._storageManager.getSessionData(userId);
|
|
846
|
+
const scope = processOpenIDScopes_default(configData.scopes);
|
|
847
|
+
if (typeof text !== "string") {
|
|
848
|
+
return text;
|
|
965
849
|
}
|
|
850
|
+
return text.replace(TokenExchangeConstants_default.Placeholders.ACCESS_TOKEN, sessionData.access_token).replace(
|
|
851
|
+
TokenExchangeConstants_default.Placeholders.USERNAME,
|
|
852
|
+
this.getAuthenticatedUserInfo(sessionData.id_token).username
|
|
853
|
+
).replace(TokenExchangeConstants_default.Placeholders.SCOPES, scope).replace(TokenExchangeConstants_default.Placeholders.CLIENT_ID, configData.clientId).replace(TokenExchangeConstants_default.Placeholders.CLIENT_SECRET, configData.clientSecret ?? "");
|
|
854
|
+
}
|
|
855
|
+
async clearSession(userId) {
|
|
856
|
+
await this._storageManager.removeTemporaryData(userId);
|
|
857
|
+
await this._storageManager.removeSessionData(userId);
|
|
858
|
+
}
|
|
859
|
+
async handleTokenResponse(response, userId) {
|
|
966
860
|
if (response.status !== 200 || !response.ok) {
|
|
967
861
|
throw new AsgardeoAuthException(
|
|
968
|
-
"JS-
|
|
969
|
-
`Invalid response status received for
|
|
862
|
+
"JS-AUTH_HELPER-HTR-NE01",
|
|
863
|
+
`Invalid response status received for token request (${response.statusText}).`,
|
|
970
864
|
await response.json()
|
|
971
865
|
);
|
|
972
866
|
}
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
867
|
+
const parsedResponse = await response.json();
|
|
868
|
+
parsedResponse.created_at = (/* @__PURE__ */ new Date()).getTime();
|
|
869
|
+
const shouldValidateIdToken = (await this._config()).validateIDToken;
|
|
870
|
+
if (shouldValidateIdToken) {
|
|
871
|
+
return this.validateIdToken(parsedResponse.id_token).then(async () => {
|
|
872
|
+
await this._storageManager.setSessionData(parsedResponse, userId);
|
|
873
|
+
const tokenResponse2 = {
|
|
874
|
+
accessToken: parsedResponse.access_token,
|
|
875
|
+
createdAt: parsedResponse.created_at,
|
|
876
|
+
expiresIn: parsedResponse.expires_in,
|
|
877
|
+
idToken: parsedResponse.id_token,
|
|
878
|
+
refreshToken: parsedResponse.refresh_token,
|
|
879
|
+
scope: parsedResponse.scope,
|
|
880
|
+
tokenType: parsedResponse.token_type
|
|
881
|
+
};
|
|
882
|
+
return Promise.resolve(tokenResponse2);
|
|
883
|
+
});
|
|
977
884
|
}
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
sessionState: sessionData.session_state
|
|
885
|
+
const tokenResponse = {
|
|
886
|
+
accessToken: parsedResponse.access_token,
|
|
887
|
+
createdAt: parsedResponse.created_at,
|
|
888
|
+
expiresIn: parsedResponse.expires_in,
|
|
889
|
+
idToken: parsedResponse.id_token,
|
|
890
|
+
refreshToken: parsedResponse.refresh_token,
|
|
891
|
+
scope: parsedResponse.scope,
|
|
892
|
+
tokenType: parsedResponse.token_type
|
|
987
893
|
};
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
delete authenticatedUser[key];
|
|
991
|
-
}
|
|
992
|
-
});
|
|
993
|
-
basicUserInfo = { ...basicUserInfo, ...authenticatedUser };
|
|
994
|
-
return basicUserInfo;
|
|
995
|
-
}
|
|
996
|
-
async getDecodedIDToken(userID) {
|
|
997
|
-
const idToken = (await this._dataLayer.getSessionData(userID)).id_token;
|
|
998
|
-
const payload = this._cryptoHelper.decodeIDToken(idToken);
|
|
999
|
-
return payload;
|
|
894
|
+
await this._storageManager.setSessionData(parsedResponse, userId);
|
|
895
|
+
return Promise.resolve(tokenResponse);
|
|
1000
896
|
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
if (!forceInit && await this._dataLayer.getTemporaryDataParameter(
|
|
1010
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED
|
|
1011
|
-
)) {
|
|
1012
|
-
return Promise.resolve();
|
|
897
|
+
};
|
|
898
|
+
|
|
899
|
+
// src/utils/generatePkceStorageKey.ts
|
|
900
|
+
var generatePkceStorageKey = (tempStore) => {
|
|
901
|
+
const keys = [];
|
|
902
|
+
Object.keys(tempStore).forEach((key) => {
|
|
903
|
+
if (key.startsWith(PKCEConstants_default.Storage.StorageKeys.CODE_VERIFIER)) {
|
|
904
|
+
keys.push(key);
|
|
1013
905
|
}
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
error ?? "Resolving endpoints by base url failed."
|
|
1045
|
-
);
|
|
1046
|
-
}
|
|
1047
|
-
await this._dataLayer.setTemporaryDataParameter(
|
|
1048
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,
|
|
1049
|
-
true
|
|
1050
|
-
);
|
|
1051
|
-
return Promise.resolve();
|
|
906
|
+
});
|
|
907
|
+
const lastKey = keys.sort().pop();
|
|
908
|
+
const index = parseInt(lastKey?.split(PKCEConstants_default.Storage.StorageKeys.SEPARATOR)[1] ?? "-1");
|
|
909
|
+
return `${PKCEConstants_default.Storage.StorageKeys.CODE_VERIFIER}${PKCEConstants_default.Storage.StorageKeys.SEPARATOR}${index + 1}`;
|
|
910
|
+
};
|
|
911
|
+
var generatePkceStorageKey_default = generatePkceStorageKey;
|
|
912
|
+
|
|
913
|
+
// src/utils/generateStateParamForRequestCorrelation.ts
|
|
914
|
+
var generateStateParamForRequestCorrelation = (pkceKey, state) => {
|
|
915
|
+
const index = parseInt(pkceKey.split(PKCEConstants_default.Storage.StorageKeys.SEPARATOR)[1]);
|
|
916
|
+
return state ? `${state}_request_${index}` : `request_${index}`;
|
|
917
|
+
};
|
|
918
|
+
var generateStateParamForRequestCorrelation_default = generateStateParamForRequestCorrelation;
|
|
919
|
+
|
|
920
|
+
// src/utils/getAuthorizeRequestUrlParams.ts
|
|
921
|
+
var getAuthorizeRequestUrlParams = (options, pkceOptions, customParams) => {
|
|
922
|
+
const { redirectUri, clientId, clientSecret, scopes, responseMode, codeChallenge, codeChallengeMethod, prompt } = options;
|
|
923
|
+
const authorizeRequestParams = /* @__PURE__ */ new Map();
|
|
924
|
+
authorizeRequestParams.set("response_type", "code");
|
|
925
|
+
authorizeRequestParams.set("client_id", clientId);
|
|
926
|
+
authorizeRequestParams.set("scope", scopes);
|
|
927
|
+
authorizeRequestParams.set("redirect_uri", redirectUri);
|
|
928
|
+
if (responseMode) {
|
|
929
|
+
authorizeRequestParams.set("response_mode", responseMode);
|
|
930
|
+
}
|
|
931
|
+
const pkceKey = pkceOptions?.key;
|
|
932
|
+
if (codeChallenge) {
|
|
933
|
+
authorizeRequestParams.set("code_challenge", codeChallenge);
|
|
934
|
+
if (codeChallengeMethod) {
|
|
935
|
+
authorizeRequestParams.set("code_challenge_method", codeChallengeMethod);
|
|
1052
936
|
} else {
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
937
|
+
throw new AsgardeoRuntimeError(
|
|
938
|
+
"Code challenge method is required when code challenge is provided.",
|
|
939
|
+
"getAuthorizeRequestUrlParams-ValidationError-001",
|
|
940
|
+
"javascript",
|
|
941
|
+
"When PKCE is enabled, the code challenge method must be provided along with the code challenge."
|
|
1057
942
|
);
|
|
1058
|
-
return Promise.resolve();
|
|
1059
943
|
}
|
|
1060
944
|
}
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
const oidcProviderMetaData = await this._oidcProviderMetaData();
|
|
1064
|
-
return {
|
|
1065
|
-
authorizationEndpoint: oidcProviderMetaData.authorization_endpoint ?? "",
|
|
1066
|
-
checkSessionIframe: oidcProviderMetaData.check_session_iframe ?? "",
|
|
1067
|
-
endSessionEndpoint: oidcProviderMetaData.end_session_endpoint ?? "",
|
|
1068
|
-
introspectionEndpoint: oidcProviderMetaData.introspection_endpoint ?? "",
|
|
1069
|
-
issuer: oidcProviderMetaData.issuer ?? "",
|
|
1070
|
-
jwksUri: oidcProviderMetaData.jwks_uri ?? "",
|
|
1071
|
-
registrationEndpoint: oidcProviderMetaData.registration_endpoint ?? "",
|
|
1072
|
-
revocationEndpoint: oidcProviderMetaData.revocation_endpoint ?? "",
|
|
1073
|
-
tokenEndpoint: oidcProviderMetaData.token_endpoint ?? "",
|
|
1074
|
-
userinfoEndpoint: oidcProviderMetaData.userinfo_endpoint ?? ""
|
|
1075
|
-
};
|
|
945
|
+
if (prompt) {
|
|
946
|
+
authorizeRequestParams.set("prompt", prompt);
|
|
1076
947
|
}
|
|
1077
|
-
|
|
1078
|
-
const
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
throw new AsgardeoAuthException(
|
|
1082
|
-
"JS-AUTH_CORE-GSOU-NF01",
|
|
1083
|
-
"Sign-out endpoint not found.",
|
|
1084
|
-
"No sign-out endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the sign-out endpoint passed to the SDK is empty."
|
|
1085
|
-
);
|
|
1086
|
-
}
|
|
1087
|
-
const callbackURL = configData?.signOutRedirectURL ?? configData?.signInRedirectURL;
|
|
1088
|
-
if (!callbackURL || callbackURL.trim().length === 0) {
|
|
1089
|
-
throw new AsgardeoAuthException(
|
|
1090
|
-
"JS-AUTH_CORE-GSOU-NF03",
|
|
1091
|
-
"No sign-out redirect URL found.",
|
|
1092
|
-
"The sign-out redirect URL cannot be found or the URL passed to the SDK is empty. No sign-in redirect URL has been found either. "
|
|
1093
|
-
);
|
|
1094
|
-
}
|
|
1095
|
-
const queryParams = new URLSearchParams();
|
|
1096
|
-
queryParams.set("post_logout_redirect_uri", callbackURL);
|
|
1097
|
-
if (configData.sendIdTokenInLogoutRequest) {
|
|
1098
|
-
const idToken = (await this._dataLayer.getSessionData(userID))?.id_token;
|
|
1099
|
-
if (!idToken || idToken.trim().length === 0) {
|
|
1100
|
-
throw new AsgardeoAuthException(
|
|
1101
|
-
"JS-AUTH_CORE-GSOU-NF02",
|
|
1102
|
-
"ID token not found.",
|
|
1103
|
-
"No ID token could be found. Either the session information is lost or you have not signed in."
|
|
1104
|
-
);
|
|
948
|
+
if (customParams) {
|
|
949
|
+
for (const [key, value] of Object.entries(customParams)) {
|
|
950
|
+
if (key !== "" && value !== "" && key !== OIDCRequestConstants_default.Params.STATE) {
|
|
951
|
+
authorizeRequestParams.set(key, value.toString());
|
|
1105
952
|
}
|
|
1106
|
-
queryParams.set("id_token_hint", idToken);
|
|
1107
|
-
} else {
|
|
1108
|
-
queryParams.set("client_id", configData.clientID);
|
|
1109
953
|
}
|
|
1110
|
-
queryParams.set("state", OIDCRequestConstants_default.Params.SIGN_OUT_SUCCESS);
|
|
1111
|
-
return `${logoutEndpoint}?${queryParams.toString()}`;
|
|
1112
|
-
}
|
|
1113
|
-
async clearUserSessionData(userID) {
|
|
1114
|
-
await this._authenticationHelper.clearUserSessionData(userID);
|
|
1115
|
-
}
|
|
1116
|
-
async getAccessToken(userID) {
|
|
1117
|
-
return (await this._dataLayer.getSessionData(userID))?.access_token;
|
|
1118
|
-
}
|
|
1119
|
-
/**
|
|
1120
|
-
* The created timestamp of the token response in milliseconds.
|
|
1121
|
-
*
|
|
1122
|
-
* @param userID - User ID
|
|
1123
|
-
* @returns Created at timestamp of the token response in milliseconds.
|
|
1124
|
-
*/
|
|
1125
|
-
async getCreatedAt(userID) {
|
|
1126
|
-
return (await this._dataLayer.getSessionData(userID))?.created_at;
|
|
1127
|
-
}
|
|
1128
|
-
/**
|
|
1129
|
-
* The expires timestamp of the token response in seconds.
|
|
1130
|
-
*
|
|
1131
|
-
* @param userID - User ID
|
|
1132
|
-
* @returns Expires in timestamp of the token response in seconds.
|
|
1133
|
-
*/
|
|
1134
|
-
async getExpiresIn(userID) {
|
|
1135
|
-
return (await this._dataLayer.getSessionData(userID))?.expires_in;
|
|
1136
|
-
}
|
|
1137
|
-
async isAuthenticated(userID) {
|
|
1138
|
-
const isAccessTokenAvailable = Boolean(await this.getAccessToken(userID));
|
|
1139
|
-
const createdAt = await this.getCreatedAt(userID);
|
|
1140
|
-
const expiresInString = await this.getExpiresIn(userID);
|
|
1141
|
-
if (!expiresInString) {
|
|
1142
|
-
return false;
|
|
1143
|
-
}
|
|
1144
|
-
const expiresIn = parseInt(expiresInString) * 1e3;
|
|
1145
|
-
const currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
1146
|
-
const isAccessTokenValid = createdAt + expiresIn > currentTime;
|
|
1147
|
-
const isAuthenticated = isAccessTokenAvailable && isAccessTokenValid;
|
|
1148
|
-
return isAuthenticated;
|
|
1149
|
-
}
|
|
1150
|
-
async getPKCECode(state, userID) {
|
|
1151
|
-
return await this._dataLayer.getTemporaryDataParameter(extractPkceStorageKeyFromState_default(state), userID);
|
|
1152
|
-
}
|
|
1153
|
-
async setPKCECode(pkce, state, userID) {
|
|
1154
|
-
return await this._dataLayer.setTemporaryDataParameter(extractPkceStorageKeyFromState_default(state), pkce, userID);
|
|
1155
|
-
}
|
|
1156
|
-
async updateConfig(config) {
|
|
1157
|
-
await this._dataLayer.setConfigData(config);
|
|
1158
|
-
await this.getOIDCProviderMetaData(true);
|
|
1159
|
-
}
|
|
1160
|
-
};
|
|
1161
|
-
|
|
1162
|
-
// src/__legacy__/data/data-layer.ts
|
|
1163
|
-
var ASGARDEO_SESSION_ACTIVE = "asgardeo-session-active";
|
|
1164
|
-
var DataLayer = class {
|
|
1165
|
-
constructor(instanceID, store) {
|
|
1166
|
-
__publicField(this, "_id");
|
|
1167
|
-
__publicField(this, "_store");
|
|
1168
|
-
this._id = instanceID;
|
|
1169
|
-
this._store = store;
|
|
1170
|
-
}
|
|
1171
|
-
async setDataInBulk(key, data) {
|
|
1172
|
-
const existingDataJSON = await this._store.getData(key) ?? null;
|
|
1173
|
-
const existingData = existingDataJSON && JSON.parse(existingDataJSON);
|
|
1174
|
-
const dataToBeSaved = { ...existingData, ...data };
|
|
1175
|
-
const dataToBeSavedJSON = JSON.stringify(dataToBeSaved);
|
|
1176
|
-
await this._store.setData(key, dataToBeSavedJSON);
|
|
1177
|
-
}
|
|
1178
|
-
async setValue(key, attribute, value) {
|
|
1179
|
-
const existingDataJSON = await this._store.getData(key) ?? null;
|
|
1180
|
-
const existingData = existingDataJSON && JSON.parse(existingDataJSON);
|
|
1181
|
-
const dataToBeSaved = { ...existingData, [attribute]: value };
|
|
1182
|
-
const dataToBeSavedJSON = JSON.stringify(dataToBeSaved);
|
|
1183
|
-
await this._store.setData(key, dataToBeSavedJSON);
|
|
1184
|
-
}
|
|
1185
|
-
async removeValue(key, attribute) {
|
|
1186
|
-
const existingDataJSON = await this._store.getData(key) ?? null;
|
|
1187
|
-
const existingData = existingDataJSON && JSON.parse(existingDataJSON);
|
|
1188
|
-
const dataToBeSaved = { ...existingData };
|
|
1189
|
-
delete dataToBeSaved[attribute];
|
|
1190
|
-
const dataToBeSavedJSON = JSON.stringify(dataToBeSaved);
|
|
1191
|
-
await this._store.setData(key, dataToBeSavedJSON);
|
|
1192
|
-
}
|
|
1193
|
-
_resolveKey(store, userID) {
|
|
1194
|
-
return userID ? `${store}-${this._id}-${userID}` : `${store}-${this._id}`;
|
|
1195
|
-
}
|
|
1196
|
-
isLocalStorageAvailable() {
|
|
1197
|
-
try {
|
|
1198
|
-
const testValue = "__ASGARDEO_AUTH_CORE_LOCAL_STORAGE_TEST__";
|
|
1199
|
-
localStorage.setItem(testValue, testValue);
|
|
1200
|
-
localStorage.removeItem(testValue);
|
|
1201
|
-
return true;
|
|
1202
|
-
} catch (error) {
|
|
1203
|
-
return false;
|
|
1204
|
-
}
|
|
1205
|
-
}
|
|
1206
|
-
async setConfigData(config) {
|
|
1207
|
-
await this.setDataInBulk(this._resolveKey("config_data" /* ConfigData */), config);
|
|
1208
|
-
}
|
|
1209
|
-
async setOIDCProviderMetaData(oidcProviderMetaData) {
|
|
1210
|
-
this.setDataInBulk(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), oidcProviderMetaData);
|
|
1211
|
-
}
|
|
1212
|
-
async setTemporaryData(temporaryData, userID) {
|
|
1213
|
-
this.setDataInBulk(this._resolveKey("temporary_data" /* TemporaryData */, userID), temporaryData);
|
|
1214
|
-
}
|
|
1215
|
-
async setSessionData(sessionData, userID) {
|
|
1216
|
-
this.setDataInBulk(this._resolveKey("session_data" /* SessionData */, userID), sessionData);
|
|
1217
|
-
}
|
|
1218
|
-
async setCustomData(key, customData, userID) {
|
|
1219
|
-
this.setDataInBulk(this._resolveKey(key, userID), customData);
|
|
1220
|
-
}
|
|
1221
|
-
async getConfigData() {
|
|
1222
|
-
return JSON.parse(await this._store.getData(this._resolveKey("config_data" /* ConfigData */)) ?? null);
|
|
1223
|
-
}
|
|
1224
|
-
async getOIDCProviderMetaData() {
|
|
1225
|
-
return JSON.parse(await this._store.getData(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */)) ?? null);
|
|
1226
|
-
}
|
|
1227
|
-
async getTemporaryData(userID) {
|
|
1228
|
-
return JSON.parse(await this._store.getData(this._resolveKey("temporary_data" /* TemporaryData */, userID)) ?? null);
|
|
1229
|
-
}
|
|
1230
|
-
async getSessionData(userID) {
|
|
1231
|
-
return JSON.parse(await this._store.getData(this._resolveKey("session_data" /* SessionData */, userID)) ?? null);
|
|
1232
|
-
}
|
|
1233
|
-
async getCustomData(key, userID) {
|
|
1234
|
-
return JSON.parse(await this._store.getData(this._resolveKey(key, userID)) ?? null);
|
|
1235
|
-
}
|
|
1236
|
-
setSessionStatus(status) {
|
|
1237
|
-
this.isLocalStorageAvailable() && localStorage.setItem(`${ASGARDEO_SESSION_ACTIVE}`, status);
|
|
1238
|
-
}
|
|
1239
|
-
getSessionStatus() {
|
|
1240
|
-
return this.isLocalStorageAvailable() ? localStorage.getItem(`${ASGARDEO_SESSION_ACTIVE}`) ?? "" : "";
|
|
1241
|
-
}
|
|
1242
|
-
removeSessionStatus() {
|
|
1243
|
-
this.isLocalStorageAvailable() && localStorage.removeItem(`${ASGARDEO_SESSION_ACTIVE}`);
|
|
1244
|
-
}
|
|
1245
|
-
async removeConfigData() {
|
|
1246
|
-
await this._store.removeData(this._resolveKey("config_data" /* ConfigData */));
|
|
1247
|
-
}
|
|
1248
|
-
async removeOIDCProviderMetaData() {
|
|
1249
|
-
await this._store.removeData(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */));
|
|
1250
|
-
}
|
|
1251
|
-
async removeTemporaryData(userID) {
|
|
1252
|
-
await this._store.removeData(this._resolveKey("temporary_data" /* TemporaryData */, userID));
|
|
1253
|
-
}
|
|
1254
|
-
async removeSessionData(userID) {
|
|
1255
|
-
await this._store.removeData(this._resolveKey("session_data" /* SessionData */, userID));
|
|
1256
|
-
}
|
|
1257
|
-
async getConfigDataParameter(key) {
|
|
1258
|
-
const data = await this._store.getData(this._resolveKey("config_data" /* ConfigData */));
|
|
1259
|
-
return data && JSON.parse(data)[key];
|
|
1260
|
-
}
|
|
1261
|
-
async getOIDCProviderMetaDataParameter(key) {
|
|
1262
|
-
const data = await this._store.getData(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */));
|
|
1263
|
-
return data && JSON.parse(data)[key];
|
|
1264
|
-
}
|
|
1265
|
-
async getTemporaryDataParameter(key, userID) {
|
|
1266
|
-
const data = await this._store.getData(this._resolveKey("temporary_data" /* TemporaryData */, userID));
|
|
1267
|
-
return data && JSON.parse(data)[key];
|
|
1268
|
-
}
|
|
1269
|
-
async getSessionDataParameter(key, userID) {
|
|
1270
|
-
const data = await this._store.getData(this._resolveKey("session_data" /* SessionData */, userID));
|
|
1271
|
-
return data && JSON.parse(data)[key];
|
|
1272
|
-
}
|
|
1273
|
-
async setConfigDataParameter(key, value) {
|
|
1274
|
-
await this.setValue(this._resolveKey("config_data" /* ConfigData */), key, value);
|
|
1275
|
-
}
|
|
1276
|
-
async setOIDCProviderMetaDataParameter(key, value) {
|
|
1277
|
-
await this.setValue(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), key, value);
|
|
1278
|
-
}
|
|
1279
|
-
async setTemporaryDataParameter(key, value, userID) {
|
|
1280
|
-
await this.setValue(this._resolveKey("temporary_data" /* TemporaryData */, userID), key, value);
|
|
1281
|
-
}
|
|
1282
|
-
async setSessionDataParameter(key, value, userID) {
|
|
1283
|
-
await this.setValue(this._resolveKey("session_data" /* SessionData */, userID), key, value);
|
|
1284
|
-
}
|
|
1285
|
-
async removeConfigDataParameter(key) {
|
|
1286
|
-
await this.removeValue(this._resolveKey("config_data" /* ConfigData */), key);
|
|
1287
|
-
}
|
|
1288
|
-
async removeOIDCProviderMetaDataParameter(key) {
|
|
1289
|
-
await this.removeValue(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), key);
|
|
1290
|
-
}
|
|
1291
|
-
async removeTemporaryDataParameter(key, userID) {
|
|
1292
|
-
await this.removeValue(this._resolveKey("temporary_data" /* TemporaryData */, userID), key);
|
|
1293
|
-
}
|
|
1294
|
-
async removeSessionDataParameter(key, userID) {
|
|
1295
|
-
await this.removeValue(this._resolveKey("session_data" /* SessionData */, userID), key);
|
|
1296
954
|
}
|
|
955
|
+
authorizeRequestParams.set(
|
|
956
|
+
OIDCRequestConstants_default.Params.STATE,
|
|
957
|
+
generateStateParamForRequestCorrelation_default(
|
|
958
|
+
pkceKey,
|
|
959
|
+
customParams ? customParams[OIDCRequestConstants_default.Params.STATE]?.toString() : ""
|
|
960
|
+
)
|
|
961
|
+
);
|
|
962
|
+
return authorizeRequestParams;
|
|
1297
963
|
};
|
|
1298
|
-
|
|
1299
|
-
// src/models/oauth-response.ts
|
|
1300
|
-
var ResponseMode = /* @__PURE__ */ ((ResponseMode2) => {
|
|
1301
|
-
ResponseMode2["FormPost"] = "form_post";
|
|
1302
|
-
ResponseMode2["Query"] = "query";
|
|
1303
|
-
ResponseMode2["Direct"] = "direct";
|
|
1304
|
-
return ResponseMode2;
|
|
1305
|
-
})(ResponseMode || {});
|
|
964
|
+
var getAuthorizeRequestUrlParams_default = getAuthorizeRequestUrlParams;
|
|
1306
965
|
|
|
1307
966
|
// src/__legacy__/client.ts
|
|
1308
967
|
var DefaultConfig = {
|
|
1309
968
|
clockTolerance: 300,
|
|
1310
969
|
enablePKCE: true,
|
|
1311
|
-
responseMode: "query"
|
|
1312
|
-
scope: [ScopeConstants_default.OPENID],
|
|
970
|
+
responseMode: "query",
|
|
1313
971
|
sendCookiesInRequests: true,
|
|
1314
972
|
validateIDToken: true,
|
|
1315
973
|
validateIDTokenIssuer: true
|
|
@@ -1331,8 +989,12 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1331
989
|
* @preserve
|
|
1332
990
|
*/
|
|
1333
991
|
constructor() {
|
|
1334
|
-
__publicField(this, "
|
|
1335
|
-
__publicField(this, "
|
|
992
|
+
__publicField(this, "_storageManager");
|
|
993
|
+
__publicField(this, "_config");
|
|
994
|
+
__publicField(this, "_oidcProviderMetaData");
|
|
995
|
+
__publicField(this, "_authenticationHelper");
|
|
996
|
+
__publicField(this, "_cryptoUtils");
|
|
997
|
+
__publicField(this, "_cryptoHelper");
|
|
1336
998
|
}
|
|
1337
999
|
/**
|
|
1338
1000
|
*
|
|
@@ -1342,8 +1004,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1342
1004
|
*
|
|
1343
1005
|
* @example
|
|
1344
1006
|
* const config = \{
|
|
1345
|
-
*
|
|
1346
|
-
*
|
|
1007
|
+
* afterSignInUrl: "http://localhost:3000/sign-in",
|
|
1008
|
+
* clientId: "client ID",
|
|
1347
1009
|
* baseUrl: "https://localhost:9443"
|
|
1348
1010
|
* \}
|
|
1349
1011
|
*
|
|
@@ -1354,7 +1016,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1354
1016
|
* @preserve
|
|
1355
1017
|
*/
|
|
1356
1018
|
async initialize(config, store, cryptoUtils, instanceID) {
|
|
1357
|
-
const clientId = config.
|
|
1019
|
+
const clientId = config.clientId;
|
|
1358
1020
|
if (!_AsgardeoAuthClient._instanceID) {
|
|
1359
1021
|
_AsgardeoAuthClient._instanceID = 0;
|
|
1360
1022
|
} else {
|
|
@@ -1364,37 +1026,38 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1364
1026
|
_AsgardeoAuthClient._instanceID = instanceID;
|
|
1365
1027
|
}
|
|
1366
1028
|
if (!clientId) {
|
|
1367
|
-
this.
|
|
1029
|
+
this._storageManager = new StorageManager_default(`instance_${_AsgardeoAuthClient._instanceID}`, store);
|
|
1368
1030
|
} else {
|
|
1369
|
-
this.
|
|
1031
|
+
this._storageManager = new StorageManager_default(`instance_${_AsgardeoAuthClient._instanceID}-${clientId}`, store);
|
|
1370
1032
|
}
|
|
1371
|
-
this.
|
|
1372
|
-
|
|
1373
|
-
|
|
1033
|
+
this._cryptoUtils = cryptoUtils;
|
|
1034
|
+
this._cryptoHelper = new IsomorphicCrypto(cryptoUtils);
|
|
1035
|
+
this._authenticationHelper = new AuthenticationHelper(this._storageManager, this._cryptoHelper);
|
|
1036
|
+
this._config = async () => await this._storageManager.getConfigData();
|
|
1037
|
+
this._oidcProviderMetaData = async () => await this._storageManager.loadOpenIDProviderConfiguration();
|
|
1038
|
+
_AsgardeoAuthClient._authenticationHelper = this._authenticationHelper;
|
|
1039
|
+
await this._storageManager.setConfigData({
|
|
1374
1040
|
...DefaultConfig,
|
|
1375
1041
|
...config,
|
|
1376
|
-
scope:
|
|
1377
|
-
...DefaultConfig.scope ?? [],
|
|
1378
|
-
...config.scope?.filter((scope) => !DefaultConfig?.scope?.includes(scope)) ?? []
|
|
1379
|
-
]
|
|
1042
|
+
scope: processOpenIDScopes_default(config.scopes)
|
|
1380
1043
|
});
|
|
1381
1044
|
}
|
|
1382
1045
|
/**
|
|
1383
|
-
* This method returns the `
|
|
1046
|
+
* This method returns the `StorageManager` object that allows you to access authentication data.
|
|
1384
1047
|
*
|
|
1385
|
-
* @returns - The `
|
|
1048
|
+
* @returns - The `StorageManager` object.
|
|
1386
1049
|
*
|
|
1387
1050
|
* @example
|
|
1388
1051
|
* ```
|
|
1389
|
-
* const data = auth.
|
|
1052
|
+
* const data = auth.getStorageManager();
|
|
1390
1053
|
* ```
|
|
1391
1054
|
*
|
|
1392
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
1055
|
+
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getStorageManager}
|
|
1393
1056
|
*
|
|
1394
1057
|
* @preserve
|
|
1395
1058
|
*/
|
|
1396
|
-
|
|
1397
|
-
return this.
|
|
1059
|
+
getStorageManager() {
|
|
1060
|
+
return this._storageManager;
|
|
1398
1061
|
}
|
|
1399
1062
|
/**
|
|
1400
1063
|
* This method returns the `instanceID` variable of the given instance.
|
|
@@ -1403,82 +1066,90 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1403
1066
|
*
|
|
1404
1067
|
* @example
|
|
1405
1068
|
* ```
|
|
1406
|
-
* const instanceId = auth.
|
|
1069
|
+
* const instanceId = auth.getInstanceId();
|
|
1407
1070
|
* ```
|
|
1408
1071
|
*
|
|
1409
1072
|
* @preserve
|
|
1410
1073
|
*/
|
|
1411
|
-
|
|
1074
|
+
getInstanceId() {
|
|
1412
1075
|
return _AsgardeoAuthClient._instanceID;
|
|
1413
1076
|
}
|
|
1414
|
-
/**
|
|
1415
|
-
* This is an async method that returns a Promise that resolves with the authorization URL parameters.
|
|
1416
|
-
*
|
|
1417
|
-
* @param config - (Optional) A config object to force initialization and pass
|
|
1418
|
-
* custom path parameters such as the `fidp` parameter.
|
|
1419
|
-
* @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1420
|
-
* scenarios where each user should be uniquely identified.
|
|
1421
|
-
*
|
|
1422
|
-
* @returns - A promise that resolves with the authorization URL parameters.
|
|
1423
|
-
*
|
|
1424
|
-
* @example
|
|
1425
|
-
* ```
|
|
1426
|
-
* auth.getAuthorizationURLParams().then((params)=>{
|
|
1427
|
-
* // console.log(params);
|
|
1428
|
-
* }).catch((error)=>{
|
|
1429
|
-
* // console.error(error);
|
|
1430
|
-
* });
|
|
1431
|
-
* ```
|
|
1432
|
-
*
|
|
1433
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getAuthorizationURLParams}
|
|
1434
|
-
*
|
|
1435
|
-
* @preserve
|
|
1436
|
-
*/
|
|
1437
|
-
async getAuthorizationURLParams(config, userID) {
|
|
1438
|
-
const authRequestConfig = { ...config };
|
|
1439
|
-
delete authRequestConfig?.forceInit;
|
|
1440
|
-
if (await this._dataLayer.getTemporaryDataParameter(
|
|
1441
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED
|
|
1442
|
-
)) {
|
|
1443
|
-
return this._authenticationCore.getAuthorizationURLParams(authRequestConfig, userID);
|
|
1444
|
-
}
|
|
1445
|
-
return this._authenticationCore.getOIDCProviderMetaData(config?.forceInit).then(() => {
|
|
1446
|
-
return this._authenticationCore.getAuthorizationURLParams(authRequestConfig, userID);
|
|
1447
|
-
});
|
|
1448
|
-
}
|
|
1449
1077
|
/**
|
|
1450
1078
|
* This is an async method that returns a Promise that resolves with the authorization URL.
|
|
1451
1079
|
*
|
|
1452
1080
|
* @param config - (Optional) A config object to force initialization and pass
|
|
1453
1081
|
* custom path parameters such as the fidp parameter.
|
|
1454
|
-
* @param
|
|
1082
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1455
1083
|
* scenarios where each user should be uniquely identified.
|
|
1456
1084
|
*
|
|
1457
1085
|
* @returns - A promise that resolves with the authorization URL.
|
|
1458
1086
|
*
|
|
1459
1087
|
* @example
|
|
1460
1088
|
* ```
|
|
1461
|
-
* auth.
|
|
1089
|
+
* auth.getSignInUrl().then((url)=>{
|
|
1462
1090
|
* // console.log(url);
|
|
1463
1091
|
* }).catch((error)=>{
|
|
1464
1092
|
* // console.error(error);
|
|
1465
1093
|
* });
|
|
1466
1094
|
* ```
|
|
1467
1095
|
*
|
|
1468
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
1096
|
+
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getSignInUrl}
|
|
1469
1097
|
*
|
|
1470
1098
|
* @preserve
|
|
1471
1099
|
*/
|
|
1472
|
-
async
|
|
1473
|
-
const authRequestConfig = { ...
|
|
1100
|
+
async getSignInUrl(requestConfig, userId) {
|
|
1101
|
+
const authRequestConfig = { ...requestConfig };
|
|
1474
1102
|
delete authRequestConfig?.forceInit;
|
|
1475
|
-
|
|
1103
|
+
const __TODO__ = async () => {
|
|
1104
|
+
const authorizeEndpoint = await this._storageManager.getOIDCProviderMetaDataParameter(
|
|
1105
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.AUTHORIZATION
|
|
1106
|
+
);
|
|
1107
|
+
if (!authorizeEndpoint || authorizeEndpoint.trim().length === 0) {
|
|
1108
|
+
throw new AsgardeoAuthException(
|
|
1109
|
+
"JS-AUTH_CORE-GAU-NF01",
|
|
1110
|
+
"No authorization endpoint found.",
|
|
1111
|
+
"No authorization endpoint was found in the OIDC provider meta data from the well-known endpoint or the authorization endpoint passed to the SDK is empty."
|
|
1112
|
+
);
|
|
1113
|
+
}
|
|
1114
|
+
const authorizeRequest = new URL(authorizeEndpoint);
|
|
1115
|
+
const configData = await this._config();
|
|
1116
|
+
const tempStore = await this._storageManager.getTemporaryData(userId);
|
|
1117
|
+
const pkceKey = await generatePkceStorageKey_default(tempStore);
|
|
1118
|
+
let codeVerifier;
|
|
1119
|
+
let codeChallenge;
|
|
1120
|
+
if (configData.enablePKCE) {
|
|
1121
|
+
codeVerifier = this._cryptoHelper?.getCodeVerifier();
|
|
1122
|
+
codeChallenge = this._cryptoHelper?.getCodeChallenge(codeVerifier);
|
|
1123
|
+
await this._storageManager.setTemporaryDataParameter(pkceKey, codeVerifier, userId);
|
|
1124
|
+
}
|
|
1125
|
+
if (authRequestConfig["client_secret"]) {
|
|
1126
|
+
authRequestConfig["client_secret"] = configData.clientSecret;
|
|
1127
|
+
}
|
|
1128
|
+
const authorizeRequestParams = getAuthorizeRequestUrlParams_default(
|
|
1129
|
+
{
|
|
1130
|
+
redirectUri: configData.afterSignInUrl,
|
|
1131
|
+
clientId: configData.clientId,
|
|
1132
|
+
scopes: processOpenIDScopes_default(configData.scopes),
|
|
1133
|
+
responseMode: configData.responseMode,
|
|
1134
|
+
codeChallengeMethod: PKCEConstants_default.DEFAULT_CODE_CHALLENGE_METHOD,
|
|
1135
|
+
codeChallenge,
|
|
1136
|
+
prompt: configData.prompt
|
|
1137
|
+
},
|
|
1138
|
+
{ key: pkceKey },
|
|
1139
|
+
authRequestConfig
|
|
1140
|
+
);
|
|
1141
|
+
for (const [key, value] of authorizeRequestParams.entries()) {
|
|
1142
|
+
authorizeRequest.searchParams.append(key, value);
|
|
1143
|
+
}
|
|
1144
|
+
return authorizeRequest.toString();
|
|
1145
|
+
};
|
|
1146
|
+
if (await this._storageManager.getTemporaryDataParameter(
|
|
1476
1147
|
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED
|
|
1477
1148
|
)) {
|
|
1478
|
-
return
|
|
1149
|
+
return __TODO__();
|
|
1479
1150
|
}
|
|
1480
|
-
return this.
|
|
1481
|
-
return
|
|
1151
|
+
return this.loadOpenIDProviderConfiguration(requestConfig?.forceInit).then(() => {
|
|
1152
|
+
return __TODO__();
|
|
1482
1153
|
});
|
|
1483
1154
|
}
|
|
1484
1155
|
/**
|
|
@@ -1487,7 +1158,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1487
1158
|
*
|
|
1488
1159
|
* @param authorizationCode - The authorization code.
|
|
1489
1160
|
* @param sessionState - The session state.
|
|
1490
|
-
* @param
|
|
1161
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1491
1162
|
* scenarios where each user should be uniquely identified.
|
|
1492
1163
|
*
|
|
1493
1164
|
* @returns - A Promise that resolves with the token response.
|
|
@@ -1506,32 +1177,139 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1506
1177
|
*
|
|
1507
1178
|
* @preserve
|
|
1508
1179
|
*/
|
|
1509
|
-
async requestAccessToken(authorizationCode, sessionState, state,
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1180
|
+
async requestAccessToken(authorizationCode, sessionState, state, userId, tokenRequestConfig) {
|
|
1181
|
+
const __TODO__ = async () => {
|
|
1182
|
+
const tokenEndpoint = (await this._oidcProviderMetaData()).token_endpoint;
|
|
1183
|
+
const configData = await this._config();
|
|
1184
|
+
if (!tokenEndpoint || tokenEndpoint.trim().length === 0) {
|
|
1185
|
+
throw new AsgardeoAuthException(
|
|
1186
|
+
"JS-AUTH_CORE-RAT1-NF01",
|
|
1187
|
+
"Token endpoint not found.",
|
|
1188
|
+
"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."
|
|
1189
|
+
);
|
|
1190
|
+
}
|
|
1191
|
+
sessionState && await this._storageManager.setSessionDataParameter(
|
|
1192
|
+
OIDCRequestConstants_default.Params.SESSION_STATE,
|
|
1515
1193
|
sessionState,
|
|
1516
|
-
|
|
1517
|
-
userID,
|
|
1518
|
-
tokenRequestConfig
|
|
1194
|
+
userId
|
|
1519
1195
|
);
|
|
1196
|
+
const body = new URLSearchParams();
|
|
1197
|
+
body.set("client_id", configData.clientId);
|
|
1198
|
+
if (configData.clientSecret && configData.clientSecret.trim().length > 0) {
|
|
1199
|
+
body.set("client_secret", configData.clientSecret);
|
|
1200
|
+
}
|
|
1201
|
+
const code = authorizationCode;
|
|
1202
|
+
body.set("code", code);
|
|
1203
|
+
body.set("grant_type", "authorization_code");
|
|
1204
|
+
body.set("redirect_uri", configData.afterSignInUrl);
|
|
1205
|
+
if (tokenRequestConfig?.params) {
|
|
1206
|
+
Object.entries(tokenRequestConfig.params).forEach(([key, value]) => {
|
|
1207
|
+
body.append(key, value);
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
if (configData.enablePKCE) {
|
|
1211
|
+
body.set(
|
|
1212
|
+
"code_verifier",
|
|
1213
|
+
`${await this._storageManager.getTemporaryDataParameter(extractPkceStorageKeyFromState_default(state), userId)}`
|
|
1214
|
+
);
|
|
1215
|
+
await this._storageManager.removeTemporaryDataParameter(extractPkceStorageKeyFromState_default(state), userId);
|
|
1216
|
+
}
|
|
1217
|
+
let tokenResponse;
|
|
1218
|
+
try {
|
|
1219
|
+
tokenResponse = await fetch(tokenEndpoint, {
|
|
1220
|
+
body,
|
|
1221
|
+
credentials: configData.sendCookiesInRequests ? "include" : "same-origin",
|
|
1222
|
+
headers: {
|
|
1223
|
+
Accept: "application/json",
|
|
1224
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
1225
|
+
},
|
|
1226
|
+
method: "POST"
|
|
1227
|
+
});
|
|
1228
|
+
} catch (error) {
|
|
1229
|
+
throw new AsgardeoAuthException(
|
|
1230
|
+
"JS-AUTH_CORE-RAT1-NE02",
|
|
1231
|
+
"Requesting access token failed",
|
|
1232
|
+
error ?? "The request to get the access token from the server failed."
|
|
1233
|
+
);
|
|
1234
|
+
}
|
|
1235
|
+
if (!tokenResponse.ok) {
|
|
1236
|
+
throw new AsgardeoAuthException(
|
|
1237
|
+
"JS-AUTH_CORE-RAT1-HE03",
|
|
1238
|
+
`Requesting access token failed with ${tokenResponse.statusText}`,
|
|
1239
|
+
await tokenResponse.json()
|
|
1240
|
+
);
|
|
1241
|
+
}
|
|
1242
|
+
return await this._authenticationHelper.handleTokenResponse(tokenResponse, userId);
|
|
1243
|
+
};
|
|
1244
|
+
if (await this._storageManager.getTemporaryDataParameter(
|
|
1245
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED
|
|
1246
|
+
)) {
|
|
1247
|
+
return __TODO__();
|
|
1520
1248
|
}
|
|
1521
|
-
return this.
|
|
1522
|
-
return
|
|
1523
|
-
authorizationCode,
|
|
1524
|
-
sessionState,
|
|
1525
|
-
state,
|
|
1526
|
-
userID,
|
|
1527
|
-
tokenRequestConfig
|
|
1528
|
-
);
|
|
1249
|
+
return this.loadOpenIDProviderConfiguration(false).then(() => {
|
|
1250
|
+
return __TODO__();
|
|
1529
1251
|
});
|
|
1530
1252
|
}
|
|
1253
|
+
async loadOpenIDProviderConfiguration(forceInit) {
|
|
1254
|
+
const configData = await this._config();
|
|
1255
|
+
if (!forceInit && await this._storageManager.getTemporaryDataParameter(
|
|
1256
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED
|
|
1257
|
+
)) {
|
|
1258
|
+
return Promise.resolve();
|
|
1259
|
+
}
|
|
1260
|
+
const wellKnownEndpoint = configData.wellKnownEndpoint;
|
|
1261
|
+
if (wellKnownEndpoint) {
|
|
1262
|
+
let response;
|
|
1263
|
+
try {
|
|
1264
|
+
response = await fetch(wellKnownEndpoint);
|
|
1265
|
+
if (response.status !== 200 || !response.ok) {
|
|
1266
|
+
throw new Error();
|
|
1267
|
+
}
|
|
1268
|
+
} catch {
|
|
1269
|
+
throw new AsgardeoAuthException(
|
|
1270
|
+
"JS-AUTH_CORE-GOPMD-HE01",
|
|
1271
|
+
"Invalid well-known response",
|
|
1272
|
+
"The well known endpoint response has been failed with an error."
|
|
1273
|
+
);
|
|
1274
|
+
}
|
|
1275
|
+
await this._storageManager.setOIDCProviderMetaData(
|
|
1276
|
+
await this._authenticationHelper.resolveEndpoints(await response.json())
|
|
1277
|
+
);
|
|
1278
|
+
await this._storageManager.setTemporaryDataParameter(
|
|
1279
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,
|
|
1280
|
+
true
|
|
1281
|
+
);
|
|
1282
|
+
return Promise.resolve();
|
|
1283
|
+
} else if (configData.baseUrl) {
|
|
1284
|
+
try {
|
|
1285
|
+
await this._storageManager.setOIDCProviderMetaData(
|
|
1286
|
+
await this._authenticationHelper.resolveEndpointsByBaseURL()
|
|
1287
|
+
);
|
|
1288
|
+
} catch (error) {
|
|
1289
|
+
throw new AsgardeoAuthException(
|
|
1290
|
+
"JS-AUTH_CORE-GOPMD-IV02",
|
|
1291
|
+
"Resolving endpoints failed.",
|
|
1292
|
+
error ?? "Resolving endpoints by base url failed."
|
|
1293
|
+
);
|
|
1294
|
+
}
|
|
1295
|
+
await this._storageManager.setTemporaryDataParameter(
|
|
1296
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,
|
|
1297
|
+
true
|
|
1298
|
+
);
|
|
1299
|
+
return Promise.resolve();
|
|
1300
|
+
} else {
|
|
1301
|
+
await this._storageManager.setOIDCProviderMetaData(await this._authenticationHelper.resolveEndpointsExplicitly());
|
|
1302
|
+
await this._storageManager.setTemporaryDataParameter(
|
|
1303
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,
|
|
1304
|
+
true
|
|
1305
|
+
);
|
|
1306
|
+
return Promise.resolve();
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1531
1309
|
/**
|
|
1532
1310
|
* This method returns the sign-out URL.
|
|
1533
1311
|
*
|
|
1534
|
-
* @param
|
|
1312
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1535
1313
|
* scenarios where each user should be uniquely identified.
|
|
1536
1314
|
*
|
|
1537
1315
|
* **This doesn't clear the authentication data.**
|
|
@@ -1540,15 +1318,48 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1540
1318
|
*
|
|
1541
1319
|
* @example
|
|
1542
1320
|
* ```
|
|
1543
|
-
* const signOutUrl = await auth.
|
|
1321
|
+
* const signOutUrl = await auth.getSignOutUrl();
|
|
1544
1322
|
* ```
|
|
1545
1323
|
*
|
|
1546
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
1324
|
+
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getSignOutUrl}
|
|
1547
1325
|
*
|
|
1548
1326
|
* @preserve
|
|
1549
1327
|
*/
|
|
1550
|
-
async
|
|
1551
|
-
|
|
1328
|
+
async getSignOutUrl(userId) {
|
|
1329
|
+
const logoutEndpoint = (await this._oidcProviderMetaData())?.end_session_endpoint;
|
|
1330
|
+
const configData = await this._config();
|
|
1331
|
+
if (!logoutEndpoint || logoutEndpoint.trim().length === 0) {
|
|
1332
|
+
throw new AsgardeoAuthException(
|
|
1333
|
+
"JS-AUTH_CORE-GSOU-NF01",
|
|
1334
|
+
"Sign-out endpoint not found.",
|
|
1335
|
+
"No sign-out endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the sign-out endpoint passed to the SDK is empty."
|
|
1336
|
+
);
|
|
1337
|
+
}
|
|
1338
|
+
const callbackURL = configData?.afterSignOutUrl ?? configData?.afterSignInUrl;
|
|
1339
|
+
if (!callbackURL || callbackURL.trim().length === 0) {
|
|
1340
|
+
throw new AsgardeoAuthException(
|
|
1341
|
+
"JS-AUTH_CORE-GSOU-NF03",
|
|
1342
|
+
"No sign-out redirect URL found.",
|
|
1343
|
+
"The sign-out redirect URL cannot be found or the URL passed to the SDK is empty. No sign-in redirect URL has been found either. "
|
|
1344
|
+
);
|
|
1345
|
+
}
|
|
1346
|
+
const queryParams = new URLSearchParams();
|
|
1347
|
+
queryParams.set("post_logout_redirect_uri", callbackURL);
|
|
1348
|
+
if (configData.sendIdTokenInLogoutRequest) {
|
|
1349
|
+
const idToken = (await this._storageManager.getSessionData(userId))?.id_token;
|
|
1350
|
+
if (!idToken || idToken.trim().length === 0) {
|
|
1351
|
+
throw new AsgardeoAuthException(
|
|
1352
|
+
"JS-AUTH_CORE-GSOU-NF02",
|
|
1353
|
+
"ID token not found.",
|
|
1354
|
+
"No ID token could be found. Either the session information is lost or you have not signed in."
|
|
1355
|
+
);
|
|
1356
|
+
}
|
|
1357
|
+
queryParams.set("id_token_hint", idToken);
|
|
1358
|
+
} else {
|
|
1359
|
+
queryParams.set("client_id", configData.clientId);
|
|
1360
|
+
}
|
|
1361
|
+
queryParams.set("state", OIDCRequestConstants_default.Params.SIGN_OUT_SUCCESS);
|
|
1362
|
+
return `${logoutEndpoint}?${queryParams.toString()}`;
|
|
1552
1363
|
}
|
|
1553
1364
|
/**
|
|
1554
1365
|
* This method returns OIDC service endpoints that are fetched from the `.well-known` endpoint.
|
|
@@ -1557,75 +1368,103 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1557
1368
|
*
|
|
1558
1369
|
* @example
|
|
1559
1370
|
* ```
|
|
1560
|
-
* const endpoints = await auth.
|
|
1371
|
+
* const endpoints = await auth.getOpenIDProviderEndpoints();
|
|
1561
1372
|
* ```
|
|
1562
1373
|
*
|
|
1563
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
1374
|
+
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getOpenIDProviderEndpoints}
|
|
1564
1375
|
*
|
|
1565
1376
|
* @preserve
|
|
1566
1377
|
*/
|
|
1567
|
-
async
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1378
|
+
async getOpenIDProviderEndpoints() {
|
|
1379
|
+
const oidcProviderMetaData = await this._oidcProviderMetaData();
|
|
1380
|
+
return {
|
|
1381
|
+
authorizationEndpoint: oidcProviderMetaData.authorization_endpoint ?? "",
|
|
1382
|
+
checkSessionIframe: oidcProviderMetaData.check_session_iframe ?? "",
|
|
1383
|
+
endSessionEndpoint: oidcProviderMetaData.end_session_endpoint ?? "",
|
|
1384
|
+
introspectionEndpoint: oidcProviderMetaData.introspection_endpoint ?? "",
|
|
1385
|
+
issuer: oidcProviderMetaData.issuer ?? "",
|
|
1386
|
+
jwksUri: oidcProviderMetaData.jwks_uri ?? "",
|
|
1387
|
+
registrationEndpoint: oidcProviderMetaData.registration_endpoint ?? "",
|
|
1388
|
+
revocationEndpoint: oidcProviderMetaData.revocation_endpoint ?? "",
|
|
1389
|
+
tokenEndpoint: oidcProviderMetaData.token_endpoint ?? "",
|
|
1390
|
+
userinfoEndpoint: oidcProviderMetaData.userinfo_endpoint ?? ""
|
|
1391
|
+
};
|
|
1392
|
+
}
|
|
1393
|
+
/**
|
|
1571
1394
|
* This method decodes the payload of the ID token and returns it.
|
|
1572
1395
|
*
|
|
1573
|
-
* @param
|
|
1396
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1574
1397
|
* scenarios where each user should be uniquely identified.
|
|
1575
1398
|
*
|
|
1576
1399
|
* @returns - A Promise that resolves with the decoded ID token payload.
|
|
1577
1400
|
*
|
|
1578
1401
|
* @example
|
|
1579
1402
|
* ```
|
|
1580
|
-
* const decodedIdToken = await auth.
|
|
1403
|
+
* const decodedIdToken = await auth.getDecodedIdToken();
|
|
1581
1404
|
* ```
|
|
1582
1405
|
*
|
|
1583
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
1406
|
+
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getDecodedIdToken}
|
|
1584
1407
|
*
|
|
1585
1408
|
* @preserve
|
|
1586
1409
|
*/
|
|
1587
|
-
async
|
|
1588
|
-
|
|
1410
|
+
async getDecodedIdToken(userId) {
|
|
1411
|
+
const idToken = (await this._storageManager.getSessionData(userId)).id_token;
|
|
1412
|
+
const payload = this._cryptoHelper.decodeIdToken(idToken);
|
|
1413
|
+
return payload;
|
|
1589
1414
|
}
|
|
1590
1415
|
/**
|
|
1591
1416
|
* This method returns the ID token.
|
|
1592
1417
|
*
|
|
1593
|
-
* @param
|
|
1418
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1594
1419
|
* scenarios where each user should be uniquely identified.
|
|
1595
1420
|
*
|
|
1596
1421
|
* @returns - A Promise that resolves with the ID token.
|
|
1597
1422
|
*
|
|
1598
1423
|
* @example
|
|
1599
1424
|
* ```
|
|
1600
|
-
* const idToken = await auth.
|
|
1425
|
+
* const idToken = await auth.getIdToken();
|
|
1601
1426
|
* ```
|
|
1602
1427
|
*
|
|
1603
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
1428
|
+
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getIdToken}
|
|
1604
1429
|
*
|
|
1605
1430
|
* @preserve
|
|
1606
1431
|
*/
|
|
1607
|
-
async
|
|
1608
|
-
return this.
|
|
1432
|
+
async getIdToken(userId) {
|
|
1433
|
+
return (await this._storageManager.getSessionData(userId)).id_token;
|
|
1609
1434
|
}
|
|
1610
1435
|
/**
|
|
1611
1436
|
* This method returns the basic user information obtained from the ID token.
|
|
1612
1437
|
*
|
|
1613
|
-
* @param
|
|
1438
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1614
1439
|
* scenarios where each user should be uniquely identified.
|
|
1615
1440
|
*
|
|
1616
1441
|
* @returns - A Promise that resolves with an object containing the basic user information.
|
|
1617
1442
|
*
|
|
1618
1443
|
* @example
|
|
1619
1444
|
* ```
|
|
1620
|
-
* const userInfo = await auth.
|
|
1445
|
+
* const userInfo = await auth.getUser();
|
|
1621
1446
|
* ```
|
|
1622
1447
|
*
|
|
1623
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
1448
|
+
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getUser}
|
|
1624
1449
|
*
|
|
1625
1450
|
* @preserve
|
|
1626
1451
|
*/
|
|
1627
|
-
async
|
|
1628
|
-
|
|
1452
|
+
async getUser(userId) {
|
|
1453
|
+
const sessionData = await this._storageManager.getSessionData(userId);
|
|
1454
|
+
const authenticatedUser = this._authenticationHelper.getAuthenticatedUserInfo(sessionData?.id_token);
|
|
1455
|
+
Object.keys(authenticatedUser).forEach((key) => {
|
|
1456
|
+
if (authenticatedUser[key] === void 0 || authenticatedUser[key] === "" || authenticatedUser[key] === null) {
|
|
1457
|
+
delete authenticatedUser[key];
|
|
1458
|
+
}
|
|
1459
|
+
});
|
|
1460
|
+
return authenticatedUser;
|
|
1461
|
+
}
|
|
1462
|
+
async getUserSession(userId) {
|
|
1463
|
+
const sessionData = await this._storageManager.getSessionData(userId);
|
|
1464
|
+
return {
|
|
1465
|
+
scopes: sessionData?.scope?.split(" "),
|
|
1466
|
+
sessionState: sessionData?.session_state ?? ""
|
|
1467
|
+
};
|
|
1629
1468
|
}
|
|
1630
1469
|
/**
|
|
1631
1470
|
* This method returns the crypto helper object.
|
|
@@ -1637,17 +1476,17 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1637
1476
|
* const cryptoHelper = await auth.IsomorphicCrypto();
|
|
1638
1477
|
* ```
|
|
1639
1478
|
*
|
|
1640
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
1479
|
+
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getCrypto}
|
|
1641
1480
|
*
|
|
1642
1481
|
* @preserve
|
|
1643
1482
|
*/
|
|
1644
|
-
async
|
|
1645
|
-
return this.
|
|
1483
|
+
async getCrypto() {
|
|
1484
|
+
return this._cryptoHelper;
|
|
1646
1485
|
}
|
|
1647
1486
|
/**
|
|
1648
1487
|
* This method revokes the access token.
|
|
1649
1488
|
*
|
|
1650
|
-
* @param
|
|
1489
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1651
1490
|
* scenarios where each user should be uniquely identified.
|
|
1652
1491
|
*
|
|
1653
1492
|
* **This method also clears the authentication data.**
|
|
@@ -1667,14 +1506,56 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1667
1506
|
*
|
|
1668
1507
|
* @preserve
|
|
1669
1508
|
*/
|
|
1670
|
-
revokeAccessToken(
|
|
1671
|
-
|
|
1509
|
+
async revokeAccessToken(userId) {
|
|
1510
|
+
const revokeTokenEndpoint = (await this._oidcProviderMetaData()).revocation_endpoint;
|
|
1511
|
+
const configData = await this._config();
|
|
1512
|
+
if (!revokeTokenEndpoint || revokeTokenEndpoint.trim().length === 0) {
|
|
1513
|
+
throw new AsgardeoAuthException(
|
|
1514
|
+
"JS-AUTH_CORE-RAT3-NF01",
|
|
1515
|
+
"No revoke access token endpoint found.",
|
|
1516
|
+
"No revoke access token endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the revoke access token endpoint passed to the SDK is empty."
|
|
1517
|
+
);
|
|
1518
|
+
}
|
|
1519
|
+
const body = [];
|
|
1520
|
+
body.push(`client_id=${configData.clientId}`);
|
|
1521
|
+
body.push(`token=${(await this._storageManager.getSessionData(userId)).access_token}`);
|
|
1522
|
+
body.push("token_type_hint=access_token");
|
|
1523
|
+
if (configData.clientSecret && configData.clientSecret.trim().length > 0) {
|
|
1524
|
+
body.push(`client_secret=${configData.clientSecret}`);
|
|
1525
|
+
}
|
|
1526
|
+
let response;
|
|
1527
|
+
try {
|
|
1528
|
+
response = await fetch(revokeTokenEndpoint, {
|
|
1529
|
+
body: body.join("&"),
|
|
1530
|
+
credentials: configData.sendCookiesInRequests ? "include" : "same-origin",
|
|
1531
|
+
headers: {
|
|
1532
|
+
Accept: "application/json",
|
|
1533
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
1534
|
+
},
|
|
1535
|
+
method: "POST"
|
|
1536
|
+
});
|
|
1537
|
+
} catch (error) {
|
|
1538
|
+
throw new AsgardeoAuthException(
|
|
1539
|
+
"JS-AUTH_CORE-RAT3-NE02",
|
|
1540
|
+
"The request to revoke access token failed.",
|
|
1541
|
+
error ?? "The request sent to revoke the access token failed."
|
|
1542
|
+
);
|
|
1543
|
+
}
|
|
1544
|
+
if (response.status !== 200 || !response.ok) {
|
|
1545
|
+
throw new AsgardeoAuthException(
|
|
1546
|
+
"JS-AUTH_CORE-RAT3-HE03",
|
|
1547
|
+
`Invalid response status received for revoke access token request (${response.statusText}).`,
|
|
1548
|
+
await response.json()
|
|
1549
|
+
);
|
|
1550
|
+
}
|
|
1551
|
+
this._authenticationHelper.clearSession(userId);
|
|
1552
|
+
return Promise.resolve(response);
|
|
1672
1553
|
}
|
|
1673
1554
|
/**
|
|
1674
1555
|
* This method refreshes the access token and returns a Promise that resolves with the new access
|
|
1675
1556
|
* token and other relevant data.
|
|
1676
1557
|
*
|
|
1677
|
-
* @param
|
|
1558
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1678
1559
|
* scenarios where each user should be uniquely identified.
|
|
1679
1560
|
*
|
|
1680
1561
|
* @returns - A Promise that resolves with the token response.
|
|
@@ -1692,13 +1573,62 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1692
1573
|
*
|
|
1693
1574
|
* @preserve
|
|
1694
1575
|
*/
|
|
1695
|
-
refreshAccessToken(
|
|
1696
|
-
|
|
1576
|
+
async refreshAccessToken(userId) {
|
|
1577
|
+
const tokenEndpoint = (await this._oidcProviderMetaData()).token_endpoint;
|
|
1578
|
+
const configData = await this._config();
|
|
1579
|
+
const sessionData = await this._storageManager.getSessionData(userId);
|
|
1580
|
+
if (!sessionData.refresh_token) {
|
|
1581
|
+
throw new AsgardeoAuthException(
|
|
1582
|
+
"JS-AUTH_CORE-RAT2-NF01",
|
|
1583
|
+
"No refresh token found.",
|
|
1584
|
+
"There was no refresh token found. Asgardeo doesn't return a refresh token if the refresh token grant is not enabled."
|
|
1585
|
+
);
|
|
1586
|
+
}
|
|
1587
|
+
if (!tokenEndpoint || tokenEndpoint.trim().length === 0) {
|
|
1588
|
+
throw new AsgardeoAuthException(
|
|
1589
|
+
"JS-AUTH_CORE-RAT2-NF02",
|
|
1590
|
+
"No refresh token endpoint found.",
|
|
1591
|
+
"No refresh token endpoint was in the OIDC provider meta data returned by the well-known endpoint or the refresh token endpoint passed to the SDK is empty."
|
|
1592
|
+
);
|
|
1593
|
+
}
|
|
1594
|
+
const body = [];
|
|
1595
|
+
body.push(`client_id=${configData.clientId}`);
|
|
1596
|
+
body.push(`refresh_token=${sessionData.refresh_token}`);
|
|
1597
|
+
body.push("grant_type=refresh_token");
|
|
1598
|
+
if (configData.clientSecret && configData.clientSecret.trim().length > 0) {
|
|
1599
|
+
body.push(`client_secret=${configData.clientSecret}`);
|
|
1600
|
+
}
|
|
1601
|
+
let tokenResponse;
|
|
1602
|
+
try {
|
|
1603
|
+
tokenResponse = await fetch(tokenEndpoint, {
|
|
1604
|
+
body: body.join("&"),
|
|
1605
|
+
credentials: configData.sendCookiesInRequests ? "include" : "same-origin",
|
|
1606
|
+
headers: {
|
|
1607
|
+
Accept: "application/json",
|
|
1608
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
1609
|
+
},
|
|
1610
|
+
method: "POST"
|
|
1611
|
+
});
|
|
1612
|
+
} catch (error) {
|
|
1613
|
+
throw new AsgardeoAuthException(
|
|
1614
|
+
"JS-AUTH_CORE-RAT2-NR03",
|
|
1615
|
+
"Refresh access token request failed.",
|
|
1616
|
+
error ?? "The request to refresh the access token failed."
|
|
1617
|
+
);
|
|
1618
|
+
}
|
|
1619
|
+
if (!tokenResponse.ok) {
|
|
1620
|
+
throw new AsgardeoAuthException(
|
|
1621
|
+
"JS-AUTH_CORE-RAT2-HE04",
|
|
1622
|
+
`Refreshing access token failed with ${tokenResponse.statusText}`,
|
|
1623
|
+
await tokenResponse.json()
|
|
1624
|
+
);
|
|
1625
|
+
}
|
|
1626
|
+
return this._authenticationHelper.handleTokenResponse(tokenResponse, userId);
|
|
1697
1627
|
}
|
|
1698
1628
|
/**
|
|
1699
1629
|
* This method returns the access token.
|
|
1700
1630
|
*
|
|
1701
|
-
* @param
|
|
1631
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1702
1632
|
* scenarios where each user should be uniquely identified.
|
|
1703
1633
|
*
|
|
1704
1634
|
* @returns - A Promise that resolves with the access token.
|
|
@@ -1712,15 +1642,15 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1712
1642
|
*
|
|
1713
1643
|
* @preserve
|
|
1714
1644
|
*/
|
|
1715
|
-
async getAccessToken(
|
|
1716
|
-
return this.
|
|
1645
|
+
async getAccessToken(userId) {
|
|
1646
|
+
return (await this._storageManager.getSessionData(userId))?.access_token;
|
|
1717
1647
|
}
|
|
1718
1648
|
/**
|
|
1719
1649
|
* This method sends a custom-grant request and returns a Promise that resolves with the response
|
|
1720
1650
|
* depending on the config passed.
|
|
1721
1651
|
*
|
|
1722
1652
|
* @param config - A config object containing the custom grant configurations.
|
|
1723
|
-
* @param
|
|
1653
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1724
1654
|
* scenarios where each user should be uniquely identified.
|
|
1725
1655
|
*
|
|
1726
1656
|
* @returns - A Promise that resolves with the response depending
|
|
@@ -1731,7 +1661,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1731
1661
|
* const config = {
|
|
1732
1662
|
* attachToken: false,
|
|
1733
1663
|
* data: {
|
|
1734
|
-
* client_id: "{{
|
|
1664
|
+
* client_id: "{{clientId}}",
|
|
1735
1665
|
* grant_type: "account_switch",
|
|
1736
1666
|
* scope: "{{scope}}",
|
|
1737
1667
|
* token: "{{token}}",
|
|
@@ -1742,44 +1672,115 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1742
1672
|
* signInRequired: true
|
|
1743
1673
|
* }
|
|
1744
1674
|
*
|
|
1745
|
-
* auth.
|
|
1675
|
+
* auth.exchangeToken(config).then((response)=>{
|
|
1746
1676
|
* // console.log(response);
|
|
1747
1677
|
* }).catch((error)=>{
|
|
1748
1678
|
* // console.error(error);
|
|
1749
1679
|
* });
|
|
1750
1680
|
* ```
|
|
1751
1681
|
*
|
|
1752
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
1682
|
+
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#exchangeToken}
|
|
1753
1683
|
*
|
|
1754
1684
|
* @preserve
|
|
1755
1685
|
*/
|
|
1756
|
-
|
|
1757
|
-
|
|
1686
|
+
async exchangeToken(config, userId) {
|
|
1687
|
+
const oidcProviderMetadata = await this._oidcProviderMetaData();
|
|
1688
|
+
const configData = await this._config();
|
|
1689
|
+
let tokenEndpoint;
|
|
1690
|
+
if (config.tokenEndpoint && config.tokenEndpoint.trim().length !== 0) {
|
|
1691
|
+
tokenEndpoint = config.tokenEndpoint;
|
|
1692
|
+
} else {
|
|
1693
|
+
tokenEndpoint = oidcProviderMetadata.token_endpoint;
|
|
1694
|
+
}
|
|
1695
|
+
if (!tokenEndpoint || tokenEndpoint.trim().length === 0) {
|
|
1696
|
+
throw new AsgardeoAuthException(
|
|
1697
|
+
"JS-AUTH_CORE-RCG-NF01",
|
|
1698
|
+
"Token endpoint not found.",
|
|
1699
|
+
"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."
|
|
1700
|
+
);
|
|
1701
|
+
}
|
|
1702
|
+
const data = await Promise.all(
|
|
1703
|
+
Object.entries(config.data).map(async ([key, value]) => {
|
|
1704
|
+
const newValue = await this._authenticationHelper.replaceCustomGrantTemplateTags(
|
|
1705
|
+
value,
|
|
1706
|
+
userId
|
|
1707
|
+
);
|
|
1708
|
+
return `${key}=${newValue}`;
|
|
1709
|
+
})
|
|
1710
|
+
);
|
|
1711
|
+
let requestHeaders = {
|
|
1712
|
+
Accept: "application/json",
|
|
1713
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
1714
|
+
};
|
|
1715
|
+
if (config.attachToken) {
|
|
1716
|
+
requestHeaders = {
|
|
1717
|
+
...requestHeaders,
|
|
1718
|
+
Authorization: `Bearer ${(await this._storageManager.getSessionData(userId)).access_token}`
|
|
1719
|
+
};
|
|
1720
|
+
}
|
|
1721
|
+
const requestConfig = {
|
|
1722
|
+
body: data.join("&"),
|
|
1723
|
+
credentials: configData.sendCookiesInRequests ? "include" : "same-origin",
|
|
1724
|
+
headers: new Headers(requestHeaders),
|
|
1725
|
+
method: "POST"
|
|
1726
|
+
};
|
|
1727
|
+
let response;
|
|
1728
|
+
try {
|
|
1729
|
+
response = await fetch(tokenEndpoint, requestConfig);
|
|
1730
|
+
} catch (error) {
|
|
1731
|
+
throw new AsgardeoAuthException(
|
|
1732
|
+
"JS-AUTH_CORE-RCG-NE02",
|
|
1733
|
+
"The custom grant request failed.",
|
|
1734
|
+
error ?? "The request sent to get the custom grant failed."
|
|
1735
|
+
);
|
|
1736
|
+
}
|
|
1737
|
+
if (response.status !== 200 || !response.ok) {
|
|
1738
|
+
throw new AsgardeoAuthException(
|
|
1739
|
+
"JS-AUTH_CORE-RCG-HE03",
|
|
1740
|
+
`Invalid response status received for the custom grant request. (${response.statusText})`,
|
|
1741
|
+
await response.json()
|
|
1742
|
+
);
|
|
1743
|
+
}
|
|
1744
|
+
if (config.returnsSession) {
|
|
1745
|
+
return this._authenticationHelper.handleTokenResponse(response, userId);
|
|
1746
|
+
} else {
|
|
1747
|
+
return Promise.resolve(await response.json());
|
|
1748
|
+
}
|
|
1758
1749
|
}
|
|
1759
1750
|
/**
|
|
1760
1751
|
* This method returns if the user is authenticated or not.
|
|
1761
1752
|
*
|
|
1762
|
-
* @param
|
|
1753
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1763
1754
|
* scenarios where each user should be uniquely identified.
|
|
1764
1755
|
*
|
|
1765
1756
|
* @returns - A Promise that resolves with `true` if the user is authenticated, `false` otherwise.
|
|
1766
1757
|
*
|
|
1767
1758
|
* @example
|
|
1768
1759
|
* ```
|
|
1769
|
-
* await auth.
|
|
1760
|
+
* await auth.isSignedIn();
|
|
1770
1761
|
* ```
|
|
1771
1762
|
*
|
|
1772
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
1763
|
+
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#isSignedIn}
|
|
1773
1764
|
*
|
|
1774
1765
|
* @preserve
|
|
1775
1766
|
*/
|
|
1776
|
-
async
|
|
1777
|
-
|
|
1767
|
+
async isSignedIn(userId) {
|
|
1768
|
+
const isAccessTokenAvailable = Boolean(await this.getAccessToken(userId));
|
|
1769
|
+
const createdAt = (await this._storageManager.getSessionData(userId))?.created_at;
|
|
1770
|
+
const expiresInString = (await this._storageManager.getSessionData(userId))?.expires_in;
|
|
1771
|
+
if (!expiresInString) {
|
|
1772
|
+
return false;
|
|
1773
|
+
}
|
|
1774
|
+
const expiresIn = parseInt(expiresInString) * 1e3;
|
|
1775
|
+
const currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
1776
|
+
const isAccessTokenValid = createdAt + expiresIn > currentTime;
|
|
1777
|
+
const isSignedIn = isAccessTokenAvailable && isAccessTokenValid;
|
|
1778
|
+
return isSignedIn;
|
|
1778
1779
|
}
|
|
1779
1780
|
/**
|
|
1780
1781
|
* This method returns the PKCE code generated during the generation of the authentication URL.
|
|
1781
1782
|
*
|
|
1782
|
-
* @param
|
|
1783
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1783
1784
|
* scenarios where each user should be uniquely identified.
|
|
1784
1785
|
* @param state - The state parameter that was passed in the authentication URL.
|
|
1785
1786
|
*
|
|
@@ -1794,15 +1795,18 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1794
1795
|
*
|
|
1795
1796
|
* @preserve
|
|
1796
1797
|
*/
|
|
1797
|
-
async getPKCECode(state,
|
|
1798
|
-
return this.
|
|
1798
|
+
async getPKCECode(state, userId) {
|
|
1799
|
+
return await this._storageManager.getTemporaryDataParameter(
|
|
1800
|
+
extractPkceStorageKeyFromState_default(state),
|
|
1801
|
+
userId
|
|
1802
|
+
);
|
|
1799
1803
|
}
|
|
1800
1804
|
/**
|
|
1801
1805
|
* This method sets the PKCE code to the data store.
|
|
1802
1806
|
*
|
|
1803
1807
|
* @param pkce - The PKCE code.
|
|
1804
1808
|
* @param state - The state parameter that was passed in the authentication URL.
|
|
1805
|
-
* @param
|
|
1809
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1806
1810
|
* scenarios where each user should be uniquely identified.
|
|
1807
1811
|
*
|
|
1808
1812
|
* @example
|
|
@@ -1814,15 +1818,15 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1814
1818
|
*
|
|
1815
1819
|
* @preserve
|
|
1816
1820
|
*/
|
|
1817
|
-
async setPKCECode(pkce, state,
|
|
1818
|
-
await this.
|
|
1821
|
+
async setPKCECode(pkce, state, userId) {
|
|
1822
|
+
return await this._storageManager.setTemporaryDataParameter(extractPkceStorageKeyFromState_default(state), pkce, userId);
|
|
1819
1823
|
}
|
|
1820
1824
|
/**
|
|
1821
1825
|
* This method returns if the sign-out is successful or not.
|
|
1822
1826
|
*
|
|
1823
1827
|
* @param signOutRedirectUrl - The URL to which the user has been redirected to after signing-out.
|
|
1824
1828
|
*
|
|
1825
|
-
* **The server appends path parameters to the `
|
|
1829
|
+
* **The server appends path parameters to the `afterSignOutUrl` and these path parameters
|
|
1826
1830
|
* are required for this method to function.**
|
|
1827
1831
|
*
|
|
1828
1832
|
* @returns - `true` if successful, `false` otherwise.
|
|
@@ -1831,8 +1835,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1831
1835
|
*
|
|
1832
1836
|
* @preserve
|
|
1833
1837
|
*/
|
|
1834
|
-
static isSignOutSuccessful(
|
|
1835
|
-
const url = new URL(
|
|
1838
|
+
static isSignOutSuccessful(afterSignOutUrl) {
|
|
1839
|
+
const url = new URL(afterSignOutUrl);
|
|
1836
1840
|
const stateParam = url.searchParams.get(OIDCRequestConstants_default.Params.STATE);
|
|
1837
1841
|
const error = Boolean(url.searchParams.get("error"));
|
|
1838
1842
|
return stateParam ? stateParam === OIDCRequestConstants_default.Params.SIGN_OUT_SUCCESS && !error : false;
|
|
@@ -1842,7 +1846,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1842
1846
|
*
|
|
1843
1847
|
* @param signOutRedirectUrl - The URL to which the user has been redirected to after signing-out.
|
|
1844
1848
|
*
|
|
1845
|
-
* **The server appends path parameters to the `
|
|
1849
|
+
* **The server appends path parameters to the `afterSignOutUrl` and these path parameters
|
|
1846
1850
|
* are required for this method to function.**
|
|
1847
1851
|
*
|
|
1848
1852
|
* @returns - `true` if successful, `false` otherwise.
|
|
@@ -1851,8 +1855,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1851
1855
|
*
|
|
1852
1856
|
* @preserve
|
|
1853
1857
|
*/
|
|
1854
|
-
static didSignOutFail(
|
|
1855
|
-
const url = new URL(
|
|
1858
|
+
static didSignOutFail(afterSignOutUrl) {
|
|
1859
|
+
const url = new URL(afterSignOutUrl);
|
|
1856
1860
|
const stateParam = url.searchParams.get(OIDCRequestConstants_default.Params.STATE);
|
|
1857
1861
|
const error = Boolean(url.searchParams.get("error"));
|
|
1858
1862
|
return stateParam ? stateParam === OIDCRequestConstants_default.Params.SIGN_OUT_SUCCESS && error : false;
|
|
@@ -1865,160 +1869,897 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1865
1869
|
* @example
|
|
1866
1870
|
* ```
|
|
1867
1871
|
* const config = {
|
|
1868
|
-
*
|
|
1869
|
-
*
|
|
1872
|
+
* afterSignInUrl: "http://localhost:3000/sign-in",
|
|
1873
|
+
* clientId: "client ID",
|
|
1870
1874
|
* baseUrl: "https://localhost:9443"
|
|
1871
1875
|
* }
|
|
1872
1876
|
*
|
|
1873
|
-
* await auth.
|
|
1877
|
+
* await auth.reInitialize(config);
|
|
1874
1878
|
* ```
|
|
1875
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
1879
|
+
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#reInitialize}
|
|
1876
1880
|
*
|
|
1877
1881
|
* @preserve
|
|
1878
1882
|
*/
|
|
1879
|
-
async
|
|
1880
|
-
await this.
|
|
1883
|
+
async reInitialize(config) {
|
|
1884
|
+
await this._storageManager.setConfigData(config);
|
|
1885
|
+
await this.loadOpenIDProviderConfiguration(true);
|
|
1886
|
+
}
|
|
1887
|
+
static async clearSession(userId) {
|
|
1888
|
+
await this._authenticationHelper.clearSession(userId);
|
|
1889
|
+
}
|
|
1890
|
+
};
|
|
1891
|
+
__publicField(_AsgardeoAuthClient, "_instanceID");
|
|
1892
|
+
// FIXME: Validate this.
|
|
1893
|
+
// Ref: https://github.com/asgardeo/asgardeo-auth-js-core/pull/205
|
|
1894
|
+
__publicField(_AsgardeoAuthClient, "_authenticationHelper");
|
|
1895
|
+
var AsgardeoAuthClient = _AsgardeoAuthClient;
|
|
1896
|
+
|
|
1897
|
+
// src/errors/AsgardeoAPIError.ts
|
|
1898
|
+
var AsgardeoAPIError = class extends AsgardeoError {
|
|
1899
|
+
/**
|
|
1900
|
+
* Creates an instance of AsgardeoAPIError.
|
|
1901
|
+
*
|
|
1902
|
+
* @param message - Human-readable description of the error
|
|
1903
|
+
* @param code - A unique error code that identifies the error type
|
|
1904
|
+
* @param statusCode - HTTP status code of the failed request
|
|
1905
|
+
* @param statusText - HTTP status text of the failed request
|
|
1906
|
+
* @param origin - Optional. The SDK origin (e.g. 'react', 'vue'). Defaults to generic 'Asgardeo'
|
|
1907
|
+
* @constructor
|
|
1908
|
+
*/
|
|
1909
|
+
constructor(message, code, origin, statusCode, statusText) {
|
|
1910
|
+
super(message, code, origin);
|
|
1911
|
+
this.statusCode = statusCode;
|
|
1912
|
+
this.statusText = statusText;
|
|
1913
|
+
Object.defineProperty(this, "name", {
|
|
1914
|
+
value: "AsgardeoAPIError",
|
|
1915
|
+
configurable: true,
|
|
1916
|
+
writable: true
|
|
1917
|
+
});
|
|
1918
|
+
}
|
|
1919
|
+
/**
|
|
1920
|
+
* Returns a string representation of the API error
|
|
1921
|
+
* @returns Formatted error string with name, code, status, and message
|
|
1922
|
+
*/
|
|
1923
|
+
toString() {
|
|
1924
|
+
const status = this.statusCode ? ` (HTTP ${this.statusCode} - ${this.statusText})` : "";
|
|
1925
|
+
return `[${this.name}] (code="${this.code}")${status}
|
|
1926
|
+
Message: ${this.message}`;
|
|
1927
|
+
}
|
|
1928
|
+
};
|
|
1929
|
+
|
|
1930
|
+
// src/api/initializeEmbeddedSignInFlow.ts
|
|
1931
|
+
var initializeEmbeddedSignInFlow = async ({
|
|
1932
|
+
url,
|
|
1933
|
+
baseUrl,
|
|
1934
|
+
payload,
|
|
1935
|
+
...requestConfig
|
|
1936
|
+
}) => {
|
|
1937
|
+
if (!payload) {
|
|
1938
|
+
throw new AsgardeoAPIError(
|
|
1939
|
+
"Authorization payload is required",
|
|
1940
|
+
"initializeEmbeddedSignInFlow-ValidationError-002",
|
|
1941
|
+
"javascript",
|
|
1942
|
+
400,
|
|
1943
|
+
"If an authorization payload is not provided, the request cannot be constructed correctly."
|
|
1944
|
+
);
|
|
1945
|
+
}
|
|
1946
|
+
const searchParams = new URLSearchParams();
|
|
1947
|
+
Object.entries(payload).forEach(([key, value]) => {
|
|
1948
|
+
if (value !== void 0 && value !== null) {
|
|
1949
|
+
searchParams.append(key, String(value));
|
|
1950
|
+
}
|
|
1951
|
+
});
|
|
1952
|
+
const { headers: customHeaders, ...otherConfig } = requestConfig;
|
|
1953
|
+
const response = await fetch(url ?? `${baseUrl}/oauth2/authorize`, {
|
|
1954
|
+
method: requestConfig.method || "POST",
|
|
1955
|
+
headers: {
|
|
1956
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
1957
|
+
Accept: "application/json",
|
|
1958
|
+
...customHeaders
|
|
1959
|
+
},
|
|
1960
|
+
body: searchParams.toString(),
|
|
1961
|
+
...otherConfig
|
|
1962
|
+
});
|
|
1963
|
+
if (!response.ok) {
|
|
1964
|
+
const errorText = await response.text();
|
|
1965
|
+
throw new AsgardeoAPIError(
|
|
1966
|
+
`Authorization request failed: ${errorText}`,
|
|
1967
|
+
"initializeEmbeddedSignInFlow-ResponseError-001",
|
|
1968
|
+
"javascript",
|
|
1969
|
+
response.status,
|
|
1970
|
+
response.statusText
|
|
1971
|
+
);
|
|
1972
|
+
}
|
|
1973
|
+
return await response.json();
|
|
1974
|
+
};
|
|
1975
|
+
var initializeEmbeddedSignInFlow_default = initializeEmbeddedSignInFlow;
|
|
1976
|
+
|
|
1977
|
+
// src/api/executeEmbeddedSignInFlow.ts
|
|
1978
|
+
var executeEmbeddedSignInFlow = async ({
|
|
1979
|
+
url,
|
|
1980
|
+
baseUrl,
|
|
1981
|
+
payload,
|
|
1982
|
+
...requestConfig
|
|
1983
|
+
}) => {
|
|
1984
|
+
if (!payload) {
|
|
1985
|
+
throw new AsgardeoAPIError(
|
|
1986
|
+
"Authorization payload is required",
|
|
1987
|
+
"executeEmbeddedSignInFlow-ValidationError-002",
|
|
1988
|
+
"javascript",
|
|
1989
|
+
400,
|
|
1990
|
+
"If an authorization payload is not provided, the request cannot be constructed correctly."
|
|
1991
|
+
);
|
|
1992
|
+
}
|
|
1993
|
+
const { headers: customHeaders, ...otherConfig } = requestConfig;
|
|
1994
|
+
const response = await fetch(url ?? `${baseUrl}/oauth2/authn`, {
|
|
1995
|
+
method: requestConfig.method || "POST",
|
|
1996
|
+
headers: {
|
|
1997
|
+
"Content-Type": "application/json",
|
|
1998
|
+
Accept: "application/json",
|
|
1999
|
+
...customHeaders
|
|
2000
|
+
},
|
|
2001
|
+
body: JSON.stringify(payload),
|
|
2002
|
+
...otherConfig
|
|
2003
|
+
});
|
|
2004
|
+
if (!response.ok) {
|
|
2005
|
+
const errorText = await response.text();
|
|
2006
|
+
throw new AsgardeoAPIError(
|
|
2007
|
+
`Authorization request failed: ${errorText}`,
|
|
2008
|
+
"initializeEmbeddedSignInFlow-ResponseError-001",
|
|
2009
|
+
"javascript",
|
|
2010
|
+
response.status,
|
|
2011
|
+
response.statusText
|
|
2012
|
+
);
|
|
2013
|
+
}
|
|
2014
|
+
return await response.json();
|
|
2015
|
+
};
|
|
2016
|
+
var executeEmbeddedSignInFlow_default = executeEmbeddedSignInFlow;
|
|
2017
|
+
|
|
2018
|
+
// src/models/embedded-flow.ts
|
|
2019
|
+
var EmbeddedFlowType = /* @__PURE__ */ ((EmbeddedFlowType2) => {
|
|
2020
|
+
EmbeddedFlowType2["Registration"] = "REGISTRATION";
|
|
2021
|
+
return EmbeddedFlowType2;
|
|
2022
|
+
})(EmbeddedFlowType || {});
|
|
2023
|
+
var EmbeddedFlowStatus = /* @__PURE__ */ ((EmbeddedFlowStatus2) => {
|
|
2024
|
+
EmbeddedFlowStatus2["Complete"] = "COMPLETE";
|
|
2025
|
+
EmbeddedFlowStatus2["Incomplete"] = "INCOMPLETE";
|
|
2026
|
+
return EmbeddedFlowStatus2;
|
|
2027
|
+
})(EmbeddedFlowStatus || {});
|
|
2028
|
+
var EmbeddedFlowResponseType = /* @__PURE__ */ ((EmbeddedFlowResponseType2) => {
|
|
2029
|
+
EmbeddedFlowResponseType2["Redirection"] = "REDIRECTION";
|
|
2030
|
+
EmbeddedFlowResponseType2["View"] = "VIEW";
|
|
2031
|
+
return EmbeddedFlowResponseType2;
|
|
2032
|
+
})(EmbeddedFlowResponseType || {});
|
|
2033
|
+
var EmbeddedFlowComponentType = /* @__PURE__ */ ((EmbeddedFlowComponentType2) => {
|
|
2034
|
+
EmbeddedFlowComponentType2["Button"] = "BUTTON";
|
|
2035
|
+
EmbeddedFlowComponentType2["Checkbox"] = "CHECKBOX";
|
|
2036
|
+
EmbeddedFlowComponentType2["Divider"] = "DIVIDER";
|
|
2037
|
+
EmbeddedFlowComponentType2["Form"] = "FORM";
|
|
2038
|
+
EmbeddedFlowComponentType2["Image"] = "IMAGE";
|
|
2039
|
+
EmbeddedFlowComponentType2["Input"] = "INPUT";
|
|
2040
|
+
EmbeddedFlowComponentType2["Radio"] = "RADIO";
|
|
2041
|
+
EmbeddedFlowComponentType2["Select"] = "SELECT";
|
|
2042
|
+
EmbeddedFlowComponentType2["Typography"] = "TYPOGRAPHY";
|
|
2043
|
+
return EmbeddedFlowComponentType2;
|
|
2044
|
+
})(EmbeddedFlowComponentType || {});
|
|
2045
|
+
|
|
2046
|
+
// src/api/executeEmbeddedSignUpFlow.ts
|
|
2047
|
+
var executeEmbeddedSignUpFlow = async ({
|
|
2048
|
+
url,
|
|
2049
|
+
baseUrl,
|
|
2050
|
+
payload,
|
|
2051
|
+
...requestConfig
|
|
2052
|
+
}) => {
|
|
2053
|
+
if (!baseUrl && !url) {
|
|
2054
|
+
throw new AsgardeoAPIError(
|
|
2055
|
+
"Embedded SignUp flow execution failed: Base URL or URL is not provided.",
|
|
2056
|
+
"javascript-executeEmbeddedSignUpFlow-ValidationError-001",
|
|
2057
|
+
"javascript",
|
|
2058
|
+
400,
|
|
2059
|
+
"At least one of the baseUrl or url must be provided to execute the embedded sign up flow."
|
|
2060
|
+
);
|
|
2061
|
+
}
|
|
2062
|
+
const { headers: customHeaders, ...otherConfig } = requestConfig;
|
|
2063
|
+
const response = await fetch(url ?? `${baseUrl}/api/server/v1/flow/execute`, {
|
|
2064
|
+
method: requestConfig.method || "POST",
|
|
2065
|
+
headers: {
|
|
2066
|
+
"Content-Type": "application/json",
|
|
2067
|
+
Accept: "application/json",
|
|
2068
|
+
...customHeaders
|
|
2069
|
+
},
|
|
2070
|
+
body: JSON.stringify({
|
|
2071
|
+
...payload ?? {},
|
|
2072
|
+
flowType: "REGISTRATION" /* Registration */
|
|
2073
|
+
}),
|
|
2074
|
+
...otherConfig
|
|
2075
|
+
});
|
|
2076
|
+
if (!response.ok) {
|
|
2077
|
+
const errorText = await response.text();
|
|
2078
|
+
throw new AsgardeoAPIError(
|
|
2079
|
+
`Embedded SignUp flow execution failed: ${errorText}`,
|
|
2080
|
+
"javascript-executeEmbeddedSignUpFlow-ResponseError-100",
|
|
2081
|
+
"javascript",
|
|
2082
|
+
response.status,
|
|
2083
|
+
response.statusText
|
|
2084
|
+
);
|
|
2085
|
+
}
|
|
2086
|
+
return await response.json();
|
|
2087
|
+
};
|
|
2088
|
+
var executeEmbeddedSignUpFlow_default = executeEmbeddedSignUpFlow;
|
|
2089
|
+
|
|
2090
|
+
// src/api/getUserInfo.ts
|
|
2091
|
+
var getUserInfo = async ({ url, ...requestConfig }) => {
|
|
2092
|
+
try {
|
|
2093
|
+
new URL(url);
|
|
2094
|
+
} catch (error) {
|
|
2095
|
+
throw new AsgardeoAPIError(
|
|
2096
|
+
"Invalid endpoint URL provided",
|
|
2097
|
+
"getUserInfo-ValidationError-001",
|
|
2098
|
+
"javascript",
|
|
2099
|
+
400,
|
|
2100
|
+
"Invalid Request"
|
|
2101
|
+
);
|
|
2102
|
+
}
|
|
2103
|
+
const response = await fetch(url, {
|
|
2104
|
+
method: "GET",
|
|
2105
|
+
headers: {
|
|
2106
|
+
"Content-Type": "application/json",
|
|
2107
|
+
Accept: "application/json"
|
|
2108
|
+
},
|
|
2109
|
+
...requestConfig
|
|
2110
|
+
});
|
|
2111
|
+
if (!response.ok) {
|
|
2112
|
+
const errorText = await response.text();
|
|
2113
|
+
throw new AsgardeoAPIError(
|
|
2114
|
+
`Failed to fetch user info: ${errorText}`,
|
|
2115
|
+
"getUserInfo-ResponseError-001",
|
|
2116
|
+
"javascript",
|
|
2117
|
+
response.status,
|
|
2118
|
+
response.statusText
|
|
2119
|
+
);
|
|
2120
|
+
}
|
|
2121
|
+
return await response.json();
|
|
2122
|
+
};
|
|
2123
|
+
var getUserInfo_default = getUserInfo;
|
|
2124
|
+
|
|
2125
|
+
// src/api/getScim2Me.ts
|
|
2126
|
+
var getScim2Me = async ({ url, baseUrl, fetcher, ...requestConfig }) => {
|
|
2127
|
+
try {
|
|
2128
|
+
new URL(url ?? baseUrl);
|
|
2129
|
+
} catch (error) {
|
|
2130
|
+
throw new AsgardeoAPIError(
|
|
2131
|
+
`Invalid URL provided. ${error?.toString()}`,
|
|
2132
|
+
"getScim2Me-ValidationError-001",
|
|
2133
|
+
"javascript",
|
|
2134
|
+
400,
|
|
2135
|
+
"The provided `url` or `baseUrl` path does not adhere to the URL schema."
|
|
2136
|
+
);
|
|
2137
|
+
}
|
|
2138
|
+
const fetchFn = fetcher || fetch;
|
|
2139
|
+
const resolvedUrl = url ?? `${baseUrl}/scim2/Me`;
|
|
2140
|
+
const requestInit = {
|
|
2141
|
+
method: "GET",
|
|
2142
|
+
headers: {
|
|
2143
|
+
"Content-Type": "application/scim+json",
|
|
2144
|
+
Accept: "application/json",
|
|
2145
|
+
...requestConfig.headers
|
|
2146
|
+
},
|
|
2147
|
+
...requestConfig
|
|
2148
|
+
};
|
|
2149
|
+
try {
|
|
2150
|
+
const response = await fetchFn(resolvedUrl, requestInit);
|
|
2151
|
+
if (!response?.ok) {
|
|
2152
|
+
const errorText = await response.text();
|
|
2153
|
+
throw new AsgardeoAPIError(
|
|
2154
|
+
`Failed to fetch user profile: ${errorText}`,
|
|
2155
|
+
"getScim2Me-ResponseError-001",
|
|
2156
|
+
"javascript",
|
|
2157
|
+
response.status,
|
|
2158
|
+
response.statusText
|
|
2159
|
+
);
|
|
2160
|
+
}
|
|
2161
|
+
return await response.json();
|
|
2162
|
+
} catch (error) {
|
|
2163
|
+
if (error instanceof AsgardeoAPIError) {
|
|
2164
|
+
throw error;
|
|
2165
|
+
}
|
|
2166
|
+
throw new AsgardeoAPIError(
|
|
2167
|
+
`Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
2168
|
+
"getScim2Me-NetworkError-001",
|
|
2169
|
+
"javascript",
|
|
2170
|
+
0,
|
|
2171
|
+
"Network Error"
|
|
2172
|
+
);
|
|
2173
|
+
}
|
|
2174
|
+
};
|
|
2175
|
+
var getScim2Me_default = getScim2Me;
|
|
2176
|
+
|
|
2177
|
+
// src/api/getSchemas.ts
|
|
2178
|
+
var getSchemas = async ({ url, baseUrl, fetcher, ...requestConfig }) => {
|
|
2179
|
+
try {
|
|
2180
|
+
new URL(url ?? baseUrl);
|
|
2181
|
+
} catch (error) {
|
|
2182
|
+
throw new AsgardeoAPIError(
|
|
2183
|
+
`Invalid URL provided. ${error?.toString()}`,
|
|
2184
|
+
"getSchemas-ValidationError-001",
|
|
2185
|
+
"javascript",
|
|
2186
|
+
400,
|
|
2187
|
+
"The provided `url` or `baseUrl` path does not adhere to the URL schema."
|
|
2188
|
+
);
|
|
2189
|
+
}
|
|
2190
|
+
const fetchFn = fetcher || fetch;
|
|
2191
|
+
const resolvedUrl = url ?? `${baseUrl}/scim2/Schemas`;
|
|
2192
|
+
const requestInit = {
|
|
2193
|
+
method: "GET",
|
|
2194
|
+
headers: {
|
|
2195
|
+
"Content-Type": "application/json",
|
|
2196
|
+
Accept: "application/json",
|
|
2197
|
+
...requestConfig.headers
|
|
2198
|
+
},
|
|
2199
|
+
...requestConfig
|
|
2200
|
+
};
|
|
2201
|
+
try {
|
|
2202
|
+
const response = await fetchFn(resolvedUrl, requestInit);
|
|
2203
|
+
if (!response?.ok) {
|
|
2204
|
+
const errorText = await response.text();
|
|
2205
|
+
throw new AsgardeoAPIError(
|
|
2206
|
+
`Failed to fetch SCIM2 schemas: ${errorText}`,
|
|
2207
|
+
"getSchemas-ResponseError-001",
|
|
2208
|
+
"javascript",
|
|
2209
|
+
response.status,
|
|
2210
|
+
response.statusText
|
|
2211
|
+
);
|
|
2212
|
+
}
|
|
2213
|
+
return await response.json();
|
|
2214
|
+
} catch (error) {
|
|
2215
|
+
if (error instanceof AsgardeoAPIError) {
|
|
2216
|
+
throw error;
|
|
2217
|
+
}
|
|
2218
|
+
throw new AsgardeoAPIError(
|
|
2219
|
+
`Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
2220
|
+
"getSchemas-NetworkError-001",
|
|
2221
|
+
"javascript",
|
|
2222
|
+
0,
|
|
2223
|
+
"Network Error"
|
|
2224
|
+
);
|
|
2225
|
+
}
|
|
2226
|
+
};
|
|
2227
|
+
var getSchemas_default = getSchemas;
|
|
2228
|
+
|
|
2229
|
+
// src/api/getAllOrganizations.ts
|
|
2230
|
+
var getAllOrganizations = async ({
|
|
2231
|
+
baseUrl,
|
|
2232
|
+
filter = "",
|
|
2233
|
+
limit = 10,
|
|
2234
|
+
recursive = false,
|
|
2235
|
+
fetcher,
|
|
2236
|
+
...requestConfig
|
|
2237
|
+
}) => {
|
|
2238
|
+
try {
|
|
2239
|
+
new URL(baseUrl);
|
|
2240
|
+
} catch (error) {
|
|
2241
|
+
throw new AsgardeoAPIError(
|
|
2242
|
+
`Invalid base URL provided. ${error?.toString()}`,
|
|
2243
|
+
"getAllOrganizations-ValidationError-001",
|
|
2244
|
+
"javascript",
|
|
2245
|
+
400,
|
|
2246
|
+
"The provided `baseUrl` does not adhere to the URL schema."
|
|
2247
|
+
);
|
|
2248
|
+
}
|
|
2249
|
+
const queryParams = new URLSearchParams(
|
|
2250
|
+
Object.fromEntries(
|
|
2251
|
+
Object.entries({
|
|
2252
|
+
filter,
|
|
2253
|
+
limit: limit.toString(),
|
|
2254
|
+
recursive: recursive.toString()
|
|
2255
|
+
}).filter(([, value]) => Boolean(value))
|
|
2256
|
+
)
|
|
2257
|
+
);
|
|
2258
|
+
const fetchFn = fetcher || fetch;
|
|
2259
|
+
const resolvedUrl = `${baseUrl}/api/server/v1/organizations?${queryParams.toString()}`;
|
|
2260
|
+
const requestInit = {
|
|
2261
|
+
method: "GET",
|
|
2262
|
+
headers: {
|
|
2263
|
+
"Content-Type": "application/json",
|
|
2264
|
+
Accept: "application/json",
|
|
2265
|
+
...requestConfig.headers
|
|
2266
|
+
},
|
|
2267
|
+
...requestConfig
|
|
2268
|
+
};
|
|
2269
|
+
try {
|
|
2270
|
+
const response = await fetchFn(resolvedUrl, requestInit);
|
|
2271
|
+
if (!response?.ok) {
|
|
2272
|
+
const errorText = await response.text();
|
|
2273
|
+
throw new AsgardeoAPIError(
|
|
2274
|
+
`Failed to get organizations: ${errorText}`,
|
|
2275
|
+
"getAllOrganizations-ResponseError-001",
|
|
2276
|
+
"javascript",
|
|
2277
|
+
response.status,
|
|
2278
|
+
response.statusText
|
|
2279
|
+
);
|
|
2280
|
+
}
|
|
2281
|
+
const data = await response.json();
|
|
2282
|
+
return {
|
|
2283
|
+
hasMore: data.hasMore,
|
|
2284
|
+
nextCursor: data.nextCursor,
|
|
2285
|
+
organizations: data.organizations || [],
|
|
2286
|
+
totalCount: data.totalCount
|
|
2287
|
+
};
|
|
2288
|
+
} catch (error) {
|
|
2289
|
+
if (error instanceof AsgardeoAPIError) {
|
|
2290
|
+
throw error;
|
|
2291
|
+
}
|
|
2292
|
+
throw new AsgardeoAPIError(
|
|
2293
|
+
`Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
2294
|
+
"getAllOrganizations-NetworkError-001",
|
|
2295
|
+
"javascript",
|
|
2296
|
+
0,
|
|
2297
|
+
"Network Error"
|
|
2298
|
+
);
|
|
2299
|
+
}
|
|
2300
|
+
};
|
|
2301
|
+
var getAllOrganizations_default = getAllOrganizations;
|
|
2302
|
+
|
|
2303
|
+
// src/api/createOrganization.ts
|
|
2304
|
+
var createOrganization = async ({
|
|
2305
|
+
baseUrl,
|
|
2306
|
+
payload,
|
|
2307
|
+
fetcher,
|
|
2308
|
+
...requestConfig
|
|
2309
|
+
}) => {
|
|
2310
|
+
try {
|
|
2311
|
+
new URL(baseUrl);
|
|
2312
|
+
} catch (error) {
|
|
2313
|
+
throw new AsgardeoAPIError(
|
|
2314
|
+
`Invalid base URL provided. ${error?.toString()}`,
|
|
2315
|
+
"createOrganization-ValidationError-001",
|
|
2316
|
+
"javascript",
|
|
2317
|
+
400,
|
|
2318
|
+
"The provided `baseUrl` does not adhere to the URL schema."
|
|
2319
|
+
);
|
|
2320
|
+
}
|
|
2321
|
+
if (!payload) {
|
|
2322
|
+
throw new AsgardeoAPIError(
|
|
2323
|
+
"Organization payload is required",
|
|
2324
|
+
"createOrganization-ValidationError-002",
|
|
2325
|
+
"javascript",
|
|
2326
|
+
400,
|
|
2327
|
+
"Invalid Request"
|
|
2328
|
+
);
|
|
2329
|
+
}
|
|
2330
|
+
const organizationPayload = {
|
|
2331
|
+
...payload,
|
|
2332
|
+
type: "TENANT"
|
|
2333
|
+
};
|
|
2334
|
+
const fetchFn = fetcher || fetch;
|
|
2335
|
+
const resolvedUrl = `${baseUrl}/api/server/v1/organizations`;
|
|
2336
|
+
const requestInit = {
|
|
2337
|
+
method: "POST",
|
|
2338
|
+
headers: {
|
|
2339
|
+
"Content-Type": "application/json",
|
|
2340
|
+
Accept: "application/json",
|
|
2341
|
+
...requestConfig.headers
|
|
2342
|
+
},
|
|
2343
|
+
body: JSON.stringify(organizationPayload),
|
|
2344
|
+
...requestConfig
|
|
2345
|
+
};
|
|
2346
|
+
try {
|
|
2347
|
+
const response = await fetchFn(resolvedUrl, requestInit);
|
|
2348
|
+
if (!response?.ok) {
|
|
2349
|
+
const errorText = await response.text();
|
|
2350
|
+
throw new AsgardeoAPIError(
|
|
2351
|
+
`Failed to create organization: ${errorText}`,
|
|
2352
|
+
"createOrganization-ResponseError-001",
|
|
2353
|
+
"javascript",
|
|
2354
|
+
response.status,
|
|
2355
|
+
response.statusText
|
|
2356
|
+
);
|
|
2357
|
+
}
|
|
2358
|
+
return await response.json();
|
|
2359
|
+
} catch (error) {
|
|
2360
|
+
if (error instanceof AsgardeoAPIError) {
|
|
2361
|
+
throw error;
|
|
2362
|
+
}
|
|
2363
|
+
throw new AsgardeoAPIError(
|
|
2364
|
+
`Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
2365
|
+
"createOrganization-NetworkError-001",
|
|
2366
|
+
"javascript",
|
|
2367
|
+
0,
|
|
2368
|
+
"Network Error"
|
|
2369
|
+
);
|
|
2370
|
+
}
|
|
2371
|
+
};
|
|
2372
|
+
var createOrganization_default = createOrganization;
|
|
2373
|
+
|
|
2374
|
+
// src/api/getMeOrganizations.ts
|
|
2375
|
+
var getMeOrganizations = async ({
|
|
2376
|
+
baseUrl,
|
|
2377
|
+
after = "",
|
|
2378
|
+
authorizedAppName = "",
|
|
2379
|
+
before = "",
|
|
2380
|
+
filter = "",
|
|
2381
|
+
limit = 10,
|
|
2382
|
+
recursive = false,
|
|
2383
|
+
fetcher,
|
|
2384
|
+
...requestConfig
|
|
2385
|
+
}) => {
|
|
2386
|
+
try {
|
|
2387
|
+
new URL(baseUrl);
|
|
2388
|
+
} catch (error) {
|
|
2389
|
+
throw new AsgardeoAPIError(
|
|
2390
|
+
`Invalid base URL provided. ${error?.toString()}`,
|
|
2391
|
+
"getMeOrganizations-ValidationError-001",
|
|
2392
|
+
"javascript",
|
|
2393
|
+
400,
|
|
2394
|
+
"The provided `baseUrl` does not adhere to the URL schema."
|
|
2395
|
+
);
|
|
2396
|
+
}
|
|
2397
|
+
const queryParams = new URLSearchParams(
|
|
2398
|
+
Object.fromEntries(
|
|
2399
|
+
Object.entries({
|
|
2400
|
+
after,
|
|
2401
|
+
authorizedAppName,
|
|
2402
|
+
before,
|
|
2403
|
+
filter,
|
|
2404
|
+
limit: limit.toString(),
|
|
2405
|
+
recursive: recursive.toString()
|
|
2406
|
+
}).filter(([, value]) => Boolean(value))
|
|
2407
|
+
)
|
|
2408
|
+
);
|
|
2409
|
+
const fetchFn = fetcher || fetch;
|
|
2410
|
+
const resolvedUrl = `${baseUrl}/api/users/v1/me/organizations?${queryParams.toString()}`;
|
|
2411
|
+
const requestInit = {
|
|
2412
|
+
method: "GET",
|
|
2413
|
+
headers: {
|
|
2414
|
+
"Content-Type": "application/json",
|
|
2415
|
+
Accept: "application/json",
|
|
2416
|
+
...requestConfig.headers
|
|
2417
|
+
},
|
|
2418
|
+
...requestConfig
|
|
2419
|
+
};
|
|
2420
|
+
try {
|
|
2421
|
+
const response = await fetchFn(resolvedUrl, requestInit);
|
|
2422
|
+
if (!response?.ok) {
|
|
2423
|
+
const errorText = await response.text();
|
|
2424
|
+
throw new AsgardeoAPIError(
|
|
2425
|
+
`Failed to fetch associated organizations of the user: ${errorText}`,
|
|
2426
|
+
"getMeOrganizations-ResponseError-001",
|
|
2427
|
+
"javascript",
|
|
2428
|
+
response.status,
|
|
2429
|
+
response.statusText
|
|
2430
|
+
);
|
|
2431
|
+
}
|
|
2432
|
+
const data = await response.json();
|
|
2433
|
+
return data.organizations || [];
|
|
2434
|
+
} catch (error) {
|
|
2435
|
+
if (error instanceof AsgardeoAPIError) {
|
|
2436
|
+
throw error;
|
|
2437
|
+
}
|
|
2438
|
+
throw new AsgardeoAPIError(
|
|
2439
|
+
`Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
2440
|
+
"getMeOrganizations-NetworkError-001",
|
|
2441
|
+
"javascript",
|
|
2442
|
+
0,
|
|
2443
|
+
"Network Error"
|
|
2444
|
+
);
|
|
2445
|
+
}
|
|
2446
|
+
};
|
|
2447
|
+
var getMeOrganizations_default = getMeOrganizations;
|
|
2448
|
+
|
|
2449
|
+
// src/api/getOrganization.ts
|
|
2450
|
+
var getOrganization = async ({
|
|
2451
|
+
baseUrl,
|
|
2452
|
+
organizationId,
|
|
2453
|
+
fetcher,
|
|
2454
|
+
...requestConfig
|
|
2455
|
+
}) => {
|
|
2456
|
+
try {
|
|
2457
|
+
new URL(baseUrl);
|
|
2458
|
+
} catch (error) {
|
|
2459
|
+
throw new AsgardeoAPIError(
|
|
2460
|
+
`Invalid base URL provided. ${error?.toString()}`,
|
|
2461
|
+
"getOrganization-ValidationError-001",
|
|
2462
|
+
"javascript",
|
|
2463
|
+
400,
|
|
2464
|
+
"The provided `baseUrl` does not adhere to the URL schema."
|
|
2465
|
+
);
|
|
1881
2466
|
}
|
|
1882
|
-
|
|
1883
|
-
|
|
2467
|
+
if (!organizationId) {
|
|
2468
|
+
throw new AsgardeoAPIError(
|
|
2469
|
+
"Organization ID is required",
|
|
2470
|
+
"getOrganization-ValidationError-002",
|
|
2471
|
+
"javascript",
|
|
2472
|
+
400,
|
|
2473
|
+
"Invalid Request"
|
|
2474
|
+
);
|
|
1884
2475
|
}
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
const
|
|
1898
|
-
|
|
1899
|
-
(
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
if (Error.captureStackTrace) {
|
|
1908
|
-
Error.captureStackTrace(this, new.target);
|
|
2476
|
+
const fetchFn = fetcher || fetch;
|
|
2477
|
+
const resolvedUrl = `${baseUrl}/api/server/v1/organizations/${organizationId}`;
|
|
2478
|
+
const requestInit = {
|
|
2479
|
+
method: "GET",
|
|
2480
|
+
headers: {
|
|
2481
|
+
"Content-Type": "application/json",
|
|
2482
|
+
Accept: "application/json",
|
|
2483
|
+
...requestConfig.headers
|
|
2484
|
+
},
|
|
2485
|
+
...requestConfig
|
|
2486
|
+
};
|
|
2487
|
+
try {
|
|
2488
|
+
const response = await fetchFn(resolvedUrl, requestInit);
|
|
2489
|
+
if (!response?.ok) {
|
|
2490
|
+
const errorText = await response.text();
|
|
2491
|
+
throw new AsgardeoAPIError(
|
|
2492
|
+
`Failed to fetch organization details: ${errorText}`,
|
|
2493
|
+
"getOrganization-ResponseError-001",
|
|
2494
|
+
"javascript",
|
|
2495
|
+
response.status,
|
|
2496
|
+
response.statusText
|
|
2497
|
+
);
|
|
1909
2498
|
}
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
if (
|
|
1913
|
-
|
|
2499
|
+
return await response.json();
|
|
2500
|
+
} catch (error) {
|
|
2501
|
+
if (error instanceof AsgardeoAPIError) {
|
|
2502
|
+
throw error;
|
|
1914
2503
|
}
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
2504
|
+
throw new AsgardeoAPIError(
|
|
2505
|
+
`Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
2506
|
+
"getOrganization-NetworkError-001",
|
|
2507
|
+
"javascript",
|
|
2508
|
+
0,
|
|
2509
|
+
"Network Error"
|
|
2510
|
+
);
|
|
1920
2511
|
}
|
|
1921
2512
|
};
|
|
2513
|
+
var getOrganization_default = getOrganization;
|
|
1922
2514
|
|
|
1923
|
-
// src/
|
|
1924
|
-
var
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
*
|
|
1928
|
-
* @param message - Human-readable description of the error
|
|
1929
|
-
* @param code - A unique error code that identifies the error type
|
|
1930
|
-
* @param statusCode - HTTP status code of the failed request
|
|
1931
|
-
* @param statusText - HTTP status text of the failed request
|
|
1932
|
-
* @param origin - Optional. The SDK origin (e.g. 'react', 'vue'). Defaults to generic 'Asgardeo'
|
|
1933
|
-
* @constructor
|
|
1934
|
-
*/
|
|
1935
|
-
constructor(message, code, origin, statusCode, statusText) {
|
|
1936
|
-
super(message, code, origin);
|
|
1937
|
-
this.statusCode = statusCode;
|
|
1938
|
-
this.statusText = statusText;
|
|
1939
|
-
Object.defineProperty(this, "name", {
|
|
1940
|
-
value: "AsgardeoAPIError",
|
|
1941
|
-
configurable: true,
|
|
1942
|
-
writable: true
|
|
1943
|
-
});
|
|
2515
|
+
// src/utils/isEmpty.ts
|
|
2516
|
+
var isEmpty = (value) => {
|
|
2517
|
+
if (value === null || value === void 0) {
|
|
2518
|
+
return true;
|
|
1944
2519
|
}
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
* @returns Formatted error string with name, code, status, and message
|
|
1948
|
-
*/
|
|
1949
|
-
toString() {
|
|
1950
|
-
const status = this.statusCode ? ` (HTTP ${this.statusCode} - ${this.statusText})` : "";
|
|
1951
|
-
return `[${this.name}] (code="${this.code}")${status}
|
|
1952
|
-
Message: ${this.message}`;
|
|
2520
|
+
if (typeof value === "string") {
|
|
2521
|
+
return value.trim() === "";
|
|
1953
2522
|
}
|
|
2523
|
+
if (Array.isArray(value)) {
|
|
2524
|
+
return value.length === 0;
|
|
2525
|
+
}
|
|
2526
|
+
if (typeof value === "object" && value.constructor === Object) {
|
|
2527
|
+
return Object.keys(value).length === 0;
|
|
2528
|
+
}
|
|
2529
|
+
return false;
|
|
1954
2530
|
};
|
|
2531
|
+
var isEmpty_default = isEmpty;
|
|
1955
2532
|
|
|
1956
|
-
// src/api/
|
|
1957
|
-
var
|
|
2533
|
+
// src/api/updateOrganization.ts
|
|
2534
|
+
var updateOrganization = async ({
|
|
2535
|
+
baseUrl,
|
|
2536
|
+
organizationId,
|
|
2537
|
+
operations,
|
|
2538
|
+
fetcher,
|
|
2539
|
+
...requestConfig
|
|
2540
|
+
}) => {
|
|
1958
2541
|
try {
|
|
1959
|
-
new URL(
|
|
2542
|
+
new URL(baseUrl);
|
|
1960
2543
|
} catch (error) {
|
|
1961
2544
|
throw new AsgardeoAPIError(
|
|
1962
|
-
|
|
1963
|
-
"
|
|
2545
|
+
`Invalid base URL provided. ${error?.toString()}`,
|
|
2546
|
+
"updateOrganization-ValidationError-001",
|
|
2547
|
+
"javascript",
|
|
2548
|
+
400,
|
|
2549
|
+
"The provided `baseUrl` does not adhere to the URL schema."
|
|
2550
|
+
);
|
|
2551
|
+
}
|
|
2552
|
+
if (!organizationId) {
|
|
2553
|
+
throw new AsgardeoAPIError(
|
|
2554
|
+
"Organization ID is required",
|
|
2555
|
+
"updateOrganization-ValidationError-002",
|
|
1964
2556
|
"javascript",
|
|
1965
2557
|
400,
|
|
1966
2558
|
"Invalid Request"
|
|
1967
2559
|
);
|
|
1968
2560
|
}
|
|
1969
|
-
|
|
1970
|
-
|
|
2561
|
+
if (!operations || !Array.isArray(operations) || operations.length === 0) {
|
|
2562
|
+
throw new AsgardeoAPIError(
|
|
2563
|
+
"Operations array is required and cannot be empty",
|
|
2564
|
+
"updateOrganization-ValidationError-003",
|
|
2565
|
+
"javascript",
|
|
2566
|
+
400,
|
|
2567
|
+
"Invalid Request"
|
|
2568
|
+
);
|
|
2569
|
+
}
|
|
2570
|
+
const fetchFn = fetcher || fetch;
|
|
2571
|
+
const resolvedUrl = `${baseUrl}/api/server/v1/organizations/${organizationId}`;
|
|
2572
|
+
const requestInit = {
|
|
2573
|
+
method: "PATCH",
|
|
1971
2574
|
headers: {
|
|
1972
2575
|
"Content-Type": "application/json",
|
|
1973
|
-
Accept: "application/json"
|
|
2576
|
+
Accept: "application/json",
|
|
2577
|
+
...requestConfig.headers
|
|
1974
2578
|
},
|
|
2579
|
+
body: JSON.stringify(operations),
|
|
1975
2580
|
...requestConfig
|
|
2581
|
+
};
|
|
2582
|
+
try {
|
|
2583
|
+
const response = await fetchFn(resolvedUrl, requestInit);
|
|
2584
|
+
if (!response?.ok) {
|
|
2585
|
+
const errorText = await response.text();
|
|
2586
|
+
throw new AsgardeoAPIError(
|
|
2587
|
+
`Failed to update organization: ${errorText}`,
|
|
2588
|
+
"updateOrganization-ResponseError-001",
|
|
2589
|
+
"javascript",
|
|
2590
|
+
response.status,
|
|
2591
|
+
response.statusText
|
|
2592
|
+
);
|
|
2593
|
+
}
|
|
2594
|
+
return await response.json();
|
|
2595
|
+
} catch (error) {
|
|
2596
|
+
if (error instanceof AsgardeoAPIError) {
|
|
2597
|
+
throw error;
|
|
2598
|
+
}
|
|
2599
|
+
throw new AsgardeoAPIError(
|
|
2600
|
+
`Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
2601
|
+
"updateOrganization-NetworkError-001",
|
|
2602
|
+
"javascript",
|
|
2603
|
+
0,
|
|
2604
|
+
"Network Error"
|
|
2605
|
+
);
|
|
2606
|
+
}
|
|
2607
|
+
};
|
|
2608
|
+
var createPatchOperations = (payload) => {
|
|
2609
|
+
return Object.entries(payload).map(([key, value]) => {
|
|
2610
|
+
if (isEmpty_default(value)) {
|
|
2611
|
+
return {
|
|
2612
|
+
operation: "REMOVE",
|
|
2613
|
+
path: `/${key}`
|
|
2614
|
+
};
|
|
2615
|
+
}
|
|
2616
|
+
return {
|
|
2617
|
+
operation: "REPLACE",
|
|
2618
|
+
path: `/${key}`,
|
|
2619
|
+
value
|
|
2620
|
+
};
|
|
1976
2621
|
});
|
|
1977
|
-
|
|
1978
|
-
|
|
2622
|
+
};
|
|
2623
|
+
var updateOrganization_default = updateOrganization;
|
|
2624
|
+
|
|
2625
|
+
// src/api/updateMeProfile.ts
|
|
2626
|
+
var updateMeProfile = async ({
|
|
2627
|
+
url,
|
|
2628
|
+
baseUrl,
|
|
2629
|
+
payload,
|
|
2630
|
+
fetcher,
|
|
2631
|
+
...requestConfig
|
|
2632
|
+
}) => {
|
|
2633
|
+
try {
|
|
2634
|
+
new URL(url ?? baseUrl);
|
|
2635
|
+
} catch (error) {
|
|
1979
2636
|
throw new AsgardeoAPIError(
|
|
1980
|
-
`
|
|
1981
|
-
"
|
|
2637
|
+
`Invalid URL provided. ${error?.toString()}`,
|
|
2638
|
+
"updateMeProfile-ValidationError-001",
|
|
1982
2639
|
"javascript",
|
|
1983
|
-
|
|
1984
|
-
|
|
2640
|
+
400,
|
|
2641
|
+
"The provided `url` or `baseUrl` path does not adhere to the URL schema."
|
|
2642
|
+
);
|
|
2643
|
+
}
|
|
2644
|
+
const data = {
|
|
2645
|
+
Operations: [
|
|
2646
|
+
{
|
|
2647
|
+
op: "replace",
|
|
2648
|
+
value: payload
|
|
2649
|
+
}
|
|
2650
|
+
],
|
|
2651
|
+
schemas: ["urn:ietf:params:scim:api:messages:2.0:PatchOp"]
|
|
2652
|
+
};
|
|
2653
|
+
const fetchFn = fetcher || fetch;
|
|
2654
|
+
const resolvedUrl = url ?? `${baseUrl}/scim2/Me`;
|
|
2655
|
+
const requestInit = {
|
|
2656
|
+
method: "PATCH",
|
|
2657
|
+
headers: {
|
|
2658
|
+
"Content-Type": "application/scim+json",
|
|
2659
|
+
Accept: "application/json",
|
|
2660
|
+
...requestConfig.headers
|
|
2661
|
+
},
|
|
2662
|
+
body: JSON.stringify(data),
|
|
2663
|
+
...requestConfig
|
|
2664
|
+
};
|
|
2665
|
+
try {
|
|
2666
|
+
const response = await fetchFn(resolvedUrl, requestInit);
|
|
2667
|
+
if (!response?.ok) {
|
|
2668
|
+
const errorText = await response.text();
|
|
2669
|
+
throw new AsgardeoAPIError(
|
|
2670
|
+
`Failed to update user profile: ${errorText}`,
|
|
2671
|
+
"updateMeProfile-ResponseError-001",
|
|
2672
|
+
"javascript",
|
|
2673
|
+
response.status,
|
|
2674
|
+
response.statusText
|
|
2675
|
+
);
|
|
2676
|
+
}
|
|
2677
|
+
return await response.json();
|
|
2678
|
+
} catch (error) {
|
|
2679
|
+
if (error instanceof AsgardeoAPIError) {
|
|
2680
|
+
throw error;
|
|
2681
|
+
}
|
|
2682
|
+
throw new AsgardeoAPIError(
|
|
2683
|
+
`Network or parsing error: ${error instanceof Error ? error.message : "Unknown error"}`,
|
|
2684
|
+
"updateMeProfile-NetworkError-001",
|
|
2685
|
+
"javascript",
|
|
2686
|
+
0,
|
|
2687
|
+
"Network Error"
|
|
1985
2688
|
);
|
|
1986
2689
|
}
|
|
1987
|
-
return await response.json();
|
|
1988
2690
|
};
|
|
1989
|
-
var
|
|
2691
|
+
var updateMeProfile_default = updateMeProfile;
|
|
1990
2692
|
|
|
1991
|
-
// src/
|
|
1992
|
-
var
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
writable: true
|
|
2009
|
-
});
|
|
2693
|
+
// src/constants/ApplicationNativeAuthenticationConstants.ts
|
|
2694
|
+
var ApplicationNativeAuthenticationConstants = {
|
|
2695
|
+
SupportedAuthenticators: {
|
|
2696
|
+
IdentifierFirst: "SWRlbnRpZmllckV4ZWN1dG9yOkxPQ0FM",
|
|
2697
|
+
EmailOtp: "ZW1haWwtb3RwLWF1dGhlbnRpY2F0b3I6TE9DQUw",
|
|
2698
|
+
Totp: "dG90cDpMT0NBTA",
|
|
2699
|
+
UsernamePassword: "QmFzaWNBdXRoZW50aWNhdG9yOkxPQ0FM",
|
|
2700
|
+
PushNotification: "cHVzaC1ub3RpZmljYXRpb24tYXV0aGVudGljYXRvcjpMT0NBTA",
|
|
2701
|
+
Passkey: "RklET0F1dGhlbnRpY2F0b3I6TE9DQUw",
|
|
2702
|
+
SmsOtp: "c21zLW90cC1hdXRoZW50aWNhdG9yOkxPQ0FM",
|
|
2703
|
+
MagicLink: "TWFnaWNMaW5rQXV0aGVudGljYXRvcjpMT0NBTA",
|
|
2704
|
+
Google: "R29vZ2xlT0lEQ0F1dGhlbnRpY2F0b3I6R29vZ2xl",
|
|
2705
|
+
GitHub: "R2l0aHViQXV0aGVudGljYXRvcjpHaXRIdWI",
|
|
2706
|
+
Microsoft: "T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I6TWljcm9zb2Z0",
|
|
2707
|
+
Facebook: "RmFjZWJvb2tBdXRoZW50aWNhdG9yOkZhY2Vib29r",
|
|
2708
|
+
LinkedIn: "TGlua2VkSW5PSURDOkxpbmtlZElu",
|
|
2709
|
+
SignInWithEthereum: "T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I6U2lnbiBJbiBXaXRoIEV0aGVyZXVt"
|
|
2010
2710
|
}
|
|
2711
|
+
};
|
|
2712
|
+
var ApplicationNativeAuthenticationConstants_default = ApplicationNativeAuthenticationConstants;
|
|
2713
|
+
|
|
2714
|
+
// src/constants/VendorConstants.ts
|
|
2715
|
+
var VendorConstants = {
|
|
2011
2716
|
/**
|
|
2012
|
-
*
|
|
2013
|
-
* @returns Formatted error string with name, code, details, and message
|
|
2717
|
+
* The prefix used for vendor-specific API endpoints, CSS classes, or other identifiers.
|
|
2014
2718
|
*/
|
|
2015
|
-
|
|
2016
|
-
const details = this.details ? `
|
|
2017
|
-
Details: ${JSON.stringify(this.details, null, 2)}` : "";
|
|
2018
|
-
return `[${this.name}] (code="${this.code}")${details}
|
|
2019
|
-
Message: ${this.message}`;
|
|
2020
|
-
}
|
|
2719
|
+
VENDOR_PREFIX: "asgardeo"
|
|
2021
2720
|
};
|
|
2721
|
+
var VendorConstants_default = VendorConstants;
|
|
2722
|
+
|
|
2723
|
+
// src/models/embedded-signin-flow.ts
|
|
2724
|
+
var EmbeddedSignInFlowStatus = /* @__PURE__ */ ((EmbeddedSignInFlowStatus2) => {
|
|
2725
|
+
EmbeddedSignInFlowStatus2["FailCompleted"] = "FAIL_COMPLETED";
|
|
2726
|
+
EmbeddedSignInFlowStatus2["FailIncomplete"] = "FAIL_INCOMPLETE";
|
|
2727
|
+
EmbeddedSignInFlowStatus2["Incomplete"] = "INCOMPLETE";
|
|
2728
|
+
EmbeddedSignInFlowStatus2["SuccessCompleted"] = "SUCCESS_COMPLETED";
|
|
2729
|
+
return EmbeddedSignInFlowStatus2;
|
|
2730
|
+
})(EmbeddedSignInFlowStatus || {});
|
|
2731
|
+
var EmbeddedSignInFlowType = /* @__PURE__ */ ((EmbeddedSignInFlowType2) => {
|
|
2732
|
+
EmbeddedSignInFlowType2["Authentication"] = "AUTHENTICATION";
|
|
2733
|
+
return EmbeddedSignInFlowType2;
|
|
2734
|
+
})(EmbeddedSignInFlowType || {});
|
|
2735
|
+
var EmbeddedSignInFlowStepType = /* @__PURE__ */ ((EmbeddedSignInFlowStepType2) => {
|
|
2736
|
+
EmbeddedSignInFlowStepType2["AuthenticatorPrompt"] = "AUTHENTICATOR_PROMPT";
|
|
2737
|
+
EmbeddedSignInFlowStepType2["MultiOptionsPrompt"] = "MULTI_OPTIONS_PROMPT";
|
|
2738
|
+
return EmbeddedSignInFlowStepType2;
|
|
2739
|
+
})(EmbeddedSignInFlowStepType || {});
|
|
2740
|
+
var EmbeddedSignInFlowAuthenticatorParamType = /* @__PURE__ */ ((EmbeddedSignInFlowAuthenticatorParamType2) => {
|
|
2741
|
+
EmbeddedSignInFlowAuthenticatorParamType2["Integer"] = "INTEGER";
|
|
2742
|
+
EmbeddedSignInFlowAuthenticatorParamType2["MultiValued"] = "MULTI_VALUED";
|
|
2743
|
+
EmbeddedSignInFlowAuthenticatorParamType2["String"] = "STRING";
|
|
2744
|
+
return EmbeddedSignInFlowAuthenticatorParamType2;
|
|
2745
|
+
})(EmbeddedSignInFlowAuthenticatorParamType || {});
|
|
2746
|
+
var EmbeddedSignInFlowAuthenticatorKnownIdPType = /* @__PURE__ */ ((EmbeddedSignInFlowAuthenticatorKnownIdPType2) => {
|
|
2747
|
+
EmbeddedSignInFlowAuthenticatorKnownIdPType2["Local"] = "LOCAL";
|
|
2748
|
+
return EmbeddedSignInFlowAuthenticatorKnownIdPType2;
|
|
2749
|
+
})(EmbeddedSignInFlowAuthenticatorKnownIdPType || {});
|
|
2750
|
+
var EmbeddedSignInFlowAuthenticatorPromptType = /* @__PURE__ */ ((EmbeddedSignInFlowAuthenticatorPromptType2) => {
|
|
2751
|
+
EmbeddedSignInFlowAuthenticatorPromptType2["InternalPrompt"] = "INTERNAL_PROMPT";
|
|
2752
|
+
EmbeddedSignInFlowAuthenticatorPromptType2["RedirectionPrompt"] = "REDIRECTION_PROMPT";
|
|
2753
|
+
EmbeddedSignInFlowAuthenticatorPromptType2["UserPrompt"] = "USER_PROMPT";
|
|
2754
|
+
return EmbeddedSignInFlowAuthenticatorPromptType2;
|
|
2755
|
+
})(EmbeddedSignInFlowAuthenticatorPromptType || {});
|
|
2756
|
+
|
|
2757
|
+
// src/models/flow.ts
|
|
2758
|
+
var FlowMode = /* @__PURE__ */ ((FlowMode2) => {
|
|
2759
|
+
FlowMode2["Embedded"] = "DIRECT";
|
|
2760
|
+
FlowMode2["Redirect"] = "REDIRECTION";
|
|
2761
|
+
return FlowMode2;
|
|
2762
|
+
})(FlowMode || {});
|
|
2022
2763
|
|
|
2023
2764
|
// src/models/scim2-schema.ts
|
|
2024
2765
|
var WellKnownSchemaIds = /* @__PURE__ */ ((WellKnownSchemaIds2) => {
|
|
@@ -2030,6 +2771,22 @@ var WellKnownSchemaIds = /* @__PURE__ */ ((WellKnownSchemaIds2) => {
|
|
|
2030
2771
|
return WellKnownSchemaIds2;
|
|
2031
2772
|
})(WellKnownSchemaIds || {});
|
|
2032
2773
|
|
|
2774
|
+
// src/models/field.ts
|
|
2775
|
+
var FieldType = /* @__PURE__ */ ((FieldType2) => {
|
|
2776
|
+
FieldType2["Text"] = "TEXT";
|
|
2777
|
+
FieldType2["Password"] = "PASSWORD";
|
|
2778
|
+
FieldType2["Email"] = "EMAIL";
|
|
2779
|
+
FieldType2["Number"] = "NUMBER";
|
|
2780
|
+
FieldType2["Select"] = "SELECT";
|
|
2781
|
+
FieldType2["Checkbox"] = "CHECKBOX";
|
|
2782
|
+
FieldType2["Radio"] = "RADIO";
|
|
2783
|
+
FieldType2["Otp"] = "OTP";
|
|
2784
|
+
FieldType2["Date"] = "DATE";
|
|
2785
|
+
FieldType2["Time"] = "TIME";
|
|
2786
|
+
FieldType2["Textarea"] = "TEXTAREA";
|
|
2787
|
+
return FieldType2;
|
|
2788
|
+
})(FieldType || {});
|
|
2789
|
+
|
|
2033
2790
|
// src/AsgardeoJavaScriptClient.ts
|
|
2034
2791
|
var AsgardeoJavaScriptClient = class {
|
|
2035
2792
|
};
|
|
@@ -2047,7 +2804,7 @@ var lightTheme = {
|
|
|
2047
2804
|
contrastText: "#ffffff"
|
|
2048
2805
|
},
|
|
2049
2806
|
background: {
|
|
2050
|
-
surface: "#
|
|
2807
|
+
surface: "#ffffff",
|
|
2051
2808
|
disabled: "#f0f0f0",
|
|
2052
2809
|
body: {
|
|
2053
2810
|
main: "#1a1a1a"
|
|
@@ -2057,7 +2814,14 @@ var lightTheme = {
|
|
|
2057
2814
|
main: "#d32f2f",
|
|
2058
2815
|
contrastText: "#ffffff"
|
|
2059
2816
|
},
|
|
2060
|
-
|
|
2817
|
+
success: {
|
|
2818
|
+
main: "#4caf50",
|
|
2819
|
+
contrastText: "#ffffff"
|
|
2820
|
+
},
|
|
2821
|
+
warning: {
|
|
2822
|
+
main: "#ff9800",
|
|
2823
|
+
contrastText: "#ffffff"
|
|
2824
|
+
},
|
|
2061
2825
|
text: {
|
|
2062
2826
|
primary: "#1a1a1a",
|
|
2063
2827
|
secondary: "#666666"
|
|
@@ -2071,6 +2835,11 @@ var lightTheme = {
|
|
|
2071
2835
|
small: "4px",
|
|
2072
2836
|
medium: "8px",
|
|
2073
2837
|
large: "16px"
|
|
2838
|
+
},
|
|
2839
|
+
shadows: {
|
|
2840
|
+
small: "0 2px 8px rgba(0, 0, 0, 0.1)",
|
|
2841
|
+
medium: "0 4px 16px rgba(0, 0, 0, 0.15)",
|
|
2842
|
+
large: "0 8px 32px rgba(0, 0, 0, 0.2)"
|
|
2074
2843
|
}
|
|
2075
2844
|
};
|
|
2076
2845
|
var darkTheme = {
|
|
@@ -2094,7 +2863,14 @@ var darkTheme = {
|
|
|
2094
2863
|
main: "#d32f2f",
|
|
2095
2864
|
contrastText: "#ffffff"
|
|
2096
2865
|
},
|
|
2097
|
-
|
|
2866
|
+
success: {
|
|
2867
|
+
main: "#4caf50",
|
|
2868
|
+
contrastText: "#ffffff"
|
|
2869
|
+
},
|
|
2870
|
+
warning: {
|
|
2871
|
+
main: "#ff9800",
|
|
2872
|
+
contrastText: "#ffffff"
|
|
2873
|
+
},
|
|
2098
2874
|
text: {
|
|
2099
2875
|
primary: "#ffffff",
|
|
2100
2876
|
secondary: "#b3b3b3"
|
|
@@ -2108,6 +2884,11 @@ var darkTheme = {
|
|
|
2108
2884
|
small: "4px",
|
|
2109
2885
|
medium: "8px",
|
|
2110
2886
|
large: "16px"
|
|
2887
|
+
},
|
|
2888
|
+
shadows: {
|
|
2889
|
+
small: "0 2px 8px rgba(0, 0, 0, 0.3)",
|
|
2890
|
+
medium: "0 4px 16px rgba(0, 0, 0, 0.4)",
|
|
2891
|
+
large: "0 8px 32px rgba(0, 0, 0, 0.5)"
|
|
2111
2892
|
}
|
|
2112
2893
|
};
|
|
2113
2894
|
var toCssVariables = (theme) => {
|
|
@@ -2121,7 +2902,10 @@ var toCssVariables = (theme) => {
|
|
|
2121
2902
|
cssVars["--asgardeo-color-background-body-main"] = theme.colors.background.body.main;
|
|
2122
2903
|
cssVars["--asgardeo-color-error-main"] = theme.colors.error.main;
|
|
2123
2904
|
cssVars["--asgardeo-color-error-contrastText"] = theme.colors.error.contrastText;
|
|
2124
|
-
cssVars["--asgardeo-color-
|
|
2905
|
+
cssVars["--asgardeo-color-success-main"] = theme.colors.success.main;
|
|
2906
|
+
cssVars["--asgardeo-color-success-contrastText"] = theme.colors.success.contrastText;
|
|
2907
|
+
cssVars["--asgardeo-color-warning-main"] = theme.colors.warning.main;
|
|
2908
|
+
cssVars["--asgardeo-color-warning-contrastText"] = theme.colors.warning.contrastText;
|
|
2125
2909
|
cssVars["--asgardeo-color-text-primary"] = theme.colors.text.primary;
|
|
2126
2910
|
cssVars["--asgardeo-color-text-secondary"] = theme.colors.text.secondary;
|
|
2127
2911
|
cssVars["--asgardeo-color-border"] = theme.colors.border;
|
|
@@ -2129,6 +2913,9 @@ var toCssVariables = (theme) => {
|
|
|
2129
2913
|
cssVars["--asgardeo-border-radius-small"] = theme.borderRadius.small;
|
|
2130
2914
|
cssVars["--asgardeo-border-radius-medium"] = theme.borderRadius.medium;
|
|
2131
2915
|
cssVars["--asgardeo-border-radius-large"] = theme.borderRadius.large;
|
|
2916
|
+
cssVars["--asgardeo-shadow-small"] = theme.shadows.small;
|
|
2917
|
+
cssVars["--asgardeo-shadow-medium"] = theme.shadows.medium;
|
|
2918
|
+
cssVars["--asgardeo-shadow-large"] = theme.shadows.large;
|
|
2132
2919
|
return cssVars;
|
|
2133
2920
|
};
|
|
2134
2921
|
var createTheme = (config = {}, isDark = false) => {
|
|
@@ -2151,6 +2938,10 @@ var createTheme = (config = {}, isDark = false) => {
|
|
|
2151
2938
|
borderRadius: {
|
|
2152
2939
|
...baseTheme.borderRadius,
|
|
2153
2940
|
...config.borderRadius
|
|
2941
|
+
},
|
|
2942
|
+
shadows: {
|
|
2943
|
+
...baseTheme.shadows,
|
|
2944
|
+
...config.shadows
|
|
2154
2945
|
}
|
|
2155
2946
|
};
|
|
2156
2947
|
return {
|
|
@@ -2160,27 +2951,416 @@ var createTheme = (config = {}, isDark = false) => {
|
|
|
2160
2951
|
};
|
|
2161
2952
|
var createTheme_default = createTheme;
|
|
2162
2953
|
|
|
2954
|
+
// src/utils/deepMerge.ts
|
|
2955
|
+
var isPlainObject = (value) => {
|
|
2956
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof RegExp) && Object.prototype.toString.call(value) === "[object Object]";
|
|
2957
|
+
};
|
|
2958
|
+
var deepMerge = (target, ...sources) => {
|
|
2959
|
+
if (!target || typeof target !== "object") {
|
|
2960
|
+
throw new Error("Target must be an object");
|
|
2961
|
+
}
|
|
2962
|
+
const result = { ...target };
|
|
2963
|
+
sources.forEach((source) => {
|
|
2964
|
+
if (!source || typeof source !== "object") {
|
|
2965
|
+
return;
|
|
2966
|
+
}
|
|
2967
|
+
Object.keys(source).forEach((key) => {
|
|
2968
|
+
const sourceValue = source[key];
|
|
2969
|
+
const targetValue = result[key];
|
|
2970
|
+
if (isPlainObject(sourceValue) && isPlainObject(targetValue)) {
|
|
2971
|
+
result[key] = deepMerge(targetValue, sourceValue);
|
|
2972
|
+
} else if (sourceValue !== void 0) {
|
|
2973
|
+
result[key] = sourceValue;
|
|
2974
|
+
}
|
|
2975
|
+
});
|
|
2976
|
+
});
|
|
2977
|
+
return result;
|
|
2978
|
+
};
|
|
2979
|
+
var deepMerge_default = deepMerge;
|
|
2980
|
+
|
|
2981
|
+
// src/utils/flattenUserSchema.ts
|
|
2982
|
+
var flattenUserSchema = (schemas) => {
|
|
2983
|
+
const flattenedAttributes = [];
|
|
2984
|
+
schemas.forEach((schema) => {
|
|
2985
|
+
if (schema.attributes && Array.isArray(schema.attributes)) {
|
|
2986
|
+
schema.attributes.forEach((attribute) => {
|
|
2987
|
+
if (attribute.subAttributes && Array.isArray(attribute.subAttributes)) {
|
|
2988
|
+
attribute.subAttributes.forEach((subAttribute) => {
|
|
2989
|
+
flattenedAttributes.push({
|
|
2990
|
+
...subAttribute,
|
|
2991
|
+
name: `${attribute.name}.${subAttribute.name}`,
|
|
2992
|
+
schemaId: schema.id
|
|
2993
|
+
});
|
|
2994
|
+
});
|
|
2995
|
+
} else {
|
|
2996
|
+
flattenedAttributes.push({
|
|
2997
|
+
...attribute,
|
|
2998
|
+
schemaId: schema.id
|
|
2999
|
+
});
|
|
3000
|
+
}
|
|
3001
|
+
});
|
|
3002
|
+
}
|
|
3003
|
+
});
|
|
3004
|
+
return flattenedAttributes;
|
|
3005
|
+
};
|
|
3006
|
+
var flattenUserSchema_default = flattenUserSchema;
|
|
3007
|
+
|
|
3008
|
+
// src/utils/get.ts
|
|
3009
|
+
var get = (object, path, defaultValue) => {
|
|
3010
|
+
if (!object || !path) return defaultValue;
|
|
3011
|
+
const pathArray = Array.isArray(path) ? path : path.split(".");
|
|
3012
|
+
const result = pathArray.reduce((current, key) => {
|
|
3013
|
+
return current?.[key];
|
|
3014
|
+
}, object);
|
|
3015
|
+
return result !== void 0 ? result : defaultValue;
|
|
3016
|
+
};
|
|
3017
|
+
var get_default = get;
|
|
3018
|
+
|
|
3019
|
+
// src/utils/set.ts
|
|
3020
|
+
var set = (object, path, value) => {
|
|
3021
|
+
if (!object || !path) return object;
|
|
3022
|
+
const pathArray = Array.isArray(path) ? path : path.split(".");
|
|
3023
|
+
const lastIndex = pathArray.length - 1;
|
|
3024
|
+
pathArray.reduce((current, key, index) => {
|
|
3025
|
+
if (index === lastIndex) {
|
|
3026
|
+
current[key] = value;
|
|
3027
|
+
} else {
|
|
3028
|
+
if (!(key in current) || typeof current[key] !== "object" || current[key] === null) {
|
|
3029
|
+
const nextKey = pathArray[index + 1];
|
|
3030
|
+
current[key] = /^\d+$/.test(nextKey) ? [] : {};
|
|
3031
|
+
}
|
|
3032
|
+
}
|
|
3033
|
+
return current[key];
|
|
3034
|
+
}, object);
|
|
3035
|
+
return object;
|
|
3036
|
+
};
|
|
3037
|
+
var set_default = set;
|
|
3038
|
+
|
|
3039
|
+
// src/utils/generateUserProfile.ts
|
|
3040
|
+
var generateUserProfile = (meResponse, processedSchemas) => {
|
|
3041
|
+
const profile = {};
|
|
3042
|
+
processedSchemas.forEach((schema) => {
|
|
3043
|
+
const { name, type, multiValued } = schema;
|
|
3044
|
+
if (!name) return;
|
|
3045
|
+
let value = get_default(meResponse, name);
|
|
3046
|
+
if (value !== void 0) {
|
|
3047
|
+
if (multiValued && !Array.isArray(value)) {
|
|
3048
|
+
value = [value];
|
|
3049
|
+
}
|
|
3050
|
+
} else {
|
|
3051
|
+
if (multiValued) {
|
|
3052
|
+
value = void 0;
|
|
3053
|
+
} else if (type === "STRING") {
|
|
3054
|
+
value = "";
|
|
3055
|
+
} else {
|
|
3056
|
+
value = void 0;
|
|
3057
|
+
}
|
|
3058
|
+
}
|
|
3059
|
+
set_default(profile, name, value);
|
|
3060
|
+
});
|
|
3061
|
+
return profile;
|
|
3062
|
+
};
|
|
3063
|
+
var generateUserProfile_default = generateUserProfile;
|
|
3064
|
+
|
|
3065
|
+
// src/utils/getLatestStateParam.ts
|
|
3066
|
+
var getLatestPkceStorageKey = (tempStore) => {
|
|
3067
|
+
const keys = [];
|
|
3068
|
+
Object.keys(tempStore).forEach((key) => {
|
|
3069
|
+
if (key.startsWith(PKCEConstants_default.Storage.StorageKeys.CODE_VERIFIER)) {
|
|
3070
|
+
keys.push(key);
|
|
3071
|
+
}
|
|
3072
|
+
});
|
|
3073
|
+
const lastKey = keys.sort().pop();
|
|
3074
|
+
return lastKey ?? null;
|
|
3075
|
+
};
|
|
3076
|
+
var getLatestStateParam = (tempStore, state) => {
|
|
3077
|
+
const latestPkceKey = getLatestPkceStorageKey(tempStore);
|
|
3078
|
+
if (!latestPkceKey) {
|
|
3079
|
+
return null;
|
|
3080
|
+
}
|
|
3081
|
+
return generateStateParamForRequestCorrelation_default(latestPkceKey, state);
|
|
3082
|
+
};
|
|
3083
|
+
var getLatestStateParam_default = getLatestStateParam;
|
|
3084
|
+
|
|
3085
|
+
// src/utils/generateFlattenedUserProfile.ts
|
|
3086
|
+
var generateFlattenedUserProfile = (meResponse, processedSchemas) => {
|
|
3087
|
+
const profile = {};
|
|
3088
|
+
const allSchemaNames = processedSchemas.map((schema) => schema.name).filter(Boolean);
|
|
3089
|
+
processedSchemas.forEach((schema) => {
|
|
3090
|
+
const { name, type, multiValued } = schema;
|
|
3091
|
+
if (!name) return;
|
|
3092
|
+
const hasChildProperties = allSchemaNames.some(
|
|
3093
|
+
(schemaName) => schemaName !== name && schemaName.startsWith(`${name}.`)
|
|
3094
|
+
);
|
|
3095
|
+
if (hasChildProperties) {
|
|
3096
|
+
return;
|
|
3097
|
+
}
|
|
3098
|
+
let value = get_default(meResponse, name);
|
|
3099
|
+
if (value === void 0) {
|
|
3100
|
+
const schemaNamespaces = [
|
|
3101
|
+
"urn:ietf:params:scim:schemas:core:2.0:User",
|
|
3102
|
+
"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User",
|
|
3103
|
+
"urn:scim:wso2:schema",
|
|
3104
|
+
"urn:scim:schemas:extension:custom:User"
|
|
3105
|
+
];
|
|
3106
|
+
schemaNamespaces.some((namespace) => {
|
|
3107
|
+
if (meResponse[namespace]) {
|
|
3108
|
+
if (meResponse[namespace][name] !== void 0) {
|
|
3109
|
+
value = meResponse[namespace][name];
|
|
3110
|
+
return true;
|
|
3111
|
+
}
|
|
3112
|
+
const nestedValue = get_default(meResponse[namespace], name);
|
|
3113
|
+
if (nestedValue !== void 0) {
|
|
3114
|
+
value = nestedValue;
|
|
3115
|
+
return true;
|
|
3116
|
+
}
|
|
3117
|
+
}
|
|
3118
|
+
return false;
|
|
3119
|
+
});
|
|
3120
|
+
}
|
|
3121
|
+
if (value !== void 0) {
|
|
3122
|
+
if (multiValued && !Array.isArray(value)) {
|
|
3123
|
+
value = [value];
|
|
3124
|
+
}
|
|
3125
|
+
} else if (multiValued) {
|
|
3126
|
+
value = void 0;
|
|
3127
|
+
} else if (type === "STRING") {
|
|
3128
|
+
value = "";
|
|
3129
|
+
} else {
|
|
3130
|
+
value = void 0;
|
|
3131
|
+
}
|
|
3132
|
+
profile[name] = value;
|
|
3133
|
+
});
|
|
3134
|
+
const flattenObject = (obj, prefix = "") => {
|
|
3135
|
+
if (obj && typeof obj === "object" && !Array.isArray(obj)) {
|
|
3136
|
+
Object.keys(obj).forEach((key) => {
|
|
3137
|
+
const fullKey = prefix ? `${prefix}.${key}` : key;
|
|
3138
|
+
const value = obj[key];
|
|
3139
|
+
if (Object.prototype.hasOwnProperty.call(profile, fullKey)) {
|
|
3140
|
+
return;
|
|
3141
|
+
}
|
|
3142
|
+
const hasSchemaChildProperties = allSchemaNames.some(
|
|
3143
|
+
(schemaName) => schemaName.startsWith(`${fullKey}.`)
|
|
3144
|
+
);
|
|
3145
|
+
if (hasSchemaChildProperties) {
|
|
3146
|
+
flattenObject(value, fullKey);
|
|
3147
|
+
} else {
|
|
3148
|
+
profile[fullKey] = value;
|
|
3149
|
+
}
|
|
3150
|
+
});
|
|
3151
|
+
}
|
|
3152
|
+
};
|
|
3153
|
+
flattenObject(meResponse);
|
|
3154
|
+
return profile;
|
|
3155
|
+
};
|
|
3156
|
+
var generateFlattenedUserProfile_default = generateFlattenedUserProfile;
|
|
3157
|
+
|
|
3158
|
+
// src/i18n/index.ts
|
|
3159
|
+
var i18n_exports = {};
|
|
3160
|
+
__export(i18n_exports, {
|
|
3161
|
+
en_US: () => en_US_default
|
|
3162
|
+
});
|
|
3163
|
+
|
|
3164
|
+
// src/i18n/en-US.ts
|
|
3165
|
+
var translations = {
|
|
3166
|
+
/* |---------------------------------------------------------------| */
|
|
3167
|
+
/* | Elements | */
|
|
3168
|
+
/* |---------------------------------------------------------------| */
|
|
3169
|
+
//* Buttons */
|
|
3170
|
+
"elements.buttons.signIn": "Sign In",
|
|
3171
|
+
"elements.buttons.signOut": "Sign Out",
|
|
3172
|
+
"elements.buttons.signUp": "Sign Up",
|
|
3173
|
+
"elements.buttons.facebook": "Continue with Facebook",
|
|
3174
|
+
"elements.buttons.google": "Continue with Google",
|
|
3175
|
+
"elements.buttons.github": "Continue with GitHub",
|
|
3176
|
+
"elements.buttons.microsoft": "Continue with Microsoft",
|
|
3177
|
+
"elements.buttons.linkedin": "Continue with LinkedIn",
|
|
3178
|
+
"elements.buttons.ethereum": "Continue with Sign In Ethereum",
|
|
3179
|
+
"elements.buttons.multi.option": "Continue with {connection}",
|
|
3180
|
+
"elements.buttons.social": "Continue with {connection}",
|
|
3181
|
+
/* Fields */
|
|
3182
|
+
"elements.fields.placeholder": "Enter your {field}",
|
|
3183
|
+
/* |---------------------------------------------------------------| */
|
|
3184
|
+
/* | Widgets | */
|
|
3185
|
+
/* |---------------------------------------------------------------| */
|
|
3186
|
+
/* Base Sign In */
|
|
3187
|
+
"signin.title": "Sign In",
|
|
3188
|
+
"signin.subtitle": "Enter your credentials to continue.",
|
|
3189
|
+
/* Base Sign Up */
|
|
3190
|
+
"signup.title": "Sign Up",
|
|
3191
|
+
"signup.subtitle": "Create a new account to get started.",
|
|
3192
|
+
/* Email OTP */
|
|
3193
|
+
"email.otp.title": "OTP Verification",
|
|
3194
|
+
"email.otp.subtitle": "Enter the code sent to your email address.",
|
|
3195
|
+
"email.otp.submit.button": "Continue",
|
|
3196
|
+
/* Identifier First */
|
|
3197
|
+
"identifier.first.title": "Sign In",
|
|
3198
|
+
"identifier.first.subtitle": "Enter your username or email address.",
|
|
3199
|
+
"identifier.first.submit.button": "Continue",
|
|
3200
|
+
/* SMS OTP */
|
|
3201
|
+
"sms.otp.title": "OTP Verification",
|
|
3202
|
+
"sms.otp.subtitle": "Enter the code sent to your phone number.",
|
|
3203
|
+
"sms.otp.submit.button": "Continue",
|
|
3204
|
+
/* TOTP */
|
|
3205
|
+
"totp.title": "Verify Your Identity",
|
|
3206
|
+
"totp.subtitle": "Enter the code from your authenticator app.",
|
|
3207
|
+
"totp.submit.button": "Continue",
|
|
3208
|
+
/* Username Password */
|
|
3209
|
+
"username.password.submit.button": "Continue",
|
|
3210
|
+
"username.password.title": "Sign In",
|
|
3211
|
+
"username.password.subtitle": "Enter your username and password to continue.",
|
|
3212
|
+
/* |---------------------------------------------------------------| */
|
|
3213
|
+
/* | Organization Switcher | */
|
|
3214
|
+
/* |---------------------------------------------------------------| */
|
|
3215
|
+
"organization.switcher.select.organization": "Select Organization",
|
|
3216
|
+
"organization.switcher.switch.organization": "Switch Organization",
|
|
3217
|
+
"organization.switcher.loading.organizations": "Loading organizations...",
|
|
3218
|
+
"organization.switcher.members": "members",
|
|
3219
|
+
"organization.switcher.member": "member",
|
|
3220
|
+
"organization.switcher.create.organization": "Create Organization",
|
|
3221
|
+
"organization.switcher.manage.organizations": "Manage Organization",
|
|
3222
|
+
"organization.switcher.manage.button": "Manage",
|
|
3223
|
+
"organization.profile.title": "Organization Profile",
|
|
3224
|
+
"organization.profile.loading": "Loading organization...",
|
|
3225
|
+
"organization.profile.error": "Failed to load organization",
|
|
3226
|
+
"organization.create.title": "Create Organization",
|
|
3227
|
+
"organization.create.name.label": "Organization Name",
|
|
3228
|
+
"organization.create.name.placeholder": "Enter organization name",
|
|
3229
|
+
"organization.create.handle.label": "Organization Handle",
|
|
3230
|
+
"organization.create.handle.placeholder": "my-organization",
|
|
3231
|
+
"organization.create.description.label": "Description",
|
|
3232
|
+
"organization.create.description.placeholder": "Enter organization description",
|
|
3233
|
+
"organization.create.button": "Create Organization",
|
|
3234
|
+
"organization.create.creating": "Creating...",
|
|
3235
|
+
"organization.create.cancel": "Cancel",
|
|
3236
|
+
/* |---------------------------------------------------------------| */
|
|
3237
|
+
/* | Messages | */
|
|
3238
|
+
/* |---------------------------------------------------------------| */
|
|
3239
|
+
"messages.loading": "Loading...",
|
|
3240
|
+
/* |---------------------------------------------------------------| */
|
|
3241
|
+
/* | Errors | */
|
|
3242
|
+
/* |---------------------------------------------------------------| */
|
|
3243
|
+
"errors.title": "Error",
|
|
3244
|
+
"errors.sign.in.initialization": "An error occurred while initializing. Please try again later.",
|
|
3245
|
+
"errors.sign.in.flow.failure": "An error occurred during the sign-in flow. Please try again later.",
|
|
3246
|
+
"errors.sign.in.flow.completion.failure": "An error occurred while completing the sign-in flow. Please try again later.",
|
|
3247
|
+
"errors.sign.in.flow.passkeys.failure": "An error occurred while signing in with passkeys. Please try again later.",
|
|
3248
|
+
"errors.sign.in.flow.passkeys.completion.failure": "An error occurred while completing the passkeys sign-in flow. Please try again later."
|
|
3249
|
+
};
|
|
3250
|
+
var metadata = {
|
|
3251
|
+
localeCode: "en-US",
|
|
3252
|
+
countryCode: "US",
|
|
3253
|
+
languageCode: "en",
|
|
3254
|
+
displayName: "English (United States)",
|
|
3255
|
+
direction: "ltr"
|
|
3256
|
+
};
|
|
3257
|
+
var en_US = {
|
|
3258
|
+
metadata,
|
|
3259
|
+
translations
|
|
3260
|
+
};
|
|
3261
|
+
var en_US_default = en_US;
|
|
3262
|
+
|
|
3263
|
+
// src/utils/getI18nBundles.ts
|
|
3264
|
+
var getI18nBundles = () => {
|
|
3265
|
+
return i18n_exports;
|
|
3266
|
+
};
|
|
3267
|
+
var getI18nBundles_default = getI18nBundles;
|
|
3268
|
+
|
|
2163
3269
|
// src/utils/removeTrailingSlash.ts
|
|
2164
3270
|
var removeTrailingSlash = (path) => path.endsWith("/") ? path.slice(0, -1) : path;
|
|
2165
3271
|
var removeTrailingSlash_default = removeTrailingSlash;
|
|
3272
|
+
|
|
3273
|
+
// src/utils/resolveFieldType.ts
|
|
3274
|
+
var resolveFieldType = (field) => {
|
|
3275
|
+
if (field.type === "STRING" /* String */) {
|
|
3276
|
+
if (field.param === "OTPCode" /* Otp */) {
|
|
3277
|
+
return "OTP" /* Otp */;
|
|
3278
|
+
} else if (field?.confidential) {
|
|
3279
|
+
return "PASSWORD" /* Password */;
|
|
3280
|
+
}
|
|
3281
|
+
return "TEXT" /* Text */;
|
|
3282
|
+
}
|
|
3283
|
+
throw new AsgardeoRuntimeError(
|
|
3284
|
+
"Field type is not supported: " + field.type,
|
|
3285
|
+
"resolveFieldType-Invalid-001",
|
|
3286
|
+
"javascript",
|
|
3287
|
+
"The provided field type is not supported. Please check the field configuration."
|
|
3288
|
+
);
|
|
3289
|
+
};
|
|
3290
|
+
var resolveFieldType_default = resolveFieldType;
|
|
3291
|
+
|
|
3292
|
+
// src/utils/resolveFieldName.ts
|
|
3293
|
+
var resolveFieldName = (field) => {
|
|
3294
|
+
if (field.param) {
|
|
3295
|
+
return field.param;
|
|
3296
|
+
}
|
|
3297
|
+
throw new AsgardeoRuntimeError(
|
|
3298
|
+
"Field name is not supported: ",
|
|
3299
|
+
"resolveFieldName-Invalid-001",
|
|
3300
|
+
"javascript",
|
|
3301
|
+
"The provided field name is not supported. Please check the field configuration."
|
|
3302
|
+
);
|
|
3303
|
+
};
|
|
3304
|
+
var resolveFieldName_default = resolveFieldName;
|
|
3305
|
+
|
|
3306
|
+
// src/utils/withVendorCSSClassPrefix.ts
|
|
3307
|
+
var withVendorCSSClassPrefix = (className) => `${VendorConstants_default.VENDOR_PREFIX}-${className}`;
|
|
3308
|
+
var withVendorCSSClassPrefix_default = withVendorCSSClassPrefix;
|
|
2166
3309
|
export {
|
|
2167
|
-
|
|
3310
|
+
ApplicationNativeAuthenticationConstants_default as ApplicationNativeAuthenticationConstants,
|
|
2168
3311
|
AsgardeoAPIError,
|
|
2169
3312
|
AsgardeoAuthClient,
|
|
2170
3313
|
AsgardeoAuthException,
|
|
2171
3314
|
AsgardeoError,
|
|
2172
3315
|
AsgardeoJavaScriptClient_default as AsgardeoJavaScriptClient,
|
|
2173
3316
|
AsgardeoRuntimeError,
|
|
2174
|
-
|
|
3317
|
+
EmbeddedFlowComponentType,
|
|
3318
|
+
EmbeddedFlowResponseType,
|
|
3319
|
+
EmbeddedFlowStatus,
|
|
3320
|
+
EmbeddedFlowType,
|
|
3321
|
+
EmbeddedSignInFlowAuthenticatorKnownIdPType,
|
|
3322
|
+
EmbeddedSignInFlowAuthenticatorParamType,
|
|
3323
|
+
EmbeddedSignInFlowAuthenticatorPromptType,
|
|
3324
|
+
EmbeddedSignInFlowStatus,
|
|
3325
|
+
EmbeddedSignInFlowStepType,
|
|
3326
|
+
EmbeddedSignInFlowType,
|
|
3327
|
+
FieldType,
|
|
3328
|
+
FlowMode,
|
|
2175
3329
|
IsomorphicCrypto,
|
|
2176
3330
|
OIDCRequestConstants_default as OIDCRequestConstants,
|
|
2177
|
-
|
|
3331
|
+
StorageManager_default as StorageManager,
|
|
2178
3332
|
TokenConstants_default as TokenConstants,
|
|
3333
|
+
VendorConstants_default as VendorConstants,
|
|
2179
3334
|
WellKnownSchemaIds,
|
|
3335
|
+
createOrganization_default as createOrganization,
|
|
3336
|
+
createPatchOperations,
|
|
2180
3337
|
createTheme_default as createTheme,
|
|
3338
|
+
deepMerge_default as deepMerge,
|
|
3339
|
+
executeEmbeddedSignInFlow_default as executeEmbeddedSignInFlow,
|
|
3340
|
+
executeEmbeddedSignUpFlow_default as executeEmbeddedSignUpFlow,
|
|
2181
3341
|
extractPkceStorageKeyFromState_default as extractPkceStorageKeyFromState,
|
|
2182
3342
|
extractUserClaimsFromIdToken_default as extractUserClaimsFromIdToken,
|
|
3343
|
+
flattenUserSchema_default as flattenUserSchema,
|
|
3344
|
+
generateFlattenedUserProfile_default as generateFlattenedUserProfile,
|
|
3345
|
+
generateUserProfile_default as generateUserProfile,
|
|
3346
|
+
get_default as get,
|
|
3347
|
+
getAllOrganizations_default as getAllOrganizations,
|
|
3348
|
+
getI18nBundles_default as getI18nBundles,
|
|
3349
|
+
getLatestStateParam_default as getLatestStateParam,
|
|
3350
|
+
getMeOrganizations_default as getMeOrganizations,
|
|
3351
|
+
getOrganization_default as getOrganization,
|
|
3352
|
+
getSchemas_default as getSchemas,
|
|
3353
|
+
getScim2Me_default as getScim2Me,
|
|
2183
3354
|
getUserInfo_default as getUserInfo,
|
|
2184
|
-
|
|
3355
|
+
initializeEmbeddedSignInFlow_default as initializeEmbeddedSignInFlow,
|
|
3356
|
+
isEmpty_default as isEmpty,
|
|
3357
|
+
processOpenIDScopes_default as processOpenIDScopes,
|
|
3358
|
+
removeTrailingSlash_default as removeTrailingSlash,
|
|
3359
|
+
resolveFieldName_default as resolveFieldName,
|
|
3360
|
+
resolveFieldType_default as resolveFieldType,
|
|
3361
|
+
set_default as set,
|
|
3362
|
+
updateMeProfile_default as updateMeProfile,
|
|
3363
|
+
updateOrganization_default as updateOrganization,
|
|
3364
|
+
withVendorCSSClassPrefix_default as withVendorCSSClassPrefix
|
|
2185
3365
|
};
|
|
2186
3366
|
//# sourceMappingURL=index.js.map
|