@asgardeo/javascript 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +20 -15
- package/dist/cjs/index.js.map +2 -2
- package/dist/index.js +20 -15
- package/dist/index.js.map +2 -2
- package/dist/models/client.d.ts +12 -0
- package/dist/models/embedded-flow.d.ts +1 -0
- package/dist/models/v2/embedded-flow-v2.d.ts +5 -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
|
};
|
|
@@ -810,13 +801,13 @@ var AuthenticationHelper = class {
|
|
|
810
801
|
jwk,
|
|
811
802
|
(await this._config()).clientId,
|
|
812
803
|
issuer ?? "",
|
|
813
|
-
this._cryptoHelper.
|
|
804
|
+
this._cryptoHelper.decodeJwtToken(idToken).sub,
|
|
814
805
|
(await this._config()).tokenValidation?.idToken?.clockTolerance,
|
|
815
806
|
(await this._config()).tokenValidation?.idToken?.validateIssuer ?? true
|
|
816
807
|
);
|
|
817
808
|
}
|
|
818
809
|
getAuthenticatedUserInfo(idToken) {
|
|
819
|
-
const payload = this._cryptoHelper.
|
|
810
|
+
const payload = this._cryptoHelper.decodeJwtToken(idToken);
|
|
820
811
|
const username = payload?.["username"] ?? "";
|
|
821
812
|
const givenName = payload?.["given_name"] ?? "";
|
|
822
813
|
const familyName = payload?.["family_name"] ?? "";
|
|
@@ -1382,6 +1373,20 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1382
1373
|
userinfoEndpoint: oidcProviderMetaData.userinfo_endpoint ?? ""
|
|
1383
1374
|
};
|
|
1384
1375
|
}
|
|
1376
|
+
/**
|
|
1377
|
+
* This method decodes a given JWT token and returns the payload.
|
|
1378
|
+
*
|
|
1379
|
+
* @param token - The token to be decoded.
|
|
1380
|
+
* @returns - A Promise that resolves with the decoded token payload.
|
|
1381
|
+
*
|
|
1382
|
+
* @example
|
|
1383
|
+
* ```
|
|
1384
|
+
* const decodedToken = await auth.decodeJwtToken(token);
|
|
1385
|
+
* ```
|
|
1386
|
+
*/
|
|
1387
|
+
async decodeJwtToken(token) {
|
|
1388
|
+
return this._cryptoHelper.decodeJwtToken(token);
|
|
1389
|
+
}
|
|
1385
1390
|
/**
|
|
1386
1391
|
* This method decodes the payload of the ID token and returns it.
|
|
1387
1392
|
*
|
|
@@ -1401,7 +1406,7 @@ var _AsgardeoAuthClient = class _AsgardeoAuthClient {
|
|
|
1401
1406
|
*/
|
|
1402
1407
|
async getDecodedIdToken(userId, idToken) {
|
|
1403
1408
|
const _idToken = (await this._storageManager.getSessionData(userId)).id_token;
|
|
1404
|
-
const payload = this._cryptoHelper.
|
|
1409
|
+
const payload = this._cryptoHelper.decodeJwtToken(_idToken ?? idToken);
|
|
1405
1410
|
return payload;
|
|
1406
1411
|
}
|
|
1407
1412
|
/**
|