Files
Genarrative/packages/shared/src/contracts/auth.ts
kdletters cf8da3f50f Merge branch 'codex/dev' into codex/backend-rewrite-spacetimedb
# Conflicts:
#	docs/technical/README.md
#	server-node/src/modules/assets/qwenSpriteRoutes.ts
#	src/components/CustomWorldResultView.test.tsx
#	src/components/CustomWorldResultView.tsx
#	src/components/custom-world-agent/CustomWorldAgentDraftDetailPanel.tsx
#	src/components/game-shell/PreGameSelectionFlow.agent.interaction.test.tsx
#	src/components/rpg-creation-asset-studio/RpgCreationRoleAssetStudioModalImpl.tsx
#	src/components/rpg-creation-editor/RpgCreationEntityEditorShared.tsx
#	src/components/rpg-entry/RpgEntryCharacterSelectView.tsx
#	src/components/rpg-entry/RpgEntryHomeView.tsx
#	src/services/apiClient.ts
#	src/tools/QwenSpriteSheetTool.tsx
2026-04-21 20:16:01 +08:00

169 lines
3.2 KiB
TypeScript

export type AuthBindingStatus = 'active' | 'pending_bind_phone';
export type AuthLoginMethod = 'password' | 'phone' | 'wechat';
export type AuthUser = {
id: string;
username: string;
displayName: string;
phoneNumberMasked: string | null;
loginMethod: AuthLoginMethod;
bindingStatus: AuthBindingStatus;
wechatBound: boolean;
};
export type AuthEntryRequest = {
username: string;
password: string;
};
export type AuthEntryResponse = {
token: string;
user: AuthUser;
};
export type AuthPhoneSendCodeRequest = {
phone: string;
scene?: 'login' | 'bind_phone' | 'change_phone';
captchaChallengeId?: string;
captchaAnswer?: string;
};
export type AuthPhoneSendCodeResponse = {
ok: true;
cooldownSeconds: number;
expiresInSeconds: number;
providerRequestId: string | null;
};
export type AuthPhoneLoginRequest = {
phone: string;
code: string;
};
export type AuthPhoneLoginResponse = {
token: string;
user: AuthUser;
};
export type AuthMeResponse = {
user: AuthUser | null;
availableLoginMethods: AuthLoginMethod[];
};
export type AuthLoginOptionsResponse = {
availableLoginMethods: AuthLoginMethod[];
};
export type AuthWechatStartResponse = {
authorizationUrl: string;
};
export type AuthWechatBindPhoneRequest = {
phone: string;
code: string;
};
export type AuthWechatBindPhoneResponse = {
token: string;
user: AuthUser;
};
export type AuthPhoneChangeRequest = {
phone: string;
code: string;
};
export type AuthPhoneChangeResponse = {
user: AuthUser;
};
export type AuthRefreshResponse = {
ok: true;
token?: string;
};
export type AuthSessionSummary = {
sessionId: string;
clientType: string;
clientRuntime: string;
clientPlatform: string;
clientLabel: string;
deviceDisplayName: string;
miniProgramAppId: string | null;
miniProgramEnv: string | null;
userAgent: string | null;
ipMasked: string | null;
isCurrent: boolean;
createdAt: string;
lastSeenAt: string;
expiresAt: string;
};
export type AuthSessionsResponse = {
sessions: AuthSessionSummary[];
};
export type AuthLogoutAllResponse = {
ok: true;
};
export type AuthRevokeSessionResponse = {
ok: true;
};
export type AuthAuditLogEventType =
| 'password_login'
| 'phone_login'
| 'wechat_login'
| 'wechat_bind_phone'
| 'change_phone'
| 'captcha_required'
| 'logout'
| 'logout_all'
| 'revoke_session'
| 'risk_block_phone'
| 'risk_block_ip'
| 'risk_unblock_phone'
| 'risk_unblock_ip';
export type AuthAuditLogEntry = {
id: string;
eventType: AuthAuditLogEventType;
title: string;
detail: string;
ipMasked: string | null;
userAgent: string | null;
createdAt: string;
};
export type AuthAuditLogsResponse = {
logs: AuthAuditLogEntry[];
};
export type AuthCaptchaChallenge = {
challengeId: string;
promptText: string;
imageDataUrl: string;
expiresInSeconds: number;
};
export type AuthRiskBlockSummary = {
scopeType: 'phone' | 'ip';
title: string;
detail: string;
expiresAt: string;
remainingSeconds: number;
};
export type AuthRiskBlocksResponse = {
blocks: AuthRiskBlockSummary[];
};
export type AuthLiftRiskBlockResponse = {
ok: true;
};
export type LogoutResponse = {
ok: true;
};