@authsignal/browser 1.12.6 → 1.13.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.
@@ -1,4 +1,5 @@
1
1
  import { CredentialDeviceType } from "@simplewebauthn/browser";
2
+ import { ErrorCode } from "../../types";
2
3
  export type ApiClientOptions = {
3
4
  baseUrl: string;
4
5
  tenantId: string;
@@ -21,9 +22,12 @@ export type VerifyResponse = {
21
22
  userAuthenticator?: Authenticator;
22
23
  };
23
24
  export type ErrorResponse = {
24
- error: string;
25
- errorCode?: "expired_token" | (string & {});
26
- errorDescription?: string;
25
+ /**
26
+ * @deprecated Use errorCode and errorDescription instead
27
+ */
28
+ error?: string;
29
+ errorCode?: ErrorCode;
30
+ errorDescription?: string | undefined;
27
31
  };
28
32
  export declare enum VerificationMethod {
29
33
  SMS = "SMS",
@@ -13,6 +13,7 @@ export declare class Authsignal {
13
13
  profilingId: string;
14
14
  cookieDomain: string;
15
15
  anonymousIdCookieName: string;
16
+ enableLogging: boolean;
16
17
  passkey: Passkey;
17
18
  totp: Totp;
18
19
  email: Email;
@@ -22,7 +23,7 @@ export declare class Authsignal {
22
23
  qrCode: QrCode;
23
24
  push: Push;
24
25
  whatsapp: Whatsapp;
25
- constructor({ cookieDomain, cookieName, baseUrl, tenantId, onTokenExpired, }: AuthsignalOptions);
26
+ constructor({ cookieDomain, cookieName, baseUrl, tenantId, onTokenExpired, enableLogging, }: AuthsignalOptions);
26
27
  setToken(token: string): void;
27
28
  launch(url: string, options?: {
28
29
  mode?: "redirect";
@@ -4,6 +4,7 @@ type EmailMagicLinkOptions = {
4
4
  baseUrl: string;
5
5
  tenantId: string;
6
6
  onTokenExpired?: () => void;
7
+ enableLogging: boolean;
7
8
  };
8
9
  type EnrollParams = {
9
10
  email: string;
@@ -11,7 +12,8 @@ type EnrollParams = {
11
12
  export declare class EmailMagicLink {
12
13
  private api;
13
14
  private cache;
14
- constructor({ baseUrl, tenantId, onTokenExpired }: EmailMagicLinkOptions);
15
+ private enableLogging;
16
+ constructor({ baseUrl, tenantId, onTokenExpired, enableLogging }: EmailMagicLinkOptions);
15
17
  enroll({ email }: EnrollParams): Promise<AuthsignalResponse<EnrollResponse>>;
16
18
  challenge(): Promise<AuthsignalResponse<ChallengeResponse>>;
17
19
  checkVerificationStatus(): Promise<AuthsignalResponse<VerifyResponse>>;
package/dist/email.d.ts CHANGED
@@ -4,6 +4,7 @@ type EmailOptions = {
4
4
  baseUrl: string;
5
5
  tenantId: string;
6
6
  onTokenExpired?: () => void;
7
+ enableLogging: boolean;
7
8
  };
8
9
  type EnrollParams = {
9
10
  email: string;
@@ -14,7 +15,8 @@ type VerifyParams = {
14
15
  export declare class Email {
15
16
  private api;
16
17
  private cache;
17
- constructor({ baseUrl, tenantId, onTokenExpired }: EmailOptions);
18
+ private enableLogging;
19
+ constructor({ baseUrl, tenantId, onTokenExpired, enableLogging }: EmailOptions);
18
20
  enroll({ email }: EnrollParams): Promise<AuthsignalResponse<EnrollResponse>>;
19
21
  challenge(): Promise<AuthsignalResponse<ChallengeResponse>>;
20
22
  verify({ code }: VerifyParams): Promise<AuthsignalResponse<VerifyResponse>>;
@@ -4,12 +4,14 @@ type PopupShowInput = {
4
4
  };
5
5
  type PopupHandlerOptions = {
6
6
  width?: string;
7
+ height?: string;
7
8
  isClosable?: boolean;
8
9
  };
9
10
  export declare class PopupHandler {
10
11
  private popup;
11
- constructor({ width, isClosable }: PopupHandlerOptions);
12
- create({ width, isClosable }: PopupHandlerOptions): void;
12
+ private height;
13
+ constructor({ width, height, isClosable }: PopupHandlerOptions);
14
+ create({ width, height, isClosable }: PopupHandlerOptions): void;
13
15
  destroy(): void;
14
16
  show({ url }: PopupShowInput): void;
15
17
  close(): void;
package/dist/helpers.d.ts CHANGED
@@ -9,15 +9,29 @@ type CookieOptions = {
9
9
  export declare function setCookie({ name, value, expire, domain, secure }: CookieOptions): void;
10
10
  export declare function getCookieDomain(): string;
11
11
  export declare function getCookie(name: string): string | null;
12
- export declare function handleErrorResponse(errorResponse: ErrorResponse): {
13
- error: string;
12
+ type HandleErrorResponseParams = {
13
+ errorResponse: ErrorResponse;
14
+ enableLogging: boolean;
14
15
  };
15
- export declare function handleApiResponse<T>(response: ErrorResponse | T): {
16
- error: string;
16
+ export declare function handleErrorResponse({ errorResponse, enableLogging }: HandleErrorResponseParams): {
17
+ error: string | undefined;
18
+ errorCode: import("./types").ErrorCode | undefined;
19
+ errorDescription: string | undefined;
20
+ };
21
+ type HandleApiResponseParams<T> = {
22
+ response: ErrorResponse | T;
23
+ enableLogging: boolean;
24
+ };
25
+ export declare function handleApiResponse<T>({ response, enableLogging }: HandleApiResponseParams<T>): {
26
+ error: string | undefined;
27
+ errorCode: import("./types").ErrorCode | undefined;
28
+ errorDescription: string | undefined;
17
29
  data?: undefined;
18
30
  } | {
19
31
  data: T;
20
32
  error?: undefined;
33
+ errorCode?: undefined;
34
+ errorDescription?: undefined;
21
35
  };
22
36
  export declare function handleWebAuthnError(error: unknown): void;
23
37
  export {};