@peac/kernel 0.11.3 → 0.12.0-preview.2
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.
- package/dist/constants.cjs +33 -0
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.ts +89 -8
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.mjs +24 -1
- package/dist/constants.mjs.map +1 -1
- package/dist/error-categories.generated.d.ts +2 -2
- package/dist/error-categories.generated.d.ts.map +1 -1
- package/dist/errors.cjs +202 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.generated.d.ts +21 -1
- package/dist/errors.generated.d.ts.map +1 -1
- package/dist/errors.mjs +202 -0
- package/dist/errors.mjs.map +1 -1
- package/dist/index.cjs +236 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +227 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.cjs +1 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.mjs +1 -0
- package/dist/types.mjs.map +1 -1
- package/dist/wire-02-types.d.ts +60 -0
- package/dist/wire-02-types.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/constants.cjs
CHANGED
|
@@ -139,6 +139,29 @@ var VERIFICATION_MODES = {
|
|
|
139
139
|
/** Allow network fetches for key discovery */
|
|
140
140
|
networkAllowed: "network_allowed"
|
|
141
141
|
};
|
|
142
|
+
var WIRE_01_JWS_TYP = "peac-receipt/0.1";
|
|
143
|
+
var WIRE_02_JWS_TYP = "interaction-record+jwt";
|
|
144
|
+
var WIRE_02_JWS_TYP_ACCEPT = [
|
|
145
|
+
"interaction-record+jwt",
|
|
146
|
+
"application/interaction-record+jwt"
|
|
147
|
+
];
|
|
148
|
+
var WIRE_02_VERSION = "0.2";
|
|
149
|
+
var WIRE_VERSIONS = ["0.1", "0.2"];
|
|
150
|
+
var ISS_CANONICAL = {
|
|
151
|
+
maxLength: 2048,
|
|
152
|
+
supportedSchemes: ["https", "did"],
|
|
153
|
+
/** Default port for https (rejected if explicit in iss). */
|
|
154
|
+
defaultPorts: { https: 443 }
|
|
155
|
+
};
|
|
156
|
+
var TYPE_GRAMMAR = { maxLength: 256 };
|
|
157
|
+
var POLICY_BLOCK = {
|
|
158
|
+
/** Maximum length of the policy.uri HTTPS hint (chars). */
|
|
159
|
+
uriMaxLength: 2048,
|
|
160
|
+
/** Maximum length of the policy.version label (chars). */
|
|
161
|
+
versionMaxLength: 256
|
|
162
|
+
};
|
|
163
|
+
var OCCURRED_AT_TOLERANCE_SECONDS = 300;
|
|
164
|
+
var PEAC_ALG = ALGORITHMS.default;
|
|
142
165
|
var CONSTANTS = {
|
|
143
166
|
WIRE_TYPE,
|
|
144
167
|
WIRE_VERSION,
|
|
@@ -164,18 +187,28 @@ exports.DISCOVERY = DISCOVERY;
|
|
|
164
187
|
exports.HASH = HASH;
|
|
165
188
|
exports.HEADERS = HEADERS;
|
|
166
189
|
exports.ISSUER_CONFIG = ISSUER_CONFIG;
|
|
190
|
+
exports.ISS_CANONICAL = ISS_CANONICAL;
|
|
167
191
|
exports.JWKS = JWKS;
|
|
168
192
|
exports.LIMITS = LIMITS;
|
|
193
|
+
exports.OCCURRED_AT_TOLERANCE_SECONDS = OCCURRED_AT_TOLERANCE_SECONDS;
|
|
194
|
+
exports.PEAC_ALG = PEAC_ALG;
|
|
169
195
|
exports.POLICY = POLICY;
|
|
196
|
+
exports.POLICY_BLOCK = POLICY_BLOCK;
|
|
170
197
|
exports.PRIVATE_IP_RANGES = PRIVATE_IP_RANGES;
|
|
171
198
|
exports.RECEIPT = RECEIPT;
|
|
199
|
+
exports.TYPE_GRAMMAR = TYPE_GRAMMAR;
|
|
172
200
|
exports.VERIFICATION_MODES = VERIFICATION_MODES;
|
|
173
201
|
exports.VERIFICATION_REPORT_VERSION = VERIFICATION_REPORT_VERSION;
|
|
174
202
|
exports.VERIFIER_LIMITS = VERIFIER_LIMITS;
|
|
175
203
|
exports.VERIFIER_NETWORK = VERIFIER_NETWORK;
|
|
176
204
|
exports.VERIFIER_POLICY_VERSION = VERIFIER_POLICY_VERSION;
|
|
205
|
+
exports.WIRE_01_JWS_TYP = WIRE_01_JWS_TYP;
|
|
206
|
+
exports.WIRE_02_JWS_TYP = WIRE_02_JWS_TYP;
|
|
207
|
+
exports.WIRE_02_JWS_TYP_ACCEPT = WIRE_02_JWS_TYP_ACCEPT;
|
|
208
|
+
exports.WIRE_02_VERSION = WIRE_02_VERSION;
|
|
177
209
|
exports.WIRE_TYPE = WIRE_TYPE;
|
|
178
210
|
exports.WIRE_VERSION = WIRE_VERSION;
|
|
211
|
+
exports.WIRE_VERSIONS = WIRE_VERSIONS;
|
|
179
212
|
exports.formatHash = formatHash;
|
|
180
213
|
exports.isValidHash = isValidHash;
|
|
181
214
|
exports.parseHash = parseHash;
|
package/dist/constants.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/constants.ts"],"names":[],"mappings":";;;AAYO,IAAM,SAAA,GAAY;AAMlB,IAAM,YAAA,GAAe;AAKrB,IAAM,UAAA,GAAa;AAAA,EACxB,SAAA,EAAW,CAAC,OAAO,CAAA;AAAA,EACnB,OAAA,EAAS;AACX;AAKO,IAAM,OAAA,GAAU;AAAA,EACrB,OAAA,EAAS,cAAA;AAAA,EACT,cAAA,EAAgB,sBAAA;AAAA,EAChB,IAAA,EAAM,MAAA;AAAA;AAAA,EAEN,OAAA,EAAS,cAAA;AAAA,EACT,cAAA,EAAgB,sBAAA;AAAA,EAChB,aAAA,EAAe;AACjB;AAQO,IAAM,MAAA,GAAS;AAAA,EACpB,YAAA,EAAc,uBAAA;AAAA,EACd,YAAA,EAAc,WAAA;AAAA,EACd,eAAA,EAAiB,iBAAA;AAAA,EACjB,eAAA,EAAiB,IAAA;AAAA,EACjB,QAAA,EAAU,MAAA;AAAA;AAAA,EACV,Q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AAA;AAAA,EAEb,gBAAA,EAAkB,mBAAA;AAAA;AAAA,EAElB,cAAA,EAAgB;AAClB;AAKO,IAAM,SAAA,GAAY;AAAA,EACvB,SAAA;AAAA,EACA,YAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,IAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA,cAAA;AAAA,EACA,2BAAA;AAAA,EACA,IAAA;AAAA,EACA,eAAA;AAAA,EACA,gBAAA;AAAA,EACA,uBAAA;AAAA,EACA;AACF","file":"constants.cjs","sourcesContent":["/**\n * PEAC Protocol Constants\n * Derived from specs/kernel/constants.json\n *\n * NOTE: This file is manually synced for v0.9.15.\n * From v0.9.16+, this will be auto-generated via codegen.\n */\n\n/**\n * Wire format type for PEAC receipts\n * Normalized to peac-receipt/0.1 per DEC-20260114-002\n */\nexport const WIRE_TYPE = 'peac-receipt/0.1' as const;\n\n/**\n * Wire format version (extracted from WIRE_TYPE)\n * Use this for wire_version fields in receipts\n */\nexport const WIRE_VERSION = '0.1' as const;\n\n/**\n * Supported cryptographic algorithms\n */\nexport const ALGORITHMS = {\n supported: ['EdDSA'] as const,\n default: 'EdDSA' as const,\n} as const;\n\n/**\n * HTTP header names for PEAC protocol\n */\nexport const HEADERS = {\n receipt: 'PEAC-Receipt' as const,\n receiptPointer: 'PEAC-Receipt-Pointer' as const,\n dpop: 'DPoP' as const,\n // Purpose headers (v0.9.24+)\n purpose: 'PEAC-Purpose' as const,\n purposeApplied: 'PEAC-Purpose-Applied' as const,\n purposeReason: 'PEAC-Purpose-Reason' as const,\n} as const;\n\n/**\n * Policy manifest settings (/.well-known/peac.txt)\n *\n * Policy documents declare access terms for agents and gateways.\n * @see docs/specs/PEAC-TXT.md\n */\nexport const POLICY = {\n manifestPath: '/.well-known/peac.txt' as const,\n fallbackPath: '/peac.txt' as const,\n manifestVersion: 'peac-policy/0.1' as const,\n cacheTtlSeconds: 3600,\n maxBytes: 262144, // 256 KiB\n maxDepth: 8,\n} as const;\n\n/**\n * Issuer configuration settings (/.well-known/peac-issuer.json)\n *\n * Issuer config enables verifiers to discover JWKS and verification endpoints.\n * @see docs/specs/PEAC-ISSUER.md\n */\nexport const ISSUER_CONFIG = {\n configPath: '/.well-known/peac-issuer.json' as const,\n configVersion: 'peac-issuer/0.1' as const,\n cacheTtlSeconds: 3600,\n maxBytes: 65536, // 64 KiB\n maxDepth: 4,\n fetchTimeoutMs: 10000,\n} as const;\n\n/**\n * @deprecated Use POLICY instead. Will be removed in v1.0.\n */\nexport const DISCOVERY = {\n manifestPath: POLICY.manifestPath,\n manifestVersion: 'peac/0.9' as const,\n cacheTtlSeconds: POLICY.cacheTtlSeconds,\n} as const;\n\n/**\n * JWKS rotation and revocation settings\n */\nexport const JWKS = {\n rotationDays: 90,\n /** Normative minimum overlap period (DD-148, v0.11.3+) */\n overlapDays: 30,\n emergencyRevocationHours: 24,\n} as const;\n\n/**\n * Receipt validation constants\n */\nexport const RECEIPT = {\n minReceiptIdLength: 16,\n maxReceiptIdLength: 64,\n defaultTtlSeconds: 86400, // 24 hours\n} as const;\n\n/**\n * Payment amount validation limits (in cents/smallest currency unit)\n */\nexport const LIMITS = {\n maxAmountCents: 999999999999,\n minAmountCents: 1,\n} as const;\n\n/**\n * Bundle format version.\n * Used in dispute bundles, audit bundles, and archive bundles.\n */\nexport const BUNDLE_VERSION = 'peac-bundle/0.1' as const;\n\n/**\n * Verification report format version.\n */\nexport const VERIFICATION_REPORT_VERSION = 'peac-verification-report/0.1' as const;\n\n/**\n * Hash format constants and utilities.\n * All hashes use the self-describing format: sha256:<64 lowercase hex chars>\n */\nexport const HASH = {\n /** Canonical hash algorithm */\n algorithm: 'sha256' as const,\n\n /** Hash prefix pattern */\n prefix: 'sha256:' as const,\n\n /** Valid hash regex: sha256:<64 lowercase hex> */\n pattern: /^sha256:[0-9a-f]{64}$/,\n\n /** Hex-only pattern for legacy comparison */\n hexPattern: /^[0-9a-f]{64}$/,\n};\n\n/**\n * Parse a sha256:<hex> hash string into components.\n * Returns null if the format is invalid.\n *\n * @param hash - Hash string to parse (e.g., \"sha256:abc123...\")\n * @returns Parsed hash or null if invalid\n */\nexport function parseHash(hash: string): { alg: 'sha256'; hex: string } | null {\n if (!HASH.pattern.test(hash)) {\n return null;\n }\n return {\n alg: 'sha256',\n hex: hash.slice(7), // Remove 'sha256:' prefix\n };\n}\n\n/**\n * Format a hex string as a sha256:<hex> hash.\n * Validates that the hex is exactly 64 lowercase characters.\n *\n * @param hex - Hex string (64 lowercase characters)\n * @returns Formatted hash or null if invalid\n */\nexport function formatHash(hex: string): string | null {\n if (!HASH.hexPattern.test(hex)) {\n return null;\n }\n return `sha256:${hex}`;\n}\n\n/**\n * Validate a hash string is in the correct format.\n *\n * @param hash - Hash string to validate\n * @returns true if valid sha256:<64 hex> format\n */\nexport function isValidHash(hash: string): boolean {\n return HASH.pattern.test(hash);\n}\n\n/**\n * Verifier security limits per VERIFIER-SECURITY-MODEL.md\n */\nexport const VERIFIER_LIMITS = {\n /** Maximum receipt size in bytes (256 KB) */\n maxReceiptBytes: 262144,\n /** Maximum number of claims in a receipt */\n maxClaimsCount: 100,\n /** Maximum extension size in bytes (64 KB) */\n maxExtensionBytes: 65536,\n /** Maximum string length for individual claims (64 KB) */\n maxStringLength: 65536,\n /** Maximum JWKS document size in bytes (64 KB) */\n maxJwksBytes: 65536,\n /** Maximum number of keys in a JWKS */\n maxJwksKeys: 20,\n /** Maximum individual key size in bytes */\n maxKeySize: 4096,\n /** Network fetch timeout in milliseconds */\n fetchTimeoutMs: 5000,\n /** Maximum number of redirects to follow */\n maxRedirects: 3,\n /** Maximum network response size in bytes (256 KB) */\n maxResponseBytes: 262144,\n} as const;\n\n/**\n * Verifier network security settings per VERIFIER-SECURITY-MODEL.md\n */\nexport const VERIFIER_NETWORK = {\n /** Only allow HTTPS URLs */\n httpsOnly: true,\n /** Block requests to private IP ranges */\n blockPrivateIps: true,\n /** Default redirect policy (false = no redirects) */\n allowRedirects: false,\n} as const;\n\n/**\n * Private IPv4 CIDR blocks to block for SSRF protection\n */\nexport const PRIVATE_IP_RANGES = {\n /** RFC 1918 private ranges */\n rfc1918: ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16'] as const,\n /** Link-local addresses */\n linkLocal: ['169.254.0.0/16'] as const,\n /** Loopback addresses */\n loopback: ['127.0.0.0/8'] as const,\n /** IPv6 loopback */\n ipv6Loopback: ['::1/128'] as const,\n /** IPv6 link-local */\n ipv6LinkLocal: ['fe80::/10'] as const,\n} as const;\n\n/**\n * Verifier policy version\n */\nexport const VERIFIER_POLICY_VERSION = 'peac-verifier-policy/0.1' as const;\n\n/**\n * Verification modes per VERIFIER-SECURITY-MODEL.md\n */\nexport const VERIFICATION_MODES = {\n /** All verification in browser/client, may fetch JWKS */\n clientSide: 'client_side' as const,\n /** No network access, uses bundled/pinned keys */\n offlineOnly: 'offline_only' as const,\n /** Prefer offline, fallback to network */\n offlinePreferred: 'offline_preferred' as const,\n /** Allow network fetches for key discovery */\n networkAllowed: 'network_allowed' as const,\n} as const;\n\n/**\n * All constants export\n */\nexport const CONSTANTS = {\n WIRE_TYPE,\n WIRE_VERSION,\n ALGORITHMS,\n HEADERS,\n DISCOVERY,\n JWKS,\n RECEIPT,\n LIMITS,\n BUNDLE_VERSION,\n VERIFICATION_REPORT_VERSION,\n HASH,\n VERIFIER_LIMITS,\n VERIFIER_NETWORK,\n VERIFIER_POLICY_VERSION,\n VERIFICATION_MODES,\n} as const;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts"],"names":[],"mappings":";;;AAWO,IAAM,SAAA,GAAY;AASlB,IAAM,YAAA,GAAe;AAKrB,IAAM,UAAA,GAAa;AAAA,EACxB,SAAA,EAAW,CAAC,OAAO,CAAA;AAAA,EACnB,OAAA,EAAS;AACX;AAKO,IAAM,OAAA,GAAU;AAAA,EACrB,OAAA,EAAS,cAAA;AAAA,EACT,cAAA,EAAgB,sBAAA;A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;AAAA,EACA;AACF","file":"constants.cjs","sourcesContent":["/**\n * PEAC Protocol Constants\n */\n\n/**\n * Wire 0.1 JWS `typ` claim (legacy constant name).\n *\n * @deprecated Use `WIRE_01_JWS_TYP` for new code. `WIRE_TYPE` and\n * `WIRE_01_JWS_TYP` resolve to the same string; `WIRE_01_JWS_TYP` is the\n * canonical name at the JWS layer (v0.12.0-preview.1+, Wire 0.2 dual-stack).\n */\nexport const WIRE_TYPE = 'peac-receipt/0.1' as const;\n\n/**\n * Wire 0.1 version string (legacy constant name).\n *\n * @deprecated Use `WIRE_VERSIONS` or compare against `WIRE_02_VERSION` for\n * dual-stack version detection. `WIRE_VERSION` remains valid for Wire 0.1\n * but does not participate in the Wire 0.2 version model.\n */\nexport const WIRE_VERSION = '0.1' as const;\n\n/**\n * Supported cryptographic algorithms\n */\nexport const ALGORITHMS = {\n supported: ['EdDSA'] as const,\n default: 'EdDSA' as const,\n} as const;\n\n/**\n * HTTP header names for PEAC protocol\n */\nexport const HEADERS = {\n receipt: 'PEAC-Receipt' as const,\n receiptPointer: 'PEAC-Receipt-Pointer' as const,\n dpop: 'DPoP' as const,\n // Purpose headers (v0.9.24+)\n purpose: 'PEAC-Purpose' as const,\n purposeApplied: 'PEAC-Purpose-Applied' as const,\n purposeReason: 'PEAC-Purpose-Reason' as const,\n} as const;\n\n/**\n * Policy manifest settings (/.well-known/peac.txt)\n *\n * Policy documents declare access terms for agents and gateways.\n * @see docs/specs/PEAC-TXT.md\n */\nexport const POLICY = {\n manifestPath: '/.well-known/peac.txt' as const,\n fallbackPath: '/peac.txt' as const,\n manifestVersion: 'peac-policy/0.1' as const,\n cacheTtlSeconds: 3600,\n maxBytes: 262144, // 256 KiB\n maxDepth: 8,\n} as const;\n\n/**\n * Issuer configuration settings (/.well-known/peac-issuer.json)\n *\n * Issuer config enables verifiers to discover JWKS and verification endpoints.\n * @see docs/specs/PEAC-ISSUER.md\n */\nexport const ISSUER_CONFIG = {\n configPath: '/.well-known/peac-issuer.json' as const,\n configVersion: 'peac-issuer/0.1' as const,\n cacheTtlSeconds: 3600,\n maxBytes: 65536, // 64 KiB\n maxDepth: 4,\n fetchTimeoutMs: 10000,\n} as const;\n\n/**\n * @deprecated Use POLICY instead. Will be removed in v1.0.\n */\nexport const DISCOVERY = {\n manifestPath: POLICY.manifestPath,\n manifestVersion: 'peac/0.9' as const,\n cacheTtlSeconds: POLICY.cacheTtlSeconds,\n} as const;\n\n/**\n * JWKS rotation and revocation settings\n */\nexport const JWKS = {\n rotationDays: 90,\n /** Normative minimum overlap period (DD-148, v0.11.3+) */\n overlapDays: 30,\n emergencyRevocationHours: 24,\n} as const;\n\n/**\n * Receipt validation constants\n */\nexport const RECEIPT = {\n minReceiptIdLength: 16,\n maxReceiptIdLength: 64,\n defaultTtlSeconds: 86400, // 24 hours\n} as const;\n\n/**\n * Payment amount validation limits (in cents/smallest currency unit)\n */\nexport const LIMITS = {\n maxAmountCents: 999999999999,\n minAmountCents: 1,\n} as const;\n\n/**\n * Bundle format version.\n * Used in dispute bundles, audit bundles, and archive bundles.\n */\nexport const BUNDLE_VERSION = 'peac-bundle/0.1' as const;\n\n/**\n * Verification report format version.\n */\nexport const VERIFICATION_REPORT_VERSION = 'peac-verification-report/0.1' as const;\n\n/**\n * Hash format constants and utilities.\n * All hashes use the self-describing format: sha256:<64 lowercase hex chars>\n */\nexport const HASH = {\n /** Canonical hash algorithm */\n algorithm: 'sha256' as const,\n\n /** Hash prefix pattern */\n prefix: 'sha256:' as const,\n\n /** Valid hash regex: sha256:<64 lowercase hex> */\n pattern: /^sha256:[0-9a-f]{64}$/,\n\n /** Hex-only pattern for legacy comparison */\n hexPattern: /^[0-9a-f]{64}$/,\n};\n\n/**\n * Parse a sha256:<hex> hash string into components.\n * Returns null if the format is invalid.\n *\n * @param hash - Hash string to parse (e.g., \"sha256:abc123...\")\n * @returns Parsed hash or null if invalid\n */\nexport function parseHash(hash: string): { alg: 'sha256'; hex: string } | null {\n if (!HASH.pattern.test(hash)) {\n return null;\n }\n return {\n alg: 'sha256',\n hex: hash.slice(7), // Remove 'sha256:' prefix\n };\n}\n\n/**\n * Format a hex string as a sha256:<hex> hash.\n * Validates that the hex is exactly 64 lowercase characters.\n *\n * @param hex - Hex string (64 lowercase characters)\n * @returns Formatted hash or null if invalid\n */\nexport function formatHash(hex: string): string | null {\n if (!HASH.hexPattern.test(hex)) {\n return null;\n }\n return `sha256:${hex}`;\n}\n\n/**\n * Validate a hash string is in the correct format.\n *\n * @param hash - Hash string to validate\n * @returns true if valid sha256:<64 hex> format\n */\nexport function isValidHash(hash: string): boolean {\n return HASH.pattern.test(hash);\n}\n\n/**\n * Verifier security limits per VERIFIER-SECURITY-MODEL.md\n */\nexport const VERIFIER_LIMITS = {\n /** Maximum receipt size in bytes (256 KB) */\n maxReceiptBytes: 262144,\n /** Maximum number of claims in a receipt */\n maxClaimsCount: 100,\n /** Maximum extension size in bytes (64 KB) */\n maxExtensionBytes: 65536,\n /** Maximum string length for individual claims (64 KB) */\n maxStringLength: 65536,\n /** Maximum JWKS document size in bytes (64 KB) */\n maxJwksBytes: 65536,\n /** Maximum number of keys in a JWKS */\n maxJwksKeys: 20,\n /** Maximum individual key size in bytes */\n maxKeySize: 4096,\n /** Network fetch timeout in milliseconds */\n fetchTimeoutMs: 5000,\n /** Maximum number of redirects to follow */\n maxRedirects: 3,\n /** Maximum network response size in bytes (256 KB) */\n maxResponseBytes: 262144,\n} as const;\n\n/**\n * Verifier network security settings per VERIFIER-SECURITY-MODEL.md\n */\nexport const VERIFIER_NETWORK = {\n /** Only allow HTTPS URLs */\n httpsOnly: true,\n /** Block requests to private IP ranges */\n blockPrivateIps: true,\n /** Default redirect policy (false = no redirects) */\n allowRedirects: false,\n} as const;\n\n/**\n * Private IPv4 CIDR blocks to block for SSRF protection\n */\nexport const PRIVATE_IP_RANGES = {\n /** RFC 1918 private ranges */\n rfc1918: ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16'] as const,\n /** Link-local addresses */\n linkLocal: ['169.254.0.0/16'] as const,\n /** Loopback addresses */\n loopback: ['127.0.0.0/8'] as const,\n /** IPv6 loopback */\n ipv6Loopback: ['::1/128'] as const,\n /** IPv6 link-local */\n ipv6LinkLocal: ['fe80::/10'] as const,\n} as const;\n\n/**\n * Verifier policy version\n */\nexport const VERIFIER_POLICY_VERSION = 'peac-verifier-policy/0.1' as const;\n\n/**\n * Verification modes per VERIFIER-SECURITY-MODEL.md\n */\nexport const VERIFICATION_MODES = {\n /** All verification in browser/client, may fetch JWKS */\n clientSide: 'client_side' as const,\n /** No network access, uses bundled/pinned keys */\n offlineOnly: 'offline_only' as const,\n /** Prefer offline, fallback to network */\n offlinePreferred: 'offline_preferred' as const,\n /** Allow network fetches for key discovery */\n networkAllowed: 'network_allowed' as const,\n} as const;\n\n// ---------------------------------------------------------------------------\n// Wire 0.2 constants (v0.12.0-preview.1, DD-156)\n// ---------------------------------------------------------------------------\n\n/**\n * JWS header typ value for Wire 0.1 receipts.\n * Canonical location: @peac/kernel (layer correction from @peac/schema).\n * The existing WIRE_TYPE constant is unchanged; both resolve to the same string.\n * @peac/schema re-exports this as PEAC_WIRE_TYP for backward compatibility.\n */\nexport const WIRE_01_JWS_TYP = 'peac-receipt/0.1' as const;\n\n/**\n * JWS header typ value for Wire 0.2 receipts (compact form).\n * Per RFC 7515 Section 4.1.9, the full media type form\n * 'application/interaction-record+jwt' is also accepted by verifiers and\n * normalized to this compact form before returning the header.\n */\nexport const WIRE_02_JWS_TYP = 'interaction-record+jwt' as const;\n\n/**\n * All accepted typ values for Wire 0.2 (compact + full media type form).\n * Used internally by @peac/crypto to fast-reject unrelated tokens.\n * Verifiers normalize the full form to WIRE_02_JWS_TYP before returning.\n */\nexport const WIRE_02_JWS_TYP_ACCEPT = [\n 'interaction-record+jwt',\n 'application/interaction-record+jwt',\n] as const;\n\n/**\n * Wire 0.2 peac_version payload claim value.\n * Discriminates Wire 0.2 envelopes from Wire 0.1 (which have no peac_version field).\n */\nexport const WIRE_02_VERSION = '0.2' as const;\n\n/**\n * All supported wire version strings for dual-stack implementations.\n */\nexport const WIRE_VERSIONS = ['0.1', '0.2'] as const;\n\n/**\n * TypeScript union type for supported wire version values.\n */\nexport type WireVersion = (typeof WIRE_VERSIONS)[number];\n\n/**\n * Canonical issuer (iss) constraints for Wire 0.2.\n * Supported schemes: 'https' (RFC 3986 origin-only) and 'did' (DID Core).\n * All other schemes produce E_ISS_NOT_CANONICAL.\n */\nexport const ISS_CANONICAL = {\n maxLength: 2048,\n supportedSchemes: ['https', 'did'] as const,\n /** Default port for https (rejected if explicit in iss). */\n defaultPorts: { https: 443 } as Record<string, number>,\n} as const;\n\n/**\n * type claim grammar constraints (open vocabulary: reverse-DNS or absolute URI).\n */\nexport const TYPE_GRAMMAR = { maxLength: 256 } as const;\n\n/**\n * policy block field constraints (Wire 0.2, DD-151).\n * Separate from ISS_CANONICAL to allow independent evolution of each limit.\n */\nexport const POLICY_BLOCK = {\n /** Maximum length of the policy.uri HTTPS hint (chars). */\n uriMaxLength: 2048,\n /** Maximum length of the policy.version label (chars). */\n versionMaxLength: 256,\n} as const;\n\n/**\n * Maximum tolerated skew between occurred_at and iat for evidence receipts (seconds).\n * If occurred_at > iat within this tolerance, a 'occurred_at_skew' warning is emitted.\n * If occurred_at > now + tolerance, E_OCCURRED_AT_FUTURE is a hard error.\n */\nexport const OCCURRED_AT_TOLERANCE_SECONDS = 300;\n\n/**\n * Verification strictness profiles for Wire 0.2.\n * Owned exclusively by @peac/protocol.verifyLocal(); @peac/crypto has no strictness parameter.\n *\n * - 'strict' (default): typ MUST be present and correct; missing typ is a hard error.\n * - 'interop': tolerates missing typ; emits 'typ_missing' warning; routes by peac_version.\n */\nexport type VerificationStrictness = 'strict' | 'interop';\n\n/**\n * JOSE signature algorithm (EdDSA / Ed25519). Re-exported from kernel for layer\n * correctness: @peac/crypto imports all typ/alg constants from @peac/kernel only.\n */\nexport const PEAC_ALG = ALGORITHMS.default;\n\n// ---------------------------------------------------------------------------\n// Legacy aggregate export (unchanged)\n// ---------------------------------------------------------------------------\n\n/**\n * All constants export\n */\nexport const CONSTANTS = {\n WIRE_TYPE,\n WIRE_VERSION,\n ALGORITHMS,\n HEADERS,\n DISCOVERY,\n JWKS,\n RECEIPT,\n LIMITS,\n BUNDLE_VERSION,\n VERIFICATION_REPORT_VERSION,\n HASH,\n VERIFIER_LIMITS,\n VERIFIER_NETWORK,\n VERIFIER_POLICY_VERSION,\n VERIFICATION_MODES,\n} as const;\n"]}
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* PEAC Protocol Constants
|
|
3
|
-
* Derived from specs/kernel/constants.json
|
|
4
|
-
*
|
|
5
|
-
* NOTE: This file is manually synced for v0.9.15.
|
|
6
|
-
* From v0.9.16+, this will be auto-generated via codegen.
|
|
7
3
|
*/
|
|
8
4
|
/**
|
|
9
|
-
* Wire
|
|
10
|
-
*
|
|
5
|
+
* Wire 0.1 JWS `typ` claim (legacy constant name).
|
|
6
|
+
*
|
|
7
|
+
* @deprecated Use `WIRE_01_JWS_TYP` for new code. `WIRE_TYPE` and
|
|
8
|
+
* `WIRE_01_JWS_TYP` resolve to the same string; `WIRE_01_JWS_TYP` is the
|
|
9
|
+
* canonical name at the JWS layer (v0.12.0-preview.1+, Wire 0.2 dual-stack).
|
|
11
10
|
*/
|
|
12
11
|
export declare const WIRE_TYPE: "peac-receipt/0.1";
|
|
13
12
|
/**
|
|
14
|
-
* Wire
|
|
15
|
-
*
|
|
13
|
+
* Wire 0.1 version string (legacy constant name).
|
|
14
|
+
*
|
|
15
|
+
* @deprecated Use `WIRE_VERSIONS` or compare against `WIRE_02_VERSION` for
|
|
16
|
+
* dual-stack version detection. `WIRE_VERSION` remains valid for Wire 0.1
|
|
17
|
+
* but does not participate in the Wire 0.2 version model.
|
|
16
18
|
*/
|
|
17
19
|
export declare const WIRE_VERSION: "0.1";
|
|
18
20
|
/**
|
|
@@ -210,6 +212,85 @@ export declare const VERIFICATION_MODES: {
|
|
|
210
212
|
/** Allow network fetches for key discovery */
|
|
211
213
|
readonly networkAllowed: "network_allowed";
|
|
212
214
|
};
|
|
215
|
+
/**
|
|
216
|
+
* JWS header typ value for Wire 0.1 receipts.
|
|
217
|
+
* Canonical location: @peac/kernel (layer correction from @peac/schema).
|
|
218
|
+
* The existing WIRE_TYPE constant is unchanged; both resolve to the same string.
|
|
219
|
+
* @peac/schema re-exports this as PEAC_WIRE_TYP for backward compatibility.
|
|
220
|
+
*/
|
|
221
|
+
export declare const WIRE_01_JWS_TYP: "peac-receipt/0.1";
|
|
222
|
+
/**
|
|
223
|
+
* JWS header typ value for Wire 0.2 receipts (compact form).
|
|
224
|
+
* Per RFC 7515 Section 4.1.9, the full media type form
|
|
225
|
+
* 'application/interaction-record+jwt' is also accepted by verifiers and
|
|
226
|
+
* normalized to this compact form before returning the header.
|
|
227
|
+
*/
|
|
228
|
+
export declare const WIRE_02_JWS_TYP: "interaction-record+jwt";
|
|
229
|
+
/**
|
|
230
|
+
* All accepted typ values for Wire 0.2 (compact + full media type form).
|
|
231
|
+
* Used internally by @peac/crypto to fast-reject unrelated tokens.
|
|
232
|
+
* Verifiers normalize the full form to WIRE_02_JWS_TYP before returning.
|
|
233
|
+
*/
|
|
234
|
+
export declare const WIRE_02_JWS_TYP_ACCEPT: readonly ["interaction-record+jwt", "application/interaction-record+jwt"];
|
|
235
|
+
/**
|
|
236
|
+
* Wire 0.2 peac_version payload claim value.
|
|
237
|
+
* Discriminates Wire 0.2 envelopes from Wire 0.1 (which have no peac_version field).
|
|
238
|
+
*/
|
|
239
|
+
export declare const WIRE_02_VERSION: "0.2";
|
|
240
|
+
/**
|
|
241
|
+
* All supported wire version strings for dual-stack implementations.
|
|
242
|
+
*/
|
|
243
|
+
export declare const WIRE_VERSIONS: readonly ["0.1", "0.2"];
|
|
244
|
+
/**
|
|
245
|
+
* TypeScript union type for supported wire version values.
|
|
246
|
+
*/
|
|
247
|
+
export type WireVersion = (typeof WIRE_VERSIONS)[number];
|
|
248
|
+
/**
|
|
249
|
+
* Canonical issuer (iss) constraints for Wire 0.2.
|
|
250
|
+
* Supported schemes: 'https' (RFC 3986 origin-only) and 'did' (DID Core).
|
|
251
|
+
* All other schemes produce E_ISS_NOT_CANONICAL.
|
|
252
|
+
*/
|
|
253
|
+
export declare const ISS_CANONICAL: {
|
|
254
|
+
readonly maxLength: 2048;
|
|
255
|
+
readonly supportedSchemes: readonly ["https", "did"];
|
|
256
|
+
/** Default port for https (rejected if explicit in iss). */
|
|
257
|
+
readonly defaultPorts: Record<string, number>;
|
|
258
|
+
};
|
|
259
|
+
/**
|
|
260
|
+
* type claim grammar constraints (open vocabulary: reverse-DNS or absolute URI).
|
|
261
|
+
*/
|
|
262
|
+
export declare const TYPE_GRAMMAR: {
|
|
263
|
+
readonly maxLength: 256;
|
|
264
|
+
};
|
|
265
|
+
/**
|
|
266
|
+
* policy block field constraints (Wire 0.2, DD-151).
|
|
267
|
+
* Separate from ISS_CANONICAL to allow independent evolution of each limit.
|
|
268
|
+
*/
|
|
269
|
+
export declare const POLICY_BLOCK: {
|
|
270
|
+
/** Maximum length of the policy.uri HTTPS hint (chars). */
|
|
271
|
+
readonly uriMaxLength: 2048;
|
|
272
|
+
/** Maximum length of the policy.version label (chars). */
|
|
273
|
+
readonly versionMaxLength: 256;
|
|
274
|
+
};
|
|
275
|
+
/**
|
|
276
|
+
* Maximum tolerated skew between occurred_at and iat for evidence receipts (seconds).
|
|
277
|
+
* If occurred_at > iat within this tolerance, a 'occurred_at_skew' warning is emitted.
|
|
278
|
+
* If occurred_at > now + tolerance, E_OCCURRED_AT_FUTURE is a hard error.
|
|
279
|
+
*/
|
|
280
|
+
export declare const OCCURRED_AT_TOLERANCE_SECONDS = 300;
|
|
281
|
+
/**
|
|
282
|
+
* Verification strictness profiles for Wire 0.2.
|
|
283
|
+
* Owned exclusively by @peac/protocol.verifyLocal(); @peac/crypto has no strictness parameter.
|
|
284
|
+
*
|
|
285
|
+
* - 'strict' (default): typ MUST be present and correct; missing typ is a hard error.
|
|
286
|
+
* - 'interop': tolerates missing typ; emits 'typ_missing' warning; routes by peac_version.
|
|
287
|
+
*/
|
|
288
|
+
export type VerificationStrictness = 'strict' | 'interop';
|
|
289
|
+
/**
|
|
290
|
+
* JOSE signature algorithm (EdDSA / Ed25519). Re-exported from kernel for layer
|
|
291
|
+
* correctness: @peac/crypto imports all typ/alg constants from @peac/kernel only.
|
|
292
|
+
*/
|
|
293
|
+
export declare const PEAC_ALG: "EdDSA";
|
|
213
294
|
/**
|
|
214
295
|
* All constants export
|
|
215
296
|
*/
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,EAAG,kBAA2B,CAAC;AAErD;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,EAAG,KAAc,CAAC;AAE3C;;GAEG;AACH,eAAO,MAAM,UAAU;;;CAGb,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,OAAO;;;;;;;CAQV,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,MAAM;;;;;;;CAOT,CAAC;AAEX;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;;;;CAOhB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,SAAS;;;;CAIZ,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,IAAI;;IAEf,0DAA0D;;;CAGlD,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,OAAO;;;;CAIV,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,MAAM;;;CAGT,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,cAAc,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@ -137,6 +137,29 @@ var VERIFICATION_MODES = {
|
|
|
137
137
|
/** Allow network fetches for key discovery */
|
|
138
138
|
networkAllowed: "network_allowed"
|
|
139
139
|
};
|
|
140
|
+
var WIRE_01_JWS_TYP = "peac-receipt/0.1";
|
|
141
|
+
var WIRE_02_JWS_TYP = "interaction-record+jwt";
|
|
142
|
+
var WIRE_02_JWS_TYP_ACCEPT = [
|
|
143
|
+
"interaction-record+jwt",
|
|
144
|
+
"application/interaction-record+jwt"
|
|
145
|
+
];
|
|
146
|
+
var WIRE_02_VERSION = "0.2";
|
|
147
|
+
var WIRE_VERSIONS = ["0.1", "0.2"];
|
|
148
|
+
var ISS_CANONICAL = {
|
|
149
|
+
maxLength: 2048,
|
|
150
|
+
supportedSchemes: ["https", "did"],
|
|
151
|
+
/** Default port for https (rejected if explicit in iss). */
|
|
152
|
+
defaultPorts: { https: 443 }
|
|
153
|
+
};
|
|
154
|
+
var TYPE_GRAMMAR = { maxLength: 256 };
|
|
155
|
+
var POLICY_BLOCK = {
|
|
156
|
+
/** Maximum length of the policy.uri HTTPS hint (chars). */
|
|
157
|
+
uriMaxLength: 2048,
|
|
158
|
+
/** Maximum length of the policy.version label (chars). */
|
|
159
|
+
versionMaxLength: 256
|
|
160
|
+
};
|
|
161
|
+
var OCCURRED_AT_TOLERANCE_SECONDS = 300;
|
|
162
|
+
var PEAC_ALG = ALGORITHMS.default;
|
|
140
163
|
var CONSTANTS = {
|
|
141
164
|
WIRE_TYPE,
|
|
142
165
|
WIRE_VERSION,
|
|
@@ -155,6 +178,6 @@ var CONSTANTS = {
|
|
|
155
178
|
VERIFICATION_MODES
|
|
156
179
|
};
|
|
157
180
|
|
|
158
|
-
export { ALGORITHMS, BUNDLE_VERSION, CONSTANTS, DISCOVERY, HASH, HEADERS, ISSUER_CONFIG, JWKS, LIMITS, POLICY, PRIVATE_IP_RANGES, RECEIPT, VERIFICATION_MODES, VERIFICATION_REPORT_VERSION, VERIFIER_LIMITS, VERIFIER_NETWORK, VERIFIER_POLICY_VERSION, WIRE_TYPE, WIRE_VERSION, formatHash, isValidHash, parseHash };
|
|
181
|
+
export { ALGORITHMS, BUNDLE_VERSION, CONSTANTS, DISCOVERY, HASH, HEADERS, ISSUER_CONFIG, ISS_CANONICAL, JWKS, LIMITS, OCCURRED_AT_TOLERANCE_SECONDS, PEAC_ALG, POLICY, POLICY_BLOCK, PRIVATE_IP_RANGES, RECEIPT, TYPE_GRAMMAR, VERIFICATION_MODES, VERIFICATION_REPORT_VERSION, VERIFIER_LIMITS, VERIFIER_NETWORK, VERIFIER_POLICY_VERSION, WIRE_01_JWS_TYP, WIRE_02_JWS_TYP, WIRE_02_JWS_TYP_ACCEPT, WIRE_02_VERSION, WIRE_TYPE, WIRE_VERSION, WIRE_VERSIONS, formatHash, isValidHash, parseHash };
|
|
159
182
|
//# sourceMappingURL=constants.mjs.map
|
|
160
183
|
//# sourceMappingURL=constants.mjs.map
|
package/dist/constants.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/constants.ts"],"names":[],"mappings":";AAYO,IAAM,SAAA,GAAY;AAMlB,IAAM,YAAA,GAAe;AAKrB,IAAM,UAAA,GAAa;AAAA,EACxB,SAAA,EAAW,CAAC,OAAO,CAAA;AAAA,EACnB,OAAA,EAAS;AACX;AAKO,IAAM,OAAA,GAAU;AAAA,EACrB,OAAA,EAAS,cAAA;AAAA,EACT,cAAA,EAAgB,sBAAA;AAAA,EAChB,IAAA,EAAM,MAAA;AAAA;AAAA,EAEN,OAAA,EAAS,cAAA;AAAA,EACT,cAAA,EAAgB,sBAAA;AAAA,EAChB,aAAA,EAAe;AACjB;AAQO,IAAM,MAAA,GAAS;AAAA,EACpB,YAAA,EAAc,uBAAA;AAAA,EACd,YAAA,EAAc,WAAA;AAAA,EACd,eAAA,EAAiB,iBAAA;AAAA,EACjB,eAAA,EAAiB,IAAA;AAAA,EACjB,QAAA,EAAU,MAAA;AAAA;AAAA,EACV,QAAA,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AAAA,EAEb,gBAAA,EAAkB,mBAAA;AAAA;AAAA,EAElB,cAAA,EAAgB;AAClB;AAKO,IAAM,SAAA,GAAY;AAAA,EACvB,SAAA;AAAA,EACA,YAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AAAA,EACA,SAAA;AAAA,EACA,IAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA,cAAA;AAAA,EACA,2BAAA;AAAA,EACA,IAAA;AAAA,EACA,eAAA;AAAA,EACA,gBAAA;AAAA,EACA,uBAAA;AAAA,EACA;AACF","file":"constants.mjs","sourcesContent":["/**\n * PEAC Protocol Constants\n * Derived from specs/kernel/constants.json\n *\n * NOTE: This file is manually synced for v0.9.15.\n * From v0.9.16+, this will be auto-generated via codegen.\n */\n\n/**\n * Wire format type for PEAC receipts\n * Normalized to peac-receipt/0.1 per DEC-20260114-002\n */\nexport const WIRE_TYPE = 'peac-receipt/0.1' as const;\n\n/**\n * Wire format version (extracted from WIRE_TYPE)\n * Use this for wire_version fields in receipts\n */\nexport const WIRE_VERSION = '0.1' as const;\n\n/**\n * Supported cryptographic algorithms\n */\nexport const ALGORITHMS = {\n supported: ['EdDSA'] as const,\n default: 'EdDSA' as const,\n} as const;\n\n/**\n * HTTP header names for PEAC protocol\n */\nexport const HEADERS = {\n receipt: 'PEAC-Receipt' as const,\n receiptPointer: 'PEAC-Receipt-Pointer' as const,\n dpop: 'DPoP' as const,\n // Purpose headers (v0.9.24+)\n purpose: 'PEAC-Purpose' as const,\n purposeApplied: 'PEAC-Purpose-Applied' as const,\n purposeReason: 'PEAC-Purpose-Reason' as const,\n} as const;\n\n/**\n * Policy manifest settings (/.well-known/peac.txt)\n *\n * Policy documents declare access terms for agents and gateways.\n * @see docs/specs/PEAC-TXT.md\n */\nexport const POLICY = {\n manifestPath: '/.well-known/peac.txt' as const,\n fallbackPath: '/peac.txt' as const,\n manifestVersion: 'peac-policy/0.1' as const,\n cacheTtlSeconds: 3600,\n maxBytes: 262144, // 256 KiB\n maxDepth: 8,\n} as const;\n\n/**\n * Issuer configuration settings (/.well-known/peac-issuer.json)\n *\n * Issuer config enables verifiers to discover JWKS and verification endpoints.\n * @see docs/specs/PEAC-ISSUER.md\n */\nexport const ISSUER_CONFIG = {\n configPath: '/.well-known/peac-issuer.json' as const,\n configVersion: 'peac-issuer/0.1' as const,\n cacheTtlSeconds: 3600,\n maxBytes: 65536, // 64 KiB\n maxDepth: 4,\n fetchTimeoutMs: 10000,\n} as const;\n\n/**\n * @deprecated Use POLICY instead. Will be removed in v1.0.\n */\nexport const DISCOVERY = {\n manifestPath: POLICY.manifestPath,\n manifestVersion: 'peac/0.9' as const,\n cacheTtlSeconds: POLICY.cacheTtlSeconds,\n} as const;\n\n/**\n * JWKS rotation and revocation settings\n */\nexport const JWKS = {\n rotationDays: 90,\n /** Normative minimum overlap period (DD-148, v0.11.3+) */\n overlapDays: 30,\n emergencyRevocationHours: 24,\n} as const;\n\n/**\n * Receipt validation constants\n */\nexport const RECEIPT = {\n minReceiptIdLength: 16,\n maxReceiptIdLength: 64,\n defaultTtlSeconds: 86400, // 24 hours\n} as const;\n\n/**\n * Payment amount validation limits (in cents/smallest currency unit)\n */\nexport const LIMITS = {\n maxAmountCents: 999999999999,\n minAmountCents: 1,\n} as const;\n\n/**\n * Bundle format version.\n * Used in dispute bundles, audit bundles, and archive bundles.\n */\nexport const BUNDLE_VERSION = 'peac-bundle/0.1' as const;\n\n/**\n * Verification report format version.\n */\nexport const VERIFICATION_REPORT_VERSION = 'peac-verification-report/0.1' as const;\n\n/**\n * Hash format constants and utilities.\n * All hashes use the self-describing format: sha256:<64 lowercase hex chars>\n */\nexport const HASH = {\n /** Canonical hash algorithm */\n algorithm: 'sha256' as const,\n\n /** Hash prefix pattern */\n prefix: 'sha256:' as const,\n\n /** Valid hash regex: sha256:<64 lowercase hex> */\n pattern: /^sha256:[0-9a-f]{64}$/,\n\n /** Hex-only pattern for legacy comparison */\n hexPattern: /^[0-9a-f]{64}$/,\n};\n\n/**\n * Parse a sha256:<hex> hash string into components.\n * Returns null if the format is invalid.\n *\n * @param hash - Hash string to parse (e.g., \"sha256:abc123...\")\n * @returns Parsed hash or null if invalid\n */\nexport function parseHash(hash: string): { alg: 'sha256'; hex: string } | null {\n if (!HASH.pattern.test(hash)) {\n return null;\n }\n return {\n alg: 'sha256',\n hex: hash.slice(7), // Remove 'sha256:' prefix\n };\n}\n\n/**\n * Format a hex string as a sha256:<hex> hash.\n * Validates that the hex is exactly 64 lowercase characters.\n *\n * @param hex - Hex string (64 lowercase characters)\n * @returns Formatted hash or null if invalid\n */\nexport function formatHash(hex: string): string | null {\n if (!HASH.hexPattern.test(hex)) {\n return null;\n }\n return `sha256:${hex}`;\n}\n\n/**\n * Validate a hash string is in the correct format.\n *\n * @param hash - Hash string to validate\n * @returns true if valid sha256:<64 hex> format\n */\nexport function isValidHash(hash: string): boolean {\n return HASH.pattern.test(hash);\n}\n\n/**\n * Verifier security limits per VERIFIER-SECURITY-MODEL.md\n */\nexport const VERIFIER_LIMITS = {\n /** Maximum receipt size in bytes (256 KB) */\n maxReceiptBytes: 262144,\n /** Maximum number of claims in a receipt */\n maxClaimsCount: 100,\n /** Maximum extension size in bytes (64 KB) */\n maxExtensionBytes: 65536,\n /** Maximum string length for individual claims (64 KB) */\n maxStringLength: 65536,\n /** Maximum JWKS document size in bytes (64 KB) */\n maxJwksBytes: 65536,\n /** Maximum number of keys in a JWKS */\n maxJwksKeys: 20,\n /** Maximum individual key size in bytes */\n maxKeySize: 4096,\n /** Network fetch timeout in milliseconds */\n fetchTimeoutMs: 5000,\n /** Maximum number of redirects to follow */\n maxRedirects: 3,\n /** Maximum network response size in bytes (256 KB) */\n maxResponseBytes: 262144,\n} as const;\n\n/**\n * Verifier network security settings per VERIFIER-SECURITY-MODEL.md\n */\nexport const VERIFIER_NETWORK = {\n /** Only allow HTTPS URLs */\n httpsOnly: true,\n /** Block requests to private IP ranges */\n blockPrivateIps: true,\n /** Default redirect policy (false = no redirects) */\n allowRedirects: false,\n} as const;\n\n/**\n * Private IPv4 CIDR blocks to block for SSRF protection\n */\nexport const PRIVATE_IP_RANGES = {\n /** RFC 1918 private ranges */\n rfc1918: ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16'] as const,\n /** Link-local addresses */\n linkLocal: ['169.254.0.0/16'] as const,\n /** Loopback addresses */\n loopback: ['127.0.0.0/8'] as const,\n /** IPv6 loopback */\n ipv6Loopback: ['::1/128'] as const,\n /** IPv6 link-local */\n ipv6LinkLocal: ['fe80::/10'] as const,\n} as const;\n\n/**\n * Verifier policy version\n */\nexport const VERIFIER_POLICY_VERSION = 'peac-verifier-policy/0.1' as const;\n\n/**\n * Verification modes per VERIFIER-SECURITY-MODEL.md\n */\nexport const VERIFICATION_MODES = {\n /** All verification in browser/client, may fetch JWKS */\n clientSide: 'client_side' as const,\n /** No network access, uses bundled/pinned keys */\n offlineOnly: 'offline_only' as const,\n /** Prefer offline, fallback to network */\n offlinePreferred: 'offline_preferred' as const,\n /** Allow network fetches for key discovery */\n networkAllowed: 'network_allowed' as const,\n} as const;\n\n/**\n * All constants export\n */\nexport const CONSTANTS = {\n WIRE_TYPE,\n WIRE_VERSION,\n ALGORITHMS,\n HEADERS,\n DISCOVERY,\n JWKS,\n RECEIPT,\n LIMITS,\n BUNDLE_VERSION,\n VERIFICATION_REPORT_VERSION,\n HASH,\n VERIFIER_LIMITS,\n VERIFIER_NETWORK,\n VERIFIER_POLICY_VERSION,\n VERIFICATION_MODES,\n} as const;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/constants.ts"],"names":[],"mappings":";AAWO,IAAM,SAAA,GAAY;AASlB,IAAM,YAAA,GAAe;AAKrB,IAAM,UAAA,GAAa;AAAA,EACxB,SAAA,EAAW,CAAC,OAAO,CAAA;AAAA,EACnB,OAAA,EAAS;AACX;AAKO,IAAM,OAAA,GAAU;AAAA,EACrB,OAAA,EAAS,cAAA;AAAA,EACT,cAAA,EAAgB,sBAAA;AAAA,EA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EACA;AACF","file":"constants.mjs","sourcesContent":["/**\n * PEAC Protocol Constants\n */\n\n/**\n * Wire 0.1 JWS `typ` claim (legacy constant name).\n *\n * @deprecated Use `WIRE_01_JWS_TYP` for new code. `WIRE_TYPE` and\n * `WIRE_01_JWS_TYP` resolve to the same string; `WIRE_01_JWS_TYP` is the\n * canonical name at the JWS layer (v0.12.0-preview.1+, Wire 0.2 dual-stack).\n */\nexport const WIRE_TYPE = 'peac-receipt/0.1' as const;\n\n/**\n * Wire 0.1 version string (legacy constant name).\n *\n * @deprecated Use `WIRE_VERSIONS` or compare against `WIRE_02_VERSION` for\n * dual-stack version detection. `WIRE_VERSION` remains valid for Wire 0.1\n * but does not participate in the Wire 0.2 version model.\n */\nexport const WIRE_VERSION = '0.1' as const;\n\n/**\n * Supported cryptographic algorithms\n */\nexport const ALGORITHMS = {\n supported: ['EdDSA'] as const,\n default: 'EdDSA' as const,\n} as const;\n\n/**\n * HTTP header names for PEAC protocol\n */\nexport const HEADERS = {\n receipt: 'PEAC-Receipt' as const,\n receiptPointer: 'PEAC-Receipt-Pointer' as const,\n dpop: 'DPoP' as const,\n // Purpose headers (v0.9.24+)\n purpose: 'PEAC-Purpose' as const,\n purposeApplied: 'PEAC-Purpose-Applied' as const,\n purposeReason: 'PEAC-Purpose-Reason' as const,\n} as const;\n\n/**\n * Policy manifest settings (/.well-known/peac.txt)\n *\n * Policy documents declare access terms for agents and gateways.\n * @see docs/specs/PEAC-TXT.md\n */\nexport const POLICY = {\n manifestPath: '/.well-known/peac.txt' as const,\n fallbackPath: '/peac.txt' as const,\n manifestVersion: 'peac-policy/0.1' as const,\n cacheTtlSeconds: 3600,\n maxBytes: 262144, // 256 KiB\n maxDepth: 8,\n} as const;\n\n/**\n * Issuer configuration settings (/.well-known/peac-issuer.json)\n *\n * Issuer config enables verifiers to discover JWKS and verification endpoints.\n * @see docs/specs/PEAC-ISSUER.md\n */\nexport const ISSUER_CONFIG = {\n configPath: '/.well-known/peac-issuer.json' as const,\n configVersion: 'peac-issuer/0.1' as const,\n cacheTtlSeconds: 3600,\n maxBytes: 65536, // 64 KiB\n maxDepth: 4,\n fetchTimeoutMs: 10000,\n} as const;\n\n/**\n * @deprecated Use POLICY instead. Will be removed in v1.0.\n */\nexport const DISCOVERY = {\n manifestPath: POLICY.manifestPath,\n manifestVersion: 'peac/0.9' as const,\n cacheTtlSeconds: POLICY.cacheTtlSeconds,\n} as const;\n\n/**\n * JWKS rotation and revocation settings\n */\nexport const JWKS = {\n rotationDays: 90,\n /** Normative minimum overlap period (DD-148, v0.11.3+) */\n overlapDays: 30,\n emergencyRevocationHours: 24,\n} as const;\n\n/**\n * Receipt validation constants\n */\nexport const RECEIPT = {\n minReceiptIdLength: 16,\n maxReceiptIdLength: 64,\n defaultTtlSeconds: 86400, // 24 hours\n} as const;\n\n/**\n * Payment amount validation limits (in cents/smallest currency unit)\n */\nexport const LIMITS = {\n maxAmountCents: 999999999999,\n minAmountCents: 1,\n} as const;\n\n/**\n * Bundle format version.\n * Used in dispute bundles, audit bundles, and archive bundles.\n */\nexport const BUNDLE_VERSION = 'peac-bundle/0.1' as const;\n\n/**\n * Verification report format version.\n */\nexport const VERIFICATION_REPORT_VERSION = 'peac-verification-report/0.1' as const;\n\n/**\n * Hash format constants and utilities.\n * All hashes use the self-describing format: sha256:<64 lowercase hex chars>\n */\nexport const HASH = {\n /** Canonical hash algorithm */\n algorithm: 'sha256' as const,\n\n /** Hash prefix pattern */\n prefix: 'sha256:' as const,\n\n /** Valid hash regex: sha256:<64 lowercase hex> */\n pattern: /^sha256:[0-9a-f]{64}$/,\n\n /** Hex-only pattern for legacy comparison */\n hexPattern: /^[0-9a-f]{64}$/,\n};\n\n/**\n * Parse a sha256:<hex> hash string into components.\n * Returns null if the format is invalid.\n *\n * @param hash - Hash string to parse (e.g., \"sha256:abc123...\")\n * @returns Parsed hash or null if invalid\n */\nexport function parseHash(hash: string): { alg: 'sha256'; hex: string } | null {\n if (!HASH.pattern.test(hash)) {\n return null;\n }\n return {\n alg: 'sha256',\n hex: hash.slice(7), // Remove 'sha256:' prefix\n };\n}\n\n/**\n * Format a hex string as a sha256:<hex> hash.\n * Validates that the hex is exactly 64 lowercase characters.\n *\n * @param hex - Hex string (64 lowercase characters)\n * @returns Formatted hash or null if invalid\n */\nexport function formatHash(hex: string): string | null {\n if (!HASH.hexPattern.test(hex)) {\n return null;\n }\n return `sha256:${hex}`;\n}\n\n/**\n * Validate a hash string is in the correct format.\n *\n * @param hash - Hash string to validate\n * @returns true if valid sha256:<64 hex> format\n */\nexport function isValidHash(hash: string): boolean {\n return HASH.pattern.test(hash);\n}\n\n/**\n * Verifier security limits per VERIFIER-SECURITY-MODEL.md\n */\nexport const VERIFIER_LIMITS = {\n /** Maximum receipt size in bytes (256 KB) */\n maxReceiptBytes: 262144,\n /** Maximum number of claims in a receipt */\n maxClaimsCount: 100,\n /** Maximum extension size in bytes (64 KB) */\n maxExtensionBytes: 65536,\n /** Maximum string length for individual claims (64 KB) */\n maxStringLength: 65536,\n /** Maximum JWKS document size in bytes (64 KB) */\n maxJwksBytes: 65536,\n /** Maximum number of keys in a JWKS */\n maxJwksKeys: 20,\n /** Maximum individual key size in bytes */\n maxKeySize: 4096,\n /** Network fetch timeout in milliseconds */\n fetchTimeoutMs: 5000,\n /** Maximum number of redirects to follow */\n maxRedirects: 3,\n /** Maximum network response size in bytes (256 KB) */\n maxResponseBytes: 262144,\n} as const;\n\n/**\n * Verifier network security settings per VERIFIER-SECURITY-MODEL.md\n */\nexport const VERIFIER_NETWORK = {\n /** Only allow HTTPS URLs */\n httpsOnly: true,\n /** Block requests to private IP ranges */\n blockPrivateIps: true,\n /** Default redirect policy (false = no redirects) */\n allowRedirects: false,\n} as const;\n\n/**\n * Private IPv4 CIDR blocks to block for SSRF protection\n */\nexport const PRIVATE_IP_RANGES = {\n /** RFC 1918 private ranges */\n rfc1918: ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16'] as const,\n /** Link-local addresses */\n linkLocal: ['169.254.0.0/16'] as const,\n /** Loopback addresses */\n loopback: ['127.0.0.0/8'] as const,\n /** IPv6 loopback */\n ipv6Loopback: ['::1/128'] as const,\n /** IPv6 link-local */\n ipv6LinkLocal: ['fe80::/10'] as const,\n} as const;\n\n/**\n * Verifier policy version\n */\nexport const VERIFIER_POLICY_VERSION = 'peac-verifier-policy/0.1' as const;\n\n/**\n * Verification modes per VERIFIER-SECURITY-MODEL.md\n */\nexport const VERIFICATION_MODES = {\n /** All verification in browser/client, may fetch JWKS */\n clientSide: 'client_side' as const,\n /** No network access, uses bundled/pinned keys */\n offlineOnly: 'offline_only' as const,\n /** Prefer offline, fallback to network */\n offlinePreferred: 'offline_preferred' as const,\n /** Allow network fetches for key discovery */\n networkAllowed: 'network_allowed' as const,\n} as const;\n\n// ---------------------------------------------------------------------------\n// Wire 0.2 constants (v0.12.0-preview.1, DD-156)\n// ---------------------------------------------------------------------------\n\n/**\n * JWS header typ value for Wire 0.1 receipts.\n * Canonical location: @peac/kernel (layer correction from @peac/schema).\n * The existing WIRE_TYPE constant is unchanged; both resolve to the same string.\n * @peac/schema re-exports this as PEAC_WIRE_TYP for backward compatibility.\n */\nexport const WIRE_01_JWS_TYP = 'peac-receipt/0.1' as const;\n\n/**\n * JWS header typ value for Wire 0.2 receipts (compact form).\n * Per RFC 7515 Section 4.1.9, the full media type form\n * 'application/interaction-record+jwt' is also accepted by verifiers and\n * normalized to this compact form before returning the header.\n */\nexport const WIRE_02_JWS_TYP = 'interaction-record+jwt' as const;\n\n/**\n * All accepted typ values for Wire 0.2 (compact + full media type form).\n * Used internally by @peac/crypto to fast-reject unrelated tokens.\n * Verifiers normalize the full form to WIRE_02_JWS_TYP before returning.\n */\nexport const WIRE_02_JWS_TYP_ACCEPT = [\n 'interaction-record+jwt',\n 'application/interaction-record+jwt',\n] as const;\n\n/**\n * Wire 0.2 peac_version payload claim value.\n * Discriminates Wire 0.2 envelopes from Wire 0.1 (which have no peac_version field).\n */\nexport const WIRE_02_VERSION = '0.2' as const;\n\n/**\n * All supported wire version strings for dual-stack implementations.\n */\nexport const WIRE_VERSIONS = ['0.1', '0.2'] as const;\n\n/**\n * TypeScript union type for supported wire version values.\n */\nexport type WireVersion = (typeof WIRE_VERSIONS)[number];\n\n/**\n * Canonical issuer (iss) constraints for Wire 0.2.\n * Supported schemes: 'https' (RFC 3986 origin-only) and 'did' (DID Core).\n * All other schemes produce E_ISS_NOT_CANONICAL.\n */\nexport const ISS_CANONICAL = {\n maxLength: 2048,\n supportedSchemes: ['https', 'did'] as const,\n /** Default port for https (rejected if explicit in iss). */\n defaultPorts: { https: 443 } as Record<string, number>,\n} as const;\n\n/**\n * type claim grammar constraints (open vocabulary: reverse-DNS or absolute URI).\n */\nexport const TYPE_GRAMMAR = { maxLength: 256 } as const;\n\n/**\n * policy block field constraints (Wire 0.2, DD-151).\n * Separate from ISS_CANONICAL to allow independent evolution of each limit.\n */\nexport const POLICY_BLOCK = {\n /** Maximum length of the policy.uri HTTPS hint (chars). */\n uriMaxLength: 2048,\n /** Maximum length of the policy.version label (chars). */\n versionMaxLength: 256,\n} as const;\n\n/**\n * Maximum tolerated skew between occurred_at and iat for evidence receipts (seconds).\n * If occurred_at > iat within this tolerance, a 'occurred_at_skew' warning is emitted.\n * If occurred_at > now + tolerance, E_OCCURRED_AT_FUTURE is a hard error.\n */\nexport const OCCURRED_AT_TOLERANCE_SECONDS = 300;\n\n/**\n * Verification strictness profiles for Wire 0.2.\n * Owned exclusively by @peac/protocol.verifyLocal(); @peac/crypto has no strictness parameter.\n *\n * - 'strict' (default): typ MUST be present and correct; missing typ is a hard error.\n * - 'interop': tolerates missing typ; emits 'typ_missing' warning; routes by peac_version.\n */\nexport type VerificationStrictness = 'strict' | 'interop';\n\n/**\n * JOSE signature algorithm (EdDSA / Ed25519). Re-exported from kernel for layer\n * correctness: @peac/crypto imports all typ/alg constants from @peac/kernel only.\n */\nexport const PEAC_ALG = ALGORITHMS.default;\n\n// ---------------------------------------------------------------------------\n// Legacy aggregate export (unchanged)\n// ---------------------------------------------------------------------------\n\n/**\n * All constants export\n */\nexport const CONSTANTS = {\n WIRE_TYPE,\n WIRE_VERSION,\n ALGORITHMS,\n HEADERS,\n DISCOVERY,\n JWKS,\n RECEIPT,\n LIMITS,\n BUNDLE_VERSION,\n VERIFICATION_REPORT_VERSION,\n HASH,\n VERIFIER_LIMITS,\n VERIFIER_NETWORK,\n VERIFIER_POLICY_VERSION,\n VERIFICATION_MODES,\n} as const;\n"]}
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
*
|
|
4
4
|
* AUTO-GENERATED from specs/kernel/errors.json
|
|
5
5
|
* DO NOT EDIT MANUALLY - run: npx tsx scripts/codegen-errors.ts
|
|
6
|
-
* Spec version: 0.
|
|
6
|
+
* Spec version: 0.12.0-preview.2
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
9
|
* Canonical error categories derived from specs/kernel/errors.json.
|
|
10
10
|
* This is the single source of truth for all error category definitions.
|
|
11
11
|
* Sorted alphabetically. This ordering is a codegen invariant.
|
|
12
12
|
*/
|
|
13
|
-
export declare const ERROR_CATEGORIES: readonly ["attribution", "bundle", "control", "dispute", "identity", "infrastructure", "interaction", "ucp", "validation", "verification", "verifier", "workflow"];
|
|
13
|
+
export declare const ERROR_CATEGORIES: readonly ["attribution", "bundle", "control", "cryptography", "dispute", "identity", "infrastructure", "interaction", "ucp", "validation", "verification", "verifier", "workflow"];
|
|
14
14
|
/**
|
|
15
15
|
* Error category type - union of all categories in specs/kernel/errors.json
|
|
16
16
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-categories.generated.d.ts","sourceRoot":"","sources":["../src/error-categories.generated.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"error-categories.generated.d.ts","sourceRoot":"","sources":["../src/error-categories.generated.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,oLAcnB,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC"}
|
package/dist/errors.cjs
CHANGED
|
@@ -36,6 +36,12 @@ var ERROR_CODES = {
|
|
|
36
36
|
// Control error codes
|
|
37
37
|
E_CONTROL_DENIED: "E_CONTROL_DENIED",
|
|
38
38
|
E_CONTROL_REVIEW_REQUIRED: "E_CONTROL_REVIEW_REQUIRED",
|
|
39
|
+
// Cryptography error codes
|
|
40
|
+
E_JWS_B64_REJECTED: "E_JWS_B64_REJECTED",
|
|
41
|
+
E_JWS_CRIT_REJECTED: "E_JWS_CRIT_REJECTED",
|
|
42
|
+
E_JWS_EMBEDDED_KEY: "E_JWS_EMBEDDED_KEY",
|
|
43
|
+
E_JWS_MISSING_KID: "E_JWS_MISSING_KID",
|
|
44
|
+
E_JWS_ZIP_REJECTED: "E_JWS_ZIP_REJECTED",
|
|
39
45
|
// Dispute error codes
|
|
40
46
|
E_DISPUTE_DUPLICATE: "E_DISPUTE_DUPLICATE",
|
|
41
47
|
E_DISPUTE_EXPIRED: "E_DISPUTE_EXPIRED",
|
|
@@ -109,6 +115,10 @@ var ERROR_CODES = {
|
|
|
109
115
|
E_UCP_VERIFICATION_FAILED: "E_UCP_VERIFICATION_FAILED",
|
|
110
116
|
// Validation error codes
|
|
111
117
|
E_CONSTRAINT_VIOLATION: "E_CONSTRAINT_VIOLATION",
|
|
118
|
+
E_EAT_INVALID_CBOR: "E_EAT_INVALID_CBOR",
|
|
119
|
+
E_EAT_INVALID_COSE: "E_EAT_INVALID_COSE",
|
|
120
|
+
E_EAT_SIZE_EXCEEDED: "E_EAT_SIZE_EXCEEDED",
|
|
121
|
+
E_EAT_UNSUPPORTED_ALG: "E_EAT_UNSUPPORTED_ALG",
|
|
112
122
|
E_EVIDENCE_NOT_JSON: "E_EVIDENCE_NOT_JSON",
|
|
113
123
|
E_EXPIRED: "E_EXPIRED",
|
|
114
124
|
E_INVALID_AMOUNT: "E_INVALID_AMOUNT",
|
|
@@ -116,16 +126,27 @@ var ERROR_CODES = {
|
|
|
116
126
|
E_INVALID_CURRENCY: "E_INVALID_CURRENCY",
|
|
117
127
|
E_INVALID_FORMAT: "E_INVALID_FORMAT",
|
|
118
128
|
E_INVALID_ISSUER: "E_INVALID_ISSUER",
|
|
129
|
+
E_INVALID_KIND: "E_INVALID_KIND",
|
|
130
|
+
E_INVALID_PILLAR_VALUE: "E_INVALID_PILLAR_VALUE",
|
|
119
131
|
E_INVALID_RAIL: "E_INVALID_RAIL",
|
|
120
132
|
E_INVALID_RECEIPT_ID: "E_INVALID_RECEIPT_ID",
|
|
121
133
|
E_INVALID_SUBJECT: "E_INVALID_SUBJECT",
|
|
134
|
+
E_INVALID_TYPE: "E_INVALID_TYPE",
|
|
135
|
+
E_ISS_NOT_CANONICAL: "E_ISS_NOT_CANONICAL",
|
|
122
136
|
E_MISSING_EXP: "E_MISSING_EXP",
|
|
123
137
|
E_MISSING_REQUIRED_CLAIM: "E_MISSING_REQUIRED_CLAIM",
|
|
124
138
|
E_NOT_YET_VALID: "E_NOT_YET_VALID",
|
|
139
|
+
E_OCCURRED_AT_FUTURE: "E_OCCURRED_AT_FUTURE",
|
|
140
|
+
E_OCCURRED_AT_ON_CHALLENGE: "E_OCCURRED_AT_ON_CHALLENGE",
|
|
125
141
|
E_PARSE_ATTESTATION_INVALID: "E_PARSE_ATTESTATION_INVALID",
|
|
126
142
|
E_PARSE_COMMERCE_INVALID: "E_PARSE_COMMERCE_INVALID",
|
|
127
143
|
E_PARSE_INVALID_INPUT: "E_PARSE_INVALID_INPUT",
|
|
144
|
+
E_PILLARS_NOT_SORTED: "E_PILLARS_NOT_SORTED",
|
|
145
|
+
E_POLICY_BINDING_FAILED: "E_POLICY_BINDING_FAILED",
|
|
146
|
+
E_UNSUPPORTED_WIRE_VERSION: "E_UNSUPPORTED_WIRE_VERSION",
|
|
147
|
+
E_WIRE_VERSION_MISMATCH: "E_WIRE_VERSION_MISMATCH",
|
|
128
148
|
// Verification error codes
|
|
149
|
+
E_EAT_SIGNATURE_FAILED: "E_EAT_SIGNATURE_FAILED",
|
|
129
150
|
E_INVALID_SIGNATURE: "E_INVALID_SIGNATURE",
|
|
130
151
|
E_KEY_NOT_FOUND: "E_KEY_NOT_FOUND",
|
|
131
152
|
E_KID_REUSE_DETECTED: "E_KID_REUSE_DETECTED",
|
|
@@ -447,6 +468,52 @@ var ERRORS = {
|
|
|
447
468
|
next_action: "contact_issuer",
|
|
448
469
|
category: "control"
|
|
449
470
|
},
|
|
471
|
+
// Cryptography error codes
|
|
472
|
+
E_JWS_B64_REJECTED: {
|
|
473
|
+
code: "E_JWS_B64_REJECTED",
|
|
474
|
+
http_status: 400,
|
|
475
|
+
title: "JWS b64:false Rejected",
|
|
476
|
+
description: "JWS header contains b64:false (RFC 7797 unencoded payload); unencoded payloads are not supported",
|
|
477
|
+
retryable: false,
|
|
478
|
+
next_action: "abort",
|
|
479
|
+
category: "cryptography"
|
|
480
|
+
},
|
|
481
|
+
E_JWS_CRIT_REJECTED: {
|
|
482
|
+
code: "E_JWS_CRIT_REJECTED",
|
|
483
|
+
http_status: 400,
|
|
484
|
+
title: "JWS crit Header Rejected",
|
|
485
|
+
description: "JWS header contains a crit field; critical header extensions are not supported and are rejected",
|
|
486
|
+
retryable: false,
|
|
487
|
+
next_action: "abort",
|
|
488
|
+
category: "cryptography"
|
|
489
|
+
},
|
|
490
|
+
E_JWS_EMBEDDED_KEY: {
|
|
491
|
+
code: "E_JWS_EMBEDDED_KEY",
|
|
492
|
+
http_status: 400,
|
|
493
|
+
title: "JWS Embedded Key Rejected",
|
|
494
|
+
description: "JWS header contains an embedded key (jwk, x5c, x5u, or jku); embedded key material is rejected by the PEAC JOSE hardening rules",
|
|
495
|
+
retryable: false,
|
|
496
|
+
next_action: "abort",
|
|
497
|
+
category: "cryptography"
|
|
498
|
+
},
|
|
499
|
+
E_JWS_MISSING_KID: {
|
|
500
|
+
code: "E_JWS_MISSING_KID",
|
|
501
|
+
http_status: 400,
|
|
502
|
+
title: "JWS kid Missing or Invalid",
|
|
503
|
+
description: "JWS header kid field is absent, empty, or exceeds the maximum allowed length (256 characters)",
|
|
504
|
+
retryable: false,
|
|
505
|
+
next_action: "abort",
|
|
506
|
+
category: "cryptography"
|
|
507
|
+
},
|
|
508
|
+
E_JWS_ZIP_REJECTED: {
|
|
509
|
+
code: "E_JWS_ZIP_REJECTED",
|
|
510
|
+
http_status: 400,
|
|
511
|
+
title: "JWS zip Header Rejected",
|
|
512
|
+
description: "JWS header contains a zip compression field; payload compression is not supported",
|
|
513
|
+
retryable: false,
|
|
514
|
+
next_action: "abort",
|
|
515
|
+
category: "cryptography"
|
|
516
|
+
},
|
|
450
517
|
// Dispute error codes
|
|
451
518
|
E_DISPUTE_DUPLICATE: {
|
|
452
519
|
code: "E_DISPUTE_DUPLICATE",
|
|
@@ -1056,6 +1123,42 @@ var ERRORS = {
|
|
|
1056
1123
|
next_action: "retry_with_different_input",
|
|
1057
1124
|
category: "validation"
|
|
1058
1125
|
},
|
|
1126
|
+
E_EAT_INVALID_CBOR: {
|
|
1127
|
+
code: "E_EAT_INVALID_CBOR",
|
|
1128
|
+
http_status: 400,
|
|
1129
|
+
title: "EAT Invalid CBOR",
|
|
1130
|
+
description: "EAT token is not valid CBOR or the payload is not a CBOR map",
|
|
1131
|
+
retryable: false,
|
|
1132
|
+
next_action: "abort",
|
|
1133
|
+
category: "validation"
|
|
1134
|
+
},
|
|
1135
|
+
E_EAT_INVALID_COSE: {
|
|
1136
|
+
code: "E_EAT_INVALID_COSE",
|
|
1137
|
+
http_status: 400,
|
|
1138
|
+
title: "EAT Invalid COSE",
|
|
1139
|
+
description: "EAT token is not a valid COSE_Sign1 structure per RFC 9052 Section 4.2",
|
|
1140
|
+
retryable: false,
|
|
1141
|
+
next_action: "abort",
|
|
1142
|
+
category: "validation"
|
|
1143
|
+
},
|
|
1144
|
+
E_EAT_SIZE_EXCEEDED: {
|
|
1145
|
+
code: "E_EAT_SIZE_EXCEEDED",
|
|
1146
|
+
http_status: 400,
|
|
1147
|
+
title: "EAT Size Exceeded",
|
|
1148
|
+
description: "EAT token exceeds the 64 KB size limit enforced before CBOR decode",
|
|
1149
|
+
retryable: false,
|
|
1150
|
+
next_action: "abort",
|
|
1151
|
+
category: "validation"
|
|
1152
|
+
},
|
|
1153
|
+
E_EAT_UNSUPPORTED_ALG: {
|
|
1154
|
+
code: "E_EAT_UNSUPPORTED_ALG",
|
|
1155
|
+
http_status: 400,
|
|
1156
|
+
title: "EAT Unsupported Algorithm",
|
|
1157
|
+
description: "COSE_Sign1 uses an unsupported algorithm; only EdDSA (alg: -8) is supported",
|
|
1158
|
+
retryable: false,
|
|
1159
|
+
next_action: "abort",
|
|
1160
|
+
category: "validation"
|
|
1161
|
+
},
|
|
1059
1162
|
E_EVIDENCE_NOT_JSON: {
|
|
1060
1163
|
code: "E_EVIDENCE_NOT_JSON",
|
|
1061
1164
|
http_status: 400,
|
|
@@ -1119,6 +1222,24 @@ var ERRORS = {
|
|
|
1119
1222
|
next_action: "retry_with_different_input",
|
|
1120
1223
|
category: "validation"
|
|
1121
1224
|
},
|
|
1225
|
+
E_INVALID_KIND: {
|
|
1226
|
+
code: "E_INVALID_KIND",
|
|
1227
|
+
http_status: 400,
|
|
1228
|
+
title: "Invalid Kind",
|
|
1229
|
+
description: "Wire 0.2 receipt kind field is missing or not one of the accepted structural kinds (evidence, challenge)",
|
|
1230
|
+
retryable: false,
|
|
1231
|
+
next_action: "abort",
|
|
1232
|
+
category: "validation"
|
|
1233
|
+
},
|
|
1234
|
+
E_INVALID_PILLAR_VALUE: {
|
|
1235
|
+
code: "E_INVALID_PILLAR_VALUE",
|
|
1236
|
+
http_status: 400,
|
|
1237
|
+
title: "Invalid Pillar Value",
|
|
1238
|
+
description: "Wire 0.2 pillars array contains an unrecognized pillar value outside the closed 10-value taxonomy",
|
|
1239
|
+
retryable: false,
|
|
1240
|
+
next_action: "abort",
|
|
1241
|
+
category: "validation"
|
|
1242
|
+
},
|
|
1122
1243
|
E_INVALID_RAIL: {
|
|
1123
1244
|
code: "E_INVALID_RAIL",
|
|
1124
1245
|
http_status: 400,
|
|
@@ -1146,6 +1267,24 @@ var ERRORS = {
|
|
|
1146
1267
|
next_action: "retry_with_different_input",
|
|
1147
1268
|
category: "validation"
|
|
1148
1269
|
},
|
|
1270
|
+
E_INVALID_TYPE: {
|
|
1271
|
+
code: "E_INVALID_TYPE",
|
|
1272
|
+
http_status: 400,
|
|
1273
|
+
title: "Invalid Type",
|
|
1274
|
+
description: "Wire 0.2 receipt type field is missing or does not conform to the required grammar (reverse-DNS or absolute URI)",
|
|
1275
|
+
retryable: false,
|
|
1276
|
+
next_action: "abort",
|
|
1277
|
+
category: "validation"
|
|
1278
|
+
},
|
|
1279
|
+
E_ISS_NOT_CANONICAL: {
|
|
1280
|
+
code: "E_ISS_NOT_CANONICAL",
|
|
1281
|
+
http_status: 400,
|
|
1282
|
+
title: "Issuer Not Canonical",
|
|
1283
|
+
description: "Wire 0.2 iss claim does not conform to canonical form: must be an https:// ASCII origin (no default port, no path) or a did: identifier",
|
|
1284
|
+
retryable: false,
|
|
1285
|
+
next_action: "abort",
|
|
1286
|
+
category: "validation"
|
|
1287
|
+
},
|
|
1149
1288
|
E_MISSING_EXP: {
|
|
1150
1289
|
code: "E_MISSING_EXP",
|
|
1151
1290
|
http_status: 400,
|
|
@@ -1173,6 +1312,24 @@ var ERRORS = {
|
|
|
1173
1312
|
next_action: "retry_after_delay",
|
|
1174
1313
|
category: "validation"
|
|
1175
1314
|
},
|
|
1315
|
+
E_OCCURRED_AT_FUTURE: {
|
|
1316
|
+
code: "E_OCCURRED_AT_FUTURE",
|
|
1317
|
+
http_status: 400,
|
|
1318
|
+
title: "occurred_at in Future",
|
|
1319
|
+
description: "Wire 0.2 occurred_at is more than the tolerance window ahead of the current time; the timestamp appears to be in the future",
|
|
1320
|
+
retryable: false,
|
|
1321
|
+
next_action: "retry_after_delay",
|
|
1322
|
+
category: "validation"
|
|
1323
|
+
},
|
|
1324
|
+
E_OCCURRED_AT_ON_CHALLENGE: {
|
|
1325
|
+
code: "E_OCCURRED_AT_ON_CHALLENGE",
|
|
1326
|
+
http_status: 400,
|
|
1327
|
+
title: "occurred_at on Challenge",
|
|
1328
|
+
description: "Wire 0.2 occurred_at field is present on a challenge-kind receipt; occurred_at is only permitted on evidence-kind receipts",
|
|
1329
|
+
retryable: false,
|
|
1330
|
+
next_action: "abort",
|
|
1331
|
+
category: "validation"
|
|
1332
|
+
},
|
|
1176
1333
|
E_PARSE_ATTESTATION_INVALID: {
|
|
1177
1334
|
code: "E_PARSE_ATTESTATION_INVALID",
|
|
1178
1335
|
http_status: 400,
|
|
@@ -1200,7 +1357,52 @@ var ERRORS = {
|
|
|
1200
1357
|
next_action: "retry_with_different_input",
|
|
1201
1358
|
category: "validation"
|
|
1202
1359
|
},
|
|
1360
|
+
E_PILLARS_NOT_SORTED: {
|
|
1361
|
+
code: "E_PILLARS_NOT_SORTED",
|
|
1362
|
+
http_status: 400,
|
|
1363
|
+
title: "Pillars Not Sorted",
|
|
1364
|
+
description: "Wire 0.2 pillars array is not in ascending lexicographic order or contains duplicates",
|
|
1365
|
+
retryable: false,
|
|
1366
|
+
next_action: "abort",
|
|
1367
|
+
category: "validation"
|
|
1368
|
+
},
|
|
1369
|
+
E_POLICY_BINDING_FAILED: {
|
|
1370
|
+
code: "E_POLICY_BINDING_FAILED",
|
|
1371
|
+
http_status: 400,
|
|
1372
|
+
title: "Policy Binding Failed",
|
|
1373
|
+
description: "Wire 0.2 policy.digest does not match the computed digest of the provided policy document",
|
|
1374
|
+
retryable: false,
|
|
1375
|
+
next_action: "none",
|
|
1376
|
+
category: "validation"
|
|
1377
|
+
},
|
|
1378
|
+
E_UNSUPPORTED_WIRE_VERSION: {
|
|
1379
|
+
code: "E_UNSUPPORTED_WIRE_VERSION",
|
|
1380
|
+
http_status: 400,
|
|
1381
|
+
title: "Unsupported Wire Version",
|
|
1382
|
+
description: "Receipt peac_version field specifies a wire version that is not supported by this implementation",
|
|
1383
|
+
retryable: false,
|
|
1384
|
+
next_action: "abort",
|
|
1385
|
+
category: "validation"
|
|
1386
|
+
},
|
|
1387
|
+
E_WIRE_VERSION_MISMATCH: {
|
|
1388
|
+
code: "E_WIRE_VERSION_MISMATCH",
|
|
1389
|
+
http_status: 400,
|
|
1390
|
+
title: "Wire Version Mismatch",
|
|
1391
|
+
description: "JWS header typ value and peac_version payload claim indicate different wire versions; the receipt is incoherent",
|
|
1392
|
+
retryable: false,
|
|
1393
|
+
next_action: "abort",
|
|
1394
|
+
category: "validation"
|
|
1395
|
+
},
|
|
1203
1396
|
// Verification error codes
|
|
1397
|
+
E_EAT_SIGNATURE_FAILED: {
|
|
1398
|
+
code: "E_EAT_SIGNATURE_FAILED",
|
|
1399
|
+
http_status: 400,
|
|
1400
|
+
title: "EAT Signature Failed",
|
|
1401
|
+
description: "COSE_Sign1 Ed25519 signature verification failed over the Sig_structure",
|
|
1402
|
+
retryable: false,
|
|
1403
|
+
next_action: "retry_with_different_key",
|
|
1404
|
+
category: "verification"
|
|
1405
|
+
},
|
|
1204
1406
|
E_INVALID_SIGNATURE: {
|
|
1205
1407
|
code: "E_INVALID_SIGNATURE",
|
|
1206
1408
|
http_status: 400,
|