25 lines
777 B
TypeScript
25 lines
777 B
TypeScript
/**
|
|
* Auth 状态机:Helpers
|
|
*
|
|
* 状态机内复用的小函数 —— 独立成文件便于测试 / 复用。
|
|
*/
|
|
import { AuthStorage } from "@/data/storage/auth/auth_storage";
|
|
|
|
/** 从本地存储读 guest deviceId;读不到 / 失败时返回 undefined(不抛)。 */
|
|
export async function readGuestId(): Promise<string | undefined> {
|
|
const r = await AuthStorage.getInstance().getDeviceId();
|
|
if (r.success && r.data != null) {
|
|
return r.data;
|
|
}
|
|
return undefined;
|
|
}
|
|
|
|
/** 从本地存储读 PSID;读不到 / 失败时返回 undefined(不抛)。 */
|
|
export async function readPsid(): Promise<string | undefined> {
|
|
const r = await AuthStorage.getInstance().getPsid();
|
|
if (r.success && r.data != null) {
|
|
return r.data;
|
|
}
|
|
return undefined;
|
|
}
|