/** * HologramShareRegistry — tracks share metadata and expiry for HoloGram bundles. * * Content-addressed bundles are immutable (they live in HologramStore), but * the SHARE layer sits on top: a share record tracks when a gram was shared, * who shared it, an optional expiry time, and a view counter. When a gram * expires, the /g/ viewer page returns 410 Gone instead of rendering. * * Storage: JSON sidecar files alongside the bundle directory, at * ///share.json * This keeps share metadata co-located with the bundle it describes and * avoids a separate database. * * SECURITY: * - Hashes are validated via assertValidHash before any path construction. * - Share records are never user-writable directly — they are created * by the upload flow or the share API endpoint. * - Expiry timestamps are server-side generated (not user-supplied) to * prevent a malicious client from setting expiry=far-future. * * @see D.019: HoloGram product line + telegram push metaphor * @see Wave B Stream 5: share URL infrastructure + expiry policy */ export interface HologramShareRecord { /** Content hash this share refers to (64 hex chars). */ hash: string; /** ISO 8601 timestamp of when the share was created. */ createdAt: string; /** * ISO 8601 timestamp of when the share expires. Null = never expires. * Set at creation time based on the configured default TTL. */ expiresAt: string | null; /** Number of times the gram has been viewed via the share URL. */ viewCount: number; /** * Who created this share. Empty string for anonymous/worker uploads. * For authenticated Studio sessions, the user identifier. */ createdBy: string; /** Schema version for future migration. */ schemaVersion: 1; } export interface HologramShareRegistryOptions { /** Same rootDir as the FileSystemHologramStore. */ rootDir: string; /** * Default TTL for new shares in seconds. 0 = never expire. * Default: 0 (never expire — content-addressed grams are permanent * by default; explicit TTL is opt-in for ephemeral shares). */ defaultTtlSeconds?: number; /** * Maximum allowed TTL in seconds. Prevents clients from requesting * absurdly long expiry times. Default: 365 days (31536000 seconds). */ maxTtlSeconds?: number; } export interface CreateShareParams { hash: string; createdBy?: string; /** Override TTL for this specific share (seconds). 0 = never expire. */ ttlSeconds?: number; } export interface ShareStatusResult { record: HologramShareRecord | null; expired: boolean; } export declare class HologramShareRegistry { private readonly rootDir; private readonly defaultTtlSeconds; private readonly maxTtlSeconds; constructor(opts: HologramShareRegistryOptions); /** * Create a share record for a bundle. If a share record already exists * for this hash, returns the existing record (idempotent). * * The TTL is resolved in priority order: * 1. Explicit ttlSeconds parameter (clamped to maxTtlSeconds) * 2. Registry defaultTtlSeconds * 3. 0 (never expire) */ createShare(params: CreateShareParams): Promise; /** * Get the share status for a bundle. Returns null record + expired=false * if no share record exists (unshared bundles are always accessible). * Returns the record + expired=true if the share has expired. */ getShareStatus(hash: string): Promise; /** * Increment the view counter for a share. No-op if no share record exists. * This is a lightweight touch — we read-modify-write the share.json file. * Race-condition tolerance: a missed increment is acceptable (views are * approximate, not financial). */ incrementViewCount(hash: string): Promise; /** * Update the expiry time for an existing share. Used to extend or * shorten the TTL of an already-shared gram. Setting expiresAt to * null removes the expiry (makes the share permanent). * * Returns the updated record, or null if no share exists. */ setExpiry(hash: string, expiresAt: string | null): Promise; /** * Get the default TTL in seconds for new shares. */ getDefaultTtl(): number; /** * Get the max allowed TTL in seconds. */ getMaxTtl(): number; private resolveTtl; private resolveSharePath; private readShareFile; private writeAtomic; } //# sourceMappingURL=HologramShareRegistry.d.ts.map