@nodetool-ai/config 0.8.18 → 0.8.20
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/dist/.nodetool-build-stamp +1 -1
- package/dist/__tests__/deployment.test.js +23 -1
- package/dist/__tests__/deployment.test.js.map +1 -1
- package/dist/__tests__/host-settings.test.d.ts +2 -0
- package/dist/__tests__/host-settings.test.d.ts.map +1 -0
- package/dist/__tests__/host-settings.test.js +36 -0
- package/dist/__tests__/host-settings.test.js.map +1 -0
- package/dist/__tests__/server-credentials.test.d.ts +2 -0
- package/dist/__tests__/server-credentials.test.d.ts.map +1 -0
- package/dist/__tests__/server-credentials.test.js +41 -0
- package/dist/__tests__/server-credentials.test.js.map +1 -0
- package/dist/acestep-models.d.ts +39 -0
- package/dist/acestep-models.d.ts.map +1 -0
- package/dist/acestep-models.js +78 -0
- package/dist/acestep-models.js.map +1 -0
- package/dist/acestep-runtime.d.ts +64 -0
- package/dist/acestep-runtime.d.ts.map +1 -0
- package/dist/acestep-runtime.js +153 -0
- package/dist/acestep-runtime.js.map +1 -0
- package/dist/app-binary-runtime.d.ts +45 -0
- package/dist/app-binary-runtime.d.ts.map +1 -0
- package/dist/app-binary-runtime.js +310 -0
- package/dist/app-binary-runtime.js.map +1 -0
- package/dist/deployment.d.ts +20 -0
- package/dist/deployment.d.ts.map +1 -1
- package/dist/deployment.js +35 -0
- package/dist/deployment.js.map +1 -1
- package/dist/env-files.d.ts +56 -0
- package/dist/env-files.d.ts.map +1 -0
- package/dist/env-files.js +102 -0
- package/dist/env-files.js.map +1 -0
- package/dist/host-settings.d.ts +22 -0
- package/dist/host-settings.d.ts.map +1 -0
- package/dist/host-settings.js +30 -0
- package/dist/host-settings.js.map +1 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime-locations.d.ts +8 -0
- package/dist/runtime-locations.d.ts.map +1 -1
- package/dist/runtime-locations.js +5 -1
- package/dist/runtime-locations.js.map +1 -1
- package/dist/sd-cpp-runtime.d.ts +2 -0
- package/dist/sd-cpp-runtime.d.ts.map +1 -1
- package/dist/sd-cpp-runtime.js +4 -2
- package/dist/sd-cpp-runtime.js.map +1 -1
- package/dist/server-credentials.d.ts +42 -0
- package/dist/server-credentials.d.ts.map +1 -0
- package/dist/server-credentials.js +64 -0
- package/dist/server-credentials.js.map +1 -0
- package/dist/setting-catalog.d.ts +7 -0
- package/dist/setting-catalog.d.ts.map +1 -1
- package/dist/setting-catalog.js +41 -1
- package/dist/setting-catalog.js.map +1 -1
- package/package.json +25 -1
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Blender and Chrome as runtime packages: where each is unpacked, how to find
|
|
3
|
+
* its executable there, and the installer the desktop Package Manager and
|
|
4
|
+
* `nodetool runtime add blender|chrome` share.
|
|
5
|
+
*
|
|
6
|
+
* Blender comes from download.blender.org, from the newest patch of the
|
|
7
|
+
* series NodeTool needs. The archive is checked against the SHA-256 file
|
|
8
|
+
* Blender publishes beside it. Chrome is the current stable Chrome for
|
|
9
|
+
* Testing build, which Google publishes for automation. Its download list
|
|
10
|
+
* carries no digests, so the archive is trusted on its HTTPS origin.
|
|
11
|
+
*
|
|
12
|
+
* Each archive unpacks into a sibling directory first and replaces the old
|
|
13
|
+
* install only after the executable is in place, so a failed update keeps
|
|
14
|
+
* the working one. This module is Node-only and is not exported from the
|
|
15
|
+
* package index.
|
|
16
|
+
*/
|
|
17
|
+
import { createHash } from "node:crypto";
|
|
18
|
+
import { createWriteStream } from "node:fs";
|
|
19
|
+
import * as fs from "node:fs/promises";
|
|
20
|
+
import * as path from "node:path";
|
|
21
|
+
import { promisify } from "node:util";
|
|
22
|
+
import * as zlib from "node:zlib";
|
|
23
|
+
import { z } from "zod";
|
|
24
|
+
import { readZipEntries } from "./sd-cpp-runtime.js";
|
|
25
|
+
/**
|
|
26
|
+
* Run a host tool (tar, hdiutil, ditto). child_process loads on first use, so
|
|
27
|
+
* importing this module (the runtime package registry does) never needs it.
|
|
28
|
+
*/
|
|
29
|
+
async function execFileAsync(file, args) {
|
|
30
|
+
const { execFile } = await import("node:child_process");
|
|
31
|
+
await promisify(execFile)(file, args);
|
|
32
|
+
}
|
|
33
|
+
/** The Blender series the Package Manager installs. Matches the 5.2 floor in blender-nodes. */
|
|
34
|
+
export const BLENDER_SERIES = "5.2";
|
|
35
|
+
const BLENDER_RELEASE_DIR = `https://download.blender.org/release/Blender${BLENDER_SERIES}/`;
|
|
36
|
+
const CHROME_VERSIONS_URL = "https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json";
|
|
37
|
+
const MARKER_FILE = "nodetool-runtime.json";
|
|
38
|
+
const markerSchema = z.object({ version: z.string() });
|
|
39
|
+
/** The Blender archive suffix for a platform, or null when Blender ships none. */
|
|
40
|
+
export function blenderArchiveSuffix(platform, arch) {
|
|
41
|
+
if (platform === "linux" && arch === "x64")
|
|
42
|
+
return "linux-x64.tar.xz";
|
|
43
|
+
if (platform === "darwin" && (arch === "arm64" || arch === "x64"))
|
|
44
|
+
return `macos-${arch}.dmg`;
|
|
45
|
+
if (platform === "win32" && (arch === "x64" || arch === "arm64"))
|
|
46
|
+
return `windows-${arch}.zip`;
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
/** The Chrome for Testing platform name, or null when Google ships no build. */
|
|
50
|
+
export function chromeForTestingPlatform(platform, arch) {
|
|
51
|
+
if (platform === "linux" && arch === "x64")
|
|
52
|
+
return "linux64";
|
|
53
|
+
if (platform === "darwin" && (arch === "arm64" || arch === "x64"))
|
|
54
|
+
return `mac-${arch}`;
|
|
55
|
+
if (platform === "win32")
|
|
56
|
+
return arch === "ia32" ? "win32" : "win64";
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
/** Whether the Package Manager can install `id` on this platform. */
|
|
60
|
+
export function appBinarySupported(id, platform, arch) {
|
|
61
|
+
return id === "blender"
|
|
62
|
+
? blenderArchiveSuffix(platform, arch) !== null
|
|
63
|
+
: chromeForTestingPlatform(platform, arch) !== null;
|
|
64
|
+
}
|
|
65
|
+
/** The executable inside an install directory. */
|
|
66
|
+
export function appBinaryPath(id, installDir, platform) {
|
|
67
|
+
const join = platform === "win32" ? path.win32.join : path.posix.join;
|
|
68
|
+
if (id === "blender") {
|
|
69
|
+
if (platform === "darwin")
|
|
70
|
+
return join(installDir, "Blender.app", "Contents", "MacOS", "Blender");
|
|
71
|
+
return join(installDir, platform === "win32" ? "blender.exe" : "blender");
|
|
72
|
+
}
|
|
73
|
+
if (platform === "darwin") {
|
|
74
|
+
return join(installDir, "Google Chrome for Testing.app", "Contents", "MacOS", "Google Chrome for Testing");
|
|
75
|
+
}
|
|
76
|
+
return join(installDir, platform === "win32" ? "chrome.exe" : "chrome");
|
|
77
|
+
}
|
|
78
|
+
export async function appBinaryInstallStatus(id, installDir, platform) {
|
|
79
|
+
try {
|
|
80
|
+
await fs.access(appBinaryPath(id, installDir, platform));
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return { installed: false };
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
const marker = markerSchema.safeParse(JSON.parse(await fs.readFile(path.join(installDir, MARKER_FILE), "utf8")));
|
|
87
|
+
return { installed: true, version: marker.success ? marker.data.version : undefined };
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
// The executable is there without a marker: an install from before markers.
|
|
91
|
+
return { installed: true };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/** The installed executable, or null when the Package Manager has not installed it. */
|
|
95
|
+
export async function installedAppBinary(id, installDir, platform = process.platform) {
|
|
96
|
+
if (!installDir)
|
|
97
|
+
return null;
|
|
98
|
+
const status = await appBinaryInstallStatus(id, installDir, platform);
|
|
99
|
+
return status.installed ? appBinaryPath(id, installDir, platform) : null;
|
|
100
|
+
}
|
|
101
|
+
async function fetchText(fetchImpl, url, signal) {
|
|
102
|
+
const response = await fetchImpl(url, { signal });
|
|
103
|
+
if (!response.ok)
|
|
104
|
+
throw new Error(`Request to ${url} failed: HTTP ${response.status}`);
|
|
105
|
+
return response.text();
|
|
106
|
+
}
|
|
107
|
+
/** The newest patch of `BLENDER_SERIES` in a release directory listing, or null. */
|
|
108
|
+
export function newestBlenderArchive(listing, suffix) {
|
|
109
|
+
const escapedSeries = BLENDER_SERIES.replace(".", "\\.");
|
|
110
|
+
const escapedSuffix = suffix.replaceAll(".", "\\.");
|
|
111
|
+
const pattern = new RegExp(`blender-(${escapedSeries}\\.(\\d+))-${escapedSuffix}`, "g");
|
|
112
|
+
let best = null;
|
|
113
|
+
for (const match of listing.matchAll(pattern)) {
|
|
114
|
+
const patch = Number(match[2]);
|
|
115
|
+
if (!best || patch > best.patch) {
|
|
116
|
+
best = { fileName: match[0], version: match[1], patch };
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return best ? { fileName: best.fileName, version: best.version } : null;
|
|
120
|
+
}
|
|
121
|
+
/** The digest for `fileName` in a Blender `.sha256` file, or null. */
|
|
122
|
+
export function digestFor(sha256File, fileName) {
|
|
123
|
+
for (const line of sha256File.split("\n")) {
|
|
124
|
+
const [digest, name] = line.trim().split(/\s+/);
|
|
125
|
+
if (name === fileName && digest && /^[0-9a-f]{64}$/i.test(digest))
|
|
126
|
+
return digest.toLowerCase();
|
|
127
|
+
}
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
async function resolveBlender(options, fetchImpl) {
|
|
131
|
+
const suffix = blenderArchiveSuffix(options.platform, options.arch);
|
|
132
|
+
if (!suffix)
|
|
133
|
+
throw new Error(`Blender has no build for ${options.platform}-${options.arch}`);
|
|
134
|
+
const listing = await fetchText(fetchImpl, BLENDER_RELEASE_DIR, options.signal);
|
|
135
|
+
const newest = newestBlenderArchive(listing, suffix);
|
|
136
|
+
if (!newest)
|
|
137
|
+
throw new Error(`No Blender ${BLENDER_SERIES} build for ${suffix} is listed at ${BLENDER_RELEASE_DIR}`);
|
|
138
|
+
const sums = await fetchText(fetchImpl, `${BLENDER_RELEASE_DIR}blender-${newest.version}.sha256`, options.signal);
|
|
139
|
+
const sha256 = digestFor(sums, newest.fileName);
|
|
140
|
+
if (!sha256)
|
|
141
|
+
throw new Error(`blender-${newest.version}.sha256 has no digest for ${newest.fileName}`);
|
|
142
|
+
return { url: `${BLENDER_RELEASE_DIR}${newest.fileName}`, fileName: newest.fileName, version: newest.version, sha256 };
|
|
143
|
+
}
|
|
144
|
+
const chromeVersionsSchema = z.object({
|
|
145
|
+
channels: z.object({
|
|
146
|
+
Stable: z.object({
|
|
147
|
+
version: z.string(),
|
|
148
|
+
downloads: z.object({
|
|
149
|
+
chrome: z.array(z.object({ platform: z.string(), url: z.string().url() }))
|
|
150
|
+
})
|
|
151
|
+
})
|
|
152
|
+
})
|
|
153
|
+
});
|
|
154
|
+
async function resolveChrome(options, fetchImpl) {
|
|
155
|
+
const platform = chromeForTestingPlatform(options.platform, options.arch);
|
|
156
|
+
if (!platform)
|
|
157
|
+
throw new Error(`Chrome for Testing has no build for ${options.platform}-${options.arch}`);
|
|
158
|
+
const stable = chromeVersionsSchema.parse(JSON.parse(await fetchText(fetchImpl, CHROME_VERSIONS_URL, options.signal))).channels.Stable;
|
|
159
|
+
const download = stable.downloads.chrome.find((entry) => entry.platform === platform);
|
|
160
|
+
if (!download)
|
|
161
|
+
throw new Error(`Chrome for Testing ${stable.version} has no ${platform} download`);
|
|
162
|
+
const url = new URL(download.url);
|
|
163
|
+
if (url.protocol !== "https:")
|
|
164
|
+
throw new Error(`Refusing a Chrome download over ${url.protocol}`);
|
|
165
|
+
return { url: download.url, fileName: `chrome-${platform}.zip`, version: stable.version, sha256: null };
|
|
166
|
+
}
|
|
167
|
+
/** Stream a download to `file`, reporting progress, and return its SHA-256. */
|
|
168
|
+
async function download(fetchImpl, url, file, options) {
|
|
169
|
+
const response = await fetchImpl(url, { signal: options.signal });
|
|
170
|
+
if (!response.ok || !response.body)
|
|
171
|
+
throw new Error(`Download of ${url} failed: HTTP ${response.status}`);
|
|
172
|
+
const total = Number(response.headers.get("content-length") ?? 0);
|
|
173
|
+
const hash = createHash("sha256");
|
|
174
|
+
const out = createWriteStream(file);
|
|
175
|
+
const closed = new Promise((resolve, reject) => {
|
|
176
|
+
out.on("finish", resolve);
|
|
177
|
+
out.on("error", reject);
|
|
178
|
+
});
|
|
179
|
+
// The failure is reported where `closed` is awaited below. Until then a
|
|
180
|
+
// rejection with no handler would end the process.
|
|
181
|
+
closed.catch(() => { });
|
|
182
|
+
let received = 0;
|
|
183
|
+
const reader = response.body.getReader();
|
|
184
|
+
try {
|
|
185
|
+
for (;;) {
|
|
186
|
+
const { done, value } = await reader.read();
|
|
187
|
+
if (done)
|
|
188
|
+
break;
|
|
189
|
+
hash.update(value);
|
|
190
|
+
received += value.byteLength;
|
|
191
|
+
if (!out.write(value)) {
|
|
192
|
+
// A stream that fails while it is full (a full disk) never drains.
|
|
193
|
+
await Promise.race([
|
|
194
|
+
new Promise((resolve) => out.once("drain", resolve)),
|
|
195
|
+
closed
|
|
196
|
+
]);
|
|
197
|
+
}
|
|
198
|
+
if (total > 0) {
|
|
199
|
+
options.onEvent?.({ type: "percent", value: Math.min(90, Math.round((received / total) * 90)) });
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
finally {
|
|
204
|
+
out.end();
|
|
205
|
+
await closed;
|
|
206
|
+
}
|
|
207
|
+
return hash.digest("hex");
|
|
208
|
+
}
|
|
209
|
+
/** Unpack a zip in process, keeping Unix modes and symlinks (macOS app bundles hold both). */
|
|
210
|
+
async function unzipInProcess(archiveFile, dest) {
|
|
211
|
+
const root = path.resolve(dest);
|
|
212
|
+
for (const entry of readZipEntries(await fs.readFile(archiveFile), zlib)) {
|
|
213
|
+
const target = path.resolve(root, entry.name);
|
|
214
|
+
if (target !== root && !target.startsWith(root + path.sep)) {
|
|
215
|
+
throw new Error(`The archive holds an entry outside its root: ${entry.name}`);
|
|
216
|
+
}
|
|
217
|
+
if (entry.name.endsWith("/")) {
|
|
218
|
+
await fs.mkdir(target, { recursive: true });
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
await fs.mkdir(path.dirname(target), { recursive: true });
|
|
222
|
+
const kind = entry.mode & 0o170000;
|
|
223
|
+
if (kind === 0o120000) {
|
|
224
|
+
const link = Buffer.from(entry.data).toString("utf8");
|
|
225
|
+
const resolved = path.resolve(path.dirname(target), link);
|
|
226
|
+
if (path.isAbsolute(link) || (resolved !== root && !resolved.startsWith(root + path.sep))) {
|
|
227
|
+
throw new Error(`The archive holds a link outside its root: ${entry.name}`);
|
|
228
|
+
}
|
|
229
|
+
await fs.symlink(link, target);
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
await fs.writeFile(target, entry.data, { mode: entry.mode & 0o777 || 0o644 });
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
async function unpack(archiveFile, fileName, dest, platform) {
|
|
236
|
+
await fs.mkdir(dest, { recursive: true });
|
|
237
|
+
if (fileName.endsWith(".tar.xz")) {
|
|
238
|
+
await execFileAsync("tar", ["-xJf", archiveFile, "-C", dest]);
|
|
239
|
+
}
|
|
240
|
+
else if (fileName.endsWith(".dmg")) {
|
|
241
|
+
const mount = `${dest}.mount`;
|
|
242
|
+
await fs.mkdir(mount, { recursive: true });
|
|
243
|
+
await execFileAsync("hdiutil", ["attach", "-nobrowse", "-readonly", "-mountpoint", mount, archiveFile]);
|
|
244
|
+
try {
|
|
245
|
+
await execFileAsync("ditto", [path.join(mount, "Blender.app"), path.join(dest, "Blender.app")]);
|
|
246
|
+
}
|
|
247
|
+
finally {
|
|
248
|
+
await execFileAsync("hdiutil", ["detach", mount, "-force"]).catch(() => {
|
|
249
|
+
// A busy mount detaches when the system releases it; the copy is complete.
|
|
250
|
+
});
|
|
251
|
+
await fs.rm(mount, { recursive: true, force: true });
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
else if (platform === "win32") {
|
|
255
|
+
// Windows 10 and later ship bsdtar, which reads zip and streams a large archive.
|
|
256
|
+
await execFileAsync("tar", ["-xf", archiveFile, "-C", dest]);
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
await unzipInProcess(archiveFile, dest);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* The directory holding the executable: the staging root, or the single
|
|
264
|
+
* top-level folder the archive unpacked into.
|
|
265
|
+
*/
|
|
266
|
+
async function contentRoot(id, staging, platform) {
|
|
267
|
+
const exists = async (dir) => fs.access(appBinaryPath(id, dir, platform)).then(() => true, () => false);
|
|
268
|
+
if (await exists(staging))
|
|
269
|
+
return staging;
|
|
270
|
+
for (const entry of await fs.readdir(staging, { withFileTypes: true })) {
|
|
271
|
+
if (entry.isDirectory() && (await exists(path.join(staging, entry.name)))) {
|
|
272
|
+
return path.join(staging, entry.name);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
throw new Error(`The ${id} archive holds no ${path.basename(appBinaryPath(id, staging, platform))}`);
|
|
276
|
+
}
|
|
277
|
+
/** Download, verify and unpack Blender or Chrome into `installDir`. */
|
|
278
|
+
export async function installAppBinary(id, options) {
|
|
279
|
+
const fetchImpl = options.fetchImpl ?? fetch;
|
|
280
|
+
const { installDir, platform, onEvent } = options;
|
|
281
|
+
onEvent?.({ type: "stage", label: id === "blender" ? `Finding the newest Blender ${BLENDER_SERIES}` : "Finding the current Chrome for Testing" });
|
|
282
|
+
const archive = id === "blender" ? await resolveBlender(options, fetchImpl) : await resolveChrome(options, fetchImpl);
|
|
283
|
+
await fs.mkdir(path.dirname(installDir), { recursive: true });
|
|
284
|
+
const archiveFile = `${installDir}.download`;
|
|
285
|
+
const staging = `${installDir}.partial`;
|
|
286
|
+
try {
|
|
287
|
+
onEvent?.({ type: "stage", label: `Downloading ${archive.fileName}` });
|
|
288
|
+
const digest = await download(fetchImpl, archive.url, archiveFile, options);
|
|
289
|
+
if (archive.sha256 && digest !== archive.sha256) {
|
|
290
|
+
throw new Error(`${archive.fileName} failed its SHA-256 check (got ${digest})`);
|
|
291
|
+
}
|
|
292
|
+
onEvent?.({ type: "stage", label: `Unpacking ${archive.fileName}` });
|
|
293
|
+
await fs.rm(staging, { recursive: true, force: true });
|
|
294
|
+
await unpack(archiveFile, archive.fileName, staging, platform);
|
|
295
|
+
const root = await contentRoot(id, staging, platform);
|
|
296
|
+
await fs.writeFile(path.join(root, MARKER_FILE), `${JSON.stringify({ version: archive.version, url: archive.url })}\n`);
|
|
297
|
+
await fs.rm(installDir, { recursive: true, force: true });
|
|
298
|
+
await fs.rename(root, installDir);
|
|
299
|
+
}
|
|
300
|
+
finally {
|
|
301
|
+
await fs.rm(archiveFile, { force: true });
|
|
302
|
+
await fs.rm(staging, { recursive: true, force: true });
|
|
303
|
+
}
|
|
304
|
+
onEvent?.({ type: "percent", value: 100 });
|
|
305
|
+
return { installed: true, version: archive.version };
|
|
306
|
+
}
|
|
307
|
+
export async function uninstallAppBinary(installDir) {
|
|
308
|
+
await fs.rm(installDir, { recursive: true, force: true });
|
|
309
|
+
}
|
|
310
|
+
//# sourceMappingURL=app-binary-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-binary-runtime.js","sourceRoot":"","sources":["../src/app-binary-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,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AAM,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;IAC3C,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;AACvD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,UAAkB;IACzD,MAAM,EAAE,CAAC,EAAE,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC5D,CAAC"}
|
package/dist/deployment.d.ts
CHANGED
|
@@ -14,4 +14,24 @@ export declare function isOidcAuthConfigured(env?: Record<string, string | undef
|
|
|
14
14
|
* where loopback is trusted and the machine belongs to the person using it.
|
|
15
15
|
*/
|
|
16
16
|
export declare function isAuthEnforced(env?: Record<string, string | undefined>): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Names the absolute maximum age, in days, of a desktop sign-in or MCP grant.
|
|
19
|
+
* Refreshing a grant never extends it past this age.
|
|
20
|
+
*/
|
|
21
|
+
export declare const OAUTH_GRANT_MAX_AGE_ENV = "NODETOOL_OAUTH_GRANT_MAX_AGE_DAYS";
|
|
22
|
+
/**
|
|
23
|
+
* The maximum grant age under SSO when the operator sets none. Group
|
|
24
|
+
* membership at the identity provider is checked at sign-in only, so a grant
|
|
25
|
+
* created from an SSO session must end on its own. 30 days matches the
|
|
26
|
+
* longest `OIDC_SESSION_TTL_SECONDS` and the MCP refresh chain.
|
|
27
|
+
*/
|
|
28
|
+
export declare const DEFAULT_SSO_OAUTH_GRANT_MAX_AGE_DAYS = 30;
|
|
29
|
+
/**
|
|
30
|
+
* The absolute maximum age of an OAuth grant in milliseconds, or null for no
|
|
31
|
+
* maximum. `NODETOOL_OAUTH_GRANT_MAX_AGE_DAYS` sets it: a whole number of
|
|
32
|
+
* days from 1 to 3650, or 0 for no maximum. Unset, it is 30 days under SSO
|
|
33
|
+
* and no maximum otherwise. Throws on any other value, so the server refuses
|
|
34
|
+
* to start with a typo in it.
|
|
35
|
+
*/
|
|
36
|
+
export declare function oauthGrantMaxAgeMs(env?: Record<string, string | undefined>): number | null;
|
|
17
37
|
//# sourceMappingURL=deployment.d.ts.map
|
package/dist/deployment.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deployment.d.ts","sourceRoot":"","sources":["../src/deployment.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAoB,GACzD,OAAO,CAET;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAoB,GACzD,OAAO,CAET;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAoB,GACzD,OAAO,CAET"}
|
|
1
|
+
{"version":3,"file":"deployment.d.ts","sourceRoot":"","sources":["../src/deployment.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAoB,GACzD,OAAO,CAET;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAoB,GACzD,OAAO,CAET;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAoB,GACzD,OAAO,CAET;AAED;;;GAGG;AACH,eAAO,MAAM,uBAAuB,sCAAsC,CAAC;AAC3E;;;;;GAKG;AACH,eAAO,MAAM,oCAAoC,KAAK,CAAC;AAIvD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAoB,GACzD,MAAM,GAAG,IAAI,CAef"}
|
package/dist/deployment.js
CHANGED
|
@@ -29,4 +29,39 @@ export function isOidcAuthConfigured(env = safeProcessEnv()) {
|
|
|
29
29
|
export function isAuthEnforced(env = safeProcessEnv()) {
|
|
30
30
|
return isSupabaseAuthConfigured(env) || isOidcAuthConfigured(env);
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Names the absolute maximum age, in days, of a desktop sign-in or MCP grant.
|
|
34
|
+
* Refreshing a grant never extends it past this age.
|
|
35
|
+
*/
|
|
36
|
+
export const OAUTH_GRANT_MAX_AGE_ENV = "NODETOOL_OAUTH_GRANT_MAX_AGE_DAYS";
|
|
37
|
+
/**
|
|
38
|
+
* The maximum grant age under SSO when the operator sets none. Group
|
|
39
|
+
* membership at the identity provider is checked at sign-in only, so a grant
|
|
40
|
+
* created from an SSO session must end on its own. 30 days matches the
|
|
41
|
+
* longest `OIDC_SESSION_TTL_SECONDS` and the MCP refresh chain.
|
|
42
|
+
*/
|
|
43
|
+
export const DEFAULT_SSO_OAUTH_GRANT_MAX_AGE_DAYS = 30;
|
|
44
|
+
const MAX_OAUTH_GRANT_MAX_AGE_DAYS = 3650;
|
|
45
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
46
|
+
/**
|
|
47
|
+
* The absolute maximum age of an OAuth grant in milliseconds, or null for no
|
|
48
|
+
* maximum. `NODETOOL_OAUTH_GRANT_MAX_AGE_DAYS` sets it: a whole number of
|
|
49
|
+
* days from 1 to 3650, or 0 for no maximum. Unset, it is 30 days under SSO
|
|
50
|
+
* and no maximum otherwise. Throws on any other value, so the server refuses
|
|
51
|
+
* to start with a typo in it.
|
|
52
|
+
*/
|
|
53
|
+
export function oauthGrantMaxAgeMs(env = safeProcessEnv()) {
|
|
54
|
+
const raw = env[OAUTH_GRANT_MAX_AGE_ENV]?.trim();
|
|
55
|
+
if (!raw) {
|
|
56
|
+
return isOidcAuthConfigured(env)
|
|
57
|
+
? DEFAULT_SSO_OAUTH_GRANT_MAX_AGE_DAYS * DAY_MS
|
|
58
|
+
: null;
|
|
59
|
+
}
|
|
60
|
+
const days = /^\d+$/.test(raw) ? Number(raw) : NaN;
|
|
61
|
+
if (!Number.isSafeInteger(days) || days > MAX_OAUTH_GRANT_MAX_AGE_DAYS) {
|
|
62
|
+
throw new Error(`${OAUTH_GRANT_MAX_AGE_ENV} must be a whole number of days between 0 ` +
|
|
63
|
+
`and ${MAX_OAUTH_GRANT_MAX_AGE_DAYS}, got "${raw.slice(0, 32)}"`);
|
|
64
|
+
}
|
|
65
|
+
return days === 0 ? null : days * DAY_MS;
|
|
66
|
+
}
|
|
32
67
|
//# sourceMappingURL=deployment.js.map
|
package/dist/deployment.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deployment.js","sourceRoot":"","sources":["../src/deployment.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;GAEG;AACH,MAAM,UAAU,wBAAwB,CACtC,GAAG,GAAuC,cAAc,EAAE;IAE1D,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,GAAG,GAAuC,cAAc,EAAE;IAE1D,OAAO,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9E,CAAC;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AG,GAAG,CAAC,uBAAuB,CAAC,EAAE,IAAI,EAAE,CAAC;IACjD,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,oBAAoB,CAAC,GAAG,CAAC;YAC9B,CAAC,CAAC,oCAAoC,GAAG,MAAM;YAC/C,CAAC,CAAC,IAAI,CAAC;IACX,CAAC;IACD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IACnD,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,4BAA4B,EAAE,CAAC;QACvE,MAAM,IAAI,KAAK,CACb,GAAG,uBAAuB,4CAA4C;YACpE,OAAO,4BAA4B,UAAU,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CACnE,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,MAAM,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** Where an env file sits in the search order. */
|
|
2
|
+
export type EnvFileScope = "flag" | "NODETOOL_ENV_FILE" | "project" | "home";
|
|
3
|
+
export interface EnvFileCandidate {
|
|
4
|
+
readonly path: string;
|
|
5
|
+
readonly scope: EnvFileScope;
|
|
6
|
+
}
|
|
7
|
+
export interface EnvFileReport extends EnvFileCandidate {
|
|
8
|
+
readonly exists: boolean;
|
|
9
|
+
/** Names this file set: absent from the environment and from every earlier file. */
|
|
10
|
+
readonly applied: readonly string[];
|
|
11
|
+
/** Names in the file that an earlier source already set. */
|
|
12
|
+
readonly shadowed: readonly string[];
|
|
13
|
+
readonly warnings: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
export interface EnvLoadResult {
|
|
16
|
+
readonly files: readonly EnvFileReport[];
|
|
17
|
+
/** Variable name to the env file that supplied it. Names missing here came from the process environment. */
|
|
18
|
+
readonly sources: Readonly<Record<string, string>>;
|
|
19
|
+
}
|
|
20
|
+
export interface EnvLoadOptions {
|
|
21
|
+
/** Mutated in place: values from env files are added to it. */
|
|
22
|
+
readonly env: NodeJS.ProcessEnv;
|
|
23
|
+
readonly cwd?: string;
|
|
24
|
+
readonly home?: string;
|
|
25
|
+
/** Value of `--env-file`. */
|
|
26
|
+
readonly envFile?: string;
|
|
27
|
+
/**
|
|
28
|
+
* False leaves out `./.env.local` and `./.env`. An entry point that another
|
|
29
|
+
* program starts in a directory the user did not choose, such as an MCP
|
|
30
|
+
* server started by an agent client inside a cloned repository, must not
|
|
31
|
+
* let that directory redirect provider base URLs or set NODE_OPTIONS.
|
|
32
|
+
*/
|
|
33
|
+
readonly projectFiles?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Env files in precedence order, highest first: `--env-file`, then
|
|
37
|
+
* NODETOOL_ENV_FILE, then `./.env.local` and `./.env` in the working
|
|
38
|
+
* directory unless `projectFiles` is false, then `~/.nodetool/.env` and
|
|
39
|
+
* `~/.env`. A path reached twice (the working directory is the home
|
|
40
|
+
* directory) is listed once.
|
|
41
|
+
*/
|
|
42
|
+
export declare function envFileCandidates(options: Omit<EnvLoadOptions, "env"> & {
|
|
43
|
+
readonly env: NodeJS.ProcessEnv;
|
|
44
|
+
}): EnvFileCandidate[];
|
|
45
|
+
/** Permission warnings for one env file. Windows has no POSIX mode bits to check. */
|
|
46
|
+
export declare function envFilePermissionWarnings(path: string): string[];
|
|
47
|
+
/**
|
|
48
|
+
* Apply env files to `options.env`. A variable already set in the environment
|
|
49
|
+
* always wins, and among files the first in the search order wins. Values are
|
|
50
|
+
* never logged or returned: only names and paths. A file named by
|
|
51
|
+
* `--env-file` or NODETOOL_ENV_FILE must exist.
|
|
52
|
+
*/
|
|
53
|
+
export declare function loadCliEnvironment(options: EnvLoadOptions): EnvLoadResult;
|
|
54
|
+
/** One line per loaded file, names only. */
|
|
55
|
+
export declare function describeEnvLoad(result: EnvLoadResult): string[];
|
|
56
|
+
//# sourceMappingURL=env-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-files.d.ts","sourceRoot":"","sources":["../src/env-files.ts"],"names":[],"mappings":"AAUA,kDAAkD;AAClD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,mBAAmB,GAAG,SAAS,GAAG,MAAM,CAAC;AAE7E,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;CAC9B;AAED,MAAM,WAAW,aAAc,SAAQ,gBAAgB;IACrD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,oFAAoF;IACpF,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;IACzC,4GAA4G;IAC5G,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,cAAc;IAC7B,+DAA+D;IAC/D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IAChC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,6BAA6B;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;CACjC;AAID;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,KAAK,CAAC,GAAG;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAA;CAAE,GAAG,gBAAgB,EAAE,CAuBhI;AAED,qFAAqF;AACrF,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAUhE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,GAAG,aAAa,CAyBzE;AAED,4CAA4C;AAC5C,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,EAAE,CAE/D"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The env files every NodeTool command-line entry point loads before it
|
|
3
|
+
* runs: the `nodetool` CLI and standalone command executables such as
|
|
4
|
+
* `nodetool-mcp`.
|
|
5
|
+
*/
|
|
6
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
7
|
+
import { homedir } from "node:os";
|
|
8
|
+
import { join, resolve } from "node:path";
|
|
9
|
+
import { parseEnvFile } from "./env-file.js";
|
|
10
|
+
const isSet = (value) => value !== undefined && value !== "";
|
|
11
|
+
/**
|
|
12
|
+
* Env files in precedence order, highest first: `--env-file`, then
|
|
13
|
+
* NODETOOL_ENV_FILE, then `./.env.local` and `./.env` in the working
|
|
14
|
+
* directory unless `projectFiles` is false, then `~/.nodetool/.env` and
|
|
15
|
+
* `~/.env`. A path reached twice (the working directory is the home
|
|
16
|
+
* directory) is listed once.
|
|
17
|
+
*/
|
|
18
|
+
export function envFileCandidates(options) {
|
|
19
|
+
const cwd = options.cwd ?? process.cwd();
|
|
20
|
+
const home = options.home ?? (options.env.HOME || options.env.USERPROFILE || homedir());
|
|
21
|
+
const candidates = [];
|
|
22
|
+
if (isSet(options.envFile)) {
|
|
23
|
+
candidates.push({ path: resolve(cwd, options.envFile), scope: "flag" });
|
|
24
|
+
}
|
|
25
|
+
if (isSet(options.env.NODETOOL_ENV_FILE)) {
|
|
26
|
+
candidates.push({ path: resolve(cwd, options.env.NODETOOL_ENV_FILE), scope: "NODETOOL_ENV_FILE" });
|
|
27
|
+
}
|
|
28
|
+
if (options.projectFiles !== false) {
|
|
29
|
+
candidates.push({ path: join(cwd, ".env.local"), scope: "project" }, { path: join(cwd, ".env"), scope: "project" });
|
|
30
|
+
}
|
|
31
|
+
candidates.push({ path: join(home, ".nodetool", ".env"), scope: "home" }, { path: join(home, ".env"), scope: "home" });
|
|
32
|
+
const seen = new Set();
|
|
33
|
+
return candidates.filter(candidate => {
|
|
34
|
+
const path = resolve(candidate.path);
|
|
35
|
+
if (seen.has(path)) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
seen.add(path);
|
|
39
|
+
return true;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/** Permission warnings for one env file. Windows has no POSIX mode bits to check. */
|
|
43
|
+
export function envFilePermissionWarnings(path) {
|
|
44
|
+
if (process.platform === "win32") {
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const mode = statSync(path).mode;
|
|
49
|
+
if (mode & 0o004) {
|
|
50
|
+
return [`${path} is readable by every user on this machine. Restrict it with \`chmod 600 ${path}\`.`];
|
|
51
|
+
}
|
|
52
|
+
if (mode & 0o040) {
|
|
53
|
+
return [`${path} is readable by its group. Restrict it with \`chmod 600 ${path}\`.`];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// The file vanished after it was read: nothing to warn about.
|
|
58
|
+
}
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Apply env files to `options.env`. A variable already set in the environment
|
|
63
|
+
* always wins, and among files the first in the search order wins. Values are
|
|
64
|
+
* never logged or returned: only names and paths. A file named by
|
|
65
|
+
* `--env-file` or NODETOOL_ENV_FILE must exist.
|
|
66
|
+
*/
|
|
67
|
+
export function loadCliEnvironment(options) {
|
|
68
|
+
const { env } = options;
|
|
69
|
+
const files = [];
|
|
70
|
+
const sources = {};
|
|
71
|
+
for (const candidate of envFileCandidates(options)) {
|
|
72
|
+
if (!existsSync(candidate.path)) {
|
|
73
|
+
if (candidate.scope === "flag" || candidate.scope === "NODETOOL_ENV_FILE") {
|
|
74
|
+
throw new Error(`Env file ${candidate.path} does not exist. It was named by ${candidate.scope === "flag" ? "--env-file" : "NODETOOL_ENV_FILE"}.`);
|
|
75
|
+
}
|
|
76
|
+
files.push({ ...candidate, exists: false, applied: [], shadowed: [], warnings: [] });
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const applied = [];
|
|
80
|
+
const shadowed = [];
|
|
81
|
+
for (const [name, value] of Object.entries(parseEnvFile(readFileSync(candidate.path, "utf8")))) {
|
|
82
|
+
// An empty assignment (`KEY=`) is a placeholder, not a value: it must not hide a lower file.
|
|
83
|
+
if (value === "") {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (isSet(env[name])) {
|
|
87
|
+
shadowed.push(name);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
env[name] = value;
|
|
91
|
+
sources[name] = candidate.path;
|
|
92
|
+
applied.push(name);
|
|
93
|
+
}
|
|
94
|
+
files.push({ ...candidate, exists: true, applied, shadowed, warnings: envFilePermissionWarnings(candidate.path) });
|
|
95
|
+
}
|
|
96
|
+
return { files, sources };
|
|
97
|
+
}
|
|
98
|
+
/** One line per loaded file, names only. */
|
|
99
|
+
export function describeEnvLoad(result) {
|
|
100
|
+
return result.files.filter(file => file.exists).map(file => `Loaded ${file.applied.length} variable(s) from ${file.path}${file.applied.length ? `: ${file.applied.join(", ")}` : ""}`);
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=env-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env-files.js","sourceRoot":"","sources":["../src/env-files.ts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GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;gBAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAAC,SAAS;YAAC,CAAC;YACxD,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;YAClB,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC;YAC/B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,yBAAyB,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACrH,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC5B,CAAC;AAED,4CAA4C;AAC5C,MAAM,UAAU,eAAe,CAAC,MAAqB;IACnD,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,MAAM,qBAAqB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACzL,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which settings a user may supply on this server, and which come only from
|
|
3
|
+
* the operator.
|
|
4
|
+
*
|
|
5
|
+
* A desktop or self-hosted single-user install belongs to the person using it,
|
|
6
|
+
* so a program path saved in their settings is theirs to choose. A shared
|
|
7
|
+
* server (auth enforced, or the cloud profile) runs every user's requests as
|
|
8
|
+
* the same host process, so a program it starts is the operator's to name:
|
|
9
|
+
* there an `executable` setting is read only from the server's environment.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* True when the server is shared between users: a remote identity provider is
|
|
13
|
+
* configured, or the cloud profile is active.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isSharedServer(env?: Record<string, string | undefined>): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* True when `key` names a program the host starts and this server is shared,
|
|
18
|
+
* so its value comes from the environment and never from a user's saved
|
|
19
|
+
* settings or secrets.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isServerEnvOnlySetting(key: string, env?: Record<string, string | undefined>): boolean;
|
|
22
|
+
//# sourceMappingURL=host-settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-settings.d.ts","sourceRoot":"","sources":["../src/host-settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAOH;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAoB,GACzD,OAAO,CAET;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,MAAM,EACX,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAoB,GACzD,OAAO,CAIT"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which settings a user may supply on this server, and which come only from
|
|
3
|
+
* the operator.
|
|
4
|
+
*
|
|
5
|
+
* A desktop or self-hosted single-user install belongs to the person using it,
|
|
6
|
+
* so a program path saved in their settings is theirs to choose. A shared
|
|
7
|
+
* server (auth enforced, or the cloud profile) runs every user's requests as
|
|
8
|
+
* the same host process, so a program it starts is the operator's to name:
|
|
9
|
+
* there an `executable` setting is read only from the server's environment.
|
|
10
|
+
*/
|
|
11
|
+
import { isAuthEnforced } from "./deployment.js";
|
|
12
|
+
import { safeProcessEnv } from "./node-import.js";
|
|
13
|
+
import { isCloudProfileEnv } from "./server-credentials.js";
|
|
14
|
+
import { settingDefinition } from "./setting-catalog.js";
|
|
15
|
+
/**
|
|
16
|
+
* True when the server is shared between users: a remote identity provider is
|
|
17
|
+
* configured, or the cloud profile is active.
|
|
18
|
+
*/
|
|
19
|
+
export function isSharedServer(env = safeProcessEnv()) {
|
|
20
|
+
return isAuthEnforced(env) || isCloudProfileEnv(env);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* True when `key` names a program the host starts and this server is shared,
|
|
24
|
+
* so its value comes from the environment and never from a user's saved
|
|
25
|
+
* settings or secrets.
|
|
26
|
+
*/
|
|
27
|
+
export function isServerEnvOnlySetting(key, env = safeProcessEnv()) {
|
|
28
|
+
return (settingDefinition(key)?.hostPath === "executable" && isSharedServer(env));
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=host-settings.js.map
|