@peac/kernel 0.11.3 → 0.12.0-preview.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -5,6 +5,7 @@ var ERROR_CATEGORIES = [
5
5
  "attribution",
6
6
  "bundle",
7
7
  "control",
8
+ "cryptography",
8
9
  "dispute",
9
10
  "identity",
10
11
  "infrastructure",
@@ -155,6 +156,29 @@ var VERIFICATION_MODES = {
155
156
  /** Allow network fetches for key discovery */
156
157
  networkAllowed: "network_allowed"
157
158
  };
159
+ var WIRE_01_JWS_TYP = "peac-receipt/0.1";
160
+ var WIRE_02_JWS_TYP = "interaction-record+jwt";
161
+ var WIRE_02_JWS_TYP_ACCEPT = [
162
+ "interaction-record+jwt",
163
+ "application/interaction-record+jwt"
164
+ ];
165
+ var WIRE_02_VERSION = "0.2";
166
+ var WIRE_VERSIONS = ["0.1", "0.2"];
167
+ var ISS_CANONICAL = {
168
+ maxLength: 2048,
169
+ supportedSchemes: ["https", "did"],
170
+ /** Default port for https (rejected if explicit in iss). */
171
+ defaultPorts: { https: 443 }
172
+ };
173
+ var TYPE_GRAMMAR = { maxLength: 256 };
174
+ var POLICY_BLOCK = {
175
+ /** Maximum length of the policy.uri HTTPS hint (chars). */
176
+ uriMaxLength: 2048,
177
+ /** Maximum length of the policy.version label (chars). */
178
+ versionMaxLength: 256
179
+ };
180
+ var OCCURRED_AT_TOLERANCE_SECONDS = 300;
181
+ var PEAC_ALG = ALGORITHMS.default;
158
182
  var CONSTANTS = {
159
183
  WIRE_TYPE,
160
184
  WIRE_VERSION,
@@ -209,6 +233,12 @@ var ERROR_CODES = {
209
233
  // Control error codes
210
234
  E_CONTROL_DENIED: "E_CONTROL_DENIED",
211
235
  E_CONTROL_REVIEW_REQUIRED: "E_CONTROL_REVIEW_REQUIRED",
236
+ // Cryptography error codes
237
+ E_JWS_B64_REJECTED: "E_JWS_B64_REJECTED",
238
+ E_JWS_CRIT_REJECTED: "E_JWS_CRIT_REJECTED",
239
+ E_JWS_EMBEDDED_KEY: "E_JWS_EMBEDDED_KEY",
240
+ E_JWS_MISSING_KID: "E_JWS_MISSING_KID",
241
+ E_JWS_ZIP_REJECTED: "E_JWS_ZIP_REJECTED",
212
242
  // Dispute error codes
213
243
  E_DISPUTE_DUPLICATE: "E_DISPUTE_DUPLICATE",
214
244
  E_DISPUTE_EXPIRED: "E_DISPUTE_EXPIRED",
@@ -282,6 +312,10 @@ var ERROR_CODES = {
282
312
  E_UCP_VERIFICATION_FAILED: "E_UCP_VERIFICATION_FAILED",
283
313
  // Validation error codes
284
314
  E_CONSTRAINT_VIOLATION: "E_CONSTRAINT_VIOLATION",
315
+ E_EAT_INVALID_CBOR: "E_EAT_INVALID_CBOR",
316
+ E_EAT_INVALID_COSE: "E_EAT_INVALID_COSE",
317
+ E_EAT_SIZE_EXCEEDED: "E_EAT_SIZE_EXCEEDED",
318
+ E_EAT_UNSUPPORTED_ALG: "E_EAT_UNSUPPORTED_ALG",
285
319
  E_EVIDENCE_NOT_JSON: "E_EVIDENCE_NOT_JSON",
286
320
  E_EXPIRED: "E_EXPIRED",
287
321
  E_INVALID_AMOUNT: "E_INVALID_AMOUNT",
@@ -289,16 +323,27 @@ var ERROR_CODES = {
289
323
  E_INVALID_CURRENCY: "E_INVALID_CURRENCY",
290
324
  E_INVALID_FORMAT: "E_INVALID_FORMAT",
291
325
  E_INVALID_ISSUER: "E_INVALID_ISSUER",
326
+ E_INVALID_KIND: "E_INVALID_KIND",
327
+ E_INVALID_PILLAR_VALUE: "E_INVALID_PILLAR_VALUE",
292
328
  E_INVALID_RAIL: "E_INVALID_RAIL",
293
329
  E_INVALID_RECEIPT_ID: "E_INVALID_RECEIPT_ID",
294
330
  E_INVALID_SUBJECT: "E_INVALID_SUBJECT",
331
+ E_INVALID_TYPE: "E_INVALID_TYPE",
332
+ E_ISS_NOT_CANONICAL: "E_ISS_NOT_CANONICAL",
295
333
  E_MISSING_EXP: "E_MISSING_EXP",
296
334
  E_MISSING_REQUIRED_CLAIM: "E_MISSING_REQUIRED_CLAIM",
297
335
  E_NOT_YET_VALID: "E_NOT_YET_VALID",
336
+ E_OCCURRED_AT_FUTURE: "E_OCCURRED_AT_FUTURE",
337
+ E_OCCURRED_AT_ON_CHALLENGE: "E_OCCURRED_AT_ON_CHALLENGE",
298
338
  E_PARSE_ATTESTATION_INVALID: "E_PARSE_ATTESTATION_INVALID",
299
339
  E_PARSE_COMMERCE_INVALID: "E_PARSE_COMMERCE_INVALID",
300
340
  E_PARSE_INVALID_INPUT: "E_PARSE_INVALID_INPUT",
341
+ E_PILLARS_NOT_SORTED: "E_PILLARS_NOT_SORTED",
342
+ E_POLICY_BINDING_FAILED: "E_POLICY_BINDING_FAILED",
343
+ E_UNSUPPORTED_WIRE_VERSION: "E_UNSUPPORTED_WIRE_VERSION",
344
+ E_WIRE_VERSION_MISMATCH: "E_WIRE_VERSION_MISMATCH",
301
345
  // Verification error codes
346
+ E_EAT_SIGNATURE_FAILED: "E_EAT_SIGNATURE_FAILED",
302
347
  E_INVALID_SIGNATURE: "E_INVALID_SIGNATURE",
303
348
  E_KEY_NOT_FOUND: "E_KEY_NOT_FOUND",
304
349
  E_KID_REUSE_DETECTED: "E_KID_REUSE_DETECTED",
@@ -620,6 +665,52 @@ var ERRORS = {
620
665
  next_action: "contact_issuer",
621
666
  category: "control"
622
667
  },
668
+ // Cryptography error codes
669
+ E_JWS_B64_REJECTED: {
670
+ code: "E_JWS_B64_REJECTED",
671
+ http_status: 400,
672
+ title: "JWS b64:false Rejected",
673
+ description: "JWS header contains b64:false (RFC 7797 unencoded payload); unencoded payloads are not supported",
674
+ retryable: false,
675
+ next_action: "abort",
676
+ category: "cryptography"
677
+ },
678
+ E_JWS_CRIT_REJECTED: {
679
+ code: "E_JWS_CRIT_REJECTED",
680
+ http_status: 400,
681
+ title: "JWS crit Header Rejected",
682
+ description: "JWS header contains a crit field; critical header extensions are not supported and are rejected",
683
+ retryable: false,
684
+ next_action: "abort",
685
+ category: "cryptography"
686
+ },
687
+ E_JWS_EMBEDDED_KEY: {
688
+ code: "E_JWS_EMBEDDED_KEY",
689
+ http_status: 400,
690
+ title: "JWS Embedded Key Rejected",
691
+ description: "JWS header contains an embedded key (jwk, x5c, x5u, or jku); embedded key material is rejected by the PEAC JOSE hardening rules",
692
+ retryable: false,
693
+ next_action: "abort",
694
+ category: "cryptography"
695
+ },
696
+ E_JWS_MISSING_KID: {
697
+ code: "E_JWS_MISSING_KID",
698
+ http_status: 400,
699
+ title: "JWS kid Missing or Invalid",
700
+ description: "JWS header kid field is absent, empty, or exceeds the maximum allowed length (256 characters)",
701
+ retryable: false,
702
+ next_action: "abort",
703
+ category: "cryptography"
704
+ },
705
+ E_JWS_ZIP_REJECTED: {
706
+ code: "E_JWS_ZIP_REJECTED",
707
+ http_status: 400,
708
+ title: "JWS zip Header Rejected",
709
+ description: "JWS header contains a zip compression field; payload compression is not supported",
710
+ retryable: false,
711
+ next_action: "abort",
712
+ category: "cryptography"
713
+ },
623
714
  // Dispute error codes
624
715
  E_DISPUTE_DUPLICATE: {
625
716
  code: "E_DISPUTE_DUPLICATE",
@@ -1229,6 +1320,42 @@ var ERRORS = {
1229
1320
  next_action: "retry_with_different_input",
1230
1321
  category: "validation"
1231
1322
  },
1323
+ E_EAT_INVALID_CBOR: {
1324
+ code: "E_EAT_INVALID_CBOR",
1325
+ http_status: 400,
1326
+ title: "EAT Invalid CBOR",
1327
+ description: "EAT token is not valid CBOR or the payload is not a CBOR map",
1328
+ retryable: false,
1329
+ next_action: "abort",
1330
+ category: "validation"
1331
+ },
1332
+ E_EAT_INVALID_COSE: {
1333
+ code: "E_EAT_INVALID_COSE",
1334
+ http_status: 400,
1335
+ title: "EAT Invalid COSE",
1336
+ description: "EAT token is not a valid COSE_Sign1 structure per RFC 9052 Section 4.2",
1337
+ retryable: false,
1338
+ next_action: "abort",
1339
+ category: "validation"
1340
+ },
1341
+ E_EAT_SIZE_EXCEEDED: {
1342
+ code: "E_EAT_SIZE_EXCEEDED",
1343
+ http_status: 400,
1344
+ title: "EAT Size Exceeded",
1345
+ description: "EAT token exceeds the 64 KB size limit enforced before CBOR decode",
1346
+ retryable: false,
1347
+ next_action: "abort",
1348
+ category: "validation"
1349
+ },
1350
+ E_EAT_UNSUPPORTED_ALG: {
1351
+ code: "E_EAT_UNSUPPORTED_ALG",
1352
+ http_status: 400,
1353
+ title: "EAT Unsupported Algorithm",
1354
+ description: "COSE_Sign1 uses an unsupported algorithm; only EdDSA (alg: -8) is supported",
1355
+ retryable: false,
1356
+ next_action: "abort",
1357
+ category: "validation"
1358
+ },
1232
1359
  E_EVIDENCE_NOT_JSON: {
1233
1360
  code: "E_EVIDENCE_NOT_JSON",
1234
1361
  http_status: 400,
@@ -1292,6 +1419,24 @@ var ERRORS = {
1292
1419
  next_action: "retry_with_different_input",
1293
1420
  category: "validation"
1294
1421
  },
1422
+ E_INVALID_KIND: {
1423
+ code: "E_INVALID_KIND",
1424
+ http_status: 400,
1425
+ title: "Invalid Kind",
1426
+ description: "Wire 0.2 receipt kind field is missing or not one of the accepted structural kinds (evidence, challenge)",
1427
+ retryable: false,
1428
+ next_action: "abort",
1429
+ category: "validation"
1430
+ },
1431
+ E_INVALID_PILLAR_VALUE: {
1432
+ code: "E_INVALID_PILLAR_VALUE",
1433
+ http_status: 400,
1434
+ title: "Invalid Pillar Value",
1435
+ description: "Wire 0.2 pillars array contains an unrecognized pillar value outside the closed 10-value taxonomy",
1436
+ retryable: false,
1437
+ next_action: "abort",
1438
+ category: "validation"
1439
+ },
1295
1440
  E_INVALID_RAIL: {
1296
1441
  code: "E_INVALID_RAIL",
1297
1442
  http_status: 400,
@@ -1319,6 +1464,24 @@ var ERRORS = {
1319
1464
  next_action: "retry_with_different_input",
1320
1465
  category: "validation"
1321
1466
  },
1467
+ E_INVALID_TYPE: {
1468
+ code: "E_INVALID_TYPE",
1469
+ http_status: 400,
1470
+ title: "Invalid Type",
1471
+ description: "Wire 0.2 receipt type field is missing or does not conform to the required grammar (reverse-DNS or absolute URI)",
1472
+ retryable: false,
1473
+ next_action: "abort",
1474
+ category: "validation"
1475
+ },
1476
+ E_ISS_NOT_CANONICAL: {
1477
+ code: "E_ISS_NOT_CANONICAL",
1478
+ http_status: 400,
1479
+ title: "Issuer Not Canonical",
1480
+ 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",
1481
+ retryable: false,
1482
+ next_action: "abort",
1483
+ category: "validation"
1484
+ },
1322
1485
  E_MISSING_EXP: {
1323
1486
  code: "E_MISSING_EXP",
1324
1487
  http_status: 400,
@@ -1346,6 +1509,24 @@ var ERRORS = {
1346
1509
  next_action: "retry_after_delay",
1347
1510
  category: "validation"
1348
1511
  },
1512
+ E_OCCURRED_AT_FUTURE: {
1513
+ code: "E_OCCURRED_AT_FUTURE",
1514
+ http_status: 400,
1515
+ title: "occurred_at in Future",
1516
+ 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",
1517
+ retryable: false,
1518
+ next_action: "retry_after_delay",
1519
+ category: "validation"
1520
+ },
1521
+ E_OCCURRED_AT_ON_CHALLENGE: {
1522
+ code: "E_OCCURRED_AT_ON_CHALLENGE",
1523
+ http_status: 400,
1524
+ title: "occurred_at on Challenge",
1525
+ description: "Wire 0.2 occurred_at field is present on a challenge-kind receipt; occurred_at is only permitted on evidence-kind receipts",
1526
+ retryable: false,
1527
+ next_action: "abort",
1528
+ category: "validation"
1529
+ },
1349
1530
  E_PARSE_ATTESTATION_INVALID: {
1350
1531
  code: "E_PARSE_ATTESTATION_INVALID",
1351
1532
  http_status: 400,
@@ -1373,7 +1554,52 @@ var ERRORS = {
1373
1554
  next_action: "retry_with_different_input",
1374
1555
  category: "validation"
1375
1556
  },
1557
+ E_PILLARS_NOT_SORTED: {
1558
+ code: "E_PILLARS_NOT_SORTED",
1559
+ http_status: 400,
1560
+ title: "Pillars Not Sorted",
1561
+ description: "Wire 0.2 pillars array is not in ascending lexicographic order or contains duplicates",
1562
+ retryable: false,
1563
+ next_action: "abort",
1564
+ category: "validation"
1565
+ },
1566
+ E_POLICY_BINDING_FAILED: {
1567
+ code: "E_POLICY_BINDING_FAILED",
1568
+ http_status: 400,
1569
+ title: "Policy Binding Failed",
1570
+ description: "Wire 0.2 policy.digest does not match the computed digest of the provided policy document",
1571
+ retryable: false,
1572
+ next_action: "none",
1573
+ category: "validation"
1574
+ },
1575
+ E_UNSUPPORTED_WIRE_VERSION: {
1576
+ code: "E_UNSUPPORTED_WIRE_VERSION",
1577
+ http_status: 400,
1578
+ title: "Unsupported Wire Version",
1579
+ description: "Receipt peac_version field specifies a wire version that is not supported by this implementation",
1580
+ retryable: false,
1581
+ next_action: "abort",
1582
+ category: "validation"
1583
+ },
1584
+ E_WIRE_VERSION_MISMATCH: {
1585
+ code: "E_WIRE_VERSION_MISMATCH",
1586
+ http_status: 400,
1587
+ title: "Wire Version Mismatch",
1588
+ description: "JWS header typ value and peac_version payload claim indicate different wire versions; the receipt is incoherent",
1589
+ retryable: false,
1590
+ next_action: "abort",
1591
+ category: "validation"
1592
+ },
1376
1593
  // Verification error codes
1594
+ E_EAT_SIGNATURE_FAILED: {
1595
+ code: "E_EAT_SIGNATURE_FAILED",
1596
+ http_status: 400,
1597
+ title: "EAT Signature Failed",
1598
+ description: "COSE_Sign1 Ed25519 signature verification failed over the Sig_structure",
1599
+ retryable: false,
1600
+ next_action: "retry_with_different_key",
1601
+ category: "verification"
1602
+ },
1377
1603
  E_INVALID_SIGNATURE: {
1378
1604
  code: "E_INVALID_SIGNATURE",
1379
1605
  http_status: 400,
@@ -1902,24 +2128,34 @@ exports.ERROR_CODES = ERROR_CODES;
1902
2128
  exports.HASH = HASH;
1903
2129
  exports.HEADERS = HEADERS;
1904
2130
  exports.ISSUER_CONFIG = ISSUER_CONFIG;
2131
+ exports.ISS_CANONICAL = ISS_CANONICAL;
1905
2132
  exports.JWKS = JWKS;
1906
2133
  exports.LIMITS = LIMITS;
2134
+ exports.OCCURRED_AT_TOLERANCE_SECONDS = OCCURRED_AT_TOLERANCE_SECONDS;
1907
2135
  exports.PAYMENT_RAILS = PAYMENT_RAILS;
2136
+ exports.PEAC_ALG = PEAC_ALG;
1908
2137
  exports.PEAC_RECEIPT_HEADER = PEAC_RECEIPT_HEADER;
1909
2138
  exports.PEAC_RECEIPT_URL_HEADER = PEAC_RECEIPT_URL_HEADER;
1910
2139
  exports.POLICY = POLICY;
2140
+ exports.POLICY_BLOCK = POLICY_BLOCK;
1911
2141
  exports.PRIVATE_IP_RANGES = PRIVATE_IP_RANGES;
1912
2142
  exports.RECEIPT = RECEIPT;
1913
2143
  exports.REGISTRIES = REGISTRIES;
1914
2144
  exports.TRANSPORT_METHODS = TRANSPORT_METHODS;
2145
+ exports.TYPE_GRAMMAR = TYPE_GRAMMAR;
1915
2146
  exports.VARY_HEADERS = VARY_HEADERS;
1916
2147
  exports.VERIFICATION_MODES = VERIFICATION_MODES;
1917
2148
  exports.VERIFICATION_REPORT_VERSION = VERIFICATION_REPORT_VERSION;
1918
2149
  exports.VERIFIER_LIMITS = VERIFIER_LIMITS;
1919
2150
  exports.VERIFIER_NETWORK = VERIFIER_NETWORK;
1920
2151
  exports.VERIFIER_POLICY_VERSION = VERIFIER_POLICY_VERSION;
2152
+ exports.WIRE_01_JWS_TYP = WIRE_01_JWS_TYP;
2153
+ exports.WIRE_02_JWS_TYP = WIRE_02_JWS_TYP;
2154
+ exports.WIRE_02_JWS_TYP_ACCEPT = WIRE_02_JWS_TYP_ACCEPT;
2155
+ exports.WIRE_02_VERSION = WIRE_02_VERSION;
1921
2156
  exports.WIRE_TYPE = WIRE_TYPE;
1922
2157
  exports.WIRE_VERSION = WIRE_VERSION;
2158
+ exports.WIRE_VERSIONS = WIRE_VERSIONS;
1923
2159
  exports.applyPurposeVary = applyPurposeVary;
1924
2160
  exports.findAgentProtocol = findAgentProtocol;
1925
2161
  exports.findControlEngine = findControlEngine;