@peac/kernel 0.11.2 → 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/README.md +45 -5
- package/dist/__tests__/registries.test.d.ts +2 -0
- package/dist/__tests__/registries.test.d.ts.map +1 -0
- package/dist/constants.cjs +35 -1
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.ts +93 -10
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.mjs +26 -2
- 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 +182 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.generated.d.ts +19 -1
- package/dist/errors.generated.d.ts.map +1 -1
- package/dist/errors.mjs +182 -0
- package/dist/errors.mjs.map +1 -1
- package/dist/index.cjs +218 -1
- 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 +209 -2
- 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/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @peac/kernel
|
|
2
2
|
|
|
3
|
-
PEAC protocol kernel
|
|
3
|
+
PEAC protocol kernel: normative constants, error codes, registries, and core types. Zero runtime dependencies.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -8,18 +8,58 @@ PEAC protocol kernel - normative constants, errors, and registries
|
|
|
8
8
|
pnpm add @peac/kernel
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## What It Does
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
`@peac/kernel` is Layer 0 of the PEAC protocol stack. It provides the type definitions, constants, and error codes that all other packages depend on. It has zero runtime dependencies and no I/O.
|
|
14
|
+
|
|
15
|
+
## How Do I Use It?
|
|
16
|
+
|
|
17
|
+
### Import types for evidence carriers
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import type { PeacEvidenceCarrier, CarrierAdapter, CarrierMeta } from '@peac/kernel';
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Use wire format constants
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { WIRE_TYPE, HEADERS, ALGORITHMS } from '@peac/kernel';
|
|
27
|
+
|
|
28
|
+
console.log(WIRE_TYPE); // 'peac-receipt/0.1'
|
|
29
|
+
console.log(HEADERS.receipt); // 'PEAC-Receipt'
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Access error definitions with recovery hints
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { ERRORS } from '@peac/kernel';
|
|
36
|
+
|
|
37
|
+
const err = ERRORS.E_JWKS_FETCH_FAILED;
|
|
38
|
+
console.log(err.code); // 'E_JWKS_FETCH_FAILED'
|
|
39
|
+
console.log(err.retryable); // true
|
|
40
|
+
console.log(err.next_action); // 'retry_after_delay'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Use registry enums
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
import { PAYMENT_RAILS, CHALLENGE_TYPES, PURPOSE_TOKENS } from '@peac/kernel';
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Integrates With
|
|
50
|
+
|
|
51
|
+
- `@peac/schema` (Layer 1): Zod validators built on kernel types
|
|
52
|
+
- `@peac/crypto` (Layer 2): Signing/verification using kernel constants
|
|
53
|
+
- `@peac/protocol` (Layer 3): High-level API using kernel error codes
|
|
54
|
+
- All `@peac/mappings-*` and `@peac/adapter-*` packages (Layer 4)
|
|
14
55
|
|
|
15
56
|
## For Agent Developers
|
|
16
57
|
|
|
17
58
|
If you are building an AI agent or MCP server that needs evidence receipts:
|
|
18
59
|
|
|
19
60
|
- Start with [`@peac/mcp-server`](https://www.npmjs.com/package/@peac/mcp-server) for a ready-to-use MCP tool server
|
|
20
|
-
- See the [llms.txt](https://github.com/peacprotocol/peac/blob/main/llms.txt) for a concise overview of all packages
|
|
21
61
|
- Use `@peac/protocol` for programmatic receipt issuance and verification
|
|
22
|
-
-
|
|
62
|
+
- See the [llms.txt](https://github.com/peacprotocol/peac/blob/main/llms.txt) for a concise overview
|
|
23
63
|
|
|
24
64
|
## License
|
|
25
65
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registries.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/registries.test.ts"],"names":[],"mappings":""}
|
package/dist/constants.cjs
CHANGED
|
@@ -41,7 +41,8 @@ var DISCOVERY = {
|
|
|
41
41
|
};
|
|
42
42
|
var JWKS = {
|
|
43
43
|
rotationDays: 90,
|
|
44
|
-
|
|
44
|
+
/** Normative minimum overlap period (DD-148, v0.11.3+) */
|
|
45
|
+
overlapDays: 30,
|
|
45
46
|
emergencyRevocationHours: 24
|
|
46
47
|
};
|
|
47
48
|
var RECEIPT = {
|
|
@@ -138,6 +139,29 @@ var VERIFICATION_MODES = {
|
|
|
138
139
|
/** Allow network fetches for key discovery */
|
|
139
140
|
networkAllowed: "network_allowed"
|
|
140
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;
|
|
141
165
|
var CONSTANTS = {
|
|
142
166
|
WIRE_TYPE,
|
|
143
167
|
WIRE_VERSION,
|
|
@@ -163,18 +187,28 @@ exports.DISCOVERY = DISCOVERY;
|
|
|
163
187
|
exports.HASH = HASH;
|
|
164
188
|
exports.HEADERS = HEADERS;
|
|
165
189
|
exports.ISSUER_CONFIG = ISSUER_CONFIG;
|
|
190
|
+
exports.ISS_CANONICAL = ISS_CANONICAL;
|
|
166
191
|
exports.JWKS = JWKS;
|
|
167
192
|
exports.LIMITS = LIMITS;
|
|
193
|
+
exports.OCCURRED_AT_TOLERANCE_SECONDS = OCCURRED_AT_TOLERANCE_SECONDS;
|
|
194
|
+
exports.PEAC_ALG = PEAC_ALG;
|
|
168
195
|
exports.POLICY = POLICY;
|
|
196
|
+
exports.POLICY_BLOCK = POLICY_BLOCK;
|
|
169
197
|
exports.PRIVATE_IP_RANGES = PRIVATE_IP_RANGES;
|
|
170
198
|
exports.RECEIPT = RECEIPT;
|
|
199
|
+
exports.TYPE_GRAMMAR = TYPE_GRAMMAR;
|
|
171
200
|
exports.VERIFICATION_MODES = VERIFICATION_MODES;
|
|
172
201
|
exports.VERIFICATION_REPORT_VERSION = VERIFICATION_REPORT_VERSION;
|
|
173
202
|
exports.VERIFIER_LIMITS = VERIFIER_LIMITS;
|
|
174
203
|
exports.VERIFIER_NETWORK = VERIFIER_NETWORK;
|
|
175
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;
|
|
176
209
|
exports.WIRE_TYPE = WIRE_TYPE;
|
|
177
210
|
exports.WIRE_VERSION = WIRE_VERSION;
|
|
211
|
+
exports.WIRE_VERSIONS = WIRE_VERSIONS;
|
|
178
212
|
exports.formatHash = formatHash;
|
|
179
213
|
exports.isValidHash = isValidHash;
|
|
180
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,QAAA,EAAU;AACZ;AAQO,IAAM,aAAA,GA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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 overlapDays: 7,\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,EAChB,IAAA,EAAM,MAAA;AAAA;AAAA,EAEN,OAAA,EAAS,cAAA;AAAA,EACT,cAA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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
|
/**
|
|
@@ -74,7 +76,8 @@ export declare const DISCOVERY: {
|
|
|
74
76
|
*/
|
|
75
77
|
export declare const JWKS: {
|
|
76
78
|
readonly rotationDays: 90;
|
|
77
|
-
|
|
79
|
+
/** Normative minimum overlap period (DD-148, v0.11.3+) */
|
|
80
|
+
readonly overlapDays: 30;
|
|
78
81
|
readonly emergencyRevocationHours: 24;
|
|
79
82
|
};
|
|
80
83
|
/**
|
|
@@ -209,6 +212,85 @@ export declare const VERIFICATION_MODES: {
|
|
|
209
212
|
/** Allow network fetches for key discovery */
|
|
210
213
|
readonly networkAllowed: "network_allowed";
|
|
211
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";
|
|
212
294
|
/**
|
|
213
295
|
* All constants export
|
|
214
296
|
*/
|
|
@@ -234,7 +316,8 @@ export declare const CONSTANTS: {
|
|
|
234
316
|
};
|
|
235
317
|
readonly JWKS: {
|
|
236
318
|
readonly rotationDays: 90;
|
|
237
|
-
|
|
319
|
+
/** Normative minimum overlap period (DD-148, v0.11.3+) */
|
|
320
|
+
readonly overlapDays: 30;
|
|
238
321
|
readonly emergencyRevocationHours: 24;
|
|
239
322
|
};
|
|
240
323
|
readonly RECEIPT: {
|
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,UAA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;;;;;;QA5QpB,0DAA0D;;;;;;;;;;;;;;;;QAsC1D,+BAA+B;;QAG/B,0BAA0B;;QAG1B,kDAAkD;;QAGlD,6CAA6C;;;;QAiD7C,6CAA6C;;QAE7C,4CAA4C;;QAE5C,8CAA8C;;QAE9C,0DAA0D;;QAE1D,kDAAkD;;QAElD,uCAAuC;;QAEvC,2CAA2C;;QAE3C,4CAA4C;;QAE5C,4CAA4C;;QAE5C,sDAAsD;;;;QAQtD,4BAA4B;;QAE5B,0CAA0C;;QAE1C,qDAAqD;;;;;QA6BrD,yDAAyD;;QAEzD,kDAAkD;;QAElD,0CAA0C;;QAE1C,8CAA8C;;;CA2HtC,CAAC"}
|
package/dist/constants.mjs
CHANGED
|
@@ -39,7 +39,8 @@ var DISCOVERY = {
|
|
|
39
39
|
};
|
|
40
40
|
var JWKS = {
|
|
41
41
|
rotationDays: 90,
|
|
42
|
-
|
|
42
|
+
/** Normative minimum overlap period (DD-148, v0.11.3+) */
|
|
43
|
+
overlapDays: 30,
|
|
43
44
|
emergencyRevocationHours: 24
|
|
44
45
|
};
|
|
45
46
|
var RECEIPT = {
|
|
@@ -136,6 +137,29 @@ var VERIFICATION_MODES = {
|
|
|
136
137
|
/** Allow network fetches for key discovery */
|
|
137
138
|
networkAllowed: "network_allowed"
|
|
138
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;
|
|
139
163
|
var CONSTANTS = {
|
|
140
164
|
WIRE_TYPE,
|
|
141
165
|
WIRE_VERSION,
|
|
@@ -154,6 +178,6 @@ var CONSTANTS = {
|
|
|
154
178
|
VERIFICATION_MODES
|
|
155
179
|
};
|
|
156
180
|
|
|
157
|
-
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 };
|
|
158
182
|
//# sourceMappingURL=constants.mjs.map
|
|
159
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,EAAU;AACZ;AAQO,IAAM,aAAA,GAAgB;AAAA,EAC3B,UAAA,EAAY,+BAAA;AAAA,EACZ,aAAA,EAAe,iBAAA;AAAA,EACf,eAAA,EAAiB,IAAA;AAAA,EACjB,QAAA,EAAU,KAAA;AAAA;AAAA,EACV,QAAA,EAAU,CAAA;AAAA,EACV,cAAA,EAAgB;AAClB;AAKO,IAAM,SAAA,GAAY;AAAA,EACvB,cAAc,MAAA,CAAO,YAAA;AAAA,EACrB,eAAA,EAAiB,UAAA;AAAA,EACjB,iBAAiB,MAAA,CAAO;AAC1B;AAKO,IAAM,IAAA,GAAO;AAAA,EAClB,YAAA,EAAc,EAAA;AAAA,EACd,WAAA,EAAa,CAAA;AAAA,EACb,wBAAA,EAA0B;AAC5B;AAKO,IAAM,OAAA,GAAU;AAAA,EACrB,kBAAA,EAAoB,EAAA;AA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A;AAAA;AAAA,EAEZ,cAAA,EAAgB,GAAA;AAAA;AAAA,EAEhB,YAAA,EAAc,CAAA;AAAA;AAAA,EAEd,gBAAA,EAAkB;AACpB;AAKO,IAAM,gBAAA,GAAmB;AAAA;AAAA,EAE9B,SAAA,EAAW,IAAA;AAAA;AAAA,EAEX,eAAA,EAAiB,IAAA;AAAA;AAAA,EAEjB,cAAA,EAAgB;AAClB;AAKO,IAAM,iBAAA,GAAoB;AAAA;AAAA,EAE/B,OAAA,EAAS,CAAC,YAAA,EAAc,eAAA,EAAiB,gBAAgB,CAAA;AAAA;AAAA,EAEzD,SAAA,EAAW,CAAC,gBAAgB,CAAA;AAAA;AAAA,EAE5B,QAAA,EAAU,CAAC,aAAa,CAAA;AAAA;AAAA,EAExB,YAAA,EAAc,CAAC,SAAS,CAAA;AAAA;AAAA,EAExB,aAAA,EAAe,CAAC,WAAW;AAC7B;AAKO,IAAM,uBAAA,GAA0B;AAKhC,IAAM,kBAAA,GAAqB;AAAA;AAAA,EAEhC,UAAA,EAAY,aAAA;AAAA;AAAA,EAEZ,WAAA,EAAa,cAAA;AAAA;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 overlapDays: 7,\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,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,EAAU;AACZ;AAQO,IAAM,aAAA,GAAgB;AAAA,EAC3B,UAAA,EAAY,+BAAA;AAAA,EACZ,aAAA,EAAe,iBAAA;AAAA,EACf,eAAA,EAAiB,IAAA;AAAA,EACjB,QAAA,EAAU,KAAA;AAAA;AAAA,EACV,QAAA,EAAU,CAAA;AAAA,EACV,cAAA,EAAgB;AAClB;AAKO,IAAM,SAAA,GAAY;AAAA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KAAK;AAYnC,IAAM,aAAA,GAAgB;AAAA,EAC3B,SAAA,EAAW,IAAA;AAAA,EACX,gBAAA,EAAkB,CAAC,OAAA,EAAS,KAAK,CAAA;AAAA;AAAA,EAEjC,YAAA,EAAc,EAAE,KAAA,EAAO,GAAA;AACzB;AAKO,IAAM,YAAA,GAAe,EAAE,SAAA,EAAW,GAAA;AAMlC,IAAM,YAAA,GAAe;AAAA;AAAA,EAE1B,YAAA,EAAc,IAAA;AAAA;AAAA,EAEd,gBAAA,EAAkB;AACpB;AAOO,IAAM,6BAAA,GAAgC;AAetC,IAAM,WAAW,UAAA,CAAW;AAS5B,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 */\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"}
|