@tokenoftrust/storefront-runner 2.0.2 → 2.0.3

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 (117) hide show
  1. package/package.json +1 -1
  2. package/scripts/lib/tenant-dirs.mjs +80 -0
  3. package/scripts/tenant/lint-embeds.mjs +180 -0
  4. package/scripts/tenant/materialize-tenant-content.mjs +533 -0
  5. package/scripts/tenant/validate.mjs +837 -0
  6. package/apps/storefront/scripts/build-v84-clean-clone-standalone.mjs +0 -68
  7. package/apps/storefront/scripts/deny-v84-clean-clone-standalone-capabilities.mjs +0 -111
  8. package/apps/storefront/scripts/deny-v84-dogfood-capabilities.mjs +0 -2
  9. package/apps/storefront/scripts/deny-v84-lifecycle-capabilities.mjs +0 -247
  10. package/apps/storefront/scripts/dogfood-v84-nonportable-routes.ts +0 -73
  11. package/apps/storefront/scripts/fixed-v84-native-install-producer.ts +0 -79
  12. package/apps/storefront/scripts/generated/v84-clean-clone-replay.bundle.mjs +0 -10982
  13. package/apps/storefront/scripts/import-v84-through-ws2.ts +0 -38
  14. package/apps/storefront/scripts/initialize-v84-lifecycle-tooling-dependency.ts +0 -2
  15. package/apps/storefront/scripts/initialize-v84-lifecycle-tooling.ts +0 -4
  16. package/apps/storefront/scripts/install-v84-native-through-ws1.ts +0 -185
  17. package/apps/storefront/scripts/prove-clone-isolation.ts +0 -506
  18. package/apps/storefront/scripts/replay-v84-clean-clone-pass.ts +0 -148
  19. package/apps/storefront/scripts/replay-v84-clean-clone-standalone.ts +0 -35
  20. package/apps/storefront/scripts/replay-v84-clean-clone.ts +0 -214
  21. package/apps/storefront/scripts/run-fixed-v84-native-install-producer.mjs +0 -18
  22. package/apps/storefront/scripts/run-v84-clone-isolation-proof.mjs +0 -18
  23. package/apps/storefront/scripts/run-v84-clone-lifecycle-proof.mjs +0 -18
  24. package/apps/storefront/scripts/run-v84-import-through-ws2-proof.mjs +0 -17
  25. package/apps/storefront/scripts/run-v84-nonportable-route-dogfood.mjs +0 -15
  26. package/apps/storefront/scripts/sanitize-v84-proof-environment.mjs +0 -21
  27. package/apps/storefront/scripts/v84CleanCloneGraphPin.ts +0 -42
  28. package/apps/storefront/scripts/v84CleanCloneSourceGraph.ts +0 -145
  29. package/apps/storefront/scripts/validate-v84-clone-lifecycle.ts +0 -18
  30. package/apps/storefront/src/components/admin/AdminAIWorkflowsTab.astro +0 -531
  31. package/apps/storefront/src/components/admin/AdminBlogDetailRail.astro +0 -878
  32. package/apps/storefront/src/components/admin/AdminBlogTab.astro +0 -1435
  33. package/apps/storefront/src/components/admin/AdminCheckoutSettingsPanel.astro +0 -226
  34. package/apps/storefront/src/components/admin/AdminCustomersTab.astro +0 -593
  35. package/apps/storefront/src/components/admin/AdminFulfillmentTab.astro +0 -465
  36. package/apps/storefront/src/components/admin/AdminIntegrationsTab.astro +0 -105
  37. package/apps/storefront/src/components/admin/AdminProductsTab.astro +0 -901
  38. package/apps/storefront/src/components/admin/AdminPublishTab.astro +0 -2983
  39. package/apps/storefront/src/components/admin/AdminReportingTab.astro +0 -435
  40. package/apps/storefront/src/components/admin/AdminSettingsTab.astro +0 -782
  41. package/apps/storefront/src/components/admin/AdminSubscriptionsTab.astro +0 -611
  42. package/apps/storefront/src/components/admin/orders/OrdersWorkspace.astro +0 -1223
  43. package/apps/storefront/src/lib/dev/cockpitStore.ts +0 -57
  44. package/apps/storefront/src/lib/publish/adminPublishTab.ts +0 -4625
  45. package/apps/storefront/src/lib/publish/apex-readiness.ts +0 -360
  46. package/apps/storefront/src/lib/publish/buildStream.ts +0 -269
  47. package/apps/storefront/src/lib/publish/collapsePersistence.ts +0 -72
  48. package/apps/storefront/src/lib/publish/dispatchHealth.ts +0 -267
  49. package/apps/storefront/src/lib/publish/domainState.ts +0 -360
  50. package/apps/storefront/src/lib/publish/lifecycleState.ts +0 -369
  51. package/apps/storefront/src/lib/publish/liveReleaseSummary.ts +0 -29
  52. package/apps/storefront/src/lib/publish/mergeDoctorOnFailure.ts +0 -78
  53. package/apps/storefront/src/lib/publish/mergeHealthBanner.ts +0 -62
  54. package/apps/storefront/src/lib/publish/mergeRowFindings.ts +0 -124
  55. package/apps/storefront/src/lib/publish/mergeSupportEscalation.ts +0 -75
  56. package/apps/storefront/src/lib/publish/panelPolling.ts +0 -78
  57. package/apps/storefront/src/lib/publish/publish-guard.ts +0 -88
  58. package/apps/storefront/src/lib/publish/publishFormat.ts +0 -165
  59. package/apps/storefront/src/lib/publish/publishHero.ts +0 -177
  60. package/apps/storefront/src/lib/publish/reviewRelease/changeState.ts +0 -66
  61. package/apps/storefront/src/lib/publish/reviewRelease/copy.ts +0 -141
  62. package/apps/storefront/src/lib/publish/reviewRelease/index.ts +0 -41
  63. package/apps/storefront/src/lib/publish/reviewRelease/permissions.ts +0 -47
  64. package/apps/storefront/src/lib/publish/reviewRelease/releaseState.ts +0 -42
  65. package/apps/storefront/src/lib/publish/reviewRelease/types.ts +0 -59
  66. package/apps/storefront/src/lib/publish/reviewRelease/viewModel.ts +0 -440
  67. package/apps/storefront/src/lib/publish/reviewReleaseWorkspace/actions.ts +0 -161
  68. package/apps/storefront/src/lib/publish/reviewReleaseWorkspace/controller.ts +0 -325
  69. package/apps/storefront/src/lib/publish/reviewReleaseWorkspace/render.ts +0 -241
  70. package/apps/storefront/src/lib/publish/shipWorkspace.ts +0 -439
  71. package/apps/storefront/src/lib/publish/sseRoute.ts +0 -119
  72. package/apps/storefront/src/lib/publish/stageBundleUpload.ts +0 -215
  73. package/apps/storefront/src/lib/publish/streamLogConsole.ts +0 -142
  74. package/apps/storefront/src/lib/publish/versionNumber.ts +0 -52
  75. package/apps/storefront/src/pages/admin/ops-timeline.astro +0 -420
  76. package/apps/storefront/src/pages/admin/review-release.astro +0 -265
  77. package/apps/storefront/src/pages/admin/select.astro +0 -96
  78. package/apps/storefront/src/pages/admin.astro +0 -570
  79. package/apps/storefront/src/pages/api/apps/admin/credentials/rotate.ts +0 -86
  80. package/apps/storefront/src/pages/api/apps/admin/gtm-migration-install.ts +0 -174
  81. package/apps/storefront/src/pages/api/apps/admin/gtm-migration.ts +0 -96
  82. package/apps/storefront/src/pages/api/apps/admin/health.ts +0 -44
  83. package/apps/storefront/src/pages/api/apps/admin/install.ts +0 -125
  84. package/apps/storefront/src/pages/api/apps/admin/integration-lifecycle.ts +0 -118
  85. package/apps/storefront/src/pages/api/apps/admin/integrations.ts +0 -89
  86. package/apps/storefront/src/pages/api/apps/admin/list.ts +0 -26
  87. package/apps/storefront/src/pages/api/apps/admin/platform-adapters.ts +0 -85
  88. package/apps/storefront/src/pages/api/apps/admin/resume.ts +0 -79
  89. package/apps/storefront/src/pages/api/apps/admin/suspend.ts +0 -80
  90. package/apps/storefront/src/pages/api/apps/admin/uninstall.ts +0 -98
  91. package/apps/storefront/src/pages/api/apps/admin/update.ts +0 -126
  92. package/apps/storefront/src/pages/api/apps/admin/webhooks/deliveries/[deliveryId]/replay.ts +0 -70
  93. package/apps/storefront/src/pages/api/apps/admin/webhooks/deliveries.ts +0 -51
  94. package/apps/storefront/src/pages/api/apps/internal/order-forward.ts +0 -255
  95. package/apps/storefront/src/pages/api/apps/oauth/token.ts +0 -87
  96. package/apps/storefront/src/pages/api/apps/v1/attribution.ts +0 -162
  97. package/apps/storefront/src/pages/api/apps/v1/catalog/products/[handle].ts +0 -39
  98. package/apps/storefront/src/pages/api/apps/v1/catalog/products.ts +0 -49
  99. package/apps/storefront/src/pages/api/apps/v1/health.ts +0 -32
  100. package/apps/storefront/src/pages/api/apps/v1/inventory.ts +0 -59
  101. package/apps/storefront/src/pages/api/apps/v1/orders/[id].ts +0 -48
  102. package/apps/storefront/src/pages/api/apps/v1/orders.ts +0 -73
  103. package/apps/storefront/src/pages/api/apps/v1/reports.ts +0 -21
  104. package/apps/storefront/src/pages/api/apps/v1/webhooks/deliveries/[deliveryId]/replay.ts +0 -74
  105. package/apps/storefront/src/pages/api/apps/v1/webhooks/deliveries.ts +0 -47
  106. package/apps/storefront/src/pages/api/cache-purge.ts +0 -55
  107. package/apps/storefront/src/pages/api/compliance/tamper.ts +0 -88
  108. package/apps/storefront/src/pages/api/dashboard/enter-vendor.ts +0 -154
  109. package/apps/storefront/src/pages/api/dashboard/vendor-search.ts +0 -120
  110. package/apps/storefront/src/pages/api/integrations/v1/[operation].ts +0 -108
  111. package/apps/storefront/src/pages/api/publish/stage-bundle.ts +0 -70
  112. package/apps/storefront/src/pages/api/test/dev-session.ts +0 -133
  113. package/apps/storefront/src/pages/cockpit.astro +0 -1548
  114. package/apps/storefront/src/pages/dashboard/[appDomain]/apps/index.astro +0 -119
  115. package/apps/storefront/src/pages/dashboard/[appDomain]/index.astro +0 -105
  116. package/apps/storefront/src/pages/dashboard/[appDomain]/team.astro +0 -177
  117. package/apps/storefront/src/pages/dashboard/index.astro +0 -160
@@ -1,68 +0,0 @@
1
- /** Deterministically build the committed runtime-only clean-clone replay snapshot. */
2
- import { readFileSync, writeFileSync } from "node:fs";
3
- import { createRequire } from "node:module";
4
- import { dirname, resolve } from "node:path";
5
- import { fileURLToPath } from "node:url";
6
-
7
- const scriptsDir = dirname(fileURLToPath(import.meta.url));
8
- const storefrontDir = dirname(scriptsDir);
9
- const repositoryRoot = resolve(storefrontDir, "../..");
10
- const outputPath = resolve(repositoryRoot, "apps/storefront/scripts/generated/v84-clean-clone-replay.bundle.mjs");
11
-
12
- export async function buildV84CleanCloneStandaloneBytes() {
13
- const require = createRequire(import.meta.url);
14
- const tsxRequire = createRequire(require.resolve("tsx/package.json"));
15
- const esbuild = tsxRequire("esbuild");
16
- if (tsxRequire("esbuild/package.json").version !== "0.28.1") {
17
- throw new Error("The pinned standalone replay bundler changed.");
18
- }
19
- const fixture = readFileSync(resolve(
20
- repositoryRoot,
21
- "packages/public-runtime/tests/gtm-migration/fixtures/gtm-sample-container-v84.redacted.json",
22
- ), "utf8");
23
- const runtimeLoaderPath = resolve(
24
- repositoryRoot,
25
- "packages/public-runtime/src/integration/lifecycle-boot.ts",
26
- );
27
- const result = await esbuild.build({
28
- absWorkingDir: repositoryRoot,
29
- entryPoints: ["apps/storefront/scripts/replay-v84-clean-clone-standalone.ts"],
30
- outfile: "apps/storefront/scripts/generated/v84-clean-clone-replay.bundle.mjs",
31
- bundle: true,
32
- write: false,
33
- platform: "node",
34
- format: "esm",
35
- target: "node24",
36
- charset: "utf8",
37
- legalComments: "none",
38
- sourcemap: false,
39
- treeShaking: true,
40
- plugins: [{
41
- name: "remove-unused-standalone-runtime-loader",
42
- setup(build) {
43
- build.onLoad({ filter: /lifecycle-boot\.ts$/ }, (args) => {
44
- if (args.path !== runtimeLoaderPath) {
45
- throw new Error("The standalone runtime-loader removal target changed.");
46
- }
47
- return { contents: "export {};\n", loader: "ts" };
48
- });
49
- },
50
- }],
51
- define: { __V84_FIXED_FIXTURE_TEXT__: JSON.stringify(fixture) },
52
- logLevel: "silent",
53
- });
54
- if (result.outputFiles.length !== 1) throw new Error("The standalone replay build output changed.");
55
- const bytes = result.outputFiles[0].contents;
56
- const source = Buffer.from(bytes).toString("utf8");
57
- const loaderMatch = source.match(/\bimport\s*\(|\b(?:createRequire|tsImport)\s*\(/);
58
- if (loaderMatch) {
59
- throw new Error(`The standalone replay contains a dynamic module loader: ${loaderMatch[0]}`);
60
- }
61
- return bytes;
62
- }
63
-
64
- const invokedPath = fileURLToPath(import.meta.url) === process.argv[1];
65
- if (invokedPath) {
66
- if (process.argv.length !== 2) throw new Error("The standalone replay build accepts no arguments.");
67
- writeFileSync(outputPath, await buildV84CleanCloneStandaloneBytes());
68
- }
@@ -1,111 +0,0 @@
1
- /** Install the no-network/no-process/no-filesystem-mutation boundary inside the attested bundle. */
2
- import childProcess from "node:child_process";
3
- import cluster from "node:cluster";
4
- import dgram from "node:dgram";
5
- import dns from "node:dns";
6
- import fs from "node:fs";
7
- import http from "node:http";
8
- import http2 from "node:http2";
9
- import https from "node:https";
10
- import net from "node:net";
11
- import tls from "node:tls";
12
- import vm from "node:vm";
13
- import workerThreads from "node:worker_threads";
14
- import { syncBuiltinESMExports } from "node:module";
15
-
16
- const MESSAGE = "Capability access is disabled for the fixed clean-clone replay.";
17
- const MUTATION_MESSAGE = "Mutation capability is disabled for the fixed clean-clone replay.";
18
-
19
- function deny() {
20
- throw new Error(MESSAGE);
21
- }
22
- function denyMutation() {
23
- throw new Error(MUTATION_MESSAGE);
24
- }
25
- function replace(target, name, value = deny) {
26
- if (typeof target[name] !== "function") return;
27
- Object.defineProperty(target, name, { configurable: false, enumerable: true, writable: false, value });
28
- }
29
-
30
- export async function installV84CleanCloneStandaloneCapabilityBoundary() {
31
- replace(globalThis, "fetch");
32
- replace(globalThis, "WebSocket");
33
- replace(globalThis, "EventSource");
34
- replace(globalThis, "Worker");
35
- if (typeof process.execve === "function") replace(process, "execve");
36
- for (const target of [http, https]) {
37
- replace(target, "request");
38
- replace(target, "get");
39
- replace(target, "ClientRequest");
40
- }
41
- replace(http2, "connect");
42
- replace(net, "connect");
43
- replace(net, "createConnection");
44
- replace(net.Socket.prototype, "connect");
45
- replace(tls, "connect");
46
- replace(tls.TLSSocket.prototype, "connect");
47
- replace(dgram, "createSocket");
48
- replace(dgram, "Socket");
49
- for (const method of [
50
- "lookup", "lookupService", "resolve", "resolve4", "resolve6", "resolveAny", "resolveCaa",
51
- "resolveCname", "resolveMx", "resolveNaptr", "resolveNs", "resolvePtr", "resolveSoa", "resolveSrv",
52
- "resolveTlsa", "resolveTxt", "reverse",
53
- ]) {
54
- replace(dns, method);
55
- replace(dns.promises, method);
56
- }
57
- replace(dns, "Resolver");
58
- replace(dns.promises, "Resolver");
59
- for (const method of ["exec", "execFile", "execFileSync", "execSync", "fork", "spawn", "spawnSync"]) {
60
- replace(childProcess, method);
61
- }
62
- replace(childProcess.ChildProcess.prototype, "spawn");
63
- replace(childProcess, "ChildProcess");
64
- replace(cluster, "fork");
65
- for (const method of ["runInContext", "runInNewContext", "runInThisContext"]) {
66
- replace(vm.Script.prototype, method);
67
- }
68
- for (const method of [
69
- "Script", "compileFunction", "createScript", "runInContext", "runInNewContext", "runInThisContext",
70
- ]) replace(vm, method);
71
- replace(workerThreads, "Worker");
72
-
73
- const WRITE_OPEN_FLAGS = fs.constants.O_WRONLY | fs.constants.O_RDWR |
74
- fs.constants.O_CREAT | fs.constants.O_TRUNC | fs.constants.O_APPEND;
75
- const readOnlyFlags = (flags) => typeof flags === "number"
76
- ? (flags & WRITE_OPEN_FLAGS) === 0
77
- : flags === "r" || flags === "rs" || flags === "sr";
78
- const guardedOpen = (original) => function (path, flags, ...rest) {
79
- if (!readOnlyFlags(flags)) return denyMutation();
80
- return Reflect.apply(original, this, [path, flags, ...rest]);
81
- };
82
- const originalOpen = fs.open;
83
- const originalOpenSync = fs.openSync;
84
- const originalPromiseOpen = fs.promises.open;
85
- const guardFileHandle = await originalPromiseOpen(process.execPath, "r");
86
- const fileHandlePrototype = Object.getPrototypeOf(guardFileHandle);
87
- await guardFileHandle.close();
88
- for (const method of [
89
- "appendFile", "appendFileSync", "chmod", "chmodSync", "chown", "chownSync",
90
- "copyFile", "copyFileSync", "cp", "cpSync", "createWriteStream", "link", "linkSync",
91
- "fchmod", "fchmodSync", "fchown", "fchownSync", "fdatasync", "fdatasyncSync",
92
- "fsync", "fsyncSync", "ftruncate", "ftruncateSync", "futimes", "futimesSync",
93
- "lchmod", "lchmodSync", "lchown", "lchownSync", "lutimes", "lutimesSync",
94
- "mkdir", "mkdirSync", "mkdtemp", "mkdtempSync", "mkdtempDisposable",
95
- "mkdtempDisposableSync", "openAsBlob", "rename", "renameSync", "rm", "rmSync",
96
- "rmdir", "rmdirSync", "symlink", "symlinkSync", "truncate", "truncateSync",
97
- "unlink", "unlinkSync", "utimes", "utimesSync", "write", "writeFile", "writeFileSync",
98
- "writeSync", "writev", "writevSync", "FileWriteStream", "WriteStream",
99
- ]) {
100
- replace(fs, method, denyMutation);
101
- replace(fs.promises, method, denyMutation);
102
- }
103
- for (const method of [
104
- "appendFile", "chmod", "chown", "createWriteStream", "datasync", "sync", "truncate",
105
- "utimes", "write", "writeFile", "writev",
106
- ]) replace(fileHandlePrototype, method, denyMutation);
107
- replace(fs, "open", guardedOpen(originalOpen));
108
- replace(fs, "openSync", guardedOpen(originalOpenSync));
109
- replace(fs.promises, "open", guardedOpen(originalPromiseOpen));
110
- syncBuiltinESMExports();
111
- }
@@ -1,2 +0,0 @@
1
- /** The common v84 proof guard includes filesystem mutation denial. */
2
- import "./deny-v84-lifecycle-capabilities.mjs";
@@ -1,247 +0,0 @@
1
- /** Fail-closed capability prelude for the fixed offline v84 lifecycle proof. */
2
- import childProcess from "node:child_process";
3
- import cluster from "node:cluster";
4
- import dgram from "node:dgram";
5
- import dns from "node:dns";
6
- import fs from "node:fs";
7
- import http from "node:http";
8
- import http2 from "node:http2";
9
- import https from "node:https";
10
- import net from "node:net";
11
- import tls from "node:tls";
12
- import vm from "node:vm";
13
- import workerThreads from "node:worker_threads";
14
- import { fileURLToPath } from "node:url";
15
- import { createRequire, syncBuiltinESMExports } from "node:module";
16
-
17
- const MESSAGE = "Capability access is disabled for the fixed lifecycle proof.";
18
- const MUTATION_MESSAGE = "Mutation capability is disabled for the fixed nonportable-route dogfood proof.";
19
- const PRODUCER_CAPABILITY = Symbol.for("tot.v84.lifecycle-producer-capability");
20
- let producerAvailable = globalThis[PRODUCER_CAPABILITY] === "allow-exact-native-install-producer";
21
- Reflect.deleteProperty(globalThis, PRODUCER_CAPABILITY);
22
- const PRODUCER_BOOTSTRAP_PATH = fileURLToPath(
23
- new URL("./run-fixed-v84-native-install-producer.mjs", import.meta.url),
24
- );
25
- const require = createRequire(import.meta.url);
26
- const tsxRequire = createRequire(require.resolve("tsx/package.json"));
27
- const ESBUILD_WORKER_PATH = tsxRequire.resolve("esbuild");
28
- const ESBUILD_VERSION = tsxRequire("esbuild/package.json").version;
29
- const ESBUILD_DEFAULT_WORKING_DIRECTORY = process.cwd();
30
- const ESBUILD_WORKER_ENV = Object.freeze(Object.fromEntries(
31
- Object.entries(process.env).filter(([name]) => name !== "ESBUILD_BINARY_PATH"),
32
- ));
33
- if (Object.prototype.hasOwnProperty.call(ESBUILD_WORKER_ENV, "ESBUILD_BINARY_PATH")) {
34
- throw new Error("Capability guard could not sanitize the tooling environment.");
35
- }
36
- const NODE_EXECUTABLE = process.execPath;
37
- const PRODUCER_TIMEOUT_MS = 20_000;
38
- const originalSpawnSync = childProcess.spawnSync;
39
- const OriginalWorker = workerThreads.Worker;
40
- function deny(..._args) {
41
- throw new Error(MESSAGE);
42
- }
43
- const replace = (target, name, value = deny) => {
44
- Object.defineProperty(target, name, {
45
- configurable: false,
46
- enumerable: true,
47
- writable: false,
48
- value,
49
- });
50
- };
51
-
52
- const producerArgs = Object.freeze([PRODUCER_BOOTSTRAP_PATH]);
53
- const producerOptions = Object.freeze({
54
- encoding: "utf8",
55
- env: Object.freeze({}),
56
- timeout: PRODUCER_TIMEOUT_MS,
57
- maxBuffer: 16 * 1024 * 1024,
58
- });
59
- const hasExactDataProperties = (value, expected) => {
60
- if (value === null || typeof value !== "object") return false;
61
- const descriptors = Object.getOwnPropertyDescriptors(value);
62
- const keys = Reflect.ownKeys(descriptors);
63
- if (keys.length !== Reflect.ownKeys(expected).length) return false;
64
- return keys.every((key) => {
65
- const descriptor = descriptors[key];
66
- return Object.prototype.hasOwnProperty.call(expected, key) &&
67
- descriptor !== undefined && "value" in descriptor && descriptor.value === expected[key];
68
- });
69
- };
70
- const guardedSpawnSync = (command, args, options) => {
71
- try {
72
- if (!producerAvailable) return deny();
73
- const exactArgs = Array.isArray(args) && hasExactDataProperties(args, {
74
- 0: PRODUCER_BOOTSTRAP_PATH,
75
- length: 1,
76
- });
77
- const optionDescriptors = options !== null && typeof options === "object"
78
- ? Object.getOwnPropertyDescriptors(options)
79
- : {};
80
- const env = optionDescriptors.env && "value" in optionDescriptors.env
81
- ? optionDescriptors.env.value
82
- : undefined;
83
- const exactOptions = hasExactDataProperties(options, {
84
- encoding: "utf8",
85
- env,
86
- timeout: PRODUCER_TIMEOUT_MS,
87
- maxBuffer: 16 * 1024 * 1024,
88
- }) && hasExactDataProperties(env, {});
89
- if (command !== NODE_EXECUTABLE || !exactArgs || !exactOptions) return deny();
90
- } catch {
91
- return deny();
92
- }
93
- producerAvailable = false;
94
- return originalSpawnSync(NODE_EXECUTABLE, [...producerArgs], {
95
- ...producerOptions,
96
- env: { ...producerOptions.env },
97
- });
98
- };
99
- let esbuildWorkerStarted = false;
100
- const guardedWorker = function (filename, options) {
101
- try {
102
- const optionDescriptors = options !== null && typeof options === "object"
103
- ? Object.getOwnPropertyDescriptors(options)
104
- : {};
105
- const workerData = optionDescriptors.workerData && "value" in optionDescriptors.workerData
106
- ? optionDescriptors.workerData.value
107
- : undefined;
108
- const transferList = optionDescriptors.transferList && "value" in optionDescriptors.transferList
109
- ? optionDescriptors.transferList.value
110
- : undefined;
111
- const execArgv = optionDescriptors.execArgv && "value" in optionDescriptors.execArgv
112
- ? optionDescriptors.execArgv.value
113
- : undefined;
114
- const dataDescriptors = workerData !== null && typeof workerData === "object"
115
- ? Object.getOwnPropertyDescriptors(workerData)
116
- : {};
117
- const port = dataDescriptors.workerPort && "value" in dataDescriptors.workerPort
118
- ? dataDescriptors.workerPort.value
119
- : undefined;
120
- const exact = !esbuildWorkerStarted && filename === ESBUILD_WORKER_PATH &&
121
- port instanceof workerThreads.MessagePort &&
122
- hasExactDataProperties(workerData, {
123
- workerPort: port,
124
- defaultWD: ESBUILD_DEFAULT_WORKING_DIRECTORY,
125
- esbuildVersion: ESBUILD_VERSION,
126
- }) &&
127
- hasExactDataProperties(transferList, { 0: port, length: 1 }) &&
128
- hasExactDataProperties(execArgv, { length: 0 }) &&
129
- hasExactDataProperties(options, { workerData, transferList, execArgv });
130
- if (!exact) return deny();
131
- esbuildWorkerStarted = true;
132
- return new OriginalWorker(ESBUILD_WORKER_PATH, {
133
- workerData: {
134
- workerPort: port,
135
- defaultWD: ESBUILD_DEFAULT_WORKING_DIRECTORY,
136
- esbuildVersion: ESBUILD_VERSION,
137
- },
138
- transferList: [port],
139
- execArgv: [],
140
- env: { ...ESBUILD_WORKER_ENV },
141
- });
142
- } catch {
143
- return deny();
144
- }
145
- };
146
-
147
- replace(globalThis, "fetch");
148
- replace(globalThis, "WebSocket");
149
- replace(globalThis, "EventSource");
150
- replace(globalThis, "Worker");
151
- if (typeof process.execve === "function") replace(process, "execve");
152
- replace(http, "request");
153
- replace(http, "get");
154
- replace(http, "ClientRequest");
155
- replace(https, "request");
156
- replace(https, "get");
157
- replace(http2, "connect");
158
- replace(net, "connect");
159
- replace(net, "createConnection");
160
- replace(net.Socket.prototype, "connect");
161
- replace(tls, "connect");
162
- replace(tls.TLSSocket.prototype, "connect");
163
- replace(dgram, "createSocket");
164
- replace(dgram, "Socket");
165
-
166
- const dnsMethods = [
167
- "lookup", "lookupService", "resolve", "resolve4", "resolve6", "resolveAny",
168
- "resolveCaa", "resolveCname", "resolveMx", "resolveNaptr", "resolveNs",
169
- "resolvePtr", "resolveSoa", "resolveSrv", "resolveTlsa", "resolveTxt", "reverse",
170
- ];
171
- for (const method of dnsMethods) {
172
- replace(dns, method);
173
- replace(dns.promises, method);
174
- }
175
- replace(dns, "Resolver");
176
- replace(dns.promises, "Resolver");
177
-
178
- for (const method of ["exec", "execFile", "execFileSync", "execSync", "fork", "spawn"]) {
179
- replace(childProcess, method);
180
- }
181
- replace(childProcess.ChildProcess.prototype, "spawn");
182
- replace(childProcess, "ChildProcess");
183
- replace(childProcess, "spawnSync", guardedSpawnSync);
184
- replace(cluster, "fork");
185
- replace(vm.Script.prototype, "runInContext");
186
- replace(vm.Script.prototype, "runInNewContext");
187
- replace(vm.Script.prototype, "runInThisContext");
188
- for (const method of [
189
- "Script", "compileFunction", "createScript", "runInContext", "runInNewContext", "runInThisContext",
190
- ]) {
191
- replace(vm, method);
192
- }
193
- replace(workerThreads, "Worker", guardedWorker);
194
-
195
- function denyMutation(..._args) {
196
- throw new Error(MUTATION_MESSAGE);
197
- }
198
- function replaceMutation(target, name, value = denyMutation) {
199
- if (typeof target[name] !== "function") return;
200
- Object.defineProperty(target, name, {
201
- configurable: false,
202
- enumerable: true,
203
- writable: false,
204
- value,
205
- });
206
- }
207
- const WRITE_OPEN_FLAGS = fs.constants.O_WRONLY | fs.constants.O_RDWR |
208
- fs.constants.O_CREAT | fs.constants.O_TRUNC | fs.constants.O_APPEND;
209
- const readOnlyFlags = (flags) => typeof flags === "number"
210
- ? (flags & WRITE_OPEN_FLAGS) === 0
211
- : flags === "r" || flags === "rs" || flags === "sr";
212
- const guardedOpen = (original) => function (path, flags, ...rest) {
213
- if (!readOnlyFlags(flags)) return denyMutation();
214
- return Reflect.apply(original, this, [path, flags, ...rest]);
215
- };
216
- const originalOpen = fs.open;
217
- const originalOpenSync = fs.openSync;
218
- const originalPromiseOpen = fs.promises.open;
219
- const guardFileHandle = await originalPromiseOpen(fileURLToPath(import.meta.url), "r");
220
- const fileHandlePrototype = Object.getPrototypeOf(guardFileHandle);
221
- await guardFileHandle.close();
222
- for (const method of [
223
- "appendFile", "appendFileSync", "chmod", "chmodSync", "chown", "chownSync",
224
- "copyFile", "copyFileSync", "cp", "cpSync", "createWriteStream", "link", "linkSync",
225
- "fchmod", "fchmodSync", "fchown", "fchownSync", "fdatasync", "fdatasyncSync",
226
- "fsync", "fsyncSync", "ftruncate", "ftruncateSync",
227
- "futimes", "futimesSync", "lchmod", "lchmodSync", "lchown", "lchownSync",
228
- "lutimes", "lutimesSync", "mkdir", "mkdirSync", "mkdtemp", "mkdtempSync",
229
- "mkdtempDisposable", "mkdtempDisposableSync", "openAsBlob", "rename", "renameSync",
230
- "rm", "rmSync", "rmdir", "rmdirSync",
231
- "symlink", "symlinkSync", "truncate", "truncateSync", "unlink", "unlinkSync",
232
- "utimes", "utimesSync", "write", "writeFile", "writeFileSync", "writeSync",
233
- "writev", "writevSync", "FileWriteStream", "WriteStream",
234
- ]) {
235
- replaceMutation(fs, method);
236
- replaceMutation(fs.promises, method);
237
- }
238
- for (const method of [
239
- "appendFile", "chmod", "chown", "createWriteStream", "datasync", "sync", "truncate",
240
- "utimes", "write", "writeFile", "writev",
241
- ]) {
242
- replaceMutation(fileHandlePrototype, method);
243
- }
244
- replaceMutation(fs, "open", guardedOpen(originalOpen));
245
- replaceMutation(fs, "openSync", guardedOpen(originalOpenSync));
246
- replaceMutation(fs.promises, "open", guardedOpen(originalPromiseOpen));
247
- syncBuiltinESMExports();
@@ -1,73 +0,0 @@
1
- /** Fixed-input clean-clone replay for all eight v84 nonportable dispositions. */
2
- import { createHash } from "node:crypto";
3
- import { readFileSync } from "node:fs";
4
- import { fileURLToPath } from "node:url";
5
- import {
6
- MANAGED_ANALYTICS_SCHEMA_VERSION,
7
- platformAdapterCatalog,
8
- type GetAdapterDefinitionRequest,
9
- type GetAdapterDefinitionResponse,
10
- } from "@tot/public-runtime";
11
- import { buildV84CloneMigrationEvidence } from "../src/lib/apps/v84CloneMigrationEvidence.js";
12
- import { buildV84NonportableRouteDogfood } from "../src/lib/apps/v84NonportableRouteDogfood.js";
13
-
14
- if (process.argv.length !== 2) {
15
- process.stderr.write("refused: fixed-input dogfood command accepts no arguments\n");
16
- process.exit(64);
17
- }
18
-
19
- const fixturePath = fileURLToPath(new URL(
20
- "../../../packages/public-runtime/tests/gtm-migration/fixtures/gtm-sample-container-v84.redacted.json",
21
- import.meta.url,
22
- ));
23
- const fixture = readFileSync(fixturePath, "utf8");
24
- const EXPECTED_FIXTURE_SHA256 = "57d28f3ed5da4215599bfb4b74f984d8b0cd8bf7d8b31e0e1172877308e9b688";
25
- const definitions = platformAdapterCatalog().map((card) => ({
26
- schemaVersion: MANAGED_ANALYTICS_SCHEMA_VERSION,
27
- adapterId: card.adapterId,
28
- adapterVersion: "1.0.0",
29
- displayName: card.name,
30
- description: card.purpose,
31
- availability: "available" as const,
32
- configuration: [{
33
- key: "destinationId", label: card.idLabel,
34
- description: "Public destination identifier used by this reviewed adapter.",
35
- kind: "string" as const, required: true,
36
- }],
37
- eventTypes: [...card.eventTypes],
38
- consentPurposes: [...card.consentPurposes],
39
- collectionOrigins: [...card.cspOrigins].sort(),
40
- }));
41
- const catalogAdapterIds = definitions.map((item) => item.adapterId);
42
- const catalog = {
43
- async getAdapterDefinition(request: GetAdapterDefinitionRequest): Promise<GetAdapterDefinitionResponse> {
44
- const found = definitions.find((item) => item.adapterId === request.query.adapterId);
45
- if (!found) return { apiVersion: "v1", requestId: "req-dogfood-missing", error: { code: "not_found", message: "The requested adapter was not found." } };
46
- return { apiVersion: "v1", requestId: "req-dogfood-catalog", data: found };
47
- },
48
- };
49
-
50
- const run = async () => {
51
- const imported = await buildV84CloneMigrationEvidence(fixture, catalog);
52
- return buildV84NonportableRouteDogfood(imported, catalogAdapterIds);
53
- };
54
- const sourceSha256Before = createHash("sha256").update(fixture).digest("hex");
55
- if (sourceSha256Before !== EXPECTED_FIXTURE_SHA256) throw new Error("The fixed v84 fixture changed.");
56
- const first = await run();
57
- const second = await run();
58
- const sourceSha256After = createHash("sha256").update(readFileSync(fixturePath, "utf8")).digest("hex");
59
- const canonicalFirst = JSON.stringify(first);
60
- const canonicalSecond = JSON.stringify(second);
61
- if (canonicalFirst !== canonicalSecond || sourceSha256Before !== sourceSha256After) {
62
- throw new Error("The clean-clone replay was not deterministic or source-read-only.");
63
- }
64
- process.stdout.write(`${JSON.stringify({
65
- ...first,
66
- cleanCloneReplay: {
67
- runs: 2,
68
- exactReplay: true,
69
- sourceSha256Before,
70
- sourceSha256After,
71
- ledgerSha256: createHash("sha256").update(canonicalFirst).digest("hex"),
72
- },
73
- }, null, 2)}\n`);
@@ -1,79 +0,0 @@
1
- /** Load the already-reviewed fixed native-install diagnostic as an inert JSON artifact. */
2
- import { spawnSync } from "node:child_process";
3
- import { createHash } from "node:crypto";
4
- import { readFileSync } from "node:fs";
5
- import { fileURLToPath } from "node:url";
6
-
7
- export const FIXED_V84_NATIVE_INSTALL_CLI_SHA256 =
8
- "a95ae6b248d50bc034287e307997df6745d02638f1094c09cfecac4da6680b44" as const;
9
-
10
- const PRODUCER_FAILURE = "The fixed native-install evidence producer failed safely.";
11
- const PRODUCER_TIMEOUT_MS = 20_000;
12
- const PRODUCER_PATH = fileURLToPath(new URL("./install-v84-native-through-ws1.ts", import.meta.url));
13
- const PRODUCER_BOOTSTRAP_PATH = fileURLToPath(
14
- new URL("./run-fixed-v84-native-install-producer.mjs", import.meta.url),
15
- );
16
-
17
- interface ProducerResult {
18
- readonly status: number | null;
19
- readonly signal: NodeJS.Signals | null;
20
- readonly stdout: string;
21
- readonly stderr: string;
22
- readonly error?: unknown;
23
- }
24
-
25
- interface ProducerDependencies {
26
- readonly readSource: (path: string) => string;
27
- readonly run: (
28
- command: string,
29
- args: readonly string[],
30
- options: {
31
- readonly encoding: "utf8";
32
- readonly env: Readonly<Record<string, string>>;
33
- readonly timeout: number;
34
- readonly maxBuffer: number;
35
- },
36
- ) => ProducerResult;
37
- }
38
-
39
- const dependencies: ProducerDependencies = {
40
- readSource: (path) => readFileSync(path, "utf8"),
41
- run: (command, args, options) => spawnSync(command, [...args], options),
42
- };
43
-
44
- /**
45
- * Run the fixed no-argument producer and return only its parsed JSON value.
46
- * Every filesystem/process/output failure collapses to one stable, path-free error.
47
- */
48
- export function readFixedV84NativeInstallEvidence(
49
- deps: ProducerDependencies = dependencies,
50
- ): unknown {
51
- try {
52
- const source = deps.readSource(PRODUCER_PATH);
53
- if (createHash("sha256").update(source).digest("hex") !== FIXED_V84_NATIVE_INSTALL_CLI_SHA256) {
54
- throw new Error(PRODUCER_FAILURE);
55
- }
56
- const result = deps.run(
57
- process.execPath,
58
- [PRODUCER_BOOTSTRAP_PATH],
59
- {
60
- encoding: "utf8",
61
- env: {},
62
- timeout: PRODUCER_TIMEOUT_MS,
63
- maxBuffer: 16 * 1024 * 1024,
64
- },
65
- );
66
- if (
67
- result.error !== undefined ||
68
- result.status !== 0 ||
69
- result.signal !== null ||
70
- result.stderr !== "" ||
71
- result.stdout.length === 0
72
- ) {
73
- throw new Error(PRODUCER_FAILURE);
74
- }
75
- return JSON.parse(result.stdout) as unknown;
76
- } catch {
77
- throw new Error(PRODUCER_FAILURE);
78
- }
79
- }