@tradejs/cli 3.1.21 → 3.1.22

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.
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/lib/runtimeEvidenceProducer.ts
31
+ var runtimeEvidenceProducer_exports = {};
32
+ __export(runtimeEvidenceProducer_exports, {
33
+ parseRuntimeEvidenceProducer: () => parseRuntimeEvidenceProducer,
34
+ resolveRuntimeEvidenceProducer: () => resolveRuntimeEvidenceProducer
35
+ });
36
+ module.exports = __toCommonJS(runtimeEvidenceProducer_exports);
37
+ var import_node_crypto = require("crypto");
38
+ var import_promises = __toESM(require("fs/promises"));
39
+ var import_node_path = __toESM(require("path"));
40
+ var isRecord = (value) => value != null && typeof value === "object" && !Array.isArray(value);
41
+ var sha256 = (value) => (0, import_node_crypto.createHash)("sha256").update(value).digest("hex");
42
+ var parseRuntimeEvidenceProducer = (value) => {
43
+ const producer = isRecord(value) ? value : null;
44
+ const runtimePackageManifest = isRecord(producer?.runtimePackageManifest) ? producer.runtimePackageManifest : null;
45
+ if (producer?.schemaVersion !== 1 || typeof producer.projectSha !== "string" || !/^[a-f0-9]{40}$/.test(producer.projectSha) || typeof producer.imageDigest !== "string" || !/^sha256:[a-f0-9]{64}$/.test(producer.imageDigest) || runtimePackageManifest?.file !== "runtime-package-manifest.json" || typeof runtimePackageManifest.sha256 !== "string" || !/^[a-f0-9]{64}$/.test(runtimePackageManifest.sha256)) {
46
+ throw new Error("Runtime evidence producer image identity is invalid");
47
+ }
48
+ return producer;
49
+ };
50
+ var resolveRuntimeEvidenceProducer = async ({
51
+ projectRoot,
52
+ required
53
+ }) => {
54
+ const projectSha = String(process.env.TRADEJS_PROJECT_SHA ?? "").trim();
55
+ const imageDigest = String(
56
+ process.env.TRADEJS_PROJECT_IMAGE_DIGEST ?? ""
57
+ ).trim();
58
+ if (!projectSha && !imageDigest && !required) {
59
+ return null;
60
+ }
61
+ if (!/^[a-f0-9]{40}$/.test(projectSha)) {
62
+ throw new Error(
63
+ "TRADEJS_PROJECT_SHA must be a full lowercase Git SHA before publishing runtime evidence"
64
+ );
65
+ }
66
+ if (!/^sha256:[a-f0-9]{64}$/.test(imageDigest)) {
67
+ throw new Error(
68
+ "TRADEJS_PROJECT_IMAGE_DIGEST must be an immutable sha256 digest before publishing runtime evidence"
69
+ );
70
+ }
71
+ const manifestPath = import_node_path.default.join(projectRoot, "runtime-package-manifest.json");
72
+ let manifest;
73
+ try {
74
+ manifest = await import_promises.default.readFile(manifestPath);
75
+ } catch (error) {
76
+ if (!required && error.code === "ENOENT") {
77
+ return null;
78
+ }
79
+ throw new Error(
80
+ `Runtime package manifest is required for runtime evidence: ${manifestPath}`,
81
+ { cause: error }
82
+ );
83
+ }
84
+ return {
85
+ schemaVersion: 1,
86
+ projectSha,
87
+ imageDigest,
88
+ runtimePackageManifest: {
89
+ file: "runtime-package-manifest.json",
90
+ sha256: sha256(manifest)
91
+ }
92
+ };
93
+ };
94
+ // Annotate the CommonJS export names for ESM import in node:
95
+ 0 && (module.exports = {
96
+ parseRuntimeEvidenceProducer,
97
+ resolveRuntimeEvidenceProducer
98
+ });
@@ -377,7 +377,8 @@ var markRuntimeEvidenceBundleProcessed = async ({
377
377
  evidenceRoot,
378
378
  deploymentId,
379
379
  bundleDir,
380
- scorecardPath
380
+ scorecardPath,
381
+ runtimeFeedback
381
382
  }) => {
382
383
  const safeDeploymentId = safeSegment(deploymentId, "production");
383
384
  const verified = await verifyRuntimeEvidenceBundle(bundleDir);
@@ -390,11 +391,15 @@ var markRuntimeEvidenceBundleProcessed = async ({
390
391
  const finalPath = receiptPath(receiptsRoot, verified.manifest.artifactId);
391
392
  const temporaryPath = `${finalPath}.tmp-${process.pid}`;
392
393
  const receipt = {
393
- schemaVersion: 1,
394
+ schemaVersion: runtimeFeedback ? 2 : 1,
394
395
  artifactId: verified.manifest.artifactId,
395
396
  payloadSha256: verified.manifest.payload.sha256,
396
397
  processedAt: Date.now(),
397
- scorecardPath: scorecardPath ?? null
398
+ scorecardPath: scorecardPath ?? null,
399
+ ...runtimeFeedback ? {
400
+ runtimeFeedbackArtifactId: runtimeFeedback.artifactId,
401
+ replayEvidenceSha256: runtimeFeedback.replayEvidenceSha256
402
+ } : {}
398
403
  };
399
404
  await import_promises2.default.mkdir(receiptsRoot, { recursive: true });
400
405
  await import_promises2.default.writeFile(