/** 登录边界与可注入端口。 / Login contracts and injectable ports. */ export interface GuestSettings { origin: string; product: string; deviceType: 'iphone' | 'ipad'; registerDevice: string; timeoutMs: number; } export interface GuestSession { guestId: string; token: string; expires: number } export interface TextStorage { getItem(key: string): string | null; setItem(key: string, value: string): void; } export interface GuestAccountStore { identity(create: () => string): string; save(session: GuestSession): void; } export interface GuestPayload { guest_id: string; pkg: string; device_type: 'iphone' | 'ipad'; register_device: string; install_fb: boolean; gyroscope_not_spinning: boolean; } export interface GuestSigner { headers(payload: GuestPayload): Record; } export interface GuestTransport { post(path: string, body: object, headers: Record, signal?: AbortSignal): Promise>; } export interface GuestLogin { signIn(signal?: AbortSignal): Promise } export type GuestFailure = 'configuration' | 'identity' | 'storage' | 'network' | 'timeout' | 'cancelled' | 'response' | 'verification' | 'rejected'; /** 只向界面提供固定消息,避免泄漏服务器原文或凭据。 / Expose fixed messages, never raw server data or credentials. */ export class GuestError extends Error { constructor(readonly kind: GuestFailure, message: string) { super(message); this.name = 'GuestError'; } } export function assertNotCancelled(signal?: AbortSignal): void { if (signal?.aborted) throw new GuestError('cancelled', 'Sign-in cancelled.'); }