@asgardeo/javascript 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/AsgardeoJavaScriptClient.d.ts +2 -1
- package/dist/IsomorphicCrypto.d.ts +4 -4
- package/dist/{__legacy__/data/data-layer.d.ts → StorageManager.d.ts} +26 -25
- package/dist/__legacy__/client.d.ts +82 -98
- package/dist/__legacy__/helpers/authentication-helper.d.ts +8 -8
- package/dist/__legacy__/models/client-config.d.ts +6 -6
- package/dist/__legacy__/models/index.d.ts +0 -5
- package/dist/api/{oidc/getUserInfo.d.ts → getUserInfo.d.ts} +1 -1
- package/dist/api/handleApplicationNativeAuthentication.d.ts +33 -0
- package/dist/api/initializeApplicationNativeAuthentication.d.ts +117 -0
- package/dist/cjs/index.js +1581 -1188
- package/dist/cjs/index.js.map +4 -4
- package/dist/constants/ApplicationNativeAuthenticationConstants.d.ts +39 -0
- package/dist/constants/OIDCRequestConstants.d.ts +14 -0
- package/dist/constants/PKCEConstants.d.ts +1 -0
- package/dist/constants/TokenExchangeConstants.d.ts +1 -1
- package/dist/{__legacy__/exception → errors}/exception.d.ts +3 -0
- package/dist/{__legacy__/data/index.d.ts → i18n/en-US.d.ts} +4 -2
- package/dist/{__legacy__/exception → i18n}/index.d.ts +2 -2
- package/dist/index.d.ts +28 -10
- package/dist/index.js +1562 -1184
- package/dist/index.js.map +4 -4
- package/dist/models/application-native-authentication.d.ts +82 -0
- package/dist/models/client.d.ts +8 -2
- package/dist/models/config.d.ts +26 -1
- package/dist/models/crypto.d.ts +2 -2
- package/dist/{__legacy__/models/custom-grant.d.ts → models/field.d.ts} +13 -9
- package/dist/models/i18n.d.ts +66 -0
- package/dist/{__legacy__/models/authorization-url.d.ts → models/oauth-request.d.ts} +3 -3
- package/dist/models/oauth-response.d.ts +1 -17
- package/dist/models/scim2-schema.d.ts +3 -0
- package/dist/{__legacy__/models/data.d.ts → models/session.d.ts} +4 -0
- package/dist/models/store.d.ts +1 -1
- package/dist/models/token.d.ts +47 -0
- package/dist/models/user.d.ts +11 -84
- package/dist/theme/types.d.ts +0 -1
- package/dist/utils/deepMerge.d.ts +44 -0
- package/dist/utils/extractTenantDomainFromIdTokenPayload.d.ts +1 -1
- package/dist/utils/extractUserClaimsFromIdToken.d.ts +1 -1
- package/dist/utils/flattenUserSchema.d.ts +64 -0
- package/dist/utils/generateFlattenedUserProfile.d.ts +46 -0
- package/dist/utils/generateUserProfile.d.ts +55 -0
- package/dist/utils/get.d.ts +29 -0
- package/dist/utils/getAuthorizeRequestUrlParams.d.ts +59 -0
- package/dist/utils/getI18nBundles.d.ts +26 -0
- package/dist/utils/getLatestStateParam.d.ts +40 -0
- package/dist/utils/processOpenIDScopes.d.ts +36 -0
- package/dist/{__legacy__/core/index.d.ts → utils/resolveFieldName.d.ts} +3 -2
- package/dist/utils/resolveFieldType.d.ts +20 -0
- package/dist/utils/set.d.ts +30 -0
- package/package.json +4 -4
- package/dist/__legacy__/core/authentication-core.d.ts +0 -51
- package/dist/__legacy__/models/fetch.d.ts +0 -55
- package/dist/__legacy__/models/user.d.ts +0 -85
- package/dist/models/id-token.d.ts +0 -55
package/dist/cjs/index.js
CHANGED
|
@@ -21,132 +21,183 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
21
21
|
// src/index.ts
|
|
22
22
|
var index_exports = {};
|
|
23
23
|
__export(index_exports, {
|
|
24
|
-
|
|
24
|
+
ApplicationNativeAuthenticationAuthenticatorKnownIdPType: () => ApplicationNativeAuthenticationAuthenticatorKnownIdPType,
|
|
25
|
+
ApplicationNativeAuthenticationAuthenticatorParamType: () => ApplicationNativeAuthenticationAuthenticatorParamType,
|
|
26
|
+
ApplicationNativeAuthenticationAuthenticatorPromptType: () => ApplicationNativeAuthenticationAuthenticatorPromptType,
|
|
27
|
+
ApplicationNativeAuthenticationConstants: () => ApplicationNativeAuthenticationConstants_default,
|
|
28
|
+
ApplicationNativeAuthenticationFlowStatus: () => ApplicationNativeAuthenticationFlowStatus,
|
|
29
|
+
ApplicationNativeAuthenticationFlowType: () => ApplicationNativeAuthenticationFlowType,
|
|
30
|
+
ApplicationNativeAuthenticationStepType: () => ApplicationNativeAuthenticationStepType,
|
|
25
31
|
AsgardeoAPIError: () => AsgardeoAPIError,
|
|
26
32
|
AsgardeoAuthClient: () => AsgardeoAuthClient,
|
|
27
33
|
AsgardeoAuthException: () => AsgardeoAuthException,
|
|
28
34
|
AsgardeoError: () => AsgardeoError,
|
|
29
35
|
AsgardeoJavaScriptClient: () => AsgardeoJavaScriptClient_default,
|
|
30
36
|
AsgardeoRuntimeError: () => AsgardeoRuntimeError,
|
|
31
|
-
|
|
37
|
+
FieldType: () => FieldType,
|
|
32
38
|
IsomorphicCrypto: () => IsomorphicCrypto,
|
|
33
39
|
OIDCRequestConstants: () => OIDCRequestConstants_default,
|
|
34
|
-
|
|
40
|
+
StorageManager: () => StorageManager_default,
|
|
35
41
|
TokenConstants: () => TokenConstants_default,
|
|
36
42
|
WellKnownSchemaIds: () => WellKnownSchemaIds,
|
|
37
43
|
createTheme: () => createTheme_default,
|
|
44
|
+
deepMerge: () => deepMerge_default,
|
|
38
45
|
extractPkceStorageKeyFromState: () => extractPkceStorageKeyFromState_default,
|
|
39
46
|
extractUserClaimsFromIdToken: () => extractUserClaimsFromIdToken_default,
|
|
47
|
+
flattenUserSchema: () => flattenUserSchema_default,
|
|
48
|
+
generateFlattenedUserProfile: () => generateFlattenedUserProfile_default,
|
|
49
|
+
generateUserProfile: () => generateUserProfile_default,
|
|
50
|
+
get: () => get_default,
|
|
51
|
+
getI18nBundles: () => getI18nBundles_default,
|
|
52
|
+
getLatestStateParam: () => getLatestStateParam_default,
|
|
40
53
|
getUserInfo: () => getUserInfo_default,
|
|
41
|
-
|
|
54
|
+
handleApplicationNativeAuthentication: () => handleApplicationNativeAuthentication_default,
|
|
55
|
+
initializeApplicationNativeAuthentication: () => initializeApplicationNativeAuthentication_default,
|
|
56
|
+
processOpenIDScopes: () => processOpenIDScopes_default,
|
|
57
|
+
removeTrailingSlash: () => removeTrailingSlash_default,
|
|
58
|
+
resolveFieldName: () => resolveFieldName_default,
|
|
59
|
+
resolveFieldType: () => resolveFieldType_default,
|
|
60
|
+
set: () => set_default
|
|
42
61
|
});
|
|
43
62
|
module.exports = __toCommonJS(index_exports);
|
|
44
63
|
|
|
45
|
-
// src/
|
|
46
|
-
var
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
// src/StorageManager.ts
|
|
65
|
+
var ASGARDEO_SESSION_ACTIVE = "asgardeo-session-active";
|
|
66
|
+
var StorageManager = class {
|
|
67
|
+
constructor(instanceID, store) {
|
|
68
|
+
__publicField(this, "_id");
|
|
69
|
+
__publicField(this, "_store");
|
|
70
|
+
this._id = instanceID;
|
|
71
|
+
this._store = store;
|
|
72
|
+
}
|
|
73
|
+
async setDataInBulk(key, data) {
|
|
74
|
+
const existingDataJSON = await this._store.getData(key) ?? null;
|
|
75
|
+
const existingData = existingDataJSON && JSON.parse(existingDataJSON);
|
|
76
|
+
const dataToBeSaved = { ...existingData, ...data };
|
|
77
|
+
const dataToBeSavedJSON = JSON.stringify(dataToBeSaved);
|
|
78
|
+
await this._store.setData(key, dataToBeSavedJSON);
|
|
79
|
+
}
|
|
80
|
+
async setValue(key, attribute, value) {
|
|
81
|
+
const existingDataJSON = await this._store.getData(key) ?? null;
|
|
82
|
+
const existingData = existingDataJSON && JSON.parse(existingDataJSON);
|
|
83
|
+
const dataToBeSaved = { ...existingData, [attribute]: value };
|
|
84
|
+
const dataToBeSavedJSON = JSON.stringify(dataToBeSaved);
|
|
85
|
+
await this._store.setData(key, dataToBeSavedJSON);
|
|
86
|
+
}
|
|
87
|
+
async removeValue(key, attribute) {
|
|
88
|
+
const existingDataJSON = await this._store.getData(key) ?? null;
|
|
89
|
+
const existingData = existingDataJSON && JSON.parse(existingDataJSON);
|
|
90
|
+
const dataToBeSaved = { ...existingData };
|
|
91
|
+
delete dataToBeSaved[attribute];
|
|
92
|
+
const dataToBeSavedJSON = JSON.stringify(dataToBeSaved);
|
|
93
|
+
await this._store.setData(key, dataToBeSavedJSON);
|
|
94
|
+
}
|
|
95
|
+
_resolveKey(store, userId) {
|
|
96
|
+
return userId ? `${store}-${this._id}-${userId}` : `${store}-${this._id}`;
|
|
97
|
+
}
|
|
98
|
+
isLocalStorageAvailable() {
|
|
99
|
+
try {
|
|
100
|
+
const testValue = "__ASGARDEO_AUTH_CORE_LOCAL_STORAGE_TEST__";
|
|
101
|
+
localStorage.setItem(testValue, testValue);
|
|
102
|
+
localStorage.removeItem(testValue);
|
|
103
|
+
return true;
|
|
104
|
+
} catch (error) {
|
|
105
|
+
return false;
|
|
66
106
|
}
|
|
67
107
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
this.
|
|
94
|
-
|
|
108
|
+
async setConfigData(config) {
|
|
109
|
+
await this.setDataInBulk(this._resolveKey("config_data" /* ConfigData */), config);
|
|
110
|
+
}
|
|
111
|
+
async setOIDCProviderMetaData(oidcProviderMetaData) {
|
|
112
|
+
this.setDataInBulk(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), oidcProviderMetaData);
|
|
113
|
+
}
|
|
114
|
+
async setTemporaryData(temporaryData, userId) {
|
|
115
|
+
this.setDataInBulk(this._resolveKey("temporary_data" /* TemporaryData */, userId), temporaryData);
|
|
116
|
+
}
|
|
117
|
+
async setSessionData(sessionData, userId) {
|
|
118
|
+
this.setDataInBulk(this._resolveKey("session_data" /* SessionData */, userId), sessionData);
|
|
119
|
+
}
|
|
120
|
+
async setCustomData(key, customData, userId) {
|
|
121
|
+
this.setDataInBulk(this._resolveKey(key, userId), customData);
|
|
122
|
+
}
|
|
123
|
+
async getConfigData() {
|
|
124
|
+
return JSON.parse(await this._store.getData(this._resolveKey("config_data" /* ConfigData */)) ?? null);
|
|
125
|
+
}
|
|
126
|
+
async loadOpenIDProviderConfiguration() {
|
|
127
|
+
return JSON.parse(await this._store.getData(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */)) ?? null);
|
|
128
|
+
}
|
|
129
|
+
async getTemporaryData(userId) {
|
|
130
|
+
return JSON.parse(await this._store.getData(this._resolveKey("temporary_data" /* TemporaryData */, userId)) ?? null);
|
|
131
|
+
}
|
|
132
|
+
async getSessionData(userId) {
|
|
133
|
+
return JSON.parse(await this._store.getData(this._resolveKey("session_data" /* SessionData */, userId)) ?? null);
|
|
134
|
+
}
|
|
135
|
+
async getCustomData(key, userId) {
|
|
136
|
+
return JSON.parse(await this._store.getData(this._resolveKey(key, userId)) ?? null);
|
|
137
|
+
}
|
|
138
|
+
setSessionStatus(status) {
|
|
139
|
+
this.isLocalStorageAvailable() && localStorage.setItem(`${ASGARDEO_SESSION_ACTIVE}`, status);
|
|
140
|
+
}
|
|
141
|
+
getSessionStatus() {
|
|
142
|
+
return this.isLocalStorageAvailable() ? localStorage.getItem(`${ASGARDEO_SESSION_ACTIVE}`) ?? "" : "";
|
|
143
|
+
}
|
|
144
|
+
removeSessionStatus() {
|
|
145
|
+
this.isLocalStorageAvailable() && localStorage.removeItem(`${ASGARDEO_SESSION_ACTIVE}`);
|
|
146
|
+
}
|
|
147
|
+
async removeConfigData() {
|
|
148
|
+
await this._store.removeData(this._resolveKey("config_data" /* ConfigData */));
|
|
149
|
+
}
|
|
150
|
+
async removeOIDCProviderMetaData() {
|
|
151
|
+
await this._store.removeData(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */));
|
|
152
|
+
}
|
|
153
|
+
async removeTemporaryData(userId) {
|
|
154
|
+
await this._store.removeData(this._resolveKey("temporary_data" /* TemporaryData */, userId));
|
|
155
|
+
}
|
|
156
|
+
async removeSessionData(userId) {
|
|
157
|
+
await this._store.removeData(this._resolveKey("session_data" /* SessionData */, userId));
|
|
158
|
+
}
|
|
159
|
+
async getConfigDataParameter(key) {
|
|
160
|
+
const data = await this._store.getData(this._resolveKey("config_data" /* ConfigData */));
|
|
161
|
+
return data && JSON.parse(data)[key];
|
|
162
|
+
}
|
|
163
|
+
async getOIDCProviderMetaDataParameter(key) {
|
|
164
|
+
const data = await this._store.getData(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */));
|
|
165
|
+
return data && JSON.parse(data)[key];
|
|
166
|
+
}
|
|
167
|
+
async getTemporaryDataParameter(key, userId) {
|
|
168
|
+
const data = await this._store.getData(this._resolveKey("temporary_data" /* TemporaryData */, userId));
|
|
169
|
+
return data && JSON.parse(data)[key];
|
|
170
|
+
}
|
|
171
|
+
async getSessionDataParameter(key, userId) {
|
|
172
|
+
const data = await this._store.getData(this._resolveKey("session_data" /* SessionData */, userId));
|
|
173
|
+
return data && JSON.parse(data)[key];
|
|
174
|
+
}
|
|
175
|
+
async setConfigDataParameter(key, value) {
|
|
176
|
+
await this.setValue(this._resolveKey("config_data" /* ConfigData */), key, value);
|
|
177
|
+
}
|
|
178
|
+
async setOIDCProviderMetaDataParameter(key, value) {
|
|
179
|
+
await this.setValue(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), key, value);
|
|
180
|
+
}
|
|
181
|
+
async setTemporaryDataParameter(key, value, userId) {
|
|
182
|
+
await this.setValue(this._resolveKey("temporary_data" /* TemporaryData */, userId), key, value);
|
|
183
|
+
}
|
|
184
|
+
async setSessionDataParameter(key, value, userId) {
|
|
185
|
+
await this.setValue(this._resolveKey("session_data" /* SessionData */, userId), key, value);
|
|
186
|
+
}
|
|
187
|
+
async removeConfigDataParameter(key) {
|
|
188
|
+
await this.removeValue(this._resolveKey("config_data" /* ConfigData */), key);
|
|
189
|
+
}
|
|
190
|
+
async removeOIDCProviderMetaDataParameter(key) {
|
|
191
|
+
await this.removeValue(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), key);
|
|
192
|
+
}
|
|
193
|
+
async removeTemporaryDataParameter(key, userId) {
|
|
194
|
+
await this.removeValue(this._resolveKey("temporary_data" /* TemporaryData */, userId), key);
|
|
195
|
+
}
|
|
196
|
+
async removeSessionDataParameter(key, userId) {
|
|
197
|
+
await this.removeValue(this._resolveKey("session_data" /* SessionData */, userId), key);
|
|
95
198
|
}
|
|
96
199
|
};
|
|
97
|
-
|
|
98
|
-
// src/utils/extractTenantDomainFromIdTokenPayload.ts
|
|
99
|
-
var extractTenantDomainFromIdTokenPayload = (payload, subjectSeparator = "@") => {
|
|
100
|
-
const uid = payload.sub;
|
|
101
|
-
if (!uid) return "";
|
|
102
|
-
const tokens = uid.split(subjectSeparator);
|
|
103
|
-
return tokens.length > 2 ? tokens[tokens.length - 1] : "";
|
|
104
|
-
};
|
|
105
|
-
var extractTenantDomainFromIdTokenPayload_default = extractTenantDomainFromIdTokenPayload;
|
|
106
|
-
|
|
107
|
-
// src/utils/extractUserClaimsFromIdToken.ts
|
|
108
|
-
var extractUserClaimsFromIdToken = (payload) => {
|
|
109
|
-
const filteredPayload = { ...payload };
|
|
110
|
-
const protocolClaims = [
|
|
111
|
-
"iss",
|
|
112
|
-
"aud",
|
|
113
|
-
"exp",
|
|
114
|
-
"iat",
|
|
115
|
-
"acr",
|
|
116
|
-
"amr",
|
|
117
|
-
"azp",
|
|
118
|
-
"auth_time",
|
|
119
|
-
"nonce",
|
|
120
|
-
"c_hash",
|
|
121
|
-
"at_hash",
|
|
122
|
-
"nbf",
|
|
123
|
-
"isk",
|
|
124
|
-
"sid",
|
|
125
|
-
"jti",
|
|
126
|
-
"sub"
|
|
127
|
-
];
|
|
128
|
-
protocolClaims.forEach((claim) => {
|
|
129
|
-
delete filteredPayload[claim];
|
|
130
|
-
});
|
|
131
|
-
const userClaims = {};
|
|
132
|
-
Object.entries(filteredPayload).forEach(([key, value]) => {
|
|
133
|
-
const camelCasedKey = key.split("_").map((part, i) => i === 0 ? part : part[0].toUpperCase() + part.slice(1)).join("");
|
|
134
|
-
userClaims[camelCasedKey] = value;
|
|
135
|
-
});
|
|
136
|
-
return userClaims;
|
|
137
|
-
};
|
|
138
|
-
var extractUserClaimsFromIdToken_default = extractUserClaimsFromIdToken;
|
|
139
|
-
|
|
140
|
-
// src/constants/ScopeConstants.ts
|
|
141
|
-
var ScopeConstants = {
|
|
142
|
-
/**
|
|
143
|
-
* The base OpenID Connect scope.
|
|
144
|
-
* Required for all OpenID Connect flows. Indicates that the client
|
|
145
|
-
* is initiating an OpenID Connect authentication request.
|
|
146
|
-
*/
|
|
147
|
-
OPENID: "openid"
|
|
148
|
-
};
|
|
149
|
-
var ScopeConstants_default = ScopeConstants;
|
|
200
|
+
var StorageManager_default = StorageManager;
|
|
150
201
|
|
|
151
202
|
// src/constants/OIDCDiscoveryConstants.ts
|
|
152
203
|
var OIDCDiscoveryConstants = {
|
|
@@ -267,279 +318,53 @@ var OIDCDiscoveryConstants = {
|
|
|
267
318
|
};
|
|
268
319
|
var OIDCDiscoveryConstants_default = OIDCDiscoveryConstants;
|
|
269
320
|
|
|
270
|
-
// src/constants/
|
|
271
|
-
var
|
|
321
|
+
// src/constants/ScopeConstants.ts
|
|
322
|
+
var ScopeConstants = {
|
|
272
323
|
/**
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
324
|
+
* The base OpenID Connect scope.
|
|
325
|
+
* Required for all OpenID Connect flows. Indicates that the client
|
|
326
|
+
* is initiating an OpenID Connect authentication request.
|
|
276
327
|
*/
|
|
277
|
-
|
|
328
|
+
OPENID: "openid"
|
|
329
|
+
};
|
|
330
|
+
var ScopeConstants_default = ScopeConstants;
|
|
331
|
+
|
|
332
|
+
// src/constants/OIDCRequestConstants.ts
|
|
333
|
+
var OIDCRequestConstants = {
|
|
334
|
+
Params: {
|
|
278
335
|
/**
|
|
279
|
-
*
|
|
280
|
-
*
|
|
336
|
+
* The authorization code returned from the authorization endpoint.
|
|
337
|
+
* Used in the authorization code flow.
|
|
281
338
|
*/
|
|
282
|
-
|
|
339
|
+
AUTHORIZATION_CODE: "code",
|
|
283
340
|
/**
|
|
284
|
-
*
|
|
285
|
-
* Used when user identity needs to be included in the exchange.
|
|
341
|
+
* Session state parameter used for session management between the client and the OP.
|
|
286
342
|
*/
|
|
287
|
-
|
|
343
|
+
SESSION_STATE: "session_state",
|
|
288
344
|
/**
|
|
289
|
-
*
|
|
290
|
-
*
|
|
345
|
+
* State parameter used to maintain state between the request and the callback.
|
|
346
|
+
* Helps in preventing CSRF attacks.
|
|
291
347
|
*/
|
|
292
|
-
|
|
348
|
+
STATE: "state",
|
|
293
349
|
/**
|
|
294
|
-
*
|
|
295
|
-
*
|
|
350
|
+
* Indicates whether sign-out was successful during the end-session flow.
|
|
351
|
+
* May be returned by the OP after a logout request.
|
|
296
352
|
*/
|
|
297
|
-
|
|
353
|
+
SIGN_OUT_SUCCESS: "sign_out_success"
|
|
354
|
+
},
|
|
355
|
+
/**
|
|
356
|
+
* Constants related to the OpenID Connect (OIDC) sign-in flow.
|
|
357
|
+
*/
|
|
358
|
+
SignIn: {
|
|
298
359
|
/**
|
|
299
|
-
*
|
|
300
|
-
* Used for client authentication in confidential client flows.
|
|
360
|
+
* Constants related to the payload of the OIDC sign-in request.
|
|
301
361
|
*/
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
// src/__legacy__/helpers/authentication-helper.ts
|
|
308
|
-
var AuthenticationHelper = class {
|
|
309
|
-
constructor(dataLayer, cryptoHelper) {
|
|
310
|
-
__publicField(this, "_dataLayer");
|
|
311
|
-
__publicField(this, "_config");
|
|
312
|
-
__publicField(this, "_oidcProviderMetaData");
|
|
313
|
-
__publicField(this, "_cryptoHelper");
|
|
314
|
-
this._dataLayer = dataLayer;
|
|
315
|
-
this._config = async () => await this._dataLayer.getConfigData();
|
|
316
|
-
this._oidcProviderMetaData = async () => await this._dataLayer.getOIDCProviderMetaData();
|
|
317
|
-
this._cryptoHelper = cryptoHelper;
|
|
318
|
-
}
|
|
319
|
-
async resolveEndpoints(response) {
|
|
320
|
-
const oidcProviderMetaData = {};
|
|
321
|
-
const configData = await this._config();
|
|
322
|
-
configData.endpoints && Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
323
|
-
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
324
|
-
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
325
|
-
});
|
|
326
|
-
return { ...response, ...oidcProviderMetaData };
|
|
327
|
-
}
|
|
328
|
-
async resolveEndpointsExplicitly() {
|
|
329
|
-
const oidcProviderMetaData = {};
|
|
330
|
-
const configData = await this._config();
|
|
331
|
-
const requiredEndpoints = [
|
|
332
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.AUTHORIZATION,
|
|
333
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.END_SESSION,
|
|
334
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.JWKS,
|
|
335
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.SESSION_IFRAME,
|
|
336
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.REVOCATION,
|
|
337
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.TOKEN,
|
|
338
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.ISSUER,
|
|
339
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.USERINFO
|
|
340
|
-
];
|
|
341
|
-
const isRequiredEndpointsContains = configData.endpoints ? requiredEndpoints.every((reqEndpointName) => {
|
|
342
|
-
return configData.endpoints ? Object.keys(configData.endpoints).some((endpointName) => {
|
|
343
|
-
const snakeCasedName = endpointName.replace(
|
|
344
|
-
/[A-Z]/g,
|
|
345
|
-
(letter) => `_${letter.toLowerCase()}`
|
|
346
|
-
);
|
|
347
|
-
return snakeCasedName === reqEndpointName;
|
|
348
|
-
}) : false;
|
|
349
|
-
}) : false;
|
|
350
|
-
if (!isRequiredEndpointsContains) {
|
|
351
|
-
throw new AsgardeoAuthException(
|
|
352
|
-
"JS-AUTH_HELPER-REE-NF01",
|
|
353
|
-
"Required endpoints missing",
|
|
354
|
-
"Some or all of the required endpoints are missing in the object passed to the `endpoints` attribute of the`AuthConfig` object."
|
|
355
|
-
);
|
|
356
|
-
}
|
|
357
|
-
configData.endpoints && Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
358
|
-
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
359
|
-
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
360
|
-
});
|
|
361
|
-
return { ...oidcProviderMetaData };
|
|
362
|
-
}
|
|
363
|
-
async resolveEndpointsByBaseURL() {
|
|
364
|
-
const oidcProviderMetaData = {};
|
|
365
|
-
const configData = await this._config();
|
|
366
|
-
const baseUrl = configData.baseUrl;
|
|
367
|
-
if (!baseUrl) {
|
|
368
|
-
throw new AsgardeoAuthException(
|
|
369
|
-
"JS-AUTH_HELPER_REBO-NF01",
|
|
370
|
-
"Base URL not defined.",
|
|
371
|
-
"Base URL is not defined in AuthClient config."
|
|
372
|
-
);
|
|
373
|
-
}
|
|
374
|
-
configData.endpoints && Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
375
|
-
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
376
|
-
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
377
|
-
});
|
|
378
|
-
const defaultEndpoints = {
|
|
379
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.AUTHORIZATION]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.AUTHORIZATION}`,
|
|
380
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.END_SESSION]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.END_SESSION}`,
|
|
381
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.ISSUER]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.ISSUER}`,
|
|
382
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.JWKS]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.JWKS}`,
|
|
383
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.SESSION_IFRAME]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.SESSION_IFRAME}`,
|
|
384
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.REVOCATION]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.REVOCATION}`,
|
|
385
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.TOKEN]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.TOKEN}`,
|
|
386
|
-
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.USERINFO]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.USERINFO}`
|
|
387
|
-
};
|
|
388
|
-
return { ...defaultEndpoints, ...oidcProviderMetaData };
|
|
389
|
-
}
|
|
390
|
-
async validateIdToken(idToken) {
|
|
391
|
-
const jwksEndpoint = (await this._dataLayer.getOIDCProviderMetaData()).jwks_uri;
|
|
392
|
-
const configData = await this._config();
|
|
393
|
-
if (!jwksEndpoint || jwksEndpoint.trim().length === 0) {
|
|
394
|
-
throw new AsgardeoAuthException(
|
|
395
|
-
"JS_AUTH_HELPER-VIT-NF01",
|
|
396
|
-
"JWKS endpoint not found.",
|
|
397
|
-
"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."
|
|
398
|
-
);
|
|
399
|
-
}
|
|
400
|
-
let response;
|
|
401
|
-
try {
|
|
402
|
-
response = await fetch(jwksEndpoint, {
|
|
403
|
-
credentials: configData.sendCookiesInRequests ? "include" : "same-origin"
|
|
404
|
-
});
|
|
405
|
-
} catch (error) {
|
|
406
|
-
throw new AsgardeoAuthException(
|
|
407
|
-
"JS-AUTH_HELPER-VIT-NE02",
|
|
408
|
-
"Request to jwks endpoint failed.",
|
|
409
|
-
error ?? "The request sent to get the jwks from the server failed."
|
|
410
|
-
);
|
|
411
|
-
}
|
|
412
|
-
if (response.status !== 200 || !response.ok) {
|
|
413
|
-
throw new AsgardeoAuthException(
|
|
414
|
-
"JS-AUTH_HELPER-VIT-HE03",
|
|
415
|
-
`Invalid response status received for jwks request (${response.statusText}).`,
|
|
416
|
-
await response.json()
|
|
417
|
-
);
|
|
418
|
-
}
|
|
419
|
-
const issuer = (await this._oidcProviderMetaData()).issuer;
|
|
420
|
-
const { keys } = await response.json();
|
|
421
|
-
const jwk = await this._cryptoHelper.getJWKForTheIdToken(idToken.split(".")[0], keys);
|
|
422
|
-
return this._cryptoHelper.isValidIdToken(
|
|
423
|
-
idToken,
|
|
424
|
-
jwk,
|
|
425
|
-
(await this._config()).clientID,
|
|
426
|
-
issuer ?? "",
|
|
427
|
-
this._cryptoHelper.decodeIDToken(idToken).sub,
|
|
428
|
-
(await this._config()).clockTolerance,
|
|
429
|
-
(await this._config()).validateIDTokenIssuer ?? true
|
|
430
|
-
);
|
|
431
|
-
}
|
|
432
|
-
getAuthenticatedUserInfo(idToken) {
|
|
433
|
-
const payload = this._cryptoHelper.decodeIDToken(idToken);
|
|
434
|
-
const tenantDomain = extractTenantDomainFromIdTokenPayload_default(payload);
|
|
435
|
-
const username = payload?.["username"] ?? "";
|
|
436
|
-
const givenName = payload?.["given_name"] ?? "";
|
|
437
|
-
const familyName = payload?.["family_name"] ?? "";
|
|
438
|
-
const fullName = givenName && familyName ? `${givenName} ${familyName}` : givenName ? givenName : familyName ? familyName : "";
|
|
439
|
-
const displayName = payload.preferred_username ?? fullName;
|
|
440
|
-
return {
|
|
441
|
-
displayName,
|
|
442
|
-
tenantDomain,
|
|
443
|
-
username,
|
|
444
|
-
...extractUserClaimsFromIdToken_default(payload)
|
|
445
|
-
};
|
|
446
|
-
}
|
|
447
|
-
async replaceCustomGrantTemplateTags(text, userID) {
|
|
448
|
-
let scope = ScopeConstants_default.OPENID;
|
|
449
|
-
const configData = await this._config();
|
|
450
|
-
const sessionData = await this._dataLayer.getSessionData(userID);
|
|
451
|
-
if (configData.scope && configData.scope.length > 0) {
|
|
452
|
-
if (!configData.scope.includes(ScopeConstants_default.OPENID)) {
|
|
453
|
-
configData.scope.push(ScopeConstants_default.OPENID);
|
|
454
|
-
}
|
|
455
|
-
scope = configData.scope.join(" ");
|
|
456
|
-
}
|
|
457
|
-
return text.replace(TokenExchangeConstants_default.Placeholders.TOKEN, sessionData.access_token).replace(
|
|
458
|
-
TokenExchangeConstants_default.Placeholders.USERNAME,
|
|
459
|
-
this.getAuthenticatedUserInfo(sessionData.id_token).username
|
|
460
|
-
).replace(TokenExchangeConstants_default.Placeholders.SCOPE, scope).replace(TokenExchangeConstants_default.Placeholders.CLIENT_ID, configData.clientID).replace(TokenExchangeConstants_default.Placeholders.CLIENT_SECRET, configData.clientSecret ?? "");
|
|
461
|
-
}
|
|
462
|
-
async clearUserSessionData(userID) {
|
|
463
|
-
await this._dataLayer.removeTemporaryData(userID);
|
|
464
|
-
await this._dataLayer.removeSessionData(userID);
|
|
465
|
-
}
|
|
466
|
-
async handleTokenResponse(response, userID) {
|
|
467
|
-
if (response.status !== 200 || !response.ok) {
|
|
468
|
-
throw new AsgardeoAuthException(
|
|
469
|
-
"JS-AUTH_HELPER-HTR-NE01",
|
|
470
|
-
`Invalid response status received for token request (${response.statusText}).`,
|
|
471
|
-
await response.json()
|
|
472
|
-
);
|
|
473
|
-
}
|
|
474
|
-
const parsedResponse = await response.json();
|
|
475
|
-
parsedResponse.created_at = (/* @__PURE__ */ new Date()).getTime();
|
|
476
|
-
const shouldValidateIdToken = (await this._config()).validateIDToken;
|
|
477
|
-
if (shouldValidateIdToken) {
|
|
478
|
-
return this.validateIdToken(parsedResponse.id_token).then(async () => {
|
|
479
|
-
await this._dataLayer.setSessionData(parsedResponse, userID);
|
|
480
|
-
const tokenResponse = {
|
|
481
|
-
accessToken: parsedResponse.access_token,
|
|
482
|
-
createdAt: parsedResponse.created_at,
|
|
483
|
-
expiresIn: parsedResponse.expires_in,
|
|
484
|
-
idToken: parsedResponse.id_token,
|
|
485
|
-
refreshToken: parsedResponse.refresh_token,
|
|
486
|
-
scope: parsedResponse.scope,
|
|
487
|
-
tokenType: parsedResponse.token_type
|
|
488
|
-
};
|
|
489
|
-
return Promise.resolve(tokenResponse);
|
|
490
|
-
});
|
|
491
|
-
} else {
|
|
492
|
-
const tokenResponse = {
|
|
493
|
-
accessToken: parsedResponse.access_token,
|
|
494
|
-
createdAt: parsedResponse.created_at,
|
|
495
|
-
expiresIn: parsedResponse.expires_in,
|
|
496
|
-
idToken: parsedResponse.id_token,
|
|
497
|
-
refreshToken: parsedResponse.refresh_token,
|
|
498
|
-
scope: parsedResponse.scope,
|
|
499
|
-
tokenType: parsedResponse.token_type
|
|
500
|
-
};
|
|
501
|
-
await this._dataLayer.setSessionData(parsedResponse, userID);
|
|
502
|
-
return Promise.resolve(tokenResponse);
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
};
|
|
506
|
-
|
|
507
|
-
// src/utils/generatePkceStorageKey.ts
|
|
508
|
-
var generatePkceStorageKey = (tempStore) => {
|
|
509
|
-
const keys = [];
|
|
510
|
-
Object.keys(tempStore).forEach((key) => {
|
|
511
|
-
if (key.startsWith(PKCEConstants_default.Storage.StorageKeys.CODE_VERIFIER)) {
|
|
512
|
-
keys.push(key);
|
|
362
|
+
Payload: {
|
|
363
|
+
/**
|
|
364
|
+
* The default scopes used in OIDC sign-in requests.
|
|
365
|
+
*/
|
|
366
|
+
DEFAULT_SCOPES: [ScopeConstants_default.OPENID]
|
|
513
367
|
}
|
|
514
|
-
});
|
|
515
|
-
const lastKey = keys.sort().pop();
|
|
516
|
-
const index = parseInt(lastKey?.split(PKCEConstants_default.Storage.StorageKeys.SEPARATOR)[1] ?? "-1");
|
|
517
|
-
return `${PKCEConstants_default.Storage.StorageKeys.CODE_VERIFIER}${PKCEConstants_default.Storage.StorageKeys.SEPARATOR}${index + 1}`;
|
|
518
|
-
};
|
|
519
|
-
var generatePkceStorageKey_default = generatePkceStorageKey;
|
|
520
|
-
|
|
521
|
-
// src/constants/OIDCRequestConstants.ts
|
|
522
|
-
var OIDCRequestConstants = {
|
|
523
|
-
Params: {
|
|
524
|
-
/**
|
|
525
|
-
* The authorization code returned from the authorization endpoint.
|
|
526
|
-
* Used in the authorization code flow.
|
|
527
|
-
*/
|
|
528
|
-
AUTHORIZATION_CODE: "code",
|
|
529
|
-
/**
|
|
530
|
-
* Session state parameter used for session management between the client and the OP.
|
|
531
|
-
*/
|
|
532
|
-
SESSION_STATE: "session_state",
|
|
533
|
-
/**
|
|
534
|
-
* State parameter used to maintain state between the request and the callback.
|
|
535
|
-
* Helps in preventing CSRF attacks.
|
|
536
|
-
*/
|
|
537
|
-
STATE: "state",
|
|
538
|
-
/**
|
|
539
|
-
* Indicates whether sign-out was successful during the end-session flow.
|
|
540
|
-
* May be returned by the OP after a logout request.
|
|
541
|
-
*/
|
|
542
|
-
SIGN_OUT_SUCCESS: "sign_out_success"
|
|
543
368
|
},
|
|
544
369
|
/**
|
|
545
370
|
* Sign-out related constants for managing the end-session flow in OIDC.
|
|
@@ -565,6 +390,19 @@ var OIDCRequestConstants = {
|
|
|
565
390
|
};
|
|
566
391
|
var OIDCRequestConstants_default = OIDCRequestConstants;
|
|
567
392
|
|
|
393
|
+
// src/errors/exception.ts
|
|
394
|
+
var AsgardeoAuthException = class {
|
|
395
|
+
constructor(code, name, message) {
|
|
396
|
+
__publicField(this, "name");
|
|
397
|
+
__publicField(this, "code");
|
|
398
|
+
__publicField(this, "message");
|
|
399
|
+
this.message = message;
|
|
400
|
+
this.name = name;
|
|
401
|
+
this.code = code;
|
|
402
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
|
|
568
406
|
// src/constants/TokenConstants.ts
|
|
569
407
|
var TokenConstants = {
|
|
570
408
|
/**
|
|
@@ -660,7 +498,7 @@ var IsomorphicCrypto = class {
|
|
|
660
498
|
*
|
|
661
499
|
* @param idToken - id_token received from the IdP.
|
|
662
500
|
* @param jwk - public key used for signing.
|
|
663
|
-
* @param
|
|
501
|
+
* @param clientId - app identification.
|
|
664
502
|
* @param issuer - id_token issuer.
|
|
665
503
|
* @param username - Username.
|
|
666
504
|
* @param clockTolerance - Allowed leeway for id_tokens (in seconds).
|
|
@@ -669,12 +507,12 @@ var IsomorphicCrypto = class {
|
|
|
669
507
|
*
|
|
670
508
|
* @throws
|
|
671
509
|
*/
|
|
672
|
-
isValidIdToken(idToken, jwk,
|
|
510
|
+
isValidIdToken(idToken, jwk, clientId, issuer, username, clockTolerance, validateJwtIssuer) {
|
|
673
511
|
return this._cryptoUtils.verifyJwt(
|
|
674
512
|
idToken,
|
|
675
513
|
jwk,
|
|
676
514
|
TokenConstants_default.SignatureValidation.SUPPORTED_ALGORITHMS,
|
|
677
|
-
|
|
515
|
+
clientId,
|
|
678
516
|
issuer,
|
|
679
517
|
username,
|
|
680
518
|
clockTolerance,
|
|
@@ -701,9 +539,9 @@ var IsomorphicCrypto = class {
|
|
|
701
539
|
*
|
|
702
540
|
* @throws
|
|
703
541
|
*/
|
|
704
|
-
|
|
542
|
+
decodeIdToken(idToken) {
|
|
705
543
|
try {
|
|
706
|
-
const utf8String = this._cryptoUtils.base64URLDecode(idToken
|
|
544
|
+
const utf8String = this._cryptoUtils.base64URLDecode(idToken?.split(".")[1]);
|
|
707
545
|
const payload = JSON.parse(utf8String);
|
|
708
546
|
return payload;
|
|
709
547
|
} catch (error) {
|
|
@@ -712,644 +550,463 @@ var IsomorphicCrypto = class {
|
|
|
712
550
|
}
|
|
713
551
|
};
|
|
714
552
|
|
|
715
|
-
// src/
|
|
716
|
-
var
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
if (configData.scope && configData.scope.length > 0) {
|
|
738
|
-
if (!configData.scope.includes(ScopeConstants_default.OPENID)) {
|
|
739
|
-
configData.scope.push(ScopeConstants_default.OPENID);
|
|
740
|
-
}
|
|
741
|
-
scope = configData.scope.join(" ");
|
|
742
|
-
}
|
|
743
|
-
authorizeRequestParams.set("scope", scope);
|
|
744
|
-
authorizeRequestParams.set("redirect_uri", configData.signInRedirectURL);
|
|
745
|
-
if (configData.responseMode) {
|
|
746
|
-
authorizeRequestParams.set("response_mode", configData.responseMode);
|
|
747
|
-
}
|
|
748
|
-
const tempStore = await this._dataLayer.getTemporaryData(userID);
|
|
749
|
-
const pkceKey = await generatePkceStorageKey_default(tempStore);
|
|
750
|
-
if (configData.enablePKCE) {
|
|
751
|
-
const codeVerifier = this._cryptoHelper?.getCodeVerifier();
|
|
752
|
-
const codeChallenge = this._cryptoHelper?.getCodeChallenge(codeVerifier);
|
|
753
|
-
await this._dataLayer.setTemporaryDataParameter(pkceKey, codeVerifier, userID);
|
|
754
|
-
authorizeRequestParams.set("code_challenge_method", "S256");
|
|
755
|
-
authorizeRequestParams.set("code_challenge", codeChallenge);
|
|
756
|
-
}
|
|
757
|
-
if (configData.prompt) {
|
|
758
|
-
authorizeRequestParams.set("prompt", configData.prompt);
|
|
759
|
-
}
|
|
760
|
-
const customParams = config;
|
|
761
|
-
if (customParams) {
|
|
762
|
-
for (const [key, value] of Object.entries(customParams)) {
|
|
763
|
-
if (key != "" && value != "" && key !== OIDCRequestConstants_default.Params.STATE) {
|
|
764
|
-
authorizeRequestParams.set(key, value.toString());
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
authorizeRequestParams.set(
|
|
769
|
-
OIDCRequestConstants_default.Params.STATE,
|
|
770
|
-
generateStateParamForRequestCorrelation_default(
|
|
771
|
-
pkceKey,
|
|
772
|
-
customParams ? customParams[OIDCRequestConstants_default.Params.STATE]?.toString() : ""
|
|
773
|
-
)
|
|
774
|
-
);
|
|
775
|
-
return authorizeRequestParams;
|
|
776
|
-
}
|
|
777
|
-
async getAuthorizationURL(config, userID) {
|
|
778
|
-
const authorizeEndpoint = await this._dataLayer.getOIDCProviderMetaDataParameter(
|
|
779
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.AUTHORIZATION
|
|
780
|
-
);
|
|
781
|
-
if (!authorizeEndpoint || authorizeEndpoint.trim().length === 0) {
|
|
782
|
-
throw new AsgardeoAuthException(
|
|
783
|
-
"JS-AUTH_CORE-GAU-NF01",
|
|
784
|
-
"No authorization endpoint found.",
|
|
785
|
-
"No authorization endpoint was found in the OIDC provider meta data from the well-known endpoint or the authorization endpoint passed to the SDK is empty."
|
|
786
|
-
);
|
|
787
|
-
}
|
|
788
|
-
const authorizeRequest = new URL(authorizeEndpoint);
|
|
789
|
-
const authorizeRequestParams = await this.getAuthorizationURLParams(config, userID);
|
|
790
|
-
for (const [key, value] of authorizeRequestParams.entries()) {
|
|
791
|
-
authorizeRequest.searchParams.append(key, value);
|
|
553
|
+
// src/constants/PKCEConstants.ts
|
|
554
|
+
var PKCEConstants = {
|
|
555
|
+
DEFAULT_CODE_CHALLENGE_METHOD: "S256",
|
|
556
|
+
/**
|
|
557
|
+
* Storage-related constants for managing PKCE state
|
|
558
|
+
*/
|
|
559
|
+
Storage: {
|
|
560
|
+
/**
|
|
561
|
+
* Collection of storage keys used in PKCE implementation
|
|
562
|
+
*/
|
|
563
|
+
StorageKeys: {
|
|
564
|
+
/**
|
|
565
|
+
* Key used to store the PKCE code verifier in temporary storage.
|
|
566
|
+
* The code verifier is a cryptographically random string that is
|
|
567
|
+
* used to generate the code challenge.
|
|
568
|
+
*/
|
|
569
|
+
CODE_VERIFIER: "pkce_code_verifier",
|
|
570
|
+
/**
|
|
571
|
+
* Separator used in storage keys to create unique identifiers
|
|
572
|
+
* by combining different parts of the key.
|
|
573
|
+
*/
|
|
574
|
+
SEPARATOR: "#"
|
|
792
575
|
}
|
|
793
|
-
return authorizeRequest.toString();
|
|
794
576
|
}
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
}
|
|
856
|
-
|
|
577
|
+
};
|
|
578
|
+
var PKCEConstants_default = PKCEConstants;
|
|
579
|
+
|
|
580
|
+
// src/utils/extractPkceStorageKeyFromState.ts
|
|
581
|
+
var extractPkceStorageKeyFromState = (state) => {
|
|
582
|
+
const index = parseInt(state.split("request_")[1]);
|
|
583
|
+
return `${PKCEConstants_default.Storage.StorageKeys.CODE_VERIFIER}${PKCEConstants_default.Storage.StorageKeys.SEPARATOR}${index}`;
|
|
584
|
+
};
|
|
585
|
+
var extractPkceStorageKeyFromState_default = extractPkceStorageKeyFromState;
|
|
586
|
+
|
|
587
|
+
// src/utils/extractUserClaimsFromIdToken.ts
|
|
588
|
+
var extractUserClaimsFromIdToken = (payload) => {
|
|
589
|
+
const filteredPayload = { ...payload };
|
|
590
|
+
const protocolClaims = [
|
|
591
|
+
"iss",
|
|
592
|
+
"aud",
|
|
593
|
+
"exp",
|
|
594
|
+
"iat",
|
|
595
|
+
"acr",
|
|
596
|
+
"amr",
|
|
597
|
+
"azp",
|
|
598
|
+
"auth_time",
|
|
599
|
+
"nonce",
|
|
600
|
+
"c_hash",
|
|
601
|
+
"at_hash",
|
|
602
|
+
"nbf",
|
|
603
|
+
"isk",
|
|
604
|
+
"sid",
|
|
605
|
+
"jti",
|
|
606
|
+
"sub"
|
|
607
|
+
];
|
|
608
|
+
protocolClaims.forEach((claim) => {
|
|
609
|
+
delete filteredPayload[claim];
|
|
610
|
+
});
|
|
611
|
+
const userClaims = {};
|
|
612
|
+
Object.entries(filteredPayload).forEach(([key, value]) => {
|
|
613
|
+
const camelCasedKey = key.split("_").map((part, i) => i === 0 ? part : part[0].toUpperCase() + part.slice(1)).join("");
|
|
614
|
+
userClaims[camelCasedKey] = value;
|
|
615
|
+
});
|
|
616
|
+
return userClaims;
|
|
617
|
+
};
|
|
618
|
+
var extractUserClaimsFromIdToken_default = extractUserClaimsFromIdToken;
|
|
619
|
+
|
|
620
|
+
// src/constants/TokenExchangeConstants.ts
|
|
621
|
+
var TokenExchangeConstants = {
|
|
622
|
+
/**
|
|
623
|
+
* Collection of placeholder strings used in token exchange operations.
|
|
624
|
+
* These placeholders are replaced with actual values when processing
|
|
625
|
+
* token exchange requests.
|
|
626
|
+
*/
|
|
627
|
+
Placeholders: {
|
|
628
|
+
/**
|
|
629
|
+
* Placeholder for the token value in exchange requests.
|
|
630
|
+
* Usually replaced with an access token or refresh token.
|
|
631
|
+
*/
|
|
632
|
+
TOKEN: "{{token}}",
|
|
633
|
+
/**
|
|
634
|
+
* Placeholder for the username in token exchange operations.
|
|
635
|
+
* Used when user identity needs to be included in the exchange.
|
|
636
|
+
*/
|
|
637
|
+
USERNAME: "{{username}}",
|
|
638
|
+
/**
|
|
639
|
+
* Placeholder for OAuth scopes in token exchange requests.
|
|
640
|
+
* Replaced with space-separated scope strings.
|
|
641
|
+
*/
|
|
642
|
+
SCOPE: "{{scope}}",
|
|
643
|
+
/**
|
|
644
|
+
* Placeholder for client ID in token exchange operations.
|
|
645
|
+
* Required for client authentication.
|
|
646
|
+
*/
|
|
647
|
+
CLIENT_ID: "{{clientId}}",
|
|
648
|
+
/**
|
|
649
|
+
* Placeholder for client secret in token exchange operations.
|
|
650
|
+
* Used for client authentication in confidential client flows.
|
|
651
|
+
*/
|
|
652
|
+
CLIENT_SECRET: "{{clientSecret}}"
|
|
857
653
|
}
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
if (configData.clientSecret && configData.clientSecret.trim().length > 0) {
|
|
881
|
-
body.push(`client_secret=${configData.clientSecret}`);
|
|
882
|
-
}
|
|
883
|
-
let tokenResponse;
|
|
884
|
-
try {
|
|
885
|
-
tokenResponse = await fetch(tokenEndpoint, {
|
|
886
|
-
body: body.join("&"),
|
|
887
|
-
credentials: configData.sendCookiesInRequests ? "include" : "same-origin",
|
|
888
|
-
headers: {
|
|
889
|
-
Accept: "application/json",
|
|
890
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
891
|
-
},
|
|
892
|
-
method: "POST"
|
|
893
|
-
});
|
|
894
|
-
} catch (error) {
|
|
895
|
-
throw new AsgardeoAuthException(
|
|
896
|
-
"JS-AUTH_CORE-RAT2-NR03",
|
|
897
|
-
"Refresh access token request failed.",
|
|
898
|
-
error ?? "The request to refresh the access token failed."
|
|
899
|
-
);
|
|
900
|
-
}
|
|
901
|
-
if (!tokenResponse.ok) {
|
|
902
|
-
throw new AsgardeoAuthException(
|
|
903
|
-
"JS-AUTH_CORE-RAT2-HE04",
|
|
904
|
-
`Refreshing access token failed with ${tokenResponse.statusText}`,
|
|
905
|
-
await tokenResponse.json()
|
|
906
|
-
);
|
|
654
|
+
};
|
|
655
|
+
var TokenExchangeConstants_default = TokenExchangeConstants;
|
|
656
|
+
|
|
657
|
+
// src/errors/AsgardeoError.ts
|
|
658
|
+
var AsgardeoError = class _AsgardeoError extends Error {
|
|
659
|
+
constructor(message, code, origin) {
|
|
660
|
+
const _origin = _AsgardeoError.resolveOrigin(origin);
|
|
661
|
+
const prefix = `\u{1F6E1}\uFE0F Asgardeo - ${_origin}:`;
|
|
662
|
+
const regex = new RegExp(`\u{1F6E1}\uFE0F\\s*Asgardeo\\s*-\\s*${_origin}:`, "i");
|
|
663
|
+
const sanitized = message.replace(regex, "");
|
|
664
|
+
const _message = `${prefix} ${sanitized.trim()}
|
|
665
|
+
|
|
666
|
+
(code="${code}")
|
|
667
|
+
`;
|
|
668
|
+
super(_message);
|
|
669
|
+
__publicField(this, "code");
|
|
670
|
+
__publicField(this, "origin");
|
|
671
|
+
this.name = new.target.name;
|
|
672
|
+
this.code = code;
|
|
673
|
+
this.origin = _origin;
|
|
674
|
+
if (Error.captureStackTrace) {
|
|
675
|
+
Error.captureStackTrace(this, new.target);
|
|
907
676
|
}
|
|
908
|
-
return this._authenticationHelper.handleTokenResponse(tokenResponse, userID);
|
|
909
677
|
}
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
if (!revokeTokenEndpoint || revokeTokenEndpoint.trim().length === 0) {
|
|
914
|
-
throw new AsgardeoAuthException(
|
|
915
|
-
"JS-AUTH_CORE-RAT3-NF01",
|
|
916
|
-
"No revoke access token endpoint found.",
|
|
917
|
-
"No revoke access token endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the revoke access token endpoint passed to the SDK is empty."
|
|
918
|
-
);
|
|
919
|
-
}
|
|
920
|
-
const body = [];
|
|
921
|
-
body.push(`client_id=${configData.clientID}`);
|
|
922
|
-
body.push(`token=${(await this._dataLayer.getSessionData(userID)).access_token}`);
|
|
923
|
-
body.push("token_type_hint=access_token");
|
|
924
|
-
if (configData.clientSecret && configData.clientSecret.trim().length > 0) {
|
|
925
|
-
body.push(`client_secret=${configData.clientSecret}`);
|
|
926
|
-
}
|
|
927
|
-
let response;
|
|
928
|
-
try {
|
|
929
|
-
response = await fetch(revokeTokenEndpoint, {
|
|
930
|
-
body: body.join("&"),
|
|
931
|
-
credentials: configData.sendCookiesInRequests ? "include" : "same-origin",
|
|
932
|
-
headers: {
|
|
933
|
-
Accept: "application/json",
|
|
934
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
935
|
-
},
|
|
936
|
-
method: "POST"
|
|
937
|
-
});
|
|
938
|
-
} catch (error) {
|
|
939
|
-
throw new AsgardeoAuthException(
|
|
940
|
-
"JS-AUTH_CORE-RAT3-NE02",
|
|
941
|
-
"The request to revoke access token failed.",
|
|
942
|
-
error ?? "The request sent to revoke the access token failed."
|
|
943
|
-
);
|
|
944
|
-
}
|
|
945
|
-
if (response.status !== 200 || !response.ok) {
|
|
946
|
-
throw new AsgardeoAuthException(
|
|
947
|
-
"JS-AUTH_CORE-RAT3-HE03",
|
|
948
|
-
`Invalid response status received for revoke access token request (${response.statusText}).`,
|
|
949
|
-
await response.json()
|
|
950
|
-
);
|
|
678
|
+
static resolveOrigin(origin) {
|
|
679
|
+
if (!origin) {
|
|
680
|
+
return "@asgardeo/javascript";
|
|
951
681
|
}
|
|
952
|
-
|
|
953
|
-
return Promise.resolve(response);
|
|
682
|
+
return `@asgardeo/${origin}`;
|
|
954
683
|
}
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
let tokenEndpoint;
|
|
959
|
-
if (customGrantParams.tokenEndpoint && customGrantParams.tokenEndpoint.trim().length !== 0) {
|
|
960
|
-
tokenEndpoint = customGrantParams.tokenEndpoint;
|
|
961
|
-
} else {
|
|
962
|
-
tokenEndpoint = oidcProviderMetadata.token_endpoint;
|
|
963
|
-
}
|
|
964
|
-
if (!tokenEndpoint || tokenEndpoint.trim().length === 0) {
|
|
965
|
-
throw new AsgardeoAuthException(
|
|
966
|
-
"JS-AUTH_CORE-RCG-NF01",
|
|
967
|
-
"Token endpoint not found.",
|
|
968
|
-
"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."
|
|
969
|
-
);
|
|
970
|
-
}
|
|
971
|
-
const data = await Promise.all(
|
|
972
|
-
Object.entries(customGrantParams.data).map(async ([key, value]) => {
|
|
973
|
-
const newValue = await this._authenticationHelper.replaceCustomGrantTemplateTags(
|
|
974
|
-
value,
|
|
975
|
-
userID
|
|
976
|
-
);
|
|
977
|
-
return `${key}=${newValue}`;
|
|
978
|
-
})
|
|
979
|
-
);
|
|
980
|
-
let requestHeaders = {
|
|
981
|
-
Accept: "application/json",
|
|
982
|
-
"Content-Type": "application/x-www-form-urlencoded"
|
|
983
|
-
};
|
|
984
|
-
if (customGrantParams.attachToken) {
|
|
985
|
-
requestHeaders = {
|
|
986
|
-
...requestHeaders,
|
|
987
|
-
Authorization: `Bearer ${(await this._dataLayer.getSessionData(userID)).access_token}`
|
|
988
|
-
};
|
|
989
|
-
}
|
|
990
|
-
const requestConfig = {
|
|
991
|
-
body: data.join("&"),
|
|
992
|
-
credentials: configData.sendCookiesInRequests ? "include" : "same-origin",
|
|
993
|
-
headers: new Headers(requestHeaders),
|
|
994
|
-
method: "POST"
|
|
995
|
-
};
|
|
996
|
-
let response;
|
|
997
|
-
try {
|
|
998
|
-
response = await fetch(tokenEndpoint, requestConfig);
|
|
999
|
-
} catch (error) {
|
|
1000
|
-
throw new AsgardeoAuthException(
|
|
1001
|
-
"JS-AUTH_CORE-RCG-NE02",
|
|
1002
|
-
"The custom grant request failed.",
|
|
1003
|
-
error ?? "The request sent to get the custom grant failed."
|
|
1004
|
-
);
|
|
1005
|
-
}
|
|
1006
|
-
if (response.status !== 200 || !response.ok) {
|
|
1007
|
-
throw new AsgardeoAuthException(
|
|
1008
|
-
"JS-AUTH_CORE-RCG-HE03",
|
|
1009
|
-
`Invalid response status received for the custom grant request. (${response.statusText})`,
|
|
1010
|
-
await response.json()
|
|
1011
|
-
);
|
|
1012
|
-
}
|
|
1013
|
-
if (customGrantParams.returnsSession) {
|
|
1014
|
-
return this._authenticationHelper.handleTokenResponse(response, userID);
|
|
1015
|
-
} else {
|
|
1016
|
-
return Promise.resolve(await response.json());
|
|
1017
|
-
}
|
|
684
|
+
toString() {
|
|
685
|
+
return `[${this.name}]
|
|
686
|
+
Message: ${this.message}`;
|
|
1018
687
|
}
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
688
|
+
};
|
|
689
|
+
|
|
690
|
+
// src/errors/AsgardeoRuntimeError.ts
|
|
691
|
+
var AsgardeoRuntimeError = class extends AsgardeoError {
|
|
692
|
+
/**
|
|
693
|
+
* Creates an instance of AsgardeoRuntimeError.
|
|
694
|
+
*
|
|
695
|
+
* @param message - Human-readable description of the error
|
|
696
|
+
* @param code - A unique error code that identifies the error type
|
|
697
|
+
* @param details - Additional details about the error that might be helpful for debugging
|
|
698
|
+
* @param origin - Optional. The SDK origin (e.g. 'react', 'vue'). Defaults to generic 'Asgardeo'
|
|
699
|
+
* @constructor
|
|
700
|
+
*/
|
|
701
|
+
constructor(message, code, origin, details) {
|
|
702
|
+
super(message, code, origin);
|
|
703
|
+
this.details = details;
|
|
704
|
+
Object.defineProperty(this, "name", {
|
|
705
|
+
value: "AsgardeoRuntimeError",
|
|
706
|
+
configurable: true,
|
|
707
|
+
writable: true
|
|
1032
708
|
});
|
|
1033
|
-
basicUserInfo = { ...basicUserInfo, ...authenticatedUser };
|
|
1034
|
-
return basicUserInfo;
|
|
1035
709
|
}
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
710
|
+
/**
|
|
711
|
+
* Returns a string representation of the runtime error
|
|
712
|
+
* @returns Formatted error string with name, code, details, and message
|
|
713
|
+
*/
|
|
714
|
+
toString() {
|
|
715
|
+
const details = this.details ? `
|
|
716
|
+
Details: ${JSON.stringify(this.details, null, 2)}` : "";
|
|
717
|
+
return `[${this.name}] (code="${this.code}")${details}
|
|
718
|
+
Message: ${this.message}`;
|
|
1040
719
|
}
|
|
1041
|
-
|
|
1042
|
-
|
|
720
|
+
};
|
|
721
|
+
|
|
722
|
+
// src/utils/processOpenIDScopes.ts
|
|
723
|
+
var processOpenIDScopes = (scopes) => {
|
|
724
|
+
let processedScopes = [];
|
|
725
|
+
if (Array.isArray(scopes)) {
|
|
726
|
+
processedScopes = scopes;
|
|
727
|
+
} else if (typeof scopes === "string") {
|
|
728
|
+
processedScopes = scopes.split(" ");
|
|
729
|
+
} else {
|
|
730
|
+
throw new AsgardeoRuntimeError(
|
|
731
|
+
"Scopes must be a string or an array of strings.",
|
|
732
|
+
"processOpenIDScopes-Invalid-001",
|
|
733
|
+
"javascript",
|
|
734
|
+
"The provided scopes are not in the expected format. Please provide a string or an array of strings."
|
|
735
|
+
);
|
|
1043
736
|
}
|
|
1044
|
-
|
|
1045
|
-
|
|
737
|
+
OIDCRequestConstants_default.SignIn.Payload.DEFAULT_SCOPES.forEach((defaultScope) => {
|
|
738
|
+
if (!processedScopes.includes(defaultScope)) {
|
|
739
|
+
processedScopes.push(defaultScope);
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
return processedScopes.join(" ");
|
|
743
|
+
};
|
|
744
|
+
var processOpenIDScopes_default = processOpenIDScopes;
|
|
745
|
+
|
|
746
|
+
// src/__legacy__/helpers/authentication-helper.ts
|
|
747
|
+
var AuthenticationHelper = class {
|
|
748
|
+
constructor(storageManager, cryptoHelper) {
|
|
749
|
+
__publicField(this, "_storageManager");
|
|
750
|
+
__publicField(this, "_config");
|
|
751
|
+
__publicField(this, "_oidcProviderMetaData");
|
|
752
|
+
__publicField(this, "_cryptoHelper");
|
|
753
|
+
this._storageManager = storageManager;
|
|
754
|
+
this._config = async () => await this._storageManager.getConfigData();
|
|
755
|
+
this._oidcProviderMetaData = async () => await this._storageManager.loadOpenIDProviderConfiguration();
|
|
756
|
+
this._cryptoHelper = cryptoHelper;
|
|
1046
757
|
}
|
|
1047
|
-
async
|
|
758
|
+
async resolveEndpoints(response) {
|
|
759
|
+
const oidcProviderMetaData = {};
|
|
1048
760
|
const configData = await this._config();
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
}
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,
|
|
1074
|
-
true
|
|
1075
|
-
);
|
|
1076
|
-
return Promise.resolve();
|
|
1077
|
-
} else if (configData.baseUrl) {
|
|
1078
|
-
try {
|
|
1079
|
-
await this._dataLayer.setOIDCProviderMetaData(await this._authenticationHelper.resolveEndpointsByBaseURL());
|
|
1080
|
-
} catch (error) {
|
|
1081
|
-
throw new AsgardeoAuthException(
|
|
1082
|
-
"JS-AUTH_CORE-GOPMD-IV02",
|
|
1083
|
-
"Resolving endpoints failed.",
|
|
1084
|
-
error ?? "Resolving endpoints by base url failed."
|
|
761
|
+
configData.endpoints && Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
762
|
+
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
763
|
+
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
764
|
+
});
|
|
765
|
+
return { ...response, ...oidcProviderMetaData };
|
|
766
|
+
}
|
|
767
|
+
async resolveEndpointsExplicitly() {
|
|
768
|
+
const oidcProviderMetaData = {};
|
|
769
|
+
const configData = await this._config();
|
|
770
|
+
const requiredEndpoints = [
|
|
771
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.AUTHORIZATION,
|
|
772
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.END_SESSION,
|
|
773
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.JWKS,
|
|
774
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.SESSION_IFRAME,
|
|
775
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.REVOCATION,
|
|
776
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.TOKEN,
|
|
777
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.ISSUER,
|
|
778
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.USERINFO
|
|
779
|
+
];
|
|
780
|
+
const isRequiredEndpointsContains = configData.endpoints ? requiredEndpoints.every((reqEndpointName) => {
|
|
781
|
+
return configData.endpoints ? Object.keys(configData.endpoints).some((endpointName) => {
|
|
782
|
+
const snakeCasedName = endpointName.replace(
|
|
783
|
+
/[A-Z]/g,
|
|
784
|
+
(letter) => `_${letter.toLowerCase()}`
|
|
1085
785
|
);
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
await this._dataLayer.setTemporaryDataParameter(
|
|
1095
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,
|
|
1096
|
-
true
|
|
786
|
+
return snakeCasedName === reqEndpointName;
|
|
787
|
+
}) : false;
|
|
788
|
+
}) : false;
|
|
789
|
+
if (!isRequiredEndpointsContains) {
|
|
790
|
+
throw new AsgardeoAuthException(
|
|
791
|
+
"JS-AUTH_HELPER-REE-NF01",
|
|
792
|
+
"Required endpoints missing",
|
|
793
|
+
"Some or all of the required endpoints are missing in the object passed to the `endpoints` attribute of the`AuthConfig` object."
|
|
1097
794
|
);
|
|
1098
|
-
return Promise.resolve();
|
|
1099
795
|
}
|
|
796
|
+
configData.endpoints && Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
797
|
+
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
798
|
+
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
799
|
+
});
|
|
800
|
+
return { ...oidcProviderMetaData };
|
|
1100
801
|
}
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
const
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
802
|
+
async resolveEndpointsByBaseURL() {
|
|
803
|
+
const oidcProviderMetaData = {};
|
|
804
|
+
const configData = await this._config();
|
|
805
|
+
const baseUrl = configData.baseUrl;
|
|
806
|
+
if (!baseUrl) {
|
|
807
|
+
throw new AsgardeoAuthException(
|
|
808
|
+
"JS-AUTH_HELPER_REBO-NF01",
|
|
809
|
+
"Base URL not defined.",
|
|
810
|
+
"Base URL is not defined in AuthClient config."
|
|
811
|
+
);
|
|
812
|
+
}
|
|
813
|
+
configData.endpoints && Object.keys(configData.endpoints).forEach((endpointName) => {
|
|
814
|
+
const snakeCasedName = endpointName.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
815
|
+
oidcProviderMetaData[snakeCasedName] = configData?.endpoints ? configData.endpoints[endpointName] : "";
|
|
816
|
+
});
|
|
817
|
+
const defaultEndpoints = {
|
|
818
|
+
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.AUTHORIZATION]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.AUTHORIZATION}`,
|
|
819
|
+
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.END_SESSION]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.END_SESSION}`,
|
|
820
|
+
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.ISSUER]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.ISSUER}`,
|
|
821
|
+
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.JWKS]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.JWKS}`,
|
|
822
|
+
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.SESSION_IFRAME]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.SESSION_IFRAME}`,
|
|
823
|
+
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.REVOCATION]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.REVOCATION}`,
|
|
824
|
+
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.TOKEN]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.TOKEN}`,
|
|
825
|
+
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.USERINFO]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.USERINFO}`
|
|
1115
826
|
};
|
|
827
|
+
return { ...defaultEndpoints, ...oidcProviderMetaData };
|
|
1116
828
|
}
|
|
1117
|
-
async
|
|
1118
|
-
const
|
|
829
|
+
async validateIdToken(idToken) {
|
|
830
|
+
const jwksEndpoint = (await this._storageManager.loadOpenIDProviderConfiguration()).jwks_uri;
|
|
1119
831
|
const configData = await this._config();
|
|
1120
|
-
if (!
|
|
832
|
+
if (!jwksEndpoint || jwksEndpoint.trim().length === 0) {
|
|
1121
833
|
throw new AsgardeoAuthException(
|
|
1122
|
-
"
|
|
1123
|
-
"
|
|
1124
|
-
"No
|
|
834
|
+
"JS_AUTH_HELPER-VIT-NF01",
|
|
835
|
+
"JWKS endpoint not found.",
|
|
836
|
+
"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."
|
|
1125
837
|
);
|
|
1126
838
|
}
|
|
1127
|
-
|
|
1128
|
-
|
|
839
|
+
let response;
|
|
840
|
+
try {
|
|
841
|
+
response = await fetch(jwksEndpoint, {
|
|
842
|
+
credentials: configData.sendCookiesInRequests ? "include" : "same-origin"
|
|
843
|
+
});
|
|
844
|
+
} catch (error) {
|
|
1129
845
|
throw new AsgardeoAuthException(
|
|
1130
|
-
"JS-
|
|
1131
|
-
"
|
|
1132
|
-
"The
|
|
846
|
+
"JS-AUTH_HELPER-VIT-NE02",
|
|
847
|
+
"Request to jwks endpoint failed.",
|
|
848
|
+
error ?? "The request sent to get the jwks from the server failed."
|
|
1133
849
|
);
|
|
1134
850
|
}
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
"JS-AUTH_CORE-GSOU-NF02",
|
|
1142
|
-
"ID token not found.",
|
|
1143
|
-
"No ID token could be found. Either the session information is lost or you have not signed in."
|
|
1144
|
-
);
|
|
1145
|
-
}
|
|
1146
|
-
queryParams.set("id_token_hint", idToken);
|
|
1147
|
-
} else {
|
|
1148
|
-
queryParams.set("client_id", configData.clientID);
|
|
1149
|
-
}
|
|
1150
|
-
queryParams.set("state", OIDCRequestConstants_default.Params.SIGN_OUT_SUCCESS);
|
|
1151
|
-
return `${logoutEndpoint}?${queryParams.toString()}`;
|
|
1152
|
-
}
|
|
1153
|
-
async clearUserSessionData(userID) {
|
|
1154
|
-
await this._authenticationHelper.clearUserSessionData(userID);
|
|
1155
|
-
}
|
|
1156
|
-
async getAccessToken(userID) {
|
|
1157
|
-
return (await this._dataLayer.getSessionData(userID))?.access_token;
|
|
1158
|
-
}
|
|
1159
|
-
/**
|
|
1160
|
-
* The created timestamp of the token response in milliseconds.
|
|
1161
|
-
*
|
|
1162
|
-
* @param userID - User ID
|
|
1163
|
-
* @returns Created at timestamp of the token response in milliseconds.
|
|
1164
|
-
*/
|
|
1165
|
-
async getCreatedAt(userID) {
|
|
1166
|
-
return (await this._dataLayer.getSessionData(userID))?.created_at;
|
|
1167
|
-
}
|
|
1168
|
-
/**
|
|
1169
|
-
* The expires timestamp of the token response in seconds.
|
|
1170
|
-
*
|
|
1171
|
-
* @param userID - User ID
|
|
1172
|
-
* @returns Expires in timestamp of the token response in seconds.
|
|
1173
|
-
*/
|
|
1174
|
-
async getExpiresIn(userID) {
|
|
1175
|
-
return (await this._dataLayer.getSessionData(userID))?.expires_in;
|
|
1176
|
-
}
|
|
1177
|
-
async isAuthenticated(userID) {
|
|
1178
|
-
const isAccessTokenAvailable = Boolean(await this.getAccessToken(userID));
|
|
1179
|
-
const createdAt = await this.getCreatedAt(userID);
|
|
1180
|
-
const expiresInString = await this.getExpiresIn(userID);
|
|
1181
|
-
if (!expiresInString) {
|
|
1182
|
-
return false;
|
|
851
|
+
if (response.status !== 200 || !response.ok) {
|
|
852
|
+
throw new AsgardeoAuthException(
|
|
853
|
+
"JS-AUTH_HELPER-VIT-HE03",
|
|
854
|
+
`Invalid response status received for jwks request (${response.statusText}).`,
|
|
855
|
+
await response.json()
|
|
856
|
+
);
|
|
1183
857
|
}
|
|
1184
|
-
const
|
|
1185
|
-
const
|
|
1186
|
-
const
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
async updateConfig(config) {
|
|
1197
|
-
await this._dataLayer.setConfigData(config);
|
|
1198
|
-
await this.getOIDCProviderMetaData(true);
|
|
1199
|
-
}
|
|
1200
|
-
};
|
|
1201
|
-
|
|
1202
|
-
// src/__legacy__/data/data-layer.ts
|
|
1203
|
-
var ASGARDEO_SESSION_ACTIVE = "asgardeo-session-active";
|
|
1204
|
-
var DataLayer = class {
|
|
1205
|
-
constructor(instanceID, store) {
|
|
1206
|
-
__publicField(this, "_id");
|
|
1207
|
-
__publicField(this, "_store");
|
|
1208
|
-
this._id = instanceID;
|
|
1209
|
-
this._store = store;
|
|
1210
|
-
}
|
|
1211
|
-
async setDataInBulk(key, data) {
|
|
1212
|
-
const existingDataJSON = await this._store.getData(key) ?? null;
|
|
1213
|
-
const existingData = existingDataJSON && JSON.parse(existingDataJSON);
|
|
1214
|
-
const dataToBeSaved = { ...existingData, ...data };
|
|
1215
|
-
const dataToBeSavedJSON = JSON.stringify(dataToBeSaved);
|
|
1216
|
-
await this._store.setData(key, dataToBeSavedJSON);
|
|
858
|
+
const issuer = (await this._oidcProviderMetaData()).issuer;
|
|
859
|
+
const { keys } = await response.json();
|
|
860
|
+
const jwk = await this._cryptoHelper.getJWKForTheIdToken(idToken.split(".")[0], keys);
|
|
861
|
+
return this._cryptoHelper.isValidIdToken(
|
|
862
|
+
idToken,
|
|
863
|
+
jwk,
|
|
864
|
+
(await this._config()).clientId,
|
|
865
|
+
issuer ?? "",
|
|
866
|
+
this._cryptoHelper.decodeIdToken(idToken).sub,
|
|
867
|
+
(await this._config()).clockTolerance,
|
|
868
|
+
(await this._config()).validateIDTokenIssuer ?? true
|
|
869
|
+
);
|
|
1217
870
|
}
|
|
1218
|
-
|
|
1219
|
-
const
|
|
1220
|
-
const
|
|
1221
|
-
const
|
|
1222
|
-
const
|
|
1223
|
-
|
|
871
|
+
getAuthenticatedUserInfo(idToken) {
|
|
872
|
+
const payload = this._cryptoHelper.decodeIdToken(idToken);
|
|
873
|
+
const username = payload?.["username"] ?? "";
|
|
874
|
+
const givenName = payload?.["given_name"] ?? "";
|
|
875
|
+
const familyName = payload?.["family_name"] ?? "";
|
|
876
|
+
const fullName = givenName && familyName ? `${givenName} ${familyName}` : givenName ? givenName : familyName ? familyName : "";
|
|
877
|
+
const displayName = payload.preferred_username ?? fullName;
|
|
878
|
+
return {
|
|
879
|
+
displayName,
|
|
880
|
+
username,
|
|
881
|
+
...extractUserClaimsFromIdToken_default(payload)
|
|
882
|
+
};
|
|
1224
883
|
}
|
|
1225
|
-
async
|
|
1226
|
-
const
|
|
1227
|
-
const
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
884
|
+
async replaceCustomGrantTemplateTags(text, userId) {
|
|
885
|
+
const configData = await this._config();
|
|
886
|
+
const sessionData = await this._storageManager.getSessionData(userId);
|
|
887
|
+
let scope = processOpenIDScopes_default(configData.scopes);
|
|
888
|
+
return text.replace(TokenExchangeConstants_default.Placeholders.TOKEN, sessionData.access_token).replace(
|
|
889
|
+
TokenExchangeConstants_default.Placeholders.USERNAME,
|
|
890
|
+
this.getAuthenticatedUserInfo(sessionData.id_token).username
|
|
891
|
+
).replace(TokenExchangeConstants_default.Placeholders.SCOPE, scope).replace(TokenExchangeConstants_default.Placeholders.CLIENT_ID, configData.clientId).replace(TokenExchangeConstants_default.Placeholders.CLIENT_SECRET, configData.clientSecret ?? "");
|
|
1232
892
|
}
|
|
1233
|
-
|
|
1234
|
-
|
|
893
|
+
async clearSession(userId) {
|
|
894
|
+
await this._storageManager.removeTemporaryData(userId);
|
|
895
|
+
await this._storageManager.removeSessionData(userId);
|
|
1235
896
|
}
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
897
|
+
async handleTokenResponse(response, userId) {
|
|
898
|
+
if (response.status !== 200 || !response.ok) {
|
|
899
|
+
throw new AsgardeoAuthException(
|
|
900
|
+
"JS-AUTH_HELPER-HTR-NE01",
|
|
901
|
+
`Invalid response status received for token request (${response.statusText}).`,
|
|
902
|
+
await response.json()
|
|
903
|
+
);
|
|
904
|
+
}
|
|
905
|
+
const parsedResponse = await response.json();
|
|
906
|
+
parsedResponse.created_at = (/* @__PURE__ */ new Date()).getTime();
|
|
907
|
+
const shouldValidateIdToken = (await this._config()).validateIDToken;
|
|
908
|
+
if (shouldValidateIdToken) {
|
|
909
|
+
return this.validateIdToken(parsedResponse.id_token).then(async () => {
|
|
910
|
+
await this._storageManager.setSessionData(parsedResponse, userId);
|
|
911
|
+
const tokenResponse = {
|
|
912
|
+
accessToken: parsedResponse.access_token,
|
|
913
|
+
createdAt: parsedResponse.created_at,
|
|
914
|
+
expiresIn: parsedResponse.expires_in,
|
|
915
|
+
idToken: parsedResponse.id_token,
|
|
916
|
+
refreshToken: parsedResponse.refresh_token,
|
|
917
|
+
scope: parsedResponse.scope,
|
|
918
|
+
tokenType: parsedResponse.token_type
|
|
919
|
+
};
|
|
920
|
+
return Promise.resolve(tokenResponse);
|
|
921
|
+
});
|
|
922
|
+
} else {
|
|
923
|
+
const tokenResponse = {
|
|
924
|
+
accessToken: parsedResponse.access_token,
|
|
925
|
+
createdAt: parsedResponse.created_at,
|
|
926
|
+
expiresIn: parsedResponse.expires_in,
|
|
927
|
+
idToken: parsedResponse.id_token,
|
|
928
|
+
refreshToken: parsedResponse.refresh_token,
|
|
929
|
+
scope: parsedResponse.scope,
|
|
930
|
+
tokenType: parsedResponse.token_type
|
|
931
|
+
};
|
|
932
|
+
await this._storageManager.setSessionData(parsedResponse, userId);
|
|
933
|
+
return Promise.resolve(tokenResponse);
|
|
1244
934
|
}
|
|
1245
935
|
}
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
}
|
|
1294
|
-
async removeSessionData(userID) {
|
|
1295
|
-
await this._store.removeData(this._resolveKey("session_data" /* SessionData */, userID));
|
|
1296
|
-
}
|
|
1297
|
-
async getConfigDataParameter(key) {
|
|
1298
|
-
const data = await this._store.getData(this._resolveKey("config_data" /* ConfigData */));
|
|
1299
|
-
return data && JSON.parse(data)[key];
|
|
1300
|
-
}
|
|
1301
|
-
async getOIDCProviderMetaDataParameter(key) {
|
|
1302
|
-
const data = await this._store.getData(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */));
|
|
1303
|
-
return data && JSON.parse(data)[key];
|
|
1304
|
-
}
|
|
1305
|
-
async getTemporaryDataParameter(key, userID) {
|
|
1306
|
-
const data = await this._store.getData(this._resolveKey("temporary_data" /* TemporaryData */, userID));
|
|
1307
|
-
return data && JSON.parse(data)[key];
|
|
1308
|
-
}
|
|
1309
|
-
async getSessionDataParameter(key, userID) {
|
|
1310
|
-
const data = await this._store.getData(this._resolveKey("session_data" /* SessionData */, userID));
|
|
1311
|
-
return data && JSON.parse(data)[key];
|
|
1312
|
-
}
|
|
1313
|
-
async setConfigDataParameter(key, value) {
|
|
1314
|
-
await this.setValue(this._resolveKey("config_data" /* ConfigData */), key, value);
|
|
1315
|
-
}
|
|
1316
|
-
async setOIDCProviderMetaDataParameter(key, value) {
|
|
1317
|
-
await this.setValue(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), key, value);
|
|
1318
|
-
}
|
|
1319
|
-
async setTemporaryDataParameter(key, value, userID) {
|
|
1320
|
-
await this.setValue(this._resolveKey("temporary_data" /* TemporaryData */, userID), key, value);
|
|
1321
|
-
}
|
|
1322
|
-
async setSessionDataParameter(key, value, userID) {
|
|
1323
|
-
await this.setValue(this._resolveKey("session_data" /* SessionData */, userID), key, value);
|
|
1324
|
-
}
|
|
1325
|
-
async removeConfigDataParameter(key) {
|
|
1326
|
-
await this.removeValue(this._resolveKey("config_data" /* ConfigData */), key);
|
|
1327
|
-
}
|
|
1328
|
-
async removeOIDCProviderMetaDataParameter(key) {
|
|
1329
|
-
await this.removeValue(this._resolveKey("oidc_provider_meta_data" /* OIDCProviderMetaData */), key);
|
|
936
|
+
};
|
|
937
|
+
|
|
938
|
+
// src/utils/generatePkceStorageKey.ts
|
|
939
|
+
var generatePkceStorageKey = (tempStore) => {
|
|
940
|
+
const keys = [];
|
|
941
|
+
Object.keys(tempStore).forEach((key) => {
|
|
942
|
+
if (key.startsWith(PKCEConstants_default.Storage.StorageKeys.CODE_VERIFIER)) {
|
|
943
|
+
keys.push(key);
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
const lastKey = keys.sort().pop();
|
|
947
|
+
const index = parseInt(lastKey?.split(PKCEConstants_default.Storage.StorageKeys.SEPARATOR)[1] ?? "-1");
|
|
948
|
+
return `${PKCEConstants_default.Storage.StorageKeys.CODE_VERIFIER}${PKCEConstants_default.Storage.StorageKeys.SEPARATOR}${index + 1}`;
|
|
949
|
+
};
|
|
950
|
+
var generatePkceStorageKey_default = generatePkceStorageKey;
|
|
951
|
+
|
|
952
|
+
// src/utils/generateStateParamForRequestCorrelation.ts
|
|
953
|
+
var generateStateParamForRequestCorrelation = (pkceKey, state) => {
|
|
954
|
+
const index = parseInt(pkceKey.split(PKCEConstants_default.Storage.StorageKeys.SEPARATOR)[1]);
|
|
955
|
+
return state ? `${state}_request_${index}` : `request_${index}`;
|
|
956
|
+
};
|
|
957
|
+
var generateStateParamForRequestCorrelation_default = generateStateParamForRequestCorrelation;
|
|
958
|
+
|
|
959
|
+
// src/utils/getAuthorizeRequestUrlParams.ts
|
|
960
|
+
var getAuthorizeRequestUrlParams = (options, pkceOptions, customParams) => {
|
|
961
|
+
const { redirectUri, clientId, scopes, responseMode, codeChallenge, codeChallengeMethod, prompt } = options;
|
|
962
|
+
const authorizeRequestParams = /* @__PURE__ */ new Map();
|
|
963
|
+
authorizeRequestParams.set("response_type", "code");
|
|
964
|
+
authorizeRequestParams.set("client_id", clientId);
|
|
965
|
+
authorizeRequestParams.set("scope", scopes);
|
|
966
|
+
authorizeRequestParams.set("redirect_uri", redirectUri);
|
|
967
|
+
if (responseMode) {
|
|
968
|
+
authorizeRequestParams.set("response_mode", responseMode);
|
|
969
|
+
}
|
|
970
|
+
const pkceKey = pkceOptions?.key;
|
|
971
|
+
if (codeChallenge) {
|
|
972
|
+
authorizeRequestParams.set("code_challenge", codeChallenge);
|
|
973
|
+
if (codeChallengeMethod) {
|
|
974
|
+
authorizeRequestParams.set("code_challenge_method", codeChallengeMethod);
|
|
975
|
+
} else {
|
|
976
|
+
throw new AsgardeoRuntimeError(
|
|
977
|
+
"Code challenge method is required when code challenge is provided.",
|
|
978
|
+
"getAuthorizeRequestUrlParams-ValidationError-001",
|
|
979
|
+
"javascript",
|
|
980
|
+
"When PKCE is enabled, the code challenge method must be provided along with the code challenge."
|
|
981
|
+
);
|
|
982
|
+
}
|
|
1330
983
|
}
|
|
1331
|
-
|
|
1332
|
-
|
|
984
|
+
if (prompt) {
|
|
985
|
+
authorizeRequestParams.set("prompt", prompt);
|
|
1333
986
|
}
|
|
1334
|
-
|
|
1335
|
-
|
|
987
|
+
if (customParams) {
|
|
988
|
+
for (const [key, value] of Object.entries(customParams)) {
|
|
989
|
+
if (key !== "" && value !== "" && key !== OIDCRequestConstants_default.Params.STATE) {
|
|
990
|
+
authorizeRequestParams.set(key, value.toString());
|
|
991
|
+
}
|
|
992
|
+
}
|
|
1336
993
|
}
|
|
994
|
+
authorizeRequestParams.set(
|
|
995
|
+
OIDCRequestConstants_default.Params.STATE,
|
|
996
|
+
generateStateParamForRequestCorrelation_default(
|
|
997
|
+
pkceKey,
|
|
998
|
+
customParams ? customParams[OIDCRequestConstants_default.Params.STATE]?.toString() : ""
|
|
999
|
+
)
|
|
1000
|
+
);
|
|
1001
|
+
return authorizeRequestParams;
|
|
1337
1002
|
};
|
|
1338
|
-
|
|
1339
|
-
// src/models/oauth-response.ts
|
|
1340
|
-
var ResponseMode = /* @__PURE__ */ ((ResponseMode2) => {
|
|
1341
|
-
ResponseMode2["FormPost"] = "form_post";
|
|
1342
|
-
ResponseMode2["Query"] = "query";
|
|
1343
|
-
ResponseMode2["Direct"] = "direct";
|
|
1344
|
-
return ResponseMode2;
|
|
1345
|
-
})(ResponseMode || {});
|
|
1003
|
+
var getAuthorizeRequestUrlParams_default = getAuthorizeRequestUrlParams;
|
|
1346
1004
|
|
|
1347
1005
|
// src/__legacy__/client.ts
|
|
1348
1006
|
var DefaultConfig = {
|
|
1349
1007
|
clockTolerance: 300,
|
|
1350
1008
|
enablePKCE: true,
|
|
1351
|
-
responseMode: "query"
|
|
1352
|
-
scope: [ScopeConstants_default.OPENID],
|
|
1009
|
+
responseMode: "query",
|
|
1353
1010
|
sendCookiesInRequests: true,
|
|
1354
1011
|
validateIDToken: true,
|
|
1355
1012
|
validateIDTokenIssuer: true
|
|
@@ -1371,8 +1028,12 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1371
1028
|
* @preserve
|
|
1372
1029
|
*/
|
|
1373
1030
|
constructor() {
|
|
1374
|
-
__publicField(this, "
|
|
1375
|
-
__publicField(this, "
|
|
1031
|
+
__publicField(this, "_storageManager");
|
|
1032
|
+
__publicField(this, "_config");
|
|
1033
|
+
__publicField(this, "_oidcProviderMetaData");
|
|
1034
|
+
__publicField(this, "_authenticationHelper");
|
|
1035
|
+
__publicField(this, "_cryptoUtils");
|
|
1036
|
+
__publicField(this, "_cryptoHelper");
|
|
1376
1037
|
}
|
|
1377
1038
|
/**
|
|
1378
1039
|
*
|
|
@@ -1382,8 +1043,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1382
1043
|
*
|
|
1383
1044
|
* @example
|
|
1384
1045
|
* const config = \{
|
|
1385
|
-
*
|
|
1386
|
-
*
|
|
1046
|
+
* afterSignInUrl: "http://localhost:3000/sign-in",
|
|
1047
|
+
* clientId: "client ID",
|
|
1387
1048
|
* baseUrl: "https://localhost:9443"
|
|
1388
1049
|
* \}
|
|
1389
1050
|
*
|
|
@@ -1394,7 +1055,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1394
1055
|
* @preserve
|
|
1395
1056
|
*/
|
|
1396
1057
|
async initialize(config, store, cryptoUtils, instanceID) {
|
|
1397
|
-
const clientId = config.
|
|
1058
|
+
const clientId = config.clientId;
|
|
1398
1059
|
if (!_AsgardeoAuthClient._instanceID) {
|
|
1399
1060
|
_AsgardeoAuthClient._instanceID = 0;
|
|
1400
1061
|
} else {
|
|
@@ -1404,37 +1065,38 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1404
1065
|
_AsgardeoAuthClient._instanceID = instanceID;
|
|
1405
1066
|
}
|
|
1406
1067
|
if (!clientId) {
|
|
1407
|
-
this.
|
|
1068
|
+
this._storageManager = new StorageManager_default(`instance_${_AsgardeoAuthClient._instanceID}`, store);
|
|
1408
1069
|
} else {
|
|
1409
|
-
this.
|
|
1070
|
+
this._storageManager = new StorageManager_default(`instance_${_AsgardeoAuthClient._instanceID}-${clientId}`, store);
|
|
1410
1071
|
}
|
|
1411
|
-
this.
|
|
1412
|
-
|
|
1413
|
-
|
|
1072
|
+
this._cryptoUtils = cryptoUtils;
|
|
1073
|
+
this._cryptoHelper = new IsomorphicCrypto(cryptoUtils);
|
|
1074
|
+
this._authenticationHelper = new AuthenticationHelper(this._storageManager, this._cryptoHelper);
|
|
1075
|
+
this._config = async () => await this._storageManager.getConfigData();
|
|
1076
|
+
this._oidcProviderMetaData = async () => await this._storageManager.loadOpenIDProviderConfiguration();
|
|
1077
|
+
_AsgardeoAuthClient._authenticationHelper = this._authenticationHelper;
|
|
1078
|
+
await this._storageManager.setConfigData({
|
|
1414
1079
|
...DefaultConfig,
|
|
1415
1080
|
...config,
|
|
1416
|
-
scope:
|
|
1417
|
-
...DefaultConfig.scope ?? [],
|
|
1418
|
-
...config.scope?.filter((scope) => !DefaultConfig?.scope?.includes(scope)) ?? []
|
|
1419
|
-
]
|
|
1081
|
+
scope: processOpenIDScopes_default(config.scopes)
|
|
1420
1082
|
});
|
|
1421
1083
|
}
|
|
1422
1084
|
/**
|
|
1423
|
-
* This method returns the `
|
|
1085
|
+
* This method returns the `StorageManager` object that allows you to access authentication data.
|
|
1424
1086
|
*
|
|
1425
|
-
* @returns - The `
|
|
1087
|
+
* @returns - The `StorageManager` object.
|
|
1426
1088
|
*
|
|
1427
1089
|
* @example
|
|
1428
1090
|
* ```
|
|
1429
|
-
* const data = auth.
|
|
1091
|
+
* const data = auth.getStorageManager();
|
|
1430
1092
|
* ```
|
|
1431
1093
|
*
|
|
1432
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
1094
|
+
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getStorageManager}
|
|
1433
1095
|
*
|
|
1434
1096
|
* @preserve
|
|
1435
1097
|
*/
|
|
1436
|
-
|
|
1437
|
-
return this.
|
|
1098
|
+
getStorageManager() {
|
|
1099
|
+
return this._storageManager;
|
|
1438
1100
|
}
|
|
1439
1101
|
/**
|
|
1440
1102
|
* This method returns the `instanceID` variable of the given instance.
|
|
@@ -1443,82 +1105,87 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1443
1105
|
*
|
|
1444
1106
|
* @example
|
|
1445
1107
|
* ```
|
|
1446
|
-
* const instanceId = auth.
|
|
1108
|
+
* const instanceId = auth.getInstanceId();
|
|
1447
1109
|
* ```
|
|
1448
1110
|
*
|
|
1449
1111
|
* @preserve
|
|
1450
1112
|
*/
|
|
1451
|
-
|
|
1113
|
+
getInstanceId() {
|
|
1452
1114
|
return _AsgardeoAuthClient._instanceID;
|
|
1453
1115
|
}
|
|
1454
|
-
/**
|
|
1455
|
-
* This is an async method that returns a Promise that resolves with the authorization URL parameters.
|
|
1456
|
-
*
|
|
1457
|
-
* @param config - (Optional) A config object to force initialization and pass
|
|
1458
|
-
* custom path parameters such as the `fidp` parameter.
|
|
1459
|
-
* @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1460
|
-
* scenarios where each user should be uniquely identified.
|
|
1461
|
-
*
|
|
1462
|
-
* @returns - A promise that resolves with the authorization URL parameters.
|
|
1463
|
-
*
|
|
1464
|
-
* @example
|
|
1465
|
-
* ```
|
|
1466
|
-
* auth.getAuthorizationURLParams().then((params)=>{
|
|
1467
|
-
* // console.log(params);
|
|
1468
|
-
* }).catch((error)=>{
|
|
1469
|
-
* // console.error(error);
|
|
1470
|
-
* });
|
|
1471
|
-
* ```
|
|
1472
|
-
*
|
|
1473
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getAuthorizationURLParams}
|
|
1474
|
-
*
|
|
1475
|
-
* @preserve
|
|
1476
|
-
*/
|
|
1477
|
-
async getAuthorizationURLParams(config, userID) {
|
|
1478
|
-
const authRequestConfig = { ...config };
|
|
1479
|
-
delete authRequestConfig?.forceInit;
|
|
1480
|
-
if (await this._dataLayer.getTemporaryDataParameter(
|
|
1481
|
-
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED
|
|
1482
|
-
)) {
|
|
1483
|
-
return this._authenticationCore.getAuthorizationURLParams(authRequestConfig, userID);
|
|
1484
|
-
}
|
|
1485
|
-
return this._authenticationCore.getOIDCProviderMetaData(config?.forceInit).then(() => {
|
|
1486
|
-
return this._authenticationCore.getAuthorizationURLParams(authRequestConfig, userID);
|
|
1487
|
-
});
|
|
1488
|
-
}
|
|
1489
1116
|
/**
|
|
1490
1117
|
* This is an async method that returns a Promise that resolves with the authorization URL.
|
|
1491
1118
|
*
|
|
1492
1119
|
* @param config - (Optional) A config object to force initialization and pass
|
|
1493
1120
|
* custom path parameters such as the fidp parameter.
|
|
1494
|
-
* @param
|
|
1121
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1495
1122
|
* scenarios where each user should be uniquely identified.
|
|
1496
1123
|
*
|
|
1497
1124
|
* @returns - A promise that resolves with the authorization URL.
|
|
1498
1125
|
*
|
|
1499
1126
|
* @example
|
|
1500
1127
|
* ```
|
|
1501
|
-
* auth.
|
|
1128
|
+
* auth.getSignInUrl().then((url)=>{
|
|
1502
1129
|
* // console.log(url);
|
|
1503
1130
|
* }).catch((error)=>{
|
|
1504
1131
|
* // console.error(error);
|
|
1505
1132
|
* });
|
|
1506
1133
|
* ```
|
|
1507
1134
|
*
|
|
1508
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
1135
|
+
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getSignInUrl}
|
|
1509
1136
|
*
|
|
1510
1137
|
* @preserve
|
|
1511
1138
|
*/
|
|
1512
|
-
async
|
|
1513
|
-
const authRequestConfig = { ...
|
|
1139
|
+
async getSignInUrl(requestConfig, userId) {
|
|
1140
|
+
const authRequestConfig = { ...requestConfig };
|
|
1514
1141
|
delete authRequestConfig?.forceInit;
|
|
1515
|
-
|
|
1142
|
+
const __TODO__ = async () => {
|
|
1143
|
+
const authorizeEndpoint = await this._storageManager.getOIDCProviderMetaDataParameter(
|
|
1144
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.AUTHORIZATION
|
|
1145
|
+
);
|
|
1146
|
+
if (!authorizeEndpoint || authorizeEndpoint.trim().length === 0) {
|
|
1147
|
+
throw new AsgardeoAuthException(
|
|
1148
|
+
"JS-AUTH_CORE-GAU-NF01",
|
|
1149
|
+
"No authorization endpoint found.",
|
|
1150
|
+
"No authorization endpoint was found in the OIDC provider meta data from the well-known endpoint or the authorization endpoint passed to the SDK is empty."
|
|
1151
|
+
);
|
|
1152
|
+
}
|
|
1153
|
+
const authorizeRequest = new URL(authorizeEndpoint);
|
|
1154
|
+
const configData = await this._config();
|
|
1155
|
+
const tempStore = await this._storageManager.getTemporaryData(userId);
|
|
1156
|
+
const pkceKey = await generatePkceStorageKey_default(tempStore);
|
|
1157
|
+
let codeVerifier;
|
|
1158
|
+
let codeChallenge;
|
|
1159
|
+
if (configData.enablePKCE) {
|
|
1160
|
+
codeVerifier = this._cryptoHelper?.getCodeVerifier();
|
|
1161
|
+
codeChallenge = this._cryptoHelper?.getCodeChallenge(codeVerifier);
|
|
1162
|
+
await this._storageManager.setTemporaryDataParameter(pkceKey, codeVerifier, userId);
|
|
1163
|
+
}
|
|
1164
|
+
const authorizeRequestParams = getAuthorizeRequestUrlParams_default(
|
|
1165
|
+
{
|
|
1166
|
+
redirectUri: configData.afterSignInUrl,
|
|
1167
|
+
clientId: configData.clientId,
|
|
1168
|
+
scopes: processOpenIDScopes_default(configData.scopes),
|
|
1169
|
+
responseMode: configData.responseMode,
|
|
1170
|
+
codeChallengeMethod: PKCEConstants_default.DEFAULT_CODE_CHALLENGE_METHOD,
|
|
1171
|
+
codeChallenge,
|
|
1172
|
+
prompt: configData.prompt
|
|
1173
|
+
},
|
|
1174
|
+
{ key: pkceKey },
|
|
1175
|
+
authRequestConfig
|
|
1176
|
+
);
|
|
1177
|
+
for (const [key, value] of authorizeRequestParams.entries()) {
|
|
1178
|
+
authorizeRequest.searchParams.append(key, value);
|
|
1179
|
+
}
|
|
1180
|
+
return authorizeRequest.toString();
|
|
1181
|
+
};
|
|
1182
|
+
if (await this._storageManager.getTemporaryDataParameter(
|
|
1516
1183
|
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED
|
|
1517
1184
|
)) {
|
|
1518
|
-
return
|
|
1185
|
+
return __TODO__();
|
|
1519
1186
|
}
|
|
1520
|
-
return this.
|
|
1521
|
-
return
|
|
1187
|
+
return this.loadOpenIDProviderConfiguration(requestConfig?.forceInit).then(() => {
|
|
1188
|
+
return __TODO__();
|
|
1522
1189
|
});
|
|
1523
1190
|
}
|
|
1524
1191
|
/**
|
|
@@ -1527,7 +1194,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1527
1194
|
*
|
|
1528
1195
|
* @param authorizationCode - The authorization code.
|
|
1529
1196
|
* @param sessionState - The session state.
|
|
1530
|
-
* @param
|
|
1197
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1531
1198
|
* scenarios where each user should be uniquely identified.
|
|
1532
1199
|
*
|
|
1533
1200
|
* @returns - A Promise that resolves with the token response.
|
|
@@ -1546,32 +1213,139 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1546
1213
|
*
|
|
1547
1214
|
* @preserve
|
|
1548
1215
|
*/
|
|
1549
|
-
async requestAccessToken(authorizationCode, sessionState, state,
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1216
|
+
async requestAccessToken(authorizationCode, sessionState, state, userId, tokenRequestConfig) {
|
|
1217
|
+
const __TODO__ = async () => {
|
|
1218
|
+
const tokenEndpoint = (await this._oidcProviderMetaData()).token_endpoint;
|
|
1219
|
+
const configData = await this._config();
|
|
1220
|
+
if (!tokenEndpoint || tokenEndpoint.trim().length === 0) {
|
|
1221
|
+
throw new AsgardeoAuthException(
|
|
1222
|
+
"JS-AUTH_CORE-RAT1-NF01",
|
|
1223
|
+
"Token endpoint not found.",
|
|
1224
|
+
"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."
|
|
1225
|
+
);
|
|
1226
|
+
}
|
|
1227
|
+
sessionState && await this._storageManager.setSessionDataParameter(
|
|
1228
|
+
OIDCRequestConstants_default.Params.SESSION_STATE,
|
|
1555
1229
|
sessionState,
|
|
1556
|
-
|
|
1557
|
-
userID,
|
|
1558
|
-
tokenRequestConfig
|
|
1230
|
+
userId
|
|
1559
1231
|
);
|
|
1232
|
+
const body = new URLSearchParams();
|
|
1233
|
+
body.set("client_id", configData.clientId);
|
|
1234
|
+
if (configData.clientSecret && configData.clientSecret.trim().length > 0) {
|
|
1235
|
+
body.set("client_secret", configData.clientSecret);
|
|
1236
|
+
}
|
|
1237
|
+
const code = authorizationCode;
|
|
1238
|
+
body.set("code", code);
|
|
1239
|
+
body.set("grant_type", "authorization_code");
|
|
1240
|
+
body.set("redirect_uri", configData.afterSignInUrl);
|
|
1241
|
+
if (tokenRequestConfig?.params) {
|
|
1242
|
+
Object.entries(tokenRequestConfig.params).forEach(([key, value]) => {
|
|
1243
|
+
body.append(key, value);
|
|
1244
|
+
});
|
|
1245
|
+
}
|
|
1246
|
+
if (configData.enablePKCE) {
|
|
1247
|
+
body.set(
|
|
1248
|
+
"code_verifier",
|
|
1249
|
+
`${await this._storageManager.getTemporaryDataParameter(extractPkceStorageKeyFromState_default(state), userId)}`
|
|
1250
|
+
);
|
|
1251
|
+
await this._storageManager.removeTemporaryDataParameter(extractPkceStorageKeyFromState_default(state), userId);
|
|
1252
|
+
}
|
|
1253
|
+
let tokenResponse;
|
|
1254
|
+
try {
|
|
1255
|
+
tokenResponse = await fetch(tokenEndpoint, {
|
|
1256
|
+
body,
|
|
1257
|
+
credentials: configData.sendCookiesInRequests ? "include" : "same-origin",
|
|
1258
|
+
headers: {
|
|
1259
|
+
Accept: "application/json",
|
|
1260
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
1261
|
+
},
|
|
1262
|
+
method: "POST"
|
|
1263
|
+
});
|
|
1264
|
+
} catch (error) {
|
|
1265
|
+
throw new AsgardeoAuthException(
|
|
1266
|
+
"JS-AUTH_CORE-RAT1-NE02",
|
|
1267
|
+
"Requesting access token failed",
|
|
1268
|
+
error ?? "The request to get the access token from the server failed."
|
|
1269
|
+
);
|
|
1270
|
+
}
|
|
1271
|
+
if (!tokenResponse.ok) {
|
|
1272
|
+
throw new AsgardeoAuthException(
|
|
1273
|
+
"JS-AUTH_CORE-RAT1-HE03",
|
|
1274
|
+
`Requesting access token failed with ${tokenResponse.statusText}`,
|
|
1275
|
+
await tokenResponse.json()
|
|
1276
|
+
);
|
|
1277
|
+
}
|
|
1278
|
+
return await this._authenticationHelper.handleTokenResponse(tokenResponse, userId);
|
|
1279
|
+
};
|
|
1280
|
+
if (await this._storageManager.getTemporaryDataParameter(
|
|
1281
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED
|
|
1282
|
+
)) {
|
|
1283
|
+
return __TODO__();
|
|
1560
1284
|
}
|
|
1561
|
-
return this.
|
|
1562
|
-
return
|
|
1563
|
-
authorizationCode,
|
|
1564
|
-
sessionState,
|
|
1565
|
-
state,
|
|
1566
|
-
userID,
|
|
1567
|
-
tokenRequestConfig
|
|
1568
|
-
);
|
|
1285
|
+
return this.loadOpenIDProviderConfiguration(false).then(() => {
|
|
1286
|
+
return __TODO__();
|
|
1569
1287
|
});
|
|
1570
1288
|
}
|
|
1289
|
+
async loadOpenIDProviderConfiguration(forceInit) {
|
|
1290
|
+
const configData = await this._config();
|
|
1291
|
+
if (!forceInit && await this._storageManager.getTemporaryDataParameter(
|
|
1292
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED
|
|
1293
|
+
)) {
|
|
1294
|
+
return Promise.resolve();
|
|
1295
|
+
}
|
|
1296
|
+
const wellKnownEndpoint = configData.wellKnownEndpoint;
|
|
1297
|
+
if (wellKnownEndpoint) {
|
|
1298
|
+
let response;
|
|
1299
|
+
try {
|
|
1300
|
+
response = await fetch(wellKnownEndpoint);
|
|
1301
|
+
if (response.status !== 200 || !response.ok) {
|
|
1302
|
+
throw new Error();
|
|
1303
|
+
}
|
|
1304
|
+
} catch {
|
|
1305
|
+
throw new AsgardeoAuthException(
|
|
1306
|
+
"JS-AUTH_CORE-GOPMD-HE01",
|
|
1307
|
+
"Invalid well-known response",
|
|
1308
|
+
"The well known endpoint response has been failed with an error."
|
|
1309
|
+
);
|
|
1310
|
+
}
|
|
1311
|
+
await this._storageManager.setOIDCProviderMetaData(
|
|
1312
|
+
await this._authenticationHelper.resolveEndpoints(await response.json())
|
|
1313
|
+
);
|
|
1314
|
+
await this._storageManager.setTemporaryDataParameter(
|
|
1315
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,
|
|
1316
|
+
true
|
|
1317
|
+
);
|
|
1318
|
+
return Promise.resolve();
|
|
1319
|
+
} else if (configData.baseUrl) {
|
|
1320
|
+
try {
|
|
1321
|
+
await this._storageManager.setOIDCProviderMetaData(
|
|
1322
|
+
await this._authenticationHelper.resolveEndpointsByBaseURL()
|
|
1323
|
+
);
|
|
1324
|
+
} catch (error) {
|
|
1325
|
+
throw new AsgardeoAuthException(
|
|
1326
|
+
"JS-AUTH_CORE-GOPMD-IV02",
|
|
1327
|
+
"Resolving endpoints failed.",
|
|
1328
|
+
error ?? "Resolving endpoints by base url failed."
|
|
1329
|
+
);
|
|
1330
|
+
}
|
|
1331
|
+
await this._storageManager.setTemporaryDataParameter(
|
|
1332
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,
|
|
1333
|
+
true
|
|
1334
|
+
);
|
|
1335
|
+
return Promise.resolve();
|
|
1336
|
+
} else {
|
|
1337
|
+
await this._storageManager.setOIDCProviderMetaData(await this._authenticationHelper.resolveEndpointsExplicitly());
|
|
1338
|
+
await this._storageManager.setTemporaryDataParameter(
|
|
1339
|
+
OIDCDiscoveryConstants_default.Storage.StorageKeys.OPENID_PROVIDER_CONFIG_INITIATED,
|
|
1340
|
+
true
|
|
1341
|
+
);
|
|
1342
|
+
return Promise.resolve();
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1571
1345
|
/**
|
|
1572
1346
|
* This method returns the sign-out URL.
|
|
1573
1347
|
*
|
|
1574
|
-
* @param
|
|
1348
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1575
1349
|
* scenarios where each user should be uniquely identified.
|
|
1576
1350
|
*
|
|
1577
1351
|
* **This doesn't clear the authentication data.**
|
|
@@ -1580,15 +1354,48 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1580
1354
|
*
|
|
1581
1355
|
* @example
|
|
1582
1356
|
* ```
|
|
1583
|
-
* const signOutUrl = await auth.
|
|
1357
|
+
* const signOutUrl = await auth.getSignOutUrl();
|
|
1584
1358
|
* ```
|
|
1585
1359
|
*
|
|
1586
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
1360
|
+
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getSignOutUrl}
|
|
1587
1361
|
*
|
|
1588
1362
|
* @preserve
|
|
1589
1363
|
*/
|
|
1590
|
-
async
|
|
1591
|
-
|
|
1364
|
+
async getSignOutUrl(userId) {
|
|
1365
|
+
const logoutEndpoint = (await this._oidcProviderMetaData())?.end_session_endpoint;
|
|
1366
|
+
const configData = await this._config();
|
|
1367
|
+
if (!logoutEndpoint || logoutEndpoint.trim().length === 0) {
|
|
1368
|
+
throw new AsgardeoAuthException(
|
|
1369
|
+
"JS-AUTH_CORE-GSOU-NF01",
|
|
1370
|
+
"Sign-out endpoint not found.",
|
|
1371
|
+
"No sign-out endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the sign-out endpoint passed to the SDK is empty."
|
|
1372
|
+
);
|
|
1373
|
+
}
|
|
1374
|
+
const callbackURL = configData?.afterSignOutUrl ?? configData?.afterSignInUrl;
|
|
1375
|
+
if (!callbackURL || callbackURL.trim().length === 0) {
|
|
1376
|
+
throw new AsgardeoAuthException(
|
|
1377
|
+
"JS-AUTH_CORE-GSOU-NF03",
|
|
1378
|
+
"No sign-out redirect URL found.",
|
|
1379
|
+
"The sign-out redirect URL cannot be found or the URL passed to the SDK is empty. No sign-in redirect URL has been found either. "
|
|
1380
|
+
);
|
|
1381
|
+
}
|
|
1382
|
+
const queryParams = new URLSearchParams();
|
|
1383
|
+
queryParams.set("post_logout_redirect_uri", callbackURL);
|
|
1384
|
+
if (configData.sendIdTokenInLogoutRequest) {
|
|
1385
|
+
const idToken = (await this._storageManager.getSessionData(userId))?.id_token;
|
|
1386
|
+
if (!idToken || idToken.trim().length === 0) {
|
|
1387
|
+
throw new AsgardeoAuthException(
|
|
1388
|
+
"JS-AUTH_CORE-GSOU-NF02",
|
|
1389
|
+
"ID token not found.",
|
|
1390
|
+
"No ID token could be found. Either the session information is lost or you have not signed in."
|
|
1391
|
+
);
|
|
1392
|
+
}
|
|
1393
|
+
queryParams.set("id_token_hint", idToken);
|
|
1394
|
+
} else {
|
|
1395
|
+
queryParams.set("client_id", configData.clientId);
|
|
1396
|
+
}
|
|
1397
|
+
queryParams.set("state", OIDCRequestConstants_default.Params.SIGN_OUT_SUCCESS);
|
|
1398
|
+
return `${logoutEndpoint}?${queryParams.toString()}`;
|
|
1592
1399
|
}
|
|
1593
1400
|
/**
|
|
1594
1401
|
* This method returns OIDC service endpoints that are fetched from the `.well-known` endpoint.
|
|
@@ -1597,75 +1404,103 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1597
1404
|
*
|
|
1598
1405
|
* @example
|
|
1599
1406
|
* ```
|
|
1600
|
-
* const endpoints = await auth.
|
|
1407
|
+
* const endpoints = await auth.getOpenIDProviderEndpoints();
|
|
1601
1408
|
* ```
|
|
1602
1409
|
*
|
|
1603
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
1410
|
+
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getOpenIDProviderEndpoints}
|
|
1604
1411
|
*
|
|
1605
1412
|
* @preserve
|
|
1606
1413
|
*/
|
|
1607
|
-
async
|
|
1608
|
-
|
|
1414
|
+
async getOpenIDProviderEndpoints() {
|
|
1415
|
+
const oidcProviderMetaData = await this._oidcProviderMetaData();
|
|
1416
|
+
return {
|
|
1417
|
+
authorizationEndpoint: oidcProviderMetaData.authorization_endpoint ?? "",
|
|
1418
|
+
checkSessionIframe: oidcProviderMetaData.check_session_iframe ?? "",
|
|
1419
|
+
endSessionEndpoint: oidcProviderMetaData.end_session_endpoint ?? "",
|
|
1420
|
+
introspectionEndpoint: oidcProviderMetaData.introspection_endpoint ?? "",
|
|
1421
|
+
issuer: oidcProviderMetaData.issuer ?? "",
|
|
1422
|
+
jwksUri: oidcProviderMetaData.jwks_uri ?? "",
|
|
1423
|
+
registrationEndpoint: oidcProviderMetaData.registration_endpoint ?? "",
|
|
1424
|
+
revocationEndpoint: oidcProviderMetaData.revocation_endpoint ?? "",
|
|
1425
|
+
tokenEndpoint: oidcProviderMetaData.token_endpoint ?? "",
|
|
1426
|
+
userinfoEndpoint: oidcProviderMetaData.userinfo_endpoint ?? ""
|
|
1427
|
+
};
|
|
1609
1428
|
}
|
|
1610
1429
|
/**
|
|
1611
1430
|
* This method decodes the payload of the ID token and returns it.
|
|
1612
1431
|
*
|
|
1613
|
-
* @param
|
|
1432
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1614
1433
|
* scenarios where each user should be uniquely identified.
|
|
1615
1434
|
*
|
|
1616
1435
|
* @returns - A Promise that resolves with the decoded ID token payload.
|
|
1617
1436
|
*
|
|
1618
1437
|
* @example
|
|
1619
1438
|
* ```
|
|
1620
|
-
* const decodedIdToken = await auth.
|
|
1439
|
+
* const decodedIdToken = await auth.getDecodedIdToken();
|
|
1621
1440
|
* ```
|
|
1622
1441
|
*
|
|
1623
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
1442
|
+
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getDecodedIdToken}
|
|
1624
1443
|
*
|
|
1625
1444
|
* @preserve
|
|
1626
1445
|
*/
|
|
1627
|
-
async
|
|
1628
|
-
|
|
1446
|
+
async getDecodedIdToken(userId) {
|
|
1447
|
+
const idToken = (await this._storageManager.getSessionData(userId)).id_token;
|
|
1448
|
+
const payload = this._cryptoHelper.decodeIdToken(idToken);
|
|
1449
|
+
return payload;
|
|
1629
1450
|
}
|
|
1630
1451
|
/**
|
|
1631
1452
|
* This method returns the ID token.
|
|
1632
1453
|
*
|
|
1633
|
-
* @param
|
|
1454
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1634
1455
|
* scenarios where each user should be uniquely identified.
|
|
1635
1456
|
*
|
|
1636
1457
|
* @returns - A Promise that resolves with the ID token.
|
|
1637
1458
|
*
|
|
1638
1459
|
* @example
|
|
1639
1460
|
* ```
|
|
1640
|
-
* const idToken = await auth.
|
|
1461
|
+
* const idToken = await auth.getIdToken();
|
|
1641
1462
|
* ```
|
|
1642
1463
|
*
|
|
1643
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
1464
|
+
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getIdToken}
|
|
1644
1465
|
*
|
|
1645
1466
|
* @preserve
|
|
1646
1467
|
*/
|
|
1647
|
-
async
|
|
1648
|
-
return this.
|
|
1468
|
+
async getIdToken(userId) {
|
|
1469
|
+
return (await this._storageManager.getSessionData(userId)).id_token;
|
|
1649
1470
|
}
|
|
1650
1471
|
/**
|
|
1651
1472
|
* This method returns the basic user information obtained from the ID token.
|
|
1652
1473
|
*
|
|
1653
|
-
* @param
|
|
1474
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1654
1475
|
* scenarios where each user should be uniquely identified.
|
|
1655
1476
|
*
|
|
1656
1477
|
* @returns - A Promise that resolves with an object containing the basic user information.
|
|
1657
1478
|
*
|
|
1658
1479
|
* @example
|
|
1659
1480
|
* ```
|
|
1660
|
-
* const userInfo = await auth.
|
|
1481
|
+
* const userInfo = await auth.getUser();
|
|
1661
1482
|
* ```
|
|
1662
1483
|
*
|
|
1663
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
1484
|
+
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getUser}
|
|
1664
1485
|
*
|
|
1665
1486
|
* @preserve
|
|
1666
1487
|
*/
|
|
1667
|
-
async
|
|
1668
|
-
|
|
1488
|
+
async getUser(userId) {
|
|
1489
|
+
const sessionData = await this._storageManager.getSessionData(userId);
|
|
1490
|
+
const authenticatedUser = this._authenticationHelper.getAuthenticatedUserInfo(sessionData?.id_token);
|
|
1491
|
+
Object.keys(authenticatedUser).forEach((key) => {
|
|
1492
|
+
if (authenticatedUser[key] === void 0 || authenticatedUser[key] === "" || authenticatedUser[key] === null) {
|
|
1493
|
+
delete authenticatedUser[key];
|
|
1494
|
+
}
|
|
1495
|
+
});
|
|
1496
|
+
return authenticatedUser;
|
|
1497
|
+
}
|
|
1498
|
+
async getUserSession(userId) {
|
|
1499
|
+
const sessionData = await this._storageManager.getSessionData(userId);
|
|
1500
|
+
return {
|
|
1501
|
+
scopes: sessionData?.scope?.split(" "),
|
|
1502
|
+
sessionState: sessionData?.session_state ?? ""
|
|
1503
|
+
};
|
|
1669
1504
|
}
|
|
1670
1505
|
/**
|
|
1671
1506
|
* This method returns the crypto helper object.
|
|
@@ -1677,17 +1512,17 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1677
1512
|
* const cryptoHelper = await auth.IsomorphicCrypto();
|
|
1678
1513
|
* ```
|
|
1679
1514
|
*
|
|
1680
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
1515
|
+
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getCrypto}
|
|
1681
1516
|
*
|
|
1682
1517
|
* @preserve
|
|
1683
1518
|
*/
|
|
1684
|
-
async
|
|
1685
|
-
return this.
|
|
1519
|
+
async getCrypto() {
|
|
1520
|
+
return this._cryptoHelper;
|
|
1686
1521
|
}
|
|
1687
1522
|
/**
|
|
1688
1523
|
* This method revokes the access token.
|
|
1689
1524
|
*
|
|
1690
|
-
* @param
|
|
1525
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1691
1526
|
* scenarios where each user should be uniquely identified.
|
|
1692
1527
|
*
|
|
1693
1528
|
* **This method also clears the authentication data.**
|
|
@@ -1707,14 +1542,56 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1707
1542
|
*
|
|
1708
1543
|
* @preserve
|
|
1709
1544
|
*/
|
|
1710
|
-
revokeAccessToken(
|
|
1711
|
-
|
|
1545
|
+
async revokeAccessToken(userId) {
|
|
1546
|
+
const revokeTokenEndpoint = (await this._oidcProviderMetaData()).revocation_endpoint;
|
|
1547
|
+
const configData = await this._config();
|
|
1548
|
+
if (!revokeTokenEndpoint || revokeTokenEndpoint.trim().length === 0) {
|
|
1549
|
+
throw new AsgardeoAuthException(
|
|
1550
|
+
"JS-AUTH_CORE-RAT3-NF01",
|
|
1551
|
+
"No revoke access token endpoint found.",
|
|
1552
|
+
"No revoke access token endpoint was found in the OIDC provider meta data returned by the well-known endpoint or the revoke access token endpoint passed to the SDK is empty."
|
|
1553
|
+
);
|
|
1554
|
+
}
|
|
1555
|
+
const body = [];
|
|
1556
|
+
body.push(`client_id=${configData.clientId}`);
|
|
1557
|
+
body.push(`token=${(await this._storageManager.getSessionData(userId)).access_token}`);
|
|
1558
|
+
body.push("token_type_hint=access_token");
|
|
1559
|
+
if (configData.clientSecret && configData.clientSecret.trim().length > 0) {
|
|
1560
|
+
body.push(`client_secret=${configData.clientSecret}`);
|
|
1561
|
+
}
|
|
1562
|
+
let response;
|
|
1563
|
+
try {
|
|
1564
|
+
response = await fetch(revokeTokenEndpoint, {
|
|
1565
|
+
body: body.join("&"),
|
|
1566
|
+
credentials: configData.sendCookiesInRequests ? "include" : "same-origin",
|
|
1567
|
+
headers: {
|
|
1568
|
+
Accept: "application/json",
|
|
1569
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
1570
|
+
},
|
|
1571
|
+
method: "POST"
|
|
1572
|
+
});
|
|
1573
|
+
} catch (error) {
|
|
1574
|
+
throw new AsgardeoAuthException(
|
|
1575
|
+
"JS-AUTH_CORE-RAT3-NE02",
|
|
1576
|
+
"The request to revoke access token failed.",
|
|
1577
|
+
error ?? "The request sent to revoke the access token failed."
|
|
1578
|
+
);
|
|
1579
|
+
}
|
|
1580
|
+
if (response.status !== 200 || !response.ok) {
|
|
1581
|
+
throw new AsgardeoAuthException(
|
|
1582
|
+
"JS-AUTH_CORE-RAT3-HE03",
|
|
1583
|
+
`Invalid response status received for revoke access token request (${response.statusText}).`,
|
|
1584
|
+
await response.json()
|
|
1585
|
+
);
|
|
1586
|
+
}
|
|
1587
|
+
this._authenticationHelper.clearSession(userId);
|
|
1588
|
+
return Promise.resolve(response);
|
|
1712
1589
|
}
|
|
1713
1590
|
/**
|
|
1714
1591
|
* This method refreshes the access token and returns a Promise that resolves with the new access
|
|
1715
1592
|
* token and other relevant data.
|
|
1716
1593
|
*
|
|
1717
|
-
* @param
|
|
1594
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1718
1595
|
* scenarios where each user should be uniquely identified.
|
|
1719
1596
|
*
|
|
1720
1597
|
* @returns - A Promise that resolves with the token response.
|
|
@@ -1732,13 +1609,62 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1732
1609
|
*
|
|
1733
1610
|
* @preserve
|
|
1734
1611
|
*/
|
|
1735
|
-
refreshAccessToken(
|
|
1736
|
-
|
|
1612
|
+
async refreshAccessToken(userId) {
|
|
1613
|
+
const tokenEndpoint = (await this._oidcProviderMetaData()).token_endpoint;
|
|
1614
|
+
const configData = await this._config();
|
|
1615
|
+
const sessionData = await this._storageManager.getSessionData(userId);
|
|
1616
|
+
if (!sessionData.refresh_token) {
|
|
1617
|
+
throw new AsgardeoAuthException(
|
|
1618
|
+
"JS-AUTH_CORE-RAT2-NF01",
|
|
1619
|
+
"No refresh token found.",
|
|
1620
|
+
"There was no refresh token found. Asgardeo doesn't return a refresh token if the refresh token grant is not enabled."
|
|
1621
|
+
);
|
|
1622
|
+
}
|
|
1623
|
+
if (!tokenEndpoint || tokenEndpoint.trim().length === 0) {
|
|
1624
|
+
throw new AsgardeoAuthException(
|
|
1625
|
+
"JS-AUTH_CORE-RAT2-NF02",
|
|
1626
|
+
"No refresh token endpoint found.",
|
|
1627
|
+
"No refresh token endpoint was in the OIDC provider meta data returned by the well-known endpoint or the refresh token endpoint passed to the SDK is empty."
|
|
1628
|
+
);
|
|
1629
|
+
}
|
|
1630
|
+
const body = [];
|
|
1631
|
+
body.push(`client_id=${configData.clientId}`);
|
|
1632
|
+
body.push(`refresh_token=${sessionData.refresh_token}`);
|
|
1633
|
+
body.push("grant_type=refresh_token");
|
|
1634
|
+
if (configData.clientSecret && configData.clientSecret.trim().length > 0) {
|
|
1635
|
+
body.push(`client_secret=${configData.clientSecret}`);
|
|
1636
|
+
}
|
|
1637
|
+
let tokenResponse;
|
|
1638
|
+
try {
|
|
1639
|
+
tokenResponse = await fetch(tokenEndpoint, {
|
|
1640
|
+
body: body.join("&"),
|
|
1641
|
+
credentials: configData.sendCookiesInRequests ? "include" : "same-origin",
|
|
1642
|
+
headers: {
|
|
1643
|
+
Accept: "application/json",
|
|
1644
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
1645
|
+
},
|
|
1646
|
+
method: "POST"
|
|
1647
|
+
});
|
|
1648
|
+
} catch (error) {
|
|
1649
|
+
throw new AsgardeoAuthException(
|
|
1650
|
+
"JS-AUTH_CORE-RAT2-NR03",
|
|
1651
|
+
"Refresh access token request failed.",
|
|
1652
|
+
error ?? "The request to refresh the access token failed."
|
|
1653
|
+
);
|
|
1654
|
+
}
|
|
1655
|
+
if (!tokenResponse.ok) {
|
|
1656
|
+
throw new AsgardeoAuthException(
|
|
1657
|
+
"JS-AUTH_CORE-RAT2-HE04",
|
|
1658
|
+
`Refreshing access token failed with ${tokenResponse.statusText}`,
|
|
1659
|
+
await tokenResponse.json()
|
|
1660
|
+
);
|
|
1661
|
+
}
|
|
1662
|
+
return this._authenticationHelper.handleTokenResponse(tokenResponse, userId);
|
|
1737
1663
|
}
|
|
1738
1664
|
/**
|
|
1739
1665
|
* This method returns the access token.
|
|
1740
1666
|
*
|
|
1741
|
-
* @param
|
|
1667
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1742
1668
|
* scenarios where each user should be uniquely identified.
|
|
1743
1669
|
*
|
|
1744
1670
|
* @returns - A Promise that resolves with the access token.
|
|
@@ -1752,15 +1678,15 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1752
1678
|
*
|
|
1753
1679
|
* @preserve
|
|
1754
1680
|
*/
|
|
1755
|
-
async getAccessToken(
|
|
1756
|
-
return this.
|
|
1681
|
+
async getAccessToken(userId) {
|
|
1682
|
+
return (await this._storageManager.getSessionData(userId))?.access_token;
|
|
1757
1683
|
}
|
|
1758
1684
|
/**
|
|
1759
1685
|
* This method sends a custom-grant request and returns a Promise that resolves with the response
|
|
1760
1686
|
* depending on the config passed.
|
|
1761
1687
|
*
|
|
1762
1688
|
* @param config - A config object containing the custom grant configurations.
|
|
1763
|
-
* @param
|
|
1689
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1764
1690
|
* scenarios where each user should be uniquely identified.
|
|
1765
1691
|
*
|
|
1766
1692
|
* @returns - A Promise that resolves with the response depending
|
|
@@ -1771,7 +1697,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1771
1697
|
* const config = {
|
|
1772
1698
|
* attachToken: false,
|
|
1773
1699
|
* data: {
|
|
1774
|
-
* client_id: "{{
|
|
1700
|
+
* client_id: "{{clientId}}",
|
|
1775
1701
|
* grant_type: "account_switch",
|
|
1776
1702
|
* scope: "{{scope}}",
|
|
1777
1703
|
* token: "{{token}}",
|
|
@@ -1782,44 +1708,115 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1782
1708
|
* signInRequired: true
|
|
1783
1709
|
* }
|
|
1784
1710
|
*
|
|
1785
|
-
* auth.
|
|
1711
|
+
* auth.exchangeToken(config).then((response)=>{
|
|
1786
1712
|
* // console.log(response);
|
|
1787
1713
|
* }).catch((error)=>{
|
|
1788
1714
|
* // console.error(error);
|
|
1789
1715
|
* });
|
|
1790
1716
|
* ```
|
|
1791
1717
|
*
|
|
1792
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
1718
|
+
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#exchangeToken}
|
|
1793
1719
|
*
|
|
1794
1720
|
* @preserve
|
|
1795
1721
|
*/
|
|
1796
|
-
|
|
1797
|
-
|
|
1722
|
+
async exchangeToken(config, userId) {
|
|
1723
|
+
const oidcProviderMetadata = await this._oidcProviderMetaData();
|
|
1724
|
+
const configData = await this._config();
|
|
1725
|
+
let tokenEndpoint;
|
|
1726
|
+
if (config.tokenEndpoint && config.tokenEndpoint.trim().length !== 0) {
|
|
1727
|
+
tokenEndpoint = config.tokenEndpoint;
|
|
1728
|
+
} else {
|
|
1729
|
+
tokenEndpoint = oidcProviderMetadata.token_endpoint;
|
|
1730
|
+
}
|
|
1731
|
+
if (!tokenEndpoint || tokenEndpoint.trim().length === 0) {
|
|
1732
|
+
throw new AsgardeoAuthException(
|
|
1733
|
+
"JS-AUTH_CORE-RCG-NF01",
|
|
1734
|
+
"Token endpoint not found.",
|
|
1735
|
+
"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."
|
|
1736
|
+
);
|
|
1737
|
+
}
|
|
1738
|
+
const data = await Promise.all(
|
|
1739
|
+
Object.entries(config.data).map(async ([key, value]) => {
|
|
1740
|
+
const newValue = await this._authenticationHelper.replaceCustomGrantTemplateTags(
|
|
1741
|
+
value,
|
|
1742
|
+
userId
|
|
1743
|
+
);
|
|
1744
|
+
return `${key}=${newValue}`;
|
|
1745
|
+
})
|
|
1746
|
+
);
|
|
1747
|
+
let requestHeaders = {
|
|
1748
|
+
Accept: "application/json",
|
|
1749
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
1750
|
+
};
|
|
1751
|
+
if (config.attachToken) {
|
|
1752
|
+
requestHeaders = {
|
|
1753
|
+
...requestHeaders,
|
|
1754
|
+
Authorization: `Bearer ${(await this._storageManager.getSessionData(userId)).access_token}`
|
|
1755
|
+
};
|
|
1756
|
+
}
|
|
1757
|
+
const requestConfig = {
|
|
1758
|
+
body: data.join("&"),
|
|
1759
|
+
credentials: configData.sendCookiesInRequests ? "include" : "same-origin",
|
|
1760
|
+
headers: new Headers(requestHeaders),
|
|
1761
|
+
method: "POST"
|
|
1762
|
+
};
|
|
1763
|
+
let response;
|
|
1764
|
+
try {
|
|
1765
|
+
response = await fetch(tokenEndpoint, requestConfig);
|
|
1766
|
+
} catch (error) {
|
|
1767
|
+
throw new AsgardeoAuthException(
|
|
1768
|
+
"JS-AUTH_CORE-RCG-NE02",
|
|
1769
|
+
"The custom grant request failed.",
|
|
1770
|
+
error ?? "The request sent to get the custom grant failed."
|
|
1771
|
+
);
|
|
1772
|
+
}
|
|
1773
|
+
if (response.status !== 200 || !response.ok) {
|
|
1774
|
+
throw new AsgardeoAuthException(
|
|
1775
|
+
"JS-AUTH_CORE-RCG-HE03",
|
|
1776
|
+
`Invalid response status received for the custom grant request. (${response.statusText})`,
|
|
1777
|
+
await response.json()
|
|
1778
|
+
);
|
|
1779
|
+
}
|
|
1780
|
+
if (config.returnsSession) {
|
|
1781
|
+
return this._authenticationHelper.handleTokenResponse(response, userId);
|
|
1782
|
+
} else {
|
|
1783
|
+
return Promise.resolve(await response.json());
|
|
1784
|
+
}
|
|
1798
1785
|
}
|
|
1799
1786
|
/**
|
|
1800
1787
|
* This method returns if the user is authenticated or not.
|
|
1801
1788
|
*
|
|
1802
|
-
* @param
|
|
1789
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1803
1790
|
* scenarios where each user should be uniquely identified.
|
|
1804
1791
|
*
|
|
1805
1792
|
* @returns - A Promise that resolves with `true` if the user is authenticated, `false` otherwise.
|
|
1806
1793
|
*
|
|
1807
1794
|
* @example
|
|
1808
1795
|
* ```
|
|
1809
|
-
* await auth.
|
|
1796
|
+
* await auth.isSignedIn();
|
|
1810
1797
|
* ```
|
|
1811
1798
|
*
|
|
1812
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
1799
|
+
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#isSignedIn}
|
|
1813
1800
|
*
|
|
1814
1801
|
* @preserve
|
|
1815
1802
|
*/
|
|
1816
|
-
async
|
|
1817
|
-
|
|
1803
|
+
async isSignedIn(userId) {
|
|
1804
|
+
const isAccessTokenAvailable = Boolean(await this.getAccessToken(userId));
|
|
1805
|
+
const createdAt = (await this._storageManager.getSessionData(userId))?.created_at;
|
|
1806
|
+
const expiresInString = (await this._storageManager.getSessionData(userId))?.expires_in;
|
|
1807
|
+
if (!expiresInString) {
|
|
1808
|
+
return false;
|
|
1809
|
+
}
|
|
1810
|
+
const expiresIn = parseInt(expiresInString) * 1e3;
|
|
1811
|
+
const currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
1812
|
+
const isAccessTokenValid = createdAt + expiresIn > currentTime;
|
|
1813
|
+
const isSignedIn = isAccessTokenAvailable && isAccessTokenValid;
|
|
1814
|
+
return isSignedIn;
|
|
1818
1815
|
}
|
|
1819
1816
|
/**
|
|
1820
1817
|
* This method returns the PKCE code generated during the generation of the authentication URL.
|
|
1821
1818
|
*
|
|
1822
|
-
* @param
|
|
1819
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1823
1820
|
* scenarios where each user should be uniquely identified.
|
|
1824
1821
|
* @param state - The state parameter that was passed in the authentication URL.
|
|
1825
1822
|
*
|
|
@@ -1834,15 +1831,18 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1834
1831
|
*
|
|
1835
1832
|
* @preserve
|
|
1836
1833
|
*/
|
|
1837
|
-
async getPKCECode(state,
|
|
1838
|
-
return this.
|
|
1834
|
+
async getPKCECode(state, userId) {
|
|
1835
|
+
return await this._storageManager.getTemporaryDataParameter(
|
|
1836
|
+
extractPkceStorageKeyFromState_default(state),
|
|
1837
|
+
userId
|
|
1838
|
+
);
|
|
1839
1839
|
}
|
|
1840
1840
|
/**
|
|
1841
1841
|
* This method sets the PKCE code to the data store.
|
|
1842
1842
|
*
|
|
1843
1843
|
* @param pkce - The PKCE code.
|
|
1844
1844
|
* @param state - The state parameter that was passed in the authentication URL.
|
|
1845
|
-
* @param
|
|
1845
|
+
* @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
|
|
1846
1846
|
* scenarios where each user should be uniquely identified.
|
|
1847
1847
|
*
|
|
1848
1848
|
* @example
|
|
@@ -1854,15 +1854,15 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1854
1854
|
*
|
|
1855
1855
|
* @preserve
|
|
1856
1856
|
*/
|
|
1857
|
-
async setPKCECode(pkce, state,
|
|
1858
|
-
await this.
|
|
1857
|
+
async setPKCECode(pkce, state, userId) {
|
|
1858
|
+
return await this._storageManager.setTemporaryDataParameter(extractPkceStorageKeyFromState_default(state), pkce, userId);
|
|
1859
1859
|
}
|
|
1860
1860
|
/**
|
|
1861
1861
|
* This method returns if the sign-out is successful or not.
|
|
1862
1862
|
*
|
|
1863
1863
|
* @param signOutRedirectUrl - The URL to which the user has been redirected to after signing-out.
|
|
1864
1864
|
*
|
|
1865
|
-
* **The server appends path parameters to the `
|
|
1865
|
+
* **The server appends path parameters to the `afterSignOutUrl` and these path parameters
|
|
1866
1866
|
* are required for this method to function.**
|
|
1867
1867
|
*
|
|
1868
1868
|
* @returns - `true` if successful, `false` otherwise.
|
|
@@ -1871,8 +1871,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1871
1871
|
*
|
|
1872
1872
|
* @preserve
|
|
1873
1873
|
*/
|
|
1874
|
-
static isSignOutSuccessful(
|
|
1875
|
-
const url = new URL(
|
|
1874
|
+
static isSignOutSuccessful(afterSignOutUrl) {
|
|
1875
|
+
const url = new URL(afterSignOutUrl);
|
|
1876
1876
|
const stateParam = url.searchParams.get(OIDCRequestConstants_default.Params.STATE);
|
|
1877
1877
|
const error = Boolean(url.searchParams.get("error"));
|
|
1878
1878
|
return stateParam ? stateParam === OIDCRequestConstants_default.Params.SIGN_OUT_SUCCESS && !error : false;
|
|
@@ -1882,7 +1882,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1882
1882
|
*
|
|
1883
1883
|
* @param signOutRedirectUrl - The URL to which the user has been redirected to after signing-out.
|
|
1884
1884
|
*
|
|
1885
|
-
* **The server appends path parameters to the `
|
|
1885
|
+
* **The server appends path parameters to the `afterSignOutUrl` and these path parameters
|
|
1886
1886
|
* are required for this method to function.**
|
|
1887
1887
|
*
|
|
1888
1888
|
* @returns - `true` if successful, `false` otherwise.
|
|
@@ -1891,8 +1891,8 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1891
1891
|
*
|
|
1892
1892
|
* @preserve
|
|
1893
1893
|
*/
|
|
1894
|
-
static didSignOutFail(
|
|
1895
|
-
const url = new URL(
|
|
1894
|
+
static didSignOutFail(afterSignOutUrl) {
|
|
1895
|
+
const url = new URL(afterSignOutUrl);
|
|
1896
1896
|
const stateParam = url.searchParams.get(OIDCRequestConstants_default.Params.STATE);
|
|
1897
1897
|
const error = Boolean(url.searchParams.get("error"));
|
|
1898
1898
|
return stateParam ? stateParam === OIDCRequestConstants_default.Params.SIGN_OUT_SUCCESS && error : false;
|
|
@@ -1905,61 +1905,31 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1905
1905
|
* @example
|
|
1906
1906
|
* ```
|
|
1907
1907
|
* const config = {
|
|
1908
|
-
*
|
|
1909
|
-
*
|
|
1908
|
+
* afterSignInUrl: "http://localhost:3000/sign-in",
|
|
1909
|
+
* clientId: "client ID",
|
|
1910
1910
|
* baseUrl: "https://localhost:9443"
|
|
1911
1911
|
* }
|
|
1912
1912
|
*
|
|
1913
|
-
* await auth.
|
|
1913
|
+
* await auth.reInitialize(config);
|
|
1914
1914
|
* ```
|
|
1915
|
-
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#
|
|
1915
|
+
* {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#reInitialize}
|
|
1916
1916
|
*
|
|
1917
1917
|
* @preserve
|
|
1918
1918
|
*/
|
|
1919
|
-
async
|
|
1920
|
-
await this.
|
|
1919
|
+
async reInitialize(config) {
|
|
1920
|
+
await this._storageManager.setConfigData(config);
|
|
1921
|
+
await this.loadOpenIDProviderConfiguration(true);
|
|
1921
1922
|
}
|
|
1922
|
-
static async
|
|
1923
|
-
await this.
|
|
1923
|
+
static async clearSession(userId) {
|
|
1924
|
+
await this._authenticationHelper.clearSession(userId);
|
|
1924
1925
|
}
|
|
1925
1926
|
};
|
|
1926
1927
|
__publicField(_AsgardeoAuthClient, "_instanceID");
|
|
1927
|
-
|
|
1928
|
+
// FIXME: Validate this.
|
|
1929
|
+
// Ref: https://github.com/asgardeo/asgardeo-auth-js-core/pull/205
|
|
1930
|
+
__publicField(_AsgardeoAuthClient, "_authenticationHelper");
|
|
1928
1931
|
var AsgardeoAuthClient = _AsgardeoAuthClient;
|
|
1929
1932
|
|
|
1930
|
-
// src/errors/AsgardeoError.ts
|
|
1931
|
-
var AsgardeoError = class _AsgardeoError extends Error {
|
|
1932
|
-
constructor(message, code, origin) {
|
|
1933
|
-
const _origin = _AsgardeoError.resolveOrigin(origin);
|
|
1934
|
-
const prefix = `\u{1F6E1}\uFE0F Asgardeo - ${_origin}:`;
|
|
1935
|
-
const regex = new RegExp(`\u{1F6E1}\uFE0F\\s*Asgardeo\\s*-\\s*${_origin}:`, "i");
|
|
1936
|
-
const sanitized = message.replace(regex, "");
|
|
1937
|
-
const _message = `${prefix} ${sanitized.trim()}
|
|
1938
|
-
|
|
1939
|
-
(code="${code}")
|
|
1940
|
-
`;
|
|
1941
|
-
super(_message);
|
|
1942
|
-
__publicField(this, "code");
|
|
1943
|
-
__publicField(this, "origin");
|
|
1944
|
-
this.name = new.target.name;
|
|
1945
|
-
this.code = code;
|
|
1946
|
-
this.origin = _origin;
|
|
1947
|
-
if (Error.captureStackTrace) {
|
|
1948
|
-
Error.captureStackTrace(this, new.target);
|
|
1949
|
-
}
|
|
1950
|
-
}
|
|
1951
|
-
static resolveOrigin(origin) {
|
|
1952
|
-
if (!origin) {
|
|
1953
|
-
return "@asgardeo/javascript";
|
|
1954
|
-
}
|
|
1955
|
-
return `@asgardeo/${origin}`;
|
|
1956
|
-
}
|
|
1957
|
-
toString() {
|
|
1958
|
-
return `[${this.name}]
|
|
1959
|
-
Message: ${this.message}`;
|
|
1960
|
-
}
|
|
1961
|
-
};
|
|
1962
|
-
|
|
1963
1933
|
// src/errors/AsgardeoAPIError.ts
|
|
1964
1934
|
var AsgardeoAPIError = class extends AsgardeoError {
|
|
1965
1935
|
/**
|
|
@@ -1993,7 +1963,95 @@ Message: ${this.message}`;
|
|
|
1993
1963
|
}
|
|
1994
1964
|
};
|
|
1995
1965
|
|
|
1996
|
-
// src/api/
|
|
1966
|
+
// src/api/initializeApplicationNativeAuthentication.ts
|
|
1967
|
+
var initializeApplicationNativeAuthentication = async ({
|
|
1968
|
+
url,
|
|
1969
|
+
baseUrl,
|
|
1970
|
+
payload,
|
|
1971
|
+
...requestConfig
|
|
1972
|
+
}) => {
|
|
1973
|
+
if (!payload) {
|
|
1974
|
+
throw new AsgardeoAPIError(
|
|
1975
|
+
"Authorization payload is required",
|
|
1976
|
+
"initializeApplicationNativeAuthentication-ValidationError-002",
|
|
1977
|
+
"javascript",
|
|
1978
|
+
400,
|
|
1979
|
+
"If an authorization payload is not provided, the request cannot be constructed correctly."
|
|
1980
|
+
);
|
|
1981
|
+
}
|
|
1982
|
+
const searchParams = new URLSearchParams();
|
|
1983
|
+
Object.entries(payload).forEach(([key, value]) => {
|
|
1984
|
+
if (value !== void 0 && value !== null) {
|
|
1985
|
+
searchParams.append(key, String(value));
|
|
1986
|
+
}
|
|
1987
|
+
});
|
|
1988
|
+
const { headers: customHeaders, ...otherConfig } = requestConfig;
|
|
1989
|
+
const response = await fetch(url ?? `${baseUrl}/oauth2/authorize`, {
|
|
1990
|
+
method: requestConfig.method || "POST",
|
|
1991
|
+
headers: {
|
|
1992
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
1993
|
+
Accept: "application/json",
|
|
1994
|
+
...customHeaders
|
|
1995
|
+
},
|
|
1996
|
+
body: searchParams.toString(),
|
|
1997
|
+
...otherConfig
|
|
1998
|
+
});
|
|
1999
|
+
if (!response.ok) {
|
|
2000
|
+
const errorText = await response.text();
|
|
2001
|
+
throw new AsgardeoAPIError(
|
|
2002
|
+
`Authorization request failed: ${errorText}`,
|
|
2003
|
+
"initializeApplicationNativeAuthentication-ResponseError-001",
|
|
2004
|
+
"javascript",
|
|
2005
|
+
response.status,
|
|
2006
|
+
response.statusText
|
|
2007
|
+
);
|
|
2008
|
+
}
|
|
2009
|
+
return await response.json();
|
|
2010
|
+
};
|
|
2011
|
+
var initializeApplicationNativeAuthentication_default = initializeApplicationNativeAuthentication;
|
|
2012
|
+
|
|
2013
|
+
// src/api/handleApplicationNativeAuthentication.ts
|
|
2014
|
+
var handleApplicationNativeAuthentication = async ({
|
|
2015
|
+
url,
|
|
2016
|
+
baseUrl,
|
|
2017
|
+
payload,
|
|
2018
|
+
...requestConfig
|
|
2019
|
+
}) => {
|
|
2020
|
+
if (!payload) {
|
|
2021
|
+
throw new AsgardeoAPIError(
|
|
2022
|
+
"Authorization payload is required",
|
|
2023
|
+
"handleApplicationNativeAuthentication-ValidationError-002",
|
|
2024
|
+
"javascript",
|
|
2025
|
+
400,
|
|
2026
|
+
"If an authorization payload is not provided, the request cannot be constructed correctly."
|
|
2027
|
+
);
|
|
2028
|
+
}
|
|
2029
|
+
const { headers: customHeaders, ...otherConfig } = requestConfig;
|
|
2030
|
+
const response = await fetch(url ?? `${baseUrl}/oauth2/authn`, {
|
|
2031
|
+
method: requestConfig.method || "POST",
|
|
2032
|
+
headers: {
|
|
2033
|
+
"Content-Type": "application/json",
|
|
2034
|
+
Accept: "application/json",
|
|
2035
|
+
...customHeaders
|
|
2036
|
+
},
|
|
2037
|
+
body: JSON.stringify(payload),
|
|
2038
|
+
...otherConfig
|
|
2039
|
+
});
|
|
2040
|
+
if (!response.ok) {
|
|
2041
|
+
const errorText = await response.text();
|
|
2042
|
+
throw new AsgardeoAPIError(
|
|
2043
|
+
`Authorization request failed: ${errorText}`,
|
|
2044
|
+
"initializeApplicationNativeAuthentication-ResponseError-001",
|
|
2045
|
+
"javascript",
|
|
2046
|
+
response.status,
|
|
2047
|
+
response.statusText
|
|
2048
|
+
);
|
|
2049
|
+
}
|
|
2050
|
+
return await response.json();
|
|
2051
|
+
};
|
|
2052
|
+
var handleApplicationNativeAuthentication_default = handleApplicationNativeAuthentication;
|
|
2053
|
+
|
|
2054
|
+
// src/api/getUserInfo.ts
|
|
1997
2055
|
var getUserInfo = async ({ url, ...requestConfig }) => {
|
|
1998
2056
|
try {
|
|
1999
2057
|
new URL(url);
|
|
@@ -2028,37 +2086,60 @@ var getUserInfo = async ({ url, ...requestConfig }) => {
|
|
|
2028
2086
|
};
|
|
2029
2087
|
var getUserInfo_default = getUserInfo;
|
|
2030
2088
|
|
|
2031
|
-
// src/
|
|
2032
|
-
var
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
writable: true
|
|
2049
|
-
});
|
|
2050
|
-
}
|
|
2051
|
-
/**
|
|
2052
|
-
* Returns a string representation of the runtime error
|
|
2053
|
-
* @returns Formatted error string with name, code, details, and message
|
|
2054
|
-
*/
|
|
2055
|
-
toString() {
|
|
2056
|
-
const details = this.details ? `
|
|
2057
|
-
Details: ${JSON.stringify(this.details, null, 2)}` : "";
|
|
2058
|
-
return `[${this.name}] (code="${this.code}")${details}
|
|
2059
|
-
Message: ${this.message}`;
|
|
2089
|
+
// src/constants/ApplicationNativeAuthenticationConstants.ts
|
|
2090
|
+
var ApplicationNativeAuthenticationConstants = {
|
|
2091
|
+
SupportedAuthenticators: {
|
|
2092
|
+
IdentifierFirst: "SWRlbnRpZmllckV4ZWN1dG9yOkxPQ0FM",
|
|
2093
|
+
EmailOtp: "ZW1haWwtb3RwLWF1dGhlbnRpY2F0b3I6TE9DQUw",
|
|
2094
|
+
Totp: "dG90cDpMT0NBTA",
|
|
2095
|
+
UsernamePassword: "QmFzaWNBdXRoZW50aWNhdG9yOkxPQ0FM",
|
|
2096
|
+
PushNotification: "cHVzaC1ub3RpZmljYXRpb24tYXV0aGVudGljYXRvcjpMT0NBTA",
|
|
2097
|
+
Passkey: "RklET0F1dGhlbnRpY2F0b3I6TE9DQUw",
|
|
2098
|
+
SmsOtp: "c21zLW90cC1hdXRoZW50aWNhdG9yOkxPQ0FM",
|
|
2099
|
+
MagicLink: "TWFnaWNMaW5rQXV0aGVudGljYXRvcjpMT0NBTA",
|
|
2100
|
+
Google: "R29vZ2xlT0lEQ0F1dGhlbnRpY2F0b3I6R29vZ2xl",
|
|
2101
|
+
GitHub: "R2l0aHViQXV0aGVudGljYXRvcjpHaXRIdWI",
|
|
2102
|
+
Microsoft: "T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I6TWljcm9zb2Z0",
|
|
2103
|
+
Facebook: "RmFjZWJvb2tBdXRoZW50aWNhdG9yOkZhY2Vib29r",
|
|
2104
|
+
LinkedIn: "TGlua2VkSW5PSURDOkxpbmtlZElu",
|
|
2105
|
+
SignInWithEthereum: "T3BlbklEQ29ubmVjdEF1dGhlbnRpY2F0b3I6U2lnbiBJbiBXaXRoIEV0aGVyZXVt"
|
|
2060
2106
|
}
|
|
2061
2107
|
};
|
|
2108
|
+
var ApplicationNativeAuthenticationConstants_default = ApplicationNativeAuthenticationConstants;
|
|
2109
|
+
|
|
2110
|
+
// src/models/application-native-authentication.ts
|
|
2111
|
+
var ApplicationNativeAuthenticationFlowStatus = /* @__PURE__ */ ((ApplicationNativeAuthenticationFlowStatus2) => {
|
|
2112
|
+
ApplicationNativeAuthenticationFlowStatus2["SuccessCompleted"] = "SUCCESS_COMPLETED";
|
|
2113
|
+
ApplicationNativeAuthenticationFlowStatus2["FailCompleted"] = "FAIL_COMPLETED";
|
|
2114
|
+
ApplicationNativeAuthenticationFlowStatus2["FailIncomplete"] = "FAIL_INCOMPLETE";
|
|
2115
|
+
ApplicationNativeAuthenticationFlowStatus2["Incomplete"] = "INCOMPLETE";
|
|
2116
|
+
return ApplicationNativeAuthenticationFlowStatus2;
|
|
2117
|
+
})(ApplicationNativeAuthenticationFlowStatus || {});
|
|
2118
|
+
var ApplicationNativeAuthenticationFlowType = /* @__PURE__ */ ((ApplicationNativeAuthenticationFlowType2) => {
|
|
2119
|
+
ApplicationNativeAuthenticationFlowType2["Authentication"] = "AUTHENTICATION";
|
|
2120
|
+
return ApplicationNativeAuthenticationFlowType2;
|
|
2121
|
+
})(ApplicationNativeAuthenticationFlowType || {});
|
|
2122
|
+
var ApplicationNativeAuthenticationStepType = /* @__PURE__ */ ((ApplicationNativeAuthenticationStepType2) => {
|
|
2123
|
+
ApplicationNativeAuthenticationStepType2["AuthenticatorPrompt"] = "AUTHENTICATOR_PROMPT";
|
|
2124
|
+
ApplicationNativeAuthenticationStepType2["MultOptionsPrompt"] = "MULTI_OPTIONS_PROMPT";
|
|
2125
|
+
return ApplicationNativeAuthenticationStepType2;
|
|
2126
|
+
})(ApplicationNativeAuthenticationStepType || {});
|
|
2127
|
+
var ApplicationNativeAuthenticationAuthenticatorParamType = /* @__PURE__ */ ((ApplicationNativeAuthenticationAuthenticatorParamType2) => {
|
|
2128
|
+
ApplicationNativeAuthenticationAuthenticatorParamType2["String"] = "STRING";
|
|
2129
|
+
ApplicationNativeAuthenticationAuthenticatorParamType2["Integer"] = "INTEGER";
|
|
2130
|
+
ApplicationNativeAuthenticationAuthenticatorParamType2["MultiValued"] = "MULTI_VALUED";
|
|
2131
|
+
return ApplicationNativeAuthenticationAuthenticatorParamType2;
|
|
2132
|
+
})(ApplicationNativeAuthenticationAuthenticatorParamType || {});
|
|
2133
|
+
var ApplicationNativeAuthenticationAuthenticatorKnownIdPType = /* @__PURE__ */ ((ApplicationNativeAuthenticationAuthenticatorKnownIdPType2) => {
|
|
2134
|
+
ApplicationNativeAuthenticationAuthenticatorKnownIdPType2["Local"] = "LOCAL";
|
|
2135
|
+
return ApplicationNativeAuthenticationAuthenticatorKnownIdPType2;
|
|
2136
|
+
})(ApplicationNativeAuthenticationAuthenticatorKnownIdPType || {});
|
|
2137
|
+
var ApplicationNativeAuthenticationAuthenticatorPromptType = /* @__PURE__ */ ((ApplicationNativeAuthenticationAuthenticatorPromptType2) => {
|
|
2138
|
+
ApplicationNativeAuthenticationAuthenticatorPromptType2["UserPrompt"] = "USER_PROMPT";
|
|
2139
|
+
ApplicationNativeAuthenticationAuthenticatorPromptType2["InternalPrompt"] = "INTERNAL_PROMPT";
|
|
2140
|
+
ApplicationNativeAuthenticationAuthenticatorPromptType2["RedirectionPrompt"] = "REDIRECTION_PROMPT";
|
|
2141
|
+
return ApplicationNativeAuthenticationAuthenticatorPromptType2;
|
|
2142
|
+
})(ApplicationNativeAuthenticationAuthenticatorPromptType || {});
|
|
2062
2143
|
|
|
2063
2144
|
// src/models/scim2-schema.ts
|
|
2064
2145
|
var WellKnownSchemaIds = /* @__PURE__ */ ((WellKnownSchemaIds2) => {
|
|
@@ -2070,6 +2151,22 @@ var WellKnownSchemaIds = /* @__PURE__ */ ((WellKnownSchemaIds2) => {
|
|
|
2070
2151
|
return WellKnownSchemaIds2;
|
|
2071
2152
|
})(WellKnownSchemaIds || {});
|
|
2072
2153
|
|
|
2154
|
+
// src/models/field.ts
|
|
2155
|
+
var FieldType = /* @__PURE__ */ ((FieldType2) => {
|
|
2156
|
+
FieldType2["Text"] = "TEXT";
|
|
2157
|
+
FieldType2["Password"] = "PASSWORD";
|
|
2158
|
+
FieldType2["Email"] = "EMAIL";
|
|
2159
|
+
FieldType2["Number"] = "NUMBER";
|
|
2160
|
+
FieldType2["Select"] = "SELECT";
|
|
2161
|
+
FieldType2["Checkbox"] = "CHECKBOX";
|
|
2162
|
+
FieldType2["Radio"] = "RADIO";
|
|
2163
|
+
FieldType2["Otp"] = "OTP";
|
|
2164
|
+
FieldType2["Date"] = "DATE";
|
|
2165
|
+
FieldType2["Time"] = "TIME";
|
|
2166
|
+
FieldType2["Textarea"] = "TEXTAREA";
|
|
2167
|
+
return FieldType2;
|
|
2168
|
+
})(FieldType || {});
|
|
2169
|
+
|
|
2073
2170
|
// src/AsgardeoJavaScriptClient.ts
|
|
2074
2171
|
var AsgardeoJavaScriptClient = class {
|
|
2075
2172
|
};
|
|
@@ -2087,7 +2184,7 @@ var lightTheme = {
|
|
|
2087
2184
|
contrastText: "#ffffff"
|
|
2088
2185
|
},
|
|
2089
2186
|
background: {
|
|
2090
|
-
surface: "#
|
|
2187
|
+
surface: "#ffffff",
|
|
2091
2188
|
disabled: "#f0f0f0",
|
|
2092
2189
|
body: {
|
|
2093
2190
|
main: "#1a1a1a"
|
|
@@ -2097,7 +2194,6 @@ var lightTheme = {
|
|
|
2097
2194
|
main: "#d32f2f",
|
|
2098
2195
|
contrastText: "#ffffff"
|
|
2099
2196
|
},
|
|
2100
|
-
surface: "#f5f5f5",
|
|
2101
2197
|
text: {
|
|
2102
2198
|
primary: "#1a1a1a",
|
|
2103
2199
|
secondary: "#666666"
|
|
@@ -2134,7 +2230,6 @@ var darkTheme = {
|
|
|
2134
2230
|
main: "#d32f2f",
|
|
2135
2231
|
contrastText: "#ffffff"
|
|
2136
2232
|
},
|
|
2137
|
-
surface: "#2d2d2d",
|
|
2138
2233
|
text: {
|
|
2139
2234
|
primary: "#ffffff",
|
|
2140
2235
|
secondary: "#b3b3b3"
|
|
@@ -2161,7 +2256,6 @@ var toCssVariables = (theme) => {
|
|
|
2161
2256
|
cssVars["--asgardeo-color-background-body-main"] = theme.colors.background.body.main;
|
|
2162
2257
|
cssVars["--asgardeo-color-error-main"] = theme.colors.error.main;
|
|
2163
2258
|
cssVars["--asgardeo-color-error-contrastText"] = theme.colors.error.contrastText;
|
|
2164
|
-
cssVars["--asgardeo-color-surface"] = theme.colors.surface;
|
|
2165
2259
|
cssVars["--asgardeo-color-text-primary"] = theme.colors.text.primary;
|
|
2166
2260
|
cssVars["--asgardeo-color-text-secondary"] = theme.colors.text.secondary;
|
|
2167
2261
|
cssVars["--asgardeo-color-border"] = theme.colors.border;
|
|
@@ -2200,28 +2294,327 @@ var createTheme = (config = {}, isDark = false) => {
|
|
|
2200
2294
|
};
|
|
2201
2295
|
var createTheme_default = createTheme;
|
|
2202
2296
|
|
|
2297
|
+
// src/utils/deepMerge.ts
|
|
2298
|
+
var isPlainObject = (value) => {
|
|
2299
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof RegExp) && Object.prototype.toString.call(value) === "[object Object]";
|
|
2300
|
+
};
|
|
2301
|
+
var deepMerge = (target, ...sources) => {
|
|
2302
|
+
if (!target || typeof target !== "object") {
|
|
2303
|
+
throw new Error("Target must be an object");
|
|
2304
|
+
}
|
|
2305
|
+
const result = { ...target };
|
|
2306
|
+
sources.forEach((source) => {
|
|
2307
|
+
if (!source || typeof source !== "object") {
|
|
2308
|
+
return;
|
|
2309
|
+
}
|
|
2310
|
+
Object.keys(source).forEach((key) => {
|
|
2311
|
+
const sourceValue = source[key];
|
|
2312
|
+
const targetValue = result[key];
|
|
2313
|
+
if (isPlainObject(sourceValue) && isPlainObject(targetValue)) {
|
|
2314
|
+
result[key] = deepMerge(targetValue, sourceValue);
|
|
2315
|
+
} else if (sourceValue !== void 0) {
|
|
2316
|
+
result[key] = sourceValue;
|
|
2317
|
+
}
|
|
2318
|
+
});
|
|
2319
|
+
});
|
|
2320
|
+
return result;
|
|
2321
|
+
};
|
|
2322
|
+
var deepMerge_default = deepMerge;
|
|
2323
|
+
|
|
2324
|
+
// src/utils/flattenUserSchema.ts
|
|
2325
|
+
var flattenUserSchema = (schemas) => {
|
|
2326
|
+
const flattenedAttributes = [];
|
|
2327
|
+
schemas.forEach((schema) => {
|
|
2328
|
+
if (schema.attributes && Array.isArray(schema.attributes)) {
|
|
2329
|
+
schema.attributes.forEach((attribute) => {
|
|
2330
|
+
if (attribute.subAttributes && Array.isArray(attribute.subAttributes)) {
|
|
2331
|
+
attribute.subAttributes.forEach((subAttribute) => {
|
|
2332
|
+
flattenedAttributes.push({
|
|
2333
|
+
...subAttribute,
|
|
2334
|
+
name: `${attribute.name}.${subAttribute.name}`,
|
|
2335
|
+
schemaId: schema.id
|
|
2336
|
+
});
|
|
2337
|
+
});
|
|
2338
|
+
} else {
|
|
2339
|
+
flattenedAttributes.push({
|
|
2340
|
+
...attribute,
|
|
2341
|
+
schemaId: schema.id
|
|
2342
|
+
});
|
|
2343
|
+
}
|
|
2344
|
+
});
|
|
2345
|
+
}
|
|
2346
|
+
});
|
|
2347
|
+
return flattenedAttributes;
|
|
2348
|
+
};
|
|
2349
|
+
var flattenUserSchema_default = flattenUserSchema;
|
|
2350
|
+
|
|
2351
|
+
// src/utils/get.ts
|
|
2352
|
+
var get = (object, path, defaultValue) => {
|
|
2353
|
+
if (!object || !path) return defaultValue;
|
|
2354
|
+
const pathArray = Array.isArray(path) ? path : path.split(".");
|
|
2355
|
+
const result = pathArray.reduce((current, key) => {
|
|
2356
|
+
return current?.[key];
|
|
2357
|
+
}, object);
|
|
2358
|
+
return result !== void 0 ? result : defaultValue;
|
|
2359
|
+
};
|
|
2360
|
+
var get_default = get;
|
|
2361
|
+
|
|
2362
|
+
// src/utils/set.ts
|
|
2363
|
+
var set = (object, path, value) => {
|
|
2364
|
+
if (!object || !path) return object;
|
|
2365
|
+
const pathArray = Array.isArray(path) ? path : path.split(".");
|
|
2366
|
+
const lastIndex = pathArray.length - 1;
|
|
2367
|
+
pathArray.reduce((current, key, index) => {
|
|
2368
|
+
if (index === lastIndex) {
|
|
2369
|
+
current[key] = value;
|
|
2370
|
+
} else {
|
|
2371
|
+
if (!(key in current) || typeof current[key] !== "object" || current[key] === null) {
|
|
2372
|
+
const nextKey = pathArray[index + 1];
|
|
2373
|
+
current[key] = /^\d+$/.test(nextKey) ? [] : {};
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
return current[key];
|
|
2377
|
+
}, object);
|
|
2378
|
+
return object;
|
|
2379
|
+
};
|
|
2380
|
+
var set_default = set;
|
|
2381
|
+
|
|
2382
|
+
// src/utils/generateUserProfile.ts
|
|
2383
|
+
var generateUserProfile = (meResponse, processedSchemas) => {
|
|
2384
|
+
const profile = {};
|
|
2385
|
+
processedSchemas.forEach((schema) => {
|
|
2386
|
+
const { name, type, multiValued } = schema;
|
|
2387
|
+
if (!name) return;
|
|
2388
|
+
let value = get_default(meResponse, name);
|
|
2389
|
+
if (value !== void 0) {
|
|
2390
|
+
if (multiValued && !Array.isArray(value)) {
|
|
2391
|
+
value = [value];
|
|
2392
|
+
}
|
|
2393
|
+
} else {
|
|
2394
|
+
if (multiValued) {
|
|
2395
|
+
value = void 0;
|
|
2396
|
+
} else if (type === "STRING") {
|
|
2397
|
+
value = "";
|
|
2398
|
+
} else {
|
|
2399
|
+
value = void 0;
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2402
|
+
set_default(profile, name, value);
|
|
2403
|
+
});
|
|
2404
|
+
return profile;
|
|
2405
|
+
};
|
|
2406
|
+
var generateUserProfile_default = generateUserProfile;
|
|
2407
|
+
|
|
2408
|
+
// src/utils/getLatestStateParam.ts
|
|
2409
|
+
var getLatestPkceStorageKey = (tempStore) => {
|
|
2410
|
+
const keys = [];
|
|
2411
|
+
Object.keys(tempStore).forEach((key) => {
|
|
2412
|
+
if (key.startsWith(PKCEConstants_default.Storage.StorageKeys.CODE_VERIFIER)) {
|
|
2413
|
+
keys.push(key);
|
|
2414
|
+
}
|
|
2415
|
+
});
|
|
2416
|
+
const lastKey = keys.sort().pop();
|
|
2417
|
+
return lastKey ?? null;
|
|
2418
|
+
};
|
|
2419
|
+
var getLatestStateParam = (tempStore, state) => {
|
|
2420
|
+
const latestPkceKey = getLatestPkceStorageKey(tempStore);
|
|
2421
|
+
if (!latestPkceKey) {
|
|
2422
|
+
return null;
|
|
2423
|
+
}
|
|
2424
|
+
return generateStateParamForRequestCorrelation_default(latestPkceKey, state);
|
|
2425
|
+
};
|
|
2426
|
+
var getLatestStateParam_default = getLatestStateParam;
|
|
2427
|
+
|
|
2428
|
+
// src/utils/generateFlattenedUserProfile.ts
|
|
2429
|
+
var generateFlattenedUserProfile = (meResponse, processedSchemas) => {
|
|
2430
|
+
const profile = {};
|
|
2431
|
+
const allSchemaNames = processedSchemas.map((schema) => schema.name).filter(Boolean);
|
|
2432
|
+
processedSchemas.forEach((schema) => {
|
|
2433
|
+
const { name, type, multiValued } = schema;
|
|
2434
|
+
if (!name) return;
|
|
2435
|
+
const hasChildProperties = allSchemaNames.some(
|
|
2436
|
+
(schemaName) => schemaName !== name && schemaName.startsWith(name + ".")
|
|
2437
|
+
);
|
|
2438
|
+
if (hasChildProperties) {
|
|
2439
|
+
return;
|
|
2440
|
+
}
|
|
2441
|
+
let value = get_default(meResponse, name);
|
|
2442
|
+
if (value !== void 0) {
|
|
2443
|
+
if (multiValued && !Array.isArray(value)) {
|
|
2444
|
+
value = [value];
|
|
2445
|
+
}
|
|
2446
|
+
} else {
|
|
2447
|
+
if (multiValued) {
|
|
2448
|
+
value = void 0;
|
|
2449
|
+
} else if (type === "STRING") {
|
|
2450
|
+
value = "";
|
|
2451
|
+
} else {
|
|
2452
|
+
value = void 0;
|
|
2453
|
+
}
|
|
2454
|
+
}
|
|
2455
|
+
profile[name] = value;
|
|
2456
|
+
});
|
|
2457
|
+
return profile;
|
|
2458
|
+
};
|
|
2459
|
+
var generateFlattenedUserProfile_default = generateFlattenedUserProfile;
|
|
2460
|
+
|
|
2461
|
+
// src/i18n/index.ts
|
|
2462
|
+
var i18n_exports = {};
|
|
2463
|
+
__export(i18n_exports, {
|
|
2464
|
+
en_US: () => en_US_default
|
|
2465
|
+
});
|
|
2466
|
+
|
|
2467
|
+
// src/i18n/en-US.ts
|
|
2468
|
+
var translations = {
|
|
2469
|
+
/* |---------------------------------------------------------------| */
|
|
2470
|
+
/* | Elements | */
|
|
2471
|
+
/* |---------------------------------------------------------------| */
|
|
2472
|
+
//* Buttons */
|
|
2473
|
+
"elements.buttons.signIn": "Sign In",
|
|
2474
|
+
"elements.buttons.signOut": "Sign Out",
|
|
2475
|
+
"elements.buttons.signUp": "Sign Up",
|
|
2476
|
+
"elements.buttons.facebook": "Continue with Facebook",
|
|
2477
|
+
"elements.buttons.google": "Continue with Google",
|
|
2478
|
+
"elements.buttons.github": "Continue with GitHub",
|
|
2479
|
+
"elements.buttons.microsoft": "Continue with Microsoft",
|
|
2480
|
+
"elements.buttons.linkedin": "Continue with LinkedIn",
|
|
2481
|
+
"elements.buttons.ethereum": "Continue with Sign In Ethereum",
|
|
2482
|
+
"elements.buttons.multi.option": "Continue with {connection}",
|
|
2483
|
+
"elements.buttons.social": "Continue with {connection}",
|
|
2484
|
+
/* Fields */
|
|
2485
|
+
"elements.fields.placeholder": "Enter your {field}",
|
|
2486
|
+
/* |---------------------------------------------------------------| */
|
|
2487
|
+
/* | Widgets | */
|
|
2488
|
+
/* |---------------------------------------------------------------| */
|
|
2489
|
+
/* Base Sign In */
|
|
2490
|
+
"signin.title": "Sign In",
|
|
2491
|
+
/* Email OTP */
|
|
2492
|
+
"email.otp.title": "OTP Verification",
|
|
2493
|
+
"email.otp.subtitle": "Enter the code sent to your email address.",
|
|
2494
|
+
"email.otp.submit.button": "Continue",
|
|
2495
|
+
/* Identifier First */
|
|
2496
|
+
"identifier.first.title": "Sign In",
|
|
2497
|
+
"identifier.first.subtitle": "Enter your username or email address.",
|
|
2498
|
+
"identifier.first.submit.button": "Continue",
|
|
2499
|
+
/* SMS OTP */
|
|
2500
|
+
"sms.otp.title": "OTP Verification",
|
|
2501
|
+
"sms.otp.subtitle": "Enter the code sent to your phone number.",
|
|
2502
|
+
"sms.otp.submit.button": "Continue",
|
|
2503
|
+
/* TOTP */
|
|
2504
|
+
"totp.title": "Verify Your Identity",
|
|
2505
|
+
"totp.subtitle": "Enter the code from your authenticator app.",
|
|
2506
|
+
"totp.submit.button": "Continue",
|
|
2507
|
+
/* Username Password */
|
|
2508
|
+
"username.password.submit.button": "Continue",
|
|
2509
|
+
"username.password.title": "Sign In",
|
|
2510
|
+
"username.password.subtitle": "Enter your username and password to continue.",
|
|
2511
|
+
/* |---------------------------------------------------------------| */
|
|
2512
|
+
/* | Messages | */
|
|
2513
|
+
/* |---------------------------------------------------------------| */
|
|
2514
|
+
"messages.loading": "Loading...",
|
|
2515
|
+
/* |---------------------------------------------------------------| */
|
|
2516
|
+
/* | Errors | */
|
|
2517
|
+
/* |---------------------------------------------------------------| */
|
|
2518
|
+
"errors.title": "Error",
|
|
2519
|
+
"errors.sign.in.initialization": "An error occurred while initializing. Please try again later.",
|
|
2520
|
+
"errors.sign.in.flow.failure": "An error occurred during the sign-in flow. Please try again later.",
|
|
2521
|
+
"errors.sign.in.flow.completion.failure": "An error occurred while completing the sign-in flow. Please try again later.",
|
|
2522
|
+
"errors.sign.in.flow.passkeys.failure": "An error occurred while signing in with passkeys. Please try again later.",
|
|
2523
|
+
"errors.sign.in.flow.passkeys.completion.failure": "An error occurred while completing the passkeys sign-in flow. Please try again later."
|
|
2524
|
+
};
|
|
2525
|
+
var metadata = {
|
|
2526
|
+
localeCode: "en-US",
|
|
2527
|
+
countryCode: "US",
|
|
2528
|
+
languageCode: "en",
|
|
2529
|
+
displayName: "English (United States)",
|
|
2530
|
+
direction: "ltr"
|
|
2531
|
+
};
|
|
2532
|
+
var en_US = {
|
|
2533
|
+
metadata,
|
|
2534
|
+
translations
|
|
2535
|
+
};
|
|
2536
|
+
var en_US_default = en_US;
|
|
2537
|
+
|
|
2538
|
+
// src/utils/getI18nBundles.ts
|
|
2539
|
+
var getI18nBundles = () => {
|
|
2540
|
+
return i18n_exports;
|
|
2541
|
+
};
|
|
2542
|
+
var getI18nBundles_default = getI18nBundles;
|
|
2543
|
+
|
|
2203
2544
|
// src/utils/removeTrailingSlash.ts
|
|
2204
2545
|
var removeTrailingSlash = (path) => path.endsWith("/") ? path.slice(0, -1) : path;
|
|
2205
2546
|
var removeTrailingSlash_default = removeTrailingSlash;
|
|
2547
|
+
|
|
2548
|
+
// src/utils/resolveFieldType.ts
|
|
2549
|
+
var resolveFieldType = (field) => {
|
|
2550
|
+
if (field.type === "STRING" /* String */) {
|
|
2551
|
+
if (field.param === "OTPCode" /* Otp */) {
|
|
2552
|
+
return "OTP" /* Otp */;
|
|
2553
|
+
} else if (field?.confidential) {
|
|
2554
|
+
return "PASSWORD" /* Password */;
|
|
2555
|
+
}
|
|
2556
|
+
return "TEXT" /* Text */;
|
|
2557
|
+
}
|
|
2558
|
+
throw new AsgardeoRuntimeError(
|
|
2559
|
+
"Field type is not supported: " + field.type,
|
|
2560
|
+
"resolveFieldType-Invalid-001",
|
|
2561
|
+
"javascript",
|
|
2562
|
+
"The provided field type is not supported. Please check the field configuration."
|
|
2563
|
+
);
|
|
2564
|
+
};
|
|
2565
|
+
var resolveFieldType_default = resolveFieldType;
|
|
2566
|
+
|
|
2567
|
+
// src/utils/resolveFieldName.ts
|
|
2568
|
+
var resolveFieldName = (field) => {
|
|
2569
|
+
if (field.param) {
|
|
2570
|
+
return field.param;
|
|
2571
|
+
}
|
|
2572
|
+
throw new AsgardeoRuntimeError(
|
|
2573
|
+
"Field name is not supported: ",
|
|
2574
|
+
"resolveFieldName-Invalid-001",
|
|
2575
|
+
"javascript",
|
|
2576
|
+
"The provided field name is not supported. Please check the field configuration."
|
|
2577
|
+
);
|
|
2578
|
+
};
|
|
2579
|
+
var resolveFieldName_default = resolveFieldName;
|
|
2206
2580
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2207
2581
|
0 && (module.exports = {
|
|
2208
|
-
|
|
2582
|
+
ApplicationNativeAuthenticationAuthenticatorKnownIdPType,
|
|
2583
|
+
ApplicationNativeAuthenticationAuthenticatorParamType,
|
|
2584
|
+
ApplicationNativeAuthenticationAuthenticatorPromptType,
|
|
2585
|
+
ApplicationNativeAuthenticationConstants,
|
|
2586
|
+
ApplicationNativeAuthenticationFlowStatus,
|
|
2587
|
+
ApplicationNativeAuthenticationFlowType,
|
|
2588
|
+
ApplicationNativeAuthenticationStepType,
|
|
2209
2589
|
AsgardeoAPIError,
|
|
2210
2590
|
AsgardeoAuthClient,
|
|
2211
2591
|
AsgardeoAuthException,
|
|
2212
2592
|
AsgardeoError,
|
|
2213
2593
|
AsgardeoJavaScriptClient,
|
|
2214
2594
|
AsgardeoRuntimeError,
|
|
2215
|
-
|
|
2595
|
+
FieldType,
|
|
2216
2596
|
IsomorphicCrypto,
|
|
2217
2597
|
OIDCRequestConstants,
|
|
2218
|
-
|
|
2598
|
+
StorageManager,
|
|
2219
2599
|
TokenConstants,
|
|
2220
2600
|
WellKnownSchemaIds,
|
|
2221
2601
|
createTheme,
|
|
2602
|
+
deepMerge,
|
|
2222
2603
|
extractPkceStorageKeyFromState,
|
|
2223
2604
|
extractUserClaimsFromIdToken,
|
|
2605
|
+
flattenUserSchema,
|
|
2606
|
+
generateFlattenedUserProfile,
|
|
2607
|
+
generateUserProfile,
|
|
2608
|
+
get,
|
|
2609
|
+
getI18nBundles,
|
|
2610
|
+
getLatestStateParam,
|
|
2224
2611
|
getUserInfo,
|
|
2225
|
-
|
|
2612
|
+
handleApplicationNativeAuthentication,
|
|
2613
|
+
initializeApplicationNativeAuthentication,
|
|
2614
|
+
processOpenIDScopes,
|
|
2615
|
+
removeTrailingSlash,
|
|
2616
|
+
resolveFieldName,
|
|
2617
|
+
resolveFieldType,
|
|
2618
|
+
set
|
|
2226
2619
|
});
|
|
2227
2620
|
//# sourceMappingURL=index.js.map
|