@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/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",
|
|
@@ -289,15 +319,25 @@ var ERROR_CODES = {
|
|
|
289
319
|
E_INVALID_CURRENCY: "E_INVALID_CURRENCY",
|
|
290
320
|
E_INVALID_FORMAT: "E_INVALID_FORMAT",
|
|
291
321
|
E_INVALID_ISSUER: "E_INVALID_ISSUER",
|
|
322
|
+
E_INVALID_KIND: "E_INVALID_KIND",
|
|
323
|
+
E_INVALID_PILLAR_VALUE: "E_INVALID_PILLAR_VALUE",
|
|
292
324
|
E_INVALID_RAIL: "E_INVALID_RAIL",
|
|
293
325
|
E_INVALID_RECEIPT_ID: "E_INVALID_RECEIPT_ID",
|
|
294
326
|
E_INVALID_SUBJECT: "E_INVALID_SUBJECT",
|
|
327
|
+
E_INVALID_TYPE: "E_INVALID_TYPE",
|
|
328
|
+
E_ISS_NOT_CANONICAL: "E_ISS_NOT_CANONICAL",
|
|
295
329
|
E_MISSING_EXP: "E_MISSING_EXP",
|
|
296
330
|
E_MISSING_REQUIRED_CLAIM: "E_MISSING_REQUIRED_CLAIM",
|
|
297
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",
|
|
298
334
|
E_PARSE_ATTESTATION_INVALID: "E_PARSE_ATTESTATION_INVALID",
|
|
299
335
|
E_PARSE_COMMERCE_INVALID: "E_PARSE_COMMERCE_INVALID",
|
|
300
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",
|
|
301
341
|
// Verification error codes
|
|
302
342
|
E_INVALID_SIGNATURE: "E_INVALID_SIGNATURE",
|
|
303
343
|
E_KEY_NOT_FOUND: "E_KEY_NOT_FOUND",
|
|
@@ -620,6 +660,52 @@ var ERRORS = {
|
|
|
620
660
|
next_action: "contact_issuer",
|
|
621
661
|
category: "control"
|
|
622
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
|
+
},
|
|
623
709
|
// Dispute error codes
|
|
624
710
|
E_DISPUTE_DUPLICATE: {
|
|
625
711
|
code: "E_DISPUTE_DUPLICATE",
|
|
@@ -1292,6 +1378,24 @@ var ERRORS = {
|
|
|
1292
1378
|
next_action: "retry_with_different_input",
|
|
1293
1379
|
category: "validation"
|
|
1294
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
|
+
},
|
|
1295
1399
|
E_INVALID_RAIL: {
|
|
1296
1400
|
code: "E_INVALID_RAIL",
|
|
1297
1401
|
http_status: 400,
|
|
@@ -1319,6 +1423,24 @@ var ERRORS = {
|
|
|
1319
1423
|
next_action: "retry_with_different_input",
|
|
1320
1424
|
category: "validation"
|
|
1321
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
|
+
},
|
|
1322
1444
|
E_MISSING_EXP: {
|
|
1323
1445
|
code: "E_MISSING_EXP",
|
|
1324
1446
|
http_status: 400,
|
|
@@ -1346,6 +1468,24 @@ var ERRORS = {
|
|
|
1346
1468
|
next_action: "retry_after_delay",
|
|
1347
1469
|
category: "validation"
|
|
1348
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
|
+
},
|
|
1349
1489
|
E_PARSE_ATTESTATION_INVALID: {
|
|
1350
1490
|
code: "E_PARSE_ATTESTATION_INVALID",
|
|
1351
1491
|
http_status: 400,
|
|
@@ -1373,6 +1513,42 @@ var ERRORS = {
|
|
|
1373
1513
|
next_action: "retry_with_different_input",
|
|
1374
1514
|
category: "validation"
|
|
1375
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
|
+
},
|
|
1376
1552
|
// Verification error codes
|
|
1377
1553
|
E_INVALID_SIGNATURE: {
|
|
1378
1554
|
code: "E_INVALID_SIGNATURE",
|
|
@@ -1902,24 +2078,34 @@ exports.ERROR_CODES = ERROR_CODES;
|
|
|
1902
2078
|
exports.HASH = HASH;
|
|
1903
2079
|
exports.HEADERS = HEADERS;
|
|
1904
2080
|
exports.ISSUER_CONFIG = ISSUER_CONFIG;
|
|
2081
|
+
exports.ISS_CANONICAL = ISS_CANONICAL;
|
|
1905
2082
|
exports.JWKS = JWKS;
|
|
1906
2083
|
exports.LIMITS = LIMITS;
|
|
2084
|
+
exports.OCCURRED_AT_TOLERANCE_SECONDS = OCCURRED_AT_TOLERANCE_SECONDS;
|
|
1907
2085
|
exports.PAYMENT_RAILS = PAYMENT_RAILS;
|
|
2086
|
+
exports.PEAC_ALG = PEAC_ALG;
|
|
1908
2087
|
exports.PEAC_RECEIPT_HEADER = PEAC_RECEIPT_HEADER;
|
|
1909
2088
|
exports.PEAC_RECEIPT_URL_HEADER = PEAC_RECEIPT_URL_HEADER;
|
|
1910
2089
|
exports.POLICY = POLICY;
|
|
2090
|
+
exports.POLICY_BLOCK = POLICY_BLOCK;
|
|
1911
2091
|
exports.PRIVATE_IP_RANGES = PRIVATE_IP_RANGES;
|
|
1912
2092
|
exports.RECEIPT = RECEIPT;
|
|
1913
2093
|
exports.REGISTRIES = REGISTRIES;
|
|
1914
2094
|
exports.TRANSPORT_METHODS = TRANSPORT_METHODS;
|
|
2095
|
+
exports.TYPE_GRAMMAR = TYPE_GRAMMAR;
|
|
1915
2096
|
exports.VARY_HEADERS = VARY_HEADERS;
|
|
1916
2097
|
exports.VERIFICATION_MODES = VERIFICATION_MODES;
|
|
1917
2098
|
exports.VERIFICATION_REPORT_VERSION = VERIFICATION_REPORT_VERSION;
|
|
1918
2099
|
exports.VERIFIER_LIMITS = VERIFIER_LIMITS;
|
|
1919
2100
|
exports.VERIFIER_NETWORK = VERIFIER_NETWORK;
|
|
1920
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;
|
|
1921
2106
|
exports.WIRE_TYPE = WIRE_TYPE;
|
|
1922
2107
|
exports.WIRE_VERSION = WIRE_VERSION;
|
|
2108
|
+
exports.WIRE_VERSIONS = WIRE_VERSIONS;
|
|
1923
2109
|
exports.applyPurposeVary = applyPurposeVary;
|
|
1924
2110
|
exports.findAgentProtocol = findAgentProtocol;
|
|
1925
2111
|
exports.findControlEngine = findControlEngine;
|