Enhance UserDecryptionOptions structure for mobile compatibility; add MasterPasswordUnlock interface

This commit is contained in:
shuaiplus
2026-02-06 00:12:08 +08:00
parent 8e10b65513
commit ef50f44a4e
2 changed files with 31 additions and 4 deletions
+10
View File
@@ -85,6 +85,16 @@ export async function handleToken(request: Request, env: Env): Promise<Response>
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
},
},
};
+21 -4
View File
@@ -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 {