mirror of
https://github.com/shuaiplus/nodewarden.git
synced 2026-11-04 10:40:20 +00:00
Preserve linked and unknown encrypted fields in Web edits, reject stale and concurrent saves, and support official bulk delete and restore methods while retaining legacy routes. Add 20 offline compatibility regressions and update undici to 8.10.2. Verified 51 tests, TypeScript checks, locale validation, Web build and Worker deployment dry run. The unpatched braces advisory remains visible.
14 lines
630 B
TypeScript
14 lines
630 B
TypeScript
import type { VaultDraftField } from './types';
|
|
|
|
// Keep metadata on each draft field so removing or reordering fields cannot
|
|
// accidentally attach another field's link or unknown encrypted properties.
|
|
export function cipherFieldMetadata(field: object): Pick<VaultDraftField, 'linkedId' | 'extra'> {
|
|
const raw = field as Record<string, unknown>;
|
|
return {
|
|
...(typeof raw.linkedId === 'number' || raw.linkedId === null ? { linkedId: raw.linkedId } : {}),
|
|
extra: Object.fromEntries(Object.entries(raw).filter(([key]) =>
|
|
!['type', 'name', 'value', 'linkedId'].includes(key) && !/^dec[A-Z]/.test(key)
|
|
)),
|
|
};
|
|
}
|