@rakay-technology/kraft 0.7.4 → 0.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +1 -11
  2. package/dist/bare-JM3EX7S4.js +27 -0
  3. package/dist/{chunk-EW4PHKB2.js → chunk-2UQFOUSZ.js} +8 -8
  4. package/dist/{chunk-WYNM7L22.js → chunk-2Y62WP2D.js} +2 -2
  5. package/dist/{chunk-N4OALTFK.js → chunk-3RCXJZJD.js} +1 -1
  6. package/dist/{chunk-PZVKPCKE.js → chunk-4UITBYUK.js} +5 -5
  7. package/dist/{chunk-DM3PKWDC.js → chunk-7UKBMDUF.js} +9 -9
  8. package/dist/{chunk-MNV2QFHW.js → chunk-BN23UUSF.js} +1 -1
  9. package/dist/{chunk-I2TOOF2A.js → chunk-CO6FAYLO.js} +1 -1
  10. package/dist/{chunk-AJ4QZLZ2.js → chunk-DFVWR6JM.js} +2 -2
  11. package/dist/{chunk-S3QBGGVP.js → chunk-DI54Y66N.js} +3 -3
  12. package/dist/{chunk-HMJUFZK7.js → chunk-DJNKEVZ7.js} +1 -1
  13. package/dist/{chunk-JSCZT76F.js → chunk-GABTH5TU.js} +10 -8
  14. package/dist/{chunk-XVKUFMIB.js → chunk-HFOE2IXZ.js} +1 -1
  15. package/dist/{chunk-RFOBMHQ7.js → chunk-JK7KKBXI.js} +4 -4
  16. package/dist/{chunk-XGCG4MD5.js → chunk-K24SBFI2.js} +1 -1
  17. package/dist/{chunk-TAML5WMA.js → chunk-MC4X55BW.js} +3 -3
  18. package/dist/chunk-ND23EK7Y.js +81645 -0
  19. package/dist/{chunk-PNNXWA2A.js → chunk-OZUFHE2T.js} +255 -104
  20. package/dist/{chunk-YZUKHG3S.js → chunk-PCOTSRS4.js} +3 -3
  21. package/dist/{chunk-MOLPYPVH.js → chunk-SPKRI7MF.js} +6 -6
  22. package/dist/{chunk-THTEUDBC.js → chunk-TVURAFJ5.js} +13 -13
  23. package/dist/{chunk-Y7PVJUXJ.js → chunk-VFPLICBX.js} +6 -6
  24. package/dist/{chunk-BQMFIXHI.js → chunk-XBGSR22I.js} +5 -5
  25. package/dist/{chunk-OFXBNFNL.js → chunk-YY5DEAZI.js} +2 -2
  26. package/dist/{chunk-PNRPKRJU.js → chunk-ZNVAHQRY.js} +6 -6
  27. package/dist/{chunk-YRSZPVMB.js → chunk-ZQJU5CTZ.js} +1 -1
  28. package/dist/{detect-676SNZK4.js → detect-N4HFQZ6Y.js} +4 -4
  29. package/dist/{docker-GOT3Q7DJ.js → docker-DU7JA2AK.js} +8 -8
  30. package/dist/{docker-edge-executor-VO6JHHW2.js → docker-edge-executor-MPIPQHNF.js} +7 -7
  31. package/dist/{edge-import-NFCHIW7G.js → edge-import-YDPEIQDU.js} +22 -22
  32. package/dist/{edge-preflight-QUJ757C6.js → edge-preflight-TT2777R5.js} +13 -13
  33. package/dist/{ensure-container-edge-Q7IZXHGM.js → ensure-container-edge-T5WRCJSE.js} +11 -11
  34. package/dist/{executor-GKXKN52K.js → executor-ZWF2J7GS.js} +6 -6
  35. package/dist/{host-channel-preflight-Z6HYSPKO.js → host-channel-preflight-Z4QG7Q44.js} +22 -22
  36. package/dist/index.js +343 -89
  37. package/dist/{local-executor-OMMDKXCM.js → local-executor-W3O5HDLM.js} +3 -3
  38. package/dist/{nginx-VITTWZZU.js → nginx-XLDZIG4E.js} +9 -9
  39. package/dist/node-bootstrap.js +72 -37
  40. package/dist/{openresty-lua-6I3Z6PEQ.js → openresty-lua-ZNE6IBYU.js} +7 -7
  41. package/dist/{privilege-UQAI2HV4.js → privilege-IMARWVU2.js} +5 -5
  42. package/dist/server/index.js +58812 -772
  43. package/dist/{setup-JWKZIECM.js → setup-I3MTOIPW.js} +12 -12
  44. package/dist/{ssh-client-NWQVRCV7.js → ssh-client-LOCZTEUC.js} +2 -2
  45. package/dist/{up-P5DMQ5YO.js → up-IADNO7AY.js} +25 -25
  46. package/package.json +1 -1
  47. package/dist/bare-HL2GUYE2.js +0 -27
  48. package/dist/chunk-PVOWHIND.js +0 -26781
@@ -4,9 +4,9 @@ import { createRequire as __ospCreateRequire } from "node:module";
4
4
  const require = __ospCreateRequire(import.meta.url);
5
5
  import {
6
6
  LocalExecutor
7
- } from "./chunk-XVKUFMIB.js";
8
- import "./chunk-MNV2QFHW.js";
9
- import "./chunk-PVOWHIND.js";
7
+ } from "./chunk-HFOE2IXZ.js";
8
+ import "./chunk-BN23UUSF.js";
9
+ import "./chunk-ND23EK7Y.js";
10
10
  import "./chunk-PXKCZB2I.js";
11
11
  export {
12
12
  LocalExecutor
@@ -14,18 +14,18 @@ import {
14
14
  renderProxyOptions,
15
15
  renderProxyTlsOptions,
16
16
  summarizeCertbotFailure
17
- } from "./chunk-Y7PVJUXJ.js";
17
+ } from "./chunk-VFPLICBX.js";
18
18
  import "./chunk-I3DPMTSF.js";
19
- import "./chunk-YZUKHG3S.js";
19
+ import "./chunk-PCOTSRS4.js";
20
20
  import "./chunk-ZVFS4LUA.js";
21
- import "./chunk-BQMFIXHI.js";
22
- import "./chunk-WYNM7L22.js";
23
- import "./chunk-N4OALTFK.js";
24
- import "./chunk-YRSZPVMB.js";
25
- import "./chunk-OFXBNFNL.js";
21
+ import "./chunk-XBGSR22I.js";
22
+ import "./chunk-2Y62WP2D.js";
23
+ import "./chunk-3RCXJZJD.js";
24
+ import "./chunk-ZQJU5CTZ.js";
25
+ import "./chunk-YY5DEAZI.js";
26
26
  import "./chunk-3CJLKL6E.js";
27
- import "./chunk-MNV2QFHW.js";
28
- import "./chunk-PVOWHIND.js";
27
+ import "./chunk-BN23UUSF.js";
28
+ import "./chunk-ND23EK7Y.js";
29
29
  import "./chunk-PXKCZB2I.js";
30
30
  export {
31
31
  MANAGED_STATIC_BASE,
@@ -1,26 +1,26 @@
1
1
  // src/node-bootstrap.ts
2
- import { spawnSync as spawnSync2 } from "child_process";
3
- import { existsSync as existsSync2 } from "fs";
4
- import { join as join4 } from "path";
2
+ import { spawnSync as spawnSync3 } from "child_process";
3
+ import { existsSync as existsSync3 } from "fs";
4
+ import { join as join5 } from "path";
5
5
  import { createInterface } from "readline";
6
6
 
7
7
  // src/lib/node-runtime.ts
8
- import { execFileSync, spawnSync } from "child_process";
8
+ import { execFileSync, spawnSync as spawnSync2 } from "child_process";
9
9
  import {
10
10
  chmodSync,
11
- existsSync,
11
+ existsSync as existsSync2,
12
12
  lstatSync,
13
- mkdirSync as mkdirSync2,
14
- rmSync,
13
+ mkdirSync as mkdirSync3,
14
+ rmSync as rmSync2,
15
15
  symlinkSync,
16
- writeFileSync
16
+ writeFileSync as writeFileSync2
17
17
  } from "fs";
18
- import { join as join3 } from "path";
18
+ import { join as join4 } from "path";
19
19
 
20
20
  // src/lib/cache.ts
21
21
  import { createHash } from "crypto";
22
- import { createReadStream, createWriteStream, mkdirSync } from "fs";
23
- import { dirname, join as join2 } from "path";
22
+ import { createReadStream, createWriteStream, mkdirSync as mkdirSync2 } from "fs";
23
+ import { dirname, join as join3 } from "path";
24
24
 
25
25
  // src/lib/paths.ts
26
26
  import { homedir } from "os";
@@ -33,13 +33,48 @@ var LOG_DIR = join(OS_DIR, "logs");
33
33
  var AUTH_SECRET_FILE = join(OS_DIR, "auth-secret");
34
34
  var INTERNAL_TOKEN_FILE = join(OS_DIR, "internal-token");
35
35
 
36
+ // src/lib/github-auth.ts
37
+ import {
38
+ mkdirSync,
39
+ readFileSync,
40
+ rmSync,
41
+ writeFileSync
42
+ } from "fs";
43
+ import { homedir as homedir2 } from "os";
44
+ import { join as join2 } from "path";
45
+ import { spawnSync } from "child_process";
46
+ var GITHUB_TOKEN_FILENAME = ".github-token";
47
+ function githubTokenFile(dir = OS_DIR) {
48
+ return join2(dir, GITHUB_TOKEN_FILENAME);
49
+ }
50
+ function envGithubToken() {
51
+ return process.env.GITHUB_TOKEN?.trim() || process.env.GH_TOKEN?.trim() || void 0;
52
+ }
53
+ function readStoredGithubToken(dir = OS_DIR) {
54
+ try {
55
+ const raw = readFileSync(githubTokenFile(dir), "utf8").trim();
56
+ return raw || null;
57
+ } catch {
58
+ return null;
59
+ }
60
+ }
61
+ function githubToken(dir = OS_DIR) {
62
+ return envGithubToken() ?? readStoredGithubToken(dir) ?? void 0;
63
+ }
64
+ function githubAuthHeaders(dir) {
65
+ const token = dir === void 0 ? githubToken() : githubToken(dir);
66
+ return token ? { Authorization: `Bearer ${token}` } : {};
67
+ }
68
+
36
69
  // src/lib/cache.ts
37
- var CACHE_DIR = join2(OS_DIR, "cache");
38
- var RELEASES_DIR = join2(CACHE_DIR, "releases");
70
+ var CACHE_DIR = join3(OS_DIR, "cache");
71
+ var RELEASES_DIR = join3(CACHE_DIR, "releases");
39
72
  async function downloadToFile(url, dest, onProgress) {
40
- const res = await fetch(url, { headers: { "User-Agent": "kraft-cli" } });
73
+ const res = await fetch(url, {
74
+ headers: { "User-Agent": "kraft-cli", ...githubAuthHeaders() }
75
+ });
41
76
  if (!res.ok || !res.body) throw new Error(`HTTP ${res.status} for ${url}`);
42
- mkdirSync(dirname(dest), { recursive: true });
77
+ mkdirSync2(dirname(dest), { recursive: true });
43
78
  const total = Number(res.headers.get("content-length")) || 0;
44
79
  const hash = createHash("sha256");
45
80
  const file = createWriteStream(dest);
@@ -69,10 +104,10 @@ async function downloadToFile(url, dest, onProgress) {
69
104
  // src/lib/node-runtime.ts
70
105
  var NODE_MAJOR = 22;
71
106
  var NODE_DIST = "https://nodejs.org/dist";
72
- var RUNTIME_DIR = join3(OS_DIR, "runtime");
73
- var RUNTIME_CURRENT = join3(RUNTIME_DIR, "current");
74
- var BIN_DIR = join3(OS_DIR, "bin");
75
- var LAUNCHER_PATH = join3(BIN_DIR, "kraft");
107
+ var RUNTIME_DIR = join4(OS_DIR, "runtime");
108
+ var RUNTIME_CURRENT = join4(RUNTIME_DIR, "current");
109
+ var BIN_DIR = join4(OS_DIR, "bin");
110
+ var LAUNCHER_PATH = join4(BIN_DIR, "kraft");
76
111
  var LAUNCHER_SH = `#!/bin/sh
77
112
  # Kraft CLI launcher \u2014 runs the tarball-installed CLI under Node.
78
113
  # Managed by scripts/install.sh and \`kraft update\`; manual edits are overwritten.
@@ -125,7 +160,7 @@ function majorOf(bin) {
125
160
  }
126
161
  function repoint(link, target) {
127
162
  try {
128
- if (lstatSync(link)) rmSync(link, { recursive: true, force: true });
163
+ if (lstatSync(link)) rmSync2(link, { recursive: true, force: true });
129
164
  } catch {
130
165
  }
131
166
  symlinkSync(target, link);
@@ -149,8 +184,8 @@ async function fetchVendoredNode(onLog) {
149
184
  const os = nodeDistOs();
150
185
  const arch = nodeDistArch();
151
186
  const name = `node-${ver}-${os}-${arch}.tar.gz`;
152
- mkdirSync2(RUNTIME_DIR, { recursive: true });
153
- const tarball = join3(RUNTIME_DIR, name);
187
+ mkdirSync3(RUNTIME_DIR, { recursive: true });
188
+ const tarball = join4(RUNTIME_DIR, name);
154
189
  onLog?.(`Fetching Node ${ver} (${os}-${arch}) from nodejs.org\u2026`);
155
190
  const { sha256 } = await downloadToFile(
156
191
  `${NODE_DIST}/${ver}/${name}`,
@@ -161,32 +196,32 @@ async function fetchVendoredNode(onLog) {
161
196
  signal: AbortSignal.timeout(15e3)
162
197
  });
163
198
  if (!shaRes.ok) {
164
- rmSync(tarball, { force: true });
199
+ rmSync2(tarball, { force: true });
165
200
  throw new Error(`Node checksum list fetch failed: HTTP ${shaRes.status}`);
166
201
  }
167
202
  const expected = (await shaRes.text()).split("\n").map((l) => l.trim()).find((l) => l.endsWith(` ${name}`) || l.endsWith(` ${name}`))?.split(/\s+/)[0]?.toLowerCase();
168
203
  if (!expected) {
169
- rmSync(tarball, { force: true });
204
+ rmSync2(tarball, { force: true });
170
205
  throw new Error(`No checksum for ${name} in SHASUMS256.txt`);
171
206
  }
172
207
  if (expected !== sha256) {
173
- rmSync(tarball, { force: true });
208
+ rmSync2(tarball, { force: true });
174
209
  throw new Error(
175
210
  `Node download checksum mismatch (expected ${expected}, got ${sha256}).`
176
211
  );
177
212
  }
178
- const unpacked = join3(RUNTIME_DIR, `node-${ver}-${os}-${arch}`);
179
- rmSync(unpacked, { recursive: true, force: true });
180
- const untar = spawnSync("tar", ["-xzf", tarball, "-C", RUNTIME_DIR], {
213
+ const unpacked = join4(RUNTIME_DIR, `node-${ver}-${os}-${arch}`);
214
+ rmSync2(unpacked, { recursive: true, force: true });
215
+ const untar = spawnSync2("tar", ["-xzf", tarball, "-C", RUNTIME_DIR], {
181
216
  stdio: "inherit"
182
217
  });
183
218
  if (untar.status !== 0)
184
219
  throw new Error(
185
220
  "Failed to extract the Node runtime (is `tar` available?)."
186
221
  );
187
- rmSync(tarball, { force: true });
188
- const nodeBin = join3(unpacked, "bin", "node");
189
- if (!existsSync(nodeBin))
222
+ rmSync2(tarball, { force: true });
223
+ const nodeBin = join4(unpacked, "bin", "node");
224
+ if (!existsSync2(nodeBin))
190
225
  throw new Error(
191
226
  `Node unpacked but ${nodeBin} is missing (unexpected layout).`
192
227
  );
@@ -196,8 +231,8 @@ async function fetchVendoredNode(onLog) {
196
231
  async function ensureNodeRuntime(onLog) {
197
232
  if ((majorOf("node") ?? 0) >= NODE_MAJOR)
198
233
  return { node: "node", source: "system" };
199
- const existing = join3(RUNTIME_CURRENT, "bin", "node");
200
- if (existsSync(existing) && (majorOf(existing) ?? 0) >= NODE_MAJOR) {
234
+ const existing = join4(RUNTIME_CURRENT, "bin", "node");
235
+ if (existsSync2(existing) && (majorOf(existing) ?? 0) >= NODE_MAJOR) {
201
236
  return { node: existing, source: "vendored" };
202
237
  }
203
238
  return { node: await fetchVendoredNode(onLog), source: "vendored" };
@@ -206,9 +241,9 @@ async function ensureNodeRuntime(onLog) {
206
241
  // src/node-bootstrap.ts
207
242
  var NODE_REEXEC_ENV = "KRAFT_NODE_REEXEC";
208
243
  var VENDOR_ENV = "KRAFT_VENDOR_NODE";
209
- var vendoredNode = () => join4(OS_DIR, "runtime", "current", "bin", "node");
244
+ var vendoredNode = () => join5(OS_DIR, "runtime", "current", "bin", "node");
210
245
  function majorOf2(bin) {
211
- const out = spawnSync2(
246
+ const out = spawnSync3(
212
247
  bin,
213
248
  ["-e", "process.stdout.write(process.versions.node)"],
214
249
  {
@@ -219,7 +254,7 @@ function majorOf2(bin) {
219
254
  return Number.parseInt(out.stdout.trim().split(".")[0] ?? "", 10) || 0;
220
255
  }
221
256
  function reexec(nodeBin, cliPath) {
222
- const res = spawnSync2(nodeBin, [cliPath, ...process.argv.slice(2)], {
257
+ const res = spawnSync3(nodeBin, [cliPath, ...process.argv.slice(2)], {
223
258
  stdio: "inherit",
224
259
  env: { ...process.env, [NODE_REEXEC_ENV]: "1" }
225
260
  });
@@ -239,7 +274,7 @@ function ask(question) {
239
274
  }
240
275
  async function recoverOldNode(opts) {
241
276
  const existing = vendoredNode();
242
- if (existsSync2(existing) && majorOf2(existing) >= NODE_MAJOR) {
277
+ if (existsSync3(existing) && majorOf2(existing) >= NODE_MAJOR) {
243
278
  return reexec(existing, opts.cliPath);
244
279
  }
245
280
  if (!opts.offerDownload) return { handled: false };
@@ -40,14 +40,14 @@ import {
40
40
  ensureOpenRestyConfig,
41
41
  luaSourceAvailable,
42
42
  parseNginxVersion
43
- } from "./chunk-BQMFIXHI.js";
44
- import "./chunk-WYNM7L22.js";
45
- import "./chunk-N4OALTFK.js";
46
- import "./chunk-YRSZPVMB.js";
47
- import "./chunk-OFXBNFNL.js";
43
+ } from "./chunk-XBGSR22I.js";
44
+ import "./chunk-2Y62WP2D.js";
45
+ import "./chunk-3RCXJZJD.js";
46
+ import "./chunk-ZQJU5CTZ.js";
47
+ import "./chunk-YY5DEAZI.js";
48
48
  import "./chunk-3CJLKL6E.js";
49
- import "./chunk-MNV2QFHW.js";
50
- import "./chunk-PVOWHIND.js";
49
+ import "./chunk-BN23UUSF.js";
50
+ import "./chunk-ND23EK7Y.js";
51
51
  import "./chunk-PXKCZB2I.js";
52
52
  export {
53
53
  ACME_CHALLENGE_LOCATION,
@@ -6,12 +6,12 @@ import {
6
6
  privilegedExecutor,
7
7
  rootChecked,
8
8
  rootOrDegrade
9
- } from "./chunk-S3QBGGVP.js";
10
- import "./chunk-YRSZPVMB.js";
11
- import "./chunk-OFXBNFNL.js";
9
+ } from "./chunk-DI54Y66N.js";
10
+ import "./chunk-ZQJU5CTZ.js";
11
+ import "./chunk-YY5DEAZI.js";
12
12
  import "./chunk-3CJLKL6E.js";
13
- import "./chunk-MNV2QFHW.js";
14
- import "./chunk-PVOWHIND.js";
13
+ import "./chunk-BN23UUSF.js";
14
+ import "./chunk-ND23EK7Y.js";
15
15
  import "./chunk-PXKCZB2I.js";
16
16
  export {
17
17
  privilegedExecutor,