From ef50f44a4ec87bfde17b09769b10013c6d948c1a Mon Sep 17 00:00:00 2001 From: shuaiplus <2327005759@qq.com> Date: Fri, 6 Feb 2026 00:12:08 +0800 Subject: [PATCH] Enhance UserDecryptionOptions structure for mobile compatibility; add MasterPasswordUnlock interface --- src/handlers/identity.ts | 10 ++++++++++ src/types/index.ts | 25 +++++++++++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/handlers/identity.ts b/src/handlers/identity.ts index 4d24a3a..aad5648 100644 --- a/src/handlers/identity.ts +++ b/src/handlers/identity.ts @@ -85,6 +85,16 @@ export async function handleToken(request: Request, env: Env): Promise UserDecryptionOptions: { HasMasterPassword: true, Object: 'userDecryptionOptions', + MasterPasswordUnlock: { + Kdf: { + KdfType: user.kdfType, + Iterations: user.kdfIterations, + Memory: user.kdfMemory || null, + Parallelism: user.kdfParallelism || null, + }, + MasterKeyEncryptedUserKey: user.key, + Salt: email, // email is already lowercased above + }, }, }; diff --git a/src/types/index.ts b/src/types/index.ts index fad8c5b..9f7747c 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -145,6 +145,26 @@ export interface JWTPayload { premium: boolean; } +// UserDecryptionOptions types for mobile client compatibility +export interface MasterPasswordUnlockKdf { + KdfType: number; + Iterations: number; + Memory: number | null; + Parallelism: number | null; +} + +export interface MasterPasswordUnlock { + Kdf: MasterPasswordUnlockKdf; + MasterKeyEncryptedUserKey: string; + Salt: string; +} + +export interface UserDecryptionOptions { + HasMasterPassword: boolean; + Object: string; + MasterPasswordUnlock?: MasterPasswordUnlock; +} + // API Response types export interface TokenResponse { access_token: string; @@ -161,10 +181,7 @@ export interface TokenResponse { ResetMasterPassword: boolean; scope: string; unofficialServer: boolean; - UserDecryptionOptions: { - HasMasterPassword: boolean; - Object: string; - }; + UserDecryptionOptions: UserDecryptionOptions; } export interface ProfileResponse {