feat(media): albums — one link for a season or a photo album; fix path traversal in media get
An album is a sealed file (shade.album/v1) listing grants, so the relay cannot tell it from a film. `shade media put dir/` uploads every file and the album (subdirectories nest, natural order); `media get` brings an album back as a directory; /watch/ shows a grid with decrypted previews and Back returns to the album without putting grants in history. Kotlin reads albums (Albums.read) against a new shared vector. Fixed: `media get` used the sealer-chosen meta.name as the output path. Fixed a relay test race (flush() is sent, not received); the relay now reports framesIn. Verified: 64 TS tests x3, Kotlin 81/0, a 6-file album with a nested album uploaded, browsed, played and downloaded back bit-identical. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -58,6 +58,8 @@ import { LivePublisher, epochKeys, chainStep, linkEpochSeed } from '../packages/
|
||||
import { encodeContent, decodeFrame } from '../packages/shade-media/src/live/frame.js';
|
||||
import type { LiveContent } from '../packages/shade-media/src/live/frame.js';
|
||||
import { encodeGrant } from '../packages/shade-media/src/grant.js';
|
||||
import type { MediaGrant } from '../packages/shade-media/src/grant.js';
|
||||
import { albumMeta, encodeAlbum } from '../packages/shade-media/src/album.js';
|
||||
import { ed25519PublicKeyFromSeed as edPub } from '../packages/shade-crypto-web/src/index.js';
|
||||
|
||||
const VECTOR_FILE_VERSION = 2;
|
||||
@@ -1083,6 +1085,29 @@ async function generateMediaVectors(): Promise<Vector[]> {
|
||||
description: 'live grant: wire JSON of a link grant (base64url fields, from: now at seq 0)',
|
||||
json: encodeGrant(grant),
|
||||
});
|
||||
|
||||
// Album: a sealed file whose plaintext lists grants — a film, a nested
|
||||
// album and the live link grant above.
|
||||
const film: MediaGrant = {
|
||||
kind: 'shade.media-grant/v1',
|
||||
mediaId: new Uint8Array(16).fill(0x11),
|
||||
mediaKey: new Uint8Array(32).fill(0x22),
|
||||
rootDigest: new Uint8Array(32).fill(0x33),
|
||||
url: 'https://relay.example/v1/media/11111111111111111111111111111111',
|
||||
meta: { name: 'Episode 1.mkv', mime: 'video/x-matroska' },
|
||||
};
|
||||
const nested: MediaGrant = { ...film, mediaId: new Uint8Array(16).fill(0x44), meta: albumMeta('Ekstra') };
|
||||
const albumPlain = encodeAlbum({ title: 'Sesong 1 — «Vinter»', items: [film, nested, grant] });
|
||||
const sealedAlbum = await sealWithPinnedKeys(albumPlain, mediaId, mediaKey, { segmentSize: 4096, meta: albumMeta('Sesong 1 — «Vinter»') });
|
||||
vectors.push({
|
||||
description: 'album: sealed shade.album/v1 holding a media grant, a nested album and a live link grant',
|
||||
sealed: hex(sealedAlbum.bytes),
|
||||
rootDigest: hex(sealedAlbum.result.rootDigest),
|
||||
plaintext: new TextDecoder().decode(albumPlain),
|
||||
title: 'Sesong 1 — «Vinter»',
|
||||
itemKinds: ['shade.media-grant/v1', 'shade.media-grant/v1', 'shade.live-grant/v1'],
|
||||
itemNames: ['Episode 1.mkv', 'Ekstra', grant.meta?.name ?? ''],
|
||||
});
|
||||
return vectors;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user