ProvenPin Install

JSZip archive round-trip: working versions (tested 2026-10-15)

Build a DEFLATE zip in memory with JSZip containing a nested folder, a text file and a binary file, then load it back, list entries and read contents as string and uint8array offline.

passed3 passed · 0 failed2026-10-15 22:58 UTC
Status
passed
Last passed
2026-10-15 22:58 UTC
Tests
3 / 3
Language
TypeScript
Runtime
node v22.23.3
pinned versions3
jszip@3.10.2@types/node@26.6.5tsx@4.23.15
run it
npm install --no-audit --no-fund --ignore-scripts=false
npm test
test environment
node v22.23.3
linux 6.17.0-1022-azure
x64
runner: github-actions 38820570375

The code

Exactly the files that passed. Your agent can pull them with get_recipe("jszip-archive-roundtrip") (install), or see them on GitHub.

package.json
{
  "name": "jszip-archive-roundtrip",
  "private": true,
  "type": "module",
  "scripts": {
    "test": "node --import tsx --test test/*.test.ts"
  },
  "dependencies": {
    "jszip": "3.10.2"
  },
  "devDependencies": {
    "@types/node": "26.6.5",
    "tsx": "4.23.15"
  }
}
src/archive.ts
import JSZip from "jszip";

export type ArchiveContents = {
  text: string;
  binary: Uint8Array;
  nested: string;
};

export async function buildArchive(): Promise<Uint8Array> {
  const zip = new JSZip();
  const folder = zip.folder("docs");
  if (!folder) {
    throw new Error("failed to create folder");
  }
  folder.file("readme.txt", "hello from the docs folder");
  zip.file("data.bin", new Uint8Array([0, 1, 2, 255, 254]));
  return zip.generateAsync({ type: "uint8array", compression: "DEFLATE" });
}

export async function listEntries(archive: Uint8Array): Promise<string[]> {
  const zip = await JSZip.loadAsync(archive);
  return Object.keys(zip.files).sort();
}

export async function readContents(archive: Uint8Array): Promise<ArchiveContents> {
  const zip = await JSZip.loadAsync(archive);

  const textFile = zip.file("docs/readme.txt");
  const binaryFile = zip.file("data.bin");
  if (!textFile || !binaryFile) {
    throw new Error("expected entries missing from archive");
  }

  const text = await textFile.async("string");
  const binary = await binaryFile.async("uint8array");
  const nested = await zip.folder("docs")!.file("readme.txt")!.async("string");

  return { text, binary, nested };
}
test/archive.test.ts
import { test } from "node:test";
import assert from "node:assert/strict";
import { buildArchive, listEntries, readContents } from "../src/archive.ts";
import JSZip from "jszip";

test("builds a zip and lists its entries", async () => {
  const archive = await buildArchive();
  assert.ok(archive instanceof Uint8Array);
  assert.ok(archive.length > 0);

  const entries = await listEntries(archive);
  assert.deepEqual(entries, ["data.bin", "docs/", "docs/readme.txt"]);
});

test("reads text and binary contents back", async () => {
  const archive = await buildArchive();
  const contents = await readContents(archive);

  assert.equal(contents.text, "hello from the docs folder");
  assert.equal(contents.nested, "hello from the docs folder");
  assert.ok(contents.binary instanceof Uint8Array);
  assert.deepEqual([...contents.binary], [0, 1, 2, 255, 254]);
});

test("preserves contents across a second round-trip", async () => {
  const archive = await buildArchive();
  const reloaded = await JSZip.loadAsync(archive);
  const regenerated = await reloaded.generateAsync({
    type: "uint8array",
    compression: "DEFLATE",
  });
  const contents = await readContents(regenerated);
  assert.deepEqual([...contents.binary], [0, 1, 2, 255, 254]);
});

Connect to ProvenPin

Add the free MCP server so your agent can pull this recipe and others like it. Same setup as the docs.

terminal
claude mcp add --transport http provenpin https://mcp.provenpin.com/mcp

Any other MCP client: Streamable HTTP at https://mcp.provenpin.com/mcp. No API key, no signup.