@auth-link/web 0.0.5 → 1.1.0

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/styles.css CHANGED
@@ -124,3 +124,9 @@
124
124
  .authlink-widget[data-variant="C"] .authlink-code { margin-bottom: 4px; }
125
125
  }
126
126
  @media (prefers-reduced-motion: reduce) { .authlink-dialog * { animation: none !important; transition: none !important; } }
127
+
128
+ .authlink-code-form { display: grid; gap: 12px; margin-top: 20px; text-align: left; }
129
+ .authlink-code-form input { width: 100%; box-sizing: border-box; padding: 12px; border: 1px solid #bccbc2; border-radius: 10px; background: white; color: #18352b; font: inherit; font-size: 24px; text-align: center; letter-spacing: .3em; }
130
+ .authlink-code-form label { font-size: 14px; font-weight: 600; }
131
+ .authlink-code-form button:disabled { opacity: .6; cursor: wait; }
132
+ .authlink-input-error { color: #a33128; font-size: 13px; }
@@ -24,10 +24,12 @@ export interface ClientOptions {
24
24
  authLinkOrigin?: string;
25
25
  fetch?: typeof fetch;
26
26
  }
27
+ export declare function createBackendCall(options: ClientOptions): (path: string, body: unknown, signal?: AbortSignal, key?: string) => Promise<unknown>;
27
28
  export declare function createAuthLinkClient(options: ClientOptions): AuthLinkClient;
28
29
  export declare function requestKey(): string;
29
30
  export declare function initialSnapshot(): Snapshot;
30
31
  export interface ObserveOptions extends Events {
32
+ onReady?: (submit: (confirmationCode: string) => Promise<void>) => void;
31
33
  /** Presentation-only timing from the same monotonic clock as code expiry. */
32
34
  onCodeTiming?: (remainingMs: number) => void;
33
35
  expectedMode?: Mode;
@@ -1,6 +1,6 @@
1
1
  import type { Locale } from './types.js';
2
2
  export declare const supportedLocales: readonly ["en", "zh-CN", "zh-TW", "ja", "bn", "es", "fil", "hi", "id", "ms", "pt", "th", "vi"];
3
- type Messages = Record<"cancel" | "close" | "bind" | "confirm" | "scan" | "code" | "help" | "waiting" | "loading" | "confirmed" | "rejected" | "expired" | "error" | "retry" | "refresh" | "autoUpdate" | "expiring" | "updating", string>;
3
+ type Messages = Record<"otpCode" | "otpHelp" | "otpWaiting" | "otpError" | "otpSetup" | "codeLocked" | "confirmationCode" | "submitCode" | "codeError" | "cancel" | "close" | "bind" | "confirm" | "scan" | "code" | "help" | "waiting" | "loading" | "confirmed" | "rejected" | "expired" | "error" | "retry" | "refresh" | "autoUpdate" | "expiring" | "updating", string>;
4
4
  export declare const defaultLocale: Locale;
5
5
  export declare function resolveLocale(locale?: string): Locale;
6
6
  export declare function getMessages(locale?: string): Messages;
@@ -4,3 +4,5 @@ export { supportedLocales } from './i18n.js';
4
4
  export { openAuthLink, openAuthLinkBind, openAuthLinkConfirm } from './modal.js';
5
5
  export type { AuthLinkModal, AuthLinkModalOptions } from './modal.js';
6
6
  export type { ClientOptions } from './core.js';
7
+ export { openPasscode, createPasscodeClient } from './passcode.js';
8
+ export type { OTPVerification, PasscodeClient, PasscodeOptions } from './passcode.js';
@@ -1,3 +1,4 @@
1
+ import type { ViewNode } from './view.js';
1
2
  import type { DialogVariant, Locale, WidgetOptions } from './types.js';
2
3
  export interface AuthLinkModalOptions extends WidgetOptions {
3
4
  className?: string;
@@ -13,6 +14,7 @@ export interface AuthLinkModal {
13
14
  setVariant(variant?: DialogVariant): void;
14
15
  retry(): void;
15
16
  }
17
+ export declare function element(value: ViewNode | string, svg?: boolean): Node;
16
18
  /** Show a backend-created request. This function never creates or authorizes a request. */
17
19
  export declare function openAuthLink(options: AuthLinkModalOptions): AuthLinkModal;
18
20
  export declare const openAuthLinkBind: (options: AuthLinkModalOptions) => AuthLinkModal;
@@ -0,0 +1,29 @@
1
+ import type { ClientOptions } from './core.js';
2
+ import type { AuthLinkModal } from './modal.js';
3
+ import type { DialogVariant, Locale } from './types.js';
4
+ export interface OTPVerification {
5
+ status: 'confirmed';
6
+ verificationId: string;
7
+ authenticationPolicy: 'device-totp.v1';
8
+ expiresAt: string;
9
+ }
10
+ export interface PasscodeClient {
11
+ verify(passcode: string, signal: AbortSignal): Promise<OTPVerification>;
12
+ }
13
+ export interface PasscodeOptions {
14
+ client: PasscodeClient;
15
+ /** The CMS's single pending action deadline, not a TOTP time step. */
16
+ expiresAt: string;
17
+ locale?: Locale;
18
+ variant?: DialogVariant;
19
+ /** First-time enrollment only. Ordinary verification has no QR or request ID. */
20
+ bindingQr?: string;
21
+ authLinkOrigin?: string;
22
+ onVerified?: (result: OTPVerification) => void | Promise<void>;
23
+ onClose?: () => void;
24
+ onExpired?: () => void | Promise<void>;
25
+ onError?: (error: Error) => void;
26
+ }
27
+ export declare function createPasscodeClient(options: ClientOptions): PasscodeClient;
28
+ /** A session-scoped passcode prompt. No request creation, request ID or polling. */
29
+ export declare function openPasscode(options: PasscodeOptions): AuthLinkModal;
@@ -1,9 +1,13 @@
1
1
  import type { Snapshot, WidgetOptions } from './types.js';
2
2
  import type { AuthLinkModalOptions } from './modal.js';
3
+ import type { PasscodeOptions } from './passcode.js';
4
+ export type { PasscodeOptions, PasscodeClient, OTPVerification } from './passcode.js';
5
+ export declare function AuthLinkPasscode(props: PasscodeOptions): null;
3
6
  export type { Ticket, Confirmation, Rejection, Snapshot, AuthLinkClient, Locale, DialogVariant } from './types.js';
4
7
  export declare function useAuthLink(options: WidgetOptions): {
5
8
  snapshot: Snapshot;
6
9
  retry: () => void;
10
+ submitCode: (code: string) => Promise<void>;
7
11
  };
8
12
  export interface AuthLinkWidgetProps extends AuthLinkModalOptions {
9
13
  }
@@ -43,10 +43,11 @@ export interface AuthLinkClient {
43
43
  idempotencyKey: string;
44
44
  signal?: AbortSignal;
45
45
  }): Promise<Ticket>;
46
- result(ticket: Ticket, signal: AbortSignal): Promise<Result>;
46
+ result(ticket: Ticket, signal: AbortSignal, confirmationCode?: string): Promise<Result>;
47
47
  }
48
48
  export interface Snapshot {
49
49
  status: Status;
50
+ submitting?: boolean;
50
51
  code: string | null;
51
52
  secondsRemaining: number;
52
53
  codeSecondsRemaining: number;
@@ -10,8 +10,12 @@ export declare function widgetView(options: {
10
10
  locale?: Locale;
11
11
  variant?: DialogVariant;
12
12
  snapshot: Snapshot;
13
+ passcodeMode?: boolean;
13
14
  qr?: string;
14
15
  showQr?: boolean;
16
+ submitCode?: (code: string) => Promise<void>;
17
+ inputCode?: string;
18
+ setCode?: (code: string) => void;
15
19
  retry: () => void;
16
20
  refresh?: () => void;
17
21
  close?: () => void;
@@ -1,10 +1,14 @@
1
1
  import type { DefineComponent, ShallowRef } from 'vue';
2
2
  import type { Snapshot, WidgetOptions } from './types.js';
3
3
  import type { AuthLinkModalOptions } from './modal.js';
4
+ import type { PasscodeOptions } from './passcode.js';
5
+ export type { PasscodeOptions, PasscodeClient, OTPVerification } from './passcode.js';
6
+ export declare const AuthLinkPasscode: DefineComponent<PasscodeOptions>;
4
7
  export type { Ticket, Confirmation, Rejection, Snapshot, AuthLinkClient, Locale, DialogVariant } from './types.js';
5
8
  export declare function useAuthLink(getOptions: () => WidgetOptions): {
6
9
  snapshot: ShallowRef<Snapshot>;
7
10
  retry: () => void;
11
+ submitCode: (code: string) => Promise<void>;
8
12
  };
9
13
  export interface AuthLinkWidgetProps extends Omit<AuthLinkModalOptions, 'mode'> {
10
14
  }