@asgardeo/javascript 0.1.4 → 0.1.5

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/index.js CHANGED
@@ -823,8 +823,8 @@ var AuthenticationHelper = class {
823
823
  (await this._config()).clientId,
824
824
  issuer ?? "",
825
825
  this._cryptoHelper.decodeIdToken(idToken).sub,
826
- (await this._config()).clockTolerance,
827
- (await this._config()).validateIDTokenIssuer ?? true
826
+ (await this._config()).tokenValidation?.idToken?.clockTolerance,
827
+ (await this._config()).tokenValidation?.idToken?.validateIssuer ?? true
828
828
  );
829
829
  }
830
830
  getAuthenticatedUserInfo(idToken) {
@@ -866,7 +866,7 @@ var AuthenticationHelper = class {
866
866
  }
867
867
  const parsedResponse = await response.json();
868
868
  parsedResponse.created_at = (/* @__PURE__ */ new Date()).getTime();
869
- const shouldValidateIdToken = (await this._config()).validateIDToken;
869
+ const shouldValidateIdToken = (await this._config()).tokenValidation?.idToken?.validate;
870
870
  if (shouldValidateIdToken) {
871
871
  return this.validateIdToken(parsedResponse.id_token).then(async () => {
872
872
  await this._storageManager.setSessionData(parsedResponse, userId);
@@ -965,12 +965,16 @@ var getAuthorizeRequestUrlParams_default = getAuthorizeRequestUrlParams;
965
965
 
966
966
  // src/__legacy__/client.ts
967
967
  var DefaultConfig = {
968
- clockTolerance: 300,
968
+ tokenValidation: {
969
+ idToken: {
970
+ validate: true,
971
+ validateIssuer: true,
972
+ clockTolerance: 300
973
+ }
974
+ },
969
975
  enablePKCE: true,
970
976
  responseMode: "query",
971
- sendCookiesInRequests: true,
972
- validateIDToken: true,
973
- validateIDTokenIssuer: true
977
+ sendCookiesInRequests: true
974
978
  };
975
979
  var _AsgardeoAuthClient = class _AsgardeoAuthClient {
976
980
  /**
@@ -3451,32 +3455,29 @@ var deriveOrganizationHandleFromBaseUrl = (baseUrl) => {
3451
3455
  "The provided base URL does not conform to valid URL syntax."
3452
3456
  );
3453
3457
  }
3454
- const hostname = parsedUrl.hostname.toLowerCase();
3455
- if (!hostname.endsWith(".asgardeo.io")) {
3456
- throw new AsgardeoRuntimeError(
3457
- "Organization handle is required since a custom domain is configured.",
3458
- "javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-001",
3459
- "javascript",
3460
- "The provided base URL uses a custom domain. Please provide the organizationHandle explicitly in the configuration."
3461
- );
3462
- }
3463
- const pathSegments = parsedUrl.pathname.split("/").filter((segment) => segment.length > 0);
3458
+ const pathSegments = parsedUrl.pathname?.split("/")?.filter((segment) => segment?.length > 0);
3464
3459
  if (pathSegments.length < 2 || pathSegments[0] !== "t") {
3465
- throw new AsgardeoRuntimeError(
3466
- "Organization handle is required since a custom domain is configured.",
3467
- "javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-002",
3468
- "javascript",
3469
- "The provided base URL does not follow the expected Asgardeo URL pattern (/t/{orgHandle}). Please provide the organizationHandle explicitly in the configuration."
3460
+ console.warn(
3461
+ new AsgardeoRuntimeError(
3462
+ "Organization handle is required since a custom domain is configured.",
3463
+ "javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-002",
3464
+ "javascript",
3465
+ "The provided base URL does not follow the expected URL pattern (/t/{orgHandle}). Please provide the organizationHandle explicitly in the configuration."
3466
+ ).toString()
3470
3467
  );
3468
+ return "";
3471
3469
  }
3472
3470
  const organizationHandle = pathSegments[1];
3473
3471
  if (!organizationHandle || organizationHandle.trim().length === 0) {
3474
- throw new AsgardeoRuntimeError(
3475
- "Organization handle is required since a custom domain is configured.",
3476
- "javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-003",
3477
- "javascript",
3478
- "The organization handle could not be extracted from the base URL. Please provide the organizationHandle explicitly in the configuration."
3472
+ console.warn(
3473
+ new AsgardeoRuntimeError(
3474
+ "Organization handle is required since a custom domain is configured.",
3475
+ "javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-003",
3476
+ "javascript",
3477
+ "The organization handle could not be extracted from the base URL. Please provide the organizationHandle explicitly in the configuration."
3478
+ ).toString()
3479
3479
  );
3480
+ return "";
3480
3481
  }
3481
3482
  return organizationHandle;
3482
3483
  };