@backifydev/cli 0.3.20 → 0.3.21
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 +380 -358
- package/dist/index.js +397 -99
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17360,7 +17360,7 @@ function datetime(args2) {
|
|
|
17360
17360
|
const timeRegex = `${time3}(?:${opts.join("|")})`;
|
|
17361
17361
|
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
17362
17362
|
}
|
|
17363
|
-
var cuid, cuid2, ulid, xid, ksuid, nanoid, duration, guid,
|
|
17363
|
+
var cuid, cuid2, ulid, xid, ksuid, nanoid, duration, guid, uuid6, email, _emoji, ipv4, ipv6, cidrv4, cidrv6, base64, base64url, hostname2, e164, dateSource, date, string, bigint, integer3, number, boolean, _null, lowercase, uppercase;
|
|
17364
17364
|
var init_regexes = __esm({
|
|
17365
17365
|
"../../node_modules/zod/v4/core/regexes.js"() {
|
|
17366
17366
|
cuid = /^[cC][^\s-]{8,}$/;
|
|
@@ -17371,7 +17371,7 @@ var init_regexes = __esm({
|
|
|
17371
17371
|
nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
17372
17372
|
duration = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
17373
17373
|
guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
17374
|
-
|
|
17374
|
+
uuid6 = (version2) => {
|
|
17375
17375
|
if (!version2)
|
|
17376
17376
|
return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;
|
|
17377
17377
|
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version2}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
@@ -18175,9 +18175,9 @@ var init_schemas = __esm({
|
|
|
18175
18175
|
const v = versionMap[def.version];
|
|
18176
18176
|
if (v === void 0)
|
|
18177
18177
|
throw new Error(`Invalid UUID version: "${def.version}"`);
|
|
18178
|
-
def.pattern ?? (def.pattern =
|
|
18178
|
+
def.pattern ?? (def.pattern = uuid6(v));
|
|
18179
18179
|
} else
|
|
18180
|
-
def.pattern ?? (def.pattern =
|
|
18180
|
+
def.pattern ?? (def.pattern = uuid6());
|
|
18181
18181
|
$ZodStringFormat.init(inst, def);
|
|
18182
18182
|
});
|
|
18183
18183
|
$ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
|
|
@@ -25548,8 +25548,8 @@ var require_keyword = __commonJS({
|
|
|
25548
25548
|
var _a2;
|
|
25549
25549
|
const { gen, keyword, schema, parentSchema, $data, it } = cxt;
|
|
25550
25550
|
checkAsyncKeyword(it, def);
|
|
25551
|
-
const
|
|
25552
|
-
const validateRef = useKeyword(gen, keyword,
|
|
25551
|
+
const validate2 = !$data && def.compile ? def.compile.call(it.self, schema, parentSchema, it) : def.validate;
|
|
25552
|
+
const validateRef = useKeyword(gen, keyword, validate2);
|
|
25553
25553
|
const valid = gen.let("valid");
|
|
25554
25554
|
cxt.block$data(valid, validateKeyword);
|
|
25555
25555
|
cxt.ok((_a2 = def.valid) !== null && _a2 !== void 0 ? _a2 : valid);
|
|
@@ -26622,28 +26622,28 @@ var require_compile = __commonJS({
|
|
|
26622
26622
|
if (this.opts.code.process)
|
|
26623
26623
|
sourceCode = this.opts.code.process(sourceCode, sch);
|
|
26624
26624
|
const makeValidate = new Function(`${names_1.default.self}`, `${names_1.default.scope}`, sourceCode);
|
|
26625
|
-
const
|
|
26626
|
-
this.scope.value(validateName2, { ref:
|
|
26627
|
-
|
|
26628
|
-
|
|
26629
|
-
|
|
26625
|
+
const validate2 = makeValidate(this, this.scope.get());
|
|
26626
|
+
this.scope.value(validateName2, { ref: validate2 });
|
|
26627
|
+
validate2.errors = null;
|
|
26628
|
+
validate2.schema = sch.schema;
|
|
26629
|
+
validate2.schemaEnv = sch;
|
|
26630
26630
|
if (sch.$async)
|
|
26631
|
-
|
|
26631
|
+
validate2.$async = true;
|
|
26632
26632
|
if (this.opts.code.source === true) {
|
|
26633
|
-
|
|
26633
|
+
validate2.source = { validateName: validateName2, validateCode, scopeValues: gen._values };
|
|
26634
26634
|
}
|
|
26635
26635
|
if (this.opts.unevaluated) {
|
|
26636
26636
|
const { props, items } = schemaCxt;
|
|
26637
|
-
|
|
26637
|
+
validate2.evaluated = {
|
|
26638
26638
|
props: props instanceof codegen_1.Name ? void 0 : props,
|
|
26639
26639
|
items: items instanceof codegen_1.Name ? void 0 : items,
|
|
26640
26640
|
dynamicProps: props instanceof codegen_1.Name,
|
|
26641
26641
|
dynamicItems: items instanceof codegen_1.Name
|
|
26642
26642
|
};
|
|
26643
|
-
if (
|
|
26644
|
-
|
|
26643
|
+
if (validate2.source)
|
|
26644
|
+
validate2.source.evaluated = (0, codegen_1.stringify)(validate2.evaluated);
|
|
26645
26645
|
}
|
|
26646
|
-
sch.validate =
|
|
26646
|
+
sch.validate = validate2;
|
|
26647
26647
|
return sch;
|
|
26648
26648
|
} catch (e) {
|
|
26649
26649
|
delete sch.validate;
|
|
@@ -30566,8 +30566,8 @@ var require_formats = __commonJS({
|
|
|
30566
30566
|
"use strict";
|
|
30567
30567
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30568
30568
|
exports.formatNames = exports.fastFormats = exports.fullFormats = void 0;
|
|
30569
|
-
function fmtDef(
|
|
30570
|
-
return { validate, compare };
|
|
30569
|
+
function fmtDef(validate2, compare) {
|
|
30570
|
+
return { validate: validate2, compare };
|
|
30571
30571
|
}
|
|
30572
30572
|
exports.fullFormats = {
|
|
30573
30573
|
// date: http://tools.ietf.org/html/rfc3339#section-5.6
|
|
@@ -33104,13 +33104,13 @@ var init_streamableHttp = __esm({
|
|
|
33104
33104
|
this.onerror?.(new Error(`Maximum reconnection attempts (${maxRetries}) exceeded.`));
|
|
33105
33105
|
return;
|
|
33106
33106
|
}
|
|
33107
|
-
const
|
|
33107
|
+
const delay3 = this._getNextReconnectionDelay(attemptCount);
|
|
33108
33108
|
this._reconnectionTimeout = setTimeout(() => {
|
|
33109
33109
|
this._startOrAuthSse(options).catch((error2) => {
|
|
33110
33110
|
this.onerror?.(new Error(`Failed to reconnect SSE stream: ${error2 instanceof Error ? error2.message : String(error2)}`));
|
|
33111
33111
|
this._scheduleReconnection(options, attemptCount + 1);
|
|
33112
33112
|
});
|
|
33113
|
-
},
|
|
33113
|
+
}, delay3);
|
|
33114
33114
|
}
|
|
33115
33115
|
_handleSseStream(stream, options, isReconnectable) {
|
|
33116
33116
|
if (!stream) {
|
|
@@ -34182,7 +34182,7 @@ __export(coding_tools_exports, {
|
|
|
34182
34182
|
});
|
|
34183
34183
|
import { existsSync as existsSync17, lstatSync as lstatSync20, mkdirSync as mkdirSync10, readFileSync as readFileSync28, renameSync as renameSync5, unlinkSync as unlinkSync6, writeFileSync as writeFileSync16 } from "node:fs";
|
|
34184
34184
|
import { basename as basename4, dirname as dirname17, join as join22, resolve as resolve24 } from "node:path";
|
|
34185
|
-
import { randomUUID as
|
|
34185
|
+
import { randomUUID as randomUUID13 } from "node:crypto";
|
|
34186
34186
|
function object6(value) {
|
|
34187
34187
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
34188
34188
|
}
|
|
@@ -34222,7 +34222,7 @@ function configureCodingTool(options) {
|
|
|
34222
34222
|
const result = { agent, transport, path, entry, changed };
|
|
34223
34223
|
if (options.dryRun || !changed) return result;
|
|
34224
34224
|
mkdirSync10(dirname17(path), { recursive: true });
|
|
34225
|
-
const temporary = path + "." +
|
|
34225
|
+
const temporary = path + "." + randomUUID13() + ".tmp";
|
|
34226
34226
|
try {
|
|
34227
34227
|
writeFileSync16(temporary, JSON.stringify({ ...config2, [key]: { ...servers, backify: entry } }, null, 2) + "\n", { flag: "wx", mode: existsSync17(path) ? lstatSync20(path).mode & 511 : 384 });
|
|
34228
34228
|
if ((existsSync17(path) ? readFileSync28(path, "utf8") : void 0) !== previous) throw new Error("MCP configuration changed during setup. Retry after reviewing it.");
|
|
@@ -35467,12 +35467,12 @@ function manifestDiagnostics(manifest, used, authentication) {
|
|
|
35467
35467
|
// ../platform/dist/delivery.js
|
|
35468
35468
|
var deliveryInstructions = `# Backify application delivery and prompt history
|
|
35469
35469
|
|
|
35470
|
-
Instruction version:
|
|
35471
|
-
Versioned guide: https://agent.backify.dev/
|
|
35470
|
+
Instruction version: 16
|
|
35471
|
+
Versioned guide: https://agent.backify.dev/v16/delivery.md
|
|
35472
35472
|
|
|
35473
35473
|
## Environment and documentation prerequisites
|
|
35474
35474
|
|
|
35475
|
-
Before installation or connection, read https://agent.backify.dev/
|
|
35475
|
+
Before installation or connection, read https://agent.backify.dev/v16 for execution capability checks, required endpoints (including https://docs.backify.dev), native permission requests, verified retries and fallback guidance. Follow the current tool's supported approval mechanism; never bypass restrictions. Read relevant capability documentation before implementation. Local validation must not depend on cloud deployment.
|
|
35476
35476
|
|
|
35477
35477
|
Before application implementation, all required setup checks and connected status must be verified OK. If any required check fails or remains unverified after supported recovery, stop setup and implementation; do not build a local website, minimal shell, placeholder, dependency-free fallback, or downloadable application archive. Report the blockers and recommend running the setup prompt in an AI coding tool such as Codex, Claude Code, or VS Code with GitHub Copilot agent mode, with terminal access, a persistent writable workspace, package installation, outbound HTTPS/DNS, and test execution enabled. Tool names alone do not guarantee readiness. Do not ask the application requirements question while setup is blocked. Later preview approval or deployment failures do not invalidate an already verified setup gate.
|
|
35478
35478
|
|
|
@@ -35498,7 +35498,7 @@ Initialize using App Id from the copied prompt and the current tool selection:
|
|
|
35498
35498
|
|
|
35499
35499
|
npx @backifydev/cli@latest init --app <app-id> --agent <current-tool>
|
|
35500
35500
|
|
|
35501
|
-
For a tool without a built-in preset, replace --agent <current-tool> with --instruction-file <relative-path>. Read BACKIFY.md and the instruction file used by the current AI coding tool before changing application code. Create or update only instruction files used by that tool; never create files for other coding tools. Use --agent for a built-in tool preset or --instruction-file <relative-path> for the current tool's native instruction file, as described in the setup guide. Initialization installs this workflow alongside the persistent SDK instructions. Follow https://agent.backify.dev/
|
|
35501
|
+
For a tool without a built-in preset, replace --agent <current-tool> with --instruction-file <relative-path>. Read BACKIFY.md and the instruction file used by the current AI coding tool before changing application code. Create or update only instruction files used by that tool; never create files for other coding tools. Use --agent for a built-in tool preset or --instruction-file <relative-path> for the current tool's native instruction file, as described in the setup guide. Initialization installs this workflow alongside the persistent SDK instructions. Follow https://agent.backify.dev/v16 for instruction version 13; use the guide matching backify.json in an existing application. Do not silently upgrade its managed instruction version or overwrite instructions outside the managed block.
|
|
35502
35502
|
|
|
35503
35503
|
Run the following to discover the connected hosting target, repository, branch, reports, releases, and deployment failures:
|
|
35504
35504
|
|
|
@@ -35580,7 +35580,7 @@ These instructions are an explicit agent workflow, not a universal chat intercep
|
|
|
35580
35580
|
`;
|
|
35581
35581
|
|
|
35582
35582
|
// ../platform/dist/index.js
|
|
35583
|
-
var INSTRUCTION_VERSION =
|
|
35583
|
+
var INSTRUCTION_VERSION = 16;
|
|
35584
35584
|
var SDK_PACKAGE = "@backifydev/sdk";
|
|
35585
35585
|
var DOCS_URL = "https://docs.backify.dev";
|
|
35586
35586
|
var MAIL_LIMITS = Object.freeze({
|
|
@@ -35640,6 +35640,7 @@ Before dependent setup operations, follow the environment checks and permission
|
|
|
35640
35640
|
- Server functions: \`defineFunction\`; background work and schedules: \`jobs\` and \`jobs.schedule\`.
|
|
35641
35641
|
- Events and event tracking, outbound HTTP, and AI: \`events\` (\`events.track\` records application events), \`http.fetch\`, and \`ai\`.
|
|
35642
35642
|
- Server-side secrets, configuration, and logs: \`secrets\`, \`config\`, and \`logs\`.
|
|
35643
|
+
- External system integrations: \`integrations\`. Discover organization-permitted definitions and pinned revisions before building a direct integration. Use \`backify integrations connect <provider>\` with the selected environment and requested operations to open browser review and wait for provider setup. The CLI never receives provider tokens. Coding tools may prepare adoption requests; an authorized application manager reviews operations and each account authorizes independently. Never infer readiness from a provider name, bypass organization access, or request credentials in chat. See https://docs.backify.dev/capabilities/integrations/ for discovery, preparation, connection and local-fixture workflows.
|
|
35643
35644
|
|
|
35644
35645
|
Verify API signatures against the installed SDK types and the relevant guide at ${DOCS_URL}/capabilities/. Never invent SDK methods. Use \`@backifydev/sdk/local\` for tests and local development; \`@backifydev/sdk/runtime\` is for runtime hosts, not application code.
|
|
35645
35646
|
|
|
@@ -35858,12 +35859,22 @@ async function diagnoseEnvironment(root = process.cwd(), options = {}, probes =
|
|
|
35858
35859
|
|
|
35859
35860
|
// src/integrations.ts
|
|
35860
35861
|
function integrationDiscoveryPath(command3, options) {
|
|
35861
|
-
const
|
|
35862
|
-
if (!
|
|
35862
|
+
const uuid7 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
35863
|
+
if (!uuid7.test(options.applicationId)) throw new Error("An application UUID is required");
|
|
35863
35864
|
const base = "/apps/" + options.applicationId + "/integrations/connectors";
|
|
35864
35865
|
if (command3 === "list") return base;
|
|
35865
35866
|
if (command3 === "catalog") return "/apps/" + options.applicationId + "/integrations/catalog";
|
|
35866
|
-
if (
|
|
35867
|
+
if (command3 === "discover") return "/apps/" + options.applicationId + "/integrations/discover?" + new URLSearchParams({ query: options.query ?? "" });
|
|
35868
|
+
if (command3 === "prepare") return "/apps/" + options.applicationId + "/integrations/prepare";
|
|
35869
|
+
if (command3 === "contract" && options.revisionId) {
|
|
35870
|
+
if (!uuid7.test(options.revisionId)) throw new Error("Use --revision with a discovered revision UUID");
|
|
35871
|
+
return "/apps/" + options.applicationId + "/integrations/definitions/" + options.revisionId;
|
|
35872
|
+
}
|
|
35873
|
+
if (command3 === "status") {
|
|
35874
|
+
if (!options.adoptionId || !uuid7.test(options.adoptionId)) throw new Error("Use --adoption with an adoption request UUID");
|
|
35875
|
+
return "/apps/" + options.applicationId + "/integrations/adoptions/" + options.adoptionId;
|
|
35876
|
+
}
|
|
35877
|
+
if (!options.connectionId || !uuid7.test(options.connectionId)) throw new Error("Use --connection with an integration connection UUID");
|
|
35867
35878
|
const connection = base + "/" + options.connectionId;
|
|
35868
35879
|
if (command3 === "contract" || command3 === "types") return connection + "/" + command3;
|
|
35869
35880
|
if (command3 === "describe") {
|
|
@@ -35875,7 +35886,256 @@ function integrationDiscoveryPath(command3, options) {
|
|
|
35875
35886
|
const query = new URLSearchParams({ query: options.query ?? "", offset: String(options.offset ?? 0), limit: "50" });
|
|
35876
35887
|
return connection + "/operations?" + query;
|
|
35877
35888
|
}
|
|
35878
|
-
throw new Error("Use backify integrations list|catalog|search|describe|contract|types");
|
|
35889
|
+
throw new Error("Use backify integrations discover|prepare|status|list|catalog|search|describe|contract|types");
|
|
35890
|
+
}
|
|
35891
|
+
function integrationPreparation(input) {
|
|
35892
|
+
for (const value of [input.definitionId, input.revisionId, input.environmentId]) if (!value || !/^[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}$/i.test(value)) throw new Error("Use --definition, --revision and --environment with discovered UUIDs");
|
|
35893
|
+
const mode = input.mode ?? "application";
|
|
35894
|
+
const operations = input.operations?.split(",").map((value) => value.trim()).filter(Boolean) ?? [];
|
|
35895
|
+
if (!["application", "user"].includes(mode) || !operations.length || operations.length > 500 || new Set(operations).size !== operations.length) throw new Error("Use --mode application|user and distinct --operations separated by commas");
|
|
35896
|
+
return { definitionId: input.definitionId, revisionId: input.revisionId, environmentId: input.environmentId, mode, operations };
|
|
35897
|
+
}
|
|
35898
|
+
|
|
35899
|
+
// src/integration-connect.ts
|
|
35900
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
35901
|
+
var integrationConnectHelp = `backify integrations connect <provider> [--app <application>] [--definition <UUID>] [--environment <UUID|name>] [--operations <comma-separated-IDs>] [--mode application|user]
|
|
35902
|
+
backify integrations connect --adoption <UUID> [--app <application>]
|
|
35903
|
+
Options: --no-browser --no-wait --timeout <seconds, 1-1800> --json
|
|
35904
|
+
Requests read operations by default. Browser review and consent remain required; provider credentials stay server-side.
|
|
35905
|
+
Pending setup returns exit code 2. Rerun with --adoption to resume.`;
|
|
35906
|
+
var uuid = /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
|
|
35907
|
+
function validateStatus(status) {
|
|
35908
|
+
if (!uuid.test(status.id) || !["application", "user"].includes(status.mode) || !["review_required", "connection_required", "ready", "reconnect_required", "blocked"].includes(status.state) || status.installationId !== null && !uuid.test(status.installationId) || status.state === "ready" && !status.installationId) throw new Error("The server returned invalid integration readiness metadata.");
|
|
35909
|
+
}
|
|
35910
|
+
function portalOrigin(value) {
|
|
35911
|
+
const url2 = new URL(value);
|
|
35912
|
+
if (url2.protocol !== "https:" && !(url2.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url2.hostname)) || url2.username || url2.password || url2.search || url2.hash || url2.pathname !== "/") throw new Error("Integration review requires a trusted HTTPS portal origin (or an explicit loopback development origin).");
|
|
35913
|
+
return url2.origin;
|
|
35914
|
+
}
|
|
35915
|
+
function reviewUrl(origin, app, status) {
|
|
35916
|
+
const url2 = new URL(status.reviewPath, origin);
|
|
35917
|
+
if (url2.origin !== origin || url2.pathname.toLowerCase() !== "/cli/integrations/" + app + "/" + status.id.toLowerCase() || [...url2.searchParams.keys()].join() !== "organization" || !uuid.test(url2.searchParams.get("organization")) || url2.username || url2.password || url2.hash) throw new Error("The server returned an invalid application integration review link.");
|
|
35918
|
+
return url2.href;
|
|
35919
|
+
}
|
|
35920
|
+
async function connectIntegration(call2, options) {
|
|
35921
|
+
const app = options.applicationId.toLowerCase();
|
|
35922
|
+
if (!uuid.test(app) || options.adoptionId && !uuid.test(options.adoptionId) || options.definitionId && !uuid.test(options.definitionId)) throw new Error("Use valid application, definition and adoption UUIDs.");
|
|
35923
|
+
if (options.mode && !["application", "user"].includes(options.mode)) throw new Error("Use --mode application|user.");
|
|
35924
|
+
const timeout = options.timeoutMs ?? 10 * 6e4;
|
|
35925
|
+
if (!Number.isFinite(timeout) || timeout < 1e3 || timeout > 30 * 6e4) throw new Error("Use --timeout between 1 and 1800 seconds.");
|
|
35926
|
+
const origin = portalOrigin(options.portalUrl), now = options.now ?? Date.now, deadline = now() + timeout;
|
|
35927
|
+
const prefix = "/apps/" + app + "/integrations";
|
|
35928
|
+
let status;
|
|
35929
|
+
if (options.adoptionId) status = await call2(prefix + "/adoptions/" + options.adoptionId + "?compact=true");
|
|
35930
|
+
else {
|
|
35931
|
+
const query = options.provider?.trim() ?? "";
|
|
35932
|
+
if (!query && !options.definitionId || query.length > 200 || /[\x00-\x1f\x7f]/.test(query)) throw new Error("Use backify integrations connect <provider> or --definition <UUID>.");
|
|
35933
|
+
let definitions = await call2(integrationDiscoveryPath("discover", { applicationId: app, query }));
|
|
35934
|
+
if (options.definitionId) definitions = definitions.filter((value) => value.definitionId.toLowerCase() === options.definitionId.toLowerCase());
|
|
35935
|
+
if (definitions.length === 0) return { state: "blocked", nextAction: "No permitted definition matches. Ask an organization administrator to enable or review it and allow this application." };
|
|
35936
|
+
if (definitions.length > 1) return { state: "selection_required", nextAction: "Choose --definition with one of the permitted definition IDs.", definitions: definitions.map(({ definitionId, name: name2, providerId }) => ({ definitionId, name: name2, providerId })) };
|
|
35937
|
+
const definition = definitions[0];
|
|
35938
|
+
const mode = options.mode ?? "application";
|
|
35939
|
+
if (!definition.connectionModes.includes(mode)) throw new Error("This definition does not support the requested connection mode.");
|
|
35940
|
+
const environments = (await call2(prefix + "/environments")).filter((value) => !value.expiresAt || Date.parse(value.expiresAt) > now());
|
|
35941
|
+
const selected = options.environment ? environments.filter((value) => value.id.toLowerCase() === options.environment.toLowerCase() || value.name.toLowerCase() === options.environment.toLowerCase()) : environments;
|
|
35942
|
+
if (selected.length !== 1) return { state: "selection_required", nextAction: "Choose --environment with an active environment UUID. No environment was selected automatically.", environments: environments.map(({ id, name: name2 }) => ({ id, name: name2 })) };
|
|
35943
|
+
const operations = options.operations ?? definition.operations.filter((operation) => operation.readOnly).map((operation) => operation.id).join(",");
|
|
35944
|
+
if (!operations) return { state: "selection_required", nextAction: "Specify the requested --operations. This definition has no read operations to use as the default.", operations: definition.operations };
|
|
35945
|
+
const preparation = integrationPreparation({ definitionId: definition.definitionId, revisionId: definition.revisionId, environmentId: selected[0].id, mode, operations });
|
|
35946
|
+
options.progress?.("Preparing reviewed integration access. Requested operations: " + operations);
|
|
35947
|
+
status = await call2(prefix + "/prepare", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(preparation) });
|
|
35948
|
+
}
|
|
35949
|
+
validateStatus(status);
|
|
35950
|
+
const link = reviewUrl(origin, app, status);
|
|
35951
|
+
async function result(reason) {
|
|
35952
|
+
const approved = status.state === "ready" || status.mode === "user" && !status.providerSetupRequired && status.state === "connection_required" && status.installationId;
|
|
35953
|
+
const binding = approved && status.installationId ? await call2(integrationDiscoveryPath("types", { applicationId: app, connectionId: status.installationId })) : void 0;
|
|
35954
|
+
return {
|
|
35955
|
+
state: status.state,
|
|
35956
|
+
adoptionId: status.id,
|
|
35957
|
+
connectionId: status.installationId,
|
|
35958
|
+
mode: status.mode,
|
|
35959
|
+
reviewUrl: link,
|
|
35960
|
+
nextAction: status.nextAction,
|
|
35961
|
+
...reason ? { reason } : {},
|
|
35962
|
+
...binding ? { bindings: binding.source } : {},
|
|
35963
|
+
...approved && status.mode === "user" ? { userConnectionFlowRequired: true } : {}
|
|
35964
|
+
};
|
|
35965
|
+
}
|
|
35966
|
+
if (status.state === "ready" || status.state === "blocked") return result();
|
|
35967
|
+
if (options.signal?.aborted) return result("cancelled");
|
|
35968
|
+
options.progress?.("Open your browser to review access and complete provider setup:\n" + link);
|
|
35969
|
+
if (!options.noBrowser) {
|
|
35970
|
+
try {
|
|
35971
|
+
options.openBrowser(link);
|
|
35972
|
+
} catch {
|
|
35973
|
+
options.progress?.("Open the review URL above manually; automatic browser launch failed.");
|
|
35974
|
+
}
|
|
35975
|
+
}
|
|
35976
|
+
if (status.mode === "user" && !status.providerSetupRequired && status.installationId && status.state === "connection_required") return result();
|
|
35977
|
+
if (options.noWait) return result("waiting_in_browser");
|
|
35978
|
+
let previous = "";
|
|
35979
|
+
while (true) {
|
|
35980
|
+
if (status.state !== previous) {
|
|
35981
|
+
options.progress?.("Integration setup: " + status.state + ". " + status.nextAction);
|
|
35982
|
+
previous = status.state;
|
|
35983
|
+
}
|
|
35984
|
+
if (status.state === "ready" || status.state === "blocked" || status.mode === "user" && !status.providerSetupRequired && status.installationId && status.state === "connection_required") return result();
|
|
35985
|
+
if (options.signal?.aborted) return result("cancelled");
|
|
35986
|
+
if (now() >= deadline) return result("timed_out");
|
|
35987
|
+
try {
|
|
35988
|
+
await (options.sleep ?? ((ms) => delay(ms, void 0, { signal: options.signal })))(Math.min(2e3, deadline - now()));
|
|
35989
|
+
} catch (error2) {
|
|
35990
|
+
if (options.signal?.aborted) return result("cancelled");
|
|
35991
|
+
throw error2;
|
|
35992
|
+
}
|
|
35993
|
+
if (options.signal?.aborted) return result("cancelled");
|
|
35994
|
+
status = await call2(prefix + "/adoptions/" + status.id + "?compact=true");
|
|
35995
|
+
validateStatus(status);
|
|
35996
|
+
if (reviewUrl(origin, app, status) !== link) throw new Error("The integration review identity changed while waiting.");
|
|
35997
|
+
}
|
|
35998
|
+
}
|
|
35999
|
+
function integrationConnectArguments(args2) {
|
|
36000
|
+
const values = {}, flags = /* @__PURE__ */ new Set();
|
|
36001
|
+
let provider;
|
|
36002
|
+
const booleans = ["--no-browser", "--no-wait", "--json"];
|
|
36003
|
+
const valued = ["--app", "--definition", "--environment", "--operations", "--mode", "--adoption", "--timeout"];
|
|
36004
|
+
for (let i = 0; i < args2.length; i++) {
|
|
36005
|
+
const value = args2[i];
|
|
36006
|
+
if (booleans.includes(value)) {
|
|
36007
|
+
if (flags.has(value)) throw new Error("Duplicate connect option: " + value);
|
|
36008
|
+
flags.add(value);
|
|
36009
|
+
} else if (valued.includes(value)) {
|
|
36010
|
+
if (value in values || !args2[i + 1] || args2[i + 1].startsWith("--")) throw new Error("Specify one value for " + value);
|
|
36011
|
+
values[value] = args2[++i];
|
|
36012
|
+
} else if (value.startsWith("--") || provider) throw new Error("Unknown integration connect argument: " + value);
|
|
36013
|
+
else provider = value;
|
|
36014
|
+
}
|
|
36015
|
+
if (values["--adoption"] && (provider || ["--definition", "--environment", "--operations", "--mode"].some((key) => values[key]))) throw new Error("Resume with --adoption and --app only, plus browser/wait options.");
|
|
36016
|
+
return {
|
|
36017
|
+
provider,
|
|
36018
|
+
definitionId: values["--definition"],
|
|
36019
|
+
environment: values["--environment"],
|
|
36020
|
+
operations: values["--operations"],
|
|
36021
|
+
mode: values["--mode"],
|
|
36022
|
+
adoptionId: values["--adoption"],
|
|
36023
|
+
noBrowser: flags.has("--no-browser"),
|
|
36024
|
+
noWait: flags.has("--no-wait"),
|
|
36025
|
+
timeoutMs: values["--timeout"] === void 0 ? void 0 : Number(values["--timeout"]) * 1e3
|
|
36026
|
+
};
|
|
36027
|
+
}
|
|
36028
|
+
|
|
36029
|
+
// src/domain-connect.ts
|
|
36030
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
36031
|
+
import { setTimeout as delay2 } from "node:timers/promises";
|
|
36032
|
+
import { domainToASCII } from "node:url";
|
|
36033
|
+
var domainConnectHelp = `backify domains connect [hostname] [--app <application>] [--environment preview|production]
|
|
36034
|
+
backify domains connect --request <UUID> [--app <application>]
|
|
36035
|
+
Options: --hostname <hostname> --no-browser --no-wait --timeout <seconds, 1-3600> --json
|
|
36036
|
+
Opens a setup page where an authorized user signs in and confirms the hostname and environment, then returns as soon
|
|
36037
|
+
as the domain is confirmed. It does not wait for DNS: Backify verifies the DNS records, issues managed HTTPS and starts
|
|
36038
|
+
routing automatically once the user adds them. Exit code 0 means confirmed; 2 means not yet confirmed or blocked.
|
|
36039
|
+
Re-run with --request to read the current status without reopening the browser.`;
|
|
36040
|
+
var uuid2 = /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
|
|
36041
|
+
var confirmedStates = ["dns_required", "certificate_pending", "ready"];
|
|
36042
|
+
function customHostname(input) {
|
|
36043
|
+
const hostname3 = domainToASCII(input.trim().replace(/\.$/, "")).toLowerCase(), labels = hostname3.split(".");
|
|
36044
|
+
if (/[\s:/\\@?#%*]/.test(input.trim()) || hostname3.length > 253 || labels.length < 2 || labels.some((label) => !/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(label)) || !/^[a-z][a-z0-9-]*$/.test(labels.at(-1)) || ["backify.dev", "backify.site"].some((suffix) => hostname3 === suffix || hostname3.endsWith("." + suffix))) throw new Error("Use a custom DNS hostname without a URL, path, port or wildcard.");
|
|
36045
|
+
return hostname3;
|
|
36046
|
+
}
|
|
36047
|
+
function portalOrigin2(input) {
|
|
36048
|
+
const url2 = new URL(input);
|
|
36049
|
+
if (url2.protocol !== "https:" && !(url2.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url2.hostname)) || url2.username || url2.password || url2.search || url2.hash || url2.pathname !== "/") throw new Error("Use a trusted HTTPS portal origin, or an explicit loopback development origin.");
|
|
36050
|
+
return url2.origin;
|
|
36051
|
+
}
|
|
36052
|
+
function validate(status, app) {
|
|
36053
|
+
if (!uuid2.test(status.id) || status.applicationId !== app || !["review_required", "dns_required", "certificate_pending", "ready", "blocked"].includes(status.state) || status.domainId !== null && !uuid2.test(status.domainId)) throw new Error("The server returned invalid domain setup metadata.");
|
|
36054
|
+
if (["dns_required", "certificate_pending"].includes(status.state) && (!status.domainId || !status.hostname || !["preview", "production"].includes(status.environment ?? ""))) throw new Error("The server returned invalid domain setup metadata.");
|
|
36055
|
+
if (status.state === "ready" && (!status.domainId || !status.hostname || customHostname(status.hostname) !== status.hostname || status.verificationStatus !== "verified" || status.certificateStatus !== "managed" || status.bindingStatus !== "ready" || !["preview", "production"].includes(status.environment ?? "") || status.url !== "https://" + status.hostname)) throw new Error("The server has not established verified DNS, managed HTTPS and routing for this domain.");
|
|
36056
|
+
}
|
|
36057
|
+
function reviewUrl2(origin, app, status) {
|
|
36058
|
+
const url2 = new URL(status.reviewPath, origin);
|
|
36059
|
+
if (url2.origin !== origin || url2.pathname.toLowerCase() !== "/cli/domains/" + app + "/" + status.id.toLowerCase() || [...url2.searchParams.keys()].join() !== "organization" || !uuid2.test(url2.searchParams.get("organization")) || url2.username || url2.password || url2.hash) throw new Error("The server returned an invalid application domain setup link.");
|
|
36060
|
+
return url2.href;
|
|
36061
|
+
}
|
|
36062
|
+
async function connectDomain(call2, options) {
|
|
36063
|
+
const app = options.applicationId.toLowerCase(), timeout = options.timeoutMs ?? 6e5;
|
|
36064
|
+
if (!uuid2.test(app) || options.requestId && !uuid2.test(options.requestId)) throw new Error("Use valid application and domain setup request IDs.");
|
|
36065
|
+
if (options.environment && !["preview", "production"].includes(options.environment)) throw new Error("Use --environment preview|production, or choose in the browser.");
|
|
36066
|
+
if (!Number.isFinite(timeout) || timeout < 1e3 || timeout > 36e5) throw new Error("Use --timeout between 1 and 3600 seconds.");
|
|
36067
|
+
const hostname3 = options.hostname === void 0 ? void 0 : customHostname(options.hostname), origin = portalOrigin2(options.portalUrl), now = options.now ?? Date.now, deadline = now() + timeout;
|
|
36068
|
+
const base = "/apps/" + app + "/domains/connections";
|
|
36069
|
+
let status = options.requestId ? await call2(base + "/" + options.requestId) : await call2(base, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ hostname: hostname3 ?? null, environment: options.environment ?? null, requestKey: randomUUID2() }) });
|
|
36070
|
+
validate(status, app);
|
|
36071
|
+
const link = reviewUrl2(origin, app, status);
|
|
36072
|
+
const result = (reason) => ({
|
|
36073
|
+
state: status.state,
|
|
36074
|
+
confirmed: confirmedStates.includes(status.state),
|
|
36075
|
+
requestId: status.id,
|
|
36076
|
+
applicationId: app,
|
|
36077
|
+
domainId: status.domainId,
|
|
36078
|
+
hostname: status.hostname,
|
|
36079
|
+
environment: status.environment,
|
|
36080
|
+
verificationStatus: status.verificationStatus,
|
|
36081
|
+
certificateStatus: status.certificateStatus,
|
|
36082
|
+
bindingStatus: status.bindingStatus,
|
|
36083
|
+
setupUrl: link,
|
|
36084
|
+
nextAction: status.nextAction,
|
|
36085
|
+
// The address the domain will serve once DNS is verified; `url` is set only when it already does.
|
|
36086
|
+
expectedUrl: status.hostname ? "https://" + status.hostname : null,
|
|
36087
|
+
url: status.state === "ready" ? status.url : null,
|
|
36088
|
+
...reason ? { reason } : {}
|
|
36089
|
+
});
|
|
36090
|
+
if (status.state !== "review_required") return result();
|
|
36091
|
+
if (options.signal?.aborted) return result("cancelled");
|
|
36092
|
+
options.progress?.("Open this page to sign in and confirm the custom domain:\n" + link);
|
|
36093
|
+
if (!options.noBrowser) {
|
|
36094
|
+
try {
|
|
36095
|
+
options.openBrowser(link);
|
|
36096
|
+
} catch {
|
|
36097
|
+
options.progress?.("Automatic browser launch failed. Open the setup URL manually.");
|
|
36098
|
+
}
|
|
36099
|
+
}
|
|
36100
|
+
if (options.noWait) return result("waiting_in_browser");
|
|
36101
|
+
options.progress?.("Waiting for confirmation in the browser\u2026");
|
|
36102
|
+
while (true) {
|
|
36103
|
+
if (status.state !== "review_required") {
|
|
36104
|
+
options.progress?.(status.nextAction);
|
|
36105
|
+
return result();
|
|
36106
|
+
}
|
|
36107
|
+
if (options.signal?.aborted) return result("cancelled");
|
|
36108
|
+
if (now() >= deadline) return result("timed_out");
|
|
36109
|
+
try {
|
|
36110
|
+
await (options.sleep ?? ((ms) => delay2(ms, void 0, { signal: options.signal })))(Math.min(3e3, deadline - now()));
|
|
36111
|
+
} catch (error2) {
|
|
36112
|
+
if (options.signal?.aborted) return result("cancelled");
|
|
36113
|
+
throw error2;
|
|
36114
|
+
}
|
|
36115
|
+
if (options.signal?.aborted) return result("cancelled");
|
|
36116
|
+
status = await call2(base + "/" + status.id);
|
|
36117
|
+
validate(status, app);
|
|
36118
|
+
if (reviewUrl2(origin, app, status) !== link) throw new Error("The domain setup request changed while waiting.");
|
|
36119
|
+
}
|
|
36120
|
+
}
|
|
36121
|
+
function domainConnectArguments(args2) {
|
|
36122
|
+
const values = {}, flags = /* @__PURE__ */ new Set();
|
|
36123
|
+
let hostname3;
|
|
36124
|
+
for (let i = 0; i < args2.length; i++) {
|
|
36125
|
+
const value = args2[i];
|
|
36126
|
+
if (["--json", "--no-browser", "--no-wait"].includes(value)) {
|
|
36127
|
+
if (flags.has(value)) throw new Error("Duplicate domain option: " + value);
|
|
36128
|
+
flags.add(value);
|
|
36129
|
+
} else if (["--app", "--hostname", "--environment", "--request", "--timeout"].includes(value)) {
|
|
36130
|
+
if (value in values || !args2[i + 1] || args2[i + 1].startsWith("--")) throw new Error("Specify one value for " + value);
|
|
36131
|
+
values[value] = args2[++i];
|
|
36132
|
+
} else if (value.startsWith("--") || hostname3) throw new Error("Unknown domains connect argument: " + value);
|
|
36133
|
+
else hostname3 = value;
|
|
36134
|
+
}
|
|
36135
|
+
if (hostname3 && values["--hostname"]) throw new Error("Specify the hostname once.");
|
|
36136
|
+
hostname3 ??= values["--hostname"];
|
|
36137
|
+
if (values["--request"] && (hostname3 || values["--environment"])) throw new Error("Resume with --request; do not change its hostname or environment.");
|
|
36138
|
+
return { hostname: hostname3, environment: values["--environment"], requestId: values["--request"], noBrowser: flags.has("--no-browser"), noWait: flags.has("--no-wait"), timeoutMs: values["--timeout"] === void 0 ? void 0 : Number(values["--timeout"]) * 1e3 };
|
|
35879
36139
|
}
|
|
35880
36140
|
|
|
35881
36141
|
// src/pairing.ts
|
|
@@ -35910,7 +36170,7 @@ import { hostname, platform, release, arch } from "node:os";
|
|
|
35910
36170
|
// package.json
|
|
35911
36171
|
var package_default = {
|
|
35912
36172
|
name: "@backifydev/cli",
|
|
35913
|
-
version: "0.3.
|
|
36173
|
+
version: "0.3.21",
|
|
35914
36174
|
description: "Command-line setup and diagnostics for Backify applications",
|
|
35915
36175
|
type: "module",
|
|
35916
36176
|
bin: {
|
|
@@ -35978,7 +36238,7 @@ import { createServer as createServer2 } from "node:http";
|
|
|
35978
36238
|
import { existsSync as existsSync7, readFileSync as readFileSync7, readdirSync as readdirSync2, writeFileSync as writeFileSync6, renameSync, rmSync, mkdtempSync, lstatSync as lstatSync3, cpSync } from "node:fs";
|
|
35979
36239
|
import { dirname as dirname4, join as join7, resolve as resolve4 } from "node:path";
|
|
35980
36240
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
35981
|
-
import { randomUUID as
|
|
36241
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
35982
36242
|
|
|
35983
36243
|
// src/setup.ts
|
|
35984
36244
|
import { existsSync as existsSync5, readFileSync as readFileSync5, writeFileSync as writeFileSync5, mkdirSync as mkdirSync2, readdirSync, lstatSync as lstatSync2 } from "node:fs";
|
|
@@ -36286,7 +36546,7 @@ function apiClient(session, transport = fetch) {
|
|
|
36286
36546
|
};
|
|
36287
36547
|
}
|
|
36288
36548
|
function saveUserConfig(path, config2) {
|
|
36289
|
-
const temporary = path + "." +
|
|
36549
|
+
const temporary = path + "." + randomUUID3() + ".tmp";
|
|
36290
36550
|
try {
|
|
36291
36551
|
writeFileSync6(temporary, JSON.stringify(config2, null, 2) + "\n", { mode: 384, flag: "wx" });
|
|
36292
36552
|
if (process.platform === "win32") {
|
|
@@ -36429,7 +36689,7 @@ function pushSource(appId, commit, branch, destination, root, environment) {
|
|
|
36429
36689
|
}
|
|
36430
36690
|
async function waitForPreview(call2, prefix, commit, options = {}) {
|
|
36431
36691
|
const deadline = Date.now() + (options.timeoutMs ?? 20 * 6e4);
|
|
36432
|
-
const sleep = options.sleep ?? ((
|
|
36692
|
+
const sleep = options.sleep ?? ((delay3) => new Promise((resolve25) => setTimeout(resolve25, delay3)));
|
|
36433
36693
|
do {
|
|
36434
36694
|
const deployments = await call2(prefix + "/deployments");
|
|
36435
36695
|
const matching = deployments.find((release2) => release2.kind === "preview" && matchesSource(release2, commit) && !options.previousDeploymentIds?.includes(release2.id));
|
|
@@ -36623,7 +36883,7 @@ function reconnectingApiClient(session, reconnect, transport = fetch) {
|
|
|
36623
36883
|
}
|
|
36624
36884
|
|
|
36625
36885
|
// src/local-runtime.ts
|
|
36626
|
-
import { createHash as createHash2, randomUUID as
|
|
36886
|
+
import { createHash as createHash2, randomUUID as randomUUID4 } from "node:crypto";
|
|
36627
36887
|
import { chmodSync, existsSync as existsSync8, lstatSync as lstatSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync8, readdirSync as readdirSync3, writeFileSync as writeFileSync7 } from "node:fs";
|
|
36628
36888
|
import { dirname as dirname5, join as join8, resolve as resolve5, sep } from "node:path";
|
|
36629
36889
|
import { homedir } from "node:os";
|
|
@@ -36706,7 +36966,7 @@ function installLocalRuntime(archive, options) {
|
|
|
36706
36966
|
const destination = checkedPath(parent, rid);
|
|
36707
36967
|
const receipt = { version: options.version, rid, files: Object.fromEntries(Object.entries(files).map(([name2, bytes]) => [name2, hash(bytes)])) };
|
|
36708
36968
|
if (!existsSync8(destination)) {
|
|
36709
|
-
const staging = checkedPath(parent, ".install-" +
|
|
36969
|
+
const staging = checkedPath(parent, ".install-" + randomUUID4());
|
|
36710
36970
|
mkdirSync3(staging, { mode: 448 });
|
|
36711
36971
|
for (const [name2, bytes] of Object.entries(files)) {
|
|
36712
36972
|
const filename2 = checkedPath(staging, name2);
|
|
@@ -36720,7 +36980,7 @@ function installLocalRuntime(archive, options) {
|
|
|
36720
36980
|
for (const [name2, digest4] of Object.entries(receipt.files)) if (hash(readFileSync8(checkedPath(destination, name2))) !== digest4) throw new Error("Runtime version already exists with different bytes; never overwrite an installation");
|
|
36721
36981
|
}
|
|
36722
36982
|
const pointer = checkedPath(base, "runtime.json");
|
|
36723
|
-
const temporary = checkedPath(base, ".runtime-" +
|
|
36983
|
+
const temporary = checkedPath(base, ".runtime-" + randomUUID4() + ".json");
|
|
36724
36984
|
writeFileSync7(temporary, JSON.stringify(receipt), { flag: "wx", mode: 384 });
|
|
36725
36985
|
renameLocalFile(temporary, pointer);
|
|
36726
36986
|
return installedLocalRuntime(base);
|
|
@@ -36767,7 +37027,7 @@ import { dirname as dirname13, isAbsolute as isAbsolute14, join as join17, relat
|
|
|
36767
37027
|
// src/local-development.ts
|
|
36768
37028
|
import { context as context2, formatMessagesSync } from "esbuild";
|
|
36769
37029
|
import { spawn as spawn4 } from "node:child_process";
|
|
36770
|
-
import { randomBytes as randomBytes6, randomUUID as
|
|
37030
|
+
import { randomBytes as randomBytes6, randomUUID as randomUUID12, createHash as createHash13 } from "node:crypto";
|
|
36771
37031
|
import { existsSync as existsSync14, lstatSync as lstatSync16, mkdirSync as mkdirSync6, readFileSync as readFileSync22, realpathSync as realpathSync5, writeFileSync as writeFileSync12, unlinkSync as unlinkSync5 } from "node:fs";
|
|
36772
37032
|
import { resolve as resolve18, join as join16, relative as relative7, isAbsolute as isAbsolute13, dirname as dirname12 } from "node:path";
|
|
36773
37033
|
|
|
@@ -37246,7 +37506,7 @@ function declarationInput(declaration) {
|
|
|
37246
37506
|
}
|
|
37247
37507
|
|
|
37248
37508
|
// ../sdk/dist/local-identity.js
|
|
37249
|
-
import { createHash as createHash3, randomBytes as randomBytes2, randomUUID as
|
|
37509
|
+
import { createHash as createHash3, randomBytes as randomBytes2, randomUUID as randomUUID5 } from "node:crypto";
|
|
37250
37510
|
|
|
37251
37511
|
// ../sdk/dist/application-auth.js
|
|
37252
37512
|
import { createPublicKey, verify } from "node:crypto";
|
|
@@ -37260,7 +37520,7 @@ var ApplicationAuthenticationError = class extends Error {
|
|
|
37260
37520
|
this.status = code === "application_identity_unavailable" ? 503 : code === "application_identity_forbidden" ? 403 : 401;
|
|
37261
37521
|
}
|
|
37262
37522
|
};
|
|
37263
|
-
var
|
|
37523
|
+
var uuid3 = (value) => typeof value === "string" && /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(value) && value !== "00000000-0000-0000-0000-000000000000";
|
|
37264
37524
|
var object2 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
37265
37525
|
var text = (value, maximum) => typeof value === "string" && value.length > 0 && value.length <= maximum && !/[\x00-\x1f\x7f]/.test(value);
|
|
37266
37526
|
function invalid() {
|
|
@@ -37306,7 +37566,7 @@ function json(segment) {
|
|
|
37306
37566
|
}
|
|
37307
37567
|
}
|
|
37308
37568
|
function scopeValid(scope) {
|
|
37309
|
-
return object2(scope) && Object.keys(scope).length === 3 &&
|
|
37569
|
+
return object2(scope) && Object.keys(scope).length === 3 && uuid3(scope.organizationId) && uuid3(scope.applicationId) && uuid3(scope.environmentId);
|
|
37310
37570
|
}
|
|
37311
37571
|
function sameScope(left, right) {
|
|
37312
37572
|
return left.organizationId === right.organizationId && left.applicationId === right.applicationId && left.environmentId === right.environmentId;
|
|
@@ -37399,7 +37659,7 @@ function createApplicationAuthProvider(source, options) {
|
|
|
37399
37659
|
const payload = json(match[2]);
|
|
37400
37660
|
fields(payload, ["ver", "iss", "aud", "sub", "organization_id", "application_id", "environment_id", "iat", "nbf", "exp", "jti", "display_name", "email", "organization_name", "roles"]);
|
|
37401
37661
|
const time3 = now();
|
|
37402
|
-
if (payload.ver !== 1 || payload.iss !== trust.issuer || payload.aud !== trust.audience || !
|
|
37662
|
+
if (payload.ver !== 1 || payload.iss !== trust.issuer || payload.aud !== trust.audience || !uuid3(payload.sub) || payload.organization_id !== expectedScope.organizationId || payload.application_id !== expectedScope.applicationId || payload.environment_id !== expectedScope.environmentId || !uuid3(payload.jti) || !Number.isSafeInteger(payload.iat) || !Number.isSafeInteger(payload.nbf) || !Number.isSafeInteger(payload.exp))
|
|
37403
37663
|
invalid();
|
|
37404
37664
|
const issued = payload.iat, notBefore = payload.nbf, expires = payload.exp;
|
|
37405
37665
|
if (issued < 0 || issued > time3 || notBefore !== issued || expires <= time3 || expires <= issued || expires - issued > 300 || !text(payload.display_name, 200) || !text(payload.organization_name, 200) || payload.email !== void 0 && !text(payload.email, 320))
|
|
@@ -37423,14 +37683,14 @@ function createLocalIdentityProvider(options) {
|
|
|
37423
37683
|
serverOnly();
|
|
37424
37684
|
if (typeof process !== "undefined" && process.env.NODE_ENV === "production")
|
|
37425
37685
|
throw new Error("Local Backify identities must not run in production");
|
|
37426
|
-
const
|
|
37686
|
+
const uuid7 = (value) => typeof value === "string" && /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(value) && value !== "00000000-0000-0000-0000-000000000000";
|
|
37427
37687
|
const text3 = (value, maximum) => typeof value === "string" && value.length > 0 && value.length <= maximum && !/[\x00-\x1f\x7f]/.test(value);
|
|
37428
|
-
if (!options.scope || Object.keys(options.scope).length !== 3 || !
|
|
37688
|
+
if (!options.scope || Object.keys(options.scope).length !== 3 || !uuid7(options.scope.organizationId) || !uuid7(options.scope.applicationId) || !uuid7(options.scope.environmentId) || !text3(options.organizationName, 200) || !Array.isArray(options.users) || options.users.length < 1 || options.users.length > 32 || !Array.isArray(options.requestOrigins) || options.requestOrigins.length < 1 || options.requestOrigins.length > 8)
|
|
37429
37689
|
throw new Error("Invalid local identity configuration");
|
|
37430
37690
|
const scope = { ...options.scope }, organizationName = options.organizationName;
|
|
37431
37691
|
const users = /* @__PURE__ */ new Map();
|
|
37432
37692
|
for (const user of options.users) {
|
|
37433
|
-
if (!user || Object.keys(user).some((name2) => !["id", "displayName", "email", "roles"].includes(name2)) || !
|
|
37693
|
+
if (!user || Object.keys(user).some((name2) => !["id", "displayName", "email", "roles"].includes(name2)) || !uuid7(user.id) || users.has(user.id) || !text3(user.displayName, 200) || user.email !== void 0 && !text3(user.email, 320))
|
|
37434
37694
|
throw new Error("Invalid local identity user");
|
|
37435
37695
|
if (user.roles !== void 0 && (!Array.isArray(user.roles) || user.roles.length > 32 || user.roles.some((role) => !role || Object.keys(role).some((name2) => !["name", "permissions"].includes(name2)) || !text3(role.name, 100) || !Array.isArray(role.permissions) || role.permissions.length > 128 || role.permissions.some((permission) => !text3(permission, 100)) || new Set(role.permissions).size !== role.permissions.length) || new Set(user.roles.map((role) => role.name)).size !== user.roles.length))
|
|
37436
37696
|
throw new Error("Invalid local identity roles");
|
|
@@ -37508,8 +37768,8 @@ function createLocalIdentityProvider(options) {
|
|
|
37508
37768
|
}
|
|
37509
37769
|
};
|
|
37510
37770
|
}
|
|
37511
|
-
function createLocalEmailAuth(options, crypto2 = { createHash: createHash3, randomBytes: randomBytes2, randomUUID:
|
|
37512
|
-
const { createHash: createHash17, randomBytes: randomBytes7, randomUUID:
|
|
37771
|
+
function createLocalEmailAuth(options, crypto2 = { createHash: createHash3, randomBytes: randomBytes2, randomUUID: randomUUID5 }) {
|
|
37772
|
+
const { createHash: createHash17, randomBytes: randomBytes7, randomUUID: randomUUID14 } = crypto2;
|
|
37513
37773
|
const origin = new URL(options.origin);
|
|
37514
37774
|
if (typeof window !== "undefined" || process.env.NODE_ENV === "production" || !["localhost", "127.0.0.1", "[::1]"].includes(origin.hostname) || !["http:", "https:"].includes(origin.protocol) || options.origin !== origin.origin)
|
|
37515
37775
|
throw new Error("Local email authentication requires an exact loopback origin outside production");
|
|
@@ -37577,7 +37837,7 @@ function createLocalEmailAuth(options, crypto2 = { createHash: createHash3, rand
|
|
|
37577
37837
|
challenges.delete(id2);
|
|
37578
37838
|
if (challenges.size >= 128)
|
|
37579
37839
|
return json4({ error: "rate_limited" }, 429);
|
|
37580
|
-
const id =
|
|
37840
|
+
const id = randomUUID14(), proof = random2(), secret = random2();
|
|
37581
37841
|
const profile = options.identity.profiles().find((item) => item.email?.toLowerCase() === email2);
|
|
37582
37842
|
if (profile) {
|
|
37583
37843
|
challenges.set(id, { userId: profile.id, proof: hash2(proof), token: hash2(secret), expires: clock() + 6e5 });
|
|
@@ -37824,7 +38084,7 @@ import { lstatSync as lstatSync12, readFileSync as readFileSync16 } from "node:f
|
|
|
37824
38084
|
import { isAbsolute as isAbsolute8, join as join12, relative as relative3, resolve as resolve12 } from "node:path";
|
|
37825
38085
|
|
|
37826
38086
|
// ../sdk/dist/application-auth-state.js
|
|
37827
|
-
import { createHash as createHash4, randomUUID as
|
|
38087
|
+
import { createHash as createHash4, randomUUID as randomUUID6 } from "node:crypto";
|
|
37828
38088
|
import { closeSync, constants, fstatSync, fsyncSync, lstatSync as lstatSync5, openSync, readSync, renameSync as renameSync3, unlinkSync as unlinkSync2, writeFileSync as writeFileSync8 } from "node:fs";
|
|
37829
38089
|
import { dirname as dirname6, isAbsolute as isAbsolute2, parse, resolve as resolve6, sep as sep2 } from "node:path";
|
|
37830
38090
|
function unavailable2() {
|
|
@@ -37897,7 +38157,7 @@ function readState(filename2) {
|
|
|
37897
38157
|
}
|
|
37898
38158
|
}
|
|
37899
38159
|
function persist(filename2, state) {
|
|
37900
|
-
const temporary = filename2 + "." +
|
|
38160
|
+
const temporary = filename2 + "." + randomUUID6() + ".tmp";
|
|
37901
38161
|
const descriptor2 = openSync(temporary, "wx", 384);
|
|
37902
38162
|
try {
|
|
37903
38163
|
writeFileSync8(descriptor2, JSON.stringify(state));
|
|
@@ -37978,7 +38238,7 @@ function createPersistentApplicationAuthProvider(source, options) {
|
|
|
37978
38238
|
}
|
|
37979
38239
|
|
|
37980
38240
|
// ../sdk/dist/application-auth-sync.js
|
|
37981
|
-
import { createHash as createHash5, createPublicKey as createPublicKey2, randomUUID as
|
|
38241
|
+
import { createHash as createHash5, createPublicKey as createPublicKey2, randomUUID as randomUUID7, verify as verify2 } from "node:crypto";
|
|
37982
38242
|
import { closeSync as closeSync2, constants as constants2, fsyncSync as fsyncSync2, lstatSync as lstatSync6, openSync as openSync2, readFileSync as readFileSync10, renameSync as renameSync4, unlinkSync as unlinkSync3, writeFileSync as writeFileSync9 } from "node:fs";
|
|
37983
38243
|
import { dirname as dirname7, isAbsolute as isAbsolute3, parse as parse2, resolve as resolve7, sep as sep3 } from "node:path";
|
|
37984
38244
|
var maximumBytes = 512 * 1024;
|
|
@@ -38133,7 +38393,7 @@ async function synchronizeApplicationAuthTrustWithDigest(options) {
|
|
|
38133
38393
|
if (current === content)
|
|
38134
38394
|
return { status: "unchanged", revision: trust.revision, validUntil: trust.validUntil, trustDigest };
|
|
38135
38395
|
writePending = true;
|
|
38136
|
-
const temporary = prepared.trustFile + "." +
|
|
38396
|
+
const temporary = prepared.trustFile + "." + randomUUID7() + ".tmp";
|
|
38137
38397
|
const output = openSync2(temporary, "wx", process.platform === "win32" ? 384 : 292);
|
|
38138
38398
|
try {
|
|
38139
38399
|
writeFileSync9(output, content);
|
|
@@ -38341,10 +38601,10 @@ function createHcrEventsProvider(options) {
|
|
|
38341
38601
|
}
|
|
38342
38602
|
if (retry !== void 0 && typeof retry !== "boolean")
|
|
38343
38603
|
throw new Error("Invalid event delivery receipt");
|
|
38344
|
-
const
|
|
38345
|
-
if (
|
|
38604
|
+
const delay3 = completeOptions?.retryDelaySeconds;
|
|
38605
|
+
if (delay3 !== void 0 && (!Number.isInteger(delay3) || delay3 < 0 || delay3 > 3600 || !retry && delay3 !== 0))
|
|
38346
38606
|
throw new Error("Invalid event retry delay");
|
|
38347
|
-
await request("/" + id + "/complete", { receipt, retry: retry ?? false, ...
|
|
38607
|
+
await request("/" + id + "/complete", { receipt, retry: retry ?? false, ...delay3 === void 0 ? {} : { retryDelaySeconds: delay3 } });
|
|
38348
38608
|
},
|
|
38349
38609
|
async renew(id, receipt) {
|
|
38350
38610
|
validateId(id);
|
|
@@ -38370,7 +38630,7 @@ var HcrJobsRequestError = class extends Error {
|
|
|
38370
38630
|
this.name = "HcrJobsRequestError";
|
|
38371
38631
|
}
|
|
38372
38632
|
};
|
|
38373
|
-
var
|
|
38633
|
+
var uuid4 = (value) => typeof value === "string" && value.length === 36 && /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(value) && value !== "00000000-0000-0000-0000-000000000000";
|
|
38374
38634
|
var digest = (value) => typeof value === "string" && value.length === 64 && /^[a-f0-9]{64}$/.test(value);
|
|
38375
38635
|
var name = (value) => typeof value === "string" && value.length <= 100 && !value.includes(String.fromCharCode(10)) && !value.includes(String.fromCharCode(13)) && /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,99}$/.test(value);
|
|
38376
38636
|
var timestamp = (value) => {
|
|
@@ -38506,7 +38766,7 @@ function createHcrJobsProvider(options) {
|
|
|
38506
38766
|
return value.kind === "cron" && value.at === null && value.intervalSeconds === null && typeof value.expression === "string" && value.expression.length <= 200 && value.expression.trim().split(/\s+/).length === 5 && !/[\r\n]/.test(value.expression);
|
|
38507
38767
|
}
|
|
38508
38768
|
function scheduleMetadata(value) {
|
|
38509
|
-
if (!fields2(value, ["id", "name", "job", "artifactVersion", "sourceVersion", "revision", "kind", "at", "intervalSeconds", "expression", "timeZone", "sourceEnabled", "enabledOverride", "enabled", "nextRunAt", "lastDispatchedAt"]) || !
|
|
38769
|
+
if (!fields2(value, ["id", "name", "job", "artifactVersion", "sourceVersion", "revision", "kind", "at", "intervalSeconds", "expression", "timeZone", "sourceEnabled", "enabledOverride", "enabled", "nextRunAt", "lastDispatchedAt"]) || !uuid4(value.id) || !name(value.name) || !name(value.job) || !digest(value.artifactVersion) || !integer(value.sourceVersion, 1, Number.MAX_SAFE_INTEGER) || !integer(value.revision, 1, Number.MAX_SAFE_INTEGER) || !scheduleTiming(value) || typeof value.sourceEnabled !== "boolean" || value.enabledOverride !== null && typeof value.enabledOverride !== "boolean" || value.enabled !== (value.enabledOverride ?? value.sourceEnabled) || value.nextRunAt !== null && !timestamp(value.nextRunAt) || value.lastDispatchedAt !== null && !timestamp(value.lastDispatchedAt))
|
|
38510
38770
|
invalid2();
|
|
38511
38771
|
return value;
|
|
38512
38772
|
}
|
|
@@ -38535,7 +38795,7 @@ function createHcrJobsProvider(options) {
|
|
|
38535
38795
|
},
|
|
38536
38796
|
async override(id, input) {
|
|
38537
38797
|
serverOnly();
|
|
38538
|
-
if (!
|
|
38798
|
+
if (!uuid4(id) || !fields2(input, ["expectedRevision", "enabled"]) || !integer(input.expectedRevision, 1, Number.MAX_SAFE_INTEGER - 1) || input.enabled !== null && typeof input.enabled !== "boolean")
|
|
38539
38799
|
throw new Error("Invalid durable schedule override");
|
|
38540
38800
|
const result = scheduleMetadata(await request("/schedules/" + id + "/override", input));
|
|
38541
38801
|
if (result.id.toLowerCase() !== id.toLowerCase() || result.enabledOverride !== input.enabled)
|
|
@@ -38589,13 +38849,13 @@ function createHcrJobsProvider(options) {
|
|
|
38589
38849
|
if (typeof serialized !== "string" || new TextEncoder().encode(serialized).length > 1048576)
|
|
38590
38850
|
throw new Error("Job payload exceeds its bound");
|
|
38591
38851
|
const result = await request("/enqueue", { version: 1, job, artifactVersion: producerArtifactVersion, payload: JSON.parse(serialized), delaySeconds, ...input?.retries !== void 0 ? { retries: input.retries } : {}, ...input?.idempotencyKey !== void 0 ? { idempotencyKey: input.idempotencyKey } : {} });
|
|
38592
|
-
if (!fields2(result, ["id", "accepted"]) || !
|
|
38852
|
+
if (!fields2(result, ["id", "accepted"]) || !uuid4(result.id) || typeof result.accepted !== "boolean")
|
|
38593
38853
|
invalid2();
|
|
38594
38854
|
return { id: result.id };
|
|
38595
38855
|
},
|
|
38596
38856
|
async enqueuePinned(input) {
|
|
38597
38857
|
serverOnly();
|
|
38598
|
-
if (!fields2(input, ["version", "runId", "job", "artifactVersion", "scheduledAt", "payload"]) || input.version !== 1 || !
|
|
38858
|
+
if (!fields2(input, ["version", "runId", "job", "artifactVersion", "scheduledAt", "payload"]) || input.version !== 1 || !uuid4(input.runId) || !name(input.job) || !digest(input.artifactVersion) || !timestamp(input.scheduledAt))
|
|
38599
38859
|
throw new Error("Invalid pinned job dispatch");
|
|
38600
38860
|
let payload;
|
|
38601
38861
|
try {
|
|
@@ -38619,7 +38879,7 @@ function createHcrJobsProvider(options) {
|
|
|
38619
38879
|
const identifiers = /* @__PURE__ */ new Set();
|
|
38620
38880
|
let payloadBytes = 0;
|
|
38621
38881
|
for (const row of rows) {
|
|
38622
|
-
if (!fields2(row, ["version", "runId", "job", "artifactVersion", "scheduledAt", "attempt", "payload", "receipt", "leaseExpiresAt", "deploymentId", "imageReference", "sourceCommit", "policy"]) || row.version !== 1 || !
|
|
38882
|
+
if (!fields2(row, ["version", "runId", "job", "artifactVersion", "scheduledAt", "attempt", "payload", "receipt", "leaseExpiresAt", "deploymentId", "imageReference", "sourceCommit", "policy"]) || row.version !== 1 || !uuid4(row.runId) || identifiers.has(row.runId) || row.job !== job || row.artifactVersion !== artifactVersion || !timestamp(row.scheduledAt) || !integer(row.attempt, 1, 101) || !digest(row.receipt) || !timestamp(row.leaseExpiresAt) || !uuid4(row.deploymentId) || !imageReference(row.imageReference) || typeof row.sourceCommit !== "string" || ![40, 64].includes(row.sourceCommit.length) || row.sourceCommit.includes(String.fromCharCode(10)) || row.sourceCommit.includes(String.fromCharCode(13)) || !/^[a-f0-9]+$/.test(row.sourceCommit))
|
|
38623
38883
|
invalid2();
|
|
38624
38884
|
const policy = row.policy;
|
|
38625
38885
|
if (!fields2(policy, ["name", "retries", "timeoutSeconds", "concurrency", "backoff"]) || policy.name !== job || !integer(policy.retries, 0, 100) || !integer(policy.timeoutSeconds, 1, 86400) || !integer(policy.concurrency, 1, 100) || !["fixed", "exponential"].includes(policy.backoff) || row.attempt > policy.retries + 1)
|
|
@@ -38635,28 +38895,28 @@ function createHcrJobsProvider(options) {
|
|
|
38635
38895
|
return rows;
|
|
38636
38896
|
},
|
|
38637
38897
|
async complete(id, receipt, outcome) {
|
|
38638
|
-
if (!
|
|
38898
|
+
if (!uuid4(id) || !digest(receipt) || !["succeeded", "failed", "timed_out", "cancelled"].includes(outcome))
|
|
38639
38899
|
throw new Error("Invalid job receipt or outcome");
|
|
38640
38900
|
if (await request("/" + id + "/complete", { receipt, outcome }, "post", 131072, true) !== null)
|
|
38641
38901
|
invalid2();
|
|
38642
38902
|
},
|
|
38643
38903
|
async cancelPending(id) {
|
|
38644
|
-
if (!
|
|
38904
|
+
if (!uuid4(id))
|
|
38645
38905
|
throw new Error("Invalid job identifier");
|
|
38646
38906
|
if (await request("/" + id + "/cancel", void 0, "empty", 131072, true) !== null)
|
|
38647
38907
|
invalid2();
|
|
38648
38908
|
},
|
|
38649
38909
|
async retryFailed(id, artifactVersion) {
|
|
38650
38910
|
serverOnly();
|
|
38651
|
-
if (!
|
|
38911
|
+
if (!uuid4(id) || !digest(artifactVersion))
|
|
38652
38912
|
throw new Error("Invalid reviewed job retry");
|
|
38653
38913
|
const result = await request("/" + id + "/retry", { version: 1, artifactVersion });
|
|
38654
|
-
if (!fields2(result, ["id", "accepted"]) || !
|
|
38914
|
+
if (!fields2(result, ["id", "accepted"]) || !uuid4(result.id) || result.id.toLowerCase() === id.toLowerCase() || typeof result.accepted !== "boolean")
|
|
38655
38915
|
invalid2();
|
|
38656
38916
|
return { id: result.id, accepted: result.accepted };
|
|
38657
38917
|
},
|
|
38658
38918
|
async attempts(id) {
|
|
38659
|
-
if (!
|
|
38919
|
+
if (!uuid4(id))
|
|
38660
38920
|
throw new Error("Invalid job identifier");
|
|
38661
38921
|
const rows = await request("/" + id + "/attempts", void 0, "get");
|
|
38662
38922
|
if (!Array.isArray(rows) || rows.length > 101)
|
|
@@ -38675,7 +38935,7 @@ function createHcrJobsProvider(options) {
|
|
|
38675
38935
|
invalid2();
|
|
38676
38936
|
const identifiers = /* @__PURE__ */ new Set();
|
|
38677
38937
|
for (const row of value.runs) {
|
|
38678
|
-
if (!fields2(row, ["runId", "job", "artifactVersion", "deploymentId", "status", "attempts", "scheduledAt", "createdAt", "leaseExpiresAt", "finishedAt", "errorCode"]) || !
|
|
38938
|
+
if (!fields2(row, ["runId", "job", "artifactVersion", "deploymentId", "status", "attempts", "scheduledAt", "createdAt", "leaseExpiresAt", "finishedAt", "errorCode"]) || !uuid4(row.runId) || identifiers.has(row.runId) || !name(row.job) || !digest(row.artifactVersion) || !uuid4(row.deploymentId) || !Object.hasOwn(value.counts, row.status) || !integer(row.attempts, 0, 101) || !timestamp(row.scheduledAt) || !timestamp(row.createdAt) || row.leaseExpiresAt !== null && !timestamp(row.leaseExpiresAt) || row.finishedAt !== null && !timestamp(row.finishedAt) || !errorCode(row.errorCode))
|
|
38679
38939
|
invalid2();
|
|
38680
38940
|
identifiers.add(row.runId);
|
|
38681
38941
|
}
|
|
@@ -38747,7 +39007,7 @@ function jsonValue(value) {
|
|
|
38747
39007
|
|
|
38748
39008
|
// src/local-services.ts
|
|
38749
39009
|
import { spawn, execFile } from "node:child_process";
|
|
38750
|
-
import { createHash as createHash7, generateKeyPairSync, randomBytes as randomBytes4, randomUUID as
|
|
39010
|
+
import { createHash as createHash7, generateKeyPairSync, randomBytes as randomBytes4, randomUUID as randomUUID9, sign } from "node:crypto";
|
|
38751
39011
|
import { createServer as createServer3 } from "node:net";
|
|
38752
39012
|
import { existsSync as existsSync11, lstatSync as lstatSync8, mkdirSync as mkdirSync4, readFileSync as readFileSync12, readdirSync as readdirSync5, realpathSync, unlinkSync as unlinkSync4, writeFileSync as writeFileSync10 } from "node:fs";
|
|
38753
39013
|
import { basename as basename2, dirname as dirname9, isAbsolute as isAbsolute4, join as join11, relative, resolve as resolve8 } from "node:path";
|
|
@@ -38797,7 +39057,7 @@ function typedMigrationSql(source) {
|
|
|
38797
39057
|
}
|
|
38798
39058
|
|
|
38799
39059
|
// src/local-job-services.ts
|
|
38800
|
-
import { createHash as createHash6, randomBytes as randomBytes3, randomUUID as
|
|
39060
|
+
import { createHash as createHash6, randomBytes as randomBytes3, randomUUID as randomUUID8 } from "node:crypto";
|
|
38801
39061
|
import { existsSync as existsSync10, lstatSync as lstatSync7, readFileSync as readFileSync11 } from "node:fs";
|
|
38802
39062
|
import { isIP } from "node:net";
|
|
38803
39063
|
import { dirname as dirname8, join as join10 } from "node:path";
|
|
@@ -38807,7 +39067,7 @@ function fields3(value, names) {
|
|
|
38807
39067
|
function digest2(value) {
|
|
38808
39068
|
return typeof value === "string" && value.length === 64 && /^[a-f0-9]{64}$/.test(value);
|
|
38809
39069
|
}
|
|
38810
|
-
function
|
|
39070
|
+
function uuid5(value) {
|
|
38811
39071
|
return typeof value === "string" && value.length === 36 && /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(value) && value !== "00000000-0000-0000-0000-000000000000";
|
|
38812
39072
|
}
|
|
38813
39073
|
function integer2(value, minimum, maximum) {
|
|
@@ -38828,7 +39088,7 @@ function image(value) {
|
|
|
38828
39088
|
function validateLocalJobArtifacts(value) {
|
|
38829
39089
|
if (!Array.isArray(value) || !integer2(value.length, 1, 100)) throw new Error("Local jobs require bounded reviewed artifact pins and policies");
|
|
38830
39090
|
const result = value.map((artifact) => {
|
|
38831
|
-
if (!fields3(artifact, ["deploymentId", "artifactVersion", "imageReference", "sourceCommit", "jobs"]) || !
|
|
39091
|
+
if (!fields3(artifact, ["deploymentId", "artifactVersion", "imageReference", "sourceCommit", "jobs"]) || !uuid5(artifact.deploymentId) || !digest2(artifact.artifactVersion) || !image(artifact.imageReference) || typeof artifact.sourceCommit !== "string" || ![40, 64].includes(artifact.sourceCommit.length) || !/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(artifact.sourceCommit) || !Array.isArray(artifact.jobs) || !integer2(artifact.jobs.length, 1, 100)) throw new Error("Local jobs require bounded reviewed artifact pins and policies");
|
|
38832
39092
|
const jobs = artifact.jobs.map((policy) => {
|
|
38833
39093
|
if (!fields3(policy, ["name", "retries", "timeoutSeconds", "concurrency", "backoff"]) || typeof policy.name !== "string" || !integer2(policy.name.length, 1, 100) || /[\r\n]/.test(policy.name) || !/^[a-zA-Z0-9][a-zA-Z0-9_-]*$/.test(policy.name) || !integer2(policy.retries, 0, 100) || !integer2(policy.timeoutSeconds, 1, 86400) || !integer2(policy.concurrency, 1, 100) || !["fixed", "exponential"].includes(policy.backoff)) throw new Error("Local jobs require bounded reviewed artifact pins and policies");
|
|
38834
39094
|
return { name: policy.name, retries: policy.retries, timeoutSeconds: policy.timeoutSeconds, concurrency: policy.concurrency, backoff: policy.backoff };
|
|
@@ -38840,7 +39100,7 @@ function validateLocalJobArtifacts(value) {
|
|
|
38840
39100
|
return result.sort((first, second) => first.artifactVersion < second.artifactVersion ? -1 : first.artifactVersion > second.artifactVersion ? 1 : 0);
|
|
38841
39101
|
}
|
|
38842
39102
|
function validLocalJobState(value, otherIds) {
|
|
38843
|
-
if (!fields3(value, ["id", "password", "schemaDigests", "initialized", "artifacts"]) || !
|
|
39103
|
+
if (!fields3(value, ["id", "password", "schemaDigests", "initialized", "artifacts"]) || !uuid5(value.id) || otherIds.some((identifier3) => identifier3.toLowerCase() === value.id.toLowerCase()) || !digest2(value.password) || !fields3(value.schemaDigests, ["base", "producer"]) || !digest2(value.schemaDigests.base) || !digest2(value.schemaDigests.producer) || typeof value.initialized !== "boolean") return false;
|
|
38844
39104
|
try {
|
|
38845
39105
|
validateLocalJobArtifacts(value.artifacts);
|
|
38846
39106
|
return true;
|
|
@@ -38865,14 +39125,14 @@ function prepareLocalJobService(hcrPath, retained, artifacts, applyMigrations) {
|
|
|
38865
39125
|
if (previous && JSON.stringify(previous) !== JSON.stringify(artifact)) throw new Error("Retained local job artifact metadata cannot change; preserve the original pins and policies");
|
|
38866
39126
|
if (!previous) retainedArtifacts.push(artifact);
|
|
38867
39127
|
}
|
|
38868
|
-
const state = { ...retained ?? { id:
|
|
39128
|
+
const state = { ...retained ?? { id: randomUUID8(), password: randomBytes3(32).toString("hex"), initialized: false }, schemaDigests, artifacts: validateLocalJobArtifacts(retainedArtifacts) };
|
|
38869
39129
|
return { state, base, producer };
|
|
38870
39130
|
}
|
|
38871
39131
|
|
|
38872
39132
|
// src/local-services.ts
|
|
38873
39133
|
function writePrivate(filename2, value) {
|
|
38874
39134
|
if (isLink(filename2)) throw new Error("Local service files must not be symbolic links");
|
|
38875
|
-
const temporary = filename2 + "." +
|
|
39135
|
+
const temporary = filename2 + "." + randomUUID9() + ".tmp";
|
|
38876
39136
|
writeFileSync10(temporary, value, { flag: "wx", mode: 384 });
|
|
38877
39137
|
renameLocalFile(temporary, filename2);
|
|
38878
39138
|
}
|
|
@@ -38893,16 +39153,16 @@ function assertLocalStatePath(root, filename2) {
|
|
|
38893
39153
|
}
|
|
38894
39154
|
}
|
|
38895
39155
|
function stateValid(value) {
|
|
38896
|
-
const
|
|
39156
|
+
const uuid7 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
38897
39157
|
if (value?.jobs !== void 0 && !validLocalJobState(value.jobs, [value.databaseId, value.storageId, ...Object.values(value.storageBindings ?? {}), ...value.events ? [value.events.id] : []].filter((identifier3) => typeof identifier3 === "string"))) return false;
|
|
38898
|
-
if (value?.events !== void 0 && (!value.events || typeof value.events !== "object" || Array.isArray(value.events) || typeof value.events.id !== "string" || value.events.id.length !== 36 || !
|
|
38899
|
-
return value?.version === 1 && value.scope && [value.scope.organizationId, value.scope.applicationId, value.scope.environmentId, value.databaseId, value.storageId].every((identifier3) => typeof identifier3 === "string" &&
|
|
39158
|
+
if (value?.events !== void 0 && (!value.events || typeof value.events !== "object" || Array.isArray(value.events) || typeof value.events.id !== "string" || value.events.id.length !== 36 || !uuid7.test(value.events.id) || value.events.id === "00000000-0000-0000-0000-000000000000" || [value.databaseId, value.storageId, ...Object.values(value.storageBindings ?? {})].some((identifier3) => typeof identifier3 === "string" && identifier3.toLowerCase() === value.events.id.toLowerCase()) || typeof value.events.password !== "string" || value.events.password.length !== 64 || !/^[a-f0-9]{64}$/.test(value.events.password) || typeof value.events.schemaDigest !== "string" || value.events.schemaDigest.length !== 64 || !/^[a-f0-9]{64}$/.test(value.events.schemaDigest) || typeof value.events.initialized !== "boolean")) return false;
|
|
39159
|
+
return value?.version === 1 && value.scope && [value.scope.organizationId, value.scope.applicationId, value.scope.environmentId, value.databaseId, value.storageId].every((identifier3) => typeof identifier3 === "string" && uuid7.test(identifier3)) && Number.isSafeInteger(value.configurationVersion) && value.configurationVersion >= 0 && /^[a-f0-9]{64}$/.test(value.adminPassword) && /^[a-f0-9]{64}$/.test(value.databasePassword) && (value.retainedDatabasePort === void 0 || Number.isInteger(value.retainedDatabasePort) && value.retainedDatabasePort > 0 && value.retainedDatabasePort <= 65535);
|
|
38900
39160
|
}
|
|
38901
39161
|
function acquireLocalLease(root, relativePath2 = ".backify/dev/development.lock") {
|
|
38902
39162
|
const filename2 = join11(root, relativePath2);
|
|
38903
39163
|
assertLocalStatePath(root, filename2);
|
|
38904
39164
|
mkdirSync4(resolve8(filename2, ".."), { recursive: true, mode: 448 });
|
|
38905
|
-
const owner = JSON.stringify({ version: 1, pid: process.pid, id:
|
|
39165
|
+
const owner = JSON.stringify({ version: 1, pid: process.pid, id: randomUUID9() });
|
|
38906
39166
|
try {
|
|
38907
39167
|
writeFileSync10(filename2, owner, { flag: "wx", mode: 384 });
|
|
38908
39168
|
} catch {
|
|
@@ -39084,9 +39344,9 @@ async function startLocalServices(root, manifest, options = {}) {
|
|
|
39084
39344
|
}
|
|
39085
39345
|
const state = existing ?? {
|
|
39086
39346
|
version: 1,
|
|
39087
|
-
scope: reviewedScope ? structuredClone(reviewedScope) : { organizationId:
|
|
39088
|
-
databaseId:
|
|
39089
|
-
storageId:
|
|
39347
|
+
scope: reviewedScope ? structuredClone(reviewedScope) : { organizationId: randomUUID9(), applicationId: randomUUID9(), environmentId: randomUUID9() },
|
|
39348
|
+
databaseId: randomUUID9(),
|
|
39349
|
+
storageId: randomUUID9(),
|
|
39090
39350
|
configurationVersion: 0,
|
|
39091
39351
|
adminPassword: randomBytes4(32).toString("hex"),
|
|
39092
39352
|
databasePassword: randomBytes4(32).toString("hex")
|
|
@@ -39101,14 +39361,14 @@ async function startLocalServices(root, manifest, options = {}) {
|
|
|
39101
39361
|
const digest4 = createHash7("sha256").update(eventSchema).digest("hex");
|
|
39102
39362
|
if (state.events && state.events.schemaDigest !== digest4) throw new Error("Native event schema changed; preserve its database and plan an explicit migration.");
|
|
39103
39363
|
if (!state.events?.initialized && !options.applyMigrations) throw new Error("Review the HCR events-v1.sql asset and pass --apply-migrations for explicit native event schema approval.");
|
|
39104
|
-
state.events ??= { id:
|
|
39364
|
+
state.events ??= { id: randomUUID9(), password: randomBytes4(32).toString("hex"), schemaDigest: digest4, initialized: false };
|
|
39105
39365
|
}
|
|
39106
39366
|
const jobSchema = jobs ? prepareLocalJobService(hcrPath, state.jobs, options.jobArtifacts, options.applyMigrations) : void 0;
|
|
39107
39367
|
if (jobSchema) state.jobs = jobSchema.state;
|
|
39108
39368
|
const storageNames = manifest.capabilities.storage?.buckets === void 0 ? ["default"] : manifest.capabilities.storage.buckets.map((bucket) => bucket.name);
|
|
39109
39369
|
state.storageBindings ??= { default: state.storageId };
|
|
39110
39370
|
if (typeof state.storageBindings !== "object" || state.storageBindings === null || Array.isArray(state.storageBindings) || Object.entries(state.storageBindings).some(([name2, identifier3]) => !/^[A-Za-z0-9_-]{1,100}$/.test(name2) || typeof identifier3 !== "string" || !/^[0-9a-f-]{36}$/i.test(identifier3))) throw new Error("Invalid local storage binding ownership state");
|
|
39111
|
-
for (const name2 of storageNames) state.storageBindings[name2] ??=
|
|
39371
|
+
for (const name2 of storageNames) state.storageBindings[name2] ??= randomUUID9();
|
|
39112
39372
|
if (Object.keys(state.storageBindings).length > 100) throw new Error("Local storage ownership history exceeds 100 bindings; preserve the data and plan an explicit migration");
|
|
39113
39373
|
if (Buffer.byteLength(JSON.stringify({ ...state, configurationVersion: Number.MAX_SAFE_INTEGER, retainedDatabasePort: 65535 }), "utf8") > 16384) throw new Error("Local ownership history exceeds supported limits; preserve state and plan an explicit migration");
|
|
39114
39374
|
const migrations = database ? localMigrationFiles(root, manifest.capabilities.database?.migrations) : [];
|
|
@@ -39179,7 +39439,7 @@ async function startLocalServices(root, manifest, options = {}) {
|
|
|
39179
39439
|
const sql = (query, application = false) => command(postgresExecutable("psql", options.postgresBin), ["-h", "127.0.0.1", "-p", String(databasePort), "-U", application ? "backify_local" : "backify_admin", "-d", application ? "backify_local" : "postgres", "-X", "-q", "-t", "-A", "-v", "ON_ERROR_STOP=1", "-c", query], { env: { ...process.env, PGPASSWORD: application ? state.databasePassword : state.adminPassword } });
|
|
39180
39440
|
if (database) {
|
|
39181
39441
|
if ((await sql("SELECT count(*) FROM pg_roles WHERE rolname='backify_local'")).trim() === "0") {
|
|
39182
|
-
const filename2 = join11(directory2, "role-" +
|
|
39442
|
+
const filename2 = join11(directory2, "role-" + randomUUID9() + ".sql");
|
|
39183
39443
|
writePrivate(filename2, "CREATE ROLE backify_local LOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE PASSWORD '" + state.databasePassword + "';");
|
|
39184
39444
|
try {
|
|
39185
39445
|
await command(postgresExecutable("psql", options.postgresBin), ["-h", "127.0.0.1", "-p", String(databasePort), "-U", "backify_admin", "-d", "postgres", "-X", "-q", "-v", "ON_ERROR_STOP=1", "-f", filename2], { env: { ...process.env, PGPASSWORD: state.adminPassword } });
|
|
@@ -39199,7 +39459,7 @@ async function startLocalServices(root, manifest, options = {}) {
|
|
|
39199
39459
|
notify("migrations", "starting");
|
|
39200
39460
|
if (pending.length) await sql("CREATE TABLE IF NOT EXISTS public.__backify_migrations (name text PRIMARY KEY, digest text NOT NULL, applied_at timestamptz NOT NULL DEFAULT now())", true);
|
|
39201
39461
|
for (const migration of pending) {
|
|
39202
|
-
const filename2 = join11(directory2, "apply-" +
|
|
39462
|
+
const filename2 = join11(directory2, "apply-" + randomUUID9() + ".sql");
|
|
39203
39463
|
writePrivate(filename2, "BEGIN;\n" + migration.sql + "\n;\nINSERT INTO public.__backify_migrations(name,digest) VALUES ('" + migration.name + "','" + migration.digest + "');\nCOMMIT;\n");
|
|
39204
39464
|
try {
|
|
39205
39465
|
await command(postgresExecutable("psql", options.postgresBin), ["-h", "127.0.0.1", "-p", String(databasePort), "-U", "backify_local", "-d", "backify_local", "-X", "-q", "-v", "ON_ERROR_STOP=1", "-f", filename2], { env: { ...process.env, PGPASSWORD: state.databasePassword } });
|
|
@@ -39215,7 +39475,7 @@ async function startLocalServices(root, manifest, options = {}) {
|
|
|
39215
39475
|
const eventSql = (query) => command(postgresExecutable("psql", options.postgresBin), ["-h", "127.0.0.1", "-p", String(databasePort), "-U", "backify_events", "-d", "backify_events", "-X", "-q", "-t", "-A", "-v", "ON_ERROR_STOP=1", "-c", query], { env: { ...process.env, PGPASSWORD: eventState.password } });
|
|
39216
39476
|
if (!eventState.initialized) {
|
|
39217
39477
|
if ((await sql("SELECT count(*) FROM pg_database WHERE datname='backify_events'")).trim() !== "0" || (await sql("SELECT count(*) FROM pg_roles WHERE rolname='backify_events'")).trim() !== "0") throw new Error("Uninitialized native event ownership conflicts with retained state; preserve it and repair explicitly.");
|
|
39218
|
-
const roleFile = join11(directory2, "event-role-" +
|
|
39478
|
+
const roleFile = join11(directory2, "event-role-" + randomUUID9() + ".sql");
|
|
39219
39479
|
writePrivate(roleFile, "CREATE ROLE backify_events LOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE PASSWORD '" + eventState.password + "';");
|
|
39220
39480
|
try {
|
|
39221
39481
|
await command(postgresExecutable("psql", options.postgresBin), ["-h", "127.0.0.1", "-p", String(databasePort), "-U", "backify_admin", "-d", "postgres", "-X", "-q", "-v", "ON_ERROR_STOP=1", "-f", roleFile], { env: { ...process.env, PGPASSWORD: state.adminPassword } });
|
|
@@ -39223,7 +39483,7 @@ async function startLocalServices(root, manifest, options = {}) {
|
|
|
39223
39483
|
if (existsSync11(roleFile)) unlinkSync4(roleFile);
|
|
39224
39484
|
}
|
|
39225
39485
|
await sql("CREATE DATABASE backify_events OWNER backify_events");
|
|
39226
|
-
const schemaFile = join11(directory2, "event-schema-" +
|
|
39486
|
+
const schemaFile = join11(directory2, "event-schema-" + randomUUID9() + ".sql");
|
|
39227
39487
|
writePrivate(schemaFile, eventSchema);
|
|
39228
39488
|
try {
|
|
39229
39489
|
await command(postgresExecutable("psql", options.postgresBin), ["-h", "127.0.0.1", "-p", String(databasePort), "-U", "backify_events", "-d", "backify_events", "-X", "-q", "-v", "ON_ERROR_STOP=1", "-f", schemaFile], { env: { ...process.env, PGPASSWORD: eventState.password } });
|
|
@@ -39242,7 +39502,7 @@ async function startLocalServices(root, manifest, options = {}) {
|
|
|
39242
39502
|
const adminSql = (query, databaseName = "postgres") => jobCommand("backify_admin", state.adminPassword, databaseName, ["-c", query]);
|
|
39243
39503
|
if (!jobState.initialized) {
|
|
39244
39504
|
if ((await adminSql("SELECT count(*) FROM pg_database WHERE datname='backify_jobs'")).trim() !== "0" || (await adminSql("SELECT count(*) FROM pg_roles WHERE rolname='backify_jobs'")).trim() !== "0") throw new Error("Uninitialized native job ownership conflicts with retained state; preserve it and repair explicitly");
|
|
39245
|
-
const roleFile = join11(directory2, "job-role-" +
|
|
39505
|
+
const roleFile = join11(directory2, "job-role-" + randomUUID9() + ".sql");
|
|
39246
39506
|
writePrivate(roleFile, "CREATE ROLE backify_jobs LOGIN NOINHERIT NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION NOBYPASSRLS PASSWORD '" + jobState.password + "';");
|
|
39247
39507
|
try {
|
|
39248
39508
|
await jobCommand("backify_admin", state.adminPassword, "postgres", ["-f", roleFile]);
|
|
@@ -39251,7 +39511,7 @@ async function startLocalServices(root, manifest, options = {}) {
|
|
|
39251
39511
|
}
|
|
39252
39512
|
await adminSql("CREATE DATABASE backify_jobs OWNER backify_admin");
|
|
39253
39513
|
for (const schema of [jobSchema.base, jobSchema.producer]) {
|
|
39254
|
-
const filename2 = join11(directory2, "job-schema-" +
|
|
39514
|
+
const filename2 = join11(directory2, "job-schema-" + randomUUID9() + ".sql");
|
|
39255
39515
|
writePrivate(filename2, schema);
|
|
39256
39516
|
try {
|
|
39257
39517
|
await jobCommand("backify_admin", state.adminPassword, "backify_jobs", ["-f", filename2]);
|
|
@@ -40271,7 +40531,7 @@ async function startLocalFrontend(prepared, port, backendUrl, onDiagnostic, auth
|
|
|
40271
40531
|
// src/local-identity.ts
|
|
40272
40532
|
import { readFileSync as readFileSync19, statSync as statSync2 } from "node:fs";
|
|
40273
40533
|
import { resolve as resolve15 } from "node:path";
|
|
40274
|
-
import { randomUUID as
|
|
40534
|
+
import { randomUUID as randomUUID10 } from "node:crypto";
|
|
40275
40535
|
function prepareLocalIdentity(root, filename2) {
|
|
40276
40536
|
if (filename2 === void 0) return void 0;
|
|
40277
40537
|
const path = resolve15(root, filename2);
|
|
@@ -40286,7 +40546,7 @@ function prepareLocalIdentity(root, filename2) {
|
|
|
40286
40546
|
if (!input || typeof input !== "object" || Array.isArray(input) || Object.keys(input).some((name2) => !["version", "organizationName", "users"].includes(name2))) throw new Error("Invalid local identity profiles");
|
|
40287
40547
|
const value = input;
|
|
40288
40548
|
if (value.version !== 1) throw new Error("Invalid local identity profile version");
|
|
40289
|
-
const identity = createLocalIdentityProvider({ scope: { organizationId:
|
|
40549
|
+
const identity = createLocalIdentityProvider({ scope: { organizationId: randomUUID10(), applicationId: randomUUID10(), environmentId: randomUUID10() }, organizationName: value.organizationName, users: value.users, requestOrigins: ["http://127.0.0.1:3000"] });
|
|
40290
40550
|
return { organizationName: value.organizationName, users: identity.profiles() };
|
|
40291
40551
|
}
|
|
40292
40552
|
function localIdentityCommand(args2) {
|
|
@@ -40368,7 +40628,7 @@ function prepareLocalJobHistory(root, filename2, artifacts, manifest, current) {
|
|
|
40368
40628
|
}
|
|
40369
40629
|
|
|
40370
40630
|
// src/local-secrets.ts
|
|
40371
|
-
import { createCipheriv, createDecipheriv, randomBytes as randomBytes5, randomUUID as
|
|
40631
|
+
import { createCipheriv, createDecipheriv, randomBytes as randomBytes5, randomUUID as randomUUID11 } from "node:crypto";
|
|
40372
40632
|
import { closeSync as closeSync3, existsSync as existsSync13, fsyncSync as fsyncSync3, lstatSync as lstatSync15, mkdirSync as mkdirSync5, openSync as openSync3, readFileSync as readFileSync21, realpathSync as realpathSync4, writeFileSync as writeFileSync11 } from "node:fs";
|
|
40373
40633
|
import { dirname as dirname11, isAbsolute as isAbsolute12, join as join15, relative as relative6, resolve as resolve17 } from "node:path";
|
|
40374
40634
|
var maximumBytes2 = 1048576;
|
|
@@ -40497,7 +40757,7 @@ function setLocalSecret(root, application, keyFile, name2, value) {
|
|
|
40497
40757
|
const secrets = readLocalSecrets(root, application, keyFile);
|
|
40498
40758
|
secrets[name2] = value;
|
|
40499
40759
|
key = externalKey(root, keyFile);
|
|
40500
|
-
const temporary = filename2 + "." +
|
|
40760
|
+
const temporary = filename2 + "." + randomUUID11() + ".tmp";
|
|
40501
40761
|
assertLocalStatePath(root, temporary);
|
|
40502
40762
|
writePrivate2(temporary, encrypt(root, application, key, secrets));
|
|
40503
40763
|
renameLocalFile(temporary, filename2);
|
|
@@ -40647,7 +40907,7 @@ async function startLocalDevelopment(options = {}) {
|
|
|
40647
40907
|
throw error2;
|
|
40648
40908
|
}
|
|
40649
40909
|
const token = randomBytes6(32).toString("hex");
|
|
40650
|
-
const identityScope = services?.identityScope ?? { organizationId:
|
|
40910
|
+
const identityScope = services?.identityScope ?? { organizationId: randomUUID12(), applicationId: randomUUID12(), environmentId: randomUUID12() };
|
|
40651
40911
|
const workerEnvironment = (worker) => {
|
|
40652
40912
|
if (!worker.authTrust) return worker;
|
|
40653
40913
|
const { renewal, ...authTrust } = worker.authTrust;
|
|
@@ -41941,9 +42201,47 @@ async function main() {
|
|
|
41941
42201
|
console.error(args.includes("--dry-run") ? "Preview only; no files changed." : result.transport === "stdio" ? "Restart your coding tool. Sign in with backify login --organization <organization-id> --organization-access." : "Restart your coding tool, connect Backify and approve organization access in your browser. The deployed MCP and portal must support OAuth.");
|
|
41942
42202
|
break;
|
|
41943
42203
|
}
|
|
42204
|
+
case "domains": {
|
|
42205
|
+
if (args[0] !== "connect" || args.includes("--help")) {
|
|
42206
|
+
console.log(domainConnectHelp);
|
|
42207
|
+
if (args[0] !== "connect" && !args.includes("--help")) process.exitCode = 2;
|
|
42208
|
+
break;
|
|
42209
|
+
}
|
|
42210
|
+
const options = domainConnectArguments(args.slice(1)), controller = new AbortController(), stop = () => controller.abort();
|
|
42211
|
+
process.once("SIGINT", stop);
|
|
42212
|
+
process.once("SIGTERM", stop);
|
|
42213
|
+
try {
|
|
42214
|
+
const result = await connectDomain(call, { ...options, applicationId: applicationGuid(option("--app") ?? projectApplication()), portalUrl: process.env.BACKIFY_PORTAL_URL ?? userConfig.portalUrl ?? "https://portal.backify.dev", openBrowser, progress: (message) => console.error(message), signal: controller.signal });
|
|
42215
|
+
console.log(JSON.stringify(result, null, 2));
|
|
42216
|
+
if (!result.confirmed) process.exitCode = 2;
|
|
42217
|
+
} finally {
|
|
42218
|
+
process.removeListener("SIGINT", stop);
|
|
42219
|
+
process.removeListener("SIGTERM", stop);
|
|
42220
|
+
}
|
|
42221
|
+
break;
|
|
42222
|
+
}
|
|
41944
42223
|
case "integrations": {
|
|
41945
|
-
|
|
41946
|
-
|
|
42224
|
+
if (args[0] === "connect") {
|
|
42225
|
+
if (args.includes("--help")) {
|
|
42226
|
+
console.log(integrationConnectHelp);
|
|
42227
|
+
break;
|
|
42228
|
+
}
|
|
42229
|
+
const options = integrationConnectArguments(args.slice(1));
|
|
42230
|
+
const controller = new AbortController(), stop = () => controller.abort();
|
|
42231
|
+
process.once("SIGINT", stop);
|
|
42232
|
+
process.once("SIGTERM", stop);
|
|
42233
|
+
try {
|
|
42234
|
+
const result = await connectIntegration(call, { ...options, applicationId: applicationGuid(option("--app") ?? projectApplication()), portalUrl: process.env.BACKIFY_PORTAL_URL ?? userConfig.portalUrl ?? "https://portal.backify.dev", openBrowser, progress: (message) => console.error(message), signal: controller.signal });
|
|
42235
|
+
console.log(JSON.stringify(result, null, 2));
|
|
42236
|
+
if (result.state !== "ready" && !("userConnectionFlowRequired" in result && result.userConnectionFlowRequired)) process.exitCode = 2;
|
|
42237
|
+
} finally {
|
|
42238
|
+
process.removeListener("SIGINT", stop);
|
|
42239
|
+
process.removeListener("SIGTERM", stop);
|
|
42240
|
+
}
|
|
42241
|
+
break;
|
|
42242
|
+
}
|
|
42243
|
+
const path = integrationDiscoveryPath(args[0], { applicationId: applicationGuid(option("--app") ?? projectApplication()), connectionId: option("--connection"), operationId: option("--operation"), query: option("--query"), offset: Number(option("--offset") ?? 0), adoptionId: option("--adoption"), revisionId: option("--revision") });
|
|
42244
|
+
const value = await call(path, args[0] === "prepare" ? { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(integrationPreparation({ definitionId: option("--definition"), revisionId: option("--revision"), environmentId: option("--environment"), mode: option("--mode"), operations: option("--operations") })) } : void 0);
|
|
41947
42245
|
if (args[0] === "types") console.log(value.source);
|
|
41948
42246
|
else console.log(JSON.stringify(value, null, 2));
|
|
41949
42247
|
break;
|
|
@@ -42250,7 +42548,7 @@ async function main() {
|
|
|
42250
42548
|
console.log(await call("/apps/" + applicationGuid(args[0]) + "/deployments/preview", { method: "POST", body: JSON.stringify({ sourceRevision: args[1] ?? "latest" }) }));
|
|
42251
42549
|
break;
|
|
42252
42550
|
default:
|
|
42253
|
-
console.log("backify tools configure --agent <tool> [--transport http|stdio] [--config <path>] [--dry-run] | connect | init | doctor | upgrade [--json] | sync | mcp [--project <directory>] [--app <application-id>] [--allow-preview] | login | logout | disconnect | status | dev | secrets local init|set|list --key-file <external-file> | test --json | inspect tables|rows|buckets|objects|preview|events --local [--json] | identity users|inbox|issue|clear --local [--json] | jobs | pull | report [--check] | prompt record --stdin --id <UUID> | ship [--production-deploy] | request | events environments|inspect|test | integrations list|catalog|search|describe|contract|types | workload plan|package|artifact-plan|trust-state|trust-sync|provenance capture|verify | apps | deploy");
|
|
42551
|
+
console.log("backify tools configure --agent <tool> [--transport http|stdio] [--config <path>] [--dry-run] | connect | init | doctor | upgrade [--json] | sync | mcp [--project <directory>] [--app <application-id>] [--allow-preview] | login | logout | disconnect | status | dev | secrets local init|set|list --key-file <external-file> | test --json | inspect tables|rows|buckets|objects|preview|events --local [--json] | identity users|inbox|issue|clear --local [--json] | jobs | pull | report [--check] | prompt record --stdin --id <UUID> | ship [--production-deploy] | request | events environments|inspect|test | domains connect [hostname] | integrations connect <provider>|discover|prepare|status|list|catalog|search|describe|contract|types | workload plan|package|artifact-plan|trust-state|trust-sync|provenance capture|verify | apps | deploy");
|
|
42254
42552
|
}
|
|
42255
42553
|
}
|
|
42256
42554
|
main().catch((error2) => {
|