@cardanowall/sdk-ts 0.0.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ids/crockford-base32.ts","../../src/ids/prefixed-id.ts","../../src/ids/zod-schemas.ts"],"names":["z"],"mappings":";;;;;AAiBA,IAAM,QAAA,GAAW,kCAAA;AAIjB,IAAM,gBAA2B,MAAM;AACrC,EAAA,MAAM,QAAQ,IAAI,SAAA,CAAU,GAAG,CAAA,CAAE,KAAK,EAAE,CAAA;AACxC,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,QAAA,CAAS,QAAQ,CAAA,EAAA,EAAK;AACxC,IAAA,MAAM,EAAA,GAAK,QAAA,CAAS,UAAA,CAAW,CAAC,CAAA;AAChC,IAAA,KAAA,CAAM,EAAE,CAAA,GAAI,CAAA;AAEZ,IAAA,MAAM,KAAA,GAAQ,OAAO,YAAA,CAAa,EAAE,EAAE,WAAA,EAAY,CAAE,WAAW,CAAC,CAAA;AAChE,IAAA,KAAA,CAAM,KAAK,CAAA,GAAI,CAAA;AAAA,EACjB;AAEA,EAAA,KAAA,CAAM,GAAA,CAAI,UAAA,CAAW,CAAC,CAAC,CAAA,GAAI,CAAA;AAC3B,EAAA,KAAA,CAAM,GAAA,CAAI,UAAA,CAAW,CAAC,CAAC,CAAA,GAAI,CAAA;AAC3B,EAAA,KAAA,CAAM,GAAA,CAAI,UAAA,CAAW,CAAC,CAAC,CAAA,GAAI,CAAA;AAC3B,EAAA,KAAA,CAAM,GAAA,CAAI,UAAA,CAAW,CAAC,CAAC,CAAA,GAAI,CAAA;AAC3B,EAAA,KAAA,CAAM,GAAA,CAAI,UAAA,CAAW,CAAC,CAAC,CAAA,GAAI,CAAA;AAC3B,EAAA,KAAA,CAAM,GAAA,CAAI,UAAA,CAAW,CAAC,CAAC,CAAA,GAAI,CAAA;AAC3B,EAAA,OA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AA;AAC1C,EAAA,IAAI,CAAC,SAAA,CAAU,UAAA,CAAW,GAAG,MAAM,CAAA,CAAA,CAAG,GAAG,OAAO,KAAA;AAChD,EAAA,MAAM,IAAA,GAAO,SAAA,CAAU,KAAA,CAAM,MAAA,CAAO,SAAS,CAAC,CAAA;AAC9C,EAAA,IAAI,IAAA,CAAK,MAAA,KAAW,EAAA,EAAI,OAAO,KAAA;AAE/B,EAAA,OAAO,0BAAA,CAA2B,KAAK,IAAI,CAAA;AAC7C;ACxFA,IAAM,eAAA,GAAkB,wBAAA;AAEjB,IAAM,aAAA,GAAgB;AAEtB,IAAM,WAAA,GAAcA,KAAA,CACxB,MAAA,EAAO,CACP,KAAA,CAAM,IAAI,MAAA,CAAO,CAAA,CAAA,EAAI,aAAa,CAAA,CAAA,EAAI,eAAe,CAAA,CAAA,CAAG,GAAG,gBAAgB;AAEvE,IAAM,cAAA,GAAiB,CAAA,CAAA,EAAI,aAAa,CAAA,CAAA,EAAI,eAAe,CAAA,CAAA","file":"index.cjs","sourcesContent":["// Crockford Base32 codec for 16-byte UUID payloads (yielding 26-char strings).\n//\n// Alphabet per https://www.crockford.com/base32.html — `0123456789ABCDEFGHJKMNPQRSTVWXYZ`\n// (32 symbols; the letters I, L, O, U are intentionally excluded for visual\n// disambiguation against digits and to avoid accidental profanity in\n// generated identifiers).\n//\n// Encoding: 16 raw bytes (128 bits) packs into exactly 26 base32 symbols\n// (130 bits with 2 trailing zero-padding bits we drop on encode and\n// reconstruct on decode). No `=` padding character is emitted — UUID payloads\n// are fixed-width.\n//\n// Decoding: case-insensitive (per Crockford spec); we also tolerate the\n// disambiguation map I/L → 1, O → 0. The encoded length MUST be 26 chars;\n// rejection is explicit (callers downstream feed the bytes back into a UUIDv7\n// validator anyway, so we surface the length problem at the codec boundary).\n\nconst ALPHABET = '0123456789abcdefghjkmnpqrstvwxyz';\n\n// 256-entry decode table indexed by lowercased ASCII char code. -1 = invalid.\n// We populate it once at module load.\nconst DECODE_TABLE: Int8Array = (() => {\n const table = new Int8Array(128).fill(-1);\n for (let i = 0; i < ALPHABET.length; i++) {\n const ch = ALPHABET.charCodeAt(i);\n table[ch] = i;\n // Uppercase variant (Crockford accepts case-insensitive input).\n const upper = String.fromCharCode(ch).toUpperCase().charCodeAt(0);\n table[upper] = i;\n }\n // Crockford disambiguation: I, L → 1; O → 0; U is reserved (always invalid).\n table['I'.charCodeAt(0)] = 1;\n table['i'.charCodeAt(0)] = 1;\n table['L'.charCodeAt(0)] = 1;\n table['l'.charCodeAt(0)] = 1;\n table['O'.charCodeAt(0)] = 0;\n table['o'.charCodeAt(0)] = 0;\n return table;\n})();\n\nexport const CROCKFORD_ENCODED_LENGTH_FOR_UUID = 26;\n\n/**\n * Encode `bytes.length` raw bytes as a lowercase Crockford base32 string.\n * Output length is `ceil(bytes.length * 8 / 5)` — no `=` padding character.\n * For 16-byte UUIDs this produces 26 chars; for 32-byte API-key secrets it\n * produces 52 chars (256 bits of entropy, matching the Stripe / OpenAI /\n * Anthropic secret-key entropy class).\n */\nexport function encodeBytesVariableLength(bytes: Uint8Array): string {\n let bits = 0;\n let bitCount = 0;\n let out = '';\n for (let i = 0; i < bytes.length; i++) {\n bits = (bits << 8) | bytes[i]!;\n bitCount += 8;\n while (bitCount >= 5) {\n bitCount -= 5;\n const idx = (bits >>> bitCount) & 0x1f;\n out += ALPHABET[idx];\n }\n }\n if (bitCount > 0) {\n const idx = (bits << (5 - bitCount)) & 0x1f;\n out += ALPHABET[idx];\n }\n return out;\n}\n\n/**\n * Encode 16 raw bytes (a UUID payload) as a 26-char lowercase Crockford\n * base32 string. Throws if the input is not exactly 16 bytes.\n */\nexport function encodeBytes(bytes: Uint8Array): string {\n if (bytes.length !== 16) {\n throw new Error(`crockford-base32: expected 16 bytes, got ${bytes.length}`);\n }\n // 16 bytes × 8 = 128 bits → 26 × 5 = 130 bits; we pad the input with 2 zero\n // bits on the right, which simply means we treat byte[15] as occupying the\n // top 8 bits of a 10-bit window for the final two symbols.\n return encodeBytesVariableLength(bytes);\n}\n\n/**\n * Decode a 26-char Crockford base32 string back to 16 raw bytes.\n * Case-insensitive; accepts the I/L → 1, O → 0 disambiguation mappings.\n * Throws on wrong length, invalid characters, or non-zero pad bits.\n */\nexport function decodeBytes(encoded: string): Uint8Array {\n if (encoded.length !== CROCKFORD_ENCODED_LENGTH_FOR_UUID) {\n throw new Error(\n `crockford-base32: expected ${CROCKFORD_ENCODED_LENGTH_FOR_UUID}-char input, got ${encoded.length}`,\n );\n }\n const out = new Uint8Array(16);\n let bits = 0;\n let bitCount = 0;\n let outIdx = 0;\n for (let i = 0; i < encoded.length; i++) {\n const code = encoded.charCodeAt(i);\n const value = code < 128 ? DECODE_TABLE[code]! : -1;\n if (value < 0) {\n throw new Error(\n `crockford-base32: invalid character ${JSON.stringify(encoded[i])} at index ${i}`,\n );\n }\n bits = (bits << 5) | value;\n bitCount += 5;\n if (bitCount >= 8) {\n bitCount -= 8;\n out[outIdx++] = (bits >>> bitCount) & 0xff;\n }\n }\n // After 26 symbols × 5 = 130 bits consumed and 16 bytes × 8 = 128 bits\n // emitted, there should be exactly 2 trailing zero pad bits. Anything else\n // means the input wasn't produced by our encoder (or was tampered with).\n if (bitCount !== 2 || (bits & 0x3) !== 0) {\n throw new Error('crockford-base32: non-zero pad bits at end of input');\n }\n return out;\n}\n","// Stripe-style prefixed resource IDs. The Postgres column stays UUIDv7; the\n// wire form is `<prefix>_<26-char-crockford-base32>`. This module is the\n// only place that knows the byte-level encoding — everything else (Zod\n// schemas, route handlers, SDK types) consumes the helpers below.\n//\n// We intentionally do NOT bind the helpers to a closed prefix enum here: the\n// SDK is published as a versioned dependency and adding a new resource type\n// (e.g. `topup_*`) must not require an SDK bump just to validate the wire.\n// The helpers therefore take the prefix as a generic string parameter; the\n// per-resource Zod schemas in `./zod-schemas.ts` are the place to enumerate\n// the known prefixes for validation purposes.\n\nimport { decodeBytes, encodeBytes } from './crockford-base32';\n\n/**\n * Branded string type — `${prefix}_<26-base32-chars>`. The phantom `__brand`\n * field gives TypeScript a way to refuse a bare string at API boundaries\n * (`function fn(id: PrefixedId<'poe'>)`) while staying ABI-compatible with\n * `string` on the wire and in JSON serialisation.\n */\nexport type PrefixedId<P extends string> = `${P}_${string}` & { readonly __brand: P };\n\n// 32-char hex UUID without separators is what the encoder converts to bytes.\nconst UUID_RE_BYTES = /^[0-9a-f]{32}$/;\n\nfunction uuidStringToBytes(uuid: string): Uint8Array {\n // Accept canonical 8-4-4-4-12 hyphenated form (case-insensitive) only —\n // this is what every UUIDv4/v7 library produces and what Postgres returns\n // for the UUIDv7 columns. Anything else (no hyphens, wrong width, non-hex)\n // is rejected.\n const hex = uuid.replace(/-/g, '').toLowerCase();\n if (!UUID_RE_BYTES.test(hex) || uuid.replace(/[^-]/g, '').length !== 4) {\n throw new Error(`prefixed-id: not a canonical hyphenated UUID: ${JSON.stringify(uuid)}`);\n }\n const out = new Uint8Array(16);\n for (let i = 0; i < 16; i++) {\n out[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);\n }\n return out;\n}\n\nfunction bytesToUuidString(bytes: Uint8Array): string {\n if (bytes.length !== 16) {\n throw new Error(`prefixed-id: expected 16 decoded bytes, got ${bytes.length}`);\n }\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n}\n\n/**\n * Encode a bare canonical UUID string (8-4-4-4-12 hyphenated) into the\n * Stripe-style wire form `${prefix}_<crockford>`.\n */\nexport function encodePrefixedId<P extends string>(prefix: P, uuid: string): PrefixedId<P> {\n const bytes = uuidStringToBytes(uuid);\n const encoded = encodeBytes(bytes);\n return `${prefix}_${encoded}` as PrefixedId<P>;\n}\n\n/**\n * Decode a wire-format prefixed id back to the bare canonical UUID string.\n * Throws when the prefix does not match, the body is not 26 base32 chars,\n * or the encoded payload is malformed.\n */\nexport function decodePrefixedId<P extends string>(prefix: P, encoded: string): string {\n if (typeof encoded !== 'string') {\n throw new Error(`prefixed-id: expected string, got ${typeof encoded}`);\n }\n const sep = encoded.indexOf('_');\n if (sep < 0) {\n throw new Error(`prefixed-id: missing prefix separator in ${JSON.stringify(encoded)}`);\n }\n const actualPrefix = encoded.slice(0, sep);\n if (actualPrefix !== prefix) {\n throw new Error(\n `prefixed-id: expected prefix ${JSON.stringify(prefix)}, got ${JSON.stringify(actualPrefix)}`,\n );\n }\n const body = encoded.slice(sep + 1);\n const bytes = decodeBytes(body);\n return bytesToUuidString(bytes);\n}\n\n/**\n * Type guard. Cheap-check: matches the prefix and the lowercase Crockford\n * length, but does NOT validate the payload bytes round-trip. Use\n * `decodePrefixedId` when a full validation is required.\n */\nexport function isPrefixedId<P extends string>(\n prefix: P,\n candidate: unknown,\n): candidate is PrefixedId<P> {\n if (typeof candidate !== 'string') return false;\n if (!candidate.startsWith(`${prefix}_`)) return false;\n const body = candidate.slice(prefix.length + 1);\n if (body.length !== 26) return false;\n // Strict Crockford alphabet — no I, L, O, U; lowercase only on the wire.\n return /^[0-9a-hjkmnp-tv-z]{26}$/.test(body);\n}\n","// Zod schema gating the CIP-309 record id at every parse boundary (HTTP route\n// handlers, SDK input validation, OpenAPI registration).\n//\n// The regex is the strict Crockford-32 alphabet (lowercase only on the wire,\n// no I/L/O/U). This is stricter than `[0-9a-z]{26}` because it catches the\n// most common typo classes (`poe_…ol1u…`) at the parser rather than letting\n// them through to the decoder for a confusing `non-zero pad bits` error.\n\nimport { z } from 'zod';\n\nconst CROCKFORD_LOWER = '[0-9a-hjkmnp-tv-z]{26}';\n\nexport const POE_ID_PREFIX = 'poe' as const;\n\nexport const PoeIdSchema = z\n .string()\n .regex(new RegExp(`^${POE_ID_PREFIX}_${CROCKFORD_LOWER}$`), 'invalid poe id');\n\nexport const POE_ID_PATTERN = `^${POE_ID_PREFIX}_${CROCKFORD_LOWER}$`;\n"]}
1
+ {"version":3,"sources":["../../src/ids/crockford-base32.ts","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AAS,CAAC,CAAA;AAC9C,EAAA,IAAI,IAAA,CAAK,MAAA,KAAW,EAAA,EAAI,OAAO,KAAA;AAE/B,EAAA,OAAO,0BAAA,CAA2B,KAAK,IAAI,CAAA;AAC7C;ACxFA,IAAM,eAAA,GAAkB,wBAAA;AAEjB,IAAM,aAAA,GAAgB;AAEtB,IAAM,WAAA,GAAcA,KAAA,CACxB,MAAA,EAAO,CACP,KAAA,CAAM,IAAI,MAAA,CAAO,CAAA,CAAA,EAAI,aAAa,CAAA,CAAA,EAAI,eAAe,CAAA,CAAA,CAAG,GAAG,gBAAgB;AAEvE,IAAM,cAAA,GAAiB,CAAA,CAAA,EAAI,aAAa,CAAA,CAAA,EAAI,eAAe,CAAA,CAAA","file":"index.cjs","sourcesContent":["// Crockford Base32 codec for 16-byte UUID payloads (yielding 26-char strings).\n//\n// Alphabet per https://www.crockford.com/base32.html — `0123456789ABCDEFGHJKMNPQRSTVWXYZ`\n// (32 symbols; the letters I, L, O, U are intentionally excluded for visual\n// disambiguation against digits and to avoid accidental profanity in\n// generated identifiers).\n//\n// Encoding: 16 raw bytes (128 bits) packs into exactly 26 base32 symbols\n// (130 bits with 2 trailing zero-padding bits we drop on encode and\n// reconstruct on decode). No `=` padding character is emitted — UUID payloads\n// are fixed-width.\n//\n// Decoding: case-insensitive (per Crockford spec); we also tolerate the\n// disambiguation map I/L → 1, O → 0. The encoded length MUST be 26 chars;\n// rejection is explicit (callers downstream feed the bytes back into a UUIDv7\n// validator anyway, so we surface the length problem at the codec boundary).\n\nconst ALPHABET = '0123456789abcdefghjkmnpqrstvwxyz';\n\n// 256-entry decode table indexed by lowercased ASCII char code. -1 = invalid.\n// We populate it once at module load.\nconst DECODE_TABLE: Int8Array = (() => {\n const table = new Int8Array(128).fill(-1);\n for (let i = 0; i < ALPHABET.length; i++) {\n const ch = ALPHABET.charCodeAt(i);\n table[ch] = i;\n // Uppercase variant (Crockford accepts case-insensitive input).\n const upper = String.fromCharCode(ch).toUpperCase().charCodeAt(0);\n table[upper] = i;\n }\n // Crockford disambiguation: I, L → 1; O → 0; U is reserved (always invalid).\n table['I'.charCodeAt(0)] = 1;\n table['i'.charCodeAt(0)] = 1;\n table['L'.charCodeAt(0)] = 1;\n table['l'.charCodeAt(0)] = 1;\n table['O'.charCodeAt(0)] = 0;\n table['o'.charCodeAt(0)] = 0;\n return table;\n})();\n\nexport const CROCKFORD_ENCODED_LENGTH_FOR_UUID = 26;\n\n/**\n * Encode `bytes.length` raw bytes as a lowercase Crockford base32 string.\n * Output length is `ceil(bytes.length * 8 / 5)` — no `=` padding character.\n * For 16-byte UUIDs this produces 26 chars; for 32-byte API-key secrets it\n * produces 52 chars (256 bits of entropy, matching the Stripe / OpenAI /\n * Anthropic secret-key entropy class).\n */\nexport function encodeBytesVariableLength(bytes: Uint8Array): string {\n let bits = 0;\n let bitCount = 0;\n let out = '';\n for (let i = 0; i < bytes.length; i++) {\n bits = (bits << 8) | bytes[i]!;\n bitCount += 8;\n while (bitCount >= 5) {\n bitCount -= 5;\n const idx = (bits >>> bitCount) & 0x1f;\n out += ALPHABET[idx];\n }\n }\n if (bitCount > 0) {\n const idx = (bits << (5 - bitCount)) & 0x1f;\n out += ALPHABET[idx];\n }\n return out;\n}\n\n/**\n * Encode 16 raw bytes (a UUID payload) as a 26-char lowercase Crockford\n * base32 string. Throws if the input is not exactly 16 bytes.\n */\nexport function encodeBytes(bytes: Uint8Array): string {\n if (bytes.length !== 16) {\n throw new Error(`crockford-base32: expected 16 bytes, got ${bytes.length}`);\n }\n // 16 bytes × 8 = 128 bits → 26 × 5 = 130 bits; we pad the input with 2 zero\n // bits on the right, which simply means we treat byte[15] as occupying the\n // top 8 bits of a 10-bit window for the final two symbols.\n return encodeBytesVariableLength(bytes);\n}\n\n/**\n * Decode a 26-char Crockford base32 string back to 16 raw bytes.\n * Case-insensitive; accepts the I/L → 1, O → 0 disambiguation mappings.\n * Throws on wrong length, invalid characters, or non-zero pad bits.\n */\nexport function decodeBytes(encoded: string): Uint8Array {\n if (encoded.length !== CROCKFORD_ENCODED_LENGTH_FOR_UUID) {\n throw new Error(\n `crockford-base32: expected ${CROCKFORD_ENCODED_LENGTH_FOR_UUID}-char input, got ${encoded.length}`,\n );\n }\n const out = new Uint8Array(16);\n let bits = 0;\n let bitCount = 0;\n let outIdx = 0;\n for (let i = 0; i < encoded.length; i++) {\n const code = encoded.charCodeAt(i);\n const value = code < 128 ? DECODE_TABLE[code]! : -1;\n if (value < 0) {\n throw new Error(\n `crockford-base32: invalid character ${JSON.stringify(encoded[i])} at index ${i}`,\n );\n }\n bits = (bits << 5) | value;\n bitCount += 5;\n if (bitCount >= 8) {\n bitCount -= 8;\n out[outIdx++] = (bits >>> bitCount) & 0xff;\n }\n }\n // After 26 symbols × 5 = 130 bits consumed and 16 bytes × 8 = 128 bits\n // emitted, there should be exactly 2 trailing zero pad bits. Anything else\n // means the input wasn't produced by our encoder (or was tampered with).\n if (bitCount !== 2 || (bits & 0x3) !== 0) {\n throw new Error('crockford-base32: non-zero pad bits at end of input');\n }\n return out;\n}\n","// Stripe-style prefixed resource IDs. The Postgres column stays UUIDv7; the\n// wire form is `<prefix>_<26-char-crockford-base32>`. This module is the\n// only place that knows the byte-level encoding — everything else (Zod\n// schemas, route handlers, SDK types) consumes the helpers below.\n//\n// We intentionally do NOT bind the helpers to a closed prefix enum here: the\n// SDK is published as a versioned dependency and adding a new resource type\n// (e.g. `topup_*`) must not require an SDK bump just to validate the wire.\n// The helpers therefore take the prefix as a generic string parameter; the\n// per-resource Zod schemas in `./zod-schemas.ts` are the place to enumerate\n// the known prefixes for validation purposes.\n\nimport { decodeBytes, encodeBytes } from './crockford-base32';\n\n/**\n * Branded string type — `${prefix}_<26-base32-chars>`. The phantom `__brand`\n * field gives TypeScript a way to refuse a bare string at API boundaries\n * (`function fn(id: PrefixedId<'poe'>)`) while staying ABI-compatible with\n * `string` on the wire and in JSON serialisation.\n */\nexport type PrefixedId<P extends string> = `${P}_${string}` & { readonly __brand: P };\n\n// 32-char hex UUID without separators is what the encoder converts to bytes.\nconst UUID_RE_BYTES = /^[0-9a-f]{32}$/;\n\nfunction uuidStringToBytes(uuid: string): Uint8Array {\n // Accept canonical 8-4-4-4-12 hyphenated form (case-insensitive) only —\n // this is what every UUIDv4/v7 library produces and what Postgres returns\n // for the UUIDv7 columns. Anything else (no hyphens, wrong width, non-hex)\n // is rejected.\n const hex = uuid.replace(/-/g, '').toLowerCase();\n if (!UUID_RE_BYTES.test(hex) || uuid.replace(/[^-]/g, '').length !== 4) {\n throw new Error(`prefixed-id: not a canonical hyphenated UUID: ${JSON.stringify(uuid)}`);\n }\n const out = new Uint8Array(16);\n for (let i = 0; i < 16; i++) {\n out[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);\n }\n return out;\n}\n\nfunction bytesToUuidString(bytes: Uint8Array): string {\n if (bytes.length !== 16) {\n throw new Error(`prefixed-id: expected 16 decoded bytes, got ${bytes.length}`);\n }\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n}\n\n/**\n * Encode a bare canonical UUID string (8-4-4-4-12 hyphenated) into the\n * Stripe-style wire form `${prefix}_<crockford>`.\n */\nexport function encodePrefixedId<P extends string>(prefix: P, uuid: string): PrefixedId<P> {\n const bytes = uuidStringToBytes(uuid);\n const encoded = encodeBytes(bytes);\n return `${prefix}_${encoded}` as PrefixedId<P>;\n}\n\n/**\n * Decode a wire-format prefixed id back to the bare canonical UUID string.\n * Throws when the prefix does not match, the body is not 26 base32 chars,\n * or the encoded payload is malformed.\n */\nexport function decodePrefixedId<P extends string>(prefix: P, encoded: string): string {\n if (typeof encoded !== 'string') {\n throw new Error(`prefixed-id: expected string, got ${typeof encoded}`);\n }\n const sep = encoded.indexOf('_');\n if (sep < 0) {\n throw new Error(`prefixed-id: missing prefix separator in ${JSON.stringify(encoded)}`);\n }\n const actualPrefix = encoded.slice(0, sep);\n if (actualPrefix !== prefix) {\n throw new Error(\n `prefixed-id: expected prefix ${JSON.stringify(prefix)}, got ${JSON.stringify(actualPrefix)}`,\n );\n }\n const body = encoded.slice(sep + 1);\n const bytes = decodeBytes(body);\n return bytesToUuidString(bytes);\n}\n\n/**\n * Type guard. Cheap-check: matches the prefix and the lowercase Crockford\n * length, but does NOT validate the payload bytes round-trip. Use\n * `decodePrefixedId` when a full validation is required.\n */\nexport function isPrefixedId<P extends string>(\n prefix: P,\n candidate: unknown,\n): candidate is PrefixedId<P> {\n if (typeof candidate !== 'string') return false;\n if (!candidate.startsWith(`${prefix}_`)) return false;\n const body = candidate.slice(prefix.length + 1);\n if (body.length !== 26) return false;\n // Strict Crockford alphabet — no I, L, O, U; lowercase only on the wire.\n return /^[0-9a-hjkmnp-tv-z]{26}$/.test(body);\n}\n","// Zod schema gating the Label 309 record id at every parse boundary (HTTP route\n// handlers, SDK input validation, OpenAPI registration).\n//\n// The regex is the strict Crockford-32 alphabet (lowercase only on the wire,\n// no I/L/O/U). This is stricter than `[0-9a-z]{26}` because it catches the\n// most common typo classes (`poe_…ol1u…`) at the parser rather than letting\n// them through to the decoder for a confusing `non-zero pad bits` error.\n\nimport { z } from 'zod';\n\nconst CROCKFORD_LOWER = '[0-9a-hjkmnp-tv-z]{26}';\n\nexport const POE_ID_PREFIX = 'poe' as const;\n\nexport const PoeIdSchema = z\n .string()\n .regex(new RegExp(`^${POE_ID_PREFIX}_${CROCKFORD_LOWER}$`), 'invalid poe id');\n\nexport const POE_ID_PATTERN = `^${POE_ID_PREFIX}_${CROCKFORD_LOWER}$`;\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ids/crockford-base32.ts","../../src/ids/prefixed-id.ts","../../src/ids/zod-schemas.ts"],"names":[],"mappings":";;;AAiBA,IAAM,QAAA,GAAW,kCAAA;AAIjB,IAAM,gBAA2B,MAAM;AACrC,EAAA,MAAM,QAAQ,IAAI,SAAA,C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,GAAkB,wBAAA;AAEjB,IAAM,aAAA,GAAgB;AAEtB,IAAM,WAAA,GAAc,CAAA,CACxB,MAAA,EAAO,CACP,KAAA,CAAM,IAAI,MAAA,CAAO,CAAA,CAAA,EAAI,aAAa,CAAA,CAAA,EAAI,eAAe,CAAA,CAAA,CAAG,GAAG,gBAAgB;AAEvE,IAAM,cAAA,GAAiB,CAAA,CAAA,EAAI,aAAa,CAAA,CAAA,EAAI,eAAe,CAAA,CAAA","file":"index.js","sourcesContent":["// Crockford Base32 codec for 16-byte UUID payloads (yielding 26-char strings).\n//\n// Alphabet per https://www.crockford.com/base32.html — `0123456789ABCDEFGHJKMNPQRSTVWXYZ`\n// (32 symbols; the letters I, L, O, U are intentionally excluded for visual\n// disambiguation against digits and to avoid accidental profanity in\n// generated identifiers).\n//\n// Encoding: 16 raw bytes (128 bits) packs into exactly 26 base32 symbols\n// (130 bits with 2 trailing zero-padding bits we drop on encode and\n// reconstruct on decode). No `=` padding character is emitted — UUID payloads\n// are fixed-width.\n//\n// Decoding: case-insensitive (per Crockford spec); we also tolerate the\n// disambiguation map I/L → 1, O → 0. The encoded length MUST be 26 chars;\n// rejection is explicit (callers downstream feed the bytes back into a UUIDv7\n// validator anyway, so we surface the length problem at the codec boundary).\n\nconst ALPHABET = '0123456789abcdefghjkmnpqrstvwxyz';\n\n// 256-entry decode table indexed by lowercased ASCII char code. -1 = invalid.\n// We populate it once at module load.\nconst DECODE_TABLE: Int8Array = (() => {\n const table = new Int8Array(128).fill(-1);\n for (let i = 0; i < ALPHABET.length; i++) {\n const ch = ALPHABET.charCodeAt(i);\n table[ch] = i;\n // Uppercase variant (Crockford accepts case-insensitive input).\n const upper = String.fromCharCode(ch).toUpperCase().charCodeAt(0);\n table[upper] = i;\n }\n // Crockford disambiguation: I, L → 1; O → 0; U is reserved (always invalid).\n table['I'.charCodeAt(0)] = 1;\n table['i'.charCodeAt(0)] = 1;\n table['L'.charCodeAt(0)] = 1;\n table['l'.charCodeAt(0)] = 1;\n table['O'.charCodeAt(0)] = 0;\n table['o'.charCodeAt(0)] = 0;\n return table;\n})();\n\nexport const CROCKFORD_ENCODED_LENGTH_FOR_UUID = 26;\n\n/**\n * Encode `bytes.length` raw bytes as a lowercase Crockford base32 string.\n * Output length is `ceil(bytes.length * 8 / 5)` — no `=` padding character.\n * For 16-byte UUIDs this produces 26 chars; for 32-byte API-key secrets it\n * produces 52 chars (256 bits of entropy, matching the Stripe / OpenAI /\n * Anthropic secret-key entropy class).\n */\nexport function encodeBytesVariableLength(bytes: Uint8Array): string {\n let bits = 0;\n let bitCount = 0;\n let out = '';\n for (let i = 0; i < bytes.length; i++) {\n bits = (bits << 8) | bytes[i]!;\n bitCount += 8;\n while (bitCount >= 5) {\n bitCount -= 5;\n const idx = (bits >>> bitCount) & 0x1f;\n out += ALPHABET[idx];\n }\n }\n if (bitCount > 0) {\n const idx = (bits << (5 - bitCount)) & 0x1f;\n out += ALPHABET[idx];\n }\n return out;\n}\n\n/**\n * Encode 16 raw bytes (a UUID payload) as a 26-char lowercase Crockford\n * base32 string. Throws if the input is not exactly 16 bytes.\n */\nexport function encodeBytes(bytes: Uint8Array): string {\n if (bytes.length !== 16) {\n throw new Error(`crockford-base32: expected 16 bytes, got ${bytes.length}`);\n }\n // 16 bytes × 8 = 128 bits → 26 × 5 = 130 bits; we pad the input with 2 zero\n // bits on the right, which simply means we treat byte[15] as occupying the\n // top 8 bits of a 10-bit window for the final two symbols.\n return encodeBytesVariableLength(bytes);\n}\n\n/**\n * Decode a 26-char Crockford base32 string back to 16 raw bytes.\n * Case-insensitive; accepts the I/L → 1, O → 0 disambiguation mappings.\n * Throws on wrong length, invalid characters, or non-zero pad bits.\n */\nexport function decodeBytes(encoded: string): Uint8Array {\n if (encoded.length !== CROCKFORD_ENCODED_LENGTH_FOR_UUID) {\n throw new Error(\n `crockford-base32: expected ${CROCKFORD_ENCODED_LENGTH_FOR_UUID}-char input, got ${encoded.length}`,\n );\n }\n const out = new Uint8Array(16);\n let bits = 0;\n let bitCount = 0;\n let outIdx = 0;\n for (let i = 0; i < encoded.length; i++) {\n const code = encoded.charCodeAt(i);\n const value = code < 128 ? DECODE_TABLE[code]! : -1;\n if (value < 0) {\n throw new Error(\n `crockford-base32: invalid character ${JSON.stringify(encoded[i])} at index ${i}`,\n );\n }\n bits = (bits << 5) | value;\n bitCount += 5;\n if (bitCount >= 8) {\n bitCount -= 8;\n out[outIdx++] = (bits >>> bitCount) & 0xff;\n }\n }\n // After 26 symbols × 5 = 130 bits consumed and 16 bytes × 8 = 128 bits\n // emitted, there should be exactly 2 trailing zero pad bits. Anything else\n // means the input wasn't produced by our encoder (or was tampered with).\n if (bitCount !== 2 || (bits & 0x3) !== 0) {\n throw new Error('crockford-base32: non-zero pad bits at end of input');\n }\n return out;\n}\n","// Stripe-style prefixed resource IDs. The Postgres column stays UUIDv7; the\n// wire form is `<prefix>_<26-char-crockford-base32>`. This module is the\n// only place that knows the byte-level encoding — everything else (Zod\n// schemas, route handlers, SDK types) consumes the helpers below.\n//\n// We intentionally do NOT bind the helpers to a closed prefix enum here: the\n// SDK is published as a versioned dependency and adding a new resource type\n// (e.g. `topup_*`) must not require an SDK bump just to validate the wire.\n// The helpers therefore take the prefix as a generic string parameter; the\n// per-resource Zod schemas in `./zod-schemas.ts` are the place to enumerate\n// the known prefixes for validation purposes.\n\nimport { decodeBytes, encodeBytes } from './crockford-base32';\n\n/**\n * Branded string type — `${prefix}_<26-base32-chars>`. The phantom `__brand`\n * field gives TypeScript a way to refuse a bare string at API boundaries\n * (`function fn(id: PrefixedId<'poe'>)`) while staying ABI-compatible with\n * `string` on the wire and in JSON serialisation.\n */\nexport type PrefixedId<P extends string> = `${P}_${string}` & { readonly __brand: P };\n\n// 32-char hex UUID without separators is what the encoder converts to bytes.\nconst UUID_RE_BYTES = /^[0-9a-f]{32}$/;\n\nfunction uuidStringToBytes(uuid: string): Uint8Array {\n // Accept canonical 8-4-4-4-12 hyphenated form (case-insensitive) only —\n // this is what every UUIDv4/v7 library produces and what Postgres returns\n // for the UUIDv7 columns. Anything else (no hyphens, wrong width, non-hex)\n // is rejected.\n const hex = uuid.replace(/-/g, '').toLowerCase();\n if (!UUID_RE_BYTES.test(hex) || uuid.replace(/[^-]/g, '').length !== 4) {\n throw new Error(`prefixed-id: not a canonical hyphenated UUID: ${JSON.stringify(uuid)}`);\n }\n const out = new Uint8Array(16);\n for (let i = 0; i < 16; i++) {\n out[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);\n }\n return out;\n}\n\nfunction bytesToUuidString(bytes: Uint8Array): string {\n if (bytes.length !== 16) {\n throw new Error(`prefixed-id: expected 16 decoded bytes, got ${bytes.length}`);\n }\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n}\n\n/**\n * Encode a bare canonical UUID string (8-4-4-4-12 hyphenated) into the\n * Stripe-style wire form `${prefix}_<crockford>`.\n */\nexport function encodePrefixedId<P extends string>(prefix: P, uuid: string): PrefixedId<P> {\n const bytes = uuidStringToBytes(uuid);\n const encoded = encodeBytes(bytes);\n return `${prefix}_${encoded}` as PrefixedId<P>;\n}\n\n/**\n * Decode a wire-format prefixed id back to the bare canonical UUID string.\n * Throws when the prefix does not match, the body is not 26 base32 chars,\n * or the encoded payload is malformed.\n */\nexport function decodePrefixedId<P extends string>(prefix: P, encoded: string): string {\n if (typeof encoded !== 'string') {\n throw new Error(`prefixed-id: expected string, got ${typeof encoded}`);\n }\n const sep = encoded.indexOf('_');\n if (sep < 0) {\n throw new Error(`prefixed-id: missing prefix separator in ${JSON.stringify(encoded)}`);\n }\n const actualPrefix = encoded.slice(0, sep);\n if (actualPrefix !== prefix) {\n throw new Error(\n `prefixed-id: expected prefix ${JSON.stringify(prefix)}, got ${JSON.stringify(actualPrefix)}`,\n );\n }\n const body = encoded.slice(sep + 1);\n const bytes = decodeBytes(body);\n return bytesToUuidString(bytes);\n}\n\n/**\n * Type guard. Cheap-check: matches the prefix and the lowercase Crockford\n * length, but does NOT validate the payload bytes round-trip. Use\n * `decodePrefixedId` when a full validation is required.\n */\nexport function isPrefixedId<P extends string>(\n prefix: P,\n candidate: unknown,\n): candidate is PrefixedId<P> {\n if (typeof candidate !== 'string') return false;\n if (!candidate.startsWith(`${prefix}_`)) return false;\n const body = candidate.slice(prefix.length + 1);\n if (body.length !== 26) return false;\n // Strict Crockford alphabet — no I, L, O, U; lowercase only on the wire.\n return /^[0-9a-hjkmnp-tv-z]{26}$/.test(body);\n}\n","// Zod schema gating the CIP-309 record id at every parse boundary (HTTP route\n// handlers, SDK input validation, OpenAPI registration).\n//\n// The regex is the strict Crockford-32 alphabet (lowercase only on the wire,\n// no I/L/O/U). This is stricter than `[0-9a-z]{26}` because it catches the\n// most common typo classes (`poe_…ol1u…`) at the parser rather than letting\n// them through to the decoder for a confusing `non-zero pad bits` error.\n\nimport { z } from 'zod';\n\nconst CROCKFORD_LOWER = '[0-9a-hjkmnp-tv-z]{26}';\n\nexport const POE_ID_PREFIX = 'poe' as const;\n\nexport const PoeIdSchema = z\n .string()\n .regex(new RegExp(`^${POE_ID_PREFIX}_${CROCKFORD_LOWER}$`), 'invalid poe id');\n\nexport const POE_ID_PATTERN = `^${POE_ID_PREFIX}_${CROCKFORD_LOWER}$`;\n"]}
1
+ {"version":3,"sources":["../../src/ids/crockford-base32.ts","../../src/ids/prefixed-id.ts","../../src/ids/zod-schemas.ts"],"names":[],"mappings":";;;AAiBA,IAAM,QAAA,GAAW,kCAAA;AAIjB,IAAM,gBAA2B,MAAM;AACrC,EAAA,MAAM,QAAQ,IAAI,SAAA,CAAU,GAAG,CAAA,CAAE,KAAK,EAAE,CAAA;AACxC,EAAA,KAAA,IAAS,CAAA,GAAI,CAAA,EAAG,CAAA,GAAI,QAAA,CAAS,QAAQ,CAAA,EAAA,EAAK;AACxC,IAAA,MAAM,EAAA,GAAK,QAAA,CA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AA,CAAA,CAAG,GAAG,gBAAgB;AAEvE,IAAM,cAAA,GAAiB,CAAA,CAAA,EAAI,aAAa,CAAA,CAAA,EAAI,eAAe,CAAA,CAAA","file":"index.js","sourcesContent":["// Crockford Base32 codec for 16-byte UUID payloads (yielding 26-char strings).\n//\n// Alphabet per https://www.crockford.com/base32.html — `0123456789ABCDEFGHJKMNPQRSTVWXYZ`\n// (32 symbols; the letters I, L, O, U are intentionally excluded for visual\n// disambiguation against digits and to avoid accidental profanity in\n// generated identifiers).\n//\n// Encoding: 16 raw bytes (128 bits) packs into exactly 26 base32 symbols\n// (130 bits with 2 trailing zero-padding bits we drop on encode and\n// reconstruct on decode). No `=` padding character is emitted — UUID payloads\n// are fixed-width.\n//\n// Decoding: case-insensitive (per Crockford spec); we also tolerate the\n// disambiguation map I/L → 1, O → 0. The encoded length MUST be 26 chars;\n// rejection is explicit (callers downstream feed the bytes back into a UUIDv7\n// validator anyway, so we surface the length problem at the codec boundary).\n\nconst ALPHABET = '0123456789abcdefghjkmnpqrstvwxyz';\n\n// 256-entry decode table indexed by lowercased ASCII char code. -1 = invalid.\n// We populate it once at module load.\nconst DECODE_TABLE: Int8Array = (() => {\n const table = new Int8Array(128).fill(-1);\n for (let i = 0; i < ALPHABET.length; i++) {\n const ch = ALPHABET.charCodeAt(i);\n table[ch] = i;\n // Uppercase variant (Crockford accepts case-insensitive input).\n const upper = String.fromCharCode(ch).toUpperCase().charCodeAt(0);\n table[upper] = i;\n }\n // Crockford disambiguation: I, L → 1; O → 0; U is reserved (always invalid).\n table['I'.charCodeAt(0)] = 1;\n table['i'.charCodeAt(0)] = 1;\n table['L'.charCodeAt(0)] = 1;\n table['l'.charCodeAt(0)] = 1;\n table['O'.charCodeAt(0)] = 0;\n table['o'.charCodeAt(0)] = 0;\n return table;\n})();\n\nexport const CROCKFORD_ENCODED_LENGTH_FOR_UUID = 26;\n\n/**\n * Encode `bytes.length` raw bytes as a lowercase Crockford base32 string.\n * Output length is `ceil(bytes.length * 8 / 5)` — no `=` padding character.\n * For 16-byte UUIDs this produces 26 chars; for 32-byte API-key secrets it\n * produces 52 chars (256 bits of entropy, matching the Stripe / OpenAI /\n * Anthropic secret-key entropy class).\n */\nexport function encodeBytesVariableLength(bytes: Uint8Array): string {\n let bits = 0;\n let bitCount = 0;\n let out = '';\n for (let i = 0; i < bytes.length; i++) {\n bits = (bits << 8) | bytes[i]!;\n bitCount += 8;\n while (bitCount >= 5) {\n bitCount -= 5;\n const idx = (bits >>> bitCount) & 0x1f;\n out += ALPHABET[idx];\n }\n }\n if (bitCount > 0) {\n const idx = (bits << (5 - bitCount)) & 0x1f;\n out += ALPHABET[idx];\n }\n return out;\n}\n\n/**\n * Encode 16 raw bytes (a UUID payload) as a 26-char lowercase Crockford\n * base32 string. Throws if the input is not exactly 16 bytes.\n */\nexport function encodeBytes(bytes: Uint8Array): string {\n if (bytes.length !== 16) {\n throw new Error(`crockford-base32: expected 16 bytes, got ${bytes.length}`);\n }\n // 16 bytes × 8 = 128 bits → 26 × 5 = 130 bits; we pad the input with 2 zero\n // bits on the right, which simply means we treat byte[15] as occupying the\n // top 8 bits of a 10-bit window for the final two symbols.\n return encodeBytesVariableLength(bytes);\n}\n\n/**\n * Decode a 26-char Crockford base32 string back to 16 raw bytes.\n * Case-insensitive; accepts the I/L → 1, O → 0 disambiguation mappings.\n * Throws on wrong length, invalid characters, or non-zero pad bits.\n */\nexport function decodeBytes(encoded: string): Uint8Array {\n if (encoded.length !== CROCKFORD_ENCODED_LENGTH_FOR_UUID) {\n throw new Error(\n `crockford-base32: expected ${CROCKFORD_ENCODED_LENGTH_FOR_UUID}-char input, got ${encoded.length}`,\n );\n }\n const out = new Uint8Array(16);\n let bits = 0;\n let bitCount = 0;\n let outIdx = 0;\n for (let i = 0; i < encoded.length; i++) {\n const code = encoded.charCodeAt(i);\n const value = code < 128 ? DECODE_TABLE[code]! : -1;\n if (value < 0) {\n throw new Error(\n `crockford-base32: invalid character ${JSON.stringify(encoded[i])} at index ${i}`,\n );\n }\n bits = (bits << 5) | value;\n bitCount += 5;\n if (bitCount >= 8) {\n bitCount -= 8;\n out[outIdx++] = (bits >>> bitCount) & 0xff;\n }\n }\n // After 26 symbols × 5 = 130 bits consumed and 16 bytes × 8 = 128 bits\n // emitted, there should be exactly 2 trailing zero pad bits. Anything else\n // means the input wasn't produced by our encoder (or was tampered with).\n if (bitCount !== 2 || (bits & 0x3) !== 0) {\n throw new Error('crockford-base32: non-zero pad bits at end of input');\n }\n return out;\n}\n","// Stripe-style prefixed resource IDs. The Postgres column stays UUIDv7; the\n// wire form is `<prefix>_<26-char-crockford-base32>`. This module is the\n// only place that knows the byte-level encoding — everything else (Zod\n// schemas, route handlers, SDK types) consumes the helpers below.\n//\n// We intentionally do NOT bind the helpers to a closed prefix enum here: the\n// SDK is published as a versioned dependency and adding a new resource type\n// (e.g. `topup_*`) must not require an SDK bump just to validate the wire.\n// The helpers therefore take the prefix as a generic string parameter; the\n// per-resource Zod schemas in `./zod-schemas.ts` are the place to enumerate\n// the known prefixes for validation purposes.\n\nimport { decodeBytes, encodeBytes } from './crockford-base32';\n\n/**\n * Branded string type — `${prefix}_<26-base32-chars>`. The phantom `__brand`\n * field gives TypeScript a way to refuse a bare string at API boundaries\n * (`function fn(id: PrefixedId<'poe'>)`) while staying ABI-compatible with\n * `string` on the wire and in JSON serialisation.\n */\nexport type PrefixedId<P extends string> = `${P}_${string}` & { readonly __brand: P };\n\n// 32-char hex UUID without separators is what the encoder converts to bytes.\nconst UUID_RE_BYTES = /^[0-9a-f]{32}$/;\n\nfunction uuidStringToBytes(uuid: string): Uint8Array {\n // Accept canonical 8-4-4-4-12 hyphenated form (case-insensitive) only —\n // this is what every UUIDv4/v7 library produces and what Postgres returns\n // for the UUIDv7 columns. Anything else (no hyphens, wrong width, non-hex)\n // is rejected.\n const hex = uuid.replace(/-/g, '').toLowerCase();\n if (!UUID_RE_BYTES.test(hex) || uuid.replace(/[^-]/g, '').length !== 4) {\n throw new Error(`prefixed-id: not a canonical hyphenated UUID: ${JSON.stringify(uuid)}`);\n }\n const out = new Uint8Array(16);\n for (let i = 0; i < 16; i++) {\n out[i] = parseInt(hex.slice(i * 2, i * 2 + 2), 16);\n }\n return out;\n}\n\nfunction bytesToUuidString(bytes: Uint8Array): string {\n if (bytes.length !== 16) {\n throw new Error(`prefixed-id: expected 16 decoded bytes, got ${bytes.length}`);\n }\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, '0')).join('');\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n}\n\n/**\n * Encode a bare canonical UUID string (8-4-4-4-12 hyphenated) into the\n * Stripe-style wire form `${prefix}_<crockford>`.\n */\nexport function encodePrefixedId<P extends string>(prefix: P, uuid: string): PrefixedId<P> {\n const bytes = uuidStringToBytes(uuid);\n const encoded = encodeBytes(bytes);\n return `${prefix}_${encoded}` as PrefixedId<P>;\n}\n\n/**\n * Decode a wire-format prefixed id back to the bare canonical UUID string.\n * Throws when the prefix does not match, the body is not 26 base32 chars,\n * or the encoded payload is malformed.\n */\nexport function decodePrefixedId<P extends string>(prefix: P, encoded: string): string {\n if (typeof encoded !== 'string') {\n throw new Error(`prefixed-id: expected string, got ${typeof encoded}`);\n }\n const sep = encoded.indexOf('_');\n if (sep < 0) {\n throw new Error(`prefixed-id: missing prefix separator in ${JSON.stringify(encoded)}`);\n }\n const actualPrefix = encoded.slice(0, sep);\n if (actualPrefix !== prefix) {\n throw new Error(\n `prefixed-id: expected prefix ${JSON.stringify(prefix)}, got ${JSON.stringify(actualPrefix)}`,\n );\n }\n const body = encoded.slice(sep + 1);\n const bytes = decodeBytes(body);\n return bytesToUuidString(bytes);\n}\n\n/**\n * Type guard. Cheap-check: matches the prefix and the lowercase Crockford\n * length, but does NOT validate the payload bytes round-trip. Use\n * `decodePrefixedId` when a full validation is required.\n */\nexport function isPrefixedId<P extends string>(\n prefix: P,\n candidate: unknown,\n): candidate is PrefixedId<P> {\n if (typeof candidate !== 'string') return false;\n if (!candidate.startsWith(`${prefix}_`)) return false;\n const body = candidate.slice(prefix.length + 1);\n if (body.length !== 26) return false;\n // Strict Crockford alphabet — no I, L, O, U; lowercase only on the wire.\n return /^[0-9a-hjkmnp-tv-z]{26}$/.test(body);\n}\n","// Zod schema gating the Label 309 record id at every parse boundary (HTTP route\n// handlers, SDK input validation, OpenAPI registration).\n//\n// The regex is the strict Crockford-32 alphabet (lowercase only on the wire,\n// no I/L/O/U). This is stricter than `[0-9a-z]{26}` because it catches the\n// most common typo classes (`poe_…ol1u…`) at the parser rather than letting\n// them through to the decoder for a confusing `non-zero pad bits` error.\n\nimport { z } from 'zod';\n\nconst CROCKFORD_LOWER = '[0-9a-hjkmnp-tv-z]{26}';\n\nexport const POE_ID_PREFIX = 'poe' as const;\n\nexport const PoeIdSchema = z\n .string()\n .regex(new RegExp(`^${POE_ID_PREFIX}_${CROCKFORD_LOWER}$`), 'invalid poe id');\n\nexport const POE_ID_PATTERN = `^${POE_ID_PREFIX}_${CROCKFORD_LOWER}$`;\n"]}
package/dist/index.cjs CHANGED
@@ -499,7 +499,7 @@ function decodeCanonicalCbor(bytes) {
499
499
  ...cbor2.cdeDecodeOptions,
500
500
  rejectStreaming: true,
501
501
  rejectDuplicateKeys: true,
502
- // A CIP-309 record carries integers, byte/text strings, arrays, maps and
502
+ // A Label 309 record carries integers, byte/text strings, arrays, maps and
503
503
  // `null` — and nothing else. Without these rejections the major-type-7
504
504
  // surface leaks into the decoder: a float16/32/64 that happens to hold an
505
505
  // integral value (e.g. 1.0) silently decodes to the integer 1 and passes
@@ -646,7 +646,7 @@ function decodeCanonicalCbor2(bytes) {
646
646
  ...cbor2.cdeDecodeOptions,
647
647
  rejectStreaming: true,
648
648
  rejectDuplicateKeys: true,
649
- // A CIP-309 record carries integers, byte/text strings, arrays, maps and
649
+ // A Label 309 record carries integers, byte/text strings, arrays, maps and
650
650
  // `null` — and nothing else. Without these rejections the major-type-7
651
651
  // surface leaks into the decoder: a float16/32/64 that happens to hold an
652
652
  // integral value (e.g. 1.0) silently decodes to the integer 1 and passes
@@ -747,7 +747,7 @@ function buildSigStructure(args) {
747
747
  args.payload
748
748
  ]);
749
749
  }
750
- function buildCip309SigStructure(args) {
750
+ function buildLabel309SigStructure(args) {
751
751
  const toSign = new Uint8Array(
752
752
  CARDANO_POE_SIG_DOMAIN_PREFIX_BYTES.length + args.recordBodyCbor.length
753
753
  );
@@ -830,7 +830,7 @@ function decodeCoseSign1(bytes) {
830
830
  signature: signatureRaw
831
831
  };
832
832
  }
833
- function coseSign1Cip309Verify(args) {
833
+ function coseSign1Label309Verify(args) {
834
834
  let decoded;
835
835
  try {
836
836
  decoded = decodeCoseSign1(args.message);
@@ -897,7 +897,7 @@ function coseSign1Cip309Verify(args) {
897
897
  payload: hashedPayload
898
898
  });
899
899
  } else {
900
- sigStructureBytes = buildCip309SigStructure({
900
+ sigStructureBytes = buildLabel309SigStructure({
901
901
  bodyProtectedBytes: decoded.protectedBytes,
902
902
  recordBodyCbor: args.detachedRecordBodyCbor
903
903
  });
@@ -1372,11 +1372,7 @@ function validateOneUri(chunks, path, errors) {
1372
1372
  const uri = reconstructed.uri;
1373
1373
  if (uri.includes("#")) {
1374
1374
  errors.push(
1375
- issue(
1376
- "INVALID_URI",
1377
- path,
1378
- "URI contains a fragment identifier ('#'), which is forbidden"
1379
- )
1375
+ issue("INVALID_URI", path, "URI contains a fragment identifier ('#'), which is forbidden")
1380
1376
  );
1381
1377
  return;
1382
1378
  }
@@ -1406,21 +1402,13 @@ function validateOneUri(chunks, path, errors) {
1406
1402
  const cid = slashIdx === -1 ? rest : rest.slice(0, slashIdx);
1407
1403
  if (!validateCidProfile(cid)) {
1408
1404
  errors.push(
1409
- issue(
1410
- "INVALID_URI",
1411
- path,
1412
- "ipfs:// URI is not a valid CID under the CIP-309 profile"
1413
- )
1405
+ issue("INVALID_URI", path, "ipfs:// URI is not a valid CID under the Label 309 profile")
1414
1406
  );
1415
1407
  }
1416
1408
  return;
1417
1409
  }
1418
1410
  errors.push(
1419
- issue(
1420
- "INVALID_URI",
1421
- path,
1422
- "unsupported URI scheme; v1 PoE URI set is {ar://, ipfs://}"
1423
- )
1411
+ issue("INVALID_URI", path, "unsupported URI scheme; v1 PoE URI set is {ar://, ipfs://}")
1424
1412
  );
1425
1413
  }
1426
1414
  function checkItemEnc(item, idx, errors) {
@@ -1462,7 +1450,7 @@ function checkItemEnc(item, idx, errors) {
1462
1450
  issue(
1463
1451
  "UNAUTHENTICATED_CIPHER_FORBIDDEN",
1464
1452
  [...basePath, "aead"],
1465
- `'${enc.aead}' is an unauthenticated cipher; CIP-309 mandates an authenticated (AEAD) cipher`
1453
+ `'${enc.aead}' is an unauthenticated cipher; Label 309 mandates an authenticated (AEAD) cipher`
1466
1454
  )
1467
1455
  );
1468
1456
  return;
@@ -3814,7 +3802,9 @@ async function tryDecryptions(args) {
3814
3802
  let plaintext = null;
3815
3803
  let failure = null;
3816
3804
  if (reqHasSecret) {
3817
- const envelope = sealedEnvelopeFromParsed(enc);
3805
+ const envelope = sealedEnvelopeFromParsed(
3806
+ enc
3807
+ );
3818
3808
  if (envelope === null) {
3819
3809
  out.push({
3820
3810
  item_index: idx,
@@ -3941,7 +3931,7 @@ function decodeCanonicalCbor3(bytes) {
3941
3931
  ...cbor2.cdeDecodeOptions,
3942
3932
  rejectStreaming: true,
3943
3933
  rejectDuplicateKeys: true,
3944
- // A CIP-309 record carries integers, byte/text strings, arrays, maps and
3934
+ // A Label 309 record carries integers, byte/text strings, arrays, maps and
3945
3935
  // `null` — and nothing else. Without these rejections the major-type-7
3946
3936
  // surface leaks into the decoder: a float16/32/64 that happens to hold an
3947
3937
  // integral value (e.g. 1.0) silently decodes to the integer 1 and passes
@@ -4556,11 +4546,11 @@ function decodeIntKey(h) {
4556
4546
  // src/verifier/resolve.ts
4557
4547
  var KOIOS_MAINNET_URL = "https://api.koios.rest/api/v1";
4558
4548
  var BLOCKFROST_MAINNET_HOST = "https://cardano-mainnet.blockfrost.io/api/v0";
4559
- var NotACip309RecordError = class extends Error {
4549
+ var NotALabel309RecordError = class extends Error {
4560
4550
  code = "METADATA_NOT_FOUND";
4561
4551
  constructor(message) {
4562
4552
  super(message);
4563
- this.name = "NotACip309RecordError";
4553
+ this.name = "NotALabel309RecordError";
4564
4554
  }
4565
4555
  };
4566
4556
  async function resolveCardanoTx(args) {
@@ -4571,7 +4561,7 @@ async function resolveCardanoTx(args) {
4571
4561
  try {
4572
4562
  return await resolveViaKoios(input.txHash, koiosUrl, fetchFn);
4573
4563
  } catch (e) {
4574
- if (e instanceof NotACip309RecordError) throw e;
4564
+ if (e instanceof NotALabel309RecordError) throw e;
4575
4565
  lastErr = e;
4576
4566
  }
4577
4567
  }
@@ -4579,7 +4569,7 @@ async function resolveCardanoTx(args) {
4579
4569
  try {
4580
4570
  return await resolveViaBlockfrost(input.txHash, input.blockfrostProjectId, fetchFn);
4581
4571
  } catch (e) {
4582
- if (e instanceof NotACip309RecordError) throw e;
4572
+ if (e instanceof NotALabel309RecordError) throw e;
4583
4573
  lastErr = e;
4584
4574
  }
4585
4575
  }
@@ -4597,7 +4587,7 @@ async function resolveViaKoios(txHash, koiosUrl, fetchFn) {
4597
4587
  }
4598
4588
  const cborJson = parseJson(cborRes.bytes);
4599
4589
  if (!Array.isArray(cborJson) || cborJson.length === 0) {
4600
- throw new NotACip309RecordError("koios returned empty array for tx_cbor; tx may not exist");
4590
+ throw new NotALabel309RecordError("koios returned empty array for tx_cbor; tx may not exist");
4601
4591
  }
4602
4592
  const cborEntry = cborJson[0];
4603
4593
  if (typeof cborEntry.cbor !== "string") {
@@ -4618,7 +4608,7 @@ async function resolveViaKoios(txHash, koiosUrl, fetchFn) {
4618
4608
  }
4619
4609
  const infoJson = parseJson(infoRes.bytes);
4620
4610
  if (!Array.isArray(infoJson) || infoJson.length === 0) {
4621
- throw new NotACip309RecordError("koios returned empty array for tx_info");
4611
+ throw new NotALabel309RecordError("koios returned empty array for tx_info");
4622
4612
  }
4623
4613
  const infoEntry = infoJson[0];
4624
4614
  if (typeof infoEntry.tx_hash === "string" && infoEntry.tx_hash.toLowerCase() !== txHash.toLowerCase()) {
@@ -4763,7 +4753,7 @@ async function verifyOneSig(index, entry, recordBodyCbor, input) {
4763
4753
  return { index, verdict: "unresolved", reason: "SIGNER_KEY_UNRESOLVED" };
4764
4754
  }
4765
4755
  const { pub, signerType } = resolved;
4766
- const verifyResult = coseSign1Cip309Verify({
4756
+ const verifyResult = coseSign1Label309Verify({
4767
4757
  message: coseBytes,
4768
4758
  detachedRecordBodyCbor: recordBodyCbor,
4769
4759
  expectedSignerKey: pub
@@ -4995,7 +4985,8 @@ function decodeTxSummary(txBodyBytes, witnessSetBytes, network) {
4995
4985
  else if (typeof invalidBefore === "bigint") summary.invalid_before = Number(invalidBefore);
4996
4986
  const invalidHereafter = body.get(BODY_KEY_INVALID_HEREAFTER);
4997
4987
  if (typeof invalidHereafter === "number") summary.invalid_hereafter = invalidHereafter;
4998
- else if (typeof invalidHereafter === "bigint") summary.invalid_hereafter = Number(invalidHereafter);
4988
+ else if (typeof invalidHereafter === "bigint")
4989
+ summary.invalid_hereafter = Number(invalidHereafter);
4999
4990
  if (requiredSigners.length > 0) summary.required_signer_key_hashes = requiredSigners;
5000
4991
  const networkId = body.get(BODY_KEY_NETWORK_ID);
5001
4992
  if (typeof networkId === "number") summary.network_id = networkId;
@@ -5114,7 +5105,7 @@ async function verifyTx(input) {
5114
5105
  try {
5115
5106
  resolved = await resolveCardanoTx({ input, fetchFn });
5116
5107
  } catch (e) {
5117
- if (e instanceof NotACip309RecordError) {
5108
+ if (e instanceof NotALabel309RecordError) {
5118
5109
  return base({
5119
5110
  verdict: "failed",
5120
5111
  exit_code: 1,
@@ -5207,7 +5198,16 @@ async function verifyResolved(input) {
5207
5198
  return report;
5208
5199
  }
5209
5200
  async function verifyResolvedRecord(args) {
5210
- const { input, metadataBytes, txCbor, numConfirmations, blockTime, blockSlot, httpCalls, fetchFn } = args;
5201
+ const {
5202
+ input,
5203
+ metadataBytes,
5204
+ txCbor,
5205
+ numConfirmations,
5206
+ blockTime,
5207
+ blockSlot,
5208
+ httpCalls,
5209
+ fetchFn
5210
+ } = args;
5211
5211
  const profile = input.profile ?? DEFAULT_PROFILE;
5212
5212
  const threshold = input.confirmationDepthThreshold ?? CONFIRMATION_DEPTH_THRESHOLD_DEFAULT;
5213
5213
  const txDescription = txCbor !== void 0 ? decodeTxDescription(txCbor, input) : {};
@@ -5446,7 +5446,7 @@ function prepareSigStructure(args) {
5446
5446
  }
5447
5447
  const { protectedHeaderBytes } = encodePath1ProtectedHeader(args.signerPubkey);
5448
5448
  const recordBodyCbor = encodeRecordBodyForSigning(args.record);
5449
- const sigStructureBytes = buildCip309SigStructure({
5449
+ const sigStructureBytes = buildLabel309SigStructure({
5450
5450
  bodyProtectedBytes: protectedHeaderBytes,
5451
5451
  recordBodyCbor
5452
5452
  });
@@ -5540,7 +5540,7 @@ function extractProblemExtensions(problem) {
5540
5540
  }
5541
5541
  return out;
5542
5542
  }
5543
- var Cip309HttpError = class extends Error {
5543
+ var Label309HttpError = class extends Error {
5544
5544
  problem;
5545
5545
  code;
5546
5546
  httpStatus;
@@ -5555,7 +5555,7 @@ var Cip309HttpError = class extends Error {
5555
5555
  retryAfterSeconds;
5556
5556
  constructor(init) {
5557
5557
  super(init.problem.detail || `${init.problem.title} (HTTP ${init.problem.status})`);
5558
- this.name = "Cip309HttpError";
5558
+ this.name = "Label309HttpError";
5559
5559
  this.problem = init.problem;
5560
5560
  this.code = init.problem.code;
5561
5561
  this.httpStatus = init.problem.status;
@@ -5572,7 +5572,7 @@ var Cip309HttpError = class extends Error {
5572
5572
  };
5573
5573
 
5574
5574
  // src/client/batch-empty-error.ts
5575
- var BatchEmptyError = class extends Cip309HttpError {
5575
+ var BatchEmptyError = class extends Label309HttpError {
5576
5576
  constructor(init) {
5577
5577
  super(init);
5578
5578
  this.name = "BatchEmptyError";
@@ -5583,7 +5583,7 @@ var BatchEmptyError = class extends Cip309HttpError {
5583
5583
  function readInt(value) {
5584
5584
  return typeof value === "number" && Number.isFinite(value) ? value : void 0;
5585
5585
  }
5586
- var BatchTooLargeError = class extends Cip309HttpError {
5586
+ var BatchTooLargeError = class extends Label309HttpError {
5587
5587
  max;
5588
5588
  got;
5589
5589
  constructor(init) {
@@ -5595,7 +5595,7 @@ var BatchTooLargeError = class extends Cip309HttpError {
5595
5595
  };
5596
5596
 
5597
5597
  // src/client/forbidden-error.ts
5598
- var ForbiddenError = class extends Cip309HttpError {
5598
+ var ForbiddenError = class extends Label309HttpError {
5599
5599
  constructor(init) {
5600
5600
  super(init);
5601
5601
  this.name = "ForbiddenError";
@@ -5603,7 +5603,7 @@ var ForbiddenError = class extends Cip309HttpError {
5603
5603
  };
5604
5604
 
5605
5605
  // src/client/idempotency-conflict-error.ts
5606
- var IdempotencyConflictError = class extends Cip309HttpError {
5606
+ var IdempotencyConflictError = class extends Label309HttpError {
5607
5607
  constructor(init) {
5608
5608
  super(init);
5609
5609
  this.name = "IdempotencyConflictError";
@@ -5623,7 +5623,7 @@ function readBigIntString(value) {
5623
5623
  function readString(value) {
5624
5624
  return typeof value === "string" ? value : void 0;
5625
5625
  }
5626
- var InsufficientFundsError = class extends Cip309HttpError {
5626
+ var InsufficientFundsError = class extends Label309HttpError {
5627
5627
  balanceUsdMicros;
5628
5628
  requiredUsdMicros;
5629
5629
  topUpUrl;
@@ -5641,7 +5641,7 @@ function readScopeArray(value) {
5641
5641
  if (!Array.isArray(value)) return [];
5642
5642
  return value.filter((entry) => typeof entry === "string");
5643
5643
  }
5644
- var InsufficientScopeError = class extends Cip309HttpError {
5644
+ var InsufficientScopeError = class extends Label309HttpError {
5645
5645
  requiredScopes;
5646
5646
  grantedScopes;
5647
5647
  constructor(init) {
@@ -5657,7 +5657,7 @@ var InsufficientScopeError = class extends Cip309HttpError {
5657
5657
  };
5658
5658
 
5659
5659
  // src/client/internal-server-error.ts
5660
- var InternalServerError = class extends Cip309HttpError {
5660
+ var InternalServerError = class extends Label309HttpError {
5661
5661
  constructor(init) {
5662
5662
  super(init);
5663
5663
  this.name = "InternalServerError";
@@ -5665,7 +5665,7 @@ var InternalServerError = class extends Cip309HttpError {
5665
5665
  };
5666
5666
 
5667
5667
  // src/client/invalid-body-error.ts
5668
- var InvalidBodyError = class extends Cip309HttpError {
5668
+ var InvalidBodyError = class extends Label309HttpError {
5669
5669
  constructor(init) {
5670
5670
  super(init);
5671
5671
  this.name = "InvalidBodyError";
@@ -5673,7 +5673,7 @@ var InvalidBodyError = class extends Cip309HttpError {
5673
5673
  };
5674
5674
 
5675
5675
  // src/client/malformed-cbor-error.ts
5676
- var MalformedCborError = class extends Cip309HttpError {
5676
+ var MalformedCborError = class extends Label309HttpError {
5677
5677
  constructor(init) {
5678
5678
  super(init);
5679
5679
  this.name = "MalformedCborError";
@@ -5681,7 +5681,7 @@ var MalformedCborError = class extends Cip309HttpError {
5681
5681
  };
5682
5682
 
5683
5683
  // src/client/not-found-error.ts
5684
- var NotFoundError = class extends Cip309HttpError {
5684
+ var NotFoundError = class extends Label309HttpError {
5685
5685
  constructor(init) {
5686
5686
  super(init);
5687
5687
  this.name = "NotFoundError";
@@ -5692,7 +5692,7 @@ var NotFoundError = class extends Cip309HttpError {
5692
5692
  function readString2(value) {
5693
5693
  return typeof value === "string" ? value : void 0;
5694
5694
  }
5695
- var QuoteAlreadyConsumedError = class extends Cip309HttpError {
5695
+ var QuoteAlreadyConsumedError = class extends Label309HttpError {
5696
5696
  quoteId;
5697
5697
  constructor(init) {
5698
5698
  super(init);
@@ -5705,7 +5705,7 @@ var QuoteAlreadyConsumedError = class extends Cip309HttpError {
5705
5705
  function readString3(value) {
5706
5706
  return typeof value === "string" ? value : void 0;
5707
5707
  }
5708
- var QuoteExpiredError = class extends Cip309HttpError {
5708
+ var QuoteExpiredError = class extends Label309HttpError {
5709
5709
  quoteId;
5710
5710
  constructor(init) {
5711
5711
  super(init);
@@ -5718,7 +5718,7 @@ var QuoteExpiredError = class extends Cip309HttpError {
5718
5718
  function readString4(value) {
5719
5719
  return typeof value === "string" ? value : void 0;
5720
5720
  }
5721
- var QuoteNotFoundError = class extends Cip309HttpError {
5721
+ var QuoteNotFoundError = class extends Label309HttpError {
5722
5722
  quoteId;
5723
5723
  constructor(init) {
5724
5724
  super(init);
@@ -5728,7 +5728,7 @@ var QuoteNotFoundError = class extends Cip309HttpError {
5728
5728
  };
5729
5729
 
5730
5730
  // src/client/rate-limited-error.ts
5731
- var RateLimitedError = class extends Cip309HttpError {
5731
+ var RateLimitedError = class extends Label309HttpError {
5732
5732
  constructor(init) {
5733
5733
  super(init);
5734
5734
  this.name = "RateLimitedError";
@@ -5736,7 +5736,7 @@ var RateLimitedError = class extends Cip309HttpError {
5736
5736
  };
5737
5737
 
5738
5738
  // src/client/record-not-found-error.ts
5739
- var RecordNotFoundError = class extends Cip309HttpError {
5739
+ var RecordNotFoundError = class extends Label309HttpError {
5740
5740
  constructor(init) {
5741
5741
  super(init);
5742
5742
  this.name = "RecordNotFoundError";
@@ -5744,7 +5744,7 @@ var RecordNotFoundError = class extends Cip309HttpError {
5744
5744
  };
5745
5745
 
5746
5746
  // src/client/service-unavailable-error.ts
5747
- var ServiceUnavailableError = class extends Cip309HttpError {
5747
+ var ServiceUnavailableError = class extends Label309HttpError {
5748
5748
  constructor(init) {
5749
5749
  super(init);
5750
5750
  this.name = "ServiceUnavailableError";
@@ -5752,7 +5752,7 @@ var ServiceUnavailableError = class extends Cip309HttpError {
5752
5752
  };
5753
5753
 
5754
5754
  // src/client/unauthorized-error.ts
5755
- var UnauthorizedError = class extends Cip309HttpError {
5755
+ var UnauthorizedError = class extends Label309HttpError {
5756
5756
  constructor(init) {
5757
5757
  super(init);
5758
5758
  this.name = "UnauthorizedError";
@@ -5760,7 +5760,7 @@ var UnauthorizedError = class extends Cip309HttpError {
5760
5760
  };
5761
5761
 
5762
5762
  // src/client/validation-failed-error.ts
5763
- var ValidationFailedError = class extends Cip309HttpError {
5763
+ var ValidationFailedError = class extends Label309HttpError {
5764
5764
  constructor(init) {
5765
5765
  super(init);
5766
5766
  this.name = "ValidationFailedError";
@@ -5878,7 +5878,7 @@ function parseHttpError(args) {
5878
5878
  case "fx-stale":
5879
5879
  return new ServiceUnavailableError(init);
5880
5880
  default:
5881
- return new Cip309HttpError(init);
5881
+ return new Label309HttpError(init);
5882
5882
  }
5883
5883
  }
5884
5884
 
@@ -6339,7 +6339,7 @@ var PoeNamespace = class {
6339
6339
  * publish time against the locked price snapshot.
6340
6340
  *
6341
6341
  * On HTTP-level failure (auth, rate limit, malformed request) this throws
6342
- * a typed `Cip309HttpError` subclass. Per-file failures inside a 200
6342
+ * a typed `Label309HttpError` subclass. Per-file failures inside a 200
6343
6343
  * response are NOT thrown by `uploads()` itself — the response body is
6344
6344
  * returned verbatim so the caller can decide how to react. The
6345
6345
  * higher-level helpers (`publishSealed`, `publishMerkle`) treat any failed
@@ -6424,7 +6424,7 @@ var PoeNamespace = class {
6424
6424
  }
6425
6425
  /**
6426
6426
  * High-level hash-only publish: hash the supplied content, build a
6427
- * single-item CIP-309 record, optionally sign it with the caller-supplied
6427
+ * single-item Label 309 record, optionally sign it with the caller-supplied
6428
6428
  * signer, and submit. No Arweave, no storage round-trip — anchors the
6429
6429
  * digest only.
6430
6430
  */
@@ -6442,7 +6442,7 @@ var PoeNamespace = class {
6442
6442
  /**
6443
6443
  * Sealed-PoE: encrypt the supplied content to the recipient X25519 public
6444
6444
  * keys (age-style sealed envelope), upload the ciphertext to Arweave via
6445
- * /uploads, build a CIP-309 record with the resulting `ar://` URI, sign
6445
+ * /uploads, build a Label 309 record with the resulting `ar://` URI, sign
6446
6446
  * it (optional), and submit via /publish.
6447
6447
  *
6448
6448
  * The sender SHOULD include their own X25519 public key in `recipients`
@@ -6540,7 +6540,7 @@ var RecordsNamespace = class {
6540
6540
  return await readJson(response);
6541
6541
  }
6542
6542
  /**
6543
- * Run the canonical CIP-309 verifier against the record at `txHash`.
6543
+ * Run the canonical Label 309 verifier against the record at `txHash`.
6544
6544
  * Returns the same `VerifyReport` shape the standalone verifier emits —
6545
6545
  * `VerifyReport` IS the wire body of this endpoint, with no transformer in
6546
6546
  * between.
@@ -6563,31 +6563,31 @@ var RecordsNamespace = class {
6563
6563
  }
6564
6564
  };
6565
6565
 
6566
- // src/client/cip309-client.ts
6566
+ // src/client/label-309-client.ts
6567
6567
  function resolveFetch(provided) {
6568
6568
  if (provided !== void 0) return provided;
6569
6569
  if (typeof globalThis.fetch === "function") {
6570
6570
  return globalThis.fetch.bind(globalThis);
6571
6571
  }
6572
6572
  throw new Error(
6573
- "Cip309Client: no fetch implementation available. Pass `fetch` in the config or run on a platform with globalThis.fetch."
6573
+ "Label309Client: no fetch implementation available. Pass `fetch` in the config or run on a platform with globalThis.fetch."
6574
6574
  );
6575
6575
  }
6576
6576
  function resolveBaseUrl(config) {
6577
6577
  const baseUrl = config.baseUrl?.trim();
6578
6578
  if (baseUrl === void 0 || baseUrl === "") {
6579
6579
  throw new InvalidClientConfigError(
6580
- "Cip309Client: baseUrl is required. Pass the base URL of the CIP-309 gateway you are targeting (e.g. https://gateway.example.com)."
6580
+ "Label309Client: baseUrl is required. Pass the base URL of the Label 309 gateway you are targeting (e.g. https://gateway.example.com)."
6581
6581
  );
6582
6582
  }
6583
6583
  return baseUrl.replace(/\/$/, "");
6584
6584
  }
6585
- var Cip309Client = class {
6585
+ var Label309Client = class {
6586
6586
  poe;
6587
6587
  records;
6588
6588
  account;
6589
6589
  /**
6590
- * Construct a client against a CIP-309 gateway.
6590
+ * Construct a client against a Label 309 gateway.
6591
6591
  *
6592
6592
  * `config.baseUrl` is required — there is no default deployment. The
6593
6593
  * `config.apiKey`, when supplied, is an opaque bearer token sent verbatim as
@@ -7028,8 +7028,6 @@ exports.BatchTooLargeError = BatchTooLargeError;
7028
7028
  exports.BodyTooLargeError = BodyTooLargeError;
7029
7029
  exports.CONFIRMATION_DEPTH_THRESHOLD_DEFAULT = CONFIRMATION_DEPTH_THRESHOLD_DEFAULT;
7030
7030
  exports.CROCKFORD_ENCODED_LENGTH_FOR_UUID = CROCKFORD_ENCODED_LENGTH_FOR_UUID;
7031
- exports.Cip309Client = Cip309Client;
7032
- exports.Cip309HttpError = Cip309HttpError;
7033
7031
  exports.DEFAULT_OUTBOUND_MAX_BYTES = DEFAULT_OUTBOUND_MAX_BYTES;
7034
7032
  exports.DEFAULT_PROFILE = DEFAULT_PROFILE;
7035
7033
  exports.DENY_HOSTS_DEFAULT = DENY_HOSTS_DEFAULT;
@@ -7043,8 +7041,10 @@ exports.InternalServerError = InternalServerError;
7043
7041
  exports.InvalidBodyError = InvalidBodyError;
7044
7042
  exports.InvalidClientConfigError = InvalidClientConfigError;
7045
7043
  exports.KOIOS_MAINNET_URL = KOIOS_MAINNET_URL;
7044
+ exports.Label309Client = Label309Client;
7045
+ exports.Label309HttpError = Label309HttpError;
7046
7046
  exports.MalformedCborError = MalformedCborError;
7047
- exports.NotACip309RecordError = NotACip309RecordError;
7047
+ exports.NotALabel309RecordError = NotALabel309RecordError;
7048
7048
  exports.NotFoundError = NotFoundError;
7049
7049
  exports.OffHostSignError = OffHostSignError;
7050
7050
  exports.OutboundExhaustedError = OutboundExhaustedError;