@asgardeo/javascript 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AsgardeoJavaScriptClient.d.ts +2 -0
- package/dist/IsomorphicCrypto.d.ts +1 -11
- package/dist/__legacy__/client.d.ts +12 -0
- package/dist/cjs/index.js +32 -24
- package/dist/cjs/index.js.map +4 -4
- package/dist/index.js +32 -24
- package/dist/index.js.map +4 -4
- package/dist/models/client.d.ts +12 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -485,22 +485,13 @@ var IsomorphicCrypto = class {
|
|
|
485
485
|
return Promise.reject(error2);
|
|
486
486
|
});
|
|
487
487
|
}
|
|
488
|
-
|
|
489
|
-
* This function decodes the payload of an id token and returns it.
|
|
490
|
-
*
|
|
491
|
-
* @param idToken - The id token to be decoded.
|
|
492
|
-
*
|
|
493
|
-
* @returns - The decoded payload of the id token.
|
|
494
|
-
*
|
|
495
|
-
* @throws
|
|
496
|
-
*/
|
|
497
|
-
decodeIdToken(idToken) {
|
|
488
|
+
decodeJwtToken(token) {
|
|
498
489
|
try {
|
|
499
|
-
const utf8String = this._cryptoUtils.base64URLDecode(
|
|
490
|
+
const utf8String = this._cryptoUtils.base64URLDecode(token?.split(".")[1]);
|
|
500
491
|
const payload = JSON.parse(utf8String);
|
|
501
492
|
return payload;
|
|
502
493
|
} catch (error2) {
|
|
503
|
-
throw new AsgardeoAuthException("JS-CRYPTO_UTIL-DIT-
|
|
494
|
+
throw new AsgardeoAuthException("JS-CRYPTO_UTIL-DIT-IV02", "Decoding token failed.", error2);
|
|
504
495
|
}
|
|
505
496
|
}
|
|
506
497
|
};
|
|
@@ -576,6 +567,15 @@ var TokenExchangeConstants = {
|
|
|
576
567
|
};
|
|
577
568
|
var TokenExchangeConstants_default = TokenExchangeConstants;
|
|
578
569
|
|
|
570
|
+
// src/models/platforms.ts
|
|
571
|
+
var Platform = /* @__PURE__ */ ((Platform2) => {
|
|
572
|
+
Platform2["Asgardeo"] = "ASGARDEO";
|
|
573
|
+
Platform2["IdentityServer"] = "IDENTITY_SERVER";
|
|
574
|
+
Platform2["AsgardeoV2"] = "AsgardeoV2";
|
|
575
|
+
Platform2["Unknown"] = "UNKNOWN";
|
|
576
|
+
return Platform2;
|
|
577
|
+
})(Platform || {});
|
|
578
|
+
|
|
579
579
|
// src/utils/extractUserClaimsFromIdToken.ts
|
|
580
580
|
var extractUserClaimsFromIdToken = (payload) => {
|
|
581
581
|
const filteredPayload = { ...payload };
|
|
@@ -771,6 +771,9 @@ var AuthenticationHelper = class {
|
|
|
771
771
|
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.TOKEN]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.TOKEN}`,
|
|
772
772
|
[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.USERINFO]: `${baseUrl}${OIDCDiscoveryConstants_default.Endpoints.USERINFO}`
|
|
773
773
|
};
|
|
774
|
+
if (configData.platform === "AsgardeoV2" /* AsgardeoV2 */) {
|
|
775
|
+
defaultEndpoints[OIDCDiscoveryConstants_default.Storage.StorageKeys.Endpoints.ISSUER] = `${baseUrl}`;
|
|
776
|
+
}
|
|
774
777
|
return { ...defaultEndpoints, ...oidcProviderMetaData };
|
|
775
778
|
}
|
|
776
779
|
async validateIdToken(idToken) {
|
|
@@ -810,13 +813,13 @@ var AuthenticationHelper = class {
|
|
|
810
813
|
jwk,
|
|
811
814
|
(await this._config()).clientId,
|
|
812
815
|
issuer ?? "",
|
|
813
|
-
this._cryptoHelper.
|
|
816
|
+
this._cryptoHelper.decodeJwtToken(idToken).sub,
|
|
814
817
|
(await this._config()).tokenValidation?.idToken?.clockTolerance,
|
|
815
818
|
(await this._config()).tokenValidation?.idToken?.validateIssuer ?? true
|
|
816
819
|
);
|
|
817
820
|
}
|
|
818
821
|
getAuthenticatedUserInfo(idToken) {
|
|
819
|
-
const payload = this._cryptoHelper.
|
|
822
|
+
const payload = this._cryptoHelper.decodeJwtToken(idToken);
|
|
820
823
|
const username = payload?.["username"] ?? "";
|
|
821
824
|
const givenName = payload?.["given_name"] ?? "";
|
|
822
825
|
const familyName = payload?.["family_name"] ?? "";
|
|
@@ -1382,6 +1385,20 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1382
1385
|
userinfoEndpoint: oidcProviderMetaData.userinfo_endpoint ?? ""
|
|
1383
1386
|
};
|
|
1384
1387
|
}
|
|
1388
|
+
/**
|
|
1389
|
+
* This method decodes a given JWT token and returns the payload.
|
|
1390
|
+
*
|
|
1391
|
+
* @param token - The token to be decoded.
|
|
1392
|
+
* @returns - A Promise that resolves with the decoded token payload.
|
|
1393
|
+
*
|
|
1394
|
+
* @example
|
|
1395
|
+
* ```
|
|
1396
|
+
* const decodedToken = await auth.decodeJwtToken(token);
|
|
1397
|
+
* ```
|
|
1398
|
+
*/
|
|
1399
|
+
async decodeJwtToken(token) {
|
|
1400
|
+
return this._cryptoHelper.decodeJwtToken(token);
|
|
1401
|
+
}
|
|
1385
1402
|
/**
|
|
1386
1403
|
* This method decodes the payload of the ID token and returns it.
|
|
1387
1404
|
*
|
|
@@ -1401,7 +1418,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1401
1418
|
*/
|
|
1402
1419
|
async getDecodedIdToken(userId, idToken) {
|
|
1403
1420
|
const _idToken = (await this._storageManager.getSessionData(userId)).id_token;
|
|
1404
|
-
const payload = this._cryptoHelper.
|
|
1421
|
+
const payload = this._cryptoHelper.decodeJwtToken(_idToken ?? idToken);
|
|
1405
1422
|
return payload;
|
|
1406
1423
|
}
|
|
1407
1424
|
/**
|
|
@@ -3143,15 +3160,6 @@ var VendorConstants = {
|
|
|
3143
3160
|
};
|
|
3144
3161
|
var VendorConstants_default = VendorConstants;
|
|
3145
3162
|
|
|
3146
|
-
// src/models/platforms.ts
|
|
3147
|
-
var Platform = /* @__PURE__ */ ((Platform2) => {
|
|
3148
|
-
Platform2["Asgardeo"] = "ASGARDEO";
|
|
3149
|
-
Platform2["IdentityServer"] = "IDENTITY_SERVER";
|
|
3150
|
-
Platform2["AsgardeoV2"] = "AsgardeoV2";
|
|
3151
|
-
Platform2["Unknown"] = "UNKNOWN";
|
|
3152
|
-
return Platform2;
|
|
3153
|
-
})(Platform || {});
|
|
3154
|
-
|
|
3155
3163
|
// src/models/embedded-signin-flow.ts
|
|
3156
3164
|
var EmbeddedSignInFlowStatus2 = /* @__PURE__ */ ((EmbeddedSignInFlowStatus3) => {
|
|
3157
3165
|
EmbeddedSignInFlowStatus3["FailCompleted"] = "FAIL_COMPLETED";
|