@blamejs/pki 0.7.29 → 0.7.30

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 CHANGED
@@ -4,6 +4,15 @@ All notable changes to `@blamejs/pki` are documented here. The format
4
4
  follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); this
5
5
  project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## v0.7.30 — 2026-09-12
8
+
9
+ The Sigstore bundle verifier decides with operations bound when the module loads.
10
+
11
+ ### Changed
12
+
13
+ - pki.sigstore.verifyBundle, parseBundle and pae read Buffer.prototype.equals, Buffer.prototype.toString, Buffer.prototype.subarray and Buffer.prototype.indexOf, Buffer.from and Buffer.concat, String.prototype.split, slice, indexOf, charAt and charCodeAt, Array.prototype.map, forEach, filter and slice, Object.assign, Object.create and Object.freeze, String, Number, BigInt, Date, Date.parse, Number.isNaN and JSON.stringify as bound at module load. Replacing Buffer.prototype.equals, String.prototype.split or indexOf, Array.prototype.filter or forEach, or Date.parse after load changes nothing this module decides: a valid bundle still verifies and a Rekor entry whose signature is not the bundle's is still refused. A replacement of Buffer.prototype.toString or subarray, Array.prototype.map, BigInt, Buffer.from or Buffer.concat still reaches the certificate parser and the chain builder's neighbors, which read those live; that residual is theirs and is stated here rather than implied covered.
14
+ - SECURITY.md names the key import and export verbs and the Sigstore bundle verifier among the surfaces that take what they decide with at load.
15
+
7
16
  ## v0.7.29 — 2026-09-12
8
17
 
9
18
  Every decision pki.key makes is taken with operations bound when the module loads.
@@ -28,6 +28,7 @@ var _keyEquals = uncurry(_nodeCrypto.KeyObject.prototype.equals);
28
28
  var _isView = ArrayBuffer.isView;
29
29
  var _isInteger = Number.isInteger;
30
30
  var _isSafeInteger = Number.isSafeInteger;
31
+ var _numberIsFinite = Number.isFinite;
31
32
  var _fromCharCode = String.fromCharCode;
32
33
  var _objectCreate = Object.create;
33
34
  var _getPrototypeOf = Object.getPrototypeOf;
@@ -85,6 +86,8 @@ var _Number = Number;
85
86
  var _Boolean = Boolean;
86
87
  var _BigInt = BigInt;
87
88
  var _Date = Date;
89
+ var _dateParse = Date.parse;
90
+ var _numberIsNaN = Number.isNaN;
88
91
  var _isFinite = globalThis.isFinite;
89
92
  var _ArrayBuffer = ArrayBuffer;
90
93
  var _Uint8Array = Uint8Array;
@@ -155,6 +158,7 @@ module.exports = Object.freeze({
155
158
  isView: _isView,
156
159
  isInteger: _isInteger,
157
160
  isSafeInteger: _isSafeInteger,
161
+ numberIsFinite: _numberIsFinite,
158
162
  fromCharCode: _fromCharCode,
159
163
  create: _objectCreate,
160
164
  getPrototypeOf: _getPrototypeOf,
@@ -202,6 +206,8 @@ module.exports = Object.freeze({
202
206
  Boolean: _Boolean,
203
207
  BigInt: _BigInt,
204
208
  Date: _Date,
209
+ dateParse: _dateParse,
210
+ numberIsNaN: _numberIsNaN,
205
211
  isFinite: _isFinite,
206
212
  ArrayBuffer: _ArrayBuffer,
207
213
  Uint8Array: _Uint8Array,
package/lib/sigstore.js CHANGED
@@ -33,6 +33,7 @@ var frameworkError = require("./framework-error");
33
33
  var constants = require("./constants");
34
34
  var asn1 = require("./asn1-der");
35
35
  var guard = require("./guard-all");
36
+ var intrinsic = require("./guard-intrinsic");
36
37
  var x509 = require("./schema-x509");
37
38
  var pkix = require("./schema-pkix");
38
39
  var pathValidate = require("./path-validate");
@@ -41,6 +42,59 @@ var oid = require("./oid");
41
42
  var ct = require("./ct");
42
43
  var edwardsPoint = require("./edwards-point");
43
44
 
45
+ /** @internal The operations this module decides with, taken at load. The bundle copy every later
46
+ * check runs on settles what is verified, so which function answers "what does this object own" and
47
+ * "what does it hold" is fixed before any caller code runs; one replaced after this module loads
48
+ * would otherwise be asked at the moment of the call. An emptied key list alone turns a bundle into
49
+ * one carrying no content arm. */
50
+ var _ownNames = intrinsic.getOwnPropertyNames;
51
+ var _ownDescriptor = intrinsic.getOwnPropertyDescriptor;
52
+ var _isArray = intrinsic.isArray;
53
+ var _create = intrinsic.create;
54
+ var _assign = intrinsic.assign;
55
+ var _freeze = intrinsic.freeze;
56
+ var _stringOf = intrinsic.String;
57
+ var _numberOf = intrinsic.Number;
58
+ var _bigIntOf = intrinsic.BigInt;
59
+ var _Date = intrinsic.Date;
60
+ var _dateParse = intrinsic.dateParse;
61
+ var _isNaN = intrinsic.numberIsNaN;
62
+ /** @internal Whether an object OWNS a name. The oneof rules are written on this question, so a
63
+ * replacement answering no for one arm hides it and a bundle setting two is read as setting one. */
64
+ var _hasOwn = intrinsic.hasOwn;
65
+ var _isFiniteNumber = intrinsic.numberIsFinite;
66
+ var _isSafeInt = intrinsic.isSafeInteger;
67
+ var _isBuffer = intrinsic.isBuffer;
68
+ var _bufferFrom = intrinsic.bufferFrom;
69
+ var _bufferConcat = intrinsic.bufferConcat;
70
+ var _bufToString = intrinsic.bufToString;
71
+ var _bufferEquals = intrinsic.bufferEquals;
72
+ var _subarray = intrinsic.subarray;
73
+ var _bufIndexOf = intrinsic.uncurry(Buffer.prototype.indexOf);
74
+ /** @internal The canonical form a Rekor signed entry timestamp is verified over. A replacement
75
+ * writing different bytes decides what that signature is checked against. */
76
+ var _jsonStringify = intrinsic.stringify;
77
+ /** @internal Every field the copy holds is DEFINED as its own, never assigned. An assignment consults
78
+ * the target's prototype for a setter, and something that installs one sees each field the copy
79
+ * writes and can hand back a different one, so a malformed value arrives valid and the checks read
80
+ * what the caller never sent. Defining reaches no prototype. */
81
+ var _defineProp = intrinsic.defineProperty;
82
+ var _isFiniteNum = intrinsic.isFinite;
83
+ /** @internal Uncurried, so the copy reads a character's code through the operation taken at load
84
+ * rather than through whatever the string it is walking offers under that name. What a character
85
+ * costs decides whether a bundle passes the size limit. */
86
+ var _charCodeAt = intrinsic.uncurry(String.prototype.charCodeAt);
87
+ var _charAt = intrinsic.uncurry(String.prototype.charAt);
88
+ var _strSlice = intrinsic.uncurry(String.prototype.slice);
89
+ var _strIndexOf = intrinsic.stringIndexOf;
90
+ var _split = intrinsic.uncurry(String.prototype.split);
91
+ var _join = intrinsic.join;
92
+ var _map = intrinsic.map;
93
+ var _forEach = intrinsic.forEach;
94
+ var _filter = intrinsic.filter;
95
+ var _arraySlice = intrinsic.arraySlice;
96
+ var _fromCharCode = intrinsic.fromCharCode;
97
+
44
98
  var C = constants;
45
99
  var SigstoreError = frameworkError.SigstoreError;
46
100
  function _err(code, message, cause) { return new SigstoreError(code, message, cause); }
@@ -62,7 +116,7 @@ function _armPresent(obj, name) {
62
116
  * records. A member this table does not carry is refused rather than mapped by guessing at its name,
63
117
  * so a member added to the enum later cannot be read as one of these.
64
118
  * HASH_ALGORITHM_UNSPECIFIED is absent for the reason it exists: it names no algorithm. */
65
- var _HASH_BY_ENUM = Object.freeze(Object.assign(Object.create(null), {
119
+ var _HASH_BY_ENUM = _freeze(_assign(_create(null), {
66
120
  SHA2_256: { node: "sha256", bytes: 32 },
67
121
  SHA2_384: { node: "sha384", bytes: 48 },
68
122
  SHA2_512: { node: "sha512", bytes: 64 },
@@ -74,7 +128,7 @@ var _HASH_BY_ENUM = Object.freeze(Object.assign(Object.create(null), {
74
128
  * a parser "accept[s] both enum names and integer values", so a bundle naming its digest algorithm as
75
129
  * 1 is one a conforming producer may write and this reads it as the name it stands for. Zero is
76
130
  * absent for the reason the name it belongs to is: HASH_ALGORITHM_UNSPECIFIED names no algorithm. */
77
- var _HASH_BY_NUMBER = Object.freeze(Object.assign(Object.create(null), {
131
+ var _HASH_BY_NUMBER = _freeze(_assign(_create(null), {
78
132
  1: _HASH_BY_ENUM.SHA2_256,
79
133
  2: _HASH_BY_ENUM.SHA2_384,
80
134
  3: _HASH_BY_ENUM.SHA2_512,
@@ -96,7 +150,7 @@ function _hashOf(algorithm) {
96
150
  /** @internal The same three algorithms keyed the way a hashedrekord names them. The entry is the
97
151
  * authenticated statement of what was signed, so its algorithm is the one the artifact is digested
98
152
  * under; the schema enumerates exactly these three. */
99
- var _HASH_BY_REKOR = Object.freeze(Object.assign(Object.create(null), {
153
+ var _HASH_BY_REKOR = _freeze(_assign(_create(null), {
100
154
  sha256: { node: "sha256", bytes: 32 },
101
155
  sha384: { node: "sha384", bytes: 48 },
102
156
  sha512: { node: "sha512", bytes: 64 },
@@ -109,64 +163,35 @@ var JSON_MAX = C.LIMITS.JSON_MAX_BYTES;
109
163
  * applied alone would admit it one way and refuse it the other. */
110
164
  var BUNDLE_MAX_DEPTH = 64;
111
165
 
112
- /** @internal The operations the bundle copy decides with, taken at load. That copy is what every
113
- * later check runs on, so which function answers "what does this object own" and "what does it hold"
114
- * settles what is verified; one replaced after this module loads would otherwise be asked at the
115
- * moment of the call. An emptied key list alone turns a bundle into one carrying no content arm. */
116
- var _ownNames = Object.getOwnPropertyNames;
117
- var _ownDescriptor = Object.getOwnPropertyDescriptor;
118
- var _isArray = Array.isArray;
119
- var _create = Object.create;
120
- var _stringOf = String;
121
- /** @internal Whether an object OWNS a name. The oneof rules are written on this question, so a
122
- * replacement answering no for one arm hides it and a bundle setting two is read as setting one. */
123
- var _hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty);
124
- var _isFiniteNumber = Number.isFinite;
125
- var _isSafeInt = Number.isSafeInteger;
126
- var _isBuffer = Buffer.isBuffer;
127
- var _bufferFrom = Buffer.from;
128
- /** @internal The canonical form a Rekor signed entry timestamp is verified over. A replacement
129
- * writing different bytes decides what that signature is checked against. */
130
- var _jsonStringify = JSON.stringify;
131
- /** @internal Every field the copy holds is DEFINED as its own, never assigned. An assignment consults
132
- * the target's prototype for a setter, and something that installs one sees each field the copy
133
- * writes and can hand back a different one, so a malformed value arrives valid and the checks read
134
- * what the caller never sent. Defining reaches no prototype. */
135
- var _defineProp = Object.defineProperty;
136
- var _isFiniteNum = isFinite;
137
- /** @internal Uncurried, so the copy reads a character's code through the operation taken at load
138
- * rather than through whatever the string it is walking offers under that name. What a character
139
- * costs decides whether a bundle passes the size limit. */
140
- var _charCodeAt = Function.prototype.call.bind(String.prototype.charCodeAt);
141
- var SP = Buffer.from(" ", "ascii");
142
- var DSSEV1 = Buffer.from("DSSEv1", "ascii");
143
- var _EM_DASH = String.fromCharCode(0x2014);
166
+ var SP = _bufferFrom(" ", "ascii");
167
+ var DSSEV1 = _bufferFrom("DSSEv1", "ascii");
168
+ var _EM_DASH = _fromCharCode(0x2014);
144
169
 
145
170
  function _parseNoteSig(line) {
146
171
  var prefix = _EM_DASH + " ";
147
- if (line.slice(0, prefix.length) !== prefix) return null;
172
+ if (_strSlice(line, 0, prefix.length) !== prefix) return null;
148
173
  var p = prefix.length, n = line.length;
149
174
  var t1s = p;
150
- while (p < n && !pkix.isJsWhitespace(line.charCodeAt(p))) p += 1;
175
+ while (p < n && !pkix.isJsWhitespace(_charCodeAt(line, p))) p += 1;
151
176
  if (p === t1s) return null;
152
- var keyId = line.slice(t1s, p);
153
- if (line.charAt(p) !== " ") return null;
177
+ var keyId = _strSlice(line, t1s, p);
178
+ if (_charAt(line, p) !== " ") return null;
154
179
  p += 1;
155
180
  var t2s = p;
156
- while (p < n && !pkix.isJsWhitespace(line.charCodeAt(p))) p += 1;
181
+ while (p < n && !pkix.isJsWhitespace(_charCodeAt(line, p))) p += 1;
157
182
  if (p === t2s) return null;
158
- var sig = line.slice(t2s, p);
183
+ var sig = _strSlice(line, t2s, p);
159
184
  if (p !== n) return null;
160
185
  return { keyId: keyId, sig: sig };
161
186
  }
162
187
 
163
188
  function _stripTrailingEquals(s) {
164
189
  var i = s.length;
165
- while (i > 0 && s.charAt(i - 1) === "=") i -= 1;
166
- return s.slice(0, i);
190
+ while (i > 0 && _charAt(s, i - 1) === "=") i -= 1;
191
+ return _strSlice(s, 0, i);
167
192
  }
168
193
 
169
- var _BUNDLE_MEDIA_TYPES = Object.assign(Object.create(null), {
194
+ var _BUNDLE_MEDIA_TYPES = _assign(_create(null), {
170
195
  "application/vnd.dev.sigstore.bundle.v0.1+json": 1,
171
196
  "application/vnd.dev.sigstore.bundle.v0.2+json": 1,
172
197
  "application/vnd.dev.sigstore.bundle.v0.3+json": 1,
@@ -206,22 +231,22 @@ function _jsonParse(input, code, label) {
206
231
  */
207
232
  function pae(payloadType, payloadBytes) {
208
233
  if (typeof payloadType !== "string") throw new TypeError("pae: payloadType must be a string");
209
- var type = Buffer.from(payloadType, "utf8");
234
+ var type = _bufferFrom(payloadType, "utf8");
210
235
  var body = _isBuffer(payloadBytes) ? payloadBytes : _bufferFrom(payloadBytes || []);
211
- return Buffer.concat([
236
+ return _bufferConcat([
212
237
  DSSEV1, SP,
213
- Buffer.from(String(type.length), "ascii"), SP, type, SP,
214
- Buffer.from(String(body.length), "ascii"), SP, body,
238
+ _bufferFrom(_stringOf(type.length), "ascii"), SP, type, SP,
239
+ _bufferFrom(_stringOf(body.length), "ascii"), SP, body,
215
240
  ]);
216
241
  }
217
242
 
218
243
 
219
244
  function _b64(s, label) {
220
245
  if (typeof s !== "string") throw _err("sigstore/bad-bundle", label + " must be a base64 string");
221
- var urlSafe = s.indexOf("-") !== -1 || s.indexOf("_") !== -1;
246
+ var urlSafe = _strIndexOf(s, "-") !== -1 || _strIndexOf(s, "_") !== -1;
222
247
  var enc = urlSafe ? "base64url" : "base64";
223
- var buf = Buffer.from(s, enc);
224
- if (_stripTrailingEquals(buf.toString(enc)) !== _stripTrailingEquals(s)) {
248
+ var buf = _bufferFrom(s, enc);
249
+ if (_stripTrailingEquals(_bufToString(buf, enc)) !== _stripTrailingEquals(s)) {
225
250
  throw _err("sigstore/bad-bundle", label + " is not canonical base64");
226
251
  }
227
252
  return buf;
@@ -358,7 +383,7 @@ function _chargeString(budget, s) {
358
383
  function _numOf(v) {
359
384
  var t = typeof v;
360
385
  if (t === "number") return v;
361
- if (t === "string" || t === "boolean") return Number(v);
386
+ if (t === "string" || t === "boolean") return _numberOf(v);
362
387
  return NaN;
363
388
  }
364
389
 
@@ -583,7 +608,7 @@ function _leafCertDer(vm) {
583
608
  }
584
609
  function _chainDers(vm) {
585
610
  if (vm.x509CertificateChain && _isArray(vm.x509CertificateChain.certificates)) {
586
- return vm.x509CertificateChain.certificates.map(function (c, i) { return _certBytes(c, "x509CertificateChain[" + i + "]"); });
611
+ return _map(vm.x509CertificateChain.certificates, function (c, i) { return _certBytes(c, "x509CertificateChain[" + i + "]"); });
587
612
  }
588
613
  return [_leafCertDer(vm)];
589
614
  }
@@ -619,8 +644,8 @@ function _sha256(buf) { return nodeCrypto.createHash("sha256").update(buf).diges
619
644
  function _toMs(x) {
620
645
  if (x == null) return null;
621
646
  if (typeof x === "number") return _isFiniteNumber(x) ? x : null;
622
- if (guard.time.isDate(x)) { var d = guard.time.instantOf(x); return isNaN(d) ? null : d; }
623
- if (typeof x === "string") { var t = Date.parse(x); return isNaN(t) ? null : t; }
647
+ if (guard.time.isDate(x)) { var d = guard.time.instantOf(x); return _isNaN(d) ? null : d; }
648
+ if (typeof x === "string") { var t = _dateParse(x); return _isNaN(t) ? null : t; }
624
649
  return null;
625
650
  }
626
651
  function _inWindow(timeMs, vf) {
@@ -632,29 +657,29 @@ function _inWindow(timeMs, vf) {
632
657
  function _rekorKey(rekorKeys, keyIdBuf, hint, timeMs) {
633
658
  for (var i = 0; i < rekorKeys.length; i++) {
634
659
  var k = rekorKeys[i];
635
- var match = (keyIdBuf && k.keyId && k.keyId.equals(keyIdBuf)) ||
636
- (hint && k.keyId && k.keyId.length >= 4 && k.keyId.subarray(0, 4).equals(hint));
660
+ var match = (keyIdBuf && k.keyId && _bufferEquals(k.keyId, keyIdBuf)) ||
661
+ (hint && k.keyId && k.keyId.length >= 4 && _bufferEquals(_subarray(k.keyId, 0, 4), hint));
637
662
  if (match && _inWindow(timeMs, k.validFor)) return k;
638
663
  }
639
664
  return null;
640
665
  }
641
666
 
642
667
  function _verifyCheckpoint(envelope, ip, rekorKeys, timeMs) {
643
- var buf = Buffer.from(envelope, "utf8");
644
- var sep = buf.indexOf("\n\n");
668
+ var buf = _bufferFrom(envelope, "utf8");
669
+ var sep = _bufIndexOf(buf, "\n\n");
645
670
  if (sep < 0) throw _err("sigstore/bad-checkpoint", "the checkpoint has no note/signature separator");
646
- var body = buf.subarray(0, sep + 1);
647
- var lines = body.toString("utf8").split("\n");
648
- if (_b64(lines[2], "checkpoint root").toString("hex") !== _b64(ip.rootHash, "inclusionProof.rootHash").toString("hex")) {
671
+ var body = _subarray(buf, 0, sep + 1);
672
+ var lines = _split(_bufToString(body, "utf8"), "\n");
673
+ if (_bufToString(_b64(lines[2], "checkpoint root"), "hex") !== _bufToString(_b64(ip.rootHash, "inclusionProof.rootHash"), "hex")) {
649
674
  throw _err("sigstore/inclusion-proof-mismatch", "the checkpoint root does not match the inclusion-proof root");
650
675
  }
651
- var sigBlock = buf.subarray(sep + 2).toString("utf8").split("\n");
676
+ var sigBlock = _split(_bufToString(_subarray(buf, sep + 2), "utf8"), "\n");
652
677
  for (var i = 0; i < sigBlock.length; i++) {
653
678
  var note = _parseNoteSig(sigBlock[i]);
654
679
  if (!note) continue;
655
680
  var blob = _b64(note.sig, "checkpoint signature");
656
681
  if (blob.length < 5) continue;
657
- var hint = blob.subarray(0, 4), derSig = blob.subarray(4);
682
+ var hint = _subarray(blob, 0, 4), derSig = _subarray(blob, 4);
658
683
  var k = _rekorKey(rekorKeys, null, hint, timeMs);
659
684
  if (!k) continue;
660
685
  if (_rawVerify(_pubFromSpki(k.spki, "Rekor log"), body, derSig)) return true;
@@ -671,11 +696,11 @@ function _verifySet(te, rekorKeys, timeMs, canonBody) {
671
696
  var canonical = _jsonStringify({
672
697
  body: canonBody,
673
698
  integratedTime: _numOf(te.integratedTime),
674
- logID: keyId.toString("hex"),
699
+ logID: _bufToString(keyId, "hex"),
675
700
  logIndex: _numOf(te.logIndex),
676
701
  });
677
702
  var sig = _b64(promise.signedEntryTimestamp, "signedEntryTimestamp");
678
- return _rawVerify(_pubFromSpki(k.spki, "Rekor log"), Buffer.from(canonical, "utf8"), sig);
703
+ return _rawVerify(_pubFromSpki(k.spki, "Rekor log"), _bufferFrom(canonical, "utf8"), sig);
679
704
  }
680
705
 
681
706
  /** @internal The entry rows this build reads, keyed on the entry's OWN kind and apiVersion together.
@@ -684,7 +709,7 @@ function _verifySet(te, rekorKeys, timeMs, canonBody) {
684
709
  * would read one shape's field names out of the other and report a mismatch rather than an
685
710
  * unsupported entry. Each row states which content arm it may accompany, because an entry describing
686
711
  * a DSSE envelope says nothing about a message signature and the two must agree. */
687
- var _ENTRY_ROWS = Object.freeze(Object.assign(Object.create(null), {
712
+ var _ENTRY_ROWS = _freeze(_assign(_create(null), {
688
713
  "dsse@0.0.1": { content: "dsseEnvelope", bind: _bindDsseEntry },
689
714
  "hashedrekord@0.0.1": { content: "messageSignature", bind: _bindHashedRekordEntry },
690
715
  }));
@@ -723,18 +748,18 @@ function _bindDsseEntry(body, envelope, leafDer) {
723
748
  }
724
749
  var envSig = _b64(envelope.signatures[0].sig, "dsseEnvelope.signatures[0].sig");
725
750
  var bodySig = _b64(spec.signatures[0].signature, "Rekor entry signature");
726
- if (!envSig.equals(bodySig)) throw _err("sigstore/entry-mismatch", "the Rekor entry signature does not match the bundle signature");
751
+ if (!_bufferEquals(envSig, bodySig)) throw _err("sigstore/entry-mismatch", "the Rekor entry signature does not match the bundle signature");
727
752
  var payload = _b64(envelope.payload, "dsseEnvelope.payload");
728
753
  if (!spec.payloadHash || typeof spec.payloadHash.value !== "string") throw _err("sigstore/bad-tlog-entry", "the Rekor dsse entry is missing its payloadHash");
729
- if (spec.payloadHash.value !== _sha256(payload).toString("hex")) {
754
+ if (spec.payloadHash.value !== _bufToString(_sha256(payload), "hex")) {
730
755
  throw _err("sigstore/entry-mismatch", "the Rekor entry payloadHash does not match the bundle payload");
731
756
  }
732
757
  var vf = spec.signatures[0].verifier;
733
758
  if (typeof vf !== "string") throw _err("sigstore/bad-tlog-entry", "the Rekor dsse entry is missing its verifier certificate");
734
759
  var vDer;
735
- try { vDer = x509.pemDecode(_b64(vf, "Rekor entry verifier").toString("utf8"), "CERTIFICATE"); }
760
+ try { vDer = x509.pemDecode(_bufToString(_b64(vf, "Rekor entry verifier"), "utf8"), "CERTIFICATE"); }
736
761
  catch (e) { throw _err("sigstore/bad-tlog-entry", "the Rekor entry verifier is not a valid certificate", e); }
737
- if (!vDer.equals(leafDer)) throw _err("sigstore/entry-mismatch", "the Rekor entry verifier certificate does not match the bundle leaf certificate");
762
+ if (!_bufferEquals(vDer, leafDer)) throw _err("sigstore/entry-mismatch", "the Rekor entry verifier certificate does not match the bundle leaf certificate");
738
763
  }
739
764
 
740
765
  /** @internal The entry's verifier, bound to the bundle's leaf. The Rekor field is "the public key
@@ -744,11 +769,11 @@ function _bindDsseEntry(body, envelope, leafDer) {
744
769
  * about it, and the certificate's own identity is settled by the chain leg rather than here. Neither
745
770
  * form is guessed at from the bytes: the armor names which one the entry wrote. */
746
771
  function _bindVerifier(content, leafDer) {
747
- var text = _b64(content, "Rekor entry verifier").toString("utf8");
772
+ var text = _bufToString(_b64(content, "Rekor entry verifier"), "utf8");
748
773
  var vDer;
749
774
  try { vDer = x509.pemDecode(text, "CERTIFICATE"); } catch (_e) { vDer = null; } // allow:swallow-unverified the other armor is tried next and a value carrying neither is refused below
750
775
  if (vDer !== null) {
751
- if (!vDer.equals(leafDer)) {
776
+ if (!_bufferEquals(vDer, leafDer)) {
752
777
  throw _err("sigstore/entry-mismatch", "the Rekor entry verifier certificate does not match the bundle leaf certificate");
753
778
  }
754
779
  return;
@@ -757,7 +782,7 @@ function _bindVerifier(content, leafDer) {
757
782
  try { spki = x509.pemDecode(text, "PUBLIC KEY"); }
758
783
  catch (e) { throw _err("sigstore/bad-tlog-entry", "the Rekor entry verifier is neither a certificate nor a public key", e); }
759
784
  var leafSpki = _parseCert(leafDer, "Fulcio leaf certificate").subjectPublicKeyInfo.bytes;
760
- if (!spki.equals(Buffer.from(leafSpki))) {
785
+ if (!_bufferEquals(spki, _bufferFrom(leafSpki))) {
761
786
  throw _err("sigstore/entry-mismatch", "the Rekor entry verifier public key does not match the bundle leaf certificate's key");
762
787
  }
763
788
  }
@@ -769,7 +794,7 @@ function _bindVerifier(content, leafDer) {
769
794
  * matched through a replaceable protocol. */
770
795
  function _isLowerHex(s) {
771
796
  for (var i = 0; i < s.length; i++) {
772
- var c = s.charCodeAt(i);
797
+ var c = _charCodeAt(s, i);
773
798
  if (!((c >= 0x30 && c <= 0x39) || (c >= 0x61 && c <= 0x66))) return false;
774
799
  }
775
800
  return s.length > 0;
@@ -792,7 +817,7 @@ function _bindHashedRekordEntry(body, ms, leafDer) {
792
817
  }
793
818
  var bodySig = _b64(spec.signature.content, "Rekor entry signature");
794
819
  var armSig = _b64(ms.signature, "messageSignature.signature");
795
- if (!armSig.equals(bodySig)) {
820
+ if (!_bufferEquals(armSig, bodySig)) {
796
821
  throw _err("sigstore/entry-mismatch", "the Rekor entry signature does not match the bundle signature");
797
822
  }
798
823
  var pk = spec.signature.publicKey;
@@ -855,10 +880,10 @@ function _verifyRekorEntry(te, rekorKeys, leafDer, contentType, bind) {
855
880
  var included;
856
881
  try {
857
882
  included = merkle.verifyInclusion({
858
- leafIndex: BigInt(ip.logIndex),
859
- treeSize: BigInt(ip.treeSize),
883
+ leafIndex: _bigIntOf(ip.logIndex),
884
+ treeSize: _bigIntOf(ip.treeSize),
860
885
  leafHash: merkle.leafHash(canonBytes),
861
- proof: ip.hashes.map(function (h, i) { return _b64(h, "inclusionProof.hashes[" + i + "]"); }),
886
+ proof: _map(ip.hashes, function (h, i) { return _b64(h, "inclusionProof.hashes[" + i + "]"); }),
862
887
  rootHash: _b64(ip.rootHash, "inclusionProof.rootHash"),
863
888
  });
864
889
  } catch (e) {
@@ -874,7 +899,7 @@ function _verifyRekorEntry(te, rekorKeys, leafDer, contentType, bind) {
874
899
  var li = _numOf(te.logIndex);
875
900
  return {
876
901
  integratedTime: t, logIndex: _isFiniteNumber(li) ? li : null,
877
- logId: te.logId && te.logId.keyId ? _b64(te.logId.keyId, "logId.keyId").toString("hex") : null,
902
+ logId: te.logId && te.logId.keyId ? _bufToString(_b64(te.logId.keyId, "logId.keyId"), "hex") : null,
878
903
  artifactHash: artifactHash,
879
904
  };
880
905
  }
@@ -883,7 +908,7 @@ function _verifyRekorEntry(te, rekorKeys, leafDer, contentType, bind) {
883
908
  function _dn(cert, which) { return cert[which] && cert[which].dn; }
884
909
 
885
910
  function _normRoots(fulcioRoots) {
886
- return fulcioRoots.map(function (r, i) {
911
+ return _map(fulcioRoots, function (r, i) {
887
912
  var der = _isBuffer(r) ? r : (r && (r.der || r.rawBytes));
888
913
  if (!_isBuffer(der)) throw _err("sigstore/bad-input", "fulcioRoots[" + i + "] must be a DER Buffer or { der, validFor }");
889
914
  return { cert: _parseCert(der, "Fulcio CA root [" + i + "]"), validFor: (r && r.validFor) || null };
@@ -895,7 +920,7 @@ function _pathToAnchor(leaf, anchor, intBySubject) {
895
920
  /** @internal Issuers are collected leaf-first and the path is assembled once, so no element is
896
921
  * ever moved to a new index: an indexed setter has nothing to intercept and cannot replace the
897
922
  * leaf the preceding signature checks authenticated. */
898
- var above = [], cur = leaf, seen = Object.create(null), guardN = 0;
923
+ var above = [], cur = leaf, seen = _create(null), guardN = 0;
899
924
  function assemble() {
900
925
  var path = [];
901
926
  for (var k = above.length - 1; k >= 0; k--) guard.list.append(path, above[k]);
@@ -927,7 +952,7 @@ var OID_SCT_LIST = oid.byName("signedCertificateTimestampList");
927
952
  function _normCtLogs(ctLogs) {
928
953
  if (!_isArray(ctLogs)) throw _err("sigstore/bad-input", "ctLogs must be an array of { keyId, spki, validFor? }");
929
954
  if (ctLogs.length === 0) throw _err("sigstore/bad-input", "ctLogs is empty; omit the option to skip the certificate-transparency check rather than supplying no logs");
930
- return ctLogs.map(function (l, i) {
955
+ return _map(ctLogs, function (l, i) {
931
956
  if (l === null || typeof l !== "object") throw _err("sigstore/bad-input", "ctLogs[" + i + "] must be { keyId, spki, validFor? }");
932
957
  if (!_isBuffer(l.keyId)) throw _err("sigstore/bad-input", "ctLogs[" + i + "].keyId must be the log id as a Buffer");
933
958
  if (!_isBuffer(l.spki)) throw _err("sigstore/bad-input", "ctLogs[" + i + "].spki must be the log's SubjectPublicKeyInfo DER");
@@ -984,24 +1009,24 @@ function _sctVerifies(entry, sct, spki) {
984
1009
 
985
1010
  /** @internal A receipt's own instant, in milliseconds. The parser's `timestampMs` is this same value
986
1011
  * wherever it is representable, and above 2^53 there is no reachable instant either way. */
987
- function _sctMs(sct) { return Number(sct.timestamp || 0); }
1012
+ function _sctMs(sct) { return _numberOf(sct.timestamp || 0); }
988
1013
 
989
1014
  function _ctLogFor(logs, logIdBytes, timeMs) {
990
- var want = _isBuffer(logIdBytes) ? logIdBytes : Buffer.from(logIdBytes || []);
1015
+ var want = _isBuffer(logIdBytes) ? logIdBytes : _bufferFrom(logIdBytes || []);
991
1016
  for (var i = 0; i < logs.length; i++) {
992
- if (logs[i].keyId.equals(want) && _inWindow(timeMs, logs[i].validFor)) return logs[i];
1017
+ if (_bufferEquals(logs[i].keyId, want) && _inWindow(timeMs, logs[i].validFor)) return logs[i];
993
1018
  }
994
1019
  return null;
995
1020
  }
996
1021
 
997
1022
  async function _verifyChain(leaf, chainDers, fulcioRoots, timeMs) {
998
1023
  var roots = _normRoots(fulcioRoots);
999
- var bundleLinks = chainDers.slice(1).map(function (d, i) { return _parseCert(d, "bundle intermediate [" + i + "]"); });
1000
- var intBySubject = Object.create(null);
1024
+ var bundleLinks = _map(_arraySlice(chainDers, 1), function (d, i) { return _parseCert(d, "bundle intermediate [" + i + "]"); });
1025
+ var intBySubject = _create(null);
1001
1026
  function addInt(c) { guard.list.append(intBySubject[_dn(c, "subject")] = intBySubject[_dn(c, "subject")] || [], c); }
1002
- roots.forEach(function (r) { addInt(r.cert); });
1003
- bundleLinks.forEach(addInt);
1004
- var candidates = roots.filter(function (r) { return _inWindow(timeMs, r.validFor); });
1027
+ _forEach(roots, function (r) { addInt(r.cert); });
1028
+ _forEach(bundleLinks, addInt);
1029
+ var candidates = _filter(roots, function (r) { return _inWindow(timeMs, r.validFor); });
1005
1030
  var lastErr = _err("sigstore/chain-incomplete", "no caller-supplied Fulcio anchor (within its validity window) issues the chain");
1006
1031
  for (var i = 0; i < candidates.length; i++) {
1007
1032
  var anchor = candidates[i].cert;
@@ -1010,7 +1035,7 @@ async function _verifyChain(leaf, chainDers, fulcioRoots, timeMs) {
1010
1035
  var spki = anchor.subjectPublicKeyInfo;
1011
1036
  try {
1012
1037
  var res = await pathValidate.validate(path, {
1013
- time: new Date(timeMs),
1038
+ time: new _Date(timeMs),
1014
1039
  historicalMode: true,
1015
1040
  trustAnchors: { name: anchor.subject, publicKey: spki.bytes, algorithm: spki.algorithm.oid, parameters: spki.algorithm.parameters },
1016
1041
  requiredEku: ["codeSigning"],
@@ -1030,14 +1055,14 @@ async function _verifyChain(leaf, chainDers, fulcioRoots, timeMs) {
1030
1055
 
1031
1056
 
1032
1057
  var SAN_OID = oid.byName("subjectAltName");
1033
- var FULCIO_PREFIX = oid.byName("otherName").split(".").slice(0, -1).join(".") + ".";
1058
+ var FULCIO_PREFIX = _join(_arraySlice(_split(oid.byName("otherName"), "."), 0, -1), ".") + ".";
1034
1059
  function _identity(leaf) {
1035
- var out = { san: null, extensions: Object.create(null) };
1060
+ var out = { san: null, extensions: _create(null) };
1036
1061
  try {
1037
- (leaf.extensions || []).forEach(function (ext) {
1062
+ _forEach(leaf.extensions || [], function (ext) {
1038
1063
  if (ext.oid === SAN_OID) { out.san = _sanValue(ext); return; }
1039
- if (ext.oid.indexOf(FULCIO_PREFIX) === 0) {
1040
- out.extensions[ext.name || ext.oid] = _fulcioExtValue(ext, Number(ext.oid.slice(FULCIO_PREFIX.length)));
1064
+ if (_strIndexOf(ext.oid, FULCIO_PREFIX) === 0) {
1065
+ out.extensions[ext.name || ext.oid] = _fulcioExtValue(ext, _numberOf(_strSlice(ext.oid, FULCIO_PREFIX.length)));
1041
1066
  }
1042
1067
  });
1043
1068
  } catch (e) {
@@ -1046,7 +1071,7 @@ function _identity(leaf) {
1046
1071
  }
1047
1072
  return out;
1048
1073
  }
1049
- var GN_TYPE = Object.assign(Object.create(null), { 1: "rfc822Name", 2: "dNSName", 6: "uri" });
1074
+ var GN_TYPE = _assign(_create(null), { 1: "rfc822Name", 2: "dNSName", 6: "uri" });
1050
1075
  function _sanValue(ext) {
1051
1076
  var seq = asn1.decode(ext.value);
1052
1077
  var names = [];
@@ -1055,7 +1080,7 @@ function _sanValue(ext) {
1055
1080
  if (n.tagClass !== "context") continue;
1056
1081
  var val = null;
1057
1082
  if (!n.constructed && GN_TYPE[n.tagNumber]) {
1058
- val = { type: GN_TYPE[n.tagNumber], value: asn1.read.octetStringImplicit(n, n.tagNumber).toString("utf8") };
1083
+ val = { type: GN_TYPE[n.tagNumber], value: _bufToString(asn1.read.octetStringImplicit(n, n.tagNumber), "utf8") };
1059
1084
  } else if (n.constructed && n.tagNumber === 0 && (n.children || []).length >= 2) {
1060
1085
  var inner = (n.children[1].children || [])[0] || n.children[1];
1061
1086
  var v;
@@ -1073,13 +1098,13 @@ function _sanValue(ext) {
1073
1098
  }
1074
1099
  function _fulcioExtValue(ext, leafArc) {
1075
1100
  if (!_isBuffer(ext.value)) throw _err("sigstore/bad-certificate", "Fulcio extension " + ext.oid + " has no value");
1076
- if (leafArc >= 1 && leafArc <= 6) return ext.value.toString("utf8");
1101
+ if (leafArc >= 1 && leafArc <= 6) return _bufToString(ext.value, "utf8");
1077
1102
  return asn1.read.string(asn1.decode(ext.value));
1078
1103
  }
1079
1104
 
1080
1105
  var IDENTITY_FIELDS = ["san", "issuer", "sourceRepositoryURI"];
1081
- var IDENTITY_KEYS = Object.assign(Object.create(null), { san: 1, issuer: 1, sourceRepositoryURI: 1 });
1082
- var _VERIFY_BUNDLE_OPTS = Object.assign(Object.create(null), { fulcioRoots: 1, rekorKeys: 1, ctLogs: 1, identity: 1, predicateType: 1, time: 1, artifact: 1 });
1106
+ var IDENTITY_KEYS = _assign(_create(null), { san: 1, issuer: 1, sourceRepositoryURI: 1 });
1107
+ var _VERIFY_BUNDLE_OPTS = _assign(_create(null), { fulcioRoots: 1, rekorKeys: 1, ctLogs: 1, identity: 1, predicateType: 1, time: 1, artifact: 1 });
1083
1108
 
1084
1109
  /** @internal The bytes a message signature covers, taken once. There is no shape here in which a
1085
1110
  * caller hands over a precomputed digest: the arm's own field comment forbids using one as a
@@ -1101,21 +1126,21 @@ function _checkIdentity(id, policy) {
1101
1126
  var ran = { san: false, issuer: false, sourceRepositoryURI: false };
1102
1127
  if (policy === undefined || policy === null) return ran;
1103
1128
  if (typeof policy !== "object" || _isArray(policy)) {
1104
- throw _err("sigstore/bad-input", "opts.identity must be an object naming the identity fields to pin (" + IDENTITY_FIELDS.join(", ") + ")");
1129
+ throw _err("sigstore/bad-input", "opts.identity must be an object naming the identity fields to pin (" + _join(IDENTITY_FIELDS, ", ") + ")");
1105
1130
  }
1106
1131
  guard.identifier.assertKnownKeys(policy, IDENTITY_KEYS, _err, "sigstore/bad-input", "opts.identity has an unknown key ");
1107
- var asked = IDENTITY_FIELDS.filter(function (f) { return policy[f] !== undefined; });
1132
+ var asked = _filter(IDENTITY_FIELDS, function (f) { return policy[f] !== undefined; });
1108
1133
  if (!asked.length) {
1109
- throw _err("sigstore/bad-input", "opts.identity constrains nothing -- name at least one of " + IDENTITY_FIELDS.join(", ") + ", or omit it to state that the signer is not being checked");
1134
+ throw _err("sigstore/bad-input", "opts.identity constrains nothing -- name at least one of " + _join(IDENTITY_FIELDS, ", ") + ", or omit it to state that the signer is not being checked");
1110
1135
  }
1111
- asked.forEach(function (f) {
1136
+ _forEach(asked, function (f) {
1112
1137
  if (typeof policy[f] !== "string" || policy[f] === "") {
1113
1138
  throw _err("sigstore/bad-input", "opts.identity." + f + " must be a non-empty string -- a value that cannot be compared would leave the signer unchecked under a policy that names it");
1114
1139
  }
1115
1140
  ran[f] = true;
1116
1141
  });
1117
1142
  var sanValue = id.san && id.san.value;
1118
- if (policy.san && sanValue !== policy.san) throw _err("sigstore/identity-mismatch", "the certificate SAN " + JSON.stringify(sanValue) + " does not match the expected identity");
1143
+ if (policy.san && sanValue !== policy.san) throw _err("sigstore/identity-mismatch", "the certificate SAN " + _jsonStringify(sanValue) + " does not match the expected identity");
1119
1144
  if (policy.issuer && policy.issuer !== id.extensions.issuer && policy.issuer !== id.extensions.issuerLegacy) throw _err("sigstore/identity-mismatch", "the certificate OIDC issuer does not match the expected issuer");
1120
1145
  if (policy.sourceRepositoryURI && id.extensions.sourceRepositoryURI !== policy.sourceRepositoryURI) throw _err("sigstore/identity-mismatch", "the certificate source-repository URI does not match");
1121
1146
  return ran;
@@ -1130,7 +1155,7 @@ function _statement(payload, payloadType, expectedPredicate) {
1130
1155
  if (!st || typeof st !== "object" || st._type !== "https://in-toto.io/Statement/v1") throw _err("sigstore/bad-statement", "the payload is not an in-toto Statement v1");
1131
1156
  if (!_isArray(st.subject) || !st.subject.length) throw _err("sigstore/bad-statement", "the in-toto statement has no subject");
1132
1157
  if (expectedPredicate && st.predicateType !== expectedPredicate) {
1133
- throw _err("sigstore/predicate-mismatch", "the statement predicateType " + JSON.stringify(st.predicateType) + " does not match the expected " + JSON.stringify(expectedPredicate));
1158
+ throw _err("sigstore/predicate-mismatch", "the statement predicateType " + _jsonStringify(st.predicateType) + " does not match the expected " + _jsonStringify(expectedPredicate));
1134
1159
  }
1135
1160
  return st;
1136
1161
  }
@@ -1305,9 +1330,9 @@ async function verifyBundle(bundle, opts) {
1305
1330
  var candidateDigest = null;
1306
1331
  if (isMsg) {
1307
1332
  candidateDigest = nodeCrypto.createHash(candidate.artifactHash.node).update(artifact).digest();
1308
- if (!guard.crypto.constantTimeEqual(candidateDigest, Buffer.from(candidate.artifactHash.value, "hex"))) {
1333
+ if (!guard.crypto.constantTimeEqual(candidateDigest, _bufferFrom(candidate.artifactHash.value, "hex"))) {
1309
1334
  throw _err("sigstore/artifact-mismatch", "the artifact does not match the one the transparency-log entry records; its " +
1310
- candidate.artifactHash.algorithm + " digest is " + candidateDigest.toString("hex") + " and the entry names " + candidate.artifactHash.value);
1335
+ candidate.artifactHash.algorithm + " digest is " + _bufToString(candidateDigest, "hex") + " and the entry names " + candidate.artifactHash.value);
1311
1336
  }
1312
1337
  }
1313
1338
  var candidateTime = haveCallerTime ? callerTime : C.TIME.seconds(candidate.integratedTime);
@@ -1337,7 +1362,7 @@ async function verifyBundle(bundle, opts) {
1337
1362
  if (isMsg) {
1338
1363
  digestAlgorithm = rekor.artifactHash.algorithm;
1339
1364
  var computed = artifactComputed;
1340
- artifactDigest = computed.toString("hex");
1365
+ artifactDigest = _bufToString(computed, "hex");
1341
1366
  if (msParsed.digest !== null) {
1342
1367
  var againstClaim = msParsed.digestAlg.node === rekor.artifactHash.node ? computed
1343
1368
  : nodeCrypto.createHash(msParsed.digestAlg.node).update(artifact).digest();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blamejs/pki",
3
- "version": "0.7.29",
3
+ "version": "0.7.30",
4
4
  "description": "Pure-JavaScript PKI toolkit that owns its stack — X.509, ASN.1/DER, CMS, PQC-first.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "blamejs contributors",
package/sbom.cdx.json CHANGED
@@ -2,10 +2,10 @@
2
2
  "$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
3
3
  "bomFormat": "CycloneDX",
4
4
  "specVersion": "1.5",
5
- "serialNumber": "urn:uuid:3c9a8588-ff6f-477c-92fd-33c03ea2c98b",
5
+ "serialNumber": "urn:uuid:cccf2ff7-2673-4c48-b9bc-d452383b439d",
6
6
  "version": 1,
7
7
  "metadata": {
8
- "timestamp": "2026-09-12T05:32:15.338Z",
8
+ "timestamp": "2026-09-12T06:10:23.138Z",
9
9
  "lifecycles": [
10
10
  {
11
11
  "phase": "build"
@@ -19,14 +19,14 @@
19
19
  }
20
20
  ],
21
21
  "component": {
22
- "bom-ref": "@blamejs/pki@0.7.29",
22
+ "bom-ref": "@blamejs/pki@0.7.30",
23
23
  "type": "application",
24
24
  "name": "pki",
25
- "version": "0.7.29",
25
+ "version": "0.7.30",
26
26
  "scope": "required",
27
27
  "author": "blamejs contributors",
28
28
  "description": "Pure-JavaScript PKI toolkit that owns its stack — X.509, ASN.1/DER, CMS, PQC-first.",
29
- "purl": "pkg:npm/%40blamejs/pki@0.7.29",
29
+ "purl": "pkg:npm/%40blamejs/pki@0.7.30",
30
30
  "properties": [],
31
31
  "externalReferences": [
32
32
  {
@@ -54,7 +54,7 @@
54
54
  "components": [],
55
55
  "dependencies": [
56
56
  {
57
- "ref": "@blamejs/pki@0.7.29",
57
+ "ref": "@blamejs/pki@0.7.30",
58
58
  "dependsOn": []
59
59
  }
60
60
  ]