@blamejs/pki 0.6.39 → 0.6.41
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/CHANGELOG.md +25 -0
- package/lib/acme.js +24 -13
- package/lib/asn1-der.js +5 -5
- package/lib/attrcert-sign.js +16 -16
- package/lib/cbor-det.js +2 -2
- package/lib/cmc-build.js +16 -16
- package/lib/cmc-verify.js +5 -5
- package/lib/cmp-build.js +29 -19
- package/lib/cmp-session.js +25 -20
- package/lib/cmp-verify.js +8 -12
- package/lib/cms-decrypt.js +8 -8
- package/lib/cms-encrypt.js +22 -22
- package/lib/cms-sign.js +17 -17
- package/lib/cms-verify.js +13 -13
- package/lib/composite-kem.js +1 -1
- package/lib/composite-sig.js +4 -4
- package/lib/constants.js +13 -9
- package/lib/crl-sign.js +25 -25
- package/lib/crmf-sign.js +11 -11
- package/lib/csr-sign.js +4 -4
- package/lib/ct.js +33 -25
- package/lib/edwards-point.js +2 -2
- package/lib/est.js +74 -43
- package/lib/guard-async.js +17 -1
- package/lib/guard-bytes.js +3 -3
- package/lib/guard-compress.js +5 -5
- package/lib/guard-identifier.js +46 -2
- package/lib/guard-json.js +1 -1
- package/lib/guard-list.js +16 -0
- package/lib/guard-name.js +1 -1
- package/lib/guard-parsed.js +1 -1
- package/lib/guard-time.js +3 -1
- package/lib/guard-verdict.js +7 -1
- package/lib/hpke.js +10 -10
- package/lib/http-digest.js +2 -2
- package/lib/http-transport.js +3 -3
- package/lib/inspect.js +9 -9
- package/lib/ip-utils.js +1 -1
- package/lib/jose.js +14 -14
- package/lib/key.js +7 -7
- package/lib/lint.js +6 -4
- package/lib/merkle.js +2 -2
- package/lib/mime.js +2 -2
- package/lib/ocsp-verify.js +1 -1
- package/lib/ocsp.js +5 -5
- package/lib/oid.js +3 -3
- package/lib/path-validate.js +127 -117
- package/lib/pbes2.js +2 -2
- package/lib/pkcs12-build.js +26 -24
- package/lib/pki-build.js +2 -2
- package/lib/scep.js +47 -16
- package/lib/schema-all.js +1 -1
- package/lib/schema-attrcert.js +4 -3
- package/lib/schema-c509.js +23 -23
- package/lib/schema-cmc.js +6 -6
- package/lib/schema-cmp.js +3 -3
- package/lib/schema-cms.js +15 -8
- package/lib/schema-crmf.js +1 -1
- package/lib/schema-csr.js +1 -1
- package/lib/schema-engine.js +2 -1
- package/lib/schema-pkcs12.js +1 -1
- package/lib/schema-pkix.js +3 -0
- package/lib/schema-tsp.js +2 -2
- package/lib/shbs.js +2 -2
- package/lib/sign-scheme.js +9 -9
- package/lib/sigstore.js +24 -14
- package/lib/smime.js +16 -16
- package/lib/tls-cert-compress.js +6 -6
- package/lib/trust.js +9 -9
- package/lib/tsp-sign.js +30 -30
- package/lib/validator-attcert.js +2 -2
- package/lib/validator-cose.js +5 -5
- package/lib/validator-sig.js +3 -3
- package/lib/validator-tpm.js +5 -4
- package/lib/webauthn.js +58 -54
- package/lib/webcrypto.js +22 -14
- package/lib/x509-sign.js +8 -8
- package/package.json +1 -1
- package/sbom.cdx.json +6 -6
package/lib/est.js
CHANGED
|
@@ -98,12 +98,12 @@ var OID_TEMPLATE = oid.byName("certificationRequestInfoTemplate");
|
|
|
98
98
|
|
|
99
99
|
var OPERATIONS = ["cacerts", "simpleenroll", "simplereenroll", "fullcmc", "serverkeygen", "csrattrs"];
|
|
100
100
|
|
|
101
|
-
var CLIENT_OPTS = {
|
|
101
|
+
var CLIENT_OPTS = intrinsic.assign(intrinsic.create(null), {
|
|
102
102
|
transport: 1, tls: 1, label: 1, timeout: 1, maxResponseBytes: 1, maxRedirects: 1, now: 1,
|
|
103
103
|
auth: 1, username: 1, password: 1, allowCrossOriginRedirect: 1, proxy: 1,
|
|
104
|
-
};
|
|
104
|
+
});
|
|
105
105
|
function _withClient(extra) {
|
|
106
|
-
var out =
|
|
106
|
+
var out = intrinsic.create(null);
|
|
107
107
|
Object.keys(CLIENT_OPTS).forEach(function (k) { out[k] = 1; });
|
|
108
108
|
Object.keys(extra || {}).forEach(function (k) { out[k] = 1; });
|
|
109
109
|
return out;
|
|
@@ -119,18 +119,34 @@ var FULLCMC_OPTS = _withClient({
|
|
|
119
119
|
transactionId: 1, senderNonce: 1, dataReturn: 1,
|
|
120
120
|
responderCerts: 1, responseRecipient: 1, allowUnverifiedResponse: 1, allowUnboundResponse: 1,
|
|
121
121
|
});
|
|
122
|
-
var CLASSIFY_OPTS = { op: 1, now: 1 };
|
|
123
|
-
var PATHS_OPTS = { label: 1 };
|
|
124
|
-
var PARSE_SERVERKEYGEN_OPTS = {
|
|
122
|
+
var CLASSIFY_OPTS = intrinsic.assign(intrinsic.create(null), { op: 1, now: 1 });
|
|
123
|
+
var PATHS_OPTS = intrinsic.assign(intrinsic.create(null), { label: 1 });
|
|
124
|
+
var PARSE_SERVERKEYGEN_OPTS = intrinsic.assign(intrinsic.create(null), {
|
|
125
125
|
requestedEncryption: 1, expectedRecipientKeyId: 1, expectedRecipientKind: 1,
|
|
126
126
|
expectedRecipientIssuerSerial: 1,
|
|
127
|
-
};
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
var TRANSPORT_SHAPE = "(request) => Promise<{ status, headers, body }>";
|
|
128
130
|
|
|
131
|
+
/** @internal Refused at the door, before any payload work, and again where the value is used. The
|
|
132
|
+
* checked value is RETURNED and it is that one the caller uses: reading the option again would ask
|
|
133
|
+
* a second time, and an accessor can answer differently on each read, so a value that passed here
|
|
134
|
+
* need not be the value that gets called. */
|
|
135
|
+
function _assertTransport(opts) {
|
|
136
|
+
return guard.identifier.assertCallableOption(opts, "transport", E, "est/bad-input", "opts.transport", TRANSPORT_SHAPE);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** @internal Settled first, as the sibling clients do: an options object whose reads change what it
|
|
140
|
+
* carries is refused here rather than answering one way to the check and another to the use, which
|
|
141
|
+
* is how a transport that passed could be replaced before it is called. */
|
|
129
142
|
function _knownOpts(opts, known, verb) {
|
|
130
|
-
guard.identifier.
|
|
143
|
+
var settled = guard.identifier.optionsObject(opts, E, "est/bad-input", "pki.est." + verb + " options");
|
|
144
|
+
guard.identifier.assertKnownKeys(settled, known, E, "est/bad-input", function (k) {
|
|
131
145
|
return "unknown option " + JSON.stringify(k) + " for pki.est." + verb + " -- accepted: " +
|
|
132
146
|
Object.keys(known).sort().join(", ");
|
|
133
147
|
});
|
|
148
|
+
_assertTransport(settled);
|
|
149
|
+
return settled;
|
|
134
150
|
}
|
|
135
151
|
|
|
136
152
|
function _snapProxy(opts) { return httpTransport.snapshotProxy(opts.proxy); }
|
|
@@ -315,7 +331,7 @@ function splitMultipartMixed(body, contentType) {
|
|
|
315
331
|
if (sep === -1) throw E("est/bad-multipart", "a multipart part is missing its header/body separator");
|
|
316
332
|
var rawHeaders = _strSlice(seg, 0, sep);
|
|
317
333
|
var partBody = _strSlice(seg, _stripTwoLeadingEol(seg, sep), _stripOneTrailingEol(seg, seg.length));
|
|
318
|
-
var headers =
|
|
334
|
+
var headers = intrinsic.create(null);
|
|
319
335
|
var lines = _splitCrlf(_unfoldHeaders(rawHeaders));
|
|
320
336
|
for (var li = 0; li < lines.length; li++) {
|
|
321
337
|
var line = lines[li];
|
|
@@ -476,7 +492,7 @@ function _partMediaType(contentType) {
|
|
|
476
492
|
|
|
477
493
|
function parseServerKeygenResponse(body, contentType, opts) {
|
|
478
494
|
opts = opts || {};
|
|
479
|
-
_knownOpts(opts, PARSE_SERVERKEYGEN_OPTS, "parseServerKeygenResponse");
|
|
495
|
+
opts = _knownOpts(opts, PARSE_SERVERKEYGEN_OPTS, "parseServerKeygenResponse");
|
|
480
496
|
var parts = splitMultipartMixed(body, contentType);
|
|
481
497
|
if (parts.length !== 2) throw E("est/bad-multipart", "a serverkeygen response must have exactly two parts (RFC 7030 sec. 4.4.2)");
|
|
482
498
|
var keyPart = null, certPart = null, encrypted = false;
|
|
@@ -513,18 +529,18 @@ function parseServerKeygenResponse(body, contentType, opts) {
|
|
|
513
529
|
}
|
|
514
530
|
|
|
515
531
|
|
|
516
|
-
var CONTENT_TYPE_BY_OP = {
|
|
532
|
+
var CONTENT_TYPE_BY_OP = intrinsic.assign(intrinsic.create(null), {
|
|
517
533
|
cacerts: { media: "application/pkcs7-mime" },
|
|
518
534
|
simpleenroll: { media: "application/pkcs7-mime", smimeTypes: ["certs-only"] },
|
|
519
535
|
simplereenroll: { media: "application/pkcs7-mime", smimeTypes: ["certs-only"] },
|
|
520
536
|
fullcmc: { media: "application/pkcs7-mime", smimeTypes: ["certs-only", "cmc-response"] },
|
|
521
537
|
serverkeygen: { media: "multipart/mixed" },
|
|
522
538
|
csrattrs: { media: "application/csrattrs" },
|
|
523
|
-
};
|
|
539
|
+
});
|
|
524
540
|
|
|
525
541
|
var CLASSIFIABLE_OPS = ["cacerts", "simpleenroll", "simplereenroll", "fullcmc", "serverkeygen", "csrattrs"];
|
|
526
542
|
|
|
527
|
-
var NOT_IMPLEMENTED_OPS = { fullcmc: 1 };
|
|
543
|
+
var NOT_IMPLEMENTED_OPS = intrinsic.assign(intrinsic.create(null), { fullcmc: 1 });
|
|
528
544
|
|
|
529
545
|
/**
|
|
530
546
|
* @primitive pki.est.classifyResponse
|
|
@@ -553,15 +569,15 @@ var NOT_IMPLEMENTED_OPS = { fullcmc: 1 };
|
|
|
553
569
|
*/
|
|
554
570
|
function classifyResponse(status, headers, body, opts) {
|
|
555
571
|
opts = opts || {};
|
|
556
|
-
_knownOpts(opts, CLASSIFY_OPTS, "classifyResponse");
|
|
572
|
+
opts = _knownOpts(opts, CLASSIFY_OPTS, "classifyResponse");
|
|
557
573
|
var op = opts.op;
|
|
558
574
|
if (op !== undefined && op !== null && CLASSIFIABLE_OPS.indexOf(op) === -1) throw E("est/unsupported-operation", "unrecognized EST operation " + guard.text.showValue(op));
|
|
559
|
-
var h = {
|
|
575
|
+
var h = intrinsic.assign(intrinsic.create(null), {
|
|
560
576
|
"content-type": _ciHeader(headers, "content-type"),
|
|
561
577
|
"retry-after": _ciHeader(headers, "retry-after"),
|
|
562
578
|
"location": _ciHeader(headers, "location"),
|
|
563
579
|
"www-authenticate": _ciHeaderList(headers, "www-authenticate"),
|
|
564
|
-
};
|
|
580
|
+
});
|
|
565
581
|
if (status === 200) {
|
|
566
582
|
var spec = CONTENT_TYPE_BY_OP[op];
|
|
567
583
|
var ct = h["content-type"] || "";
|
|
@@ -625,7 +641,7 @@ function classifyResponse(status, headers, body, opts) {
|
|
|
625
641
|
*/
|
|
626
642
|
function paths(baseUrl, opts) {
|
|
627
643
|
opts = opts || {};
|
|
628
|
-
_knownOpts(opts, PATHS_OPTS, "paths");
|
|
644
|
+
opts = _knownOpts(opts, PATHS_OPTS, "paths");
|
|
629
645
|
var base = String(baseUrl);
|
|
630
646
|
var prefix = base.slice(0, _stripTrailingSlashEnd(base)) + "/.well-known/est";
|
|
631
647
|
if (opts.label != null) {
|
|
@@ -635,7 +651,7 @@ function paths(baseUrl, opts) {
|
|
|
635
651
|
}
|
|
636
652
|
prefix += "/" + label;
|
|
637
653
|
}
|
|
638
|
-
var out =
|
|
654
|
+
var out = intrinsic.create(null);
|
|
639
655
|
OPERATIONS.forEach(function (op) { out[op] = prefix + "/" + op; });
|
|
640
656
|
return out;
|
|
641
657
|
}
|
|
@@ -845,7 +861,7 @@ function _authScheme(opts) {
|
|
|
845
861
|
function _authUser(opts) { return opts.auth && opts.auth.username !== undefined ? opts.auth.username : opts.username; }
|
|
846
862
|
function _authPass(opts) { return opts.auth && opts.auth.password !== undefined ? opts.auth.password : opts.password; }
|
|
847
863
|
function _hasCreds(opts) { return _authUser(opts) !== undefined || _authPass(opts) !== undefined; }
|
|
848
|
-
var DIGEST_CODES = { unsupportedAlgorithm: "est/digest-unsupported-algorithm", weakAlgorithm: "est/digest-weak-algorithm", noQop: "est/digest-no-qop", badChallenge: "est/digest-bad-challenge" };
|
|
864
|
+
var DIGEST_CODES = intrinsic.assign(intrinsic.create(null), { unsupportedAlgorithm: "est/digest-unsupported-algorithm", weakAlgorithm: "est/digest-weak-algorithm", noQop: "est/digest-no-qop", badChallenge: "est/digest-bad-challenge" });
|
|
849
865
|
function _digestPolicy(opts) { return { allowMD5: !!(opts.auth && opts.auth.allowMD5), allowLegacyQop: !!(opts.auth && opts.auth.allowLegacyQop), codes: DIGEST_CODES }; }
|
|
850
866
|
|
|
851
867
|
function _drive(method, url, body, headers, opts, transport, budgets) {
|
|
@@ -882,14 +898,14 @@ function _drive(method, url, body, headers, opts, transport, budgets) {
|
|
|
882
898
|
}
|
|
883
899
|
function step() {
|
|
884
900
|
var hopBody = (typeof body === "function" && budgets.onAttempt) ? budgets.onAttempt() : body;
|
|
885
|
-
return guard.async.
|
|
901
|
+
return guard.async.invoked(transport, [{ method: method, url: url.href, headers: _headersFor(url), body: hopBody, tls: _tlsFor(url), proxy: budgets.proxy, timeout: budgets.timeout, maxResponseBytes: budgets.maxResponseBytes }], E, "est/bad-input", "opts.transport").then(function (res) {
|
|
886
902
|
res = res || {};
|
|
887
903
|
var blen = _bodyLen(res);
|
|
888
904
|
if (blen > budgets.maxResponseBytes) throw E("est/response-too-large", "the response body (" + blen + " bytes) exceeds the " + budgets.maxResponseBytes + "-byte cap (RFC 7030 sec. 6)");
|
|
889
|
-
var h = {
|
|
905
|
+
var h = intrinsic.assign(intrinsic.create(null), {
|
|
890
906
|
location: _ciHeader(res.headers, "location"),
|
|
891
907
|
"www-authenticate": _ciHeaderList(res.headers, "www-authenticate"),
|
|
892
|
-
};
|
|
908
|
+
});
|
|
893
909
|
var status = res.status;
|
|
894
910
|
if (status >= 300 && status < 400) {
|
|
895
911
|
if (redirects >= budgets.maxRedirects) throw E("est/too-many-redirects", "the redirect chain exceeded maxRedirects=" + budgets.maxRedirects + " (RFC 7030 sec. 3.2.1)");
|
|
@@ -945,13 +961,16 @@ function _drive(method, url, body, headers, opts, transport, budgets) {
|
|
|
945
961
|
return step();
|
|
946
962
|
}
|
|
947
963
|
|
|
948
|
-
|
|
964
|
+
/** @internal `checked` is the transport the verb already took at its door. Taking it again here
|
|
965
|
+
* would ask the caller's options a second time, and anything read in between could change the
|
|
966
|
+
* answer, so a verb that holds one passes it and this reads the option only when none was held. */
|
|
967
|
+
function _client(op, method, baseUrl, body, headers, opts, proxySnap, onAttempt, checked) {
|
|
949
968
|
var base;
|
|
950
969
|
try { base = new URL(String(baseUrl)); }
|
|
951
970
|
catch (e) { throw E("est/bad-url", "the EST base URL did not parse: " + guard.text.showValue(baseUrl), e); }
|
|
952
971
|
if (base.search || base.hash) throw E("est/bad-url", "the EST base URL must not carry a query or fragment component (RFC 7030 sec. 3.2.2)");
|
|
953
972
|
var url = _parseUrl(paths(baseUrl, { label: opts.label })[op]);
|
|
954
|
-
var transport = opts
|
|
973
|
+
var transport = checked !== undefined ? checked : _assertTransport(opts);
|
|
955
974
|
if (!transport) {
|
|
956
975
|
var t = opts.tls || {};
|
|
957
976
|
var hasAnchors = t.anchors !== undefined && t.anchors !== null && !(Array.isArray(t.anchors) && t.anchors.length === 0);
|
|
@@ -1086,16 +1105,23 @@ function fullcmc(baseUrl, request, opts) {
|
|
|
1086
1105
|
var der, wanted, sent;
|
|
1087
1106
|
try {
|
|
1088
1107
|
if (typeof opts !== "object" || Buffer.isBuffer(opts)) throw E("est/bad-input", "pki.est.fullcmc options must be an object");
|
|
1089
|
-
_knownOpts(opts, FULLCMC_OPTS, "fullcmc");
|
|
1108
|
+
opts = _knownOpts(opts, FULLCMC_OPTS, "fullcmc");
|
|
1109
|
+
/** @internal Held from the door, before the request is read. What follows traverses the
|
|
1110
|
+
* caller's nested objects, and one of those reads must not be able to change which transport
|
|
1111
|
+
* the request goes out on, so the value that was checked is the value carried below. */
|
|
1112
|
+
var carriedTransport = opts.transport;
|
|
1090
1113
|
var proxySnap;
|
|
1091
1114
|
try { proxySnap = _snapProxy(opts); } catch (_pe) { throw E("est/bad-input", "the options object could not be read", _pe); }
|
|
1092
1115
|
der = _cmcRequestDer(request);
|
|
1093
1116
|
wanted = _requestedPublicKeys(der);
|
|
1094
1117
|
sent = _cmcSent(opts, der);
|
|
1118
|
+
/** @internal The copy below keeps own properties only, and a defaults bag holds its options on
|
|
1119
|
+
* a prototype, so the transport is put back from the value held at the door. */
|
|
1095
1120
|
opts = _shallowCopy(opts);
|
|
1121
|
+
if (carriedTransport !== undefined) opts.transport = carriedTransport;
|
|
1096
1122
|
var body = transferEncode(der);
|
|
1097
1123
|
return _client("fullcmc", "POST", baseUrl, body,
|
|
1098
|
-
{ accept: "application/pkcs7-mime", "content-type": "application/pkcs7-mime; smime-type=CMC-request" }, opts, proxySnap)
|
|
1124
|
+
{ accept: "application/pkcs7-mime", "content-type": "application/pkcs7-mime; smime-type=CMC-request" }, opts, proxySnap, undefined, carriedTransport)
|
|
1099
1125
|
.then(function (res) { return _fullcmcResult(res, opts, wanted, sent); });
|
|
1100
1126
|
} catch (e) {
|
|
1101
1127
|
return _rej(e);
|
|
@@ -1109,7 +1135,7 @@ function _correlateIssued(bag, wanted, arm) {
|
|
|
1109
1135
|
"this /fullcmc request declared no certification request whose key a returned certificate could be " +
|
|
1110
1136
|
"matched against, so a " + arm + " response cannot be read as an issuance (RFC 5272 sec. 4.1)");
|
|
1111
1137
|
}
|
|
1112
|
-
var byKey =
|
|
1138
|
+
var byKey = intrinsic.create(null);
|
|
1113
1139
|
wanted.forEach(function (k) {
|
|
1114
1140
|
var hex = k.toString("hex");
|
|
1115
1141
|
if (!byKey[hex]) byKey[hex] = { key: k, want: 0, have: null };
|
|
@@ -1211,8 +1237,8 @@ function _copyBytes(v) {
|
|
|
1211
1237
|
}
|
|
1212
1238
|
|
|
1213
1239
|
function _requestBinding(der) {
|
|
1214
|
-
var out = { transactionId: undefined, senderNonce: undefined, dataReturn: undefined, bodyPartIDs: undefined,
|
|
1215
|
-
bodyPartPaths: undefined };
|
|
1240
|
+
var out = intrinsic.assign(intrinsic.create(null), { transactionId: undefined, senderNonce: undefined, dataReturn: undefined, bodyPartIDs: undefined,
|
|
1241
|
+
bodyPartPaths: undefined });
|
|
1216
1242
|
var body = cmcFmt.parse(der);
|
|
1217
1243
|
var ids = [];
|
|
1218
1244
|
var paths = [];
|
|
@@ -1287,16 +1313,16 @@ function _assertAgrees(name, supplied, carried) {
|
|
|
1287
1313
|
|
|
1288
1314
|
function _copyRecipient(r) {
|
|
1289
1315
|
if (!r || typeof r !== "object") return r;
|
|
1290
|
-
var out =
|
|
1316
|
+
var out = intrinsic.create(null), k;
|
|
1291
1317
|
for (k in r) { if (_hasOwn(r, k)) out[k] = _copyBytes(r[k]); }
|
|
1292
1318
|
return out;
|
|
1293
1319
|
}
|
|
1294
1320
|
|
|
1295
1321
|
function _shallowCopy(o) {
|
|
1296
|
-
var out =
|
|
1322
|
+
var out = intrinsic.create(null), k;
|
|
1297
1323
|
for (k in o) { if (_hasOwn(o, k)) out[k] = o[k]; }
|
|
1298
1324
|
if (out.auth && typeof out.auth === "object") {
|
|
1299
|
-
var a =
|
|
1325
|
+
var a = intrinsic.create(null), ak;
|
|
1300
1326
|
for (ak in out.auth) { if (_hasOwn(out.auth, ak)) a[ak] = out.auth[ak]; }
|
|
1301
1327
|
out.auth = a;
|
|
1302
1328
|
}
|
|
@@ -1414,9 +1440,12 @@ function _causedBy(e, target) {
|
|
|
1414
1440
|
return false;
|
|
1415
1441
|
}
|
|
1416
1442
|
|
|
1417
|
-
var ENROLL_HEADERS = { accept: "application/pkcs7-mime", "content-type": "application/pkcs10" };
|
|
1443
|
+
var ENROLL_HEADERS = intrinsic.assign(intrinsic.create(null), { accept: "application/pkcs7-mime", "content-type": "application/pkcs10" });
|
|
1418
1444
|
|
|
1419
1445
|
function _enrollBound(op, baseUrl, builder, opts, proxySnap) {
|
|
1446
|
+
/** @internal Held before anything else the caller supplied is read, and carried to the client:
|
|
1447
|
+
* the builder runs during the handshake, so a later read could answer with a different value. */
|
|
1448
|
+
var checkedTransport = opts.transport;
|
|
1420
1449
|
if (_authScheme(opts) === "digest") {
|
|
1421
1450
|
throw E("est/channel-binding-digest-unsupported",
|
|
1422
1451
|
"Digest authentication cannot be combined with a channel-bound CSR builder: the Authorization header " +
|
|
@@ -1443,7 +1472,7 @@ function _enrollBound(op, baseUrl, builder, opts, proxySnap) {
|
|
|
1443
1472
|
.then(null, function (e) { attempt.error = e; attempt.done = true; throw e; });
|
|
1444
1473
|
};
|
|
1445
1474
|
}
|
|
1446
|
-
return _client(op, "POST", baseUrl, hopBody, ENROLL_HEADERS, opts, proxySnap, hopBody)
|
|
1475
|
+
return _client(op, "POST", baseUrl, hopBody, ENROLL_HEADERS, opts, proxySnap, hopBody, checkedTransport)
|
|
1447
1476
|
.then(function (res) {
|
|
1448
1477
|
if (current && current.error) throw current.error;
|
|
1449
1478
|
if (!current || !current.done) {
|
|
@@ -1461,10 +1490,11 @@ function _enrollBound(op, baseUrl, builder, opts, proxySnap) {
|
|
|
1461
1490
|
|
|
1462
1491
|
function _enroll(op, baseUrl, csrInput, opts, proxySnap) {
|
|
1463
1492
|
if (typeof csrInput === "function") return _enrollBound(op, baseUrl, csrInput, opts, proxySnap);
|
|
1493
|
+
var checkedTransport = opts.transport;
|
|
1464
1494
|
var csrDer = _csrDer(csrInput);
|
|
1465
1495
|
var spki = csr.parse(csrDer).subjectPublicKeyInfo;
|
|
1466
1496
|
var body = transferEncode(csrDer);
|
|
1467
|
-
return _client(op, "POST", baseUrl, body, ENROLL_HEADERS, opts, proxySnap)
|
|
1497
|
+
return _client(op, "POST", baseUrl, body, ENROLL_HEADERS, opts, proxySnap, undefined, checkedTransport)
|
|
1468
1498
|
.then(function (res) { return _certsResult(op, res, opts, spki); });
|
|
1469
1499
|
}
|
|
1470
1500
|
|
|
@@ -1505,8 +1535,8 @@ function cacerts(baseUrl, opts) {
|
|
|
1505
1535
|
opts = opts || {};
|
|
1506
1536
|
var proxySnap; try { proxySnap = _snapProxy(opts); } catch (_pe) { return _rej(E("est/bad-input", "the options object could not be read", _pe)); }
|
|
1507
1537
|
return Promise.resolve().then(function () {
|
|
1508
|
-
_knownOpts(opts, CACERTS_OPTS, "cacerts");
|
|
1509
|
-
return _client("cacerts", "GET", baseUrl, null, { accept: "application/pkcs7-mime" }, opts, proxySnap);
|
|
1538
|
+
opts = _knownOpts(opts, CACERTS_OPTS, "cacerts");
|
|
1539
|
+
return _client("cacerts", "GET", baseUrl, null, { accept: "application/pkcs7-mime" }, opts, proxySnap, undefined, opts.transport);
|
|
1510
1540
|
}).then(function (res) { return _certsResult("cacerts", res, opts, null); });
|
|
1511
1541
|
}
|
|
1512
1542
|
|
|
@@ -1571,7 +1601,7 @@ function simpleenroll(baseUrl, csrInput, opts) {
|
|
|
1571
1601
|
opts = opts || {};
|
|
1572
1602
|
var proxySnap; try { proxySnap = _snapProxy(opts); } catch (_pe) { return _rej(E("est/bad-input", "the options object could not be read", _pe)); }
|
|
1573
1603
|
return Promise.resolve().then(function () {
|
|
1574
|
-
_knownOpts(opts, SIMPLEENROLL_OPTS, "simpleenroll");
|
|
1604
|
+
opts = _knownOpts(opts, SIMPLEENROLL_OPTS, "simpleenroll");
|
|
1575
1605
|
return _enroll("simpleenroll", baseUrl, csrInput, opts, proxySnap);
|
|
1576
1606
|
});
|
|
1577
1607
|
}
|
|
@@ -1611,7 +1641,7 @@ function simplereenroll(baseUrl, csrInput, opts) {
|
|
|
1611
1641
|
opts = opts || {};
|
|
1612
1642
|
var proxySnap; try { proxySnap = _snapProxy(opts); } catch (_pe) { return _rej(E("est/bad-input", "the options object could not be read", _pe)); }
|
|
1613
1643
|
return Promise.resolve().then(function () {
|
|
1614
|
-
_knownOpts(opts, SIMPLEREENROLL_OPTS, "simplereenroll");
|
|
1644
|
+
opts = _knownOpts(opts, SIMPLEREENROLL_OPTS, "simplereenroll");
|
|
1615
1645
|
if (!opts.oldCert) throw E("est/bad-input", "simplereenroll requires opts.oldCert (the certificate being renewed, RFC 7030 sec. 4.2.2)");
|
|
1616
1646
|
if (typeof csrInput !== "function") reenrollGuard(opts.oldCert, _csrDer(csrInput));
|
|
1617
1647
|
return _enroll("simplereenroll", baseUrl, csrInput, opts, proxySnap);
|
|
@@ -1755,7 +1785,8 @@ function serverkeygen(baseUrl, csrInput, opts) {
|
|
|
1755
1785
|
opts = opts || {};
|
|
1756
1786
|
var proxySnap; try { proxySnap = _snapProxy(opts); } catch (_pe) { return _rej(E("est/bad-input", "the options object could not be read", _pe)); }
|
|
1757
1787
|
return Promise.resolve().then(function () {
|
|
1758
|
-
_knownOpts(opts, SERVERKEYGEN_OPTS, "serverkeygen");
|
|
1788
|
+
opts = _knownOpts(opts, SERVERKEYGEN_OPTS, "serverkeygen");
|
|
1789
|
+
var checkedTransport = opts.transport;
|
|
1759
1790
|
var csrDer = _csrDer(csrInput);
|
|
1760
1791
|
var derived = _serverkeygenEncryptionFromCsr(csrDer);
|
|
1761
1792
|
if (opts.requestedEncryption !== undefined && !!opts.requestedEncryption !== derived.requestedEncryption) throw E("est/bad-input", "opts.requestedEncryption (" + !!opts.requestedEncryption + ") contradicts the CSR's advertised key-encryption attribute (" + derived.requestedEncryption + ") (RFC 7030 sec. 4.4.1)");
|
|
@@ -1772,7 +1803,7 @@ function serverkeygen(baseUrl, csrInput, opts) {
|
|
|
1772
1803
|
if ((opts.expectedRecipientKeyId !== undefined || opts.expectedRecipientIssuerSerial != null) && !derived.requestedEncryption) {
|
|
1773
1804
|
throw E("est/bad-input", "a recipient expectation (expectedRecipientKeyId / expectedRecipientIssuerSerial) implies an encrypted key, but the CSR advertised no DecryptKeyIdentifier / AsymmetricDecryptKeyIdentifier attribute (RFC 7030 sec. 4.4.1)");
|
|
1774
1805
|
}
|
|
1775
|
-
return _client("serverkeygen", "POST", baseUrl, transferEncode(csrDer), { accept: "multipart/mixed", "content-type": "application/pkcs10" }, opts, proxySnap)
|
|
1806
|
+
return _client("serverkeygen", "POST", baseUrl, transferEncode(csrDer), { accept: "multipart/mixed", "content-type": "application/pkcs10" }, opts, proxySnap, undefined, checkedTransport)
|
|
1776
1807
|
.then(function (res) { return _serverkeygenResult(res, opts, derived); });
|
|
1777
1808
|
});
|
|
1778
1809
|
}
|
|
@@ -1816,8 +1847,8 @@ function csrattrs(baseUrl, opts) {
|
|
|
1816
1847
|
opts = opts || {};
|
|
1817
1848
|
var proxySnap; try { proxySnap = _snapProxy(opts); } catch (_pe) { return _rej(E("est/bad-input", "the options object could not be read", _pe)); }
|
|
1818
1849
|
return Promise.resolve().then(function () {
|
|
1819
|
-
_knownOpts(opts, CSRATTRS_OPTS, "csrattrs");
|
|
1820
|
-
return _client("csrattrs", "GET", baseUrl, null, { accept: "application/csrattrs" }, opts, proxySnap);
|
|
1850
|
+
opts = _knownOpts(opts, CSRATTRS_OPTS, "csrattrs");
|
|
1851
|
+
return _client("csrattrs", "GET", baseUrl, null, { accept: "application/csrattrs" }, opts, proxySnap, undefined, opts.transport);
|
|
1821
1852
|
}).then(function (res) { return _csrattrsResult(res, opts); });
|
|
1822
1853
|
}
|
|
1823
1854
|
|
package/lib/guard-async.js
CHANGED
|
@@ -6,6 +6,7 @@ var _intrinsic = require("./guard-intrinsic");
|
|
|
6
6
|
var _resolve = _intrinsic.uncurry(_intrinsic.promiseResolve);
|
|
7
7
|
var _reject = _intrinsic.uncurry(_intrinsic.promiseReject);
|
|
8
8
|
var _apply = _intrinsic.apply;
|
|
9
|
+
var _String = _intrinsic.String;
|
|
9
10
|
var _Promise = Promise;
|
|
10
11
|
// @internal
|
|
11
12
|
// @enforced-by behavioral -- the rule has no rename-proof code shape (it is the ABSENCE of a wrapper
|
|
@@ -29,4 +30,19 @@ function awaited(value, E, code, label) {
|
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
// @internal
|
|
34
|
+
// @enforced-by behavioral -- a RED vector drives a bound class constructor through a client verb
|
|
35
|
+
/** @internal Call a caller-supplied producer and hand back its promise. A synchronous throw from
|
|
36
|
+
* the call becomes the boundary's typed error, the same as a rejected promise or a non-thenable
|
|
37
|
+
* return already does. Some values pass a callability check and still throw when called: binding a
|
|
38
|
+
* class constructor hides its source, and a proxy can throw from its apply trap. */
|
|
39
|
+
function invoked(fn, args, E, code, label) {
|
|
40
|
+
var out;
|
|
41
|
+
try { out = _apply(fn, undefined, args); }
|
|
42
|
+
catch (e) {
|
|
43
|
+
throw E(code, label + " threw when it was called: " + (e && e.message ? e.message : _String(e)), e);
|
|
44
|
+
}
|
|
45
|
+
return awaited(out, E, code, label);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = _intrinsic.freeze({ deferred: deferred, awaited: awaited, invoked: invoked });
|
package/lib/guard-bytes.js
CHANGED
|
@@ -6,7 +6,7 @@ var async = require("./guard-async");
|
|
|
6
6
|
var identifier = require("./guard-identifier");
|
|
7
7
|
var time = require("./guard-time");
|
|
8
8
|
var intrinsic = require("./guard-intrinsic");
|
|
9
|
-
var util = { types: intrinsic.types };
|
|
9
|
+
var util = intrinsic.assign(intrinsic.create(null), { types: intrinsic.types });
|
|
10
10
|
var _isArray = intrinsic.isArray;
|
|
11
11
|
var _bufferFrom = intrinsic.bufferFrom;
|
|
12
12
|
var _isView = intrinsic.isView;
|
|
@@ -41,7 +41,7 @@ var _mapSet = intrinsic.mapSet;
|
|
|
41
41
|
var _taSet = intrinsic.typedArraySet;
|
|
42
42
|
var _Set = intrinsic.Set;
|
|
43
43
|
var _Map = intrinsic.Map;
|
|
44
|
-
|
|
44
|
+
var _append = require("./guard-list").append;
|
|
45
45
|
|
|
46
46
|
function _ownArrayIndices(v, n) {
|
|
47
47
|
var keys = _ownKeys(v);
|
|
@@ -65,7 +65,7 @@ function asyncStreamOf(x) {
|
|
|
65
65
|
if (isByteSource(x) || x == null || (typeof x !== "object" && typeof x !== "function")) return null;
|
|
66
66
|
var acquire = x[_asyncIterator];
|
|
67
67
|
if (typeof acquire !== "function") return null;
|
|
68
|
-
var stream =
|
|
68
|
+
var stream = intrinsic.create(null);
|
|
69
69
|
stream[_asyncIterator] = function () { return _apply(acquire, x, _NO_ARGS); };
|
|
70
70
|
return stream;
|
|
71
71
|
}
|
package/lib/guard-compress.js
CHANGED
|
@@ -15,17 +15,17 @@ var _sizeOf = _intrinsic.sizeOf;
|
|
|
15
15
|
var _subarray = _intrinsic.uncurry(Uint8Array.prototype.subarray);
|
|
16
16
|
var _hasOwn = _intrinsic.hasOwn;
|
|
17
17
|
|
|
18
|
-
var DECOMPRESS = {
|
|
18
|
+
var DECOMPRESS = _intrinsic.assign(_intrinsic.create(null), {
|
|
19
19
|
zlib: zlib.inflateSync,
|
|
20
20
|
brotli: zlib.brotliDecompressSync,
|
|
21
21
|
zstd: zlib.zstdDecompressSync,
|
|
22
|
-
};
|
|
22
|
+
});
|
|
23
23
|
|
|
24
|
-
var _PROBE_COMPRESS = {
|
|
24
|
+
var _PROBE_COMPRESS = _intrinsic.assign(_intrinsic.create(null), {
|
|
25
25
|
zlib: zlib.deflateSync,
|
|
26
26
|
brotli: zlib.brotliCompressSync,
|
|
27
27
|
zstd: zlib.zstdCompressSync,
|
|
28
|
-
};
|
|
28
|
+
});
|
|
29
29
|
|
|
30
30
|
function _reportsTruncation(name) {
|
|
31
31
|
var compress = _PROBE_COMPRESS[name];
|
|
@@ -47,7 +47,7 @@ function _reportsTruncation(name) {
|
|
|
47
47
|
return !cutAccepted;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
var SAFE =
|
|
50
|
+
var SAFE = _intrinsic.create(null);
|
|
51
51
|
_intrinsic.forEach(_objectKeys(DECOMPRESS), function (n) { if (_reportsTruncation(n)) SAFE[n] = true; });
|
|
52
52
|
|
|
53
53
|
// @enforced-by guard-shape-reinlined
|
package/lib/guard-identifier.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright (c) blamejs contributors
|
|
3
3
|
"use strict";
|
|
4
4
|
var intrinsic = require("./guard-intrinsic");
|
|
5
|
-
var util = { types: intrinsic.types };
|
|
5
|
+
var util = intrinsic.assign(intrinsic.create(null), { types: intrinsic.types });
|
|
6
6
|
// @internal
|
|
7
7
|
|
|
8
8
|
var _isArray = intrinsic.isArray;
|
|
@@ -32,13 +32,14 @@ var _Set = intrinsic.Set;
|
|
|
32
32
|
var _Map = intrinsic.Map;
|
|
33
33
|
var _charCodeAt = intrinsic.uncurry(String.prototype.charCodeAt);
|
|
34
34
|
var _strSplit = intrinsic.uncurry(String.prototype.split);
|
|
35
|
+
var _fnToString = intrinsic.uncurry(Function.prototype.toString);
|
|
35
36
|
var _hasOwn = intrinsic.hasOwn;
|
|
36
37
|
var _String = intrinsic.String;
|
|
37
38
|
var _Number = intrinsic.Number;
|
|
38
39
|
var _BigInt = intrinsic.BigInt;
|
|
39
40
|
var _Object = intrinsic.Object;
|
|
40
41
|
var _BufferProto = intrinsic.BufferProto;
|
|
41
|
-
|
|
42
|
+
var _append = require("./guard-list").append;
|
|
42
43
|
|
|
43
44
|
function _isDottedDecimal(str) {
|
|
44
45
|
if (str.length === 0) return false;
|
|
@@ -390,7 +391,50 @@ function _settle(opts, E, code, label) {
|
|
|
390
391
|
return opts;
|
|
391
392
|
}
|
|
392
393
|
|
|
394
|
+
/** @internal An injectable callback option, refused unless it is callable. A value that is present
|
|
395
|
+
* but not a function reaches the call site otherwise, where the operator gets a bare TypeError
|
|
396
|
+
* naming no option; and one read as absent sends the caller to whatever default the boundary
|
|
397
|
+
* installs, which for a transport is a real network client the caller was trying to replace. Take a
|
|
398
|
+
* value only when it is known to be present; `assertCallableOption` decides presence.
|
|
399
|
+
*
|
|
400
|
+
* Callable is all this asks. A class constructor answers "function" to typeof and still throws when
|
|
401
|
+
* called, but no test here separates one from an ordinary function: freezing a function leaves its
|
|
402
|
+
* prototype non-writable exactly as a class's is, and reading the source text mistakes a method
|
|
403
|
+
* named `class` for the keyword. The boundary that calls the value reports that throw as its own
|
|
404
|
+
* typed error (`guard.async.invoked`), which covers a class however it is disguised, binding it
|
|
405
|
+
* included, and rejects nothing a caller can legitimately pass. */
|
|
406
|
+
// @enforced-by behavioral -- the shape is a typeof test against a string literal, and the pattern
|
|
407
|
+
// @enforced-by behavioral -- scanner blanks every literal, so "function" cannot be told from
|
|
408
|
+
// @enforced-by behavioral -- "string" or "object"; a lexical rule would flag every type check in
|
|
409
|
+
// @enforced-by behavioral -- lib. The per-verb vectors across est, scep, acme, cmp and ct are the
|
|
410
|
+
// @enforced-by behavioral -- guard: each drives the shipped verb and asserts the typed refusal.
|
|
411
|
+
function assertCallable(value, E, code, label, shape) {
|
|
412
|
+
var wanted = label + " must be a function" + (shape ? " " + shape : "");
|
|
413
|
+
if (value === undefined) {
|
|
414
|
+
throw E(code, wanted + ", got undefined");
|
|
415
|
+
}
|
|
416
|
+
if (typeof value !== "function") {
|
|
417
|
+
throw E(code, wanted + ", got " + (value === null ? "null" : typeof value));
|
|
418
|
+
}
|
|
419
|
+
return value;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/** @internal The option form: an option counts as supplied when a name lookup finds the key, so a
|
|
423
|
+
* merge that produced `{ transport: undefined }` is a value the caller set rather than an option it
|
|
424
|
+
* left out. Presence is asked the way the boundary asks for the value, which is a plain lookup, so
|
|
425
|
+
* an inherited option from a defaults bag is checked rather than skipped; testing own keys alone
|
|
426
|
+
* would let an inherited null pass here and then be read as absent, selecting the default client.
|
|
427
|
+
* Only a key no lookup finds falls through to that default. */
|
|
428
|
+
// @enforced-by behavioral -- the per-verb vectors across est, scep, acme, cmp, ct and path drive the
|
|
429
|
+
// @enforced-by behavioral -- shipped verb and assert the typed refusal for each unusable value
|
|
430
|
+
function assertCallableOption(opts, key, E, code, label, shape) {
|
|
431
|
+
if (opts == null || !(key in _Object(opts))) return undefined;
|
|
432
|
+
return assertCallable(opts[key], E, code, label, shape);
|
|
433
|
+
}
|
|
434
|
+
|
|
393
435
|
module.exports = intrinsic.freeze({
|
|
436
|
+
assertCallable: assertCallable,
|
|
437
|
+
assertCallableOption: assertCallableOption,
|
|
394
438
|
assertCanonicalOid: assertCanonicalOid,
|
|
395
439
|
assertKnownKeys: assertKnownKeys,
|
|
396
440
|
assertPlainRecord: assertPlainRecord,
|
package/lib/guard-json.js
CHANGED
|
@@ -12,7 +12,7 @@ var _hasOwn = require("./guard-intrinsic").hasOwn;
|
|
|
12
12
|
var _Number = require("./guard-intrinsic").Number;
|
|
13
13
|
var _isFinite = require("./guard-intrinsic").isFinite;
|
|
14
14
|
var _stringify = require("./guard-intrinsic").stringify;
|
|
15
|
-
|
|
15
|
+
var _append = require("./guard-list").append;
|
|
16
16
|
var limits = require("./guard-limits");
|
|
17
17
|
|
|
18
18
|
function _hexVal(c) {
|
package/lib/guard-list.js
CHANGED
|
@@ -4,6 +4,21 @@
|
|
|
4
4
|
// @internal
|
|
5
5
|
|
|
6
6
|
var _freeze = require("./guard-intrinsic").freeze;
|
|
7
|
+
var _defineProperty = require("./guard-intrinsic").defineProperty;
|
|
8
|
+
var _isArray = require("./guard-intrinsic").isArray;
|
|
9
|
+
|
|
10
|
+
var MAX_ARRAY_LENGTH = 4294967295;
|
|
11
|
+
|
|
12
|
+
// @enforced-by guard-shape-reinlined
|
|
13
|
+
// @guard-shape defineProperty\(\s*\w+\s*,\s*\w+\.length\s*,\s*\{\s*value:
|
|
14
|
+
// @guard-via guard\.list\.append\(
|
|
15
|
+
function append(list, value) {
|
|
16
|
+
if (!_isArray(list)) throw new TypeError("guard.list.append: the receiver must be an array");
|
|
17
|
+
var n = list.length;
|
|
18
|
+
if (n >= MAX_ARRAY_LENGTH) throw new RangeError("guard.list.append: the array is at its maximum length");
|
|
19
|
+
_defineProperty(list, n, { value: value, writable: true, enumerable: true, configurable: true });
|
|
20
|
+
return list;
|
|
21
|
+
}
|
|
7
22
|
|
|
8
23
|
// @enforced-by behavioral -- `.indexOf(x) !== -1` has no rename-proof form that separates a
|
|
9
24
|
function contains(list, value) {
|
|
@@ -34,6 +49,7 @@ function allMatch(list, predicate) {
|
|
|
34
49
|
}
|
|
35
50
|
|
|
36
51
|
module.exports = _freeze({
|
|
52
|
+
append: append,
|
|
37
53
|
contains: contains,
|
|
38
54
|
containsAll: containsAll,
|
|
39
55
|
anyMatches: anyMatches,
|
package/lib/guard-name.js
CHANGED
|
@@ -152,7 +152,7 @@ function escapeControlBytes(str) {
|
|
|
152
152
|
return out;
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
var DN_SPECIAL = { 0x2c: 1, 0x2b: 1, 0x22: 1, 0x5c: 1, 0x3c: 1, 0x3e: 1, 0x3b: 1 };
|
|
155
|
+
var DN_SPECIAL = intrinsic.assign(intrinsic.create(null), { 0x2c: 1, 0x2b: 1, 0x22: 1, 0x5c: 1, 0x3c: 1, 0x3e: 1, 0x3b: 1 });
|
|
156
156
|
// @enforced-by behavioral -- the escaping has no rename-proof code shape distinct
|
|
157
157
|
function escapeDnValue(v) {
|
|
158
158
|
var s = _String(v), out = "";
|
package/lib/guard-parsed.js
CHANGED
|
@@ -20,7 +20,7 @@ var _weakSet = require("./guard-intrinsic").weakSet;
|
|
|
20
20
|
var _weakHas = require("./guard-intrinsic").weakHas;
|
|
21
21
|
var _WeakMap = require("./guard-intrinsic").WeakMap;
|
|
22
22
|
var _defineProperty = require("./guard-intrinsic").defineProperty;
|
|
23
|
-
|
|
23
|
+
var _append = require("./guard-list").append;
|
|
24
24
|
|
|
25
25
|
function _isBytes(x) {
|
|
26
26
|
return bytes.isByteSource(x);
|
package/lib/guard-time.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
"use strict";
|
|
4
4
|
// @internal
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _create = require("./guard-intrinsic").create;
|
|
7
|
+
var _assign = require("./guard-intrinsic").assign;
|
|
8
|
+
var util = _assign(_create(null), { types: require("./guard-intrinsic").types });
|
|
7
9
|
var _freeze = require("./guard-intrinsic").freeze;
|
|
8
10
|
var _isNaN = Number.isNaN;
|
|
9
11
|
var _Date = Date;
|
package/lib/guard-verdict.js
CHANGED
|
@@ -38,4 +38,10 @@ function carries(obj, key) {
|
|
|
38
38
|
return obj != null && _hasOwn(_Object(obj), key);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
// @enforced-by behavioral -- for a target that cannot be rebuilt, an Error carrying a field a
|
|
42
|
+
function set(target, key, value) {
|
|
43
|
+
_defineProperty(target, key, { value: value, enumerable: true, configurable: true, writable: true });
|
|
44
|
+
return target;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = _freeze({ of: of, carries: carries, set: set });
|
package/lib/hpke.js
CHANGED
|
@@ -102,8 +102,8 @@ function _labeledExpand(kdf, suiteId, prk, label, info, len) {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
|
|
105
|
-
var OKP_SPKI = { X25519: "302a300506032b656e032100", X448: "3042300506032b656f033900" };
|
|
106
|
-
var OKP_PKCS8 = { X25519: "302e020100300506032b656e04220420", X448: "3046020100300506032b656f043a0438" };
|
|
105
|
+
var OKP_SPKI = intrinsic.assign(intrinsic.create(null), { X25519: "302a300506032b656e032100", X448: "3042300506032b656f033900" });
|
|
106
|
+
var OKP_PKCS8 = intrinsic.assign(intrinsic.create(null), { X25519: "302e020100300506032b656e04220420", X448: "3046020100300506032b656f043a0438" });
|
|
107
107
|
|
|
108
108
|
function _importPublic(kem, raw) {
|
|
109
109
|
if (!Buffer.isBuffer(raw) || raw.length !== kem.Npub) {
|
|
@@ -318,9 +318,9 @@ function _recipPrivate(suite, sk) {
|
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
-
var _COMMON_KEYS = { mode: 1, info: 1, psk: 1, pskId: 1 };
|
|
321
|
+
var _COMMON_KEYS = intrinsic.assign(intrinsic.create(null), { mode: 1, info: 1, psk: 1, pskId: 1 });
|
|
322
322
|
function _withCommon(extra) {
|
|
323
|
-
var out =
|
|
323
|
+
var out = intrinsic.create(null);
|
|
324
324
|
Object.keys(_COMMON_KEYS).forEach(function (k) { out[k] = 1; });
|
|
325
325
|
Object.keys(extra).forEach(function (k) { out[k] = 1; });
|
|
326
326
|
return out;
|
|
@@ -348,12 +348,12 @@ function _mode(opts, keys, who) {
|
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
// @module @intro; a data registry, not a callable primitive).
|
|
351
|
-
var suites = {
|
|
352
|
-
KEM: { DHKEM_P256_HKDF_SHA256: 0x0010, DHKEM_P521_HKDF_SHA512: 0x0012, DHKEM_X25519_HKDF_SHA256: 0x0020, DHKEM_X448_HKDF_SHA512: 0x0021 },
|
|
353
|
-
KDF: { HKDF_SHA256: 0x0001, HKDF_SHA512: 0x0003 },
|
|
354
|
-
AEAD: { AES_128_GCM: 0x0001, AES_256_GCM: 0x0002, CHACHA20_POLY1305: 0x0003, EXPORT_ONLY: 0xFFFF },
|
|
355
|
-
MODE: { BASE: MODE_BASE, PSK: MODE_PSK, AUTH: MODE_AUTH, AUTH_PSK: MODE_AUTH_PSK },
|
|
356
|
-
};
|
|
351
|
+
var suites = intrinsic.assign(intrinsic.create(null), {
|
|
352
|
+
KEM: intrinsic.assign(intrinsic.create(null), { DHKEM_P256_HKDF_SHA256: 0x0010, DHKEM_P521_HKDF_SHA512: 0x0012, DHKEM_X25519_HKDF_SHA256: 0x0020, DHKEM_X448_HKDF_SHA512: 0x0021 }),
|
|
353
|
+
KDF: intrinsic.assign(intrinsic.create(null), { HKDF_SHA256: 0x0001, HKDF_SHA512: 0x0003 }),
|
|
354
|
+
AEAD: intrinsic.assign(intrinsic.create(null), { AES_128_GCM: 0x0001, AES_256_GCM: 0x0002, CHACHA20_POLY1305: 0x0003, EXPORT_ONLY: 0xFFFF }),
|
|
355
|
+
MODE: intrinsic.assign(intrinsic.create(null), { BASE: MODE_BASE, PSK: MODE_PSK, AUTH: MODE_AUTH, AUTH_PSK: MODE_AUTH_PSK }),
|
|
356
|
+
});
|
|
357
357
|
|
|
358
358
|
|
|
359
359
|
/**
|
package/lib/http-digest.js
CHANGED
|
@@ -17,10 +17,10 @@ var ALGS = intrinsic.assign(intrinsic.create(null), {
|
|
|
17
17
|
"SHA-256": { hash: "sha256", rank: 2, sess: false }, "SHA-256-SESS": { hash: "sha256", rank: 2, sess: true },
|
|
18
18
|
"MD5": { hash: "md5", rank: 1, sess: false }, "MD5-SESS": { hash: "md5", rank: 1, sess: true },
|
|
19
19
|
});
|
|
20
|
-
var DEFAULT_CODES = {
|
|
20
|
+
var DEFAULT_CODES = intrinsic.assign(intrinsic.create(null), {
|
|
21
21
|
unsupportedAlgorithm: "digest/unsupported-algorithm", weakAlgorithm: "digest/weak-algorithm",
|
|
22
22
|
noQop: "digest/no-qop", badChallenge: "digest/bad-challenge",
|
|
23
|
-
};
|
|
23
|
+
});
|
|
24
24
|
|
|
25
25
|
function H(hash, s) { return crypto.createHash(hash).update(s, "latin1").digest("hex"); }
|
|
26
26
|
function KD(hash, secret, data) { return H(hash, secret + ":" + data); }
|