@ghostlytools/cli 1.5.1 → 1.5.3

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 (99) hide show
  1. package/README.md +16 -11
  2. package/dist/assets/{api-oUpBfryK.js → api-BIg0Msax.js} +2 -2
  3. package/dist/assets/{api-Dy_05gaq.js → api-d2aXkbM5.js} +343 -116
  4. package/dist/assets/api-d2aXkbM5.js.map +1 -0
  5. package/dist/assets/{apiKit-B-PUYkXH.js → apiKit-Ba_t7MZO.js} +18 -4
  6. package/dist/assets/apiKit-Ba_t7MZO.js.map +1 -0
  7. package/dist/assets/{apps-C6MBfO-I.js → apps-B_F3gEI4.js} +1 -1
  8. package/dist/assets/{apps-ejb6H1lT.js → apps-CJo1MmSY.js} +17 -16
  9. package/dist/assets/apps-CJo1MmSY.js.map +1 -0
  10. package/dist/assets/{arkade-DXyOeKEI.js → arkade-DTne0O3Q.js} +12 -5
  11. package/dist/assets/arkade-DTne0O3Q.js.map +1 -0
  12. package/dist/assets/{backup-DRIIguzE.js → backup-BY88aZr5.js} +11 -8
  13. package/dist/assets/backup-BY88aZr5.js.map +1 -0
  14. package/dist/assets/{backup-Bt6UjCiM.js → backup-CqpDAZZG.js} +1 -1
  15. package/dist/assets/{blobFiles-1wUBd8ZD.js → blobFiles-B1lX6iGy.js} +3 -3
  16. package/dist/assets/{blobFiles-1wUBd8ZD.js.map → blobFiles-B1lX6iGy.js.map} +1 -1
  17. package/dist/assets/{buttons-DoccJ_cK.js → buttons-B5EnA2nh.js} +23 -6
  18. package/dist/assets/buttons-B5EnA2nh.js.map +1 -0
  19. package/dist/assets/buttons-azvbN6xn.js +2 -0
  20. package/dist/assets/{daemonProof-CWTVNUmr.js → daemonProof-Dx3N_DLC.js} +19 -37
  21. package/dist/assets/daemonProof-Dx3N_DLC.js.map +1 -0
  22. package/dist/assets/{endpoint-Cl3cgAYl.js → endpoint-BdaeBw2L.js} +3 -3
  23. package/dist/assets/endpoint-BdaeBw2L.js.map +1 -0
  24. package/dist/assets/{envelope-hJ0SfbAh.js → envelope-BU-BB1wR.js} +2 -2
  25. package/dist/assets/{envelope-hJ0SfbAh.js.map → envelope-BU-BB1wR.js.map} +1 -1
  26. package/dist/assets/{errors-BLSPp0tK.js → errors-DI6Z3jTH.js} +26 -1
  27. package/dist/assets/errors-DI6Z3jTH.js.map +1 -0
  28. package/dist/assets/{fileBytes-gTd_8l-P.js → fileBytes-BMlLVdfg.js} +1 -1
  29. package/dist/assets/{fileBytes-uRqLyxa0.js → fileBytes-D0CYuRwZ.js} +2 -2
  30. package/dist/assets/{fileBytes-uRqLyxa0.js.map → fileBytes-D0CYuRwZ.js.map} +1 -1
  31. package/dist/assets/{fileBytes-B8eTZfAT.js → fileBytes-D85lBh-Q.js} +3 -3
  32. package/dist/assets/{fileBytes-B8eTZfAT.js.map → fileBytes-D85lBh-Q.js.map} +1 -1
  33. package/dist/assets/fileBytesIdb-Dn9levD1.js +2 -0
  34. package/dist/assets/{fileBytesIdb-BIFKtgln.js → fileBytesIdb-LAhH7kY2.js} +7 -7
  35. package/dist/assets/fileBytesIdb-LAhH7kY2.js.map +1 -0
  36. package/dist/assets/{fileBytesOpfs-ChrHcCVV.js → fileBytesOpfs-DjBBghvq.js} +3 -3
  37. package/dist/assets/{fileBytesOpfs-ChrHcCVV.js.map → fileBytesOpfs-DjBBghvq.js.map} +1 -1
  38. package/dist/assets/{ghostly_iroh_web-BsAEFIjl.js → ghostly_iroh_web-BXCsSxxo.js} +29 -29
  39. package/dist/assets/{ghostly_iroh_web-BsAEFIjl.js.map → ghostly_iroh_web-BXCsSxxo.js.map} +1 -1
  40. package/dist/assets/ghostly_iroh_web_bg.wasm +0 -0
  41. package/dist/assets/{groupFiles-BXPINkVJ.js → groupFiles-D9k6fyhf.js} +61 -17
  42. package/dist/assets/groupFiles-D9k6fyhf.js.map +1 -0
  43. package/dist/assets/{host-CzgYwupN.js → host-DrL7FPG4.js} +157 -49
  44. package/dist/assets/host-DrL7FPG4.js.map +1 -0
  45. package/dist/assets/{hyperdhtRelay-CJBqsS_e.js → hyperdhtRelay-C-BsT6_V.js} +2 -2
  46. package/dist/assets/{hyperdhtRelay-CJBqsS_e.js.map → hyperdhtRelay-C-BsT6_V.js.map} +1 -1
  47. package/dist/assets/{idb-BJARz3Qi.js → idb-CWvq4HKc.js} +25 -3
  48. package/dist/assets/{idb-BJARz3Qi.js.map → idb-CWvq4HKc.js.map} +1 -1
  49. package/dist/assets/{irohWeb-CrGOD-OD.js → irohWeb-DdHXEwgj.js} +3 -3
  50. package/dist/assets/{irohWeb-CrGOD-OD.js.map → irohWeb-DdHXEwgj.js.map} +1 -1
  51. package/dist/assets/{main-BDOIJ_ls.js → main-xeoX7yLM.js} +160 -50
  52. package/dist/assets/main-xeoX7yLM.js.map +1 -0
  53. package/dist/assets/{mainline-Cw7rnEWM.js → mainline-CEqGvRYJ.js} +46 -16
  54. package/dist/assets/mainline-CEqGvRYJ.js.map +1 -0
  55. package/dist/assets/{networkReason-C0VY94cG.js → networkReason-RGRU5xoa.js} +3 -3
  56. package/dist/assets/{networkReason-C0VY94cG.js.map → networkReason-RGRU5xoa.js.map} +1 -1
  57. package/dist/assets/{nwc-lpGWvzYU.js → nwc-s5xHLqNf.js} +3 -3
  58. package/dist/assets/{nwc-lpGWvzYU.js.map → nwc-s5xHLqNf.js.map} +1 -1
  59. package/dist/assets/{nwcProvider-CAGRn2ly.js → nwcProvider-CfAFO5Fr.js} +2 -2
  60. package/dist/assets/{nwcProvider-CAGRn2ly.js.map → nwcProvider-CfAFO5Fr.js.map} +1 -1
  61. package/dist/assets/{profiles-BehWURA9.js → profiles-gZdQPyaz.js} +74 -13
  62. package/dist/assets/profiles-gZdQPyaz.js.map +1 -0
  63. package/dist/assets/{registry-D2bK-k1T.js → registry-BUhSjM-J.js} +1 -1
  64. package/dist/assets/{registry-DWkkBN57.js → registry-CVUdD4bJ.js} +3 -3
  65. package/dist/assets/{registry-DWkkBN57.js.map → registry-CVUdD4bJ.js.map} +1 -1
  66. package/dist/assets/{resolve-CvYK0Lbt.js → resolve-uZECJ3f7.js} +2 -2
  67. package/dist/assets/{resolve-CvYK0Lbt.js.map → resolve-uZECJ3f7.js.map} +1 -1
  68. package/dist/assets/{restoredRows-DGuKtIBz.js → restoredRows-D6WZUA2U.js} +2 -2
  69. package/dist/assets/{restoredRows-DGuKtIBz.js.map → restoredRows-D6WZUA2U.js.map} +1 -1
  70. package/dist/assets/{server-BktMmp7L.js → server-DOtUKoYR.js} +797 -251
  71. package/dist/assets/server-DOtUKoYR.js.map +1 -0
  72. package/dist/assets/{src-Bpy99Z2K.js → src-Dd_7Ew1X.js} +512 -141
  73. package/dist/assets/src-Dd_7Ew1X.js.map +1 -0
  74. package/dist/assets/{usdt-DFusiw8x.js → usdt-C2Anx8p7.js} +3 -3
  75. package/dist/assets/{usdt-DFusiw8x.js.map → usdt-C2Anx8p7.js.map} +1 -1
  76. package/dist/assets/{words-Z-izzDBN.js → words-DoLU6p8H.js} +4 -4
  77. package/dist/assets/words-DoLU6p8H.js.map +1 -0
  78. package/dist/ghostly.mjs +1 -1
  79. package/package.json +1 -1
  80. package/dist/assets/api-Dy_05gaq.js.map +0 -1
  81. package/dist/assets/apiKit-B-PUYkXH.js.map +0 -1
  82. package/dist/assets/apps-ejb6H1lT.js.map +0 -1
  83. package/dist/assets/arkade-DXyOeKEI.js.map +0 -1
  84. package/dist/assets/backup-DRIIguzE.js.map +0 -1
  85. package/dist/assets/buttons-B3bi6p_d.js +0 -2
  86. package/dist/assets/buttons-DoccJ_cK.js.map +0 -1
  87. package/dist/assets/daemonProof-CWTVNUmr.js.map +0 -1
  88. package/dist/assets/endpoint-Cl3cgAYl.js.map +0 -1
  89. package/dist/assets/errors-BLSPp0tK.js.map +0 -1
  90. package/dist/assets/fileBytesIdb-BIFKtgln.js.map +0 -1
  91. package/dist/assets/fileBytesIdb-BVVr_rWX.js +0 -2
  92. package/dist/assets/groupFiles-BXPINkVJ.js.map +0 -1
  93. package/dist/assets/host-CzgYwupN.js.map +0 -1
  94. package/dist/assets/main-BDOIJ_ls.js.map +0 -1
  95. package/dist/assets/mainline-Cw7rnEWM.js.map +0 -1
  96. package/dist/assets/profiles-BehWURA9.js.map +0 -1
  97. package/dist/assets/server-BktMmp7L.js.map +0 -1
  98. package/dist/assets/src-Bpy99Z2K.js.map +0 -1
  99. package/dist/assets/words-Z-izzDBN.js.map +0 -1
@@ -1,8 +1,65 @@
1
- import { t as CliError } from "./errors-BLSPp0tK.js";
2
- import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
3
- import { join, resolve } from "node:path";
1
+ import { t as CliError } from "./errors-DI6Z3jTH.js";
2
+ import { chmodSync, closeSync, existsSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
3
+ import { isAbsolute, join, resolve } from "node:path";
4
4
  import { createHash } from "node:crypto";
5
- import { homedir } from "node:os";
5
+ import { homedir, tmpdir } from "node:os";
6
+ //#region src/privateFolder.ts
7
+ /**
8
+ * Where a socket goes when its path in the profile is longer than a Unix socket may be: `<base>/<prefix>-<hash of the
9
+ * profile>/<leaf>`, in `$XDG_RUNTIME_DIR` or else the temp folder (macOS gives each user one) when that folder is the
10
+ * user's alone, so no other user can make the folder first. When neither is, or the path would still be too long:
11
+ * `/tmp/<prefix>-<uid>-<hash>/<leaf>`. Either way `privateFolder` checks the folder before use.
12
+ */
13
+ function runtimePath(prefix, profileDir, leaf) {
14
+ const hash = createHash("sha256").update(profileDir).digest("hex").slice(0, 24);
15
+ for (const base of [process.env.XDG_RUNTIME_DIR, tmpdir()]) {
16
+ if (!base || !isAbsolute(base) || !usersAlone(base)) continue;
17
+ const path = join(base, `${prefix}-${hash}`, leaf);
18
+ if (Buffer.byteLength(path) <= 100) return path;
19
+ }
20
+ return join("/tmp", `${prefix}-${process.getuid?.() ?? 0}-${hash}`, leaf);
21
+ }
22
+ function usersAlone(path) {
23
+ try {
24
+ const info = statSync(path);
25
+ return info.isDirectory() && (!process.getuid || info.uid === process.getuid()) && (info.mode & 63) === 0;
26
+ } catch {
27
+ return false;
28
+ }
29
+ }
30
+ /**
31
+ * A folder for a socket outside the profile (when the profile's path is too long for one): made owner-only, and
32
+ * refused when it is a link, someone else made it, or anyone else may enter it.
33
+ */
34
+ function privateFolder(path, what) {
35
+ mkdirSync(path, {
36
+ recursive: true,
37
+ mode: 448
38
+ });
39
+ const info = lstatSync(path);
40
+ if (!info.isDirectory() || process.getuid && info.uid !== process.getuid() || (info.mode & 63) !== 0) throw new Error(`${path} is not a folder of this user's alone: ${what}`);
41
+ }
42
+ /**
43
+ * The profile's own folder, made owner-only again before the daemon's socket goes in it: a folder made by an older
44
+ * release, or opened up by hand, is closed rather than trusted. Refused when it is a link or someone else's.
45
+ */
46
+ function ownFolder(path, what) {
47
+ const info = lstatSync(path);
48
+ if (!info.isDirectory() || process.getuid && info.uid !== process.getuid()) throw new Error(`${path} is not a folder of this user's: ${what}`);
49
+ if ((info.mode & 63) !== 0) chmodSync(path, 448);
50
+ }
51
+ /** False when `path` is there but is not a socket of this user's: nothing to connect to. */
52
+ function ownSocket(path) {
53
+ if (process.platform === "win32") return true;
54
+ let info;
55
+ try {
56
+ info = lstatSync(path);
57
+ } catch {
58
+ return true;
59
+ }
60
+ return info.isSocket() && (!process.getuid || info.uid === process.getuid());
61
+ }
62
+ //#endregion
6
63
  //#region src/profiles.ts
7
64
  /**
8
65
  * Profiles on disk (WISP 1100 § Profiles and files): `<home>/profiles/<name>/`, 0700, one engine store each.
@@ -16,16 +73,19 @@ var NAME = /^[a-z0-9][a-z0-9._-]{0,63}$/i;
16
73
  */
17
74
  function ghostlyHome(option) {
18
75
  if (option === "") throw new CliError("usage", "--home needs a folder");
19
- return userPath(option ?? (process.env.GHOSTLY_HOME || join(homedir(), ".ghostly")));
76
+ return userPath(option ?? (process.env.GHOSTLY_HOME || join(homedir(), ".ghostly")), true);
20
77
  }
21
78
  /**
22
79
  * A path the CLI was given, made absolute. A `~` the shell left alone (`--home=~/bots`, a quoted variable, a unit
23
80
  * file's `Environment=` line) is the user's home, as the shell reads it: it was a folder named `~` in the current one.
24
- * `~user/…` is a usage error, not a guess at another user's home.
81
+ * `~user/…` is a usage error, not a guess at another user's home, unless it is there under this folder. Any other name
82
+ * that starts with `~` is a file here, as the shell and every other tool read it (`~notes.txt`, Office's
83
+ * `~$report.docx`, a new `~cursor`): all of them were refused (agents#1604). `home`: the profiles' folder, where a bare
84
+ * `~bob` that is not there is refused too, as a new profile would be made in a folder of that name.
25
85
  */
26
- function userPath(path) {
86
+ function userPath(path, home = false) {
27
87
  if (path === "~" || path.startsWith("~/")) return join(homedir(), path.slice(1));
28
- if (path.startsWith("~")) throw new CliError("usage", `${path}: ~user is not read here: write the folder in full`);
88
+ if (path.startsWith("~") && (home || path.includes("/")) && !existsSync(resolve(path))) throw new CliError("usage", `${path}: ~user is not read here: write the ${home || path.endsWith("/") ? "folder" : "path"} in full`);
29
89
  return resolve(path);
30
90
  }
31
91
  function checkProfileName(name) {
@@ -75,14 +135,15 @@ function lockPath(dir) {
75
135
  }
76
136
  /**
77
137
  * The daemon's socket: in the profile's folder, unless that path is longer than a Unix socket may be (104 bytes on
78
- * macOS); then in a folder of /tmp named after the profile's, which the daemon makes owner-only and checks before
79
- * use (`privateFolder`), and whose socket a client connects to only when it is this user's (`ownSocket`).
138
+ * macOS); then in a folder of the user's runtime folder named after the profile's (`runtimePath`), which the daemon
139
+ * makes owner-only and checks before use (`privateFolder`), and whose socket a client connects to only when it is this
140
+ * user's (`ownSocket`).
80
141
  */
81
142
  function socketPath(dir) {
82
143
  const inside = join(dir, "daemon.sock");
83
144
  if (process.platform === "win32") return `\\\\.\\pipe\\ghostly-${createHash("sha256").update(dir).digest("hex").slice(0, 24)}`;
84
145
  if (Buffer.byteLength(inside) <= 100) return inside;
85
- return join("/tmp", `ghostly-${createHash("sha256").update(dir).digest("hex").slice(0, 24)}`, "daemon.sock");
146
+ return runtimePath("ghostly", dir, "daemon.sock");
86
147
  }
87
148
  function ensureFolder(path) {
88
149
  mkdirSync(path, {
@@ -158,6 +219,6 @@ function lockOwner(paths) {
158
219
  }
159
220
  }
160
221
  //#endregion
161
- export { checkShownName as a, ghostlyHome as c, lockPath as d, profileExists as f, userPath as h, checkProfileName as i, listProfiles as l, selectProfile as m, RESTORED_MARK as n, createProfile as o, profilePaths as p, acquireLock as r, currentProfile as s, DEFAULT_PROFILE as t, lockOwner as u };
222
+ export { ownSocket as _, checkShownName as a, ghostlyHome as c, lockPath as d, profileExists as f, ownFolder as g, userPath as h, checkProfileName as i, listProfiles as l, selectProfile as m, RESTORED_MARK as n, createProfile as o, profilePaths as p, acquireLock as r, currentProfile as s, DEFAULT_PROFILE as t, lockOwner as u, privateFolder as v, runtimePath as y };
162
223
 
163
- //# sourceMappingURL=profiles-BehWURA9.js.map
224
+ //# sourceMappingURL=profiles-gZdQPyaz.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profiles-gZdQPyaz.js","names":[],"sources":["../../src/privateFolder.ts","../../src/profiles.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { chmodSync, lstatSync, mkdirSync, statSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { isAbsolute, join } from \"node:path\";\n\n/**\n * Where a socket goes when its path in the profile is longer than a Unix socket may be: `<base>/<prefix>-<hash of the\n * profile>/<leaf>`, in `$XDG_RUNTIME_DIR` or else the temp folder (macOS gives each user one) when that folder is the\n * user's alone, so no other user can make the folder first. When neither is, or the path would still be too long:\n * `/tmp/<prefix>-<uid>-<hash>/<leaf>`. Either way `privateFolder` checks the folder before use.\n */\nexport function runtimePath(prefix: string, profileDir: string, leaf: string): string {\n const hash = createHash(\"sha256\").update(profileDir).digest(\"hex\").slice(0, 24);\n for (const base of [process.env.XDG_RUNTIME_DIR, tmpdir()]) {\n if (!base || !isAbsolute(base) || !usersAlone(base)) continue;\n const path = join(base, `${prefix}-${hash}`, leaf);\n if (Buffer.byteLength(path) <= 100) return path;\n }\n return join(\"/tmp\", `${prefix}-${process.getuid?.() ?? 0}-${hash}`, leaf);\n}\n\nfunction usersAlone(path: string): boolean {\n try {\n const info = statSync(path);\n return info.isDirectory() && (!process.getuid || info.uid === process.getuid()) && (info.mode & 0o077) === 0;\n } catch {\n return false;\n }\n}\n\n/**\n * A folder for a socket outside the profile (when the profile's path is too long for one): made owner-only, and\n * refused when it is a link, someone else made it, or anyone else may enter it.\n */\nexport function privateFolder(path: string, what: string): void {\n mkdirSync(path, { recursive: true, mode: 0o700 });\n const info = lstatSync(path);\n if (!info.isDirectory() || (process.getuid && info.uid !== process.getuid()) || (info.mode & 0o077) !== 0) {\n throw new Error(`${path} is not a folder of this user's alone: ${what}`);\n }\n}\n\n/**\n * The profile's own folder, made owner-only again before the daemon's socket goes in it: a folder made by an older\n * release, or opened up by hand, is closed rather than trusted. Refused when it is a link or someone else's.\n */\nexport function ownFolder(path: string, what: string): void {\n const info = lstatSync(path);\n if (!info.isDirectory() || (process.getuid && info.uid !== process.getuid())) throw new Error(`${path} is not a folder of this user's: ${what}`);\n if ((info.mode & 0o077) !== 0) chmodSync(path, 0o700);\n}\n\n/** False when `path` is there but is not a socket of this user's: nothing to connect to. */\nexport function ownSocket(path: string): boolean {\n if (process.platform === \"win32\") return true;\n let info;\n try { info = lstatSync(path); } catch { return true; }\n return info.isSocket() && (!process.getuid || info.uid === process.getuid());\n}\n","import { closeSync, existsSync, mkdirSync, openSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync, writeSync } from \"node:fs\";\nimport { createHash } from \"node:crypto\";\nimport { homedir } from \"node:os\";\nimport { join, resolve } from \"node:path\";\nimport { CliError } from \"./errors\";\nimport { runtimePath } from \"./privateFolder\";\n\n/**\n * Profiles on disk (WISP 1100 § Profiles and files): `<home>/profiles/<name>/`, 0700, one engine store each.\n * `<home>/current` names the profile commands use when none is given.\n */\nexport const DEFAULT_PROFILE = \"default\";\nconst NAME = /^[a-z0-9][a-z0-9._-]{0,63}$/i;\n\n/**\n * An empty `--home` or `--profile` (an unset variable in a script) is a usage error: taken as not given, it ran the\n * command in the current folder, or as the current profile. An empty variable of the environment counts as unset.\n */\nexport function ghostlyHome(option?: string): string {\n if (option === \"\") throw new CliError(\"usage\", \"--home needs a folder\");\n return userPath(option ?? (process.env.GHOSTLY_HOME || join(homedir(), \".ghostly\")), true);\n}\n\n/**\n * A path the CLI was given, made absolute. A `~` the shell left alone (`--home=~/bots`, a quoted variable, a unit\n * file's `Environment=` line) is the user's home, as the shell reads it: it was a folder named `~` in the current one.\n * `~user/…` is a usage error, not a guess at another user's home, unless it is there under this folder. Any other name\n * that starts with `~` is a file here, as the shell and every other tool read it (`~notes.txt`, Office's\n * `~$report.docx`, a new `~cursor`): all of them were refused (agents#1604). `home`: the profiles' folder, where a bare\n * `~bob` that is not there is refused too, as a new profile would be made in a folder of that name.\n */\nexport function userPath(path: string, home = false): string {\n if (path === \"~\" || path.startsWith(\"~/\")) return join(homedir(), path.slice(1));\n if (path.startsWith(\"~\") && (home || path.includes(\"/\")) && !existsSync(resolve(path))) {\n throw new CliError(\"usage\", `${path}: ~user is not read here: write the ${home || path.endsWith(\"/\") ? \"folder\" : \"path\"} in full`);\n }\n return resolve(path);\n}\n\nexport function checkProfileName(name: string): string {\n if (!NAME.test(name) || name.includes(\"..\")) throw new CliError(\"usage\", `Not a profile name: ${JSON.stringify(name)} (letters, digits, \".\", \"_\" and \"-\", up to 64)`);\n return name;\n}\n\n/**\n * The name a profile shows its contacts, whichever command sets it (`--name`, `profile.set`, `settings set nick`):\n * trimmed, up to 64 characters on one line, as a group's name; empty is no name. `settings set nick` took any length\n * and every one took a line break, printed whole by `status`. `field` names it in the refusal.\n */\nexport function checkShownName(name: unknown, field = \"name\"): string {\n const shown = typeof name === \"string\" ? name.trim() : undefined;\n // Core's MAX_NICK_LENGTH: this file loads before any command, without the engine.\n if (shown === undefined || [...shown].length > 64 || /\\p{Cc}/u.test(shown)) {\n throw new CliError(\"bad_request\", `${field} must be up to 64 characters on one line`);\n }\n return shown;\n}\n\nexport function currentProfile(home: string, option?: string): string {\n if (option === \"\") throw new CliError(\"usage\", \"--profile needs a profile name\");\n if (option !== undefined) return checkProfileName(option);\n if (process.env.GHOSTLY_PROFILE) return checkProfileName(process.env.GHOSTLY_PROFILE);\n const file = join(home, \"current\");\n if (existsSync(file)) {\n const name = readFileSync(file, \"utf8\").trim();\n if (name) return checkProfileName(name);\n }\n return DEFAULT_PROFILE;\n}\n\nexport function profileDir(home: string, name: string): string {\n return join(home, \"profiles\", checkProfileName(name));\n}\n\nexport interface ProfilePaths { name: string; dir: string; db: string; socket: string; lock: string; events: string; files: string; log: string }\nexport function profilePaths(home: string, name: string): ProfilePaths {\n const dir = profileDir(home, name);\n return {\n name, dir, db: join(dir, \"db\"), socket: socketPath(dir), lock: lockPath(dir),\n events: join(dir, \"events.jsonl\"), files: join(dir, \"files\"), log: join(dir, \"daemon.log\"),\n };\n}\n\n/** The file that says which process holds the profile (`acquireLock`). */\nexport function lockPath(dir: string): string {\n return join(dir, \"daemon.lock\");\n}\n\n/**\n * The daemon's socket: in the profile's folder, unless that path is longer than a Unix socket may be (104 bytes on\n * macOS); then in a folder of the user's runtime folder named after the profile's (`runtimePath`), which the daemon\n * makes owner-only and checks before use (`privateFolder`), and whose socket a client connects to only when it is this\n * user's (`ownSocket`).\n */\nfunction socketPath(dir: string): string {\n const inside = join(dir, \"daemon.sock\");\n if (process.platform === \"win32\") return `\\\\\\\\.\\\\pipe\\\\ghostly-${createHash(\"sha256\").update(dir).digest(\"hex\").slice(0, 24)}`;\n if (Buffer.byteLength(inside) <= 100) return inside;\n return runtimePath(\"ghostly\", dir, \"daemon.sock\");\n}\n\nfunction ensureFolder(path: string): void {\n mkdirSync(path, { recursive: true, mode: 0o700 });\n}\n\n/** Makes the profile's folder; refused when it exists and `existing` is not allowed. */\nexport function createProfile(home: string, name: string, { existing = false } = {}): ProfilePaths {\n const paths = profilePaths(home, name);\n if (existsSync(paths.dir) && !existing) throw new CliError(\"refused\", `Profile ${name} exists`);\n ensureFolder(join(home, \"profiles\"));\n ensureFolder(paths.dir);\n return paths;\n}\n\n/**\n * A file in the folder of a profile a restore made, until its engine starts for the first time: the store came back\n * whole, as the backup held it, and the money in it is then treated as every restore treats it (WISP 05 § Restoring).\n */\nexport const RESTORED_MARK = \"restored\";\n\nexport function profileExists(home: string, name: string): boolean {\n return existsSync(profileDir(home, name));\n}\n\nexport function listProfiles(home: string): string[] {\n const root = join(home, \"profiles\");\n if (!existsSync(root)) return [];\n return readdirSync(root).filter((name) => NAME.test(name) && statSync(join(root, name)).isDirectory()).sort();\n}\n\nexport function selectProfile(home: string, name: string): void {\n if (!profileExists(home, name)) throw new CliError(\"not_found\", `No profile ${name}`);\n ensureFolder(home);\n writeFileSync(join(home, \"current\"), name + \"\\n\", { mode: 0o600 });\n}\n\n/**\n * One process per profile: the daemon or a one-shot command. The lock holds the owner's pid; a lock whose\n * process is gone is taken over.\n */\nexport function acquireLock(paths: ProfilePaths): () => void {\n for (let attempt = 0; attempt < 2; attempt++) {\n try {\n const fd = openSync(paths.lock, \"wx\", 0o600);\n writeSync(fd, String(process.pid));\n closeSync(fd);\n let released = false;\n return () => {\n if (released) return;\n released = true;\n try { if (readFileSync(paths.lock, \"utf8\").trim() === String(process.pid)) rmSync(paths.lock, { force: true }); } catch { /* gone already */ }\n };\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n const owner = lockOwner(paths);\n if (owner !== null) throw new CliError(\"busy\", `Profile ${paths.name} is in use by process ${owner}`, { pid: owner });\n rmSync(paths.lock, { force: true });\n }\n }\n throw new CliError(\"busy\", `Profile ${paths.name} is in use`);\n}\n\n/** The pid holding the profile, or null when nobody (or a process that is gone) does. */\nexport function lockOwner(paths: ProfilePaths): number | null {\n let pid: number;\n try { pid = Number(readFileSync(paths.lock, \"utf8\").trim()); } catch { return null; }\n if (!Number.isInteger(pid) || pid <= 0) return null;\n try { process.kill(pid, 0); return pid; } catch (error) { return (error as NodeJS.ErrnoException).code === \"EPERM\" ? pid : null; }\n}\n"],"mappings":";;;;;;;;;;;;AAWA,SAAgB,YAAY,QAAgB,YAAoB,MAAsB;CACpF,MAAM,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,UAAU,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,EAAE;CAC9E,KAAK,MAAM,QAAQ,CAAC,QAAQ,IAAI,iBAAiB,OAAO,CAAC,GAAG;EAC1D,IAAI,CAAC,QAAQ,CAAC,WAAW,IAAI,KAAK,CAAC,WAAW,IAAI,GAAG;EACrD,MAAM,OAAO,KAAK,MAAM,GAAG,OAAO,GAAG,QAAQ,IAAI;EACjD,IAAI,OAAO,WAAW,IAAI,KAAK,KAAK,OAAO;CAC7C;CACA,OAAO,KAAK,QAAQ,GAAG,OAAO,GAAG,QAAQ,SAAS,KAAK,EAAE,GAAG,QAAQ,IAAI;AAC1E;AAEA,SAAS,WAAW,MAAuB;CACzC,IAAI;EACF,MAAM,OAAO,SAAS,IAAI;EAC1B,OAAO,KAAK,YAAY,MAAM,CAAC,QAAQ,UAAU,KAAK,QAAQ,QAAQ,OAAO,OAAO,KAAK,OAAO,QAAW;CAC7G,QAAQ;EACN,OAAO;CACT;AACF;;;;;AAMA,SAAgB,cAAc,MAAc,MAAoB;CAC9D,UAAU,MAAM;EAAE,WAAW;EAAM,MAAM;CAAM,CAAC;CAChD,MAAM,OAAO,UAAU,IAAI;CAC3B,IAAI,CAAC,KAAK,YAAY,KAAM,QAAQ,UAAU,KAAK,QAAQ,QAAQ,OAAO,MAAO,KAAK,OAAO,QAAW,GACtG,MAAM,IAAI,MAAM,GAAG,KAAK,yCAAyC,MAAM;AAE3E;;;;;AAMA,SAAgB,UAAU,MAAc,MAAoB;CAC1D,MAAM,OAAO,UAAU,IAAI;CAC3B,IAAI,CAAC,KAAK,YA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IAAI,WAAW;EACf,aAAa;GACX,IAAI,UAAU;GACd,WAAW;GACX,IAAI;IAAE,IAAI,aAAa,MAAM,MAAM,MAAM,CAAC,CAAC,KAAK,MAAM,OAAO,QAAQ,GAAG,GAAG,OAAO,MAAM,MAAM,EAAE,OAAO,KAAK,CAAC;GAAG,QAAQ,CAAqB;EAC/I;CACF,SAAS,OAAO;EACd,IAAK,MAAgC,SAAS,UAAU,MAAM;EAC9D,MAAM,QAAQ,UAAU,KAAK;EAC7B,IAAI,UAAU,MAAM,MAAM,IAAI,SAAS,QAAQ,WAAW,MAAM,KAAK,wBAAwB,SAAS,EAAE,KAAK,MAAM,CAAC;EACpH,OAAO,MAAM,MAAM,EAAE,OAAO,KAAK,CAAC;CACpC;CAEF,MAAM,IAAI,SAAS,QAAQ,WAAW,MAAM,KAAK,WAAW;AAC9D;;AAGA,SAAgB,UAAU,OAAoC;CAC5D,IAAI;CACJ,IAAI;EAAE,MAAM,OAAO,aAAa,MAAM,MAAM,MAAM,CAAC,CAAC,KAAK,CAAC;CAAG,QAAQ;EAAE,OAAO;CAAM;CACpF,IAAI,CAAC,OAAO,UAAU,GAAG,KAAK,OAAO,GAAG,OAAO;CAC/C,IAAI;EAAE,QAAQ,KAAK,KAAK,CAAC;EAAG,OAAO;CAAK,SAAS,OAAO;EAAE,OAAQ,MAAgC,SAAS,UAAU,MAAM;CAAM;AACnI"}
@@ -1,2 +1,2 @@
1
- import { n as identityProvider, r as identityProviders, t as IDENTITY_PROVIDERS } from "./registry-DWkkBN57.js";
1
+ import { n as identityProvider, r as identityProviders, t as IDENTITY_PROVIDERS } from "./registry-CVUdD4bJ.js";
2
2
  export { IDENTITY_PROVIDERS, identityProvider, identityProviders };
@@ -1,5 +1,5 @@
1
- import { $ as parseSshPublicKey, At as didWebDocumentUrl, Bt as staticDidDocument, Cn as pubkyHomeserverOf, Dt as didGhostlyServiceEntry, Et as checkDidSignature, Ft as normalizeDid, It as parseDid, Kt as resolveDidDht, Li as IdentityCheckUnavailable, Lt as parseDidDocument, Mt as didWebFileNames, Nt as didWebFileUrl, Ot as didJwsAlg, Pt as didWebHost, Q as SshSigError, Ql as openRelayPayload, Rt as parseDidSignaturePaste, Sn as homeserverWebEndpoint, St as DID_FILE_MAX_BYTES, Tt as checkDidJws, Vt as strictBase64Url, Yl as RELAY_PAYLOAD_MAX_BYTES, Z as SSHSIG_NAMESPACE, _n as newPubkyProofFolder, at as BitcoinAddressError, bi as domainWellKnownFile, bn as pubkyProofFile, bt as verifyAtprotoRecordProof, ct as ATPROTO_FULL_SCOPE, du as randomBytes, et as parseSshSignature, ft as atprotoProofRecord, fu as toBase64Url, gn as isPubkyProofFolder, gt as normalizeAtprotoHandle, hn as isPubkyKey, ht as isAtprotoDid, hu as utf8Encode, it as verifyBitcoinMessage, jt as didWebFile, ki as wellKnownUrl, kt as didSignedMessages, lt as ATPROTO_PROOF_COLLECTION, lu as fromBase64Url, mn as PUBKY_PROOF_MAX_BYTES, mt as checkAtprotoProofRecord, mu as utf8Decode, nt as sshSignCommand, ot as decodeAnyBitcoinAddress, pt as atprotoProofRkey, rt as verifySshSignature, st as ATPROTO_DECLARED_SCOPE, tt as sameSshKey, ut as ATPROTO_PROOF_SCOPE, vi as dnsProofName, vn as normalizePubkyKey, vt as shortAtprotoDid, wi as normalizeDomain, wt as DidError, xn as pubkyProofPath, xt as DID_DOCUMENT_MAX_BYTES, yi as domainTxtRecord, yn as pubkyProofCapability, yt as AtprotoProofError, zt as signingKeys } from "./src-Bpy99Z2K.js";
2
- import { _ as reserveAdapterIds, a as DomainCheckError, b as testBuild, c as assertPublicHost, d as ownDid, i as verifiedAtprotoHandle, l as chosenResolver, m as registeredIdentityProviders, n as resolveAtprotoDid, o as assertDomainRecord, r as resolveAtprotoHandle, s as assertNip05, t as assertPublicServer, u as resolverById, v as boundedIdentityFetch } from "./resolve-CvYK0Lbt.js";
1
+ import { $ as parseSshPublicKey, At as didWebDocumentUrl, Bt as staticDidDocument, Cn as pubkyHomeserverOf, Dt as didGhostlyServiceEntry, Ei as normalizeDomain, Et as checkDidSignature, Ft as normalizeDid, It as parseDid, Kt as resolveDidDht, Lt as parseDidDocument, Mt as didWebFileNames, Nt as didWebFileUrl, Ot as didJwsAlg, Pt as didWebHost, Q as SshSigError, Rt as parseDidSignaturePaste, Si as domainWellKnownFile, Sn as homeserverWebEndpoint, St as DID_FILE_MAX_BYTES, Tt as checkDidJws, Vt as strictBase64Url, Z as SSHSIG_NAMESPACE, _n as newPubkyProofFolder, _u as toBase64Url, at as BitcoinAddressError, bi as dnsProofName, bn as pubkyProofFile, bt as verifyAtprotoRecordProof, bu as utf8Encode, ct as ATPROTO_FULL_SCOPE, et as parseSshSignature, eu as RELAY_PAYLOAD_MAX_BYTES, ft as atprotoProofRecord, gn as isPubkyProofFolder, gt as normalizeAtprotoHandle, gu as randomBytes, hn as isPubkyKey, ht as isAtprotoDid, it as verifyBitcoinMessage, ji as wellKnownUrl, jt as didWebFile, kt as didSignedMessages, lt as ATPROTO_PROOF_COLLECTION, mn as PUBKY_PROOF_MAX_BYTES, mt as checkAtprotoProofRecord, mu as fromBase64Url, nt as sshSignCommand, ot as decodeAnyBitcoinAddress, pt as atprotoProofRkey, rt as verifySshSignature, ru as openRelayPayload, st as ATPROTO_DECLARED_SCOPE, tt as sameSshKey, ut as ATPROTO_PROOF_SCOPE, vn as normalizePubkyKey, vt as shortAtprotoDid, wt as DidError, xi as domainTxtRecord, xn as pubkyProofPath, xt as DID_DOCUMENT_MAX_BYTES, yn as pubkyProofCapability, yt as AtprotoProofError, yu as utf8Decode, zi as IdentityCheckUnavailable, zt as signingKeys } from "./src-Dd_7Ew1X.js";
2
+ import { _ as reserveAdapterIds, a as DomainCheckError, b as testBuild, c as assertPublicHost, d as ownDid, i as verifiedAtprotoHandle, l as chosenResolver, m as registeredIdentityProviders, n as resolveAtprotoDid, o as assertDomainRecord, r as resolveAtprotoHandle, s as assertNip05, t as assertPublicServer, u as resolverById, v as boundedIdentityFetch } from "./resolve-uZECJ3f7.js";
3
3
  import { ed25519 } from "@noble/curves/ed25519.js";
4
4
  import { sha256 } from "@noble/hashes/sha2.js";
5
5
  import { schnorr } from "@noble/curves/secp256k1.js";
@@ -3775,4 +3775,4 @@ function identityProvider(id, providers = identityProviders()) {
3775
3775
  //#endregion
3776
3776
  export { identityProvider as n, identityProviders as r, IDENTITY_PROVIDERS as t };
3777
3777
 
3778
- //# sourceMappingURL=registry-DWkkBN57.js.map
3778
+ //# sourceMappingURL=registry-CVUdD4bJ.js.map