@asgardeo/javascript 0.1.3 → 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.
@@ -43,6 +43,7 @@ declare abstract class AsgardeoJavaScriptClient<T = Config> implements AsgardeoC
43
43
  abstract getConfiguration(): T;
44
44
  abstract signIn(options?: SignInOptions, sessionId?: string, onSignInSuccess?: (afterSignInUrl: string) => void): Promise<User>;
45
45
  abstract signIn(payload: EmbeddedSignInFlowHandleRequestPayload, request: Request, sessionId?: string, onSignInSuccess?: (afterSignInUrl: string) => void): Promise<User>;
46
+ abstract signInSilently(options?: SignInOptions): Promise<User | boolean>;
46
47
  abstract signOut(options?: SignOutOptions, afterSignOut?: (afterSignOutUrl: string) => void): Promise<string>;
47
48
  abstract signOut(options?: SignOutOptions, sessionId?: string, afterSignOut?: (afterSignOutUrl: string) => void): Promise<string>;
48
49
  abstract signUp(options?: SignUpOptions): Promise<void>;
@@ -27,12 +27,25 @@ export interface DefaultAuthClientConfig {
27
27
  prompt?: string;
28
28
  responseMode?: OAuthResponseMode;
29
29
  scopes?: string | string[] | undefined;
30
- validateIDToken?: boolean;
31
- validateIDTokenIssuer?: boolean;
32
- /**
33
- * Allowed leeway for id_tokens (in seconds).
34
- */
35
- clockTolerance?: number;
30
+ tokenValidation?: {
31
+ /**
32
+ * ID token validation config.
33
+ */
34
+ idToken?: {
35
+ /**
36
+ * Whether to validate ID tokens.
37
+ */
38
+ validate?: boolean;
39
+ /**
40
+ * Whether to validate the issuer of ID tokens.
41
+ */
42
+ validateIssuer?: boolean;
43
+ /**
44
+ * Allowed leeway for ID tokens (in seconds).
45
+ */
46
+ clockTolerance?: number;
47
+ };
48
+ };
36
49
  /**
37
50
  * Specifies if cookies should be sent with access-token requests, refresh-token requests,
38
51
  * custom-grant requests, etc.
package/dist/cjs/index.js CHANGED
@@ -900,8 +900,8 @@ var AuthenticationHelper = class {
900
900
  (await this._config()).clientId,
901
901
  issuer ?? "",
902
902
  this._cryptoHelper.decodeIdToken(idToken).sub,
903
- (await this._config()).clockTolerance,
904
- (await this._config()).validateIDTokenIssuer ?? true
903
+ (await this._config()).tokenValidation?.idToken?.clockTolerance,
904
+ (await this._config()).tokenValidation?.idToken?.validateIssuer ?? true
905
905
  );
906
906
  }
907
907
  getAuthenticatedUserInfo(idToken) {
@@ -943,7 +943,7 @@ var AuthenticationHelper = class {
943
943
  }
944
944
  const parsedResponse = await response.json();
945
945
  parsedResponse.created_at = (/* @__PURE__ */ new Date()).getTime();
946
- const shouldValidateIdToken = (await this._config()).validateIDToken;
946
+ const shouldValidateIdToken = (await this._config()).tokenValidation?.idToken?.validate;
947
947
  if (shouldValidateIdToken) {
948
948
  return this.validateIdToken(parsedResponse.id_token).then(async () => {
949
949
  await this._storageManager.setSessionData(parsedResponse, userId);
@@ -1042,12 +1042,16 @@ var getAuthorizeRequestUrlParams_default = getAuthorizeRequestUrlParams;
1042
1042
 
1043
1043
  // src/__legacy__/client.ts
1044
1044
  var DefaultConfig = {
1045
- clockTolerance: 300,
1045
+ tokenValidation: {
1046
+ idToken: {
1047
+ validate: true,
1048
+ validateIssuer: true,
1049
+ clockTolerance: 300
1050
+ }
1051
+ },
1046
1052
  enablePKCE: true,
1047
1053
  responseMode: "query",
1048
- sendCookiesInRequests: true,
1049
- validateIDToken: true,
1050
- validateIDTokenIssuer: true
1054
+ sendCookiesInRequests: true
1051
1055
  };
1052
1056
  var _AsgardeoAuthClient = class _AsgardeoAuthClient {
1053
1057
  /**
@@ -3528,32 +3532,29 @@ var deriveOrganizationHandleFromBaseUrl = (baseUrl) => {
3528
3532
  "The provided base URL does not conform to valid URL syntax."
3529
3533
  );
3530
3534
  }
3531
- const hostname = parsedUrl.hostname.toLowerCase();
3532
- if (!hostname.endsWith(".asgardeo.io")) {
3533
- throw new AsgardeoRuntimeError(
3534
- "Organization handle is required since a custom domain is configured.",
3535
- "javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-001",
3536
- "javascript",
3537
- "The provided base URL uses a custom domain. Please provide the organizationHandle explicitly in the configuration."
3538
- );
3539
- }
3540
- const pathSegments = parsedUrl.pathname.split("/").filter((segment) => segment.length > 0);
3535
+ const pathSegments = parsedUrl.pathname?.split("/")?.filter((segment) => segment?.length > 0);
3541
3536
  if (pathSegments.length < 2 || pathSegments[0] !== "t") {
3542
- throw new AsgardeoRuntimeError(
3543
- "Organization handle is required since a custom domain is configured.",
3544
- "javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-002",
3545
- "javascript",
3546
- "The provided base URL does not follow the expected Asgardeo URL pattern (/t/{orgHandle}). Please provide the organizationHandle explicitly in the configuration."
3537
+ console.warn(
3538
+ new AsgardeoRuntimeError(
3539
+ "Organization handle is required since a custom domain is configured.",
3540
+ "javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-002",
3541
+ "javascript",
3542
+ "The provided base URL does not follow the expected URL pattern (/t/{orgHandle}). Please provide the organizationHandle explicitly in the configuration."
3543
+ ).toString()
3547
3544
  );
3545
+ return "";
3548
3546
  }
3549
3547
  const organizationHandle = pathSegments[1];
3550
3548
  if (!organizationHandle || organizationHandle.trim().length === 0) {
3551
- throw new AsgardeoRuntimeError(
3552
- "Organization handle is required since a custom domain is configured.",
3553
- "javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-003",
3554
- "javascript",
3555
- "The organization handle could not be extracted from the base URL. Please provide the organizationHandle explicitly in the configuration."
3549
+ console.warn(
3550
+ new AsgardeoRuntimeError(
3551
+ "Organization handle is required since a custom domain is configured.",
3552
+ "javascript-deriveOrganizationHandleFromBaseUrl-CustomDomainError-003",
3553
+ "javascript",
3554
+ "The organization handle could not be extracted from the base URL. Please provide the organizationHandle explicitly in the configuration."
3555
+ ).toString()
3556
3556
  );
3557
+ return "";
3557
3558
  }
3558
3559
  return organizationHandle;
3559
3560
  };