Commit Graph

3 Commits

Author SHA1 Message Date
wuzf
cd904b659f fix(export): fall back to local export when offline or payload too large
Restore PWA offline parity for standard TXT/JSON/CSV/HTML exports by
falling back to the local generator when the unified /api/secrets/export
endpoint is unreachable (network TypeError), returns 503 with
{offline:true} from the service worker, or rejects with 413. The local
OTPAuth path now preserves HOTP type and counter.
2026-04-18 20:34:03 +08:00
wuzf
c0b8369a81 feat(backup): add unified export endpoint with format preference
Add a dedicated /api/secrets/export route (api/secrets/export.js)
that streams the unified backup format (JSON/CSV/HTML/TXT) with size
and auth guards. Settings persist the preferred export format per
user; backup runs pick it up so generated files match the chosen
schema. The UI settings label/toast reads "导出偏好格式" to clarify
the preference applies to batch export and backup export. The
Service Worker passes through offline responses, utils/backup-format.js
is slimmed down after route consolidation, and unused createdAt is
dropped from the unified format and validation.
2026-04-12 01:36:28 +08:00
wuzf
88b9cd8878 refactor(backup): unify backup formats and indexing
Centralize backup serialization in utils/backup-format.js with a
single createBackupEntry() path shared by scheduled backups, manual
backups and exports. Introduce utils/backup-index.js for KV key
listing/pruning and utils/data-hash.js for change detection,
replacing ad-hoc helpers scattered across api/secrets/backup.js,
restore.js and worker.js. UI backup/export modules consume the shared
format so HTML/JSON/CSV exports round-trip through the same schema.
2026-04-11 23:35:46 +08:00