the code

read the code

our privacy policy says what we do with your photos and other data. These are the parts of our code that do it, copied from the source. Each one is dated, and when one changes, this page changes with it.

what a photo keeps

before anyone sees a photo or video, its metadata is stripped to when it was taken, its orientation, and that it was processed by ZIV. Location and device details are removed and the picture itself is untouched. A file that can't be cleaned is refused.

terms §7.6privacy §3.2updated November 25, 2026
lib/exif/tiff.ts
export const ZIV_SOFTWARE = "ziv.live";

const TAG_ORIENTATION = 0x0112;
const TAG_SOFTWARE = 0x0131;
const TAG_EXIF_IFD = 0x8769;
const TAG_DATE_TIME_ORIGINAL = 0x9003;
const TAG_CREATE_DATE = 0x9004;
const TAG_OFFSET_TIME_ORIGINAL = 0x9011;
const TAG_OFFSET_TIME = 0x9010;
const TAG_GPS_IFD = 0x8825;
const TAG_GPS_TIME_STAMP = 0x0007;
const TAG_GPS_DATE_STAMP = 0x001d;
const TYPE_RATIONAL = 5;

const TYPE_ASCII = 2;
const TYPE_SHORT = 3;
const TYPE_LONG = 4;

const EXIF_DATE = /^\d{4}:\d{2}:\d{2} \d{2}:\d{2}:\d{2}$/;

export interface AllowlistedTags {
  orientation?: number;
  dateTimeOriginal?: string;
  software?: string;
}
lib/exif/strip.ts
export function stripImageMetadata(bytes: Buffer, mimeType: string): StripOutcome {
  try {
    let out: Buffer | StripOutcome;
    switch (mimeType) {
      case "image/jpeg":
        out = stripJpeg(bytes);
        break;
      case "image/png":
        out = stripPng(bytes);
        break;
      case "image/webp":
        out = stripWebp(bytes);
        break;
      case "image/heic":
      case "image/heif":
        out = stripHeif(bytes);
        break;
      default:
        return { outcome: "unsupported", reason: `no stripper for ${mimeType}` };
    }
    if (!Buffer.isBuffer(out)) return out;
    return out.equals(bytes) ? { outcome: "already-clean" } : { outcome: "stripped", bytes: out };
  } catch (e) {
    return { outcome: "failed", reason: e instanceof Error ? e.message : String(e) };
  }
}
lib/ingest/stages/clean.ts
export async function clean(ctx: Screened): Promise<Screened | Verdict> {
  const { job, db, storage, rawBytes, artifacts, fileHash } = ctx;
  let cleanedSize: number | null = null;
  const reason = await cleanStoredOriginal(storage, job.file_key, job.mime_type, rawBytes, {
    beforeRewrite: async (size) => {
      await recordCleaned(db, job.id, size, fileHash);
      cleanedSize = size;
    },
  });
  if (!reason) return cleanedSize === null ? ctx : { ...ctx, storedSize: cleanedSize };
  return {
    verdict: "unclean",
    ctx,
    keys: [job.file_key, artifacts.thumbnailKey, artifacts.displayKey, artifacts.canvasKey, job.poster_file_key],
    reason,
  };
}

when an event ends

when an event's download window closes, its photos and videos are deleted, and the venue's Wi-Fi details and the host's welcome message go with them.

terms §8.2privacy §7updated November 25, 2026
lib/commercial/limits.ts
export function purgeCutoffFilter(now: Date): string {
  return TIERS.map((t) => {
    const cutoff = new Date(now.getTime() - getTierLimits(t).archiveWindowDays * 86_400_000)
    return `and(tier.eq.${t},expires_at.lte.${cutoff.toISOString()})`
  }).join(',')
}
lib/event-purge.ts
export async function purgeEvents(
  db: DbClient,
  storage: StorageClient,
  bucket: string,
  eventIds: string[],
): Promise<PurgeResult> {
  const now = new Date().toISOString()
  const result: PurgeResult = {
    eventsPurged: 0,
    mediaDeleted: 0,
    objectsDeleted: 0,
    failedEventIds: [],
  }

  if (eventIds.length === 0) return result

  const { data: events, error: eventsErr } = await db
    .from('events')
    .select('id, cover_image_key')
    .in('id', eventIds)

  if (eventsErr || !events) {
    result.failedEventIds = [...eventIds]
    return result
  }

  for (const event of events) {
    try {
      const media = await listMedia(db, event.id)
      if (!media) {
        result.failedEventIds.push(event.id)
        continue
      }

      const { data: jobs, error: jobsErr } = await db
        .from('ingest_jobs')
        .select('file_key, poster_file_key')
        .eq('event_id', event.id)
        .in('status', ['received', 'processing'])

      if (jobsErr) {
        console.error(`[purgeEvents] ingest job read error for event ${event.id}:`, jobsErr)
        result.failedEventIds.push(event.id)
        continue
      }

      const keySet = new Set<string>()
      for (const item of media) for (const k of mediaObjectKeys(item)) keySet.add(k)
      for (const job of jobs ?? []) {
        if (job.file_key) keySet.add(job.file_key)
        if (job.poster_file_key) keySet.add(job.poster_file_key)
      }
      if (event.cover_image_key) keySet.add(event.cover_image_key)
      const keysToDelete = [...keySet]

      if (!(await deleteObjectKeys(storage, bucket, event.id, keysToDelete, result))) {
        result.failedEventIds.push(event.id)
        continue
      }

      if (!(await deleteMediaRows(db, event.id, media.map((m) => m.id), result))) {
        result.failedEventIds.push(event.id)
        continue
      }

      const { error: linksErr } = await db
        .from('archive_links')
        .delete()
        .eq('event_id', event.id)

      if (linksErr) {
        console.error(`[purgeEvents] archive link delete error for event ${event.id}:`, linksErr)
        result.failedEventIds.push(event.id)
        continue
      }

      const { error: wifiErr } = await db
        .from('event_secrets')
        .update({ wifi_ssid: null, wifi_password: null })
        .eq('event_id', event.id)

      if (wifiErr) {
        console.error(`[purgeEvents] Wi-Fi clear error for event ${event.id}:`, wifiErr)
        result.failedEventIds.push(event.id)
        continue
      }

      const { error: hashesErr } = await db
        .from('event_rejected_hashes')
        .delete()
        .eq('event_id', event.id)

      if (hashesErr) {
        console.error(`[purgeEvents] rejected hash delete error for event ${event.id}:`, hashesErr)
        result.failedEventIds.push(event.id)
        continue
      }

      const { error: jobsDeleteErr } = await db
        .from('ingest_jobs')
        .delete()
        .eq('event_id', event.id)

      if (jobsDeleteErr) {
        console.error(`[purgeEvents] ingest job delete error for event ${event.id}:`, jobsDeleteErr)
        result.failedEventIds.push(event.id)
        continue
      }

      const { error: windowsErr } = await db
        .from('event_journey_windows')
        .delete()
        .eq('event_id', event.id)

      if (windowsErr) {
        console.error(`[purgeEvents] journey windows delete error for event ${event.id}:`, windowsErr)
        result.failedEventIds.push(event.id)
        continue
      }

      const { error: promptsErr } = await db
        .from('event_prompts')
        .delete()
        .eq('event_id', event.id)

      if (promptsErr) {
        console.error(`[purgeEvents] prompts delete error for event ${event.id}:`, promptsErr)
        result.failedEventIds.push(event.id)
        continue
      }

      const { error: stampErr } = await db
        .from('events')
        .update({ purged_at: now, welcome_message: null, timezone: null, share_message: null })
        .eq('id', event.id)

      if (stampErr) {
        console.error(`[purgeEvents] purged_at stamp error for event ${event.id}:`, stampErr)
        result.failedEventIds.push(event.id)
        continue
      }

      if (
        !(await drainMedia(db, storage, bucket, event.id, result)) ||
        !(await sweepLateCover(db, storage, bucket, event.id, result, keySet))
      ) {
        const { error: unstampErr } = await db
          .from('events')
          .update({ purged_at: null })
          .eq('id', event.id)
        if (unstampErr) {
          console.error(`[purgeEvents] un-stamp error for event ${event.id}, left to the residue sweep:`, unstampErr)
        }
        result.failedEventIds.push(event.id)
        continue
      }

      result.eventsPurged++
    } catch (err) {
      console.error(`[purgeEvents] unexpected error for event ${event.id}:`, err)
      result.failedEventIds.push(event.id)
    }
  }

  return result
}

guests without accounts

a guest needs no account to upload. Each guest is a random identifier, signed so nobody can forge one. A guest at one event can't be matched to the same guest at another.

privacy §3.2updated November 23, 2026
lib/event-tokens.ts
export function generateGuestIdSignature(
  guestId: string,
  uploadSecret: string,
): string {
  return createHmac("sha256", uploadSecret)
    .update(`guest:${guestId}`)
    .digest("hex");
}
lib/event-tokens.ts
export function guestUsageHash(guestId: string, uploadSecret: string): string {
  return createHmac("sha256", uploadSecret).update(`usage:${guestId}`).digest("hex");
}

export function verifyGuestIdSignature(
  sig: string,
  guestId: string,
  uploadSecret?: string | null,
): boolean {
  if (!sig || !guestId || !uploadSecret || typeof uploadSecret !== "string")
    return false;
  const expected = generateGuestIdSignature(guestId, uploadSecret);
  if (sig.length !== expected.length) return false;
  const a = Buffer.from(sig, "utf8");
  const b = Buffer.from(expected, "utf8");
  return timingSafeEqual(a, b);
}

export function newGuestId(): string {
  const bytes = randomBytes(16);
  const ms = BigInt(Date.now());
  for (let i = 0; i < 6; i++) bytes[i] = Number((ms >> BigInt(8 * (5 - i))) & BigInt(0xff));
  bytes[6] = (bytes[6] & 0x0f) | 0x70;
  bytes[8] = (bytes[8] & 0x3f) | 0x80;
  const hex = bytes.toString("hex");
  return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
}

export function guestIdIssuedAt(id: string): string | null {
  if (!/^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(id)) return null;
  const ms = parseInt(id.replace(/-/g, "").slice(0, 12), 16);
  return new Date(ms).toISOString();
}

export function signGuestAcceptance(
  guestId: string,
  termsVersion: string,
  acceptedAt: string,
  uploadSecret: string,
): string {
  return createHmac("sha256", uploadSecret)
    .update(`accept:${guestId}:${termsVersion}:${acceptedAt}`)
    .digest("hex");
}

export function verifyGuestAcceptance(
  a: GuestAcceptance,
  uploadSecret?: string | null,
): GuestAcceptance | null {
  if (!uploadSecret || typeof uploadSecret !== "string") return null;
  if (!guestIdIssuedAt(a.guestId)) return null;
  if (!verifyGuestIdSignature(a.guestSig, a.guestId, uploadSecret)) return null;
  const expected = signGuestAcceptance(a.guestId, a.termsVersion, a.acceptedAt, uploadSecret);
  if (!a.acceptSig || a.acceptSig.length !== expected.length) return null;
  if (!timingSafeEqual(Buffer.from(a.acceptSig, "utf8"), Buffer.from(expected, "utf8"))) return null;
  return a;
}

export function mintGuestAcceptance(
  guestId: string,
  guestSig: string,
  termsVersion: string,
  uploadSecret: string,
): GuestAcceptance {
  const acceptedAt = new Date().toISOString();
  return {
    guestId,
    guestSig,
    termsVersion,
    acceptedAt,
    acceptSig: signGuestAcceptance(guestId, termsVersion, acceptedAt, uploadSecret),
  };
}

an email we don't keep

a guest can ask for the full archive by email, and we never store the address. The code sends one email with a random one-use link and discards the address; the database keeps only a hash of the link so it can be claimed once.

privacy §3.2terms §8.2updated November 24, 2026
lib/archive-send.ts
export async function processArchiveSend(p: {
  id: string;
  email: string;
  ip: string;
  locale: Locale;
  now?: number;
}): Promise<ArchiveSendOutcome> {
  const now = p.now ?? Date.now();
  const filter = guestEventFilter(p.id);
  if (!filter) return "not-found";
  const db = createServiceClient();
  const { data: event } = await db
    .from("events")
    .select("id, org_id, title, tier, short_code, paid_at, expires_at, purged_at, roll_size, reveal_at, refunded_at")
    .eq(filter.column, filter.value)
    .maybeSingle();
  if (!event || !isEventActivated(event)) return "not-found";
  if (event.refunded_at) return "not-eligible";

  const tier = event.tier as Tier;
  if (event.purged_at || !event.expires_at || !isFeatureEnabled("bulkDownloadEnabled", tier)) {
    return "not-eligible";
  }
  const endsAt = new Date(event.expires_at);
  const archiveUntil = computeArchiveUntil(tier, endsAt);
  if (archiveUntil.getTime() <= now) return "outside-window";
  if (eventHeld(event, new Date(now))) return "held";

  if (!(await checkArchiveSendRateLimit(p.ip, event.id, p.email)).allowed) {
    return "rate-limited";
  }

  const source = { kind: "event", eventId: event.id, code: event.short_code } as const;
  const token = await mintArchiveLink(source, event.org_id);
  const urls = guestArchiveUrls(event.short_code, token);
  const sent = await sendEmail({
    to: [p.email],
    ...guestArchiveEmail({ title: event.title, shortCode: event.short_code, ...urls, endsAt, archiveUntil }, p.locale),
  });
  if (!sent) {
    await discardArchiveLink(source, token);
    return "send-failed";
  }
  return "sent";
}
lib/archive-links.ts
const hashToken = (token: string) => createHash("sha256").update(token).digest("hex");

function linkRow(source: ArchiveSource, token: string) {
  const db = createServiceClient();
  return {
    read: () =>
      source.kind === "event"
        ? db.from("archive_links").select("used_at").eq("event_id", source.eventId).eq("token_hash", hashToken(token)).maybeSingle()
        : db.from("demo_archive_links").select("used_at").eq("demo_event_id", source.demoId).eq("token_hash", hashToken(token)).maybeSingle(),
    spend: () => {
      const used_at = new Date().toISOString();
      return source.kind === "event"
        ? db.from("archive_links").update({ used_at }).eq("event_id", source.eventId).eq("token_hash", hashToken(token)).is("used_at", null).select("id")
        : db.from("demo_archive_links").update({ used_at }).eq("demo_event_id", source.demoId).eq("token_hash", hashToken(token)).is("used_at", null).select("id");
    },
    discard: () =>
      source.kind === "event"
        ? db.from("archive_links").delete().eq("token_hash", hashToken(token))
        : db.from("demo_archive_links").delete().eq("token_hash", hashToken(token)),
  };
}

export async function mintArchiveLink(source: ArchiveSource, orgId: string | null): Promise<string> {
  const token = randomBytes(32).toString("base64url");
  const db = createServiceClient();
  const { error } =
    source.kind === "event"
      ? await db.from("archive_links").insert({ event_id: source.eventId, org_id: orgId, token_hash: hashToken(token) })
      : await db.from("demo_archive_links").insert({ demo_event_id: source.demoId, token_hash: hashToken(token) });
  if (error) throw error;
  return token;
}

export async function discardArchiveLink(source: ArchiveSource, token: string): Promise<void> {
  await linkRow(source, token).discard();
}

export type ArchiveLinkState = "unused" | "spent" | "unknown";

export async function readArchiveLink(source: ArchiveSource, token: string): Promise<ArchiveLinkState> {
  const { data } = await linkRow(source, token).read();
  if (!data) return "unknown";
  return data.used_at ? "spent" : "unused";
}

export async function claimArchiveLink(
  source: ArchiveSource,
  token: string,
): Promise<"claimed" | ArchiveLinkState> {
  const { data, error } = await linkRow(source, token).spend();
  if (error) throw error;
  if (data && data.length === 1) return "claimed";
  const state = await readArchiveLink(source, token);
  return state === "unused" ? "unknown" : state;
}

what your browser loads

every page tells your browser where it may load anything from: ZIV and the services that run it. There are no analytics and no ads. Your browser receives this list as the Content-Security-Policy header, so you can check it yourself.

cookies §2privacy §3.3privacy §6updated November 24, 2026
lib/security-headers.ts
export function publicSecurityHeaders(env: SecurityHeaderEnv, { wasm = false }: { wasm?: boolean } = {}): SecurityHeader[] {
  const dev = env.NODE_ENV === "development";
  const media = origin(env.NEXT_PUBLIC_MEDIA_URL);
  const policy = csp({
    "default-src": ["'self'"],
    "script-src": ["'self'", "'unsafe-inline'", dev ? "'unsafe-eval'" : null, wasm ? "'wasm-unsafe-eval'" : null],
    "style-src": ["'self'", "'unsafe-inline'"],
    "img-src": ["'self'", "data:", "blob:", media],
    "media-src": ["'self'", "blob:", media],
    "font-src": ["'self'", "data:"],
    "connect-src": [
      "'self'",
      wasm ? "data:" : null,
      media,
      ...dbOrigins(env.NEXT_PUBLIC_DB_URL),
      ...storageOrigins(env.STORAGE_ENDPOINT, env.STORAGE_BUCKET),
    ],
    "worker-src": ["'self'", "blob:"],
    "frame-src": ["'none'"],
    "object-src": ["'none'"],
    "base-uri": ["'self'"],
    "form-action": ["'self'", origin(env.OPS_URL)],
    "frame-ancestors": ["'none'"],
  });
  return common(
    policy,
    "camera=(self), microphone=(self), fullscreen=(self), screen-wake-lock=(self), web-share=(self), clipboard-write=(self), geolocation=(), payment=(), usb=(), serial=(), bluetooth=(), hid=(), midi=()",
  );
}

when something breaks

when a page crashes on your phone or an upload doesn't reach us, your browser sends us a short note: which page, what went wrong, and for an upload how big the file was and how far it got. The note never carries the photo, its name, your IP address, or anything that says who you are, and it is deleted after 90 days.

privacy §3.3privacy §7updated November 25, 2026
lib/client-report.ts
export function pathOnly(raw: string): string {
  const path = raw.split(/[?#]/)[0] ?? "";
  return path.replace(/[^A-Za-z0-9/_.-]/g, "").slice(0, 200) || "/";
}

export function scrub(text: string, max: number): string {
  return text
    .replace(/[^\s@]+@[^\s@]+\.[^\s@]+/g, "[address]")
    .replace(/\?[^\s)'"]*/g, "")
    .slice(0, max);
}

export function coarseBrowser(ua: string | null): { browser: string; os: string } {
  const s = ua ?? "";
  const os = /iPhone|iPad|iPod/.test(s)
    ? "iOS"
    : /Android/.test(s)
      ? "Android"
      : /Mac OS X/.test(s)
        ? "macOS"
        : /Windows/.test(s)
          ? "Windows"
          : /Linux/.test(s)
            ? "Linux"
            : "other";
  const m =
    s.match(/(SamsungBrowser|Edg|OPR|Firefox|FxiOS|CriOS|Chrome)\/(\d+)/) ?? s.match(/Version\/(\d+).*(Safari)/);
  if (!m) return { browser: "other", os };
  return m[2] === "Safari" ? { browser: `Safari ${m[1]}`, os } : { browser: `${m[1]} ${m[2]}`, os };
}

export function reportRecord(r: ClientReport, userAgent: string | null): Record<string, unknown> {
  const where = { page: pathOnly(r.page), ...coarseBrowser(userAgent) };
  if (r.kind === "crash") {
    return {
      ...where,
      message: scrub(r.message, 500),
      stack: r.stack ? scrub(r.stack.split("\n").slice(0, 12).join("\n"), 3000) : null,
      digest: r.digest ?? null,
    };
  }
  return {
    ...where,
    outcome: r.outcome,
    reason: r.reason ?? null,
    put: r.put ?? null,
    fileSize: r.fileSize,
    fileType: r.fileType,
    progress: r.progress,
  };
}
why we work this wayprivacy policy