feat: extend CiphersImportRequest with additional fields for enhanced import functionality

This commit is contained in:
shuaiplus
2026-02-20 16:54:42 +08:00
parent 363a029618
commit 269055867b
+13 -6
View File
@@ -17,6 +17,11 @@ interface CiphersImportRequest {
username?: string | null; username?: string | null;
password?: string | null; password?: string | null;
totp?: string | null; totp?: string | null;
autofillOnPageLoad?: boolean | null;
fido2Credentials?: any[] | null;
uri?: string | null;
passwordRevisionDate?: string | null;
[key: string]: any;
} | null; } | null;
card?: { card?: {
cardholderName?: string | null; cardholderName?: string | null;
@@ -143,6 +148,7 @@ export async function handleCiphersImport(request: Request, env: Env, userId: st
const folderId = cipherFolderMap.get(i) || null; const folderId = cipherFolderMap.get(i) || null;
const cipher: Cipher = { const cipher: Cipher = {
...c,
id: generateUUID(), id: generateUUID(),
userId: userId, userId: userId,
type: c.type as CipherType, type: c.type as CipherType,
@@ -151,6 +157,7 @@ export async function handleCiphersImport(request: Request, env: Env, userId: st
notes: c.notes || null, notes: c.notes || null,
favorite: c.favorite || false, favorite: c.favorite || false,
login: c.login ? { login: c.login ? {
...c.login,
username: c.login.username || null, username: c.login.username || null,
password: c.login.password || null, password: c.login.password || null,
uris: c.login.uris?.map(u => ({ uris: c.login.uris?.map(u => ({
@@ -159,10 +166,10 @@ export async function handleCiphersImport(request: Request, env: Env, userId: st
match: u.match ?? null, match: u.match ?? null,
})) || null, })) || null,
totp: c.login.totp || null, totp: c.login.totp || null,
autofillOnPageLoad: null, autofillOnPageLoad: c.login.autofillOnPageLoad ?? null,
fido2Credentials: null, fido2Credentials: c.login.fido2Credentials ?? null,
uri: null, uri: c.login.uri ?? null,
passwordRevisionDate: null, passwordRevisionDate: c.login.passwordRevisionDate ?? null,
} : null, } : null,
card: c.card ? { card: c.card ? {
cardholderName: c.card.cardholderName || null, cardholderName: c.card.cardholderName || null,
@@ -201,8 +208,8 @@ export async function handleCiphersImport(request: Request, env: Env, userId: st
})) || null, })) || null,
passwordHistory: c.passwordHistory || null, passwordHistory: c.passwordHistory || null,
reprompt: c.reprompt || 0, reprompt: c.reprompt || 0,
sshKey: null, sshKey: (c as any).sshKey ?? null,
key: null, key: (c as any).key ?? null,
createdAt: now, createdAt: now,
updatedAt: now, updatedAt: now,
deletedAt: null, deletedAt: null,