@bridge_gpt/mcp-server 0.2.73 → 0.2.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/build/agent-launchers/claude-executor-adapter.js +12 -0
- package/build/agents.generated.js +3 -3
- package/build/bridge-config.js +7 -1
- package/build/bridge-permissions.js +3 -0
- package/build/command-provisioning.js +4 -3
- package/build/commands.generated.js +5 -5
- package/build/conductor/bridge-api-client.js +26 -1
- package/build/conductor/command-drift.js +1 -1
- package/build/conductor/declared-extras.js +335 -0
- package/build/conductor/doctor.js +2 -0
- package/build/conductor/driver-pass-output.js +104 -0
- package/build/conductor/driver-pass.js +571 -0
- package/build/conductor/epic-branch-ci-inspection.js +61 -16
- package/build/conductor/epic-implementer-cli.js +33 -0
- package/build/conductor/epic-server-sfcc-upload.js +1567 -0
- package/build/conductor/epic-server-sfcc.js +58 -80
- package/build/conductor/epic-server.js +57 -4
- package/build/conductor/gate-discovery.js +46 -6
- package/build/conductor/gate-settings-review.js +51 -14
- package/build/credential-delivery.js +280 -0
- package/build/credential-launch-safety.js +142 -0
- package/build/credential-materialization.js +91 -16
- package/build/credential-references-node-deps.js +29 -0
- package/build/credential-references.js +1394 -0
- package/build/credential-references.test-fixtures.js +211 -0
- package/build/credential-scan-conventions.js +145 -0
- package/build/credential-scan.js +517 -0
- package/build/credential-store.js +50 -0
- package/build/credentials-cli.js +252 -3
- package/build/dependency-install-declarations.js +47 -1
- package/build/docs.generated.js +8 -1
- package/build/doctor.js +41 -0
- package/build/drive-epic.js +297 -37
- package/build/epic-branch-ci-summary.js +18 -1
- package/build/epic-capability-statement.js +71 -3
- package/build/epic-ci-workflow-drift.js +52 -13
- package/build/epic-ci-workflow-install.js +31 -6
- package/build/epic-ci-workflow-v3.js +273 -0
- package/build/epic-ci-workflow.js +128 -7
- package/build/epic-implementer-bin.js +161 -70
- package/build/epic-launch-context.js +102 -7
- package/build/epic-server-record.js +30 -15
- package/build/executor/credential-delivery-step.js +168 -0
- package/build/executor/deps.js +3 -1
- package/build/executor/env.js +39 -1
- package/build/executor/epic-server-context.js +23 -7
- package/build/executor/guarded-fast-forward-push.js +13 -8
- package/build/executor/job-runner.js +159 -17
- package/build/executor/permissions.js +85 -3
- package/build/executor/prompt-spec.js +37 -3
- package/build/executor-launch.js +4 -2
- package/build/git-exclude-lock.js +187 -0
- package/build/index.js +398 -269
- package/build/install-bridge-conductor-answers.js +84 -21
- package/build/install-bridge-conductor-apply.js +30 -1
- package/build/install-bridge-conductor-assessment.js +375 -48
- package/build/install-bridge-conductor-compact.js +27 -2
- package/build/install-bridge-conductor-contracts.js +10 -1
- package/build/install-bridge-conductor-gate.js +124 -11
- package/build/install-bridge-conductor-setup.js +46 -8
- package/build/install-bridge-conductor.js +625 -113
- package/build/install-bridge.js +88 -11
- package/build/install-doctor.js +38 -8
- package/build/install-sfcc-detection.js +120 -0
- package/build/install-sfcc-setup.js +185 -0
- package/build/mcp-grant-candidates.js +108 -96
- package/build/mcp-invoke.js +168 -4
- package/build/mcp-provisioning.js +21 -4
- package/build/mcp-server-invocation.js +13 -0
- package/build/merge-workflow-install.js +9 -1
- package/build/pipelines.generated.js +2 -1
- package/build/plane/status.js +8 -2
- package/build/printed-remedy-commands.js +5 -0
- package/build/project-root.js +40 -0
- package/build/readme.generated.js +1 -1
- package/build/repository-state-paths.js +5 -2
- package/build/repository-toolchains.js +6 -3
- package/build/setup-epic.js +116 -15
- package/build/sfcc/credentials.js +3 -2
- package/build/sfcc/hostname.js +98 -2
- package/build/sfcc/tool-wrapper.js +6 -95
- package/build/start-tickets.js +193 -29
- package/build/test-support/executor-source-files.js +200 -0
- package/build/testing-config-client.js +25 -2
- package/build/third-party-mcp-targets.js +35 -4
- package/build/version.generated.js +3 -3
- package/build/with-credentials.js +208 -0
- package/build/worktree-credential-delivery.js +340 -0
- package/package.json +1 -1
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Per-repository state records kept OUTSIDE every worktree (BAPI-1545).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Three record families live here, one file per repository:
|
|
5
5
|
*
|
|
6
6
|
* - `mcp-grants/<repo>.json` — the owner-approved MCP grant (`mcp-grant.ts`).
|
|
7
7
|
* - `epic-server/<repo>.json` — the epic-server record child 3 writes
|
|
8
8
|
* (`epic-server-record.ts` owns the contract).
|
|
9
|
+
* - `worker-credentials/<repo>.json` — the owner-approved credential
|
|
10
|
+
* references, names and source locations only, never values
|
|
11
|
+
* (`credential-references.ts` owns the contract).
|
|
9
12
|
*
|
|
10
|
-
*
|
|
13
|
+
* All sit beside the user credential store, under `~/.config/bridge` (or
|
|
11
14
|
* `$XDG_CONFIG_HOME/bridge` when that is set, exactly as the credential store
|
|
12
15
|
* resolves it). A worker's worktree never contains them, so nothing a worker
|
|
13
16
|
* commits or edits inside its checkout can change them.
|
|
@@ -532,13 +532,16 @@ export function installArgvForJavaScript(js) {
|
|
|
532
532
|
* BAPI-1551 — the fixed install argv for a Python toolchain. pip's argv is kept
|
|
533
533
|
* for the description only: a bare `pip install` targets whatever interpreter is
|
|
534
534
|
* first on `PATH`, so a dependency refresh never proposes it.
|
|
535
|
+
*
|
|
536
|
+
* BAPI-1677 — `extras` holds only keys the install target declares. With none, every
|
|
537
|
+
* caller's argv is byte-identical to before. pip takes none: it is never proposed.
|
|
535
538
|
*/
|
|
536
|
-
export function installArgvForPython(py) {
|
|
539
|
+
export function installArgvForPython(py, extras = []) {
|
|
537
540
|
switch (py.manager) {
|
|
538
541
|
case "uv":
|
|
539
|
-
return ["uv", "sync", "--frozen"];
|
|
542
|
+
return ["uv", "sync", "--frozen", ...extras.flatMap((name) => ["--extra", name])];
|
|
540
543
|
case "poetry":
|
|
541
|
-
return ["poetry", "install"];
|
|
544
|
+
return ["poetry", "install", ...extras.flatMap((name) => ["-E", name])];
|
|
542
545
|
case "pip":
|
|
543
546
|
return ["pip", "install", "-r", "requirements.txt"];
|
|
544
547
|
}
|
package/build/setup-epic.js
CHANGED
|
@@ -2784,6 +2784,41 @@ export async function readCanonicalParseTruth(access, fetchImpl) {
|
|
|
2784
2784
|
}
|
|
2785
2785
|
return { ok: true, cutCommitSha: evidence.sourceCommitSha };
|
|
2786
2786
|
}
|
|
2787
|
+
/**
|
|
2788
|
+
* Classify a remote epic branch against an authoritative target SHA. One decision,
|
|
2789
|
+
* shared by the preview and the create-time preflight.
|
|
2790
|
+
*
|
|
2791
|
+
* Remote reads and commit-object acquisition only: it reads the remote tip, makes
|
|
2792
|
+
* both commit objects resolvable locally with a read-only fetch by SHA, and
|
|
2793
|
+
* compares ancestry. It never updates a branch (local or remote), and it never
|
|
2794
|
+
* trusts a local `origin/{base}` tracking ref: the target is supplied by the caller.
|
|
2795
|
+
*/
|
|
2796
|
+
export async function classifyRemoteEpicBranch(deps, branch, targetSha) {
|
|
2797
|
+
const unreadable = (tipSha, detail) => ({ status: "unknown", tipSha, detail });
|
|
2798
|
+
try {
|
|
2799
|
+
const head = await readRemoteBranchHead(deps, branch);
|
|
2800
|
+
if (!head.ok)
|
|
2801
|
+
return unreadable(null, head.error);
|
|
2802
|
+
if (head.sha === null)
|
|
2803
|
+
return { status: "absent" };
|
|
2804
|
+
const tipSha = head.sha;
|
|
2805
|
+
if (tipSha === targetSha)
|
|
2806
|
+
return { status: "at_target", tipSha };
|
|
2807
|
+
if (!(await ensureCommitResolvableLocally(deps, targetSha)) ||
|
|
2808
|
+
!(await ensureCommitResolvableLocally(deps, tipSha))) {
|
|
2809
|
+
return unreadable(tipSha, `Could not resolve origin/${branch} (${tipSha}) and ${targetSha} locally.`);
|
|
2810
|
+
}
|
|
2811
|
+
const ancestry = await runGit(deps, ["merge-base", "--is-ancestor", tipSha, targetSha]);
|
|
2812
|
+
if (ancestry.exitCode === 0)
|
|
2813
|
+
return { status: "behind_target", tipSha, targetSha };
|
|
2814
|
+
if (ancestry.exitCode === 1)
|
|
2815
|
+
return { status: "has_own_commits", tipSha, targetSha };
|
|
2816
|
+
return unreadable(tipSha, `Could not compare origin/${branch} (${tipSha}) with ${targetSha}.`);
|
|
2817
|
+
}
|
|
2818
|
+
catch {
|
|
2819
|
+
return unreadable(null, `Could not classify origin/${branch}.`);
|
|
2820
|
+
}
|
|
2821
|
+
}
|
|
2787
2822
|
/** The strict subset of `SetupEpicDeps` the shared cut protocol consumes. */
|
|
2788
2823
|
function cutProtocolDeps(deps, runCommand) {
|
|
2789
2824
|
return {
|
|
@@ -2942,10 +2977,13 @@ function recordStoredRunFacts(sink, storedPolicy) {
|
|
|
2942
2977
|
* same exit codes — and differs only in what it hands back.
|
|
2943
2978
|
*/
|
|
2944
2979
|
export async function runSetupEpicWorkflow(argv, overrides = {}, handoff) {
|
|
2945
|
-
const sink = {};
|
|
2980
|
+
const sink = { createRequestAttempted: false };
|
|
2946
2981
|
const exitCode = await executeSetupEpic(argv, overrides, sink, handoff);
|
|
2947
2982
|
return {
|
|
2948
2983
|
exitCode,
|
|
2984
|
+
...(exitCode !== 0 && sink.createRequestAttempted === false && sink.existingRunEstablished !== true &&
|
|
2985
|
+
sink.epicRunId === undefined ? { refusedBeforeCreate: true } : {}),
|
|
2986
|
+
...(sink.branchMove !== undefined ? { branchMove: { ...sink.branchMove } } : {}),
|
|
2949
2987
|
...(sink.epicRunId !== undefined ? { epicRunId: sink.epicRunId } : {}),
|
|
2950
2988
|
...(sink.epicRunId !== undefined ? { runExists: true } : {}),
|
|
2951
2989
|
...(sink.runCreated !== undefined ? { runCreated: sink.runCreated } : {}),
|
|
@@ -3172,8 +3210,10 @@ async function executeSetupEpic(argv, overrides, runIdSink, handoff) {
|
|
|
3172
3210
|
existingNotificationSink = state?.notification_sink ?? null;
|
|
3173
3211
|
// BAPI-1581 — the live run's governing facts, captured the moment it resolves
|
|
3174
3212
|
// so every later early return (attach-only, refusal, failure) still has them.
|
|
3175
|
-
if (existingRunId !== null)
|
|
3213
|
+
if (existingRunId !== null) {
|
|
3176
3214
|
recordStoredRunFacts(runIdSink, existingPolicy);
|
|
3215
|
+
runIdSink.existingRunEstablished = true;
|
|
3216
|
+
}
|
|
3177
3217
|
const existingBase = existingPolicy && typeof existingPolicy === "object"
|
|
3178
3218
|
? existingPolicy.base_branch
|
|
3179
3219
|
: undefined;
|
|
@@ -3945,20 +3985,79 @@ async function executeSetupEpic(argv, overrides, runIdSink, handoff) {
|
|
|
3945
3985
|
`created and no branch was changed.`);
|
|
3946
3986
|
return 1;
|
|
3947
3987
|
}
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3988
|
+
if (existingRunId === null) {
|
|
3989
|
+
// A NEW run: classify the leftover branch against the exact cut.
|
|
3990
|
+
const branch = effectiveFeatureBranch;
|
|
3991
|
+
const classified = await classifyRemoteEpicBranch(gitDeps, branch, cutCommitSha);
|
|
3992
|
+
if (classified.status === "has_own_commits") {
|
|
3993
|
+
deps.errorLog(`origin/${branch} already exists at ${classified.tipSha} and holds commits that are not in ` +
|
|
3994
|
+
`the canonical indexed commit ${cutCommitSha}. setup-epic never force-updates an existing ` +
|
|
3995
|
+
`branch. Inspect it with: git log origin/${scopeBaseBranch}..origin/${branch}. ` +
|
|
3996
|
+
`Then finish that work, or delete the branch with: git push origin --delete ${branch}. ` +
|
|
3997
|
+
`No run was created and no branch was changed.`);
|
|
3998
|
+
return 1;
|
|
3999
|
+
}
|
|
4000
|
+
if (classified.status === "unknown") {
|
|
4001
|
+
deps.errorLog(classified.tipSha === null
|
|
4002
|
+
? `${classified.detail} No run was created and no branch was changed.`
|
|
4003
|
+
: `origin/${branch} already exists at ${classified.tipSha}, and its relationship to the ` +
|
|
4004
|
+
`canonical indexed commit ${cutCommitSha} could not be established. setup-epic never ` +
|
|
4005
|
+
`force-updates an existing branch: delete it, or finish the previous run first. ` +
|
|
4006
|
+
`No run was created and no branch was changed.`);
|
|
4007
|
+
return 1;
|
|
4008
|
+
}
|
|
4009
|
+
if (classified.status === "behind_target") {
|
|
4010
|
+
// One plain push (no force, no leading '+'). Whatever it returns, the remote
|
|
4011
|
+
// is re-read once; only an exact match with the cut lets setup continue.
|
|
4012
|
+
try {
|
|
4013
|
+
await runGit(gitDeps, ["push", "origin", `${cutCommitSha}:refs/heads/${branch}`]);
|
|
4014
|
+
}
|
|
4015
|
+
catch { /* judged by the re-read below */ }
|
|
4016
|
+
let reread;
|
|
4017
|
+
try {
|
|
4018
|
+
reread = await readRemoteBranchHead(gitDeps, branch);
|
|
4019
|
+
}
|
|
4020
|
+
catch {
|
|
4021
|
+
reread = { ok: false, error: `git ls-remote could not read origin/${branch}.` };
|
|
4022
|
+
}
|
|
4023
|
+
if (!reread.ok || reread.sha !== cutCommitSha) {
|
|
4024
|
+
deps.errorLog(!reread.ok
|
|
4025
|
+
? `Tried to move origin/${branch} from ${classified.tipSha} to the canonical indexed commit ` +
|
|
4026
|
+
`${cutCommitSha}, but could not read the branch afterwards. Check it with: ` +
|
|
4027
|
+
`git ls-remote origin refs/heads/${branch}. No run was created.`
|
|
4028
|
+
: reread.sha === null
|
|
4029
|
+
? `Tried to move origin/${branch} to the canonical indexed commit ${cutCommitSha}, but the ` +
|
|
4030
|
+
`branch is now absent. No run was created.`
|
|
4031
|
+
: `Tried to move origin/${branch} to the canonical indexed commit ${cutCommitSha}, but it is ` +
|
|
4032
|
+
`now at ${reread.sha}. No run was created.`);
|
|
4033
|
+
return 1;
|
|
4034
|
+
}
|
|
4035
|
+
runIdSink.branchMove = { branch, from: classified.tipSha, to: cutCommitSha };
|
|
4036
|
+
say(`Branch: moved origin/${branch} from ${classified.tipSha} to the cut commit ${cutCommitSha}`);
|
|
4037
|
+
}
|
|
4038
|
+
else {
|
|
4039
|
+
say(classified.status === "absent"
|
|
4040
|
+
? `Branch: origin/${branch} is absent; it will be cut at ${cutCommitSha}`
|
|
4041
|
+
: `Branch: origin/${branch} already sits at the cut commit ${cutCommitSha}`);
|
|
4042
|
+
}
|
|
3952
4043
|
}
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
4044
|
+
else {
|
|
4045
|
+
// A reused run keeps its prior cut validation unchanged: no branch is ever moved.
|
|
4046
|
+
const remoteHead = await readRemoteBranchHead(gitDeps, effectiveFeatureBranch);
|
|
4047
|
+
if (!remoteHead.ok) {
|
|
4048
|
+
deps.errorLog(`${remoteHead.error} No run was created and no branch was changed.`);
|
|
4049
|
+
return 1;
|
|
4050
|
+
}
|
|
4051
|
+
if (remoteHead.sha !== null && remoteHead.sha !== cutCommitSha) {
|
|
4052
|
+
deps.errorLog(`origin/${effectiveFeatureBranch} already exists at ${remoteHead.sha}, which is not the ` +
|
|
4053
|
+
`canonical indexed commit ${cutCommitSha}. setup-epic never force-updates an existing ` +
|
|
4054
|
+
`branch: delete it, or finish the previous run first. No run was created and no branch was changed.`);
|
|
4055
|
+
return 1;
|
|
4056
|
+
}
|
|
4057
|
+
say(remoteHead.sha === null
|
|
4058
|
+
? `Branch: origin/${effectiveFeatureBranch} is absent; it will be cut at ${cutCommitSha}`
|
|
4059
|
+
: `Branch: origin/${effectiveFeatureBranch} already sits at the cut commit ${cutCommitSha}`);
|
|
3958
4060
|
}
|
|
3959
|
-
say(remoteHead.sha === null
|
|
3960
|
-
? `Branch: origin/${effectiveFeatureBranch} is absent; it will be cut at ${cutCommitSha}`
|
|
3961
|
-
: `Branch: origin/${effectiveFeatureBranch} already sits at the cut commit ${cutCommitSha}`);
|
|
3962
4061
|
}
|
|
3963
4062
|
const result = {
|
|
3964
4063
|
epic_run_id: existingRunId ?? "",
|
|
@@ -4161,6 +4260,8 @@ async function executeSetupEpic(argv, overrides, runIdSink, handoff) {
|
|
|
4161
4260
|
: { epicKey: opts.epicKey };
|
|
4162
4261
|
let createResponse;
|
|
4163
4262
|
try {
|
|
4263
|
+
// From here a create request may commit even if its response is lost.
|
|
4264
|
+
runIdSink.createRequestAttempted = true;
|
|
4164
4265
|
createResponse = await createEpicRunWithDisposition(access, createRequest, deps.fetch);
|
|
4165
4266
|
}
|
|
4166
4267
|
catch (createErr) {
|
|
@@ -4388,7 +4489,7 @@ async function executeSetupEpic(argv, overrides, runIdSink, handoff) {
|
|
|
4388
4489
|
// and a fresh probe would just re-confirm what a prior run already ensured
|
|
4389
4490
|
// or deferred). Non-fatal in every outcome: setup-epic's provisioning
|
|
4390
4491
|
// workflow (plan storage, approval, scope polling) proceeds unchanged.
|
|
4391
|
-
if (cut.branchCreated && scopeBaseBranch !== null) {
|
|
4492
|
+
if ((cut.branchCreated || runIdSink.branchMove !== undefined) && scopeBaseBranch !== null) {
|
|
4392
4493
|
const ghRunner = deps.epicIntegrationGh ?? createProductionEpicIntegrationGhRunner();
|
|
4393
4494
|
let outcome;
|
|
4394
4495
|
try {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* first-pick. Secret values (client_secret, tokens) are never included in
|
|
8
8
|
* any returned or thrown string — only source and target are reported.
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
10
|
+
import { ensureGitInfoExcludedSerialized } from "../git-exclude-lock.js";
|
|
11
11
|
import { canonicalizeSfccHostname, formatSafeHost } from "./hostname.js";
|
|
12
12
|
import { readFile, writeFile, mkdir } from "fs/promises";
|
|
13
13
|
import path from "path";
|
|
@@ -57,7 +57,8 @@ async function loadDwJson(deps) {
|
|
|
57
57
|
const mk = deps.mkdir ?? ((p, opts) => mkdir(p, opts));
|
|
58
58
|
// Ensure dw.json is excluded from git tracking.
|
|
59
59
|
try {
|
|
60
|
-
|
|
60
|
+
// BAPI-1647: serialized with every other Bridge exclude writer.
|
|
61
|
+
await ensureGitInfoExcludedSerialized(cwd, DW_JSON, { readFile: rf, writeFile: wf, mkdir: mk });
|
|
61
62
|
}
|
|
62
63
|
catch {
|
|
63
64
|
// Non-fatal — continue even if we can't update .git/info/exclude.
|
package/build/sfcc/hostname.js
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* `canonicalizeSfccHostname` lives here so the target boundary
|
|
5
5
|
* (`tool-wrapper.ts`), the credential resolver, and `check_permissions` all
|
|
6
|
-
* canonicalize and display hosts the same way.
|
|
7
|
-
* so
|
|
6
|
+
* canonicalize and display hosts the same way. It also owns the approved
|
|
7
|
+
* sandbox-host policy so the credential scan can reuse it without importing
|
|
8
|
+
* tool configuration or credential resolution. `tool-wrapper.ts` re-exports
|
|
9
|
+
* these so its public import surface is unchanged.
|
|
8
10
|
*/
|
|
9
11
|
/** Longest hostname echoed in a diagnostic. */
|
|
10
12
|
export const MAX_DIAGNOSTIC_HOST_LENGTH = 120;
|
|
@@ -65,3 +67,97 @@ export function formatSafeHost(raw) {
|
|
|
65
67
|
? `${canonical.slice(0, MAX_DIAGNOSTIC_HOST_LENGTH)}…`
|
|
66
68
|
: canonical;
|
|
67
69
|
}
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
// Sandbox host policy
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
/**
|
|
74
|
+
* The DNS suffix every approved sandbox form shares.
|
|
75
|
+
*
|
|
76
|
+
* Every SFCC developer-sandbox hostname evidenced anywhere in this repository —
|
|
77
|
+
* `credentials.ts`'s JSDoc, the install guide's prerequisites, the BAPI-399
|
|
78
|
+
* live smoke-test record, and the existing test fixtures — lives under this
|
|
79
|
+
* suffix. Legacy `*.demandware.net` hosts are deliberately NOT accepted: that
|
|
80
|
+
* domain covers sandbox, staging, development, and production instances alike
|
|
81
|
+
* with no suffix that separates them, so admitting it would reintroduce exactly
|
|
82
|
+
* the unbounded target this boundary exists to close. It appears in this repo
|
|
83
|
+
* only as a test fixture, never in production code or the SFCC install docs.
|
|
84
|
+
*/
|
|
85
|
+
const SFCC_DX_SUFFIX = ".dx.commercecloud.salesforce.com";
|
|
86
|
+
/**
|
|
87
|
+
* First labels that name a non-sandbox environment on the B2C platform.
|
|
88
|
+
*
|
|
89
|
+
* Checked against the leading label of every candidate, so a host like
|
|
90
|
+
* `production-zzrf.dx.commercecloud.salesforce.com` or
|
|
91
|
+
* `staging-zzrf.sandbox.us01.dx.commercecloud.salesforce.com` is refused even
|
|
92
|
+
* though it would otherwise satisfy a form below. This is belt-and-braces: form
|
|
93
|
+
* B alone would already admit `production-001`, and a named production instance
|
|
94
|
+
* is precisely the target the ticket was filed about.
|
|
95
|
+
*/
|
|
96
|
+
const RESERVED_ENVIRONMENT_LABELS = [
|
|
97
|
+
"production",
|
|
98
|
+
"prod",
|
|
99
|
+
"staging",
|
|
100
|
+
"stg",
|
|
101
|
+
"development",
|
|
102
|
+
];
|
|
103
|
+
/**
|
|
104
|
+
* Human-readable description of every accepted form, for the refusal envelope
|
|
105
|
+
* and the documentation contract test. Keep in sync with
|
|
106
|
+
* `isApprovedSfccSandboxHost` — the tests assert both directions.
|
|
107
|
+
*/
|
|
108
|
+
export const APPROVED_SANDBOX_HOST_FORMS = [
|
|
109
|
+
"<realm>-<nnn>.sandbox.<region>.dx.commercecloud.salesforce.com",
|
|
110
|
+
"<realm>-<nnn>.sandbox.dx.commercecloud.salesforce.com",
|
|
111
|
+
"<realm>-<nnn>.dx.commercecloud.salesforce.com",
|
|
112
|
+
];
|
|
113
|
+
/** Form B's leading label: an SFCC realm id followed by a numeric instance. */
|
|
114
|
+
const REALM_INSTANCE_LABEL = /^[a-z0-9]+-\d{3}$/;
|
|
115
|
+
/**
|
|
116
|
+
* Decide whether a canonical hostname is an approved developer sandbox.
|
|
117
|
+
*
|
|
118
|
+
* Matching is ANCHORED on both ends: the host must END with the platform suffix
|
|
119
|
+
* and the labels in front of it must form one of the shapes below. This is the
|
|
120
|
+
* property a substring test lacks — `.includes(".sandbox.")` matches
|
|
121
|
+
* `zzzz-001.sandbox.evil.example.com`, whose registrable domain is not
|
|
122
|
+
* Salesforce's at all.
|
|
123
|
+
*
|
|
124
|
+
* Form A — explicit sandbox label, with or without a region:
|
|
125
|
+
* `zzzz-001.sandbox.us01.dx.commercecloud.salesforce.com`
|
|
126
|
+
* `zzzz-001.sandbox.dx.commercecloud.salesforce.com`
|
|
127
|
+
* Form B — realm + numeric instance, the on-demand sandbox form this project
|
|
128
|
+
* actually smoke-tested against (`docs/BAPI-399-sfcc-mcp-smoke-test.md`
|
|
129
|
+
* records sandbox `zyis-001`):
|
|
130
|
+
* `zyis-001.dx.commercecloud.salesforce.com`
|
|
131
|
+
*
|
|
132
|
+
* Form B is required for correctness, not convenience: without it the boundary
|
|
133
|
+
* would refuse the very sandbox this repository documents itself using, and a
|
|
134
|
+
* safety check that blocks the intended workflow gets disabled rather than
|
|
135
|
+
* obeyed. It is kept safe by requiring the `<realm>-<nnn>` shape (named
|
|
136
|
+
* environments such as `production-zzrf` do not match) and by the reserved-label
|
|
137
|
+
* check.
|
|
138
|
+
*
|
|
139
|
+
* Anything not matching — including every `*.demandware.net` host and any other
|
|
140
|
+
* registrable domain — is refused. Widening this set is a deliberate decision,
|
|
141
|
+
* not a bug fix: the ticket's Decision 1(b), an explicit per-instance opt-in, is
|
|
142
|
+
* the sanctioned way to reach an instance this policy does not recognize.
|
|
143
|
+
*/
|
|
144
|
+
export function isApprovedSfccSandboxHost(canonical) {
|
|
145
|
+
if (!canonical.endsWith(SFCC_DX_SUFFIX))
|
|
146
|
+
return false;
|
|
147
|
+
const prefix = canonical.slice(0, -SFCC_DX_SUFFIX.length);
|
|
148
|
+
if (prefix === "")
|
|
149
|
+
return false;
|
|
150
|
+
const labels = prefix.split(".");
|
|
151
|
+
const first = labels[0];
|
|
152
|
+
for (const reserved of RESERVED_ENVIRONMENT_LABELS) {
|
|
153
|
+
if (first === reserved || first.startsWith(`${reserved}-`))
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
// Form A: <label>.sandbox[.<region>]
|
|
157
|
+
if ((labels.length === 2 || labels.length === 3) && labels[1] === "sandbox")
|
|
158
|
+
return true;
|
|
159
|
+
// Form B: <realm>-<nnn>
|
|
160
|
+
if (labels.length === 1 && REALM_INSTANCE_LABEL.test(first))
|
|
161
|
+
return true;
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
@@ -65,104 +65,15 @@ import { SFCC_VERSIONS, getSfccVersionConfig } from "./config.js";
|
|
|
65
65
|
import { publishSfccVersion } from "./tools-configured.js";
|
|
66
66
|
import { resolveSfccCredentials } from "./credentials.js";
|
|
67
67
|
import { formatSfccFailure } from "./sfcc-result.js";
|
|
68
|
-
import { canonicalizeSfccHostname, formatSafeHost } from "./hostname.js";
|
|
69
|
-
// `canonicalizeSfccHostname` moved to hostname.ts;
|
|
70
|
-
// importers of this module are unaffected.
|
|
71
|
-
export { canonicalizeSfccHostname };
|
|
68
|
+
import { APPROVED_SANDBOX_HOST_FORMS, canonicalizeSfccHostname, formatSafeHost, isApprovedSfccSandboxHost, } from "./hostname.js";
|
|
69
|
+
// `canonicalizeSfccHostname` and the sandbox-host policy moved to hostname.ts;
|
|
70
|
+
// re-exported so existing importers of this module are unaffected.
|
|
71
|
+
export { APPROVED_SANDBOX_HOST_FORMS, canonicalizeSfccHostname, isApprovedSfccSandboxHost };
|
|
72
72
|
// ---------------------------------------------------------------------------
|
|
73
73
|
// Hostname policy
|
|
74
74
|
// ---------------------------------------------------------------------------
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
*
|
|
78
|
-
* Every SFCC developer-sandbox hostname evidenced anywhere in this repository —
|
|
79
|
-
* `credentials.ts`'s JSDoc, the install guide's prerequisites, the BAPI-399
|
|
80
|
-
* live smoke-test record, and the existing test fixtures — lives under this
|
|
81
|
-
* suffix. Legacy `*.demandware.net` hosts are deliberately NOT accepted: that
|
|
82
|
-
* domain covers sandbox, staging, development, and production instances alike
|
|
83
|
-
* with no suffix that separates them, so admitting it would reintroduce exactly
|
|
84
|
-
* the unbounded target this boundary exists to close. It appears in this repo
|
|
85
|
-
* only as a test fixture, never in production code or the SFCC install docs.
|
|
86
|
-
*/
|
|
87
|
-
const SFCC_DX_SUFFIX = ".dx.commercecloud.salesforce.com";
|
|
88
|
-
/**
|
|
89
|
-
* First labels that name a non-sandbox environment on the B2C platform.
|
|
90
|
-
*
|
|
91
|
-
* Checked against the leading label of every candidate, so a host like
|
|
92
|
-
* `production-zzrf.dx.commercecloud.salesforce.com` or
|
|
93
|
-
* `staging-zzrf.sandbox.us01.dx.commercecloud.salesforce.com` is refused even
|
|
94
|
-
* though it would otherwise satisfy a form below. This is belt-and-braces: form
|
|
95
|
-
* B alone would already admit `production-001`, and a named production instance
|
|
96
|
-
* is precisely the target the ticket was filed about.
|
|
97
|
-
*/
|
|
98
|
-
const RESERVED_ENVIRONMENT_LABELS = [
|
|
99
|
-
"production",
|
|
100
|
-
"prod",
|
|
101
|
-
"staging",
|
|
102
|
-
"stg",
|
|
103
|
-
"development",
|
|
104
|
-
];
|
|
105
|
-
/**
|
|
106
|
-
* Human-readable description of every accepted form, for the refusal envelope
|
|
107
|
-
* and the documentation contract test. Keep in sync with
|
|
108
|
-
* `isApprovedSfccSandboxHost` — the tests assert both directions.
|
|
109
|
-
*/
|
|
110
|
-
export const APPROVED_SANDBOX_HOST_FORMS = [
|
|
111
|
-
"<realm>-<nnn>.sandbox.<region>.dx.commercecloud.salesforce.com",
|
|
112
|
-
"<realm>-<nnn>.sandbox.dx.commercecloud.salesforce.com",
|
|
113
|
-
"<realm>-<nnn>.dx.commercecloud.salesforce.com",
|
|
114
|
-
];
|
|
115
|
-
/** Form B's leading label: an SFCC realm id followed by a numeric instance. */
|
|
116
|
-
const REALM_INSTANCE_LABEL = /^[a-z0-9]+-\d{3}$/;
|
|
117
|
-
/**
|
|
118
|
-
* Decide whether a canonical hostname is an approved developer sandbox.
|
|
119
|
-
*
|
|
120
|
-
* Matching is ANCHORED on both ends: the host must END with the platform suffix
|
|
121
|
-
* and the labels in front of it must form one of the shapes below. This is the
|
|
122
|
-
* property a substring test lacks — `.includes(".sandbox.")` matches
|
|
123
|
-
* `zzzz-001.sandbox.evil.example.com`, whose registrable domain is not
|
|
124
|
-
* Salesforce's at all.
|
|
125
|
-
*
|
|
126
|
-
* Form A — explicit sandbox label, with or without a region:
|
|
127
|
-
* `zzzz-001.sandbox.us01.dx.commercecloud.salesforce.com`
|
|
128
|
-
* `zzzz-001.sandbox.dx.commercecloud.salesforce.com`
|
|
129
|
-
* Form B — realm + numeric instance, the on-demand sandbox form this project
|
|
130
|
-
* actually smoke-tested against (`docs/BAPI-399-sfcc-mcp-smoke-test.md`
|
|
131
|
-
* records sandbox `zyis-001`):
|
|
132
|
-
* `zyis-001.dx.commercecloud.salesforce.com`
|
|
133
|
-
*
|
|
134
|
-
* Form B is required for correctness, not convenience: without it the boundary
|
|
135
|
-
* would refuse the very sandbox this repository documents itself using, and a
|
|
136
|
-
* safety check that blocks the intended workflow gets disabled rather than
|
|
137
|
-
* obeyed. It is kept safe by requiring the `<realm>-<nnn>` shape (named
|
|
138
|
-
* environments such as `production-zzrf` do not match) and by the reserved-label
|
|
139
|
-
* check.
|
|
140
|
-
*
|
|
141
|
-
* Anything not matching — including every `*.demandware.net` host and any other
|
|
142
|
-
* registrable domain — is refused. Widening this set is a deliberate decision,
|
|
143
|
-
* not a bug fix: the ticket's Decision 1(b), an explicit per-instance opt-in, is
|
|
144
|
-
* the sanctioned way to reach an instance this policy does not recognize.
|
|
145
|
-
*/
|
|
146
|
-
export function isApprovedSfccSandboxHost(canonical) {
|
|
147
|
-
if (!canonical.endsWith(SFCC_DX_SUFFIX))
|
|
148
|
-
return false;
|
|
149
|
-
const prefix = canonical.slice(0, -SFCC_DX_SUFFIX.length);
|
|
150
|
-
if (prefix === "")
|
|
151
|
-
return false;
|
|
152
|
-
const labels = prefix.split(".");
|
|
153
|
-
const first = labels[0];
|
|
154
|
-
for (const reserved of RESERVED_ENVIRONMENT_LABELS) {
|
|
155
|
-
if (first === reserved || first.startsWith(`${reserved}-`))
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
// Form A: <label>.sandbox[.<region>]
|
|
159
|
-
if ((labels.length === 2 || labels.length === 3) && labels[1] === "sandbox")
|
|
160
|
-
return true;
|
|
161
|
-
// Form B: <realm>-<nnn>
|
|
162
|
-
if (labels.length === 1 && REALM_INSTANCE_LABEL.test(first))
|
|
163
|
-
return true;
|
|
164
|
-
return false;
|
|
165
|
-
}
|
|
75
|
+
// The sandbox-host policy (`isApprovedSfccSandboxHost`,
|
|
76
|
+
// `APPROVED_SANDBOX_HOST_FORMS`) lives in hostname.ts and is re-exported above.
|
|
166
77
|
/**
|
|
167
78
|
* The one refusal envelope every SFCC tool returns for an unapproved target.
|
|
168
79
|
*
|