@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/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",
@@ -57,7 +58,8 @@ var DISCOVERY = {
57
58
  };
58
59
  var JWKS = {
59
60
  rotationDays: 90,
60
- overlapDays: 7,
61
+ /** Normative minimum overlap period (DD-148, v0.11.3+) */
62
+ overlapDays: 30,
61
63
  emergencyRevocationHours: 24
62
64
  };
63
65
  var RECEIPT = {
@@ -154,6 +156,29 @@ var VERIFICATION_MODES = {
154
156
  /** Allow network fetches for key discovery */
155
157
  networkAllowed: "network_allowed"
156
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;
157
182
  var CONSTANTS = {
158
183
  WIRE_TYPE,
159
184
  WIRE_VERSION,
@@ -208,6 +233,12 @@ var ERROR_CODES = {
208
233
  // Control error codes
209
234
  E_CONTROL_DENIED: "E_CONTROL_DENIED",
210
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",
211
242
  // Dispute error codes
212
243
  E_DISPUTE_DUPLICATE: "E_DISPUTE_DUPLICATE",
213
244
  E_DISPUTE_EXPIRED: "E_DISPUTE_EXPIRED",
@@ -237,6 +268,7 @@ var ERROR_CODES = {
237
268
  E_IDENTITY_NOT_YET_VALID: "E_IDENTITY_NOT_YET_VALID",
238
269
  E_IDENTITY_PROOF_UNSUPPORTED: "E_IDENTITY_PROOF_UNSUPPORTED",
239
270
  E_IDENTITY_SIG_INVALID: "E_IDENTITY_SIG_INVALID",
271
+ E_MVIS_INCOMPLETE: "E_MVIS_INCOMPLETE",
240
272
  // Infrastructure error codes
241
273
  E_CIRCUIT_BREAKER_OPEN: "E_CIRCUIT_BREAKER_OPEN",
242
274
  E_INTERNAL: "E_INTERNAL",
@@ -287,18 +319,30 @@ var ERROR_CODES = {
287
319
  E_INVALID_CURRENCY: "E_INVALID_CURRENCY",
288
320
  E_INVALID_FORMAT: "E_INVALID_FORMAT",
289
321
  E_INVALID_ISSUER: "E_INVALID_ISSUER",
322
+ E_INVALID_KIND: "E_INVALID_KIND",
323
+ E_INVALID_PILLAR_VALUE: "E_INVALID_PILLAR_VALUE",
290
324
  E_INVALID_RAIL: "E_INVALID_RAIL",
291
325
  E_INVALID_RECEIPT_ID: "E_INVALID_RECEIPT_ID",
292
326
  E_INVALID_SUBJECT: "E_INVALID_SUBJECT",
327
+ E_INVALID_TYPE: "E_INVALID_TYPE",
328
+ E_ISS_NOT_CANONICAL: "E_ISS_NOT_CANONICAL",
293
329
  E_MISSING_EXP: "E_MISSING_EXP",
294
330
  E_MISSING_REQUIRED_CLAIM: "E_MISSING_REQUIRED_CLAIM",
295
331
  E_NOT_YET_VALID: "E_NOT_YET_VALID",
332
+ E_OCCURRED_AT_FUTURE: "E_OCCURRED_AT_FUTURE",
333
+ E_OCCURRED_AT_ON_CHALLENGE: "E_OCCURRED_AT_ON_CHALLENGE",
296
334
  E_PARSE_ATTESTATION_INVALID: "E_PARSE_ATTESTATION_INVALID",
297
335
  E_PARSE_COMMERCE_INVALID: "E_PARSE_COMMERCE_INVALID",
298
336
  E_PARSE_INVALID_INPUT: "E_PARSE_INVALID_INPUT",
337
+ E_PILLARS_NOT_SORTED: "E_PILLARS_NOT_SORTED",
338
+ E_POLICY_BINDING_FAILED: "E_POLICY_BINDING_FAILED",
339
+ E_UNSUPPORTED_WIRE_VERSION: "E_UNSUPPORTED_WIRE_VERSION",
340
+ E_WIRE_VERSION_MISMATCH: "E_WIRE_VERSION_MISMATCH",
299
341
  // Verification error codes
300
342
  E_INVALID_SIGNATURE: "E_INVALID_SIGNATURE",
301
343
  E_KEY_NOT_FOUND: "E_KEY_NOT_FOUND",
344
+ E_KID_REUSE_DETECTED: "E_KID_REUSE_DETECTED",
345
+ E_REVOKED_KEY_USED: "E_REVOKED_KEY_USED",
302
346
  // Verifier error codes
303
347
  E_VERIFY_EXTENSION_TOO_LARGE: "E_VERIFY_EXTENSION_TOO_LARGE",
304
348
  E_VERIFY_INSECURE_SCHEME_BLOCKED: "E_VERIFY_INSECURE_SCHEME_BLOCKED",
@@ -616,6 +660,52 @@ var ERRORS = {
616
660
  next_action: "contact_issuer",
617
661
  category: "control"
618
662
  },
663
+ // Cryptography error codes
664
+ E_JWS_B64_REJECTED: {
665
+ code: "E_JWS_B64_REJECTED",
666
+ http_status: 400,
667
+ title: "JWS b64:false Rejected",
668
+ description: "JWS header contains b64:false (RFC 7797 unencoded payload); unencoded payloads are not supported",
669
+ retryable: false,
670
+ next_action: "abort",
671
+ category: "cryptography"
672
+ },
673
+ E_JWS_CRIT_REJECTED: {
674
+ code: "E_JWS_CRIT_REJECTED",
675
+ http_status: 400,
676
+ title: "JWS crit Header Rejected",
677
+ description: "JWS header contains a crit field; critical header extensions are not supported and are rejected",
678
+ retryable: false,
679
+ next_action: "abort",
680
+ category: "cryptography"
681
+ },
682
+ E_JWS_EMBEDDED_KEY: {
683
+ code: "E_JWS_EMBEDDED_KEY",
684
+ http_status: 400,
685
+ title: "JWS Embedded Key Rejected",
686
+ description: "JWS header contains an embedded key (jwk, x5c, x5u, or jku); embedded key material is rejected by the PEAC JOSE hardening rules",
687
+ retryable: false,
688
+ next_action: "abort",
689
+ category: "cryptography"
690
+ },
691
+ E_JWS_MISSING_KID: {
692
+ code: "E_JWS_MISSING_KID",
693
+ http_status: 400,
694
+ title: "JWS kid Missing or Invalid",
695
+ description: "JWS header kid field is absent, empty, or exceeds the maximum allowed length (256 characters)",
696
+ retryable: false,
697
+ next_action: "abort",
698
+ category: "cryptography"
699
+ },
700
+ E_JWS_ZIP_REJECTED: {
701
+ code: "E_JWS_ZIP_REJECTED",
702
+ http_status: 400,
703
+ title: "JWS zip Header Rejected",
704
+ description: "JWS header contains a zip compression field; payload compression is not supported",
705
+ retryable: false,
706
+ next_action: "abort",
707
+ category: "cryptography"
708
+ },
619
709
  // Dispute error codes
620
710
  E_DISPUTE_DUPLICATE: {
621
711
  code: "E_DISPUTE_DUPLICATE",
@@ -861,6 +951,15 @@ var ERRORS = {
861
951
  next_action: "retry_with_different_input",
862
952
  category: "identity"
863
953
  },
954
+ E_MVIS_INCOMPLETE: {
955
+ code: "E_MVIS_INCOMPLETE",
956
+ http_status: 400,
957
+ title: "MVIS Incomplete",
958
+ description: "Identity receipt missing one or more Minimum Viable Identity Set required fields (issuer, subject, key_binding, time_bounds, replay_protection)",
959
+ retryable: false,
960
+ next_action: "retry_with_different_input",
961
+ category: "identity"
962
+ },
864
963
  // Infrastructure error codes
865
964
  E_CIRCUIT_BREAKER_OPEN: {
866
965
  code: "E_CIRCUIT_BREAKER_OPEN",
@@ -1279,6 +1378,24 @@ var ERRORS = {
1279
1378
  next_action: "retry_with_different_input",
1280
1379
  category: "validation"
1281
1380
  },
1381
+ E_INVALID_KIND: {
1382
+ code: "E_INVALID_KIND",
1383
+ http_status: 400,
1384
+ title: "Invalid Kind",
1385
+ description: "Wire 0.2 receipt kind field is missing or not one of the accepted structural kinds (evidence, challenge)",
1386
+ retryable: false,
1387
+ next_action: "abort",
1388
+ category: "validation"
1389
+ },
1390
+ E_INVALID_PILLAR_VALUE: {
1391
+ code: "E_INVALID_PILLAR_VALUE",
1392
+ http_status: 400,
1393
+ title: "Invalid Pillar Value",
1394
+ description: "Wire 0.2 pillars array contains an unrecognized pillar value outside the closed 10-value taxonomy",
1395
+ retryable: false,
1396
+ next_action: "abort",
1397
+ category: "validation"
1398
+ },
1282
1399
  E_INVALID_RAIL: {
1283
1400
  code: "E_INVALID_RAIL",
1284
1401
  http_status: 400,
@@ -1306,6 +1423,24 @@ var ERRORS = {
1306
1423
  next_action: "retry_with_different_input",
1307
1424
  category: "validation"
1308
1425
  },
1426
+ E_INVALID_TYPE: {
1427
+ code: "E_INVALID_TYPE",
1428
+ http_status: 400,
1429
+ title: "Invalid Type",
1430
+ description: "Wire 0.2 receipt type field is missing or does not conform to the required grammar (reverse-DNS or absolute URI)",
1431
+ retryable: false,
1432
+ next_action: "abort",
1433
+ category: "validation"
1434
+ },
1435
+ E_ISS_NOT_CANONICAL: {
1436
+ code: "E_ISS_NOT_CANONICAL",
1437
+ http_status: 400,
1438
+ title: "Issuer Not Canonical",
1439
+ 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",
1440
+ retryable: false,
1441
+ next_action: "abort",
1442
+ category: "validation"
1443
+ },
1309
1444
  E_MISSING_EXP: {
1310
1445
  code: "E_MISSING_EXP",
1311
1446
  http_status: 400,
@@ -1333,6 +1468,24 @@ var ERRORS = {
1333
1468
  next_action: "retry_after_delay",
1334
1469
  category: "validation"
1335
1470
  },
1471
+ E_OCCURRED_AT_FUTURE: {
1472
+ code: "E_OCCURRED_AT_FUTURE",
1473
+ http_status: 400,
1474
+ title: "occurred_at in Future",
1475
+ 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",
1476
+ retryable: false,
1477
+ next_action: "retry_after_delay",
1478
+ category: "validation"
1479
+ },
1480
+ E_OCCURRED_AT_ON_CHALLENGE: {
1481
+ code: "E_OCCURRED_AT_ON_CHALLENGE",
1482
+ http_status: 400,
1483
+ title: "occurred_at on Challenge",
1484
+ description: "Wire 0.2 occurred_at field is present on a challenge-kind receipt; occurred_at is only permitted on evidence-kind receipts",
1485
+ retryable: false,
1486
+ next_action: "abort",
1487
+ category: "validation"
1488
+ },
1336
1489
  E_PARSE_ATTESTATION_INVALID: {
1337
1490
  code: "E_PARSE_ATTESTATION_INVALID",
1338
1491
  http_status: 400,
@@ -1360,6 +1513,42 @@ var ERRORS = {
1360
1513
  next_action: "retry_with_different_input",
1361
1514
  category: "validation"
1362
1515
  },
1516
+ E_PILLARS_NOT_SORTED: {
1517
+ code: "E_PILLARS_NOT_SORTED",
1518
+ http_status: 400,
1519
+ title: "Pillars Not Sorted",
1520
+ description: "Wire 0.2 pillars array is not in ascending lexicographic order or contains duplicates",
1521
+ retryable: false,
1522
+ next_action: "abort",
1523
+ category: "validation"
1524
+ },
1525
+ E_POLICY_BINDING_FAILED: {
1526
+ code: "E_POLICY_BINDING_FAILED",
1527
+ http_status: 400,
1528
+ title: "Policy Binding Failed",
1529
+ description: "Wire 0.2 policy.digest does not match the computed digest of the provided policy document",
1530
+ retryable: false,
1531
+ next_action: "none",
1532
+ category: "validation"
1533
+ },
1534
+ E_UNSUPPORTED_WIRE_VERSION: {
1535
+ code: "E_UNSUPPORTED_WIRE_VERSION",
1536
+ http_status: 400,
1537
+ title: "Unsupported Wire Version",
1538
+ description: "Receipt peac_version field specifies a wire version that is not supported by this implementation",
1539
+ retryable: false,
1540
+ next_action: "abort",
1541
+ category: "validation"
1542
+ },
1543
+ E_WIRE_VERSION_MISMATCH: {
1544
+ code: "E_WIRE_VERSION_MISMATCH",
1545
+ http_status: 400,
1546
+ title: "Wire Version Mismatch",
1547
+ description: "JWS header typ value and peac_version payload claim indicate different wire versions; the receipt is incoherent",
1548
+ retryable: false,
1549
+ next_action: "abort",
1550
+ category: "validation"
1551
+ },
1363
1552
  // Verification error codes
1364
1553
  E_INVALID_SIGNATURE: {
1365
1554
  code: "E_INVALID_SIGNATURE",
@@ -1379,6 +1568,24 @@ var ERRORS = {
1379
1568
  next_action: "retry_with_different_key",
1380
1569
  category: "verification"
1381
1570
  },
1571
+ E_KID_REUSE_DETECTED: {
1572
+ code: "E_KID_REUSE_DETECTED",
1573
+ http_status: 400,
1574
+ title: "Kid Reuse Detected",
1575
+ description: "Same kid value used with different key material within the retention window",
1576
+ retryable: false,
1577
+ next_action: "abort",
1578
+ category: "verification"
1579
+ },
1580
+ E_REVOKED_KEY_USED: {
1581
+ code: "E_REVOKED_KEY_USED",
1582
+ http_status: 400,
1583
+ title: "Revoked Key Used",
1584
+ description: "Receipt signed with a key listed in the issuer revoked_keys set",
1585
+ retryable: false,
1586
+ next_action: "retry_with_different_key",
1587
+ category: "verification"
1588
+ },
1382
1589
  // Verifier error codes
1383
1590
  E_VERIFY_EXTENSION_TOO_LARGE: {
1384
1591
  code: "E_VERIFY_EXTENSION_TOO_LARGE",
@@ -1871,24 +2078,34 @@ exports.ERROR_CODES = ERROR_CODES;
1871
2078
  exports.HASH = HASH;
1872
2079
  exports.HEADERS = HEADERS;
1873
2080
  exports.ISSUER_CONFIG = ISSUER_CONFIG;
2081
+ exports.ISS_CANONICAL = ISS_CANONICAL;
1874
2082
  exports.JWKS = JWKS;
1875
2083
  exports.LIMITS = LIMITS;
2084
+ exports.OCCURRED_AT_TOLERANCE_SECONDS = OCCURRED_AT_TOLERANCE_SECONDS;
1876
2085
  exports.PAYMENT_RAILS = PAYMENT_RAILS;
2086
+ exports.PEAC_ALG = PEAC_ALG;
1877
2087
  exports.PEAC_RECEIPT_HEADER = PEAC_RECEIPT_HEADER;
1878
2088
  exports.PEAC_RECEIPT_URL_HEADER = PEAC_RECEIPT_URL_HEADER;
1879
2089
  exports.POLICY = POLICY;
2090
+ exports.POLICY_BLOCK = POLICY_BLOCK;
1880
2091
  exports.PRIVATE_IP_RANGES = PRIVATE_IP_RANGES;
1881
2092
  exports.RECEIPT = RECEIPT;
1882
2093
  exports.REGISTRIES = REGISTRIES;
1883
2094
  exports.TRANSPORT_METHODS = TRANSPORT_METHODS;
2095
+ exports.TYPE_GRAMMAR = TYPE_GRAMMAR;
1884
2096
  exports.VARY_HEADERS = VARY_HEADERS;
1885
2097
  exports.VERIFICATION_MODES = VERIFICATION_MODES;
1886
2098
  exports.VERIFICATION_REPORT_VERSION = VERIFICATION_REPORT_VERSION;
1887
2099
  exports.VERIFIER_LIMITS = VERIFIER_LIMITS;
1888
2100
  exports.VERIFIER_NETWORK = VERIFIER_NETWORK;
1889
2101
  exports.VERIFIER_POLICY_VERSION = VERIFIER_POLICY_VERSION;
2102
+ exports.WIRE_01_JWS_TYP = WIRE_01_JWS_TYP;
2103
+ exports.WIRE_02_JWS_TYP = WIRE_02_JWS_TYP;
2104
+ exports.WIRE_02_JWS_TYP_ACCEPT = WIRE_02_JWS_TYP_ACCEPT;
2105
+ exports.WIRE_02_VERSION = WIRE_02_VERSION;
1890
2106
  exports.WIRE_TYPE = WIRE_TYPE;
1891
2107
  exports.WIRE_VERSION = WIRE_VERSION;
2108
+ exports.WIRE_VERSIONS = WIRE_VERSIONS;
1892
2109
  exports.applyPurposeVary = applyPurposeVary;
1893
2110
  exports.findAgentProtocol = findAgentProtocol;
1894
2111
  exports.findControlEngine = findControlEngine;