添加登录功能
This commit is contained in:
commit
a3f61a29d0
120 files changed
+3974
No files matched your search
@@ -0,0 +1,40 @@
|
||||
/** 登录边界与可注入端口。 / 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<string, string>;
|
||||
}
|
||||
export interface GuestTransport {
|
||||
post(path: string, body: object, headers: Record<string, string>, signal?: AbortSignal): Promise<Record<string, unknown>>;
|
||||
}
|
||||
export interface GuestLogin { signIn(signal?: AbortSignal): Promise<GuestSession> }
|
||||
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.');
|
||||
}
|
||||
Reference in new issue
Block a user