| .. | ||
| address.ts | 3.8K | |
| deno.json | 331B | |
| hash.ts | 434B | |
| limits.ts | 1009B | |
| manifest.test.mts | 1.7K | |
| manifest.ts | 4.0K | |
| mediatypes.ts | 1.5K | |
| mod.ts | 949B | |
| README.md | 1.6K | |
| types.ts | 17.0K | |
| version.test.mts | 454B | |
| version.ts | 142B |
@nzip/ shared
The runtime-agnostic contract between the nzip CLI and Worker.
Manifest canonicalization, content hashing, address/target parsing, and the wire types exchanged
over the API. Canonical JSON serialization lives in exactly one place
(manifest.ts) so the CLI and Worker can never disagree about a manifest hash.
This package uses only Web-standard APIs (crypto.subtle, TextEncoder/TextDecoder, JSON), so
the same code runs under Deno, Cloudflare Workers, Node.js, Bun, and browsers.
The wire contract also defines lifecycle-aware vault metadata (defaultVaults, per-vault
defaultTtl/effectiveDefaultTtl/defaultFor), resolved push retention (ttl and ttlSource),
and permanent app-origin reservations. These fields let agents inspect policy before mutating
hosting state instead of inferring defaults from names.
Install
deno add jsr:@nzip/shared
Use
import { canonicalManifestBytes, type Manifest, manifestHash, parseTarget } from "@nzip/shared";
const manifest: Manifest = {
v: 1,
files: {
"index.html": {
h: "…64-hex-sha256…",
s: 128,
ct: "text/html; charset=utf-8",
},
},
};
// Byte-identical on every runtime, which is what makes hashes agree across CLI and Worker.
const hash = await manifestHash(manifest);
const bytes = canonicalManifestBytes(manifest);
parseTarget("2a3f"); // { kind: "address", address: 10815 }
parseTarget("work:demo"); // { kind: "vaultAlias", vault: "work", alias: "demo" }
parseTarget("demo"); // { kind: "alias", alias: "demo" }
MIT licensed.