@blaxel/core 0.3.20-preview.288 → 0.3.20-preview.289
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/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/common/env.js +25 -9
- package/dist/cjs/common/env.test.js +68 -6
- package/dist/cjs/common/settings.js +2 -2
- package/dist/cjs-browser/.tsbuildinfo +1 -1
- package/dist/cjs-browser/common/env.js +25 -9
- package/dist/cjs-browser/common/env.test.js +68 -6
- package/dist/cjs-browser/common/settings.js +2 -2
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/common/env.js +25 -9
- package/dist/esm/common/env.test.js +68 -6
- package/dist/esm/common/settings.js +2 -2
- package/dist/esm-browser/.tsbuildinfo +1 -1
- package/dist/esm-browser/common/env.js +25 -9
- package/dist/esm-browser/common/env.test.js +68 -6
- package/dist/esm-browser/common/settings.js +2 -2
- package/package.json +2 -2
package/dist/cjs/common/env.js
CHANGED
|
@@ -4,16 +4,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.env = void 0;
|
|
7
|
-
const
|
|
7
|
+
const smol_toml_1 = __importDefault(require("smol-toml"));
|
|
8
8
|
const node_js_1 = require("./node.js");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
9
|
+
const hasOwn = (source, prop) => Object.prototype.hasOwnProperty.call(source, prop);
|
|
10
|
+
const secretEnv = Object.create(null);
|
|
11
|
+
const configEnv = Object.create(null);
|
|
12
|
+
const stringifyTomlEnvValue = (value) => {
|
|
13
|
+
if (typeof value === "string") {
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
|
|
17
|
+
return String(value);
|
|
18
|
+
}
|
|
19
|
+
if (value instanceof Date) {
|
|
20
|
+
return value.toISOString();
|
|
21
|
+
}
|
|
22
|
+
const serialized = JSON.stringify(value);
|
|
23
|
+
return serialized === undefined ? String(value) : serialized;
|
|
24
|
+
};
|
|
11
25
|
if (node_js_1.fs !== null) {
|
|
12
26
|
try {
|
|
13
27
|
const configFile = node_js_1.fs.readFileSync("blaxel.toml", "utf8");
|
|
14
|
-
const configInfos =
|
|
15
|
-
|
|
16
|
-
|
|
28
|
+
const configInfos = smol_toml_1.default.parse(configFile, { maxDepth: 100 });
|
|
29
|
+
if (configInfos.env && typeof configInfos.env === "object") {
|
|
30
|
+
for (const [key, value] of Object.entries(configInfos.env)) {
|
|
31
|
+
configEnv[key] = stringifyTomlEnvValue(value);
|
|
32
|
+
}
|
|
17
33
|
}
|
|
18
34
|
}
|
|
19
35
|
catch {
|
|
@@ -42,13 +58,13 @@ if (node_js_1.fs !== null) {
|
|
|
42
58
|
}
|
|
43
59
|
const env = new Proxy({}, {
|
|
44
60
|
get: (target, prop) => {
|
|
45
|
-
if (secretEnv
|
|
61
|
+
if (hasOwn(secretEnv, prop)) {
|
|
46
62
|
return secretEnv[prop];
|
|
47
63
|
}
|
|
48
|
-
if (configEnv
|
|
64
|
+
if (hasOwn(configEnv, prop)) {
|
|
49
65
|
return configEnv[prop];
|
|
50
66
|
}
|
|
51
|
-
if (typeof process !== "undefined" && process.env) {
|
|
67
|
+
if (typeof process !== "undefined" && process.env && hasOwn(process.env, prop)) {
|
|
52
68
|
return process.env[prop];
|
|
53
69
|
}
|
|
54
70
|
return undefined;
|
|
@@ -39,9 +39,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
const node_fs_1 = require("node:fs");
|
|
40
40
|
const node_os_1 = require("node:os");
|
|
41
41
|
const node_path_1 = require("node:path");
|
|
42
|
-
const
|
|
42
|
+
const smol_toml_1 = __importDefault(require("smol-toml"));
|
|
43
43
|
const vitest_1 = require("vitest");
|
|
44
44
|
const originalCwd = process.cwd();
|
|
45
|
+
const originalWorkspace = process.env.BL_WORKSPACE;
|
|
45
46
|
let currentTempDir;
|
|
46
47
|
const importEnvFromTempConfig = async (config) => {
|
|
47
48
|
currentTempDir = (0, node_fs_1.mkdtempSync)((0, node_path_1.join)((0, node_os_1.tmpdir)(), "blaxel-env-"));
|
|
@@ -52,6 +53,14 @@ const importEnvFromTempConfig = async (config) => {
|
|
|
52
53
|
};
|
|
53
54
|
(0, vitest_1.afterEach)(() => {
|
|
54
55
|
process.chdir(originalCwd);
|
|
56
|
+
if (originalWorkspace === undefined) {
|
|
57
|
+
delete process.env.BL_WORKSPACE;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
process.env.BL_WORKSPACE = originalWorkspace;
|
|
61
|
+
}
|
|
62
|
+
delete Object.prototype.BL_WORKSPACE;
|
|
63
|
+
delete Object.prototype.SECRET_ENV;
|
|
55
64
|
vitest_1.vi.resetModules();
|
|
56
65
|
if (currentTempDir) {
|
|
57
66
|
(0, node_fs_1.rmSync)(currentTempDir, { force: true, recursive: true });
|
|
@@ -68,10 +77,63 @@ BL_API_URL = "https://api.example.test"
|
|
|
68
77
|
(0, vitest_1.expect)(env.BL_WORKSPACE).toBe("test-workspace");
|
|
69
78
|
(0, vitest_1.expect)(env.BL_API_URL).toBe("https://api.example.test");
|
|
70
79
|
});
|
|
71
|
-
(0, vitest_1.it)("
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
(0, vitest_1.it)("serializes supported TOML env value types through the SDK env proxy", async () => {
|
|
81
|
+
const { env } = await importEnvFromTempConfig(`
|
|
82
|
+
[env]
|
|
83
|
+
BOOLEAN_VALUE = true
|
|
84
|
+
NUMBER_VALUE = 42
|
|
85
|
+
ARRAY_VALUE = ["a", "b"]
|
|
86
|
+
INLINE_TABLE_VALUE = { name = "sandbox", enabled = true }
|
|
87
|
+
MULTILINE_VALUE = """
|
|
88
|
+
line one
|
|
89
|
+
line two
|
|
90
|
+
"""
|
|
91
|
+
`);
|
|
92
|
+
(0, vitest_1.expect)(env.BOOLEAN_VALUE).toBe("true");
|
|
93
|
+
(0, vitest_1.expect)(env.NUMBER_VALUE).toBe("42");
|
|
94
|
+
(0, vitest_1.expect)(env.ARRAY_VALUE).toBe('["a","b"]');
|
|
95
|
+
(0, vitest_1.expect)(env.INLINE_TABLE_VALUE).toBe('{"name":"sandbox","enabled":true}');
|
|
96
|
+
(0, vitest_1.expect)(env.MULTILINE_VALUE).toBe("line one\nline two\n");
|
|
97
|
+
});
|
|
98
|
+
(0, vitest_1.it)("bounds array and inline-table nesting in the selected TOML parser", () => {
|
|
99
|
+
const nestedArray = `value = ${"[".repeat(6)}0${"]".repeat(6)}`;
|
|
100
|
+
const nestedInlineTable = `value = ${"{ a = ".repeat(6)}0${"}".repeat(6)}`;
|
|
101
|
+
(0, vitest_1.expect)(() => smol_toml_1.default.parse(nestedArray, { maxDepth: 5 })).toThrow(/excessively nested structures/);
|
|
102
|
+
(0, vitest_1.expect)(() => smol_toml_1.default.parse(nestedInlineTable, { maxDepth: 5 })).toThrow(/excessively nested structures/);
|
|
103
|
+
});
|
|
104
|
+
(0, vitest_1.it)("uses the SDK loader bounded TOML parser for default config parsing", async () => {
|
|
105
|
+
process.env.BL_WORKSPACE = "process-workspace";
|
|
106
|
+
const nestedArray = `${"[".repeat(101)}0${"]".repeat(101)}`;
|
|
107
|
+
const { env } = await importEnvFromTempConfig(`
|
|
108
|
+
[env]
|
|
109
|
+
BL_WORKSPACE = "toml-workspace"
|
|
110
|
+
TOO_DEEP = ${nestedArray}
|
|
111
|
+
`);
|
|
112
|
+
(0, vitest_1.expect)(env.BL_WORKSPACE).toBe("process-workspace");
|
|
113
|
+
});
|
|
114
|
+
(0, vitest_1.it)("does not load inherited env keys from config or secret sources", async () => {
|
|
115
|
+
delete process.env.BL_WORKSPACE;
|
|
116
|
+
Object.prototype.BL_WORKSPACE = "polluted-workspace";
|
|
117
|
+
Object.prototype.SECRET_ENV = "polluted-secret";
|
|
118
|
+
const { env } = await importEnvFromTempConfig(`
|
|
119
|
+
[env]
|
|
120
|
+
LEGITIMATE_ENV = "kept"
|
|
121
|
+
`);
|
|
122
|
+
(0, vitest_1.expect)(env.BL_WORKSPACE).toBeUndefined();
|
|
123
|
+
(0, vitest_1.expect)(env.SECRET_ENV).toBeUndefined();
|
|
124
|
+
(0, vitest_1.expect)(env.LEGITIMATE_ENV).toBe("kept");
|
|
125
|
+
});
|
|
126
|
+
(0, vitest_1.it)("does not pollute prototypes while loading malicious TOML env keys", async () => {
|
|
127
|
+
delete process.env.BL_WORKSPACE;
|
|
128
|
+
const { env } = await importEnvFromTempConfig(`
|
|
129
|
+
[env]
|
|
130
|
+
BL_WORKSPACE = "legitimate-workspace"
|
|
131
|
+
|
|
132
|
+
[env.__proto__]
|
|
133
|
+
INJECTED = "polluted-workspace"
|
|
134
|
+
`);
|
|
135
|
+
(0, vitest_1.expect)(env.BL_WORKSPACE).toBe("legitimate-workspace");
|
|
136
|
+
(0, vitest_1.expect)(env.INJECTED).toBeUndefined();
|
|
137
|
+
(0, vitest_1.expect)(Object.prototype).not.toHaveProperty("INJECTED");
|
|
76
138
|
});
|
|
77
139
|
});
|
|
@@ -30,8 +30,8 @@ function missingCredentialsMessage() {
|
|
|
30
30
|
return "No Blaxel credentials found. Set the BL_API_KEY and BL_WORKSPACE environment variables, or run `bl login`.";
|
|
31
31
|
}
|
|
32
32
|
// Build info - these placeholders are replaced at build time by build:replace-imports
|
|
33
|
-
const BUILD_VERSION = "0.3.20-preview.
|
|
34
|
-
const BUILD_COMMIT = "
|
|
33
|
+
const BUILD_VERSION = "0.3.20-preview.289";
|
|
34
|
+
const BUILD_COMMIT = "58aa51d749f749507d5fee77ee0393ec7d9c4753";
|
|
35
35
|
const BUILD_SENTRY_DSN = "https://fd5e60e1c9820e1eef5ccebb84a07127@o4508714045276160.ingest.us.sentry.io/4510465864564736";
|
|
36
36
|
const BLAXEL_API_VERSION = "2026-04-28";
|
|
37
37
|
// Bun < 1.3.11 never sends connection-level WINDOW_UPDATE: the pooled h2
|