@auth-link/web 0.0.0-stage → 0.0.2

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.
@@ -0,0 +1,7 @@
1
+ import type { Locale } from './types.js';
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>;
4
+ export declare const defaultLocale: Locale;
5
+ export declare function resolveLocale(locale?: string): Locale;
6
+ export declare function getMessages(locale?: string): Messages;
7
+ export {};
@@ -0,0 +1,6 @@
1
+ export * from './types.js';
2
+ export { AuthLinkError, createAuthLinkClient, requestKey, validateTicket, qrImage, observeRequest, initialSnapshot } from './core.js';
3
+ export { supportedLocales } from './i18n.js';
4
+ export { openAuthLink, openAuthLinkBind, openAuthLinkConfirm } from './modal.js';
5
+ export type { AuthLinkModal, AuthLinkModalOptions } from './modal.js';
6
+ export type { ClientOptions } from './core.js';
@@ -0,0 +1,19 @@
1
+ import type { DialogVariant, Locale, WidgetOptions } from './types.js';
2
+ export interface AuthLinkModalOptions extends WidgetOptions {
3
+ className?: string;
4
+ onClose?: () => void;
5
+ }
6
+ export interface AuthLinkModal {
7
+ /** Close the UI and abort observation. Does not reject or delete the server request. */
8
+ close(): void;
9
+ /** Component cleanup: close without delivering a user-close callback. */
10
+ destroy(): void;
11
+ setLocale(locale?: Locale): void;
12
+ /** Change presentation without creating or restarting a request. */
13
+ setVariant(variant?: DialogVariant): void;
14
+ retry(): void;
15
+ }
16
+ /** Show a backend-created request. This function never creates or authorizes a request. */
17
+ export declare function openAuthLink(options: AuthLinkModalOptions): AuthLinkModal;
18
+ export declare const openAuthLinkBind: (options: AuthLinkModalOptions) => AuthLinkModal;
19
+ export declare const openAuthLinkConfirm: (options: AuthLinkModalOptions) => AuthLinkModal;
@@ -0,0 +1,11 @@
1
+ import type { Snapshot, WidgetOptions } from './types.js';
2
+ import type { AuthLinkModalOptions } from './modal.js';
3
+ export type { Ticket, Confirmation, Rejection, Snapshot, AuthLinkClient, Locale, DialogVariant } from './types.js';
4
+ export declare function useAuthLink(options: WidgetOptions): {
5
+ snapshot: Snapshot;
6
+ retry: () => void;
7
+ };
8
+ export interface AuthLinkWidgetProps extends AuthLinkModalOptions {
9
+ }
10
+ export declare function AuthLinkBind(props: AuthLinkWidgetProps): import("react").JSX.Element;
11
+ export declare function AuthLinkConfirm(props: AuthLinkWidgetProps): import("react").JSX.Element;
@@ -0,0 +1,71 @@
1
+ export type Mode = 'bind' | 'confirm';
2
+ export type DialogVariant = 'A' | 'B' | 'C';
3
+ export type Status = 'idle' | 'pending' | 'confirmed' | 'rejected' | 'expired' | 'error';
4
+ export type Locale = 'en' | 'zh-CN' | 'zh-TW' | 'ja' | 'bn' | 'es' | 'fil' | 'hi' | 'id' | 'ms' | 'pt' | 'th' | 'vi';
5
+ /** Current display only. The generation secret must never reach the browser. */
6
+ export interface DisplayCode {
7
+ value: string;
8
+ serverTime: string;
9
+ validUntil: string;
10
+ periodSeconds: 30;
11
+ }
12
+ export interface Ticket {
13
+ requestId: string;
14
+ purpose: Mode;
15
+ qr: string;
16
+ pairingCode: string;
17
+ expiresAt: string;
18
+ displayCode?: DisplayCode;
19
+ }
20
+ export interface Confirmation {
21
+ status: 'confirmed';
22
+ requestId: string;
23
+ verificationId: string;
24
+ authenticationPolicy: 'device-presence.v1';
25
+ purpose: Mode;
26
+ expiresAt: string;
27
+ }
28
+ /** Business result delivered when the phone rejects a request. Not an HTTP status. */
29
+ export interface Rejection {
30
+ status: 'rejected';
31
+ code: 'REJECTED';
32
+ requestId: string;
33
+ purpose: Mode;
34
+ }
35
+ export interface PendingResult {
36
+ status: 'new' | 'pending' | 'approved' | 'consumed' | 'rejected' | 'expired';
37
+ requestId: string;
38
+ displayCode?: DisplayCode;
39
+ }
40
+ export type Result = Confirmation | PendingResult;
41
+ export interface AuthLinkClient {
42
+ create(mode: Mode, options: {
43
+ idempotencyKey: string;
44
+ signal?: AbortSignal;
45
+ }): Promise<Ticket>;
46
+ result(ticket: Ticket, signal: AbortSignal): Promise<Result>;
47
+ }
48
+ export interface Snapshot {
49
+ status: Status;
50
+ code: string | null;
51
+ secondsRemaining: number;
52
+ codeSecondsRemaining: number;
53
+ error: Error | null;
54
+ }
55
+ export interface Events {
56
+ onConfirmed?: (result: Confirmation) => void | Promise<void>;
57
+ onRejected?: (result: Rejection) => void | Promise<void>;
58
+ onExpired?: () => void | Promise<void>;
59
+ onError?: (error: Error) => void;
60
+ }
61
+ export interface WidgetOptions extends Events {
62
+ mode?: Mode;
63
+ ticket: Ticket;
64
+ client: AuthLinkClient;
65
+ locale?: Locale;
66
+ /** A: minimal (default), B: split, C: compact / mobile bottom sheet. */
67
+ variant?: DialogVariant;
68
+ showQr?: boolean;
69
+ intervalMs?: number;
70
+ onRefresh?: () => void;
71
+ }
@@ -0,0 +1,19 @@
1
+ import type { DialogVariant, Locale, Mode, Snapshot } from './types.js';
2
+ export interface ViewNode {
3
+ tag: string;
4
+ props: Record<string, unknown>;
5
+ children: (ViewNode | string)[];
6
+ }
7
+ export declare function resolveVariant(variant?: string): DialogVariant;
8
+ export declare function widgetView(options: {
9
+ mode: Mode;
10
+ locale?: Locale;
11
+ variant?: DialogVariant;
12
+ snapshot: Snapshot;
13
+ qr?: string;
14
+ showQr?: boolean;
15
+ retry: () => void;
16
+ refresh?: () => void;
17
+ close?: () => void;
18
+ className?: string;
19
+ }): ViewNode;
@@ -0,0 +1,12 @@
1
+ import type { DefineComponent, ShallowRef } from 'vue';
2
+ import type { Snapshot, WidgetOptions } from './types.js';
3
+ import type { AuthLinkModalOptions } from './modal.js';
4
+ export type { Ticket, Confirmation, Rejection, Snapshot, AuthLinkClient, Locale, DialogVariant } from './types.js';
5
+ export declare function useAuthLink(getOptions: () => WidgetOptions): {
6
+ snapshot: ShallowRef<Snapshot>;
7
+ retry: () => void;
8
+ };
9
+ export interface AuthLinkWidgetProps extends Omit<AuthLinkModalOptions, 'mode'> {
10
+ }
11
+ export declare const AuthLinkBind: DefineComponent<AuthLinkWidgetProps>;
12
+ export declare const AuthLinkConfirm: DefineComponent<AuthLinkWidgetProps>;