📄 src/downloader/keys.ts
D-OPEN SOVEREIGN
1/*
2 * Copyright (c) 2026 DataPond D-Library Pty Ltd. ("The Sanctuary")
3 * Non-Profit Public Library — The World Library
4 *
5 * D-SAFE Certification issued by POND Enterprise.
6 * Published under the D-Open Code Sovereign Licence v1.0 framework
7 * DataPond D-Library All exclusive Right reserved on modifiying the code - CC Attribution to data pond, Non modifiable, Non Commercial.
8 * https://registry.world.bibliotech.com/licence
9 * Source code donated to DataPond D-Library by it's author: data pond.
10 *
11 * Technical Guardian ("The Shield"): Pond Enterprise Pty Ltd. (ACN 694 747 987)
12 * All liability claims about D-SAFE certification issues coming from the published D-Safe direction must be addressed with Pond Enterprise Pty Ltd.
13 * Code Modification automatically voids the certified liability protection provided by Pond Enterprise.
14 */
15// Single source of truth for all cache names and key patterns.
16
17export const CACHE_VERSION = 1;
18
19export const CACHES = {
20 pdf: `dl2-pdf-v${CACHE_VERSION}`,
21 preview: `dl2-preview-v${CACHE_VERSION}`,
22 pages: `dl2-pages-v${CACHE_VERSION}`,
23} as const;
24
25// Replaced at build time by tsup define (git hash or build timestamp).
26export const DL2_SW_VERSION = '__DL2_SW_VERSION__';
27
28// PDFs and previews share the same /ar/<txId> path — they're kept in separate
29// named Cache objects (CACHES.pdf / CACHES.preview), so no collision.
30const arKey = (txId: string): string => `/ar/${txId}`;
31export const pdfKey = arKey;
32export const previewKey = arKey;
33export const pageKey = (txId: string, n: number): string =>
34 `/pages/${encodeURIComponent(txId)}/${n}`;
35