@event4u/agent-config 17.3.0 → 17.4.0

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.
Files changed (137) hide show
  1. package/.augment-plugin/marketplace.json +3 -3
  2. package/.augment-plugin/plugin.json +1 -1
  3. package/.claude-plugin/marketplace.json +1 -1
  4. package/CHANGELOG.md +164 -342
  5. package/CREDITS.md +2 -2
  6. package/README.md +1 -1
  7. package/dist/agent-src/skills/code-intelligence/SKILL.md +3 -0
  8. package/dist/agent-src/templates/agents/agent-project-settings.example.yml +1 -1
  9. package/dist/cli/registry.js +2 -2
  10. package/dist/cli-delegate/{chunk-DHSSP7V3.js → chunk-5AYJGUA3.js} +0 -2
  11. package/dist/cli-delegate/chunk-DIFZBP4G.js +1336 -0
  12. package/dist/cli-delegate/{chunk-MT2WOOCY.js → chunk-WY5ZZPGL.js} +2 -2
  13. package/dist/cli-delegate/{chunk-ORJPBER2.js → chunk-X6LZ7W5A.js} +73 -10
  14. package/dist/cli-delegate/cmd_conformance.js +175 -183
  15. package/dist/cli-delegate/cmd_doctor.js +5 -5
  16. package/dist/cli-delegate/cmd_doctor_neighbours.js +3 -3
  17. package/dist/cli-delegate/cmd_explain.js +1 -1
  18. package/dist/cli-delegate/cmd_handoff.js +2 -2
  19. package/dist/cli-delegate/cmd_memory_get.js +1 -1
  20. package/dist/cli-delegate/cmd_route_audit.js +1 -1
  21. package/dist/cli-delegate/cmd_session_recycle.js +2 -2
  22. package/dist/cli-delegate/cmd_update.js +24 -13
  23. package/dist/cli-delegate/cmd_upgrade.js +2 -2
  24. package/dist/cli-delegate/dist-25AZAHOP.js +3240 -0
  25. package/dist/cli-delegate/dist-P7MFPMF3.js +411 -0
  26. package/dist/cli-delegate/dist-XAS5ZLQB.js +6 -0
  27. package/dist/cli-delegate/{upgrade_unattended-VVL6JLSX.js → upgrade_unattended-QCWOKTUN.js} +178 -163
  28. package/dist/discovery/deprecation-report.md +1 -1
  29. package/dist/discovery/discovery-manifest.json +3 -3
  30. package/dist/discovery/discovery-manifest.json.sha256 +1 -1
  31. package/dist/discovery/discovery-manifest.summary.md +1 -1
  32. package/dist/discovery/dormancy-report.md +1 -1
  33. package/dist/discovery/orphan-report.md +1 -1
  34. package/dist/discovery/packs.json +2 -2
  35. package/dist/discovery/trust-report.md +1 -1
  36. package/dist/discovery/workspaces.json +2 -2
  37. package/dist/hooks/code_graph_refresh.chunk.cjs +56 -27
  38. package/dist/hooks/code_graph_refresh.chunk.cjs.sha256 +1 -1
  39. package/dist/hooks/dispatch.js +982 -929
  40. package/dist/hooks/dispatch.sha256 +1 -1
  41. package/dist/hooks/egress_engine.chunk.cjs +56 -6
  42. package/dist/hooks/egress_engine.chunk.cjs.sha256 +1 -1
  43. package/dist/hooks/update_notice.chunk.cjs +914 -0
  44. package/dist/hooks/update_notice.chunk.cjs.sha256 +1 -0
  45. package/dist/mcp/registry-manifest.json +1 -1
  46. package/dist/mcp/server.json +2 -2
  47. package/dist/mcp/server.mjs +71259 -66437
  48. package/dist/scripts/condense.js +9 -6
  49. package/package.json +4 -1
  50. package/src/config/evaluator-budgets.json +9 -8
  51. package/src/config/gate-violation-baselines.json +2 -2
  52. package/src/config/hook-bundle-budget.json +31 -6
  53. package/src/config/packed-binary-manifest.json +9 -0
  54. package/src/config/sigstore/npm_keys.json +50 -0
  55. package/src/config/sigstore/trust-material.json +9 -0
  56. package/src/config/sigstore/trusted_root.json +126 -0
  57. package/src/config/skill-body-budget.json +7 -1
  58. package/src/scripts/_cli/cmd_update.ts +48 -20
  59. package/src/scripts/_cli/cmd_upgrade.ts +7 -1
  60. package/src/scripts/_cli/upgrade_unattended.ts +90 -76
  61. package/src/scripts/_dispatch.bash +3 -2
  62. package/src/scripts/_lib/confusables.ts +0 -19
  63. package/src/scripts/_lib/egress_normalize.ts +53 -23
  64. package/src/scripts/_lib/egress_text.ts +5 -3
  65. package/src/scripts/_lib/egress_token.ts +7 -5
  66. package/src/scripts/_lib/gate_collector_experimental.ts +633 -0
  67. package/src/scripts/_lib/git_common_dir.ts +10 -0
  68. package/src/scripts/_lib/graph_feeder_record.ts +3 -2
  69. package/src/scripts/_lib/install_reach_checks.ts +32 -2
  70. package/src/scripts/_lib/lineage_backfill.ts +136 -0
  71. package/src/scripts/_lib/lineage_ledger.ts +211 -0
  72. package/src/scripts/_lib/lineage_map.ts +55 -0
  73. package/src/scripts/_lib/lineage_query.ts +140 -0
  74. package/src/scripts/_lib/lineage_seed.ts +116 -0
  75. package/src/scripts/_lib/lineage_watch.ts +249 -0
  76. package/src/scripts/_lib/link_crypto.ts +8 -4
  77. package/src/scripts/_lib/production_reach.ts +3 -3
  78. package/src/scripts/_lib/project_registry.ts +227 -0
  79. package/src/scripts/_lib/provenance_verify.ts +14 -242
  80. package/src/scripts/_lib/sigstore_provenance.ts +177 -0
  81. package/src/scripts/_lib/source_id.ts +48 -0
  82. package/src/scripts/_lib/source_shape.ts +4 -0
  83. package/src/scripts/_lib/unattended_gates.ts +6 -1
  84. package/src/scripts/advisories.ts +26 -10
  85. package/src/scripts/ai_council/council_egress.ts +5 -6
  86. package/src/scripts/bench_graph_feeder_latency.ts +10 -3
  87. package/src/scripts/check_dependency_floors.ts +7 -0
  88. package/src/scripts/check_egress_mutations.ts +1 -0
  89. package/src/scripts/code_graph/build.ts +67 -3
  90. package/src/scripts/code_graph/cli.ts +131 -28
  91. package/src/scripts/code_graph/conventions_default.ts +20 -1
  92. package/src/scripts/code_graph/detect.ts +5 -5
  93. package/src/scripts/code_graph/estate_cli.ts +135 -0
  94. package/src/scripts/code_graph/estate_index.ts +394 -0
  95. package/src/scripts/code_graph/estate_manifests.ts +223 -0
  96. package/src/scripts/code_graph/estate_map.ts +141 -0
  97. package/src/scripts/code_graph/extract.ts +4 -1
  98. package/src/scripts/code_graph/extract_more.ts +137 -2
  99. package/src/scripts/code_graph/graph_budget.ts +158 -0
  100. package/src/scripts/code_graph/graph_home.ts +80 -0
  101. package/src/scripts/code_graph/lineage_cli.ts +315 -0
  102. package/src/scripts/code_graph/map.ts +22 -13
  103. package/src/scripts/code_graph/map_model.ts +67 -12
  104. package/src/scripts/code_graph/map_verify.ts +68 -5
  105. package/src/scripts/code_graph/map_viewer/viewer.css +12 -0
  106. package/src/scripts/code_graph/map_viewer/viewer.js +45 -15
  107. package/src/scripts/code_graph/project_ref.ts +25 -0
  108. package/src/scripts/code_graph/projects_cli.ts +254 -0
  109. package/src/scripts/code_graph/providers/catalog.ts +14 -5
  110. package/src/scripts/code_graph/providers/django.ts +52 -9
  111. package/src/scripts/code_graph/providers/index.ts +2 -0
  112. package/src/scripts/code_graph/providers/rails.ts +204 -0
  113. package/src/scripts/code_graph/providers/spring.ts +38 -1
  114. package/src/scripts/code_graph/query.ts +9 -9
  115. package/src/scripts/code_graph/refresh_lock.ts +12 -8
  116. package/src/scripts/code_graph/repo_identity.ts +169 -0
  117. package/src/scripts/code_graph/sqlite_store.ts +22 -25
  118. package/src/scripts/code_graph/types.ts +6 -2
  119. package/src/scripts/condense.ts +6 -6
  120. package/src/scripts/hook_chunks.mjs +7 -0
  121. package/src/scripts/hook_manifest.json +1 -1
  122. package/src/scripts/hook_manifest.yaml +20 -17
  123. package/src/scripts/hooks/code_graph_refresh_hook.ts +10 -7
  124. package/src/scripts/hooks/dispatch_hook.ts +6 -7
  125. package/src/scripts/hooks/host_semantics.ts +72 -0
  126. package/src/scripts/hooks/lazy_concern.ts +4 -0
  127. package/src/scripts/hooks/user_notice.ts +105 -0
  128. package/src/scripts/lint_harvest_provenance.ts +137 -11
  129. package/src/scripts/mcp_server/consumer_tool_catalog.json +69 -15
  130. package/src/scripts/mcp_server/graph_tools.ts +161 -41
  131. package/src/scripts/network_sources.ts +24 -6
  132. package/src/scripts/schemas/provenance-mechanism.schema.json +46 -0
  133. package/src/scripts/update_notice_hook.ts +75 -7
  134. package/src/vendor/grammars/README.md +7 -6
  135. package/src/vendor/grammars/tree-sitter-ruby.wasm +0 -0
  136. /package/dist/cli-delegate/{chunk-FKYZOWVD.js → chunk-QBAFP67O.js} +0 -0
  137. /package/dist/cli-delegate/{chunk-BMGUGSY6.js → chunk-TQG6UMPC.js} +0 -0
@@ -0,0 +1,3240 @@
1
+ import { createRequire as __acCreateRequire } from 'node:module'; const require = globalThis.require ?? __acCreateRequire(import.meta.url);
2
+ import {
3
+ require_dist,
4
+ require_envelope,
5
+ require_sigstore_common
6
+ } from "./chunk-DIFZBP4G.js";
7
+ import {
8
+ __commonJS,
9
+ __require
10
+ } from "./chunk-J55WI3RR.js";
11
+
12
+ // node_modules/@sigstore/core/dist/stream.js
13
+ var require_stream = __commonJS({
14
+ "node_modules/@sigstore/core/dist/stream.js"(exports) {
15
+ "use strict";
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.ByteStream = void 0;
18
+ var StreamError = class extends Error {
19
+ };
20
+ var ByteStream = class _ByteStream {
21
+ static BLOCK_SIZE = 1024;
22
+ buf;
23
+ view;
24
+ start = 0;
25
+ constructor(buffer) {
26
+ if (buffer) {
27
+ this.buf = buffer;
28
+ this.view = Buffer.from(buffer);
29
+ } else {
30
+ this.buf = Buffer.alloc(0);
31
+ this.view = Buffer.from(this.buf);
32
+ }
33
+ }
34
+ get buffer() {
35
+ return this.view.subarray(0, this.start);
36
+ }
37
+ get length() {
38
+ return this.view.byteLength;
39
+ }
40
+ get position() {
41
+ return this.start;
42
+ }
43
+ seek(position) {
44
+ this.start = position;
45
+ }
46
+ // Returns a Buffer containing the specified number of bytes starting at the
47
+ // given start position.
48
+ slice(start, len) {
49
+ const end = start + len;
50
+ if (end > this.length) {
51
+ throw new StreamError("request past end of buffer");
52
+ }
53
+ return this.view.subarray(start, end);
54
+ }
55
+ appendChar(char) {
56
+ this.ensureCapacity(1);
57
+ this.view[this.start] = char;
58
+ this.start += 1;
59
+ }
60
+ appendUint16(num) {
61
+ this.ensureCapacity(2);
62
+ const value = new Uint16Array([num]);
63
+ const view = new Uint8Array(value.buffer);
64
+ this.view[this.start] = view[1];
65
+ this.view[this.start + 1] = view[0];
66
+ this.start += 2;
67
+ }
68
+ appendUint24(num) {
69
+ this.ensureCapacity(3);
70
+ const value = new Uint32Array([num]);
71
+ const view = new Uint8Array(value.buffer);
72
+ this.view[this.start] = view[2];
73
+ this.view[this.start + 1] = view[1];
74
+ this.view[this.start + 2] = view[0];
75
+ this.start += 3;
76
+ }
77
+ appendView(view) {
78
+ this.ensureCapacity(view.length);
79
+ this.view.set(view, this.start);
80
+ this.start += view.length;
81
+ }
82
+ getBlock(size) {
83
+ if (size <= 0) {
84
+ return Buffer.alloc(0);
85
+ }
86
+ if (this.start + size > this.view.length) {
87
+ throw new Error("request past end of buffer");
88
+ }
89
+ const result = this.view.subarray(this.start, this.start + size);
90
+ this.start += size;
91
+ return result;
92
+ }
93
+ getUint8() {
94
+ return this.getBlock(1)[0];
95
+ }
96
+ getUint16() {
97
+ const block = this.getBlock(2);
98
+ return block[0] << 8 | block[1];
99
+ }
100
+ ensureCapacity(size) {
101
+ if (this.start + size > this.view.byteLength) {
102
+ const blockSize = _ByteStream.BLOCK_SIZE + (size > _ByteStream.BLOCK_SIZE ? size : 0);
103
+ this.realloc(this.view.byteLength + blockSize);
104
+ }
105
+ }
106
+ realloc(size) {
107
+ const newArray = Buffer.alloc(size);
108
+ const newView = Buffer.from(newArray);
109
+ newView.set(this.view);
110
+ this.buf = newArray;
111
+ this.view = newView;
112
+ }
113
+ };
114
+ exports.ByteStream = ByteStream;
115
+ }
116
+ });
117
+
118
+ // node_modules/@sigstore/core/dist/asn1/error.js
119
+ var require_error = __commonJS({
120
+ "node_modules/@sigstore/core/dist/asn1/error.js"(exports) {
121
+ "use strict";
122
+ Object.defineProperty(exports, "__esModule", { value: true });
123
+ exports.ASN1TypeError = exports.ASN1ParseError = void 0;
124
+ var ASN1ParseError = class extends Error {
125
+ };
126
+ exports.ASN1ParseError = ASN1ParseError;
127
+ var ASN1TypeError = class extends Error {
128
+ };
129
+ exports.ASN1TypeError = ASN1TypeError;
130
+ }
131
+ });
132
+
133
+ // node_modules/@sigstore/core/dist/asn1/length.js
134
+ var require_length = __commonJS({
135
+ "node_modules/@sigstore/core/dist/asn1/length.js"(exports) {
136
+ "use strict";
137
+ Object.defineProperty(exports, "__esModule", { value: true });
138
+ exports.decodeLength = decodeLength;
139
+ exports.encodeLength = encodeLength;
140
+ var error_1 = require_error();
141
+ function decodeLength(stream) {
142
+ const buf = stream.getUint8();
143
+ if ((buf & 128) === 0) {
144
+ return buf;
145
+ }
146
+ const byteCount = buf & 127;
147
+ if (byteCount > 6) {
148
+ throw new error_1.ASN1ParseError("length exceeds 6 byte limit");
149
+ }
150
+ let len = 0;
151
+ for (let i = 0; i < byteCount; i++) {
152
+ const byte = stream.getUint8();
153
+ if (i === 0 && byte === 0) {
154
+ throw new error_1.ASN1ParseError("non-minimal length encoding");
155
+ }
156
+ len = len * 256 + byte;
157
+ }
158
+ if (len === 0) {
159
+ throw new error_1.ASN1ParseError("indefinite length encoding not supported");
160
+ }
161
+ if (len < 128) {
162
+ throw new error_1.ASN1ParseError("non-minimal length encoding");
163
+ }
164
+ return len;
165
+ }
166
+ function encodeLength(len) {
167
+ if (len < 128) {
168
+ return Buffer.from([len]);
169
+ }
170
+ let val = BigInt(len);
171
+ const bytes = [];
172
+ while (val > 0n) {
173
+ bytes.unshift(Number(val & 255n));
174
+ val = val >> 8n;
175
+ }
176
+ return Buffer.from([128 | bytes.length, ...bytes]);
177
+ }
178
+ }
179
+ });
180
+
181
+ // node_modules/@sigstore/core/dist/asn1/parse.js
182
+ var require_parse = __commonJS({
183
+ "node_modules/@sigstore/core/dist/asn1/parse.js"(exports) {
184
+ "use strict";
185
+ Object.defineProperty(exports, "__esModule", { value: true });
186
+ exports.parseInteger = parseInteger;
187
+ exports.parseStringASCII = parseStringASCII;
188
+ exports.parseTime = parseTime;
189
+ exports.parseOID = parseOID;
190
+ exports.parseBoolean = parseBoolean;
191
+ exports.parseBitString = parseBitString;
192
+ var error_1 = require_error();
193
+ var RE_TIME_SHORT_YEAR = /^(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\.\d{3})?Z$/;
194
+ var RE_TIME_LONG_YEAR = /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\.\d{3})?Z$/;
195
+ function parseInteger(buf) {
196
+ let pos = 0;
197
+ const end = buf.length;
198
+ let val = buf[pos];
199
+ const neg = val > 127;
200
+ const pad = neg ? 255 : 0;
201
+ while (val == pad && ++pos < end) {
202
+ val = buf[pos];
203
+ }
204
+ const len = end - pos;
205
+ if (len === 0)
206
+ return BigInt(neg ? -1 : 0);
207
+ val = neg ? val - 256 : val;
208
+ let n = BigInt(val);
209
+ for (let i = pos + 1; i < end; ++i) {
210
+ n = n * BigInt(256) + BigInt(buf[i]);
211
+ }
212
+ return n;
213
+ }
214
+ function parseStringASCII(buf) {
215
+ return buf.toString("ascii");
216
+ }
217
+ function parseTime(buf, shortYear) {
218
+ const timeStr = parseStringASCII(buf);
219
+ const m = shortYear ? RE_TIME_SHORT_YEAR.exec(timeStr) : RE_TIME_LONG_YEAR.exec(timeStr);
220
+ if (!m) {
221
+ throw new Error("invalid time");
222
+ }
223
+ if (shortYear) {
224
+ let year = Number(m[1]);
225
+ year += year >= 50 ? 1900 : 2e3;
226
+ m[1] = year.toString();
227
+ }
228
+ return /* @__PURE__ */ new Date(`${m[1]}-${m[2]}-${m[3]}T${m[4]}:${m[5]}:${m[6]}Z`);
229
+ }
230
+ function parseOID(buf) {
231
+ let pos = 0;
232
+ const end = buf.length;
233
+ let n = buf[pos++];
234
+ const first = Math.floor(n / 40);
235
+ const second = n % 40;
236
+ let oid = `${first}.${second}`;
237
+ let val = 0n;
238
+ for (; pos < end; ++pos) {
239
+ n = buf[pos];
240
+ val = (val << 7n) + BigInt(n & 127);
241
+ if ((n & 128) === 0) {
242
+ oid += `.${val}`;
243
+ val = 0n;
244
+ }
245
+ }
246
+ return oid;
247
+ }
248
+ function parseBoolean(buf) {
249
+ if (buf.length !== 1) {
250
+ throw new error_1.ASN1ParseError("invalid boolean");
251
+ }
252
+ switch (buf[0]) {
253
+ case 0:
254
+ return false;
255
+ case 255:
256
+ return true;
257
+ default:
258
+ throw new error_1.ASN1ParseError("invalid boolean");
259
+ }
260
+ }
261
+ function parseBitString(buf) {
262
+ const unused = buf[0];
263
+ if (unused > 7) {
264
+ throw new error_1.ASN1ParseError("invalid bit string");
265
+ }
266
+ const start = 1;
267
+ const end = buf.length;
268
+ const bits = [];
269
+ for (let i = start; i < end; ++i) {
270
+ const byte = buf[i];
271
+ const skip = i === end - 1 ? unused : 0;
272
+ for (let j = 7; j >= skip; --j) {
273
+ bits.push(byte >> j & 1);
274
+ }
275
+ }
276
+ return bits;
277
+ }
278
+ }
279
+ });
280
+
281
+ // node_modules/@sigstore/core/dist/asn1/tag.js
282
+ var require_tag = __commonJS({
283
+ "node_modules/@sigstore/core/dist/asn1/tag.js"(exports) {
284
+ "use strict";
285
+ Object.defineProperty(exports, "__esModule", { value: true });
286
+ exports.ASN1Tag = void 0;
287
+ var error_1 = require_error();
288
+ var UNIVERSAL_TAG = {
289
+ BOOLEAN: 1,
290
+ INTEGER: 2,
291
+ BIT_STRING: 3,
292
+ OCTET_STRING: 4,
293
+ OBJECT_IDENTIFIER: 6,
294
+ SEQUENCE: 16,
295
+ SET: 17,
296
+ PRINTABLE_STRING: 19,
297
+ UTC_TIME: 23,
298
+ GENERALIZED_TIME: 24
299
+ };
300
+ var TAG_CLASS = {
301
+ UNIVERSAL: 0,
302
+ APPLICATION: 1,
303
+ CONTEXT_SPECIFIC: 2,
304
+ PRIVATE: 3
305
+ };
306
+ var ASN1Tag = class {
307
+ number;
308
+ constructed;
309
+ class;
310
+ constructor(enc) {
311
+ this.number = enc & 31;
312
+ this.constructed = (enc & 32) === 32;
313
+ this.class = enc >> 6;
314
+ if (this.number === 31) {
315
+ throw new error_1.ASN1ParseError("long form tags not supported");
316
+ }
317
+ if (this.class === TAG_CLASS.UNIVERSAL && this.number === 0) {
318
+ throw new error_1.ASN1ParseError("unsupported tag 0x00");
319
+ }
320
+ }
321
+ isUniversal() {
322
+ return this.class === TAG_CLASS.UNIVERSAL;
323
+ }
324
+ isContextSpecific(num) {
325
+ const res = this.class === TAG_CLASS.CONTEXT_SPECIFIC;
326
+ return num !== void 0 ? res && this.number === num : res;
327
+ }
328
+ isBoolean() {
329
+ return this.isUniversal() && this.number === UNIVERSAL_TAG.BOOLEAN;
330
+ }
331
+ isInteger() {
332
+ return this.isUniversal() && this.number === UNIVERSAL_TAG.INTEGER;
333
+ }
334
+ isBitString() {
335
+ return this.isUniversal() && this.number === UNIVERSAL_TAG.BIT_STRING;
336
+ }
337
+ isOctetString() {
338
+ return this.isUniversal() && this.number === UNIVERSAL_TAG.OCTET_STRING;
339
+ }
340
+ isOID() {
341
+ return this.isUniversal() && this.number === UNIVERSAL_TAG.OBJECT_IDENTIFIER;
342
+ }
343
+ isUTCTime() {
344
+ return this.isUniversal() && this.number === UNIVERSAL_TAG.UTC_TIME;
345
+ }
346
+ isGeneralizedTime() {
347
+ return this.isUniversal() && this.number === UNIVERSAL_TAG.GENERALIZED_TIME;
348
+ }
349
+ toDER() {
350
+ return this.number | (this.constructed ? 32 : 0) | this.class << 6;
351
+ }
352
+ };
353
+ exports.ASN1Tag = ASN1Tag;
354
+ }
355
+ });
356
+
357
+ // node_modules/@sigstore/core/dist/asn1/obj.js
358
+ var require_obj = __commonJS({
359
+ "node_modules/@sigstore/core/dist/asn1/obj.js"(exports) {
360
+ "use strict";
361
+ Object.defineProperty(exports, "__esModule", { value: true });
362
+ exports.ASN1Obj = void 0;
363
+ var stream_1 = require_stream();
364
+ var error_1 = require_error();
365
+ var length_1 = require_length();
366
+ var parse_1 = require_parse();
367
+ var tag_1 = require_tag();
368
+ var ASN1Obj = class {
369
+ tag;
370
+ subs;
371
+ value;
372
+ constructor(tag, value, subs) {
373
+ this.tag = tag;
374
+ this.value = value;
375
+ this.subs = subs;
376
+ }
377
+ // Constructs an ASN.1 object from a Buffer of DER-encoded bytes.
378
+ static parseBuffer(buf) {
379
+ const stream = new stream_1.ByteStream(buf);
380
+ const obj = parseStream(stream);
381
+ if (stream.position !== stream.length) {
382
+ throw new error_1.ASN1ParseError("invalid trailing data");
383
+ }
384
+ return obj;
385
+ }
386
+ toDER() {
387
+ const valueStream = new stream_1.ByteStream();
388
+ if (this.subs.length > 0) {
389
+ for (const sub of this.subs) {
390
+ valueStream.appendView(sub.toDER());
391
+ }
392
+ } else {
393
+ valueStream.appendView(this.value);
394
+ }
395
+ const value = valueStream.buffer;
396
+ const obj = new stream_1.ByteStream();
397
+ obj.appendChar(this.tag.toDER());
398
+ obj.appendView((0, length_1.encodeLength)(value.length));
399
+ obj.appendView(value);
400
+ return obj.buffer;
401
+ }
402
+ /////////////////////////////////////////////////////////////////////////////
403
+ // Convenience methods for parsing ASN.1 primitives into JS types
404
+ // Returns the ASN.1 object's value as a boolean. Throws an error if the
405
+ // object is not a boolean.
406
+ toBoolean() {
407
+ if (!this.tag.isBoolean()) {
408
+ throw new error_1.ASN1TypeError("not a boolean");
409
+ }
410
+ return (0, parse_1.parseBoolean)(this.value);
411
+ }
412
+ // Returns the ASN.1 object's value as a BigInt. Throws an error if the
413
+ // object is not an integer.
414
+ toInteger() {
415
+ if (!this.tag.isInteger()) {
416
+ throw new error_1.ASN1TypeError("not an integer");
417
+ }
418
+ return (0, parse_1.parseInteger)(this.value);
419
+ }
420
+ // Returns the ASN.1 object's value as an OID string. Throws an error if the
421
+ // object is not an OID.
422
+ toOID() {
423
+ if (!this.tag.isOID()) {
424
+ throw new error_1.ASN1TypeError("not an OID");
425
+ }
426
+ return (0, parse_1.parseOID)(this.value);
427
+ }
428
+ // Returns the ASN.1 object's value as a Date. Throws an error if the object
429
+ // is not either a UTCTime or a GeneralizedTime.
430
+ toDate() {
431
+ switch (true) {
432
+ case this.tag.isUTCTime():
433
+ return (0, parse_1.parseTime)(this.value, true);
434
+ case this.tag.isGeneralizedTime():
435
+ return (0, parse_1.parseTime)(this.value, false);
436
+ default:
437
+ throw new error_1.ASN1TypeError("not a date");
438
+ }
439
+ }
440
+ // Returns the ASN.1 object's value as a number[] where each number is the
441
+ // value of a bit in the bit string. Throws an error if the object is not a
442
+ // bit string.
443
+ toBitString() {
444
+ if (!this.tag.isBitString()) {
445
+ throw new error_1.ASN1TypeError("not a bit string");
446
+ }
447
+ return (0, parse_1.parseBitString)(this.value);
448
+ }
449
+ };
450
+ exports.ASN1Obj = ASN1Obj;
451
+ var MAX_DEPTH = 100;
452
+ function parseStream(stream, depth = 0) {
453
+ if (depth > MAX_DEPTH) {
454
+ throw new error_1.ASN1ParseError("maximum nesting depth exceeded");
455
+ }
456
+ const tag = new tag_1.ASN1Tag(stream.getUint8());
457
+ const len = (0, length_1.decodeLength)(stream);
458
+ const value = stream.slice(stream.position, len);
459
+ const start = stream.position;
460
+ let subs = [];
461
+ if (tag.constructed) {
462
+ subs = collectSubs(stream, len, depth);
463
+ } else if (tag.isOctetString()) {
464
+ try {
465
+ subs = collectSubs(stream, len, depth);
466
+ } catch (e) {
467
+ }
468
+ }
469
+ if (subs.length === 0) {
470
+ stream.seek(start + len);
471
+ }
472
+ return new ASN1Obj(tag, value, subs);
473
+ }
474
+ function collectSubs(stream, len, depth) {
475
+ const end = stream.position + len;
476
+ if (end > stream.length) {
477
+ throw new error_1.ASN1ParseError("invalid length");
478
+ }
479
+ const subs = [];
480
+ while (stream.position < end) {
481
+ subs.push(parseStream(stream, depth + 1));
482
+ }
483
+ if (stream.position !== end) {
484
+ throw new error_1.ASN1ParseError("invalid length");
485
+ }
486
+ return subs;
487
+ }
488
+ }
489
+ });
490
+
491
+ // node_modules/@sigstore/core/dist/asn1/index.js
492
+ var require_asn1 = __commonJS({
493
+ "node_modules/@sigstore/core/dist/asn1/index.js"(exports) {
494
+ "use strict";
495
+ Object.defineProperty(exports, "__esModule", { value: true });
496
+ exports.ASN1Obj = void 0;
497
+ var obj_1 = require_obj();
498
+ Object.defineProperty(exports, "ASN1Obj", { enumerable: true, get: function() {
499
+ return obj_1.ASN1Obj;
500
+ } });
501
+ }
502
+ });
503
+
504
+ // node_modules/@sigstore/core/dist/crypto.js
505
+ var require_crypto = __commonJS({
506
+ "node_modules/@sigstore/core/dist/crypto.js"(exports) {
507
+ "use strict";
508
+ var __importDefault = exports && exports.__importDefault || function(mod) {
509
+ return mod && mod.__esModule ? mod : { "default": mod };
510
+ };
511
+ Object.defineProperty(exports, "__esModule", { value: true });
512
+ exports.createPublicKey = createPublicKey;
513
+ exports.digest = digest;
514
+ exports.verify = verify;
515
+ exports.bufferEqual = bufferEqual;
516
+ var crypto_1 = __importDefault(__require("crypto"));
517
+ function createPublicKey(key, type = "spki") {
518
+ if (typeof key === "string") {
519
+ if (key.startsWith("-----")) {
520
+ return crypto_1.default.createPublicKey(key);
521
+ } else {
522
+ return crypto_1.default.createPublicKey({
523
+ key: Buffer.from(key, "base64"),
524
+ format: "der",
525
+ type
526
+ });
527
+ }
528
+ } else {
529
+ return crypto_1.default.createPublicKey({ key, format: "der", type });
530
+ }
531
+ }
532
+ function digest(algorithm, ...data) {
533
+ const hash = crypto_1.default.createHash(algorithm);
534
+ for (const d of data) {
535
+ hash.update(d);
536
+ }
537
+ return hash.digest();
538
+ }
539
+ function verify(data, key, signature, algorithm) {
540
+ try {
541
+ return crypto_1.default.verify(algorithm, data, key, signature);
542
+ } catch (e) {
543
+ return false;
544
+ }
545
+ }
546
+ function bufferEqual(a, b) {
547
+ try {
548
+ return crypto_1.default.timingSafeEqual(a, b);
549
+ } catch {
550
+ return false;
551
+ }
552
+ }
553
+ }
554
+ });
555
+
556
+ // node_modules/@sigstore/core/dist/dsse.js
557
+ var require_dsse = __commonJS({
558
+ "node_modules/@sigstore/core/dist/dsse.js"(exports) {
559
+ "use strict";
560
+ Object.defineProperty(exports, "__esModule", { value: true });
561
+ exports.preAuthEncoding = preAuthEncoding;
562
+ var PAE_PREFIX = "DSSEv1";
563
+ function preAuthEncoding(payloadType, payload) {
564
+ const typeBytes = Buffer.from(payloadType, "utf-8");
565
+ return Buffer.concat([
566
+ Buffer.from(`${PAE_PREFIX} ${typeBytes.length} `, "ascii"),
567
+ typeBytes,
568
+ Buffer.from(` ${payload.length} `, "ascii"),
569
+ payload
570
+ ]);
571
+ }
572
+ }
573
+ });
574
+
575
+ // node_modules/@sigstore/core/dist/encoding.js
576
+ var require_encoding = __commonJS({
577
+ "node_modules/@sigstore/core/dist/encoding.js"(exports) {
578
+ "use strict";
579
+ Object.defineProperty(exports, "__esModule", { value: true });
580
+ exports.base64Encode = base64Encode;
581
+ exports.base64Decode = base64Decode;
582
+ var BASE64_ENCODING = "base64";
583
+ var UTF8_ENCODING = "utf-8";
584
+ function base64Encode(str) {
585
+ return Buffer.from(str, UTF8_ENCODING).toString(BASE64_ENCODING);
586
+ }
587
+ function base64Decode(str) {
588
+ return Buffer.from(str, BASE64_ENCODING).toString(UTF8_ENCODING);
589
+ }
590
+ }
591
+ });
592
+
593
+ // node_modules/@sigstore/core/dist/json.js
594
+ var require_json = __commonJS({
595
+ "node_modules/@sigstore/core/dist/json.js"(exports) {
596
+ "use strict";
597
+ Object.defineProperty(exports, "__esModule", { value: true });
598
+ exports.canonicalize = canonicalize;
599
+ function canonicalize(object) {
600
+ let buffer = "";
601
+ if (object === null || typeof object !== "object" || object.toJSON != null) {
602
+ buffer += JSON.stringify(object);
603
+ } else if (Array.isArray(object)) {
604
+ buffer += "[";
605
+ let first = true;
606
+ object.forEach((element) => {
607
+ if (!first) {
608
+ buffer += ",";
609
+ }
610
+ first = false;
611
+ buffer += canonicalize(element);
612
+ });
613
+ buffer += "]";
614
+ } else {
615
+ buffer += "{";
616
+ let first = true;
617
+ Object.keys(object).sort().forEach((property) => {
618
+ if (!first) {
619
+ buffer += ",";
620
+ }
621
+ first = false;
622
+ buffer += JSON.stringify(property);
623
+ buffer += ":";
624
+ buffer += canonicalize(object[property]);
625
+ });
626
+ buffer += "}";
627
+ }
628
+ return buffer;
629
+ }
630
+ }
631
+ });
632
+
633
+ // node_modules/@sigstore/core/dist/pem.js
634
+ var require_pem = __commonJS({
635
+ "node_modules/@sigstore/core/dist/pem.js"(exports) {
636
+ "use strict";
637
+ Object.defineProperty(exports, "__esModule", { value: true });
638
+ exports.toDER = toDER;
639
+ exports.fromDER = fromDER;
640
+ var PEM_HEADER = /-----BEGIN (.*)-----/;
641
+ var PEM_FOOTER = /-----END (.*)-----/;
642
+ function toDER(certificate) {
643
+ let der = "";
644
+ certificate.split("\n").forEach((line) => {
645
+ if (line.match(PEM_HEADER) || line.match(PEM_FOOTER)) {
646
+ return;
647
+ }
648
+ der += line;
649
+ });
650
+ return Buffer.from(der, "base64");
651
+ }
652
+ function fromDER(certificate, type = "CERTIFICATE") {
653
+ const der = certificate.toString("base64");
654
+ const lines = der.match(/.{1,64}/g) || "";
655
+ return [`-----BEGIN ${type}-----`, ...lines, `-----END ${type}-----`].join("\n").concat("\n");
656
+ }
657
+ }
658
+ });
659
+
660
+ // node_modules/@sigstore/core/dist/oid.js
661
+ var require_oid = __commonJS({
662
+ "node_modules/@sigstore/core/dist/oid.js"(exports) {
663
+ "use strict";
664
+ Object.defineProperty(exports, "__esModule", { value: true });
665
+ exports.SHA2_HASH_ALGOS = exports.RSA_SIGNATURE_ALGOS = exports.ECDSA_SIGNATURE_ALGOS = void 0;
666
+ exports.ECDSA_SIGNATURE_ALGOS = {
667
+ "1.2.840.10045.4.3.1": "sha224",
668
+ "1.2.840.10045.4.3.2": "sha256",
669
+ "1.2.840.10045.4.3.3": "sha384",
670
+ "1.2.840.10045.4.3.4": "sha512"
671
+ };
672
+ exports.RSA_SIGNATURE_ALGOS = {
673
+ "1.2.840.113549.1.1.14": "sha224",
674
+ "1.2.840.113549.1.1.11": "sha256",
675
+ "1.2.840.113549.1.1.12": "sha384",
676
+ "1.2.840.113549.1.1.13": "sha512"
677
+ };
678
+ exports.SHA2_HASH_ALGOS = {
679
+ "2.16.840.1.101.3.4.2.1": "sha256",
680
+ "2.16.840.1.101.3.4.2.2": "sha384",
681
+ "2.16.840.1.101.3.4.2.3": "sha512"
682
+ };
683
+ }
684
+ });
685
+
686
+ // node_modules/@sigstore/core/dist/rfc3161/error.js
687
+ var require_error2 = __commonJS({
688
+ "node_modules/@sigstore/core/dist/rfc3161/error.js"(exports) {
689
+ "use strict";
690
+ Object.defineProperty(exports, "__esModule", { value: true });
691
+ exports.RFC3161TimestampVerificationError = void 0;
692
+ var RFC3161TimestampVerificationError = class extends Error {
693
+ };
694
+ exports.RFC3161TimestampVerificationError = RFC3161TimestampVerificationError;
695
+ }
696
+ });
697
+
698
+ // node_modules/@sigstore/core/dist/rfc3161/tstinfo.js
699
+ var require_tstinfo = __commonJS({
700
+ "node_modules/@sigstore/core/dist/rfc3161/tstinfo.js"(exports) {
701
+ "use strict";
702
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
703
+ if (k2 === void 0) k2 = k;
704
+ var desc = Object.getOwnPropertyDescriptor(m, k);
705
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
706
+ desc = { enumerable: true, get: function() {
707
+ return m[k];
708
+ } };
709
+ }
710
+ Object.defineProperty(o, k2, desc);
711
+ }) : (function(o, m, k, k2) {
712
+ if (k2 === void 0) k2 = k;
713
+ o[k2] = m[k];
714
+ }));
715
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
716
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
717
+ }) : function(o, v) {
718
+ o["default"] = v;
719
+ });
720
+ var __importStar = exports && exports.__importStar || /* @__PURE__ */ (function() {
721
+ var ownKeys = function(o) {
722
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
723
+ var ar = [];
724
+ for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
725
+ return ar;
726
+ };
727
+ return ownKeys(o);
728
+ };
729
+ return function(mod) {
730
+ if (mod && mod.__esModule) return mod;
731
+ var result = {};
732
+ if (mod != null) {
733
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
734
+ }
735
+ __setModuleDefault(result, mod);
736
+ return result;
737
+ };
738
+ })();
739
+ Object.defineProperty(exports, "__esModule", { value: true });
740
+ exports.TSTInfo = void 0;
741
+ var crypto = __importStar(require_crypto());
742
+ var oid_1 = require_oid();
743
+ var error_1 = require_error2();
744
+ var TSTInfo = class {
745
+ root;
746
+ constructor(asn1) {
747
+ this.root = asn1;
748
+ }
749
+ get version() {
750
+ return this.root.subs[0].toInteger();
751
+ }
752
+ get genTime() {
753
+ return this.root.subs[4].toDate();
754
+ }
755
+ get messageImprintHashAlgorithm() {
756
+ const oid = this.messageImprintObj.subs[0].subs[0].toOID();
757
+ return oid_1.SHA2_HASH_ALGOS[oid];
758
+ }
759
+ get messageImprintHashedMessage() {
760
+ return this.messageImprintObj.subs[1].value;
761
+ }
762
+ get raw() {
763
+ return this.root.toDER();
764
+ }
765
+ verify(data) {
766
+ const digest = crypto.digest(this.messageImprintHashAlgorithm, data);
767
+ if (!crypto.bufferEqual(digest, this.messageImprintHashedMessage)) {
768
+ throw new error_1.RFC3161TimestampVerificationError("message imprint does not match artifact");
769
+ }
770
+ }
771
+ // https://www.rfc-editor.org/rfc/rfc3161#section-2.4.2
772
+ get messageImprintObj() {
773
+ return this.root.subs[2];
774
+ }
775
+ };
776
+ exports.TSTInfo = TSTInfo;
777
+ }
778
+ });
779
+
780
+ // node_modules/@sigstore/core/dist/rfc3161/timestamp.js
781
+ var require_timestamp = __commonJS({
782
+ "node_modules/@sigstore/core/dist/rfc3161/timestamp.js"(exports) {
783
+ "use strict";
784
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
785
+ if (k2 === void 0) k2 = k;
786
+ var desc = Object.getOwnPropertyDescriptor(m, k);
787
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
788
+ desc = { enumerable: true, get: function() {
789
+ return m[k];
790
+ } };
791
+ }
792
+ Object.defineProperty(o, k2, desc);
793
+ }) : (function(o, m, k, k2) {
794
+ if (k2 === void 0) k2 = k;
795
+ o[k2] = m[k];
796
+ }));
797
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
798
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
799
+ }) : function(o, v) {
800
+ o["default"] = v;
801
+ });
802
+ var __importStar = exports && exports.__importStar || /* @__PURE__ */ (function() {
803
+ var ownKeys = function(o) {
804
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
805
+ var ar = [];
806
+ for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
807
+ return ar;
808
+ };
809
+ return ownKeys(o);
810
+ };
811
+ return function(mod) {
812
+ if (mod && mod.__esModule) return mod;
813
+ var result = {};
814
+ if (mod != null) {
815
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
816
+ }
817
+ __setModuleDefault(result, mod);
818
+ return result;
819
+ };
820
+ })();
821
+ Object.defineProperty(exports, "__esModule", { value: true });
822
+ exports.RFC3161Timestamp = void 0;
823
+ var asn1_1 = require_asn1();
824
+ var crypto = __importStar(require_crypto());
825
+ var oid_1 = require_oid();
826
+ var error_1 = require_error2();
827
+ var tstinfo_1 = require_tstinfo();
828
+ var OID_PKCS9_CONTENT_TYPE_SIGNED_DATA = "1.2.840.113549.1.7.2";
829
+ var OID_PKCS9_CONTENT_TYPE_TSTINFO = "1.2.840.113549.1.9.16.1.4";
830
+ var OID_PKCS9_MESSAGE_DIGEST_KEY = "1.2.840.113549.1.9.4";
831
+ var RFC3161Timestamp = class _RFC3161Timestamp {
832
+ root;
833
+ constructor(asn1) {
834
+ this.root = asn1;
835
+ }
836
+ static parse(der) {
837
+ const asn1 = asn1_1.ASN1Obj.parseBuffer(der);
838
+ return new _RFC3161Timestamp(asn1);
839
+ }
840
+ get status() {
841
+ return this.pkiStatusInfoObj.subs[0].toInteger();
842
+ }
843
+ get contentType() {
844
+ return this.contentTypeObj.toOID();
845
+ }
846
+ get eContentType() {
847
+ return this.eContentTypeObj.toOID();
848
+ }
849
+ get signingTime() {
850
+ return this.tstInfo.genTime;
851
+ }
852
+ get signerIssuer() {
853
+ return this.signerSidObj.subs[0].value;
854
+ }
855
+ get signerSerialNumber() {
856
+ return this.signerSidObj.subs[1].value;
857
+ }
858
+ get signerDigestAlgorithm() {
859
+ const oid = this.signerDigestAlgorithmObj.subs[0].toOID();
860
+ return oid_1.SHA2_HASH_ALGOS[oid];
861
+ }
862
+ get signatureAlgorithm() {
863
+ const oid = this.signatureAlgorithmObj.subs[0].toOID();
864
+ return oid_1.ECDSA_SIGNATURE_ALGOS[oid];
865
+ }
866
+ get signatureValue() {
867
+ return this.signatureValueObj.value;
868
+ }
869
+ get tstInfo() {
870
+ return new tstinfo_1.TSTInfo(this.eContentObj.subs[0].subs[0]);
871
+ }
872
+ verify(data, publicKey) {
873
+ if (!this.timeStampTokenObj) {
874
+ throw new error_1.RFC3161TimestampVerificationError("timeStampToken is missing");
875
+ }
876
+ if (this.contentType !== OID_PKCS9_CONTENT_TYPE_SIGNED_DATA) {
877
+ throw new error_1.RFC3161TimestampVerificationError(`incorrect content type: ${this.contentType}`);
878
+ }
879
+ if (this.eContentType !== OID_PKCS9_CONTENT_TYPE_TSTINFO) {
880
+ throw new error_1.RFC3161TimestampVerificationError(`incorrect encapsulated content type: ${this.eContentType}`);
881
+ }
882
+ this.tstInfo.verify(data);
883
+ this.verifyMessageDigest();
884
+ this.verifySignature(publicKey);
885
+ }
886
+ verifyMessageDigest() {
887
+ const tstInfoDigest = crypto.digest(this.signerDigestAlgorithm, this.tstInfo.raw);
888
+ const expectedDigest = this.messageDigestAttributeObj.subs[1].subs[0].value;
889
+ if (!crypto.bufferEqual(tstInfoDigest, expectedDigest)) {
890
+ throw new error_1.RFC3161TimestampVerificationError("signed data does not match tstInfo");
891
+ }
892
+ }
893
+ verifySignature(key) {
894
+ const signedAttrs = this.signedAttrsObj.toDER();
895
+ signedAttrs[0] = 49;
896
+ const verified = crypto.verify(signedAttrs, key, this.signatureValue, this.signatureAlgorithm);
897
+ if (!verified) {
898
+ throw new error_1.RFC3161TimestampVerificationError("signature verification failed");
899
+ }
900
+ }
901
+ // https://www.rfc-editor.org/rfc/rfc3161#section-2.4.2
902
+ get pkiStatusInfoObj() {
903
+ return this.root.subs[0];
904
+ }
905
+ // https://www.rfc-editor.org/rfc/rfc3161#section-2.4.2
906
+ get timeStampTokenObj() {
907
+ return this.root.subs[1];
908
+ }
909
+ // https://datatracker.ietf.org/doc/html/rfc5652#section-3
910
+ get contentTypeObj() {
911
+ return this.timeStampTokenObj.subs[0];
912
+ }
913
+ // https://www.rfc-editor.org/rfc/rfc5652#section-3
914
+ get signedDataObj() {
915
+ const obj = this.timeStampTokenObj.subs.find((sub) => sub.tag.isContextSpecific(0));
916
+ return obj.subs[0];
917
+ }
918
+ // https://datatracker.ietf.org/doc/html/rfc5652#section-5.1
919
+ get encapContentInfoObj() {
920
+ return this.signedDataObj.subs[2];
921
+ }
922
+ // https://datatracker.ietf.org/doc/html/rfc5652#section-5.1
923
+ get signerInfosObj() {
924
+ const sd = this.signedDataObj;
925
+ return sd.subs[sd.subs.length - 1];
926
+ }
927
+ // https://www.rfc-editor.org/rfc/rfc5652#section-5.1
928
+ get signerInfoObj() {
929
+ return this.signerInfosObj.subs[0];
930
+ }
931
+ // https://datatracker.ietf.org/doc/html/rfc5652#section-5.2
932
+ get eContentTypeObj() {
933
+ return this.encapContentInfoObj.subs[0];
934
+ }
935
+ // https://datatracker.ietf.org/doc/html/rfc5652#section-5.2
936
+ get eContentObj() {
937
+ return this.encapContentInfoObj.subs[1];
938
+ }
939
+ // https://datatracker.ietf.org/doc/html/rfc5652#section-5.3
940
+ get signedAttrsObj() {
941
+ const signedAttrs = this.signerInfoObj.subs.find((sub) => sub.tag.isContextSpecific(0));
942
+ return signedAttrs;
943
+ }
944
+ // https://datatracker.ietf.org/doc/html/rfc5652#section-5.3
945
+ get messageDigestAttributeObj() {
946
+ const messageDigest = this.signedAttrsObj.subs.find((sub) => sub.subs[0].tag.isOID() && sub.subs[0].toOID() === OID_PKCS9_MESSAGE_DIGEST_KEY);
947
+ return messageDigest;
948
+ }
949
+ // https://datatracker.ietf.org/doc/html/rfc5652#section-5.3
950
+ get signerSidObj() {
951
+ return this.signerInfoObj.subs[1];
952
+ }
953
+ // https://datatracker.ietf.org/doc/html/rfc5652#section-5.3
954
+ get signerDigestAlgorithmObj() {
955
+ return this.signerInfoObj.subs[2];
956
+ }
957
+ // https://datatracker.ietf.org/doc/html/rfc5652#section-5.3
958
+ get signatureAlgorithmObj() {
959
+ return this.signerInfoObj.subs[4];
960
+ }
961
+ // https://datatracker.ietf.org/doc/html/rfc5652#section-5.3
962
+ get signatureValueObj() {
963
+ return this.signerInfoObj.subs[5];
964
+ }
965
+ };
966
+ exports.RFC3161Timestamp = RFC3161Timestamp;
967
+ }
968
+ });
969
+
970
+ // node_modules/@sigstore/core/dist/rfc3161/index.js
971
+ var require_rfc3161 = __commonJS({
972
+ "node_modules/@sigstore/core/dist/rfc3161/index.js"(exports) {
973
+ "use strict";
974
+ Object.defineProperty(exports, "__esModule", { value: true });
975
+ exports.RFC3161Timestamp = void 0;
976
+ var timestamp_1 = require_timestamp();
977
+ Object.defineProperty(exports, "RFC3161Timestamp", { enumerable: true, get: function() {
978
+ return timestamp_1.RFC3161Timestamp;
979
+ } });
980
+ }
981
+ });
982
+
983
+ // node_modules/@sigstore/core/dist/x509/sct.js
984
+ var require_sct = __commonJS({
985
+ "node_modules/@sigstore/core/dist/x509/sct.js"(exports) {
986
+ "use strict";
987
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
988
+ if (k2 === void 0) k2 = k;
989
+ var desc = Object.getOwnPropertyDescriptor(m, k);
990
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
991
+ desc = { enumerable: true, get: function() {
992
+ return m[k];
993
+ } };
994
+ }
995
+ Object.defineProperty(o, k2, desc);
996
+ }) : (function(o, m, k, k2) {
997
+ if (k2 === void 0) k2 = k;
998
+ o[k2] = m[k];
999
+ }));
1000
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
1001
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
1002
+ }) : function(o, v) {
1003
+ o["default"] = v;
1004
+ });
1005
+ var __importStar = exports && exports.__importStar || /* @__PURE__ */ (function() {
1006
+ var ownKeys = function(o) {
1007
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
1008
+ var ar = [];
1009
+ for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
1010
+ return ar;
1011
+ };
1012
+ return ownKeys(o);
1013
+ };
1014
+ return function(mod) {
1015
+ if (mod && mod.__esModule) return mod;
1016
+ var result = {};
1017
+ if (mod != null) {
1018
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
1019
+ }
1020
+ __setModuleDefault(result, mod);
1021
+ return result;
1022
+ };
1023
+ })();
1024
+ Object.defineProperty(exports, "__esModule", { value: true });
1025
+ exports.SignedCertificateTimestamp = void 0;
1026
+ var crypto = __importStar(require_crypto());
1027
+ var stream_1 = require_stream();
1028
+ var SignedCertificateTimestamp = class _SignedCertificateTimestamp {
1029
+ version;
1030
+ logID;
1031
+ timestamp;
1032
+ extensions;
1033
+ hashAlgorithm;
1034
+ signatureAlgorithm;
1035
+ signature;
1036
+ constructor(options) {
1037
+ this.version = options.version;
1038
+ this.logID = options.logID;
1039
+ this.timestamp = options.timestamp;
1040
+ this.extensions = options.extensions;
1041
+ this.hashAlgorithm = options.hashAlgorithm;
1042
+ this.signatureAlgorithm = options.signatureAlgorithm;
1043
+ this.signature = options.signature;
1044
+ }
1045
+ get datetime() {
1046
+ return new Date(Number(this.timestamp.readBigInt64BE()));
1047
+ }
1048
+ // Returns the hash algorithm used to generate the SCT's signature.
1049
+ // https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.4.1
1050
+ get algorithm() {
1051
+ switch (this.hashAlgorithm) {
1052
+ /* istanbul ignore next */
1053
+ case 0:
1054
+ return "none";
1055
+ /* istanbul ignore next */
1056
+ case 1:
1057
+ return "md5";
1058
+ /* istanbul ignore next */
1059
+ case 2:
1060
+ return "sha1";
1061
+ /* istanbul ignore next */
1062
+ case 3:
1063
+ return "sha224";
1064
+ case 4:
1065
+ return "sha256";
1066
+ /* istanbul ignore next */
1067
+ case 5:
1068
+ return "sha384";
1069
+ /* istanbul ignore next */
1070
+ case 6:
1071
+ return "sha512";
1072
+ /* istanbul ignore next */
1073
+ default:
1074
+ return "unknown";
1075
+ }
1076
+ }
1077
+ verify(preCert, key) {
1078
+ const stream = new stream_1.ByteStream();
1079
+ stream.appendChar(this.version);
1080
+ stream.appendChar(0);
1081
+ stream.appendView(this.timestamp);
1082
+ stream.appendUint16(1);
1083
+ stream.appendView(preCert);
1084
+ stream.appendUint16(this.extensions.byteLength);
1085
+ if (this.extensions.byteLength > 0) {
1086
+ stream.appendView(this.extensions);
1087
+ }
1088
+ return crypto.verify(stream.buffer, key, this.signature, this.algorithm);
1089
+ }
1090
+ // Parses a SignedCertificateTimestamp from a buffer. SCTs are encoded using
1091
+ // TLS encoding which means the fields and lengths of most fields are
1092
+ // specified as part of the SCT and TLS specs.
1093
+ // https://www.rfc-editor.org/rfc/rfc6962#section-3.2
1094
+ // https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.4.1
1095
+ static parse(buf) {
1096
+ const stream = new stream_1.ByteStream(buf);
1097
+ const version = stream.getUint8();
1098
+ const logID = stream.getBlock(32);
1099
+ const timestamp = stream.getBlock(8);
1100
+ const extenstionLength = stream.getUint16();
1101
+ const extensions = stream.getBlock(extenstionLength);
1102
+ const hashAlgorithm = stream.getUint8();
1103
+ const signatureAlgorithm = stream.getUint8();
1104
+ const sigLength = stream.getUint16();
1105
+ const signature = stream.getBlock(sigLength);
1106
+ if (stream.position !== buf.length) {
1107
+ throw new Error("SCT buffer length mismatch");
1108
+ }
1109
+ return new _SignedCertificateTimestamp({
1110
+ version,
1111
+ logID,
1112
+ timestamp,
1113
+ extensions,
1114
+ hashAlgorithm,
1115
+ signatureAlgorithm,
1116
+ signature
1117
+ });
1118
+ }
1119
+ };
1120
+ exports.SignedCertificateTimestamp = SignedCertificateTimestamp;
1121
+ }
1122
+ });
1123
+
1124
+ // node_modules/@sigstore/core/dist/x509/ext.js
1125
+ var require_ext = __commonJS({
1126
+ "node_modules/@sigstore/core/dist/x509/ext.js"(exports) {
1127
+ "use strict";
1128
+ Object.defineProperty(exports, "__esModule", { value: true });
1129
+ exports.X509SCTExtension = exports.X509SubjectKeyIDExtension = exports.X509AuthorityKeyIDExtension = exports.X509SubjectAlternativeNameExtension = exports.X509KeyUsageExtension = exports.X509BasicConstraintsExtension = exports.X509Extension = void 0;
1130
+ var stream_1 = require_stream();
1131
+ var sct_1 = require_sct();
1132
+ var X509Extension = class {
1133
+ root;
1134
+ constructor(asn1) {
1135
+ this.root = asn1;
1136
+ }
1137
+ get oid() {
1138
+ return this.root.subs[0].toOID();
1139
+ }
1140
+ get critical() {
1141
+ return this.root.subs.length === 3 ? this.root.subs[1].toBoolean() : false;
1142
+ }
1143
+ get value() {
1144
+ return this.extnValueObj.value;
1145
+ }
1146
+ get valueObj() {
1147
+ return this.extnValueObj;
1148
+ }
1149
+ get extnValueObj() {
1150
+ return this.root.subs[this.root.subs.length - 1];
1151
+ }
1152
+ };
1153
+ exports.X509Extension = X509Extension;
1154
+ var X509BasicConstraintsExtension = class extends X509Extension {
1155
+ get isCA() {
1156
+ return this.sequence.subs[0]?.toBoolean() ?? false;
1157
+ }
1158
+ get pathLenConstraint() {
1159
+ return this.sequence.subs.length > 1 ? this.sequence.subs[1].toInteger() : void 0;
1160
+ }
1161
+ // The extnValue field contains a single sequence wrapping the isCA and
1162
+ // pathLenConstraint.
1163
+ get sequence() {
1164
+ return this.extnValueObj.subs[0];
1165
+ }
1166
+ };
1167
+ exports.X509BasicConstraintsExtension = X509BasicConstraintsExtension;
1168
+ var X509KeyUsageExtension = class extends X509Extension {
1169
+ get digitalSignature() {
1170
+ return this.bitString[0] === 1;
1171
+ }
1172
+ get keyCertSign() {
1173
+ return this.bitString[5] === 1;
1174
+ }
1175
+ get crlSign() {
1176
+ return this.bitString[6] === 1;
1177
+ }
1178
+ // The extnValue field contains a single bit string which is a bit mask
1179
+ // indicating which key usages are enabled.
1180
+ get bitString() {
1181
+ return this.extnValueObj.subs[0].toBitString();
1182
+ }
1183
+ };
1184
+ exports.X509KeyUsageExtension = X509KeyUsageExtension;
1185
+ var X509SubjectAlternativeNameExtension = class extends X509Extension {
1186
+ get rfc822Name() {
1187
+ return this.findGeneralName(1)?.value.toString("ascii");
1188
+ }
1189
+ get uri() {
1190
+ return this.findGeneralName(6)?.value.toString("ascii");
1191
+ }
1192
+ // Retrieve the value of an otherName with the given OID.
1193
+ otherName(oid) {
1194
+ const otherName = this.findGeneralName(0);
1195
+ if (otherName === void 0) {
1196
+ return void 0;
1197
+ }
1198
+ const otherNameOID = otherName.subs[0].toOID();
1199
+ if (otherNameOID !== oid) {
1200
+ return void 0;
1201
+ }
1202
+ const otherNameValue = otherName.subs[1];
1203
+ return otherNameValue.subs[0].value.toString("ascii");
1204
+ }
1205
+ findGeneralName(tag) {
1206
+ return this.generalNames.find((gn) => gn.tag.isContextSpecific(tag));
1207
+ }
1208
+ // The extnValue field contains a sequence of GeneralNames.
1209
+ get generalNames() {
1210
+ return this.extnValueObj.subs[0].subs;
1211
+ }
1212
+ };
1213
+ exports.X509SubjectAlternativeNameExtension = X509SubjectAlternativeNameExtension;
1214
+ var X509AuthorityKeyIDExtension = class extends X509Extension {
1215
+ get keyIdentifier() {
1216
+ return this.findSequenceMember(0)?.value;
1217
+ }
1218
+ findSequenceMember(tag) {
1219
+ return this.sequence.subs.find((el) => el.tag.isContextSpecific(tag));
1220
+ }
1221
+ // The extnValue field contains a single sequence wrapping the keyIdentifier
1222
+ get sequence() {
1223
+ return this.extnValueObj.subs[0];
1224
+ }
1225
+ };
1226
+ exports.X509AuthorityKeyIDExtension = X509AuthorityKeyIDExtension;
1227
+ var X509SubjectKeyIDExtension = class extends X509Extension {
1228
+ get keyIdentifier() {
1229
+ return this.extnValueObj.subs[0].value;
1230
+ }
1231
+ };
1232
+ exports.X509SubjectKeyIDExtension = X509SubjectKeyIDExtension;
1233
+ var X509SCTExtension = class extends X509Extension {
1234
+ constructor(asn1) {
1235
+ super(asn1);
1236
+ }
1237
+ get signedCertificateTimestamps() {
1238
+ const buf = this.extnValueObj.subs[0].value;
1239
+ const stream = new stream_1.ByteStream(buf);
1240
+ const end = stream.getUint16() + 2;
1241
+ const sctList = [];
1242
+ while (stream.position < end) {
1243
+ const sctLength = stream.getUint16();
1244
+ const sct = stream.getBlock(sctLength);
1245
+ sctList.push(sct_1.SignedCertificateTimestamp.parse(sct));
1246
+ }
1247
+ if (stream.position !== end) {
1248
+ throw new Error("SCT list length does not match actual length");
1249
+ }
1250
+ return sctList;
1251
+ }
1252
+ };
1253
+ exports.X509SCTExtension = X509SCTExtension;
1254
+ }
1255
+ });
1256
+
1257
+ // node_modules/@sigstore/core/dist/x509/cert.js
1258
+ var require_cert = __commonJS({
1259
+ "node_modules/@sigstore/core/dist/x509/cert.js"(exports) {
1260
+ "use strict";
1261
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
1262
+ if (k2 === void 0) k2 = k;
1263
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1264
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1265
+ desc = { enumerable: true, get: function() {
1266
+ return m[k];
1267
+ } };
1268
+ }
1269
+ Object.defineProperty(o, k2, desc);
1270
+ }) : (function(o, m, k, k2) {
1271
+ if (k2 === void 0) k2 = k;
1272
+ o[k2] = m[k];
1273
+ }));
1274
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
1275
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
1276
+ }) : function(o, v) {
1277
+ o["default"] = v;
1278
+ });
1279
+ var __importStar = exports && exports.__importStar || /* @__PURE__ */ (function() {
1280
+ var ownKeys = function(o) {
1281
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
1282
+ var ar = [];
1283
+ for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
1284
+ return ar;
1285
+ };
1286
+ return ownKeys(o);
1287
+ };
1288
+ return function(mod) {
1289
+ if (mod && mod.__esModule) return mod;
1290
+ var result = {};
1291
+ if (mod != null) {
1292
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
1293
+ }
1294
+ __setModuleDefault(result, mod);
1295
+ return result;
1296
+ };
1297
+ })();
1298
+ Object.defineProperty(exports, "__esModule", { value: true });
1299
+ exports.X509Certificate = exports.EXTENSION_OID_SCT = void 0;
1300
+ var asn1_1 = require_asn1();
1301
+ var crypto = __importStar(require_crypto());
1302
+ var oid_1 = require_oid();
1303
+ var pem = __importStar(require_pem());
1304
+ var ext_1 = require_ext();
1305
+ var EXTENSION_OID_SUBJECT_KEY_ID = "2.5.29.14";
1306
+ var EXTENSION_OID_KEY_USAGE = "2.5.29.15";
1307
+ var EXTENSION_OID_SUBJECT_ALT_NAME = "2.5.29.17";
1308
+ var EXTENSION_OID_BASIC_CONSTRAINTS = "2.5.29.19";
1309
+ var EXTENSION_OID_AUTHORITY_KEY_ID = "2.5.29.35";
1310
+ exports.EXTENSION_OID_SCT = "1.3.6.1.4.1.11129.2.4.2";
1311
+ var X509Certificate = class _X509Certificate {
1312
+ root;
1313
+ constructor(asn1) {
1314
+ this.root = asn1;
1315
+ }
1316
+ static parse(cert) {
1317
+ const der = typeof cert === "string" ? pem.toDER(cert) : cert;
1318
+ const asn1 = asn1_1.ASN1Obj.parseBuffer(der);
1319
+ return new _X509Certificate(asn1);
1320
+ }
1321
+ get tbsCertificate() {
1322
+ return this.tbsCertificateObj;
1323
+ }
1324
+ get version() {
1325
+ const ver = this.versionObj.subs[0].toInteger();
1326
+ return `v${(ver + BigInt(1)).toString()}`;
1327
+ }
1328
+ get serialNumber() {
1329
+ return this.serialNumberObj.value;
1330
+ }
1331
+ get notBefore() {
1332
+ return this.validityObj.subs[0].toDate();
1333
+ }
1334
+ get notAfter() {
1335
+ return this.validityObj.subs[1].toDate();
1336
+ }
1337
+ get issuer() {
1338
+ return this.issuerObj.value;
1339
+ }
1340
+ get subject() {
1341
+ return this.subjectObj.value;
1342
+ }
1343
+ get publicKey() {
1344
+ return this.subjectPublicKeyInfoObj.toDER();
1345
+ }
1346
+ get signatureAlgorithm() {
1347
+ const oid = this.signatureAlgorithmObj.subs[0].toOID();
1348
+ if (oid_1.RSA_SIGNATURE_ALGOS[oid]) {
1349
+ return oid_1.RSA_SIGNATURE_ALGOS[oid];
1350
+ }
1351
+ return oid_1.ECDSA_SIGNATURE_ALGOS[oid];
1352
+ }
1353
+ get signatureValue() {
1354
+ return this.signatureValueObj.value.subarray(1);
1355
+ }
1356
+ get subjectAltName() {
1357
+ const ext = this.extSubjectAltName;
1358
+ return ext?.uri || /* istanbul ignore next */
1359
+ ext?.rfc822Name;
1360
+ }
1361
+ get extensions() {
1362
+ const extSeq = this.extensionsObj?.subs[0];
1363
+ return extSeq?.subs || [];
1364
+ }
1365
+ get extKeyUsage() {
1366
+ const ext = this.findExtension(EXTENSION_OID_KEY_USAGE);
1367
+ return ext ? new ext_1.X509KeyUsageExtension(ext) : void 0;
1368
+ }
1369
+ get extBasicConstraints() {
1370
+ const ext = this.findExtension(EXTENSION_OID_BASIC_CONSTRAINTS);
1371
+ return ext ? new ext_1.X509BasicConstraintsExtension(ext) : void 0;
1372
+ }
1373
+ get extSubjectAltName() {
1374
+ const ext = this.findExtension(EXTENSION_OID_SUBJECT_ALT_NAME);
1375
+ return ext ? new ext_1.X509SubjectAlternativeNameExtension(ext) : void 0;
1376
+ }
1377
+ get extAuthorityKeyID() {
1378
+ const ext = this.findExtension(EXTENSION_OID_AUTHORITY_KEY_ID);
1379
+ return ext ? new ext_1.X509AuthorityKeyIDExtension(ext) : void 0;
1380
+ }
1381
+ get extSubjectKeyID() {
1382
+ const ext = this.findExtension(EXTENSION_OID_SUBJECT_KEY_ID);
1383
+ return ext ? new ext_1.X509SubjectKeyIDExtension(ext) : (
1384
+ /* istanbul ignore next */
1385
+ void 0
1386
+ );
1387
+ }
1388
+ get extSCT() {
1389
+ const ext = this.findExtension(exports.EXTENSION_OID_SCT);
1390
+ return ext ? new ext_1.X509SCTExtension(ext) : void 0;
1391
+ }
1392
+ get isCA() {
1393
+ const ca = this.extBasicConstraints?.isCA || false;
1394
+ if (this.extKeyUsage) {
1395
+ return ca && this.extKeyUsage.keyCertSign;
1396
+ }
1397
+ return ca;
1398
+ }
1399
+ extension(oid) {
1400
+ const ext = this.findExtension(oid);
1401
+ return ext ? new ext_1.X509Extension(ext) : void 0;
1402
+ }
1403
+ verify(issuerCertificate) {
1404
+ const publicKey = issuerCertificate?.publicKey || this.publicKey;
1405
+ const key = crypto.createPublicKey(publicKey);
1406
+ return crypto.verify(this.tbsCertificate.toDER(), key, this.signatureValue, this.signatureAlgorithm);
1407
+ }
1408
+ validForDate(date) {
1409
+ return this.notBefore <= date && date <= this.notAfter;
1410
+ }
1411
+ equals(other) {
1412
+ return this.root.toDER().equals(other.root.toDER());
1413
+ }
1414
+ // Creates a copy of the certificate with a new buffer
1415
+ clone() {
1416
+ const der = this.root.toDER();
1417
+ const clone = Buffer.alloc(der.length);
1418
+ der.copy(clone);
1419
+ return _X509Certificate.parse(clone);
1420
+ }
1421
+ findExtension(oid) {
1422
+ return this.extensions.find((ext) => ext.subs[0].toOID() === oid);
1423
+ }
1424
+ /////////////////////////////////////////////////////////////////////////////
1425
+ // The following properties use the documented x509 structure to locate the
1426
+ // desired ASN.1 object
1427
+ // https://www.rfc-editor.org/rfc/rfc5280#section-4.1
1428
+ // https://www.rfc-editor.org/rfc/rfc5280#section-4.1.1.1
1429
+ get tbsCertificateObj() {
1430
+ return this.root.subs[0];
1431
+ }
1432
+ // https://www.rfc-editor.org/rfc/rfc5280#section-4.1.1.2
1433
+ get signatureAlgorithmObj() {
1434
+ return this.root.subs[1];
1435
+ }
1436
+ // https://www.rfc-editor.org/rfc/rfc5280#section-4.1.1.3
1437
+ get signatureValueObj() {
1438
+ return this.root.subs[2];
1439
+ }
1440
+ // https://www.rfc-editor.org/rfc/rfc5280#section-4.1.2.1
1441
+ get versionObj() {
1442
+ return this.tbsCertificateObj.subs[0];
1443
+ }
1444
+ // https://www.rfc-editor.org/rfc/rfc5280#section-4.1.2.2
1445
+ get serialNumberObj() {
1446
+ return this.tbsCertificateObj.subs[1];
1447
+ }
1448
+ // https://www.rfc-editor.org/rfc/rfc5280#section-4.1.2.4
1449
+ get issuerObj() {
1450
+ return this.tbsCertificateObj.subs[3];
1451
+ }
1452
+ // https://www.rfc-editor.org/rfc/rfc5280#section-4.1.2.5
1453
+ get validityObj() {
1454
+ return this.tbsCertificateObj.subs[4];
1455
+ }
1456
+ // https://www.rfc-editor.org/rfc/rfc5280#section-4.1.2.6
1457
+ get subjectObj() {
1458
+ return this.tbsCertificateObj.subs[5];
1459
+ }
1460
+ // https://www.rfc-editor.org/rfc/rfc5280#section-4.1.2.7
1461
+ get subjectPublicKeyInfoObj() {
1462
+ return this.tbsCertificateObj.subs[6];
1463
+ }
1464
+ // Extensions can't be located by index because their position varies. Instead,
1465
+ // we need to find the extensions context specific tag
1466
+ // https://www.rfc-editor.org/rfc/rfc5280#section-4.1.2.9
1467
+ get extensionsObj() {
1468
+ return this.tbsCertificateObj.subs.find((sub) => sub.tag.isContextSpecific(3));
1469
+ }
1470
+ };
1471
+ exports.X509Certificate = X509Certificate;
1472
+ }
1473
+ });
1474
+
1475
+ // node_modules/@sigstore/core/dist/x509/index.js
1476
+ var require_x509 = __commonJS({
1477
+ "node_modules/@sigstore/core/dist/x509/index.js"(exports) {
1478
+ "use strict";
1479
+ Object.defineProperty(exports, "__esModule", { value: true });
1480
+ exports.X509SCTExtension = exports.X509Certificate = exports.EXTENSION_OID_SCT = void 0;
1481
+ var cert_1 = require_cert();
1482
+ Object.defineProperty(exports, "EXTENSION_OID_SCT", { enumerable: true, get: function() {
1483
+ return cert_1.EXTENSION_OID_SCT;
1484
+ } });
1485
+ Object.defineProperty(exports, "X509Certificate", { enumerable: true, get: function() {
1486
+ return cert_1.X509Certificate;
1487
+ } });
1488
+ var ext_1 = require_ext();
1489
+ Object.defineProperty(exports, "X509SCTExtension", { enumerable: true, get: function() {
1490
+ return ext_1.X509SCTExtension;
1491
+ } });
1492
+ }
1493
+ });
1494
+
1495
+ // node_modules/@sigstore/core/dist/index.js
1496
+ var require_dist2 = __commonJS({
1497
+ "node_modules/@sigstore/core/dist/index.js"(exports) {
1498
+ "use strict";
1499
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
1500
+ if (k2 === void 0) k2 = k;
1501
+ var desc = Object.getOwnPropertyDescriptor(m, k);
1502
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
1503
+ desc = { enumerable: true, get: function() {
1504
+ return m[k];
1505
+ } };
1506
+ }
1507
+ Object.defineProperty(o, k2, desc);
1508
+ }) : (function(o, m, k, k2) {
1509
+ if (k2 === void 0) k2 = k;
1510
+ o[k2] = m[k];
1511
+ }));
1512
+ var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o, v) {
1513
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
1514
+ }) : function(o, v) {
1515
+ o["default"] = v;
1516
+ });
1517
+ var __importStar = exports && exports.__importStar || /* @__PURE__ */ (function() {
1518
+ var ownKeys = function(o) {
1519
+ ownKeys = Object.getOwnPropertyNames || function(o2) {
1520
+ var ar = [];
1521
+ for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
1522
+ return ar;
1523
+ };
1524
+ return ownKeys(o);
1525
+ };
1526
+ return function(mod) {
1527
+ if (mod && mod.__esModule) return mod;
1528
+ var result = {};
1529
+ if (mod != null) {
1530
+ for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
1531
+ }
1532
+ __setModuleDefault(result, mod);
1533
+ return result;
1534
+ };
1535
+ })();
1536
+ Object.defineProperty(exports, "__esModule", { value: true });
1537
+ exports.X509SCTExtension = exports.X509Certificate = exports.EXTENSION_OID_SCT = exports.ByteStream = exports.RFC3161Timestamp = exports.pem = exports.json = exports.encoding = exports.dsse = exports.crypto = exports.ASN1Obj = void 0;
1538
+ var asn1_1 = require_asn1();
1539
+ Object.defineProperty(exports, "ASN1Obj", { enumerable: true, get: function() {
1540
+ return asn1_1.ASN1Obj;
1541
+ } });
1542
+ exports.crypto = __importStar(require_crypto());
1543
+ exports.dsse = __importStar(require_dsse());
1544
+ exports.encoding = __importStar(require_encoding());
1545
+ exports.json = __importStar(require_json());
1546
+ exports.pem = __importStar(require_pem());
1547
+ var rfc3161_1 = require_rfc3161();
1548
+ Object.defineProperty(exports, "RFC3161Timestamp", { enumerable: true, get: function() {
1549
+ return rfc3161_1.RFC3161Timestamp;
1550
+ } });
1551
+ var stream_1 = require_stream();
1552
+ Object.defineProperty(exports, "ByteStream", { enumerable: true, get: function() {
1553
+ return stream_1.ByteStream;
1554
+ } });
1555
+ var x509_1 = require_x509();
1556
+ Object.defineProperty(exports, "EXTENSION_OID_SCT", { enumerable: true, get: function() {
1557
+ return x509_1.EXTENSION_OID_SCT;
1558
+ } });
1559
+ Object.defineProperty(exports, "X509Certificate", { enumerable: true, get: function() {
1560
+ return x509_1.X509Certificate;
1561
+ } });
1562
+ Object.defineProperty(exports, "X509SCTExtension", { enumerable: true, get: function() {
1563
+ return x509_1.X509SCTExtension;
1564
+ } });
1565
+ }
1566
+ });
1567
+
1568
+ // node_modules/@sigstore/verify/dist/bundle/dsse.js
1569
+ var require_dsse2 = __commonJS({
1570
+ "node_modules/@sigstore/verify/dist/bundle/dsse.js"(exports) {
1571
+ "use strict";
1572
+ Object.defineProperty(exports, "__esModule", { value: true });
1573
+ exports.DSSESignatureContent = void 0;
1574
+ var core_1 = require_dist2();
1575
+ var DSSESignatureContent = class {
1576
+ env;
1577
+ constructor(env) {
1578
+ this.env = env;
1579
+ }
1580
+ compareDigest(digest) {
1581
+ return core_1.crypto.bufferEqual(digest, core_1.crypto.digest("sha256", this.env.payload));
1582
+ }
1583
+ // For a DSSE envelope the signature is computed over the pre-authentication
1584
+ // encoding (PAE), so the digest of the signed bytes is the digest of the PAE.
1585
+ // This is what a Rekor v2 hashedrekord entry records for a DSSE envelope.
1586
+ compareSignedDigest(digest) {
1587
+ return core_1.crypto.bufferEqual(digest, core_1.crypto.digest("sha256", this.preAuthEncoding));
1588
+ }
1589
+ compareSignature(signature) {
1590
+ return core_1.crypto.bufferEqual(signature, this.signature);
1591
+ }
1592
+ verifySignature(key) {
1593
+ return core_1.crypto.verify(this.preAuthEncoding, key, this.signature);
1594
+ }
1595
+ get signature() {
1596
+ return this.env.signatures.length > 0 ? this.env.signatures[0].sig : Buffer.from("");
1597
+ }
1598
+ // DSSE Pre-Authentication Encoding
1599
+ get preAuthEncoding() {
1600
+ return core_1.dsse.preAuthEncoding(this.env.payloadType, this.env.payload);
1601
+ }
1602
+ };
1603
+ exports.DSSESignatureContent = DSSESignatureContent;
1604
+ }
1605
+ });
1606
+
1607
+ // node_modules/@sigstore/verify/dist/bundle/message.js
1608
+ var require_message = __commonJS({
1609
+ "node_modules/@sigstore/verify/dist/bundle/message.js"(exports) {
1610
+ "use strict";
1611
+ Object.defineProperty(exports, "__esModule", { value: true });
1612
+ exports.MessageSignatureContent = void 0;
1613
+ var core_1 = require_dist2();
1614
+ var protobuf_specs_1 = require_dist();
1615
+ var HASH_ALGORITHM_MAP = {
1616
+ [protobuf_specs_1.HashAlgorithm.HASH_ALGORITHM_UNSPECIFIED]: "sha256",
1617
+ [protobuf_specs_1.HashAlgorithm.SHA2_256]: "sha256",
1618
+ [protobuf_specs_1.HashAlgorithm.SHA2_384]: "sha384",
1619
+ [protobuf_specs_1.HashAlgorithm.SHA2_512]: "sha512",
1620
+ [protobuf_specs_1.HashAlgorithm.SHA3_256]: "sha3-256",
1621
+ [protobuf_specs_1.HashAlgorithm.SHA3_384]: "sha3-384"
1622
+ };
1623
+ var MessageSignatureContent = class {
1624
+ signature;
1625
+ messageDigest;
1626
+ artifact;
1627
+ hashAlgorithm;
1628
+ constructor(messageSignature, artifact) {
1629
+ this.signature = messageSignature.signature;
1630
+ this.messageDigest = messageSignature.messageDigest.digest;
1631
+ this.artifact = artifact;
1632
+ this.hashAlgorithm = HASH_ALGORITHM_MAP[messageSignature.messageDigest.algorithm] ?? /* istanbul ignore next */
1633
+ "sha256";
1634
+ }
1635
+ compareSignature(signature) {
1636
+ return core_1.crypto.bufferEqual(signature, this.signature);
1637
+ }
1638
+ compareDigest(digest) {
1639
+ return core_1.crypto.bufferEqual(digest, this.messageDigest);
1640
+ }
1641
+ // For a message signature the signature is computed over the artifact, so the
1642
+ // digest of the signed bytes is the artifact's message digest.
1643
+ compareSignedDigest(digest) {
1644
+ return this.compareDigest(digest);
1645
+ }
1646
+ verifySignature(key) {
1647
+ return core_1.crypto.verify(this.artifact, key, this.signature, this.hashAlgorithm);
1648
+ }
1649
+ };
1650
+ exports.MessageSignatureContent = MessageSignatureContent;
1651
+ }
1652
+ });
1653
+
1654
+ // node_modules/@sigstore/verify/dist/bundle/index.js
1655
+ var require_bundle = __commonJS({
1656
+ "node_modules/@sigstore/verify/dist/bundle/index.js"(exports) {
1657
+ "use strict";
1658
+ Object.defineProperty(exports, "__esModule", { value: true });
1659
+ exports.toSignedEntity = toSignedEntity;
1660
+ exports.signatureContent = signatureContent;
1661
+ var core_1 = require_dist2();
1662
+ var dsse_1 = require_dsse2();
1663
+ var message_1 = require_message();
1664
+ function toSignedEntity(bundle, artifact) {
1665
+ const { tlogEntries, timestampVerificationData } = bundle.verificationMaterial;
1666
+ const timestamps = [];
1667
+ for (const entry of tlogEntries) {
1668
+ if (entry.integratedTime && entry.integratedTime !== "0") {
1669
+ timestamps.push({
1670
+ $case: "transparency-log",
1671
+ tlogEntry: entry
1672
+ });
1673
+ }
1674
+ }
1675
+ for (const ts of timestampVerificationData?.rfc3161Timestamps ?? []) {
1676
+ timestamps.push({
1677
+ $case: "timestamp-authority",
1678
+ timestamp: core_1.RFC3161Timestamp.parse(Buffer.from(ts.signedTimestamp))
1679
+ });
1680
+ }
1681
+ return {
1682
+ signature: signatureContent(bundle, artifact),
1683
+ key: key(bundle),
1684
+ tlogEntries,
1685
+ timestamps
1686
+ };
1687
+ }
1688
+ function signatureContent(bundle, artifact) {
1689
+ switch (bundle.content.$case) {
1690
+ case "dsseEnvelope":
1691
+ return new dsse_1.DSSESignatureContent(bundle.content.dsseEnvelope);
1692
+ case "messageSignature":
1693
+ return new message_1.MessageSignatureContent(bundle.content.messageSignature, artifact);
1694
+ }
1695
+ }
1696
+ function key(bundle) {
1697
+ switch (bundle.verificationMaterial.content.$case) {
1698
+ case "publicKey":
1699
+ return {
1700
+ $case: "public-key",
1701
+ hint: bundle.verificationMaterial.content.publicKey.hint
1702
+ };
1703
+ case "x509CertificateChain":
1704
+ return {
1705
+ $case: "certificate",
1706
+ certificate: core_1.X509Certificate.parse(Buffer.from(bundle.verificationMaterial.content.x509CertificateChain.certificates[0].rawBytes))
1707
+ };
1708
+ case "certificate":
1709
+ return {
1710
+ $case: "certificate",
1711
+ certificate: core_1.X509Certificate.parse(Buffer.from(bundle.verificationMaterial.content.certificate.rawBytes))
1712
+ };
1713
+ }
1714
+ }
1715
+ }
1716
+ });
1717
+
1718
+ // node_modules/@sigstore/verify/dist/error.js
1719
+ var require_error3 = __commonJS({
1720
+ "node_modules/@sigstore/verify/dist/error.js"(exports) {
1721
+ "use strict";
1722
+ Object.defineProperty(exports, "__esModule", { value: true });
1723
+ exports.PolicyError = exports.VerificationError = void 0;
1724
+ var BaseError = class extends Error {
1725
+ code;
1726
+ cause;
1727
+ /* eslint-disable-line @typescript-eslint/no-explicit-any */
1728
+ constructor({ code, message, cause }) {
1729
+ super(message);
1730
+ this.code = code;
1731
+ this.cause = cause;
1732
+ this.name = this.constructor.name;
1733
+ }
1734
+ };
1735
+ var VerificationError = class extends BaseError {
1736
+ };
1737
+ exports.VerificationError = VerificationError;
1738
+ var PolicyError = class extends BaseError {
1739
+ };
1740
+ exports.PolicyError = PolicyError;
1741
+ }
1742
+ });
1743
+
1744
+ // node_modules/@sigstore/verify/dist/trust/filter.js
1745
+ var require_filter = __commonJS({
1746
+ "node_modules/@sigstore/verify/dist/trust/filter.js"(exports) {
1747
+ "use strict";
1748
+ Object.defineProperty(exports, "__esModule", { value: true });
1749
+ exports.filterCertAuthorities = filterCertAuthorities;
1750
+ exports.filterTLogAuthorities = filterTLogAuthorities;
1751
+ function filterCertAuthorities(certAuthorities, timestamp) {
1752
+ return certAuthorities.filter((ca) => {
1753
+ return ca.validFor.start <= timestamp && ca.validFor.end >= timestamp;
1754
+ });
1755
+ }
1756
+ function filterTLogAuthorities(tlogAuthorities, criteria) {
1757
+ return tlogAuthorities.filter((tlog) => {
1758
+ if (criteria.logID && !tlog.logID.equals(criteria.logID)) {
1759
+ return false;
1760
+ }
1761
+ return tlog.validFor.start <= criteria.targetDate && criteria.targetDate <= tlog.validFor.end;
1762
+ });
1763
+ }
1764
+ }
1765
+ });
1766
+
1767
+ // node_modules/@sigstore/verify/dist/trust/index.js
1768
+ var require_trust = __commonJS({
1769
+ "node_modules/@sigstore/verify/dist/trust/index.js"(exports) {
1770
+ "use strict";
1771
+ Object.defineProperty(exports, "__esModule", { value: true });
1772
+ exports.filterTLogAuthorities = exports.filterCertAuthorities = void 0;
1773
+ exports.toTrustMaterial = toTrustMaterial;
1774
+ var core_1 = require_dist2();
1775
+ var protobuf_specs_1 = require_dist();
1776
+ var error_1 = require_error3();
1777
+ var BEGINNING_OF_TIME = /* @__PURE__ */ new Date(0);
1778
+ var END_OF_TIME = /* @__PURE__ */ new Date(864e13);
1779
+ var filter_1 = require_filter();
1780
+ Object.defineProperty(exports, "filterCertAuthorities", { enumerable: true, get: function() {
1781
+ return filter_1.filterCertAuthorities;
1782
+ } });
1783
+ Object.defineProperty(exports, "filterTLogAuthorities", { enumerable: true, get: function() {
1784
+ return filter_1.filterTLogAuthorities;
1785
+ } });
1786
+ function toTrustMaterial(root, keys) {
1787
+ const keyFinder = typeof keys === "function" ? keys : keyLocator(keys);
1788
+ return {
1789
+ certificateAuthorities: root.certificateAuthorities.map(createCertAuthority),
1790
+ timestampAuthorities: root.timestampAuthorities.map(createCertAuthority),
1791
+ tlogs: root.tlogs.map(createTLogAuthority),
1792
+ ctlogs: root.ctlogs.map(createTLogAuthority),
1793
+ publicKey: keyFinder
1794
+ };
1795
+ }
1796
+ function createTLogAuthority(tlogInstance) {
1797
+ const keyDetails = tlogInstance.publicKey.keyDetails;
1798
+ const keyType = keyDetails === protobuf_specs_1.PublicKeyDetails.PKCS1_RSA_PKCS1V5 || keyDetails === protobuf_specs_1.PublicKeyDetails.PKIX_RSA_PKCS1V5 || keyDetails === protobuf_specs_1.PublicKeyDetails.PKIX_RSA_PKCS1V15_2048_SHA256 || keyDetails === protobuf_specs_1.PublicKeyDetails.PKIX_RSA_PKCS1V15_3072_SHA256 || keyDetails === protobuf_specs_1.PublicKeyDetails.PKIX_RSA_PKCS1V15_4096_SHA256 ? "pkcs1" : "spki";
1799
+ return {
1800
+ baseURL: tlogInstance.baseUrl,
1801
+ logID: tlogInstance.checkpointKeyId ? tlogInstance.checkpointKeyId.keyId : tlogInstance.logId.keyId,
1802
+ publicKey: core_1.crypto.createPublicKey(tlogInstance.publicKey.rawBytes, keyType),
1803
+ validFor: {
1804
+ start: tlogInstance.publicKey.validFor?.start || BEGINNING_OF_TIME,
1805
+ end: tlogInstance.publicKey.validFor?.end || END_OF_TIME
1806
+ }
1807
+ };
1808
+ }
1809
+ function createCertAuthority(ca) {
1810
+ return {
1811
+ certChain: ca.certChain.certificates.map((cert) => {
1812
+ return core_1.X509Certificate.parse(Buffer.from(cert.rawBytes));
1813
+ }),
1814
+ validFor: {
1815
+ start: ca.validFor?.start || BEGINNING_OF_TIME,
1816
+ end: ca.validFor?.end || END_OF_TIME
1817
+ }
1818
+ };
1819
+ }
1820
+ function keyLocator(keys) {
1821
+ return (hint) => {
1822
+ const key = (keys || {})[hint];
1823
+ if (!key) {
1824
+ throw new error_1.VerificationError({
1825
+ code: "PUBLIC_KEY_ERROR",
1826
+ message: `key not found: ${hint}`
1827
+ });
1828
+ }
1829
+ return {
1830
+ publicKey: core_1.crypto.createPublicKey(key.rawBytes),
1831
+ validFor: (date) => {
1832
+ return (key.validFor?.start || BEGINNING_OF_TIME) <= date && (key.validFor?.end || END_OF_TIME) >= date;
1833
+ }
1834
+ };
1835
+ };
1836
+ }
1837
+ }
1838
+ });
1839
+
1840
+ // node_modules/@sigstore/verify/dist/key/certificate.js
1841
+ var require_certificate = __commonJS({
1842
+ "node_modules/@sigstore/verify/dist/key/certificate.js"(exports) {
1843
+ "use strict";
1844
+ Object.defineProperty(exports, "__esModule", { value: true });
1845
+ exports.CertificateChainVerifier = void 0;
1846
+ exports.verifyCertificateChain = verifyCertificateChain;
1847
+ var error_1 = require_error3();
1848
+ var trust_1 = require_trust();
1849
+ function verifyCertificateChain(timestamp, leaf, certificateAuthorities) {
1850
+ const cas = (0, trust_1.filterCertAuthorities)(certificateAuthorities, timestamp);
1851
+ let error;
1852
+ for (const ca of cas) {
1853
+ try {
1854
+ const verifier = new CertificateChainVerifier({
1855
+ trustedCerts: ca.certChain,
1856
+ untrustedCert: leaf,
1857
+ timestamp
1858
+ });
1859
+ return verifier.verify();
1860
+ } catch (err) {
1861
+ error = err;
1862
+ }
1863
+ }
1864
+ throw new error_1.VerificationError({
1865
+ code: "CERTIFICATE_ERROR",
1866
+ message: "Failed to verify certificate chain",
1867
+ cause: error
1868
+ });
1869
+ }
1870
+ var CertificateChainVerifier = class {
1871
+ untrustedCert;
1872
+ trustedCerts;
1873
+ localCerts;
1874
+ timestamp;
1875
+ constructor(opts) {
1876
+ this.untrustedCert = opts.untrustedCert;
1877
+ this.trustedCerts = opts.trustedCerts;
1878
+ this.localCerts = dedupeCertificates([
1879
+ ...opts.trustedCerts,
1880
+ opts.untrustedCert
1881
+ ]);
1882
+ this.timestamp = opts.timestamp;
1883
+ }
1884
+ verify() {
1885
+ const certificatePath = this.sort();
1886
+ this.checkPath(certificatePath);
1887
+ const validForDate = certificatePath.every((cert) => cert.validForDate(this.timestamp));
1888
+ if (!validForDate) {
1889
+ throw new error_1.VerificationError({
1890
+ code: "CERTIFICATE_ERROR",
1891
+ message: "certificate is not valid or expired at the specified date"
1892
+ });
1893
+ }
1894
+ return certificatePath;
1895
+ }
1896
+ sort() {
1897
+ const leafCert = this.untrustedCert;
1898
+ let paths = this.buildPaths(leafCert);
1899
+ paths = paths.filter((path2) => path2.some((cert) => this.trustedCerts.includes(cert)));
1900
+ if (paths.length === 0) {
1901
+ throw new error_1.VerificationError({
1902
+ code: "CERTIFICATE_ERROR",
1903
+ message: "no trusted certificate path found"
1904
+ });
1905
+ }
1906
+ const path = paths.reduce((prev, curr) => prev.length < curr.length ? prev : curr);
1907
+ return [leafCert, ...path].slice(0, -1);
1908
+ }
1909
+ // Recursively build all possible paths from the leaf to the root
1910
+ buildPaths(certificate) {
1911
+ const paths = [];
1912
+ const issuers = this.findIssuer(certificate);
1913
+ if (issuers.length === 0) {
1914
+ throw new error_1.VerificationError({
1915
+ code: "CERTIFICATE_ERROR",
1916
+ message: "no valid certificate path found"
1917
+ });
1918
+ }
1919
+ for (let i = 0; i < issuers.length; i++) {
1920
+ const issuer = issuers[i];
1921
+ if (issuer.equals(certificate)) {
1922
+ paths.push([certificate]);
1923
+ continue;
1924
+ }
1925
+ const subPaths = this.buildPaths(issuer);
1926
+ for (let j = 0; j < subPaths.length; j++) {
1927
+ paths.push([issuer, ...subPaths[j]]);
1928
+ }
1929
+ }
1930
+ return paths;
1931
+ }
1932
+ // Return all possible issuers for the given certificate
1933
+ findIssuer(certificate) {
1934
+ let issuers = [];
1935
+ let keyIdentifier;
1936
+ if (certificate.subject.equals(certificate.issuer)) {
1937
+ if (certificate.verify()) {
1938
+ return [certificate];
1939
+ }
1940
+ }
1941
+ if (certificate.extAuthorityKeyID) {
1942
+ keyIdentifier = certificate.extAuthorityKeyID.keyIdentifier;
1943
+ }
1944
+ this.localCerts.forEach((possibleIssuer) => {
1945
+ if (keyIdentifier) {
1946
+ if (possibleIssuer.extSubjectKeyID) {
1947
+ if (possibleIssuer.extSubjectKeyID.keyIdentifier.equals(keyIdentifier)) {
1948
+ issuers.push(possibleIssuer);
1949
+ }
1950
+ return;
1951
+ }
1952
+ }
1953
+ if (possibleIssuer.subject.equals(certificate.issuer)) {
1954
+ issuers.push(possibleIssuer);
1955
+ }
1956
+ });
1957
+ issuers = issuers.filter((issuer) => {
1958
+ try {
1959
+ return certificate.verify(issuer);
1960
+ } catch (ex) {
1961
+ return false;
1962
+ }
1963
+ });
1964
+ return issuers;
1965
+ }
1966
+ checkPath(path) {
1967
+ if (path.length < 1) {
1968
+ throw new error_1.VerificationError({
1969
+ code: "CERTIFICATE_ERROR",
1970
+ message: "certificate chain must contain at least one certificate"
1971
+ });
1972
+ }
1973
+ const validCAs = path.slice(1).every((cert) => cert.isCA);
1974
+ if (!validCAs) {
1975
+ throw new error_1.VerificationError({
1976
+ code: "CERTIFICATE_ERROR",
1977
+ message: "intermediate certificate is not a CA"
1978
+ });
1979
+ }
1980
+ for (let i = path.length - 2; i >= 0; i--) {
1981
+ if (!path[i].issuer.equals(path[i + 1].subject)) {
1982
+ throw new error_1.VerificationError({
1983
+ code: "CERTIFICATE_ERROR",
1984
+ message: "incorrect certificate name chaining"
1985
+ });
1986
+ }
1987
+ }
1988
+ for (let i = 0; i < path.length; i++) {
1989
+ const cert = path[i];
1990
+ if (cert.extBasicConstraints?.isCA) {
1991
+ const pathLength = cert.extBasicConstraints.pathLenConstraint;
1992
+ if (pathLength !== void 0 && pathLength < i - 1) {
1993
+ throw new error_1.VerificationError({
1994
+ code: "CERTIFICATE_ERROR",
1995
+ message: "path length constraint exceeded"
1996
+ });
1997
+ }
1998
+ }
1999
+ }
2000
+ }
2001
+ };
2002
+ exports.CertificateChainVerifier = CertificateChainVerifier;
2003
+ function dedupeCertificates(certs) {
2004
+ for (let i = 0; i < certs.length; i++) {
2005
+ for (let j = i + 1; j < certs.length; j++) {
2006
+ if (certs[i].equals(certs[j])) {
2007
+ certs.splice(j, 1);
2008
+ j--;
2009
+ }
2010
+ }
2011
+ }
2012
+ return certs;
2013
+ }
2014
+ }
2015
+ });
2016
+
2017
+ // node_modules/@sigstore/verify/dist/key/sct.js
2018
+ var require_sct2 = __commonJS({
2019
+ "node_modules/@sigstore/verify/dist/key/sct.js"(exports) {
2020
+ "use strict";
2021
+ Object.defineProperty(exports, "__esModule", { value: true });
2022
+ exports.verifySCTs = verifySCTs;
2023
+ var core_1 = require_dist2();
2024
+ var error_1 = require_error3();
2025
+ var trust_1 = require_trust();
2026
+ function verifySCTs(cert, issuer, ctlogs) {
2027
+ let extSCT;
2028
+ const clone = cert.clone();
2029
+ for (let i = 0; i < clone.extensions.length; i++) {
2030
+ const ext = clone.extensions[i];
2031
+ if (ext.subs[0].toOID() === core_1.EXTENSION_OID_SCT) {
2032
+ extSCT = new core_1.X509SCTExtension(ext);
2033
+ clone.extensions.splice(i, 1);
2034
+ break;
2035
+ }
2036
+ }
2037
+ if (!extSCT) {
2038
+ return [];
2039
+ }
2040
+ if (extSCT.signedCertificateTimestamps.length === 0) {
2041
+ return [];
2042
+ }
2043
+ const preCert = new core_1.ByteStream();
2044
+ const issuerId = core_1.crypto.digest("sha256", issuer.publicKey);
2045
+ preCert.appendView(issuerId);
2046
+ const tbs = clone.tbsCertificate.toDER();
2047
+ preCert.appendUint24(tbs.length);
2048
+ preCert.appendView(tbs);
2049
+ return extSCT.signedCertificateTimestamps.map((sct) => {
2050
+ const validCTLogs = (0, trust_1.filterTLogAuthorities)(ctlogs, {
2051
+ logID: sct.logID,
2052
+ targetDate: sct.datetime
2053
+ });
2054
+ const verified = validCTLogs.some((log) => sct.verify(preCert.buffer, log.publicKey));
2055
+ if (!verified) {
2056
+ throw new error_1.VerificationError({
2057
+ code: "CERTIFICATE_ERROR",
2058
+ message: "SCT verification failed"
2059
+ });
2060
+ }
2061
+ return sct.logID;
2062
+ });
2063
+ }
2064
+ }
2065
+ });
2066
+
2067
+ // node_modules/@sigstore/verify/dist/key/index.js
2068
+ var require_key = __commonJS({
2069
+ "node_modules/@sigstore/verify/dist/key/index.js"(exports) {
2070
+ "use strict";
2071
+ Object.defineProperty(exports, "__esModule", { value: true });
2072
+ exports.verifyPublicKey = verifyPublicKey;
2073
+ exports.verifyCertificate = verifyCertificate;
2074
+ var core_1 = require_dist2();
2075
+ var error_1 = require_error3();
2076
+ var certificate_1 = require_certificate();
2077
+ var sct_1 = require_sct2();
2078
+ var OID_FULCIO_ISSUER_V1 = "1.3.6.1.4.1.57264.1.1";
2079
+ var OID_FULCIO_ISSUER_V2 = "1.3.6.1.4.1.57264.1.8";
2080
+ function verifyPublicKey(hint, timestamps, trustMaterial) {
2081
+ const key = trustMaterial.publicKey(hint);
2082
+ timestamps.forEach((timestamp) => {
2083
+ if (!key.validFor(timestamp)) {
2084
+ throw new error_1.VerificationError({
2085
+ code: "PUBLIC_KEY_ERROR",
2086
+ message: `Public key is not valid for timestamp: ${timestamp.toISOString()}`
2087
+ });
2088
+ }
2089
+ });
2090
+ return { key: key.publicKey };
2091
+ }
2092
+ function verifyCertificate(leaf, timestamps, trustMaterial) {
2093
+ let path = [];
2094
+ timestamps.forEach((timestamp) => {
2095
+ path = (0, certificate_1.verifyCertificateChain)(timestamp, leaf, trustMaterial.certificateAuthorities);
2096
+ });
2097
+ return {
2098
+ scts: (0, sct_1.verifySCTs)(path[0], path[1], trustMaterial.ctlogs),
2099
+ signer: getSigner(path[0])
2100
+ };
2101
+ }
2102
+ function getSigner(cert) {
2103
+ let issuer;
2104
+ const issuerExtension = cert.extension(OID_FULCIO_ISSUER_V2);
2105
+ if (issuerExtension) {
2106
+ issuer = issuerExtension.valueObj.subs?.[0]?.value.toString("ascii");
2107
+ } else {
2108
+ issuer = cert.extension(OID_FULCIO_ISSUER_V1)?.value.toString("ascii");
2109
+ }
2110
+ const oids = cert.extensions.map((ext) => {
2111
+ const oid = ext.subs[0].toOID();
2112
+ return {
2113
+ oid: { id: oid.split(".").map(Number) },
2114
+ value: ext.subs[ext.subs.length - 1].value
2115
+ };
2116
+ });
2117
+ const identity = {
2118
+ extensions: { issuer },
2119
+ subjectAlternativeName: cert.subjectAltName,
2120
+ oids
2121
+ };
2122
+ return {
2123
+ key: core_1.crypto.createPublicKey(cert.publicKey),
2124
+ identity
2125
+ };
2126
+ }
2127
+ }
2128
+ });
2129
+
2130
+ // node_modules/@sigstore/verify/dist/policy.js
2131
+ var require_policy = __commonJS({
2132
+ "node_modules/@sigstore/verify/dist/policy.js"(exports) {
2133
+ "use strict";
2134
+ Object.defineProperty(exports, "__esModule", { value: true });
2135
+ exports.verifySubjectAlternativeName = verifySubjectAlternativeName;
2136
+ exports.verifyExtensions = verifyExtensions;
2137
+ exports.verifyOIDs = verifyOIDs;
2138
+ var error_1 = require_error3();
2139
+ function verifySubjectAlternativeName(policyIdentity, signerIdentity) {
2140
+ if (signerIdentity === void 0 || !signerIdentity.match(policyIdentity)) {
2141
+ throw new error_1.PolicyError({
2142
+ code: "UNTRUSTED_SIGNER_ERROR",
2143
+ message: `certificate identity error - expected ${policyIdentity}, got ${signerIdentity}`
2144
+ });
2145
+ }
2146
+ }
2147
+ function verifyExtensions(policyExtensions, signerExtensions = {}) {
2148
+ let key;
2149
+ for (key in policyExtensions) {
2150
+ if (signerExtensions[key] !== policyExtensions[key]) {
2151
+ throw new error_1.PolicyError({
2152
+ code: "UNTRUSTED_SIGNER_ERROR",
2153
+ message: `invalid certificate extension - expected ${key}=${policyExtensions[key]}, got ${key}=${signerExtensions[key]}`
2154
+ });
2155
+ }
2156
+ }
2157
+ }
2158
+ function verifyOIDs(policyOIDs, signerOIDs = []) {
2159
+ for (const policyOID of policyOIDs) {
2160
+ const match = signerOIDs.find((signerOID) => oidEquals(policyOID.oid?.id, signerOID.oid?.id) && policyOID.value.equals(signerOID.value));
2161
+ if (!match) {
2162
+ const oid = policyOID.oid?.id.join(".") ?? "<unknown>";
2163
+ throw new error_1.PolicyError({
2164
+ code: "UNTRUSTED_SIGNER_ERROR",
2165
+ message: `invalid certificate extension - missing OID ${oid}`
2166
+ });
2167
+ }
2168
+ }
2169
+ }
2170
+ function oidEquals(a, b) {
2171
+ if (a === void 0 || b === void 0) {
2172
+ return false;
2173
+ }
2174
+ return a.length === b.length && a.every((v, i) => v === b[i]);
2175
+ }
2176
+ }
2177
+ });
2178
+
2179
+ // node_modules/@sigstore/verify/dist/timestamp/tsa.js
2180
+ var require_tsa = __commonJS({
2181
+ "node_modules/@sigstore/verify/dist/timestamp/tsa.js"(exports) {
2182
+ "use strict";
2183
+ Object.defineProperty(exports, "__esModule", { value: true });
2184
+ exports.verifyRFC3161Timestamp = verifyRFC3161Timestamp;
2185
+ var core_1 = require_dist2();
2186
+ var error_1 = require_error3();
2187
+ var certificate_1 = require_certificate();
2188
+ var trust_1 = require_trust();
2189
+ function verifyRFC3161Timestamp(timestamp, data, timestampAuthorities) {
2190
+ const signingTime = timestamp.signingTime;
2191
+ timestampAuthorities = (0, trust_1.filterCertAuthorities)(timestampAuthorities, signingTime);
2192
+ timestampAuthorities = filterCAsBySerialAndIssuer(timestampAuthorities, {
2193
+ serialNumber: timestamp.signerSerialNumber,
2194
+ issuer: timestamp.signerIssuer
2195
+ });
2196
+ const verified = timestampAuthorities.some((ca) => {
2197
+ try {
2198
+ verifyTimestampForCA(timestamp, data, ca);
2199
+ return true;
2200
+ } catch (e) {
2201
+ return false;
2202
+ }
2203
+ });
2204
+ if (!verified) {
2205
+ throw new error_1.VerificationError({
2206
+ code: "TIMESTAMP_ERROR",
2207
+ message: "timestamp could not be verified"
2208
+ });
2209
+ }
2210
+ }
2211
+ function verifyTimestampForCA(timestamp, data, ca) {
2212
+ const [leaf, ...cas] = ca.certChain;
2213
+ const signingKey = core_1.crypto.createPublicKey(leaf.publicKey);
2214
+ const signingTime = timestamp.signingTime;
2215
+ try {
2216
+ new certificate_1.CertificateChainVerifier({
2217
+ untrustedCert: leaf,
2218
+ trustedCerts: cas,
2219
+ timestamp: signingTime
2220
+ }).verify();
2221
+ } catch (e) {
2222
+ throw new error_1.VerificationError({
2223
+ code: "TIMESTAMP_ERROR",
2224
+ message: "invalid certificate chain"
2225
+ });
2226
+ }
2227
+ timestamp.verify(data, signingKey);
2228
+ }
2229
+ function filterCAsBySerialAndIssuer(timestampAuthorities, criteria) {
2230
+ return timestampAuthorities.filter((ca) => ca.certChain.length > 0 && core_1.crypto.bufferEqual(ca.certChain[0].serialNumber, criteria.serialNumber) && core_1.crypto.bufferEqual(ca.certChain[0].issuer, criteria.issuer));
2231
+ }
2232
+ }
2233
+ });
2234
+
2235
+ // node_modules/@sigstore/verify/dist/timestamp/index.js
2236
+ var require_timestamp2 = __commonJS({
2237
+ "node_modules/@sigstore/verify/dist/timestamp/index.js"(exports) {
2238
+ "use strict";
2239
+ Object.defineProperty(exports, "__esModule", { value: true });
2240
+ exports.getTSATimestamp = getTSATimestamp;
2241
+ exports.getTLogTimestamp = getTLogTimestamp;
2242
+ var tsa_1 = require_tsa();
2243
+ function getTSATimestamp(timestamp, data, timestampAuthorities) {
2244
+ (0, tsa_1.verifyRFC3161Timestamp)(timestamp, data, timestampAuthorities);
2245
+ return {
2246
+ type: "timestamp-authority",
2247
+ logID: timestamp.signerSerialNumber,
2248
+ timestamp: timestamp.signingTime
2249
+ };
2250
+ }
2251
+ function getTLogTimestamp(entry) {
2252
+ if (!entry.inclusionPromise) {
2253
+ return void 0;
2254
+ }
2255
+ return {
2256
+ type: "transparency-log",
2257
+ logID: entry.logId.keyId,
2258
+ timestamp: new Date(Number(entry.integratedTime) * 1e3)
2259
+ };
2260
+ }
2261
+ }
2262
+ });
2263
+
2264
+ // node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/verifier.js
2265
+ var require_verifier = __commonJS({
2266
+ "node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/verifier.js"(exports) {
2267
+ "use strict";
2268
+ Object.defineProperty(exports, "__esModule", { value: true });
2269
+ exports.Signature = exports.Verifier = exports.PublicKey = void 0;
2270
+ var sigstore_common_1 = require_sigstore_common();
2271
+ exports.PublicKey = {
2272
+ fromJSON(object) {
2273
+ return { rawBytes: isSet(object.rawBytes) ? Buffer.from(bytesFromBase64(object.rawBytes)) : Buffer.alloc(0) };
2274
+ },
2275
+ toJSON(message) {
2276
+ const obj = {};
2277
+ if (message.rawBytes.length !== 0) {
2278
+ obj.rawBytes = base64FromBytes(message.rawBytes);
2279
+ }
2280
+ return obj;
2281
+ }
2282
+ };
2283
+ exports.Verifier = {
2284
+ fromJSON(object) {
2285
+ return {
2286
+ verifier: isSet(object.publicKey) ? { $case: "publicKey", publicKey: exports.PublicKey.fromJSON(object.publicKey) } : isSet(object.x509Certificate) ? { $case: "x509Certificate", x509Certificate: sigstore_common_1.X509Certificate.fromJSON(object.x509Certificate) } : void 0,
2287
+ keyDetails: isSet(object.keyDetails) ? (0, sigstore_common_1.publicKeyDetailsFromJSON)(object.keyDetails) : 0
2288
+ };
2289
+ },
2290
+ toJSON(message) {
2291
+ const obj = {};
2292
+ if (message.verifier?.$case === "publicKey") {
2293
+ obj.publicKey = exports.PublicKey.toJSON(message.verifier.publicKey);
2294
+ } else if (message.verifier?.$case === "x509Certificate") {
2295
+ obj.x509Certificate = sigstore_common_1.X509Certificate.toJSON(message.verifier.x509Certificate);
2296
+ }
2297
+ if (message.keyDetails !== 0) {
2298
+ obj.keyDetails = (0, sigstore_common_1.publicKeyDetailsToJSON)(message.keyDetails);
2299
+ }
2300
+ return obj;
2301
+ }
2302
+ };
2303
+ exports.Signature = {
2304
+ fromJSON(object) {
2305
+ return {
2306
+ content: isSet(object.content) ? Buffer.from(bytesFromBase64(object.content)) : Buffer.alloc(0),
2307
+ verifier: isSet(object.verifier) ? exports.Verifier.fromJSON(object.verifier) : void 0
2308
+ };
2309
+ },
2310
+ toJSON(message) {
2311
+ const obj = {};
2312
+ if (message.content.length !== 0) {
2313
+ obj.content = base64FromBytes(message.content);
2314
+ }
2315
+ if (message.verifier !== void 0) {
2316
+ obj.verifier = exports.Verifier.toJSON(message.verifier);
2317
+ }
2318
+ return obj;
2319
+ }
2320
+ };
2321
+ function bytesFromBase64(b64) {
2322
+ return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
2323
+ }
2324
+ function base64FromBytes(arr) {
2325
+ return globalThis.Buffer.from(arr).toString("base64");
2326
+ }
2327
+ function isSet(value) {
2328
+ return value !== null && value !== void 0;
2329
+ }
2330
+ }
2331
+ });
2332
+
2333
+ // node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/dsse.js
2334
+ var require_dsse3 = __commonJS({
2335
+ "node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/dsse.js"(exports) {
2336
+ "use strict";
2337
+ Object.defineProperty(exports, "__esModule", { value: true });
2338
+ exports.DSSELogEntryV002 = exports.DSSERequestV002 = void 0;
2339
+ var envelope_1 = require_envelope();
2340
+ var sigstore_common_1 = require_sigstore_common();
2341
+ var verifier_1 = require_verifier();
2342
+ exports.DSSERequestV002 = {
2343
+ fromJSON(object) {
2344
+ return {
2345
+ envelope: isSet(object.envelope) ? envelope_1.Envelope.fromJSON(object.envelope) : void 0,
2346
+ verifiers: globalThis.Array.isArray(object?.verifiers) ? object.verifiers.map((e) => verifier_1.Verifier.fromJSON(e)) : []
2347
+ };
2348
+ },
2349
+ toJSON(message) {
2350
+ const obj = {};
2351
+ if (message.envelope !== void 0) {
2352
+ obj.envelope = envelope_1.Envelope.toJSON(message.envelope);
2353
+ }
2354
+ if (message.verifiers?.length) {
2355
+ obj.verifiers = message.verifiers.map((e) => verifier_1.Verifier.toJSON(e));
2356
+ }
2357
+ return obj;
2358
+ }
2359
+ };
2360
+ exports.DSSELogEntryV002 = {
2361
+ fromJSON(object) {
2362
+ return {
2363
+ payloadHash: isSet(object.payloadHash) ? sigstore_common_1.HashOutput.fromJSON(object.payloadHash) : void 0,
2364
+ signatures: globalThis.Array.isArray(object?.signatures) ? object.signatures.map((e) => verifier_1.Signature.fromJSON(e)) : []
2365
+ };
2366
+ },
2367
+ toJSON(message) {
2368
+ const obj = {};
2369
+ if (message.payloadHash !== void 0) {
2370
+ obj.payloadHash = sigstore_common_1.HashOutput.toJSON(message.payloadHash);
2371
+ }
2372
+ if (message.signatures?.length) {
2373
+ obj.signatures = message.signatures.map((e) => verifier_1.Signature.toJSON(e));
2374
+ }
2375
+ return obj;
2376
+ }
2377
+ };
2378
+ function isSet(value) {
2379
+ return value !== null && value !== void 0;
2380
+ }
2381
+ }
2382
+ });
2383
+
2384
+ // node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/hashedrekord.js
2385
+ var require_hashedrekord = __commonJS({
2386
+ "node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/hashedrekord.js"(exports) {
2387
+ "use strict";
2388
+ Object.defineProperty(exports, "__esModule", { value: true });
2389
+ exports.HashedRekordLogEntryV002 = exports.HashedRekordRequestV002 = void 0;
2390
+ var sigstore_common_1 = require_sigstore_common();
2391
+ var verifier_1 = require_verifier();
2392
+ exports.HashedRekordRequestV002 = {
2393
+ fromJSON(object) {
2394
+ return {
2395
+ digest: isSet(object.digest) ? Buffer.from(bytesFromBase64(object.digest)) : Buffer.alloc(0),
2396
+ signature: isSet(object.signature) ? verifier_1.Signature.fromJSON(object.signature) : void 0
2397
+ };
2398
+ },
2399
+ toJSON(message) {
2400
+ const obj = {};
2401
+ if (message.digest.length !== 0) {
2402
+ obj.digest = base64FromBytes(message.digest);
2403
+ }
2404
+ if (message.signature !== void 0) {
2405
+ obj.signature = verifier_1.Signature.toJSON(message.signature);
2406
+ }
2407
+ return obj;
2408
+ }
2409
+ };
2410
+ exports.HashedRekordLogEntryV002 = {
2411
+ fromJSON(object) {
2412
+ return {
2413
+ data: isSet(object.data) ? sigstore_common_1.HashOutput.fromJSON(object.data) : void 0,
2414
+ signature: isSet(object.signature) ? verifier_1.Signature.fromJSON(object.signature) : void 0
2415
+ };
2416
+ },
2417
+ toJSON(message) {
2418
+ const obj = {};
2419
+ if (message.data !== void 0) {
2420
+ obj.data = sigstore_common_1.HashOutput.toJSON(message.data);
2421
+ }
2422
+ if (message.signature !== void 0) {
2423
+ obj.signature = verifier_1.Signature.toJSON(message.signature);
2424
+ }
2425
+ return obj;
2426
+ }
2427
+ };
2428
+ function bytesFromBase64(b64) {
2429
+ return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
2430
+ }
2431
+ function base64FromBytes(arr) {
2432
+ return globalThis.Buffer.from(arr).toString("base64");
2433
+ }
2434
+ function isSet(value) {
2435
+ return value !== null && value !== void 0;
2436
+ }
2437
+ }
2438
+ });
2439
+
2440
+ // node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/entry.js
2441
+ var require_entry = __commonJS({
2442
+ "node_modules/@sigstore/protobuf-specs/dist/__generated__/rekor/v2/entry.js"(exports) {
2443
+ "use strict";
2444
+ Object.defineProperty(exports, "__esModule", { value: true });
2445
+ exports.CreateEntryRequest = exports.Spec = exports.Entry = void 0;
2446
+ var dsse_1 = require_dsse3();
2447
+ var hashedrekord_1 = require_hashedrekord();
2448
+ exports.Entry = {
2449
+ fromJSON(object) {
2450
+ return {
2451
+ kind: isSet(object.kind) ? globalThis.String(object.kind) : "",
2452
+ apiVersion: isSet(object.apiVersion) ? globalThis.String(object.apiVersion) : "",
2453
+ spec: isSet(object.spec) ? exports.Spec.fromJSON(object.spec) : void 0
2454
+ };
2455
+ },
2456
+ toJSON(message) {
2457
+ const obj = {};
2458
+ if (message.kind !== "") {
2459
+ obj.kind = message.kind;
2460
+ }
2461
+ if (message.apiVersion !== "") {
2462
+ obj.apiVersion = message.apiVersion;
2463
+ }
2464
+ if (message.spec !== void 0) {
2465
+ obj.spec = exports.Spec.toJSON(message.spec);
2466
+ }
2467
+ return obj;
2468
+ }
2469
+ };
2470
+ exports.Spec = {
2471
+ fromJSON(object) {
2472
+ return {
2473
+ spec: isSet(object.hashedRekordV002) ? { $case: "hashedRekordV002", hashedRekordV002: hashedrekord_1.HashedRekordLogEntryV002.fromJSON(object.hashedRekordV002) } : isSet(object.dsseV002) ? { $case: "dsseV002", dsseV002: dsse_1.DSSELogEntryV002.fromJSON(object.dsseV002) } : void 0
2474
+ };
2475
+ },
2476
+ toJSON(message) {
2477
+ const obj = {};
2478
+ if (message.spec?.$case === "hashedRekordV002") {
2479
+ obj.hashedRekordV002 = hashedrekord_1.HashedRekordLogEntryV002.toJSON(message.spec.hashedRekordV002);
2480
+ } else if (message.spec?.$case === "dsseV002") {
2481
+ obj.dsseV002 = dsse_1.DSSELogEntryV002.toJSON(message.spec.dsseV002);
2482
+ }
2483
+ return obj;
2484
+ }
2485
+ };
2486
+ exports.CreateEntryRequest = {
2487
+ fromJSON(object) {
2488
+ return {
2489
+ spec: isSet(object.hashedRekordRequestV002) ? {
2490
+ $case: "hashedRekordRequestV002",
2491
+ hashedRekordRequestV002: hashedrekord_1.HashedRekordRequestV002.fromJSON(object.hashedRekordRequestV002)
2492
+ } : isSet(object.dsseRequestV002) ? { $case: "dsseRequestV002", dsseRequestV002: dsse_1.DSSERequestV002.fromJSON(object.dsseRequestV002) } : void 0
2493
+ };
2494
+ },
2495
+ toJSON(message) {
2496
+ const obj = {};
2497
+ if (message.spec?.$case === "hashedRekordRequestV002") {
2498
+ obj.hashedRekordRequestV002 = hashedrekord_1.HashedRekordRequestV002.toJSON(message.spec.hashedRekordRequestV002);
2499
+ } else if (message.spec?.$case === "dsseRequestV002") {
2500
+ obj.dsseRequestV002 = dsse_1.DSSERequestV002.toJSON(message.spec.dsseRequestV002);
2501
+ }
2502
+ return obj;
2503
+ }
2504
+ };
2505
+ function isSet(value) {
2506
+ return value !== null && value !== void 0;
2507
+ }
2508
+ }
2509
+ });
2510
+
2511
+ // node_modules/@sigstore/protobuf-specs/dist/rekor/v2/index.js
2512
+ var require_v2 = __commonJS({
2513
+ "node_modules/@sigstore/protobuf-specs/dist/rekor/v2/index.js"(exports) {
2514
+ "use strict";
2515
+ var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
2516
+ if (k2 === void 0) k2 = k;
2517
+ var desc = Object.getOwnPropertyDescriptor(m, k);
2518
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2519
+ desc = { enumerable: true, get: function() {
2520
+ return m[k];
2521
+ } };
2522
+ }
2523
+ Object.defineProperty(o, k2, desc);
2524
+ }) : (function(o, m, k, k2) {
2525
+ if (k2 === void 0) k2 = k;
2526
+ o[k2] = m[k];
2527
+ }));
2528
+ var __exportStar = exports && exports.__exportStar || function(m, exports2) {
2529
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
2530
+ };
2531
+ Object.defineProperty(exports, "__esModule", { value: true });
2532
+ __exportStar(require_dsse3(), exports);
2533
+ __exportStar(require_entry(), exports);
2534
+ __exportStar(require_hashedrekord(), exports);
2535
+ __exportStar(require_verifier(), exports);
2536
+ }
2537
+ });
2538
+
2539
+ // node_modules/@sigstore/verify/dist/tlog/dsse.js
2540
+ var require_dsse4 = __commonJS({
2541
+ "node_modules/@sigstore/verify/dist/tlog/dsse.js"(exports) {
2542
+ "use strict";
2543
+ Object.defineProperty(exports, "__esModule", { value: true });
2544
+ exports.DSSE_API_VERSION_V1 = void 0;
2545
+ exports.verifyDSSETLogBody = verifyDSSETLogBody;
2546
+ exports.verifyDSSETLogBodyV2 = verifyDSSETLogBodyV2;
2547
+ var error_1 = require_error3();
2548
+ exports.DSSE_API_VERSION_V1 = "0.0.1";
2549
+ function verifyDSSETLogBody(tlogEntry, content) {
2550
+ switch (tlogEntry.apiVersion) {
2551
+ case exports.DSSE_API_VERSION_V1:
2552
+ return verifyDSSE001TLogBody(tlogEntry, content);
2553
+ default:
2554
+ throw new error_1.VerificationError({
2555
+ code: "TLOG_BODY_ERROR",
2556
+ message: `unsupported dsse version: ${tlogEntry.apiVersion}`
2557
+ });
2558
+ }
2559
+ }
2560
+ function verifyDSSETLogBodyV2(tlogEntry, content) {
2561
+ const spec = tlogEntry.spec?.spec;
2562
+ if (!spec) {
2563
+ throw new error_1.VerificationError({
2564
+ code: "TLOG_BODY_ERROR",
2565
+ message: `missing dsse spec`
2566
+ });
2567
+ }
2568
+ switch (spec.$case) {
2569
+ case "dsseV002":
2570
+ return verifyDSSE002TLogBody(spec.dsseV002, content);
2571
+ default:
2572
+ throw new error_1.VerificationError({
2573
+ code: "TLOG_BODY_ERROR",
2574
+ message: `unsupported version: ${spec.$case}`
2575
+ });
2576
+ }
2577
+ }
2578
+ function verifyDSSE001TLogBody(tlogEntry, content) {
2579
+ if (tlogEntry.spec.signatures?.length !== 1) {
2580
+ throw new error_1.VerificationError({
2581
+ code: "TLOG_BODY_ERROR",
2582
+ message: "signature count mismatch"
2583
+ });
2584
+ }
2585
+ const tlogSig = tlogEntry.spec.signatures[0].signature;
2586
+ if (!content.compareSignature(Buffer.from(tlogSig, "base64")))
2587
+ throw new error_1.VerificationError({
2588
+ code: "TLOG_BODY_ERROR",
2589
+ message: "tlog entry signature mismatch"
2590
+ });
2591
+ const tlogHash = tlogEntry.spec.payloadHash?.value || "";
2592
+ if (!content.compareDigest(Buffer.from(tlogHash, "hex"))) {
2593
+ throw new error_1.VerificationError({
2594
+ code: "TLOG_BODY_ERROR",
2595
+ message: "DSSE payload hash mismatch"
2596
+ });
2597
+ }
2598
+ }
2599
+ function verifyDSSE002TLogBody(spec, content) {
2600
+ if (spec.signatures?.length !== 1) {
2601
+ throw new error_1.VerificationError({
2602
+ code: "TLOG_BODY_ERROR",
2603
+ message: "signature count mismatch"
2604
+ });
2605
+ }
2606
+ const tlogSig = spec.signatures[0].content;
2607
+ if (!content.compareSignature(tlogSig))
2608
+ throw new error_1.VerificationError({
2609
+ code: "TLOG_BODY_ERROR",
2610
+ message: "tlog entry signature mismatch"
2611
+ });
2612
+ const tlogHash = spec.payloadHash?.digest || Buffer.from("");
2613
+ if (!content.compareDigest(tlogHash)) {
2614
+ throw new error_1.VerificationError({
2615
+ code: "TLOG_BODY_ERROR",
2616
+ message: "DSSE payload hash mismatch"
2617
+ });
2618
+ }
2619
+ }
2620
+ }
2621
+ });
2622
+
2623
+ // node_modules/@sigstore/verify/dist/tlog/hashedrekord.js
2624
+ var require_hashedrekord2 = __commonJS({
2625
+ "node_modules/@sigstore/verify/dist/tlog/hashedrekord.js"(exports) {
2626
+ "use strict";
2627
+ Object.defineProperty(exports, "__esModule", { value: true });
2628
+ exports.HASHEDREKORD_API_VERSION_V1 = void 0;
2629
+ exports.verifyHashedRekordTLogBody = verifyHashedRekordTLogBody;
2630
+ exports.verifyHashedRekordTLogBodyV2 = verifyHashedRekordTLogBodyV2;
2631
+ var error_1 = require_error3();
2632
+ exports.HASHEDREKORD_API_VERSION_V1 = "0.0.1";
2633
+ function verifyHashedRekordTLogBody(tlogEntry, content) {
2634
+ switch (tlogEntry.apiVersion) {
2635
+ case exports.HASHEDREKORD_API_VERSION_V1:
2636
+ return verifyHashedrekord001TLogBody(tlogEntry, content);
2637
+ default:
2638
+ throw new error_1.VerificationError({
2639
+ code: "TLOG_BODY_ERROR",
2640
+ message: `unsupported hashedrekord version: ${tlogEntry.apiVersion}`
2641
+ });
2642
+ }
2643
+ }
2644
+ function verifyHashedRekordTLogBodyV2(tlogEntry, content) {
2645
+ const spec = tlogEntry.spec?.spec;
2646
+ if (!spec) {
2647
+ throw new error_1.VerificationError({
2648
+ code: "TLOG_BODY_ERROR",
2649
+ message: `missing dsse spec`
2650
+ });
2651
+ }
2652
+ switch (spec.$case) {
2653
+ case "hashedRekordV002":
2654
+ return verifyHashedrekord002TLogBody(spec.hashedRekordV002, content);
2655
+ default:
2656
+ throw new error_1.VerificationError({
2657
+ code: "TLOG_BODY_ERROR",
2658
+ message: `unsupported version: ${spec.$case}`
2659
+ });
2660
+ }
2661
+ }
2662
+ function verifyHashedrekord001TLogBody(tlogEntry, content) {
2663
+ const tlogSig = tlogEntry.spec.signature.content || "";
2664
+ if (!content.compareSignature(Buffer.from(tlogSig, "base64"))) {
2665
+ throw new error_1.VerificationError({
2666
+ code: "TLOG_BODY_ERROR",
2667
+ message: "signature mismatch"
2668
+ });
2669
+ }
2670
+ const tlogDigest = tlogEntry.spec.data.hash?.value || "";
2671
+ if (!content.compareSignedDigest(Buffer.from(tlogDigest, "hex"))) {
2672
+ throw new error_1.VerificationError({
2673
+ code: "TLOG_BODY_ERROR",
2674
+ message: "digest mismatch"
2675
+ });
2676
+ }
2677
+ }
2678
+ function verifyHashedrekord002TLogBody(spec, content) {
2679
+ const tlogSig = spec.signature?.content || Buffer.from("");
2680
+ if (!content.compareSignature(tlogSig)) {
2681
+ throw new error_1.VerificationError({
2682
+ code: "TLOG_BODY_ERROR",
2683
+ message: "signature mismatch"
2684
+ });
2685
+ }
2686
+ const tlogHash = spec.data?.digest || Buffer.from("");
2687
+ if (!content.compareSignedDigest(tlogHash)) {
2688
+ throw new error_1.VerificationError({
2689
+ code: "TLOG_BODY_ERROR",
2690
+ message: "digest mismatch"
2691
+ });
2692
+ }
2693
+ }
2694
+ }
2695
+ });
2696
+
2697
+ // node_modules/@sigstore/verify/dist/tlog/intoto.js
2698
+ var require_intoto = __commonJS({
2699
+ "node_modules/@sigstore/verify/dist/tlog/intoto.js"(exports) {
2700
+ "use strict";
2701
+ Object.defineProperty(exports, "__esModule", { value: true });
2702
+ exports.verifyIntotoTLogBody = verifyIntotoTLogBody;
2703
+ var error_1 = require_error3();
2704
+ function verifyIntotoTLogBody(tlogEntry, content) {
2705
+ switch (tlogEntry.apiVersion) {
2706
+ case "0.0.2":
2707
+ return verifyIntoto002TLogBody(tlogEntry, content);
2708
+ default:
2709
+ throw new error_1.VerificationError({
2710
+ code: "TLOG_BODY_ERROR",
2711
+ message: `unsupported intoto version: ${tlogEntry.apiVersion}`
2712
+ });
2713
+ }
2714
+ }
2715
+ function verifyIntoto002TLogBody(tlogEntry, content) {
2716
+ if (tlogEntry.spec.content.envelope.signatures?.length !== 1) {
2717
+ throw new error_1.VerificationError({
2718
+ code: "TLOG_BODY_ERROR",
2719
+ message: "signature count mismatch"
2720
+ });
2721
+ }
2722
+ const tlogSig = base64Decode(tlogEntry.spec.content.envelope.signatures[0].sig);
2723
+ if (!content.compareSignature(Buffer.from(tlogSig, "base64"))) {
2724
+ throw new error_1.VerificationError({
2725
+ code: "TLOG_BODY_ERROR",
2726
+ message: "tlog entry signature mismatch"
2727
+ });
2728
+ }
2729
+ const tlogHash = tlogEntry.spec.content.payloadHash?.value || "";
2730
+ if (!content.compareDigest(Buffer.from(tlogHash, "hex"))) {
2731
+ throw new error_1.VerificationError({
2732
+ code: "TLOG_BODY_ERROR",
2733
+ message: "DSSE payload hash mismatch"
2734
+ });
2735
+ }
2736
+ }
2737
+ function base64Decode(str) {
2738
+ return Buffer.from(str, "base64").toString("utf-8");
2739
+ }
2740
+ }
2741
+ });
2742
+
2743
+ // node_modules/@sigstore/verify/dist/tlog/checkpoint.js
2744
+ var require_checkpoint = __commonJS({
2745
+ "node_modules/@sigstore/verify/dist/tlog/checkpoint.js"(exports) {
2746
+ "use strict";
2747
+ Object.defineProperty(exports, "__esModule", { value: true });
2748
+ exports.LogCheckpoint = void 0;
2749
+ exports.verifyCheckpoint = verifyCheckpoint;
2750
+ var core_1 = require_dist2();
2751
+ var error_1 = require_error3();
2752
+ var CHECKPOINT_SEPARATOR = "\n\n";
2753
+ var SIGNATURE_REGEX = /\u2014 (\S+) (\S+)\n/g;
2754
+ function verifyCheckpoint(entry, tlogs) {
2755
+ const inclusionProof = entry.inclusionProof;
2756
+ const signedNote = SignedNote.fromString(inclusionProof.checkpoint.envelope);
2757
+ const checkpoint = LogCheckpoint.fromString(signedNote.note);
2758
+ if (!verifySignedNote(signedNote, tlogs)) {
2759
+ throw new error_1.VerificationError({
2760
+ code: "TLOG_INCLUSION_PROOF_ERROR",
2761
+ message: "invalid checkpoint signature"
2762
+ });
2763
+ }
2764
+ return checkpoint;
2765
+ }
2766
+ function verifySignedNote(signedNote, tlogs) {
2767
+ const data = Buffer.from(signedNote.note, "utf-8");
2768
+ return signedNote.signatures.some((signature) => {
2769
+ const tlog = tlogs.find((tlog2) => core_1.crypto.bufferEqual(tlog2.logID.subarray(0, 4), signature.keyHint) && // Match the signature name to the base URL of the tlog. The name is
2770
+ // attacker-controlled, so it MUST be compared as a literal substring
2771
+ // and never coerced into a RegExp (as String.prototype.match would).
2772
+ tlog2.baseURL.includes(signature.name));
2773
+ if (!tlog) {
2774
+ return false;
2775
+ }
2776
+ return core_1.crypto.verify(data, tlog.publicKey, signature.signature);
2777
+ });
2778
+ }
2779
+ var SignedNote = class _SignedNote {
2780
+ note;
2781
+ signatures;
2782
+ constructor(note, signatures) {
2783
+ this.note = note;
2784
+ this.signatures = signatures;
2785
+ }
2786
+ // Deserialize a SignedNote from a string
2787
+ static fromString(envelope) {
2788
+ if (!envelope.includes(CHECKPOINT_SEPARATOR)) {
2789
+ throw new error_1.VerificationError({
2790
+ code: "TLOG_INCLUSION_PROOF_ERROR",
2791
+ message: "missing checkpoint separator"
2792
+ });
2793
+ }
2794
+ const split = envelope.indexOf(CHECKPOINT_SEPARATOR);
2795
+ const header = envelope.slice(0, split + 1);
2796
+ const data = envelope.slice(split + CHECKPOINT_SEPARATOR.length);
2797
+ const matches = data.matchAll(SIGNATURE_REGEX);
2798
+ const signatures = Array.from(matches, (match) => {
2799
+ const [, name, signature] = match;
2800
+ const sigBytes = Buffer.from(signature, "base64");
2801
+ if (sigBytes.length < 5) {
2802
+ throw new error_1.VerificationError({
2803
+ code: "TLOG_INCLUSION_PROOF_ERROR",
2804
+ message: "malformed checkpoint signature"
2805
+ });
2806
+ }
2807
+ return {
2808
+ name,
2809
+ keyHint: sigBytes.subarray(0, 4),
2810
+ signature: sigBytes.subarray(4)
2811
+ };
2812
+ });
2813
+ if (signatures.length === 0) {
2814
+ throw new error_1.VerificationError({
2815
+ code: "TLOG_INCLUSION_PROOF_ERROR",
2816
+ message: "no signatures found in checkpoint"
2817
+ });
2818
+ }
2819
+ return new _SignedNote(header, signatures);
2820
+ }
2821
+ };
2822
+ var LogCheckpoint = class _LogCheckpoint {
2823
+ origin;
2824
+ logSize;
2825
+ logHash;
2826
+ rest;
2827
+ constructor(origin, logSize, logHash, rest) {
2828
+ this.origin = origin;
2829
+ this.logSize = logSize;
2830
+ this.logHash = logHash;
2831
+ this.rest = rest;
2832
+ }
2833
+ static fromString(note) {
2834
+ const lines = note.trimEnd().split("\n");
2835
+ if (lines.length < 3) {
2836
+ throw new error_1.VerificationError({
2837
+ code: "TLOG_INCLUSION_PROOF_ERROR",
2838
+ message: "too few lines in checkpoint header"
2839
+ });
2840
+ }
2841
+ const origin = lines[0];
2842
+ let logSize;
2843
+ try {
2844
+ logSize = BigInt(lines[1]);
2845
+ } catch {
2846
+ throw new error_1.VerificationError({
2847
+ code: "TLOG_INCLUSION_PROOF_ERROR",
2848
+ message: "invalid checkpoint log size"
2849
+ });
2850
+ }
2851
+ const rootHash = Buffer.from(lines[2], "base64");
2852
+ const rest = lines.slice(3);
2853
+ return new _LogCheckpoint(origin, logSize, rootHash, rest);
2854
+ }
2855
+ };
2856
+ exports.LogCheckpoint = LogCheckpoint;
2857
+ }
2858
+ });
2859
+
2860
+ // node_modules/@sigstore/verify/dist/tlog/merkle.js
2861
+ var require_merkle = __commonJS({
2862
+ "node_modules/@sigstore/verify/dist/tlog/merkle.js"(exports) {
2863
+ "use strict";
2864
+ Object.defineProperty(exports, "__esModule", { value: true });
2865
+ exports.verifyMerkleInclusion = verifyMerkleInclusion;
2866
+ var core_1 = require_dist2();
2867
+ var error_1 = require_error3();
2868
+ var RFC6962_LEAF_HASH_PREFIX = Buffer.from([0]);
2869
+ var RFC6962_NODE_HASH_PREFIX = Buffer.from([1]);
2870
+ function verifyMerkleInclusion(entry, checkpoint) {
2871
+ const inclusionProof = entry.inclusionProof;
2872
+ let logIndex;
2873
+ try {
2874
+ logIndex = BigInt(inclusionProof.logIndex);
2875
+ } catch {
2876
+ throw new error_1.VerificationError({
2877
+ code: "TLOG_INCLUSION_PROOF_ERROR",
2878
+ message: "invalid inclusion proof log index"
2879
+ });
2880
+ }
2881
+ const treeSize = BigInt(checkpoint.logSize);
2882
+ if (logIndex < 0n || logIndex >= treeSize) {
2883
+ throw new error_1.VerificationError({
2884
+ code: "TLOG_INCLUSION_PROOF_ERROR",
2885
+ message: `invalid index: ${logIndex}`
2886
+ });
2887
+ }
2888
+ const { inner, border } = decompInclProof(logIndex, treeSize);
2889
+ if (inclusionProof.hashes.length !== inner + border) {
2890
+ throw new error_1.VerificationError({
2891
+ code: "TLOG_INCLUSION_PROOF_ERROR",
2892
+ message: "invalid hash count"
2893
+ });
2894
+ }
2895
+ const innerHashes = inclusionProof.hashes.slice(0, inner);
2896
+ const borderHashes = inclusionProof.hashes.slice(inner);
2897
+ const leafHash = hashLeaf(entry.canonicalizedBody);
2898
+ const calculatedHash = chainBorderRight(chainInner(leafHash, innerHashes, logIndex), borderHashes);
2899
+ if (!core_1.crypto.bufferEqual(calculatedHash, checkpoint.logHash)) {
2900
+ throw new error_1.VerificationError({
2901
+ code: "TLOG_INCLUSION_PROOF_ERROR",
2902
+ message: "calculated root hash does not match inclusion proof"
2903
+ });
2904
+ }
2905
+ }
2906
+ function decompInclProof(index, size) {
2907
+ const inner = innerProofSize(index, size);
2908
+ const border = onesCount(index >> BigInt(inner));
2909
+ return { inner, border };
2910
+ }
2911
+ function chainInner(seed, hashes, index) {
2912
+ return hashes.reduce((acc, h, i) => {
2913
+ if (index >> BigInt(i) & BigInt(1)) {
2914
+ return hashChildren(h, acc);
2915
+ } else {
2916
+ return hashChildren(acc, h);
2917
+ }
2918
+ }, seed);
2919
+ }
2920
+ function chainBorderRight(seed, hashes) {
2921
+ return hashes.reduce((acc, h) => hashChildren(h, acc), seed);
2922
+ }
2923
+ function innerProofSize(index, size) {
2924
+ return bitLength(index ^ size - BigInt(1));
2925
+ }
2926
+ function onesCount(num) {
2927
+ return num.toString(2).split("1").length - 1;
2928
+ }
2929
+ function bitLength(n) {
2930
+ if (n === 0n) {
2931
+ return 0;
2932
+ }
2933
+ return n.toString(2).length;
2934
+ }
2935
+ function hashChildren(left, right) {
2936
+ return core_1.crypto.digest("sha256", RFC6962_NODE_HASH_PREFIX, left, right);
2937
+ }
2938
+ function hashLeaf(leaf) {
2939
+ return core_1.crypto.digest("sha256", RFC6962_LEAF_HASH_PREFIX, leaf);
2940
+ }
2941
+ }
2942
+ });
2943
+
2944
+ // node_modules/@sigstore/verify/dist/tlog/set.js
2945
+ var require_set = __commonJS({
2946
+ "node_modules/@sigstore/verify/dist/tlog/set.js"(exports) {
2947
+ "use strict";
2948
+ Object.defineProperty(exports, "__esModule", { value: true });
2949
+ exports.verifyTLogSET = verifyTLogSET;
2950
+ var core_1 = require_dist2();
2951
+ var error_1 = require_error3();
2952
+ var trust_1 = require_trust();
2953
+ function verifyTLogSET(entry, tlogs) {
2954
+ const validTLogs = (0, trust_1.filterTLogAuthorities)(tlogs, {
2955
+ logID: entry.logId.keyId,
2956
+ targetDate: new Date(Number(entry.integratedTime) * 1e3)
2957
+ });
2958
+ const verified = validTLogs.some((tlog) => {
2959
+ const payload = toVerificationPayload(entry);
2960
+ const data = Buffer.from(core_1.json.canonicalize(payload), "utf8");
2961
+ const signature = entry.inclusionPromise.signedEntryTimestamp;
2962
+ return core_1.crypto.verify(data, tlog.publicKey, signature);
2963
+ });
2964
+ if (!verified) {
2965
+ throw new error_1.VerificationError({
2966
+ code: "TLOG_INCLUSION_PROMISE_ERROR",
2967
+ message: "inclusion promise could not be verified"
2968
+ });
2969
+ }
2970
+ }
2971
+ function toVerificationPayload(entry) {
2972
+ const { integratedTime, logIndex, logId, canonicalizedBody } = entry;
2973
+ return {
2974
+ body: canonicalizedBody.toString("base64"),
2975
+ integratedTime: Number(integratedTime),
2976
+ logIndex: Number(logIndex),
2977
+ logID: logId.keyId.toString("hex")
2978
+ };
2979
+ }
2980
+ }
2981
+ });
2982
+
2983
+ // node_modules/@sigstore/verify/dist/tlog/index.js
2984
+ var require_tlog = __commonJS({
2985
+ "node_modules/@sigstore/verify/dist/tlog/index.js"(exports) {
2986
+ "use strict";
2987
+ Object.defineProperty(exports, "__esModule", { value: true });
2988
+ exports.verifyTLogBody = verifyTLogBody;
2989
+ exports.verifyTLogInclusion = verifyTLogInclusion;
2990
+ var v2_1 = require_v2();
2991
+ var error_1 = require_error3();
2992
+ var dsse_1 = require_dsse4();
2993
+ var hashedrekord_1 = require_hashedrekord2();
2994
+ var intoto_1 = require_intoto();
2995
+ var checkpoint_1 = require_checkpoint();
2996
+ var merkle_1 = require_merkle();
2997
+ var set_1 = require_set();
2998
+ function verifyTLogBody(entry, sigContent) {
2999
+ const { kind, version } = entry.kindVersion;
3000
+ let body;
3001
+ try {
3002
+ body = JSON.parse(entry.canonicalizedBody.toString("utf8"));
3003
+ } catch {
3004
+ throw new error_1.VerificationError({
3005
+ code: "TLOG_BODY_ERROR",
3006
+ message: "invalid canonicalized body"
3007
+ });
3008
+ }
3009
+ if (kind !== body.kind || version !== body.apiVersion) {
3010
+ throw new error_1.VerificationError({
3011
+ code: "TLOG_BODY_ERROR",
3012
+ message: `kind/version mismatch - expected: ${kind}/${version}, received: ${body.kind}/${body.apiVersion}`
3013
+ });
3014
+ }
3015
+ switch (kind) {
3016
+ case "dsse":
3017
+ if (version == dsse_1.DSSE_API_VERSION_V1) {
3018
+ return (0, dsse_1.verifyDSSETLogBody)(body, sigContent);
3019
+ } else {
3020
+ const entryRekorV2 = v2_1.Entry.fromJSON(body);
3021
+ return (0, dsse_1.verifyDSSETLogBodyV2)(entryRekorV2, sigContent);
3022
+ }
3023
+ case "intoto":
3024
+ return (0, intoto_1.verifyIntotoTLogBody)(body, sigContent);
3025
+ case "hashedrekord":
3026
+ if (version == hashedrekord_1.HASHEDREKORD_API_VERSION_V1) {
3027
+ return (0, hashedrekord_1.verifyHashedRekordTLogBody)(body, sigContent);
3028
+ } else {
3029
+ const entryRekorV2 = v2_1.Entry.fromJSON(body);
3030
+ return (0, hashedrekord_1.verifyHashedRekordTLogBodyV2)(entryRekorV2, sigContent);
3031
+ }
3032
+ /* istanbul ignore next */
3033
+ default:
3034
+ throw new error_1.VerificationError({
3035
+ code: "TLOG_BODY_ERROR",
3036
+ message: `unsupported kind: ${kind}`
3037
+ });
3038
+ }
3039
+ }
3040
+ function verifyTLogInclusion(entry, tlogAuthorities) {
3041
+ let inclusionVerified = false;
3042
+ if (isTLogEntryWithInclusionPromise(entry)) {
3043
+ (0, set_1.verifyTLogSET)(entry, tlogAuthorities);
3044
+ inclusionVerified = true;
3045
+ }
3046
+ if (isTLogEntryWithInclusionProof(entry)) {
3047
+ const checkpoint = (0, checkpoint_1.verifyCheckpoint)(entry, tlogAuthorities);
3048
+ (0, merkle_1.verifyMerkleInclusion)(entry, checkpoint);
3049
+ inclusionVerified = true;
3050
+ }
3051
+ if (!inclusionVerified) {
3052
+ throw new error_1.VerificationError({
3053
+ code: "TLOG_MISSING_INCLUSION_ERROR",
3054
+ message: "inclusion could not be verified"
3055
+ });
3056
+ }
3057
+ return;
3058
+ }
3059
+ function isTLogEntryWithInclusionPromise(entry) {
3060
+ return entry.inclusionPromise !== void 0;
3061
+ }
3062
+ function isTLogEntryWithInclusionProof(entry) {
3063
+ return entry.inclusionProof !== void 0;
3064
+ }
3065
+ }
3066
+ });
3067
+
3068
+ // node_modules/@sigstore/verify/dist/verifier.js
3069
+ var require_verifier2 = __commonJS({
3070
+ "node_modules/@sigstore/verify/dist/verifier.js"(exports) {
3071
+ "use strict";
3072
+ Object.defineProperty(exports, "__esModule", { value: true });
3073
+ exports.Verifier = void 0;
3074
+ var util_1 = __require("util");
3075
+ var error_1 = require_error3();
3076
+ var key_1 = require_key();
3077
+ var policy_1 = require_policy();
3078
+ var timestamp_1 = require_timestamp2();
3079
+ var tlog_1 = require_tlog();
3080
+ var Verifier = class {
3081
+ trustMaterial;
3082
+ options;
3083
+ constructor(trustMaterial, options = {}) {
3084
+ this.trustMaterial = trustMaterial;
3085
+ this.options = {
3086
+ ctlogThreshold: options.ctlogThreshold ?? 1,
3087
+ tlogThreshold: options.tlogThreshold ?? 1,
3088
+ timestampThreshold: options.timestampThreshold ?? options.tsaThreshold ?? 1,
3089
+ tsaThreshold: 0
3090
+ };
3091
+ }
3092
+ verify(entity, policy) {
3093
+ const timestamps = this.verifyTimestamps(entity);
3094
+ const signer = this.verifySigningKey(entity, timestamps);
3095
+ this.verifyTLogs(entity);
3096
+ this.verifySignature(entity, signer);
3097
+ if (policy) {
3098
+ this.verifyPolicy(policy, signer.identity || {});
3099
+ }
3100
+ return signer;
3101
+ }
3102
+ // Checks that all of the timestamps in the entity are valid and returns them
3103
+ verifyTimestamps(entity) {
3104
+ const timestamps = [];
3105
+ for (const timestamp of entity.timestamps) {
3106
+ switch (timestamp.$case) {
3107
+ case "timestamp-authority":
3108
+ timestamps.push((0, timestamp_1.getTSATimestamp)(timestamp.timestamp, entity.signature.signature, this.trustMaterial.timestampAuthorities));
3109
+ break;
3110
+ case "transparency-log": {
3111
+ const result = (0, timestamp_1.getTLogTimestamp)(timestamp.tlogEntry);
3112
+ if (result) {
3113
+ timestamps.push(result);
3114
+ }
3115
+ break;
3116
+ }
3117
+ }
3118
+ }
3119
+ if (containsDupes(timestamps)) {
3120
+ throw new error_1.VerificationError({
3121
+ code: "TIMESTAMP_ERROR",
3122
+ message: "duplicate timestamp"
3123
+ });
3124
+ }
3125
+ if (timestamps.length < this.options.timestampThreshold) {
3126
+ throw new error_1.VerificationError({
3127
+ code: "TIMESTAMP_ERROR",
3128
+ message: `expected ${this.options.timestampThreshold} timestamps, got ${timestamps.length}`
3129
+ });
3130
+ }
3131
+ return timestamps.map((t) => t.timestamp);
3132
+ }
3133
+ // Checks that the signing key is valid for all of the the supplied timestamps
3134
+ // and returns the signer.
3135
+ verifySigningKey({ key }, timestamps) {
3136
+ switch (key.$case) {
3137
+ case "public-key": {
3138
+ return (0, key_1.verifyPublicKey)(key.hint, timestamps, this.trustMaterial);
3139
+ }
3140
+ case "certificate": {
3141
+ const result = (0, key_1.verifyCertificate)(key.certificate, timestamps, this.trustMaterial);
3142
+ if (containsDupes(result.scts)) {
3143
+ throw new error_1.VerificationError({
3144
+ code: "CERTIFICATE_ERROR",
3145
+ message: "duplicate SCT"
3146
+ });
3147
+ }
3148
+ if (result.scts.length < this.options.ctlogThreshold) {
3149
+ throw new error_1.VerificationError({
3150
+ code: "CERTIFICATE_ERROR",
3151
+ message: `expected ${this.options.ctlogThreshold} SCTs, got ${result.scts.length}`
3152
+ });
3153
+ }
3154
+ return result.signer;
3155
+ }
3156
+ }
3157
+ }
3158
+ // Checks that the tlog entries are valid for the supplied content
3159
+ verifyTLogs({ signature: content, tlogEntries }) {
3160
+ const entryIDs = [];
3161
+ tlogEntries.forEach((entry) => {
3162
+ (0, tlog_1.verifyTLogInclusion)(entry, this.trustMaterial.tlogs);
3163
+ (0, tlog_1.verifyTLogBody)(entry, content);
3164
+ entryIDs.push({ logID: entry.logId.keyId, logIndex: entry.logIndex });
3165
+ });
3166
+ if (containsDupes(entryIDs)) {
3167
+ throw new error_1.VerificationError({
3168
+ code: "TLOG_ERROR",
3169
+ message: "duplicate tlog entry"
3170
+ });
3171
+ }
3172
+ if (entryIDs.length < this.options.tlogThreshold) {
3173
+ throw new error_1.VerificationError({
3174
+ code: "TLOG_ERROR",
3175
+ message: `expected ${this.options.tlogThreshold} tlog entries, got ${entryIDs.length}`
3176
+ });
3177
+ }
3178
+ }
3179
+ // Checks that the signature is valid for the supplied content
3180
+ verifySignature(entity, signer) {
3181
+ if (!entity.signature.verifySignature(signer.key)) {
3182
+ throw new error_1.VerificationError({
3183
+ code: "SIGNATURE_ERROR",
3184
+ message: "signature verification failed"
3185
+ });
3186
+ }
3187
+ }
3188
+ verifyPolicy(policy, identity) {
3189
+ if (policy.subjectAlternativeName) {
3190
+ (0, policy_1.verifySubjectAlternativeName)(policy.subjectAlternativeName, identity.subjectAlternativeName);
3191
+ }
3192
+ if (policy.extensions) {
3193
+ (0, policy_1.verifyExtensions)(policy.extensions, identity.extensions);
3194
+ }
3195
+ if (policy.oids) {
3196
+ (0, policy_1.verifyOIDs)(policy.oids, identity.oids);
3197
+ }
3198
+ }
3199
+ };
3200
+ exports.Verifier = Verifier;
3201
+ function containsDupes(arr) {
3202
+ for (let i = 0; i < arr.length; i++) {
3203
+ for (let j = i + 1; j < arr.length; j++) {
3204
+ if ((0, util_1.isDeepStrictEqual)(arr[i], arr[j])) {
3205
+ return true;
3206
+ }
3207
+ }
3208
+ }
3209
+ return false;
3210
+ }
3211
+ }
3212
+ });
3213
+
3214
+ // node_modules/@sigstore/verify/dist/index.js
3215
+ var require_dist3 = __commonJS({
3216
+ "node_modules/@sigstore/verify/dist/index.js"(exports) {
3217
+ Object.defineProperty(exports, "__esModule", { value: true });
3218
+ exports.Verifier = exports.toTrustMaterial = exports.VerificationError = exports.PolicyError = exports.toSignedEntity = void 0;
3219
+ var bundle_1 = require_bundle();
3220
+ Object.defineProperty(exports, "toSignedEntity", { enumerable: true, get: function() {
3221
+ return bundle_1.toSignedEntity;
3222
+ } });
3223
+ var error_1 = require_error3();
3224
+ Object.defineProperty(exports, "PolicyError", { enumerable: true, get: function() {
3225
+ return error_1.PolicyError;
3226
+ } });
3227
+ Object.defineProperty(exports, "VerificationError", { enumerable: true, get: function() {
3228
+ return error_1.VerificationError;
3229
+ } });
3230
+ var trust_1 = require_trust();
3231
+ Object.defineProperty(exports, "toTrustMaterial", { enumerable: true, get: function() {
3232
+ return trust_1.toTrustMaterial;
3233
+ } });
3234
+ var verifier_1 = require_verifier2();
3235
+ Object.defineProperty(exports, "Verifier", { enumerable: true, get: function() {
3236
+ return verifier_1.Verifier;
3237
+ } });
3238
+ }
3239
+ });
3240
+ export default require_dist3();