@blamejs/pki 0.6.40 → 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 +13 -0
- package/lib/acme.js +24 -13
- package/lib/asn1-der.js +5 -5
- package/lib/attrcert-sign.js +14 -14
- 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 +21 -16
- package/lib/cmp-verify.js +4 -4
- 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 +6 -6
- 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 +17 -17
- package/lib/crmf-sign.js +11 -11
- package/lib/csr-sign.js +2 -2
- package/lib/ct.js +19 -11
- 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 +2 -2
- package/lib/guard-compress.js +5 -5
- package/lib/guard-identifier.js +45 -1
- package/lib/guard-name.js +1 -1
- package/lib/guard-time.js +3 -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/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 +32 -22
- package/lib/pbes2.js +2 -2
- package/lib/pkcs12-build.js +15 -15
- 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 +9 -8
- package/lib/smime.js +12 -12
- package/lib/tls-cert-compress.js +6 -6
- package/lib/trust.js +9 -9
- package/lib/tsp-sign.js +11 -11
- 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 +12 -12
- 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/crl-sign.js
CHANGED
|
@@ -58,28 +58,28 @@ var CRL_REASON = constants.NAMES.CRL_REASON;
|
|
|
58
58
|
var REASON_BY_NAME = intrinsic.create(null);
|
|
59
59
|
Object.keys(CRL_REASON).forEach(function (v) { REASON_BY_NAME[CRL_REASON[v]] = Number(v); });
|
|
60
60
|
|
|
61
|
-
var KNOWN_CRL_EXT_KEYS = { authorityKeyIdentifier: 1, issuingDistributionPoint: 1, deltaCRLIndicator: 1, freshestCRL: 1, authorityInfoAccess: 1 };
|
|
62
|
-
var KNOWN_SPEC_KEYS = {
|
|
61
|
+
var KNOWN_CRL_EXT_KEYS = intrinsic.assign(intrinsic.create(null), { authorityKeyIdentifier: 1, issuingDistributionPoint: 1, deltaCRLIndicator: 1, freshestCRL: 1, authorityInfoAccess: 1 });
|
|
62
|
+
var KNOWN_SPEC_KEYS = intrinsic.assign(intrinsic.create(null), {
|
|
63
63
|
issuer: 1, thisUpdate: 1, nextUpdate: 1, revoked: 1, crlNumber: 1, extensions: 1,
|
|
64
|
-
};
|
|
65
|
-
var KNOWN_SPEC_KEYS_ISSUER_NAMED = {
|
|
64
|
+
});
|
|
65
|
+
var KNOWN_SPEC_KEYS_ISSUER_NAMED = intrinsic.assign(intrinsic.create(null), {
|
|
66
66
|
thisUpdate: 1, nextUpdate: 1, revoked: 1, crlNumber: 1, extensions: 1,
|
|
67
|
-
};
|
|
68
|
-
var KNOWN_ISSUER_CERT_KEYS = { key: 1, cert: 1 };
|
|
69
|
-
var KNOWN_ISSUER_EXPLICIT_KEYS = { key: 1, name: 1, publicKey: 1 };
|
|
70
|
-
var KNOWN_SIGN_OPTS = { digestAlgorithm: 1, pem: 1, pss: 1 };
|
|
67
|
+
});
|
|
68
|
+
var KNOWN_ISSUER_CERT_KEYS = intrinsic.assign(intrinsic.create(null), { key: 1, cert: 1 });
|
|
69
|
+
var KNOWN_ISSUER_EXPLICIT_KEYS = intrinsic.assign(intrinsic.create(null), { key: 1, name: 1, publicKey: 1 });
|
|
70
|
+
var KNOWN_SIGN_OPTS = intrinsic.assign(intrinsic.create(null), { digestAlgorithm: 1, pem: 1, pss: 1 });
|
|
71
71
|
|
|
72
|
-
var KNOWN_IDP_KEYS = { fullName: 1, onlyContainsUserCerts: 1, onlyContainsCACerts: 1, onlyContainsAttributeCerts: 1, indirectCRL: 1 };
|
|
72
|
+
var KNOWN_IDP_KEYS = intrinsic.assign(intrinsic.create(null), { fullName: 1, onlyContainsUserCerts: 1, onlyContainsCACerts: 1, onlyContainsAttributeCerts: 1, indirectCRL: 1 });
|
|
73
73
|
|
|
74
|
-
var KNOWN_REVOKED_KEYS = {
|
|
74
|
+
var KNOWN_REVOKED_KEYS = intrinsic.assign(intrinsic.create(null), {
|
|
75
75
|
serialNumber: 1, revocationDate: 1, reason: 1, invalidityDate: 1, certificateIssuer: 1, extensions: 1,
|
|
76
|
-
};
|
|
76
|
+
});
|
|
77
77
|
|
|
78
|
-
var REQUIRED_CRITICALITY =
|
|
78
|
+
var REQUIRED_CRITICALITY = intrinsic.create(null);
|
|
79
79
|
[["cRLNumber", false], ["authorityKeyIdentifier", false], ["freshestCRL", false], ["authorityInfoAccess", false],
|
|
80
80
|
["issuingDistributionPoint", true], ["deltaCRLIndicator", true]].forEach(function (r) { REQUIRED_CRITICALITY[O(r[0])] = r[1]; });
|
|
81
81
|
|
|
82
|
-
var REQUIRED_ENTRY_CRITICALITY =
|
|
82
|
+
var REQUIRED_ENTRY_CRITICALITY = intrinsic.create(null);
|
|
83
83
|
[["reasonCode", false], ["invalidityDate", false]].forEach(function (r) { REQUIRED_ENTRY_CRITICALITY[O(r[0])] = r[1]; });
|
|
84
84
|
|
|
85
85
|
var _CERT_ISSUER_DEFERRED = "certificateIssuer (indirect CRLs) is not yet supported -- pki.path.crlChecker skips a CRL carrying any critical entry extension other than reasonCode, so an indirect CRL would never be authoritative for revocation. Re-enabled once the checker processes certificateIssuer / indirect CRLs.";
|
|
@@ -189,7 +189,7 @@ function _aiaValue(spec) {
|
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
function _buildCrlExtensions(spec, ctx) {
|
|
192
|
-
var out = [], seen =
|
|
192
|
+
var out = [], seen = intrinsic.create(null), isDelta = false;
|
|
193
193
|
function push(oidName, critical, valueDer) {
|
|
194
194
|
var id = O(oidName);
|
|
195
195
|
if (seen[id]) throw _err("crl/bad-input", "duplicate CRL extension " + oidName + " (RFC 5280 sec. 5.2 -- at most one instance)");
|
|
@@ -255,7 +255,7 @@ function _buildCrlExtensions(spec, ctx) {
|
|
|
255
255
|
|
|
256
256
|
function _buildRevoked(entryList, isDelta) {
|
|
257
257
|
if (!Array.isArray(entryList)) throw _err("crl/bad-input", "revoked must be an array of revoked-certificate entries");
|
|
258
|
-
var anyExt = false, seenSerials =
|
|
258
|
+
var anyExt = false, seenSerials = intrinsic.create(null);
|
|
259
259
|
var entries = _b.reqDenseArray(entryList, "revoked").map(function (e, idx) {
|
|
260
260
|
if (!e || typeof e !== "object" || Buffer.isBuffer(e)) throw _err("crl/bad-input", "each revoked entry must be an object");
|
|
261
261
|
guard.identifier.assertKnownKeys(e, KNOWN_REVOKED_KEYS, _err, "crl/bad-input", function (k) {
|
|
@@ -268,7 +268,7 @@ function _buildRevoked(entryList, isDelta) {
|
|
|
268
268
|
if (seenSerials[serialKey]) throw _err("crl/bad-input", "revoked entry [" + idx + "] duplicates a serial number already listed in this CRL (RFC 5280 sec. 5.1.2.6)");
|
|
269
269
|
seenSerials[serialKey] = true;
|
|
270
270
|
var children = [serialTlv, _timeDer(e.revocationDate, "revocationDate")];
|
|
271
|
-
var entryExts = [], seen =
|
|
271
|
+
var entryExts = [], seen = intrinsic.create(null);
|
|
272
272
|
function pushE(oidName, critical, valueDer) {
|
|
273
273
|
var id = O(oidName);
|
|
274
274
|
if (seen[id]) throw _err("crl/bad-input", "duplicate entry extension " + oidName + " in revoked entry [" + idx + "]");
|
|
@@ -602,7 +602,7 @@ function _serialHexOf(serial) {
|
|
|
602
602
|
* { cert: signerCertDer, key: signerKeyPkcs8 });
|
|
603
603
|
* pki.crl.isRevoked(crlDer, 0x1234n) ? "revoked" : "not listed";
|
|
604
604
|
*/
|
|
605
|
-
var KNOWN_IS_REVOKED_KEYS = { time: 1, historicalMode: 1 };
|
|
605
|
+
var KNOWN_IS_REVOKED_KEYS = intrinsic.assign(intrinsic.create(null), { time: 1, historicalMode: 1 });
|
|
606
606
|
function isRevoked(crl, serialNumber, opts) {
|
|
607
607
|
var o = guard.identifier.optionsObject(opts, _err, "crl/bad-input", "pki.crl.isRevoked options");
|
|
608
608
|
guard.identifier.assertKnownKeys(o, KNOWN_IS_REVOKED_KEYS, _err, "crl/bad-input", function (k) {
|
package/lib/crmf-sign.js
CHANGED
|
@@ -47,8 +47,8 @@ var _b = pkiBuild.makeBuilder({
|
|
|
47
47
|
NAME_SCHEMA: pkix.name(NS), SPKI_SCHEMA: pkix.spki(NS), EXT_DECODERS: EXT_DECODERS,
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
var KNOWN_SPEC_KEYS = { certReqId: 1, certTemplate: 1, controls: 1, regInfo: 1, pop: 1 };
|
|
51
|
-
var POP_KEYS_BY_ARM = {
|
|
50
|
+
var KNOWN_SPEC_KEYS = intrinsic.assign(intrinsic.create(null), { certReqId: 1, certTemplate: 1, controls: 1, regInfo: 1, pop: 1 });
|
|
51
|
+
var POP_KEYS_BY_ARM = intrinsic.assign(intrinsic.create(null), {
|
|
52
52
|
raVerified: { type: 1, raVerified: 1 },
|
|
53
53
|
signature: { type: 1, sender: 1 },
|
|
54
54
|
subsequentMessage: { type: 1, method: 1, subsequentMessage: 1 },
|
|
@@ -59,14 +59,14 @@ var POP_KEYS_BY_ARM = {
|
|
|
59
59
|
agreeMAC: { type: 1, method: 1 },
|
|
60
60
|
thisMessage: { type: 1, method: 1 },
|
|
61
61
|
dhMAC: { type: 1, method: 1 },
|
|
62
|
-
};
|
|
63
|
-
var KNOWN_BATCH_KEYS = { messages: 1 };
|
|
64
|
-
var KNOWN_TEMPLATE_KEYS = { version: 1, subject: 1, publicKey: 1, validity: 1, extensions: 1, issuer: 1 };
|
|
65
|
-
var REVOCATION_TEMPLATE_KEYS = { version: 1, subject: 1, publicKey: 1, validity: 1, extensions: 1, issuer: 1, serialNumber: 1 };
|
|
62
|
+
});
|
|
63
|
+
var KNOWN_BATCH_KEYS = intrinsic.assign(intrinsic.create(null), { messages: 1 });
|
|
64
|
+
var KNOWN_TEMPLATE_KEYS = intrinsic.assign(intrinsic.create(null), { version: 1, subject: 1, publicKey: 1, validity: 1, extensions: 1, issuer: 1 });
|
|
65
|
+
var REVOCATION_TEMPLATE_KEYS = intrinsic.assign(intrinsic.create(null), { version: 1, subject: 1, publicKey: 1, validity: 1, extensions: 1, issuer: 1, serialNumber: 1 });
|
|
66
66
|
function _ctlUtf8(v) { return b.utf8(String(v)); }
|
|
67
67
|
function _ctlSpki(v) { var k = _b.reqDer(v, "protocolEncrKey (an SPKI DER)"); _b.assertValidSpki(k, "protocolEncrKey"); return b.raw(k); }
|
|
68
|
-
var CONTROL_VALUE = { regToken: _ctlUtf8, authenticator: _ctlUtf8, oldCertID: function (v) { return _encodeCertId(v); }, protocolEncrKey: _ctlSpki };
|
|
69
|
-
var REGINFO_VALUE = { utf8Pairs: _ctlUtf8 };
|
|
68
|
+
var CONTROL_VALUE = intrinsic.assign(intrinsic.create(null), { regToken: _ctlUtf8, authenticator: _ctlUtf8, oldCertID: function (v) { return _encodeCertId(v); }, protocolEncrKey: _ctlSpki });
|
|
69
|
+
var REGINFO_VALUE = intrinsic.assign(intrinsic.create(null), { utf8Pairs: _ctlUtf8 });
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
function _encodeOptionalValidity(validity) {
|
|
@@ -106,7 +106,7 @@ function _encodeCertTemplate(tpl, opts) {
|
|
|
106
106
|
function _buildAttrTypeAndValues(spec, code, label, valueMap) {
|
|
107
107
|
if (Array.isArray(spec)) {
|
|
108
108
|
if (!spec.length) throw _err(code, label + " must carry at least one entry");
|
|
109
|
-
var seenA =
|
|
109
|
+
var seenA = intrinsic.create(null);
|
|
110
110
|
return b.sequence(pkiBuild.reqDenseArray(spec, label, _err, code).map(function (e, i) {
|
|
111
111
|
var der = _b.reqDer(e, label + " [" + i + "]");
|
|
112
112
|
var n;
|
|
@@ -120,7 +120,7 @@ function _buildAttrTypeAndValues(spec, code, label, valueMap) {
|
|
|
120
120
|
}));
|
|
121
121
|
}
|
|
122
122
|
if (!spec || typeof spec !== "object") throw _err("crmf/bad-input", label + " must be an object or an array of pre-encoded AttributeTypeAndValue DER");
|
|
123
|
-
var out = [], seen =
|
|
123
|
+
var out = [], seen = intrinsic.create(null);
|
|
124
124
|
guard.identifier.assertKnownKeys(spec, valueMap, _err, "crmf/bad-input", function (k) {
|
|
125
125
|
return "unknown " + label + " " + JSON.stringify(k) + "; pass a pre-encoded AttributeTypeAndValue DER via the array form for a " + label + " entry outside " + Object.keys(valueMap).join("/");
|
|
126
126
|
});
|
|
@@ -147,7 +147,7 @@ function _encodeCertId(id) {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
var POPO_PRIVKEY_TAGS = intrinsic.assign(intrinsic.create(null), { keyEncipherment: 2, keyAgreement: 3 });
|
|
150
|
-
var SUBSEQUENT_MESSAGE = { encrCert: 0n, challengeResp: 1n };
|
|
150
|
+
var SUBSEQUENT_MESSAGE = intrinsic.assign(intrinsic.create(null), { encrCert: 0n, challengeResp: 1n });
|
|
151
151
|
var DEPRECATED_POPO_METHOD = intrinsic.assign(intrinsic.create(null), { thisMessage: "encryptedKey", dhMAC: "agreeMAC" });
|
|
152
152
|
|
|
153
153
|
function _encKeyWithID(privateKeyDer, identifier) {
|
package/lib/csr-sign.js
CHANGED
|
@@ -29,7 +29,7 @@ require("./path-validate");
|
|
|
29
29
|
var csrVerify = require("./csr-verify");
|
|
30
30
|
|
|
31
31
|
var CsrError = frameworkError.CsrError;
|
|
32
|
-
var KNOWN_SPEC_KEYS = { subject: 1, subjectPublicKey: 1, extensionRequest: 1, challengePassword: 1, attributes: 1 };
|
|
32
|
+
var KNOWN_SPEC_KEYS = Object.assign(Object.create(null), { subject: 1, subjectPublicKey: 1, extensionRequest: 1, challengePassword: 1, attributes: 1 });
|
|
33
33
|
var b = asn1.build;
|
|
34
34
|
function _err(code, message, cause) { return new CsrError(code, message, cause); }
|
|
35
35
|
function _signE(kind, message, cause) { return new CsrError("csr/" + kind, message, cause); }
|
|
@@ -106,7 +106,7 @@ function _sign(spec, key, opts) {
|
|
|
106
106
|
_b.assertValidSpki(subjectSpki, "spec.subjectPublicKey");
|
|
107
107
|
var subjectDer = _b.encodeName(spec.subject == null ? [] : spec.subject);
|
|
108
108
|
|
|
109
|
-
var attrs = [], seenAttr =
|
|
109
|
+
var attrs = [], seenAttr = Object.create(null);
|
|
110
110
|
function addAttr(attrType, valueTlv) {
|
|
111
111
|
if (seenAttr[attrType]) throw _err("csr/bad-input", "duplicate " + (oid.name(attrType) || attrType) + " attribute");
|
|
112
112
|
seenAttr[attrType] = true;
|
package/lib/ct.js
CHANGED
|
@@ -64,10 +64,10 @@ var C = constants;
|
|
|
64
64
|
|
|
65
65
|
function _ctErr(c, m, cause) { return new CtError(c, m, cause); }
|
|
66
66
|
|
|
67
|
-
var HASH_ALGORITHMS = {
|
|
67
|
+
var HASH_ALGORITHMS = intrinsic.assign(intrinsic.create(null), {
|
|
68
68
|
0: "none", 1: "md5", 2: "sha1", 3: "sha224", 4: "sha256", 5: "sha384", 6: "sha512",
|
|
69
|
-
};
|
|
70
|
-
var SIGNATURE_ALGORITHMS = { 0: "anonymous", 1: "rsa", 2: "dsa", 3: "ecdsa" };
|
|
69
|
+
});
|
|
70
|
+
var SIGNATURE_ALGORITHMS = intrinsic.assign(intrinsic.create(null), { 0: "anonymous", 1: "rsa", 2: "dsa", 3: "ecdsa" });
|
|
71
71
|
|
|
72
72
|
var SCT_MIN_BODY = 47;
|
|
73
73
|
var LOGID_BYTES = 32;
|
|
@@ -290,8 +290,8 @@ function reconstructSignedData(entry, sct) {
|
|
|
290
290
|
return Buffer.concat(parts);
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
-
var CT_HASH = { sha256: "SHA-256" };
|
|
294
|
-
var CT_EC_CURVE =
|
|
293
|
+
var CT_HASH = intrinsic.assign(intrinsic.create(null), { sha256: "SHA-256" });
|
|
294
|
+
var CT_EC_CURVE = intrinsic.create(null);
|
|
295
295
|
CT_EC_CURVE[oid.byName("prime256v1")] = { curve: "P-256", coordLen: 32 };
|
|
296
296
|
|
|
297
297
|
function _spkiAlg(spki) {
|
|
@@ -563,7 +563,7 @@ async function signSct(entry, logKey, opts) {
|
|
|
563
563
|
}
|
|
564
564
|
|
|
565
565
|
|
|
566
|
-
var LOG_STATE_TRUST = { pending: "no", qualified: "yes", usable: "yes", readonly: "yes", retired: "conditional", rejected: "no" };
|
|
566
|
+
var LOG_STATE_TRUST = intrinsic.assign(intrinsic.create(null), { pending: "no", qualified: "yes", usable: "yes", readonly: "yes", retired: "conditional", rejected: "no" });
|
|
567
567
|
|
|
568
568
|
function _parseLogState(state) {
|
|
569
569
|
if (state == null || typeof state !== "object") throw _ctErr("ct/bad-state", "a CT log entry is missing its state");
|
|
@@ -776,7 +776,7 @@ async function verifySctWithLogList(entry, sct, logList, opts) {
|
|
|
776
776
|
});
|
|
777
777
|
}
|
|
778
778
|
|
|
779
|
-
var _VERIFY_SCT_LIST_OPTS = { minScts: 1, minOperators: 1, certNotAfter: 1, at: 1 };
|
|
779
|
+
var _VERIFY_SCT_LIST_OPTS = intrinsic.assign(intrinsic.create(null), { minScts: 1, minOperators: 1, certNotAfter: 1, at: 1 });
|
|
780
780
|
|
|
781
781
|
function _policyCount(v, name) {
|
|
782
782
|
if (v == null) return null;
|
|
@@ -1029,7 +1029,7 @@ async function verifyLogListSignature(json, signature, publicKey) {
|
|
|
1029
1029
|
|
|
1030
1030
|
var DEFAULT_FETCH_TIMEOUT = C.TIME.seconds(30);
|
|
1031
1031
|
var MAX_FETCH_TIMEOUT = C.TIME.seconds(600);
|
|
1032
|
-
var KNOWN_FETCH_OPTS = { url: 1, signerKey: 1, sigUrl: 1, transport: 1, tls: 1, headers: 1, timeout: 1, maxResponseBytes: 1, requireJsonContentType: 1 };
|
|
1032
|
+
var KNOWN_FETCH_OPTS = intrinsic.assign(intrinsic.create(null), { url: 1, signerKey: 1, sigUrl: 1, transport: 1, tls: 1, headers: 1, timeout: 1, maxResponseBytes: 1, requireJsonContentType: 1 });
|
|
1033
1033
|
|
|
1034
1034
|
function _tlsForFetch(opts) {
|
|
1035
1035
|
var t = opts.tls || {};
|
|
@@ -1038,6 +1038,12 @@ function _tlsForFetch(opts) {
|
|
|
1038
1038
|
|
|
1039
1039
|
function _sameOrigin(a, b) { return new URL(a).origin === new URL(b).origin; }
|
|
1040
1040
|
|
|
1041
|
+
/** @internal Refused at the door and again where the value is used. */
|
|
1042
|
+
function _assertTransport(opts) {
|
|
1043
|
+
return guard.identifier.assertCallableOption(opts, "transport", _ctErr, "ct/bad-input", "opts.transport",
|
|
1044
|
+
"(request) => Promise<{ status, headers, body }>");
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1041
1047
|
function _fetchCtypeToken(headers) { return String((headers || {})["content-type"] || "").split(";")[0].trim().toLowerCase(); }
|
|
1042
1048
|
|
|
1043
1049
|
function _parseHttpsUrl(u, label) {
|
|
@@ -1060,7 +1066,7 @@ function _fetchBody(transport, url, req, label) {
|
|
|
1060
1066
|
return transport({ method: "GET", url: url, headers: req.headers, tls: req.tls, timeout: req.timeout, maxResponseBytes: req.maxResponseBytes });
|
|
1061
1067
|
}).then(function (res) {
|
|
1062
1068
|
res = res || {};
|
|
1063
|
-
var h =
|
|
1069
|
+
var h = intrinsic.create(null);
|
|
1064
1070
|
Object.keys(res.headers || {}).forEach(function (k) { h[k.toLowerCase()] = res.headers[k]; });
|
|
1065
1071
|
var body = guard.bytes.isByteSource(res.body)
|
|
1066
1072
|
? guard.bytes.source(res.body, CtError, "ct/bad-input", label)
|
|
@@ -1116,13 +1122,15 @@ function _fetchBody(transport, url, req, label) {
|
|
|
1116
1122
|
async function fetchLogList(opts) {
|
|
1117
1123
|
opts = opts || {};
|
|
1118
1124
|
guard.identifier.assertKnownKeys(opts, KNOWN_FETCH_OPTS, _ctErr, "ct/bad-input", "unknown opts field ");
|
|
1125
|
+
/** @internal Read once, at the door, and carried from here. Asking again would let an option that
|
|
1126
|
+
* answers differently on each read hand back something other than the value that was checked. */
|
|
1127
|
+
var transport = _assertTransport(opts);
|
|
1119
1128
|
if (opts.signerKey == null) throw _ctErr("ct/bad-input", "opts.signerKey is required -- the caller-pinned CT log-list distributor SPKI (there is no baked-in key)");
|
|
1120
1129
|
if (opts.url == null) throw _ctErr("ct/bad-input", "opts.url is required -- the log_list.json URL (there is no baked-in vendor URL)");
|
|
1121
1130
|
var jsonParsed = _parseHttpsUrl(opts.url, "URL");
|
|
1122
1131
|
var jsonUrl = jsonParsed.href;
|
|
1123
1132
|
var sigUrl = opts.sigUrl != null ? _parseHttpsUrl(opts.sigUrl, "signature URL").href : _sigUrlFor(jsonParsed);
|
|
1124
1133
|
if (!_sameOrigin(jsonUrl, sigUrl)) throw _ctErr("ct/bad-input", "opts.sigUrl must share the log-list URL's origin (" + jsonParsed.origin + "); a cross-origin detached-signature host is not supported");
|
|
1125
|
-
var transport = opts.transport;
|
|
1126
1134
|
if (!transport) {
|
|
1127
1135
|
var t = opts.tls || {};
|
|
1128
1136
|
var hasAnchors = t.anchors !== undefined && t.anchors !== null && !(Array.isArray(t.anchors) && t.anchors.length === 0);
|
|
@@ -1131,7 +1139,7 @@ async function fetchLogList(opts) {
|
|
|
1131
1139
|
}
|
|
1132
1140
|
var timeout = guard.limits.cap(opts.timeout, "timeout", DEFAULT_FETCH_TIMEOUT, { E: _ctErr, code: "ct/bad-input", min: 1, max: MAX_FETCH_TIMEOUT });
|
|
1133
1141
|
var maxResponseBytes = guard.limits.cap(opts.maxResponseBytes, "maxResponseBytes", C.LIMITS.CT_LOG_LIST_MAX_BYTES, { E: _ctErr, code: "ct/bad-input", min: 1, max: C.LIMITS.CT_LOG_LIST_MAX_BYTES });
|
|
1134
|
-
var headers =
|
|
1142
|
+
var headers = intrinsic.create(null);
|
|
1135
1143
|
Object.keys(opts.headers || {}).forEach(function (k) {
|
|
1136
1144
|
var lk = k.toLowerCase();
|
|
1137
1145
|
if (lk !== "content-length" && lk !== "transfer-encoding") headers[k] = opts.headers[k];
|
package/lib/edwards-point.js
CHANGED
|
@@ -11,10 +11,10 @@ var SQRTM1 = _pow(2n, (P25519 - 1n) / 4n, P25519);
|
|
|
11
11
|
var P448 = (1n << 448n) - (1n << 224n) - 1n;
|
|
12
12
|
var D448 = P448 - 39081n;
|
|
13
13
|
|
|
14
|
-
var CURVE = {
|
|
14
|
+
var CURVE = Object.assign(Object.create(null), {
|
|
15
15
|
6: { p: P25519, d: D25519, a: P25519 - 1n, len: 32, signBit: 255n },
|
|
16
16
|
7: { p: P448, d: D448, a: 1n, len: 57, signBit: 455n },
|
|
17
|
-
};
|
|
17
|
+
});
|
|
18
18
|
|
|
19
19
|
function _mul(x, y, p) { return (x % p) * (y % p) % p; }
|
|
20
20
|
function _pow(b, e, p) { var r = 1n; b %= p; while (e > 0n) { if (e & 1n) r = r * b % p; b = b * b % p; e >>= 1n; } return r; }
|
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 });
|