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