Files
immich-folio/lib/proofing.ts
Ralksta 2f546f440d release: v0.11.0 (#459)
Ships `dev` as **v0.11.0**. `main` contains nothing that `dev` does not,
so this is a clean sync.

## Headline changes since v0.10.0

- **Journal & Journal Studio** — photo essays at `/journal`,
split-screen block editor with live preview, drafts, per-entry
passwords, cover images
- **First-run setup wizard at `/install`** — configure a fresh
deployment from the browser; credentials are verified against Immich
before anything is written, and the wizard is gated by a one-time token
- **About page editor and toggle** in the admin panel
- **Per-album photo order** independent of Immich, with a drag & drop
editor
- **Custom favicon upload**
- **Experimental portfolio features** — justified grid, `cover` hero,
unlisted subpages, per-album grid overrides, cover focal points,
external nav links
- **Security** — asset tokens length-capped before decoding (#423),
journal author markdown escaped rather than filtered, journal file paths
contained, admin session key derived with scrypt (#432), Next.js 16.3.0
for CVE-2025-13465
- **Fixed** — client proofing honours its own configuration again
(#454); journal photo rendering (#432)

Full detail in [CHANGELOG.md](CHANGELOG.md#0110--2026-08-15).

## Verified

`npx tsc --noEmit` clean · `npx vitest run` 435 tests pass · `npm run
build` succeeds · lint 0 errors · `prettier --check` clean · local
`docker build` of the release tree.

## After merge

Tag `v0.11.0` on `main` and publish the release — that triggers
`docker-publish.yml`, which pushes the image and moves `latest`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: ralksta <ralksta@users.noreply.github.com>
Co-authored-by: lancetm714 <108419425+lancetm714@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-15 09:09:18 +02:00

63 lines
1.8 KiB
TypeScript

/**
* Bitmask encoder/decoder for compact proofing URL query parameters.
* Serializes selected asset indices in an album into a short base64url string.
*/
/**
* Encode an array of 0-based asset indices into a compact base64url bitmask.
*/
export function encodeProofBitmask(indices: number[]): string {
if (!indices || indices.length === 0) return '';
const sorted = Array.from(new Set(indices)).sort((a, b) => a - b);
const maxIndex = sorted[sorted.length - 1];
if (maxIndex < 0) return '';
const numBytes = Math.ceil((maxIndex + 1) / 8);
const bytes = new Uint8Array(numBytes);
for (const idx of sorted) {
if (idx < 0) continue;
const byteIdx = Math.floor(idx / 8);
const bitIdx = idx % 8;
bytes[byteIdx] |= 1 << bitIdx;
}
let binary = '';
for (let i = 0; i < bytes.length; i++) {
binary += String.fromCharCode(bytes[i]);
}
return btoa(binary).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
}
/**
* Decode a base64url bitmask string back into an array of selected asset indices.
*/
export function decodeProofBitmask(code: string, totalCount?: number): number[] {
if (!code || typeof code !== 'string') return [];
try {
let base64 = code.trim().replace(/-/g, '+').replace(/_/g, '/');
while (base64.length % 4) {
base64 += '=';
}
const binary = atob(base64);
const result: number[] = [];
for (let byteIdx = 0; byteIdx < binary.length; byteIdx++) {
const byte = binary.charCodeAt(byteIdx);
for (let bitIdx = 0; bitIdx < 8; bitIdx++) {
if (byte & (1 << bitIdx)) {
const index = byteIdx * 8 + bitIdx;
if (totalCount === undefined || index < totalCount) {
result.push(index);
}
}
}
}
return result;
} catch {
return [];
}
}