@peac/kernel 0.11.3 → 0.12.0-preview.1
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 +152 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.generated.d.ts +16 -1
- package/dist/errors.generated.d.ts.map +1 -1
- package/dist/errors.mjs +152 -0
- package/dist/errors.mjs.map +1 -1
- package/dist/index.cjs +186 -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 +177 -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.1
|
|
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",
|
|
@@ -116,15 +122,25 @@ var ERROR_CODES = {
|
|
|
116
122
|
E_INVALID_CURRENCY: "E_INVALID_CURRENCY",
|
|
117
123
|
E_INVALID_FORMAT: "E_INVALID_FORMAT",
|
|
118
124
|
E_INVALID_ISSUER: "E_INVALID_ISSUER",
|
|
125
|
+
E_INVALID_KIND: "E_INVALID_KIND",
|
|
126
|
+
E_INVALID_PILLAR_VALUE: "E_INVALID_PILLAR_VALUE",
|
|
119
127
|
E_INVALID_RAIL: "E_INVALID_RAIL",
|
|
120
128
|
E_INVALID_RECEIPT_ID: "E_INVALID_RECEIPT_ID",
|
|
121
129
|
E_INVALID_SUBJECT: "E_INVALID_SUBJECT",
|
|
130
|
+
E_INVALID_TYPE: "E_INVALID_TYPE",
|
|
131
|
+
E_ISS_NOT_CANONICAL: "E_ISS_NOT_CANONICAL",
|
|
122
132
|
E_MISSING_EXP: "E_MISSING_EXP",
|
|
123
133
|
E_MISSING_REQUIRED_CLAIM: "E_MISSING_REQUIRED_CLAIM",
|
|
124
134
|
E_NOT_YET_VALID: "E_NOT_YET_VALID",
|
|
135
|
+
E_OCCURRED_AT_FUTURE: "E_OCCURRED_AT_FUTURE",
|
|
136
|
+
E_OCCURRED_AT_ON_CHALLENGE: "E_OCCURRED_AT_ON_CHALLENGE",
|
|
125
137
|
E_PARSE_ATTESTATION_INVALID: "E_PARSE_ATTESTATION_INVALID",
|
|
126
138
|
E_PARSE_COMMERCE_INVALID: "E_PARSE_COMMERCE_INVALID",
|
|
127
139
|
E_PARSE_INVALID_INPUT: "E_PARSE_INVALID_INPUT",
|
|
140
|
+
E_PILLARS_NOT_SORTED: "E_PILLARS_NOT_SORTED",
|
|
141
|
+
E_POLICY_BINDING_FAILED: "E_POLICY_BINDING_FAILED",
|
|
142
|
+
E_UNSUPPORTED_WIRE_VERSION: "E_UNSUPPORTED_WIRE_VERSION",
|
|
143
|
+
E_WIRE_VERSION_MISMATCH: "E_WIRE_VERSION_MISMATCH",
|
|
128
144
|
// Verification error codes
|
|
129
145
|
E_INVALID_SIGNATURE: "E_INVALID_SIGNATURE",
|
|
130
146
|
E_KEY_NOT_FOUND: "E_KEY_NOT_FOUND",
|
|
@@ -447,6 +463,52 @@ var ERRORS = {
|
|
|
447
463
|
next_action: "contact_issuer",
|
|
448
464
|
category: "control"
|
|
449
465
|
},
|
|
466
|
+
// Cryptography error codes
|
|
467
|
+
E_JWS_B64_REJECTED: {
|
|
468
|
+
code: "E_JWS_B64_REJECTED",
|
|
469
|
+
http_status: 400,
|
|
470
|
+
title: "JWS b64:false Rejected",
|
|
471
|
+
description: "JWS header contains b64:false (RFC 7797 unencoded payload); unencoded payloads are not supported",
|
|
472
|
+
retryable: false,
|
|
473
|
+
next_action: "abort",
|
|
474
|
+
category: "cryptography"
|
|
475
|
+
},
|
|
476
|
+
E_JWS_CRIT_REJECTED: {
|
|
477
|
+
code: "E_JWS_CRIT_REJECTED",
|
|
478
|
+
http_status: 400,
|
|
479
|
+
title: "JWS crit Header Rejected",
|
|
480
|
+
description: "JWS header contains a crit field; critical header extensions are not supported and are rejected",
|
|
481
|
+
retryable: false,
|
|
482
|
+
next_action: "abort",
|
|
483
|
+
category: "cryptography"
|
|
484
|
+
},
|
|
485
|
+
E_JWS_EMBEDDED_KEY: {
|
|
486
|
+
code: "E_JWS_EMBEDDED_KEY",
|
|
487
|
+
http_status: 400,
|
|
488
|
+
title: "JWS Embedded Key Rejected",
|
|
489
|
+
description: "JWS header contains an embedded key (jwk, x5c, x5u, or jku); embedded key material is rejected by the PEAC JOSE hardening rules",
|
|
490
|
+
retryable: false,
|
|
491
|
+
next_action: "abort",
|
|
492
|
+
category: "cryptography"
|
|
493
|
+
},
|
|
494
|
+
E_JWS_MISSING_KID: {
|
|
495
|
+
code: "E_JWS_MISSING_KID",
|
|
496
|
+
http_status: 400,
|
|
497
|
+
title: "JWS kid Missing or Invalid",
|
|
498
|
+
description: "JWS header kid field is absent, empty, or exceeds the maximum allowed length (256 characters)",
|
|
499
|
+
retryable: false,
|
|
500
|
+
next_action: "abort",
|
|
501
|
+
category: "cryptography"
|
|
502
|
+
},
|
|
503
|
+
E_JWS_ZIP_REJECTED: {
|
|
504
|
+
code: "E_JWS_ZIP_REJECTED",
|
|
505
|
+
http_status: 400,
|
|
506
|
+
title: "JWS zip Header Rejected",
|
|
507
|
+
description: "JWS header contains a zip compression field; payload compression is not supported",
|
|
508
|
+
retryable: false,
|
|
509
|
+
next_action: "abort",
|
|
510
|
+
category: "cryptography"
|
|
511
|
+
},
|
|
450
512
|
// Dispute error codes
|
|
451
513
|
E_DISPUTE_DUPLICATE: {
|
|
452
514
|
code: "E_DISPUTE_DUPLICATE",
|
|
@@ -1119,6 +1181,24 @@ var ERRORS = {
|
|
|
1119
1181
|
next_action: "retry_with_different_input",
|
|
1120
1182
|
category: "validation"
|
|
1121
1183
|
},
|
|
1184
|
+
E_INVALID_KIND: {
|
|
1185
|
+
code: "E_INVALID_KIND",
|
|
1186
|
+
http_status: 400,
|
|
1187
|
+
title: "Invalid Kind",
|
|
1188
|
+
description: "Wire 0.2 receipt kind field is missing or not one of the accepted structural kinds (evidence, challenge)",
|
|
1189
|
+
retryable: false,
|
|
1190
|
+
next_action: "abort",
|
|
1191
|
+
category: "validation"
|
|
1192
|
+
},
|
|
1193
|
+
E_INVALID_PILLAR_VALUE: {
|
|
1194
|
+
code: "E_INVALID_PILLAR_VALUE",
|
|
1195
|
+
http_status: 400,
|
|
1196
|
+
title: "Invalid Pillar Value",
|
|
1197
|
+
description: "Wire 0.2 pillars array contains an unrecognized pillar value outside the closed 10-value taxonomy",
|
|
1198
|
+
retryable: false,
|
|
1199
|
+
next_action: "abort",
|
|
1200
|
+
category: "validation"
|
|
1201
|
+
},
|
|
1122
1202
|
E_INVALID_RAIL: {
|
|
1123
1203
|
code: "E_INVALID_RAIL",
|
|
1124
1204
|
http_status: 400,
|
|
@@ -1146,6 +1226,24 @@ var ERRORS = {
|
|
|
1146
1226
|
next_action: "retry_with_different_input",
|
|
1147
1227
|
category: "validation"
|
|
1148
1228
|
},
|
|
1229
|
+
E_INVALID_TYPE: {
|
|
1230
|
+
code: "E_INVALID_TYPE",
|
|
1231
|
+
http_status: 400,
|
|
1232
|
+
title: "Invalid Type",
|
|
1233
|
+
description: "Wire 0.2 receipt type field is missing or does not conform to the required grammar (reverse-DNS or absolute URI)",
|
|
1234
|
+
retryable: false,
|
|
1235
|
+
next_action: "abort",
|
|
1236
|
+
category: "validation"
|
|
1237
|
+
},
|
|
1238
|
+
E_ISS_NOT_CANONICAL: {
|
|
1239
|
+
code: "E_ISS_NOT_CANONICAL",
|
|
1240
|
+
http_status: 400,
|
|
1241
|
+
title: "Issuer Not Canonical",
|
|
1242
|
+
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",
|
|
1243
|
+
retryable: false,
|
|
1244
|
+
next_action: "abort",
|
|
1245
|
+
category: "validation"
|
|
1246
|
+
},
|
|
1149
1247
|
E_MISSING_EXP: {
|
|
1150
1248
|
code: "E_MISSING_EXP",
|
|
1151
1249
|
http_status: 400,
|
|
@@ -1173,6 +1271,24 @@ var ERRORS = {
|
|
|
1173
1271
|
next_action: "retry_after_delay",
|
|
1174
1272
|
category: "validation"
|
|
1175
1273
|
},
|
|
1274
|
+
E_OCCURRED_AT_FUTURE: {
|
|
1275
|
+
code: "E_OCCURRED_AT_FUTURE",
|
|
1276
|
+
http_status: 400,
|
|
1277
|
+
title: "occurred_at in Future",
|
|
1278
|
+
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",
|
|
1279
|
+
retryable: false,
|
|
1280
|
+
next_action: "retry_after_delay",
|
|
1281
|
+
category: "validation"
|
|
1282
|
+
},
|
|
1283
|
+
E_OCCURRED_AT_ON_CHALLENGE: {
|
|
1284
|
+
code: "E_OCCURRED_AT_ON_CHALLENGE",
|
|
1285
|
+
http_status: 400,
|
|
1286
|
+
title: "occurred_at on Challenge",
|
|
1287
|
+
description: "Wire 0.2 occurred_at field is present on a challenge-kind receipt; occurred_at is only permitted on evidence-kind receipts",
|
|
1288
|
+
retryable: false,
|
|
1289
|
+
next_action: "abort",
|
|
1290
|
+
category: "validation"
|
|
1291
|
+
},
|
|
1176
1292
|
E_PARSE_ATTESTATION_INVALID: {
|
|
1177
1293
|
code: "E_PARSE_ATTESTATION_INVALID",
|
|
1178
1294
|
http_status: 400,
|
|
@@ -1200,6 +1316,42 @@ var ERRORS = {
|
|
|
1200
1316
|
next_action: "retry_with_different_input",
|
|
1201
1317
|
category: "validation"
|
|
1202
1318
|
},
|
|
1319
|
+
E_PILLARS_NOT_SORTED: {
|
|
1320
|
+
code: "E_PILLARS_NOT_SORTED",
|
|
1321
|
+
http_status: 400,
|
|
1322
|
+
title: "Pillars Not Sorted",
|
|
1323
|
+
description: "Wire 0.2 pillars array is not in ascending lexicographic order or contains duplicates",
|
|
1324
|
+
retryable: false,
|
|
1325
|
+
next_action: "abort",
|
|
1326
|
+
category: "validation"
|
|
1327
|
+
},
|
|
1328
|
+
E_POLICY_BINDING_FAILED: {
|
|
1329
|
+
code: "E_POLICY_BINDING_FAILED",
|
|
1330
|
+
http_status: 400,
|
|
1331
|
+
title: "Policy Binding Failed",
|
|
1332
|
+
description: "Wire 0.2 policy.digest does not match the computed digest of the provided policy document",
|
|
1333
|
+
retryable: false,
|
|
1334
|
+
next_action: "none",
|
|
1335
|
+
category: "validation"
|
|
1336
|
+
},
|
|
1337
|
+
E_UNSUPPORTED_WIRE_VERSION: {
|
|
1338
|
+
code: "E_UNSUPPORTED_WIRE_VERSION",
|
|
1339
|
+
http_status: 400,
|
|
1340
|
+
title: "Unsupported Wire Version",
|
|
1341
|
+
description: "Receipt peac_version field specifies a wire version that is not supported by this implementation",
|
|
1342
|
+
retryable: false,
|
|
1343
|
+
next_action: "abort",
|
|
1344
|
+
category: "validation"
|
|
1345
|
+
},
|
|
1346
|
+
E_WIRE_VERSION_MISMATCH: {
|
|
1347
|
+
code: "E_WIRE_VERSION_MISMATCH",
|
|
1348
|
+
http_status: 400,
|
|
1349
|
+
title: "Wire Version Mismatch",
|
|
1350
|
+
description: "JWS header typ value and peac_version payload claim indicate different wire versions; the receipt is incoherent",
|
|
1351
|
+
retryable: false,
|
|
1352
|
+
next_action: "abort",
|
|
1353
|
+
category: "validation"
|
|
1354
|
+
},
|
|
1203
1355
|
// Verification error codes
|
|
1204
1356
|
E_INVALID_SIGNATURE: {
|
|
1205
1357
|
code: "E_INVALID_SIGNATURE",
|