@ghostlytools/cli 1.11.2 → 1.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -28
- package/SKILL.md +4 -2
- package/dist/assets/{api-CtXgscmK.js → api-BwyFq4lA.js} +2 -2
- package/dist/assets/{api-BM3PsXbB.js → api-MYc6QNRs.js} +306 -114
- package/dist/assets/api-MYc6QNRs.js.map +1 -0
- package/dist/assets/{apiKit-lCTQ0EBG.js → apiKit-CfsNx9ZR.js} +62 -16
- package/dist/assets/apiKit-CfsNx9ZR.js.map +1 -0
- package/dist/assets/{appFetch-BKHy5H8J.js → appFetch-DVYZOZFw.js} +3 -3
- package/dist/assets/{appFetch-BKHy5H8J.js.map → appFetch-DVYZOZFw.js.map} +1 -1
- package/dist/assets/{apps-DO_gAZgm.js → apps-Dbw2Hcko.js} +1 -1
- package/dist/assets/{apps-Do26w3c7.js → apps-h12II1us.js} +150 -57
- package/dist/assets/apps-h12II1us.js.map +1 -0
- package/dist/assets/{arkade-CZrLbz-M.js → arkade-Bw_4PZRG.js} +2 -2
- package/dist/assets/{arkade-CZrLbz-M.js.map → arkade-Bw_4PZRG.js.map} +1 -1
- package/dist/assets/{backup-D21x1f5P.js → backup-CdEzTq5C.js} +1 -1
- package/dist/assets/{backup-j47AzDvG.js → backup-Chvy79SN.js} +60 -55
- package/dist/assets/backup-Chvy79SN.js.map +1 -0
- package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +1 -1
- package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js.map +1 -1
- package/dist/assets/{buttons-CiGlBVBT.js → buttons-BgoExb4E.js} +37 -7
- package/dist/assets/buttons-BgoExb4E.js.map +1 -0
- package/dist/assets/buttons-DK2aAGat.js +2 -0
- package/dist/assets/{client-raIncVtF.js → client-DY8tZZWi.js} +28 -8
- package/dist/assets/client-DY8tZZWi.js.map +1 -0
- package/dist/assets/{codec-DcG2AeyE.js → codec-BnMg-Grj.js} +2 -2
- package/dist/assets/{codec-DcG2AeyE.js.map → codec-BnMg-Grj.js.map} +1 -1
- package/dist/assets/{envelope-Dud6lntA.js → envelope-CdV7vHVZ.js} +2 -2
- package/dist/assets/{envelope-Dud6lntA.js.map → envelope-CdV7vHVZ.js.map} +1 -1
- package/dist/assets/{errors-Dt-ZnyOX.js → errors-CAh6GLJZ.js} +27 -2
- package/dist/assets/errors-CAh6GLJZ.js.map +1 -0
- package/dist/assets/{fedimintSdk-DRKRSw14.js → fedimintSdk-CPFfVK-G.js} +2 -2
- package/dist/assets/{fedimintSdk-DRKRSw14.js.map → fedimintSdk-CPFfVK-G.js.map} +1 -1
- package/dist/assets/{fixedHosts-CNX7QiUD.js → fixedHosts-CbgqrIKs.js} +3 -3
- package/dist/assets/{fixedHosts-CNX7QiUD.js.map → fixedHosts-CbgqrIKs.js.map} +1 -1
- package/dist/assets/{host-8RskzQgB.js → host-C0NMNQLl.js} +702 -143
- package/dist/assets/host-C0NMNQLl.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-uAThbFub.js → hyperdhtRelay-Dz7pvcBA.js} +2 -2
- package/dist/assets/{hyperdhtRelay-uAThbFub.js.map → hyperdhtRelay-Dz7pvcBA.js.map} +1 -1
- package/dist/assets/{irohWeb-DGelfgDJ.js → irohWeb-caAj4Dms.js} +19 -12
- package/dist/assets/irohWeb-caAj4Dms.js.map +1 -0
- package/dist/assets/{main-BC33ooYg.js → main-C6t5zrD5.js} +383 -110
- package/dist/assets/main-C6t5zrD5.js.map +1 -0
- package/dist/assets/{mainline-DYrjsS1t.js → mainline-DCuGUSZF.js} +35 -18
- package/dist/assets/mainline-DCuGUSZF.js.map +1 -0
- package/dist/assets/{networkReason-n2oBs4by.js → networkReason-BbQW1Xpc.js} +3 -3
- package/dist/assets/{networkReason-n2oBs4by.js.map → networkReason-BbQW1Xpc.js.map} +1 -1
- package/dist/assets/{nwc-Do3VSlIS.js → nwc-CSDRMZ0e.js} +3 -3
- package/dist/assets/{nwc-Do3VSlIS.js.map → nwc-CSDRMZ0e.js.map} +1 -1
- package/dist/assets/{nwcProvider-Du5aWNIn.js → nwcProvider-PE0wli8n.js} +2 -2
- package/dist/assets/{nwcProvider-Du5aWNIn.js.map → nwcProvider-PE0wli8n.js.map} +1 -1
- package/dist/assets/{ownDid-CwwYu8s2.js → ownDid-C1R5Kd8q.js} +2 -2
- package/dist/assets/{ownDid-CwwYu8s2.js.map → ownDid-C1R5Kd8q.js.map} +1 -1
- package/dist/assets/{ownStatus-D7dB4zJB.js → ownStatus-BoTf5WqQ.js} +27 -9
- package/dist/assets/ownStatus-BoTf5WqQ.js.map +1 -0
- package/dist/assets/{profiles-NyF5FnYF.js → profiles-DszHjEJi.js} +25 -10
- package/dist/assets/profiles-DszHjEJi.js.map +1 -0
- package/dist/assets/{registry-DKDInr0A.js → registry-Da-r6eC3.js} +30 -12
- package/dist/assets/registry-Da-r6eC3.js.map +1 -0
- package/dist/assets/{registry-C734VrO9.js → registry-zUZBSHYv.js} +1 -1
- package/dist/assets/{resolve-3Tqh9AWQ.js → resolve-tUzh4lHh.js} +2 -2
- package/dist/assets/{resolve-3Tqh9AWQ.js.map → resolve-tUzh4lHh.js.map} +1 -1
- package/dist/assets/{secretGuard-B7Hj0Kvz.js → secretGuard-CsVHDdYk.js} +68 -6
- package/dist/assets/{secretGuard-B7Hj0Kvz.js.map → secretGuard-CsVHDdYk.js.map} +1 -1
- package/dist/assets/secretGuard-DCb1I0_B.js +2 -0
- package/dist/assets/{server-B6PQ6iae.js → server-C1jZZ61O.js} +896 -277
- package/dist/assets/server-C1jZZ61O.js.map +1 -0
- package/dist/assets/{src-ChJijTlM.js → src-DJe-OYxd.js} +1010 -236
- package/dist/assets/src-DJe-OYxd.js.map +1 -0
- package/dist/assets/{sshForges-Brf0fslM.js → sshForges-C9zTO72R.js} +4 -3
- package/dist/assets/sshForges-C9zTO72R.js.map +1 -0
- package/dist/assets/{translate-xLme9Rdh.js → translate-CUuC5szR.js} +36 -15
- package/dist/assets/translate-CUuC5szR.js.map +1 -0
- package/dist/assets/{usdt-CSU5KzTV.js → usdt-DI51znt-.js} +3 -3
- package/dist/assets/{usdt-CSU5KzTV.js.map → usdt-DI51znt-.js.map} +1 -1
- package/dist/ghostly.mjs +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/assets/api-BM3PsXbB.js.map +0 -1
- package/dist/assets/apiKit-lCTQ0EBG.js.map +0 -1
- package/dist/assets/apps-Do26w3c7.js.map +0 -1
- package/dist/assets/backup-j47AzDvG.js.map +0 -1
- package/dist/assets/buttons-CiGlBVBT.js.map +0 -1
- package/dist/assets/buttons-D2l2bVCG.js +0 -2
- package/dist/assets/client-raIncVtF.js.map +0 -1
- package/dist/assets/errors-Dt-ZnyOX.js.map +0 -1
- package/dist/assets/host-8RskzQgB.js.map +0 -1
- package/dist/assets/irohWeb-DGelfgDJ.js.map +0 -1
- package/dist/assets/main-BC33ooYg.js.map +0 -1
- package/dist/assets/mainline-DYrjsS1t.js.map +0 -1
- package/dist/assets/ownStatus-D7dB4zJB.js.map +0 -1
- package/dist/assets/profiles-NyF5FnYF.js.map +0 -1
- package/dist/assets/registry-DKDInr0A.js.map +0 -1
- package/dist/assets/secretGuard-DUr6bgKc.js +0 -2
- package/dist/assets/server-B6PQ6iae.js.map +0 -1
- package/dist/assets/src-ChJijTlM.js.map +0 -1
- package/dist/assets/sshForges-Brf0fslM.js.map +0 -1
- package/dist/assets/translate-xLme9Rdh.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./src-
|
|
2
|
-
import { t as CliError } from "./errors-
|
|
3
|
-
import { i as cleanName,
|
|
1
|
+
import "./src-DJe-OYxd.js";
|
|
2
|
+
import { t as CliError } from "./errors-CAh6GLJZ.js";
|
|
3
|
+
import { i as cleanName, j as shownName } from "./apiKit-CfsNx9ZR.js";
|
|
4
4
|
import { t as childEnv } from "./childEnv-K_IzUqQx.js";
|
|
5
5
|
import { execFileSync } from "node:child_process";
|
|
6
6
|
import { chmodSync, closeSync, existsSync, linkSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmSync, statSync, utimesSync, writeFileSync, writeSync } from "node:fs";
|
|
@@ -33,7 +33,8 @@ function usersAlone(path) {
|
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* A folder for a socket outside the profile (when the profile's path is too long for one): made owner-only, and
|
|
36
|
-
* refused when it is a link, someone else made it, or anyone else may enter it
|
|
36
|
+
* refused when it is a link, someone else made it, or anyone else may enter it: `refused`, as the profile's own checks
|
|
37
|
+
* (`ownProfile`), with the way out. It holds only sockets, so removing it loses nothing; it is made again.
|
|
37
38
|
*/
|
|
38
39
|
function privateFolder(path, what) {
|
|
39
40
|
mkdirSync(path, {
|
|
@@ -41,7 +42,7 @@ function privateFolder(path, what) {
|
|
|
41
42
|
mode: 448
|
|
42
43
|
});
|
|
43
44
|
const info = lstatSync(path);
|
|
44
|
-
if (!info.isDirectory() || process.getuid && info.uid !== process.getuid() || (info.mode & 63) !== 0) throw new
|
|
45
|
+
if (!info.isDirectory() || process.getuid && info.uid !== process.getuid() || (info.mode & 63) !== 0) throw new CliError("refused", `${path} is not a folder of this user's alone: ${what}. Run \`rm -r ${path}\` (ghostly makes it again), or if it is this user's folder, \`chmod 700 ${path}\`, then try again`);
|
|
45
46
|
}
|
|
46
47
|
/**
|
|
47
48
|
* The profile's own folder, made owner-only again before the daemon's socket goes in it: a folder made by an older
|
|
@@ -49,7 +50,7 @@ function privateFolder(path, what) {
|
|
|
49
50
|
*/
|
|
50
51
|
function ownFolder(path, what) {
|
|
51
52
|
const info = lstatSync(path);
|
|
52
|
-
if (!info.isDirectory() || process.getuid && info.uid !== process.getuid()) throw new
|
|
53
|
+
if (!info.isDirectory() || process.getuid && info.uid !== process.getuid()) throw new CliError("refused", `${path} is not a folder of this user's: ${what}`);
|
|
53
54
|
if ((info.mode & 63) !== 0) chmodSync(path, 448);
|
|
54
55
|
}
|
|
55
56
|
/**
|
|
@@ -134,8 +135,9 @@ function userPath(path, home = false) {
|
|
|
134
135
|
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`);
|
|
135
136
|
return resolve(path);
|
|
136
137
|
}
|
|
138
|
+
var isProfileName = (name) => NAME.test(name) && !name.includes("..");
|
|
137
139
|
function checkProfileName(name) {
|
|
138
|
-
if (!
|
|
140
|
+
if (!isProfileName(name)) throw new CliError("usage", `Not a profile name: ${JSON.stringify(name)} (letters, digits, ".", "_" and "-", up to 64)`);
|
|
139
141
|
return name;
|
|
140
142
|
}
|
|
141
143
|
/**
|
|
@@ -170,10 +172,23 @@ function currentProfile(home, option) {
|
|
|
170
172
|
const file = join(home, "current");
|
|
171
173
|
if (existsSync(file)) {
|
|
172
174
|
const name = readFileSync(file, "utf8").trim();
|
|
173
|
-
if (name)
|
|
175
|
+
if (name && !isProfileName(name)) throw new CliError("refused", `${file} names no profile (${JSON.stringify(name)}): ghostly profile use <name> or ghostly profile create <name> --use replaces it, or delete the file`, { file });
|
|
176
|
+
if (name) return name;
|
|
174
177
|
}
|
|
175
178
|
return DEFAULT_PROFILE;
|
|
176
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* The current profile, or null when `<home>/current` names none: for the commands that list profiles or replace that
|
|
182
|
+
* file (`profile list`, `use`, `create`, `restore`), which a bad name there would otherwise block.
|
|
183
|
+
*/
|
|
184
|
+
function currentProfileOrNone(home, option) {
|
|
185
|
+
try {
|
|
186
|
+
return currentProfile(home, option);
|
|
187
|
+
} catch (error) {
|
|
188
|
+
if (error instanceof CliError && error.details?.file) return null;
|
|
189
|
+
throw error;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
177
192
|
function profileDir(home, name) {
|
|
178
193
|
return join(home, "profiles", checkProfileName(name));
|
|
179
194
|
}
|
|
@@ -523,6 +538,6 @@ function holder(file, lock) {
|
|
|
523
538
|
return recorded && now !== null && now !== recorded ? null : pid;
|
|
524
539
|
}
|
|
525
540
|
//#endregion
|
|
526
|
-
export {
|
|
541
|
+
export { ownFolder as C, runtimePath as D, privateFolder as E, userPath as S, ownSocket as T, profileExists as _, checkShownName as a, startingDaemon as b, createProfile as c, daemonClaim as d, ghostlyHome as f, noProfile as g, lockPath as h, checkProfileName as i, currentProfile as l, lockOwner as m, RESTORED_MARK as n, checkShownNameOption as o, listProfiles as p, acquireLock as r, claimForDaemon as s, DEFAULT_PROFILE as t, currentProfileOrNone as u, profilePaths as v, ownProfile as w, startingPath as x, selectProfile as y };
|
|
527
542
|
|
|
528
|
-
//# sourceMappingURL=profiles-
|
|
543
|
+
//# sourceMappingURL=profiles-DszHjEJi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiles-DszHjEJi.js","names":[],"sources":["../../src/privateFolder.ts","../../src/profiles.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { chmodSync, lstatSync, mkdirSync, readdirSync, statSync, type Stats } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, isAbsolute, join } from \"node:path\";\nimport { CliError } from \"./errors\";\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: `refused`, as the profile's own checks\n * (`ownProfile`), with the way out. It holds only sockets, so removing it loses nothing; it is made again.\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 CliError(\"refused\", `${path} is not a folder of this user's alone: ${what}. Run \\`rm -r ${path}\\` (ghostly makes it again), or if it is this user's folder, \\`chmod 700 ${path}\\`, then try again`);\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 CliError(\"refused\", `${path} is not a folder of this user's: ${what}`);\n if ((info.mode & 0o077) !== 0) chmodSync(path, 0o700);\n}\n\n/**\n * A profile's folders and files, checked before a command (a one-shot as much as the daemon) takes its lock or opens\n * its store, which append to the files in place and follow a link: the home and its `profiles/` must be this user's\n * (a link to a folder of this user's is one); the home is closed to others' writes, `profiles/` to 0700. The profile's\n * folder and its `db/` must be this user's and not links, and are closed to 0700; what is in them must be this user's\n * and not a link, and a file is closed to 0600. A home, profile or journal opened up by hand, or made by another\n * account in a folder it could write, was used as it was: the events journal (message texts) stayed readable by others.\n */\nexport function ownProfile(dir: string): void {\n if (process.platform === \"win32\") return;\n const what = \"ghostly will not open the profile there\";\n const profiles = dirname(dir), home = dirname(profiles);\n const mine = (info: Stats) => !process.getuid || info.uid === process.getuid();\n for (const folder of [home, profiles]) {\n const info = statSync(folder);\n if (!info.isDirectory() || !mine(info)) throw new CliError(\"refused\", `${folder} is not a folder of this user's: ${what}`);\n const open = folder === home ? 0o022 : 0o077;\n if ((info.mode & open) !== 0) chmodSync(folder, info.mode & 0o777 & ~open);\n }\n const db = join(dir, \"db\");\n for (const folder of [dir, db]) {\n let info;\n try { info = lstatSync(folder); } catch (error) { if (folder === db && (error as NodeJS.ErrnoException).code === \"ENOENT\") continue; throw error; }\n if (!info.isDirectory() || !mine(info)) throw new CliError(\"refused\", `${folder} is not a folder of this user's: ${what}`);\n if ((info.mode & 0o077) !== 0) chmodSync(folder, 0o700);\n for (const name of readdirSync(folder)) {\n // Another command at once on the profile removes its lock's draft, start and stale files as it goes: one gone\n // since the listing is passed over, not the command's error.\n const path = join(folder, name), entry = lstatSync(path, { throwIfNoEntry: false });\n if (!entry) continue;\n if (entry.isSymbolicLink() || !mine(entry)) throw new CliError(\"refused\", `${path} is a link or another user's: ${what}`);\n if (entry.isFile() && (entry.mode & 0o077) !== 0) {\n try { chmodSync(path, 0o600); } catch (error) { if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error; }\n }\n }\n }\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 { execFileSync } from \"node:child_process\";\nimport { closeSync, existsSync, linkSync, lstatSync, mkdirSync, openSync, readdirSync, readFileSync, renameSync, rmSync, statSync, utimesSync, writeFileSync, writeSync, type Stats } from \"node:fs\";\nimport { createHash } from \"node:crypto\";\nimport { homedir } from \"node:os\";\nimport { join, resolve } from \"node:path\";\nimport { MAX_NICK_LENGTH } from \"@ghostly/core\";\nimport { cleanName, shownName } from \"./apiKit\";\nimport { childEnv } from \"./childEnv\";\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\nconst isProfileName = (name: string): boolean => NAME.test(name) && !name.includes(\"..\");\n\nexport function checkProfileName(name: string): string {\n if (!isProfileName(name)) 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 * cleaned as a group's name is (`shownName`: a tab or a line break is a space, invisible characters go), then up to 64\n * characters as stored; empty (or spaces) is no name. `settings set nick` took any length and every one took a line\n * break, printed whole by `status`; a name with nothing that shows was kept as given, and contacts saw no name. `field`\n * names it in the refusal.\n */\nexport function checkShownName(name: unknown, field = \"name\"): string {\n if (typeof name !== \"string\") throw new CliError(\"bad_request\", `${field} must be up to ${MAX_NICK_LENGTH} characters on one line`);\n if (!name.trim()) return \"\";\n return shownName(name, MAX_NICK_LENGTH, field, \" (an empty one is no name)\");\n}\n\n/**\n * `--name` of `profile create` and `profile set`, checked before the profile opens: `checkShownName`'s rule, counted as\n * it counts (code points once cleaned, so a line break is a space and e + a combining accent is one), refused as a\n * usage error (exit 2) that names the option, as `app init --title` is. It was the engine's `bad_request` (exit 1),\n * \"name must be up to 64 characters on one line\", which named neither the option nor the length given.\n */\nexport function checkShownNameOption(name: string): string {\n const shown = cleanName(name, Infinity) ?? \"\";\n const length = [...shown].length;\n if (length > MAX_NICK_LENGTH) throw new CliError(\"usage\", `--name is up to ${MAX_NICK_LENGTH} characters, not ${length} characters`);\n if (name.trim() && !shown) throw new CliError(\"usage\", \"--name needs a character that shows (an empty one is no name)\");\n return checkShownName(name);\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 // Nobody typed it: refused naming the file and the way out, not a usage error of a name the command never had.\n if (name && !isProfileName(name)) {\n throw new CliError(\"refused\", `${file} names no profile (${JSON.stringify(name)}): ghostly profile use <name> or ghostly profile create <name> --use replaces it, or delete the file`, { file });\n }\n if (name) return name;\n }\n return DEFAULT_PROFILE;\n}\n\n/**\n * The current profile, or null when `<home>/current` names none: for the commands that list profiles or replace that\n * file (`profile list`, `use`, `create`, `restore`), which a bad name there would otherwise block.\n */\nexport function currentProfileOrNone(home: string, option?: string): string | null {\n try {\n return currentProfile(home, option);\n } catch (error) {\n if (error instanceof CliError && error.details?.file) return null;\n throw error;\n }\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/** The file in which a daemon says it is starting: its pid, from the lock it took until its socket listens. */\nexport function startingPath(dir: string): string {\n return join(dir, \"daemon.starting\");\n}\n\n/**\n * The pid of the profile's daemon while it starts (its engine, before its socket listens): the lock's holder, when it\n * marked its start. Null otherwise: nobody holds the profile, a one-shot command does, or the mark is a dead daemon's.\n */\nexport function startingDaemon(paths: ProfilePaths): number | null {\n let pid: number;\n try { pid = Number(readFileSync(startingPath(paths.dir), \"utf8\").trim()); } catch { return null; }\n // Alive, and this profile's: the lock's holder is.\n return Number.isInteger(pid) && pid > 0 && pid === lockOwner(paths) ? pid : null;\n}\n\n/**\n * The file in which `daemon restart` or `daemon --detach` keeps the profile for the daemon it starts (`claimForDaemon`):\n * its pid, the file touched every CLAIM_TOUCH_MS while it waits.\n */\nexport function claimPath(dir: string): string {\n return join(dir, \"daemon.claim\");\n}\n\nconst CLAIM_TOUCH_MS = 1_000;\n/** A claim not touched for that long is a start that ended without removing it (killed): none. */\nconst CLAIM_FRESH_MS = 10_000;\n\n/**\n * The pid of the `daemon restart` or `daemon --detach` that keeps the profile for the daemon it starts, from the stop\n * of the old one until the new one holds the profile: the lock is free in between, and one-shot commands that kept\n * taking it in turn (a bot's typing indicator every few seconds) left the new daemon, seconds to boot, never finding\n * it free. Null when no live start claims it.\n */\nexport function daemonClaim(paths: ProfilePaths): number | null {\n const file = claimPath(paths.dir);\n let pid: number;\n try {\n if (Date.now() - statSync(file).mtimeMs > CLAIM_FRESH_MS) return null;\n pid = Number(readFileSync(file, \"utf8\").trim());\n } catch { return null; }\n if (!Number.isInteger(pid) || pid <= 0) return null;\n try { process.kill(pid, 0); } catch (error) { if ((error as NodeJS.ErrnoException).code !== \"EPERM\") return null; }\n return pid;\n}\n\n/**\n * Keeps the profile for the daemon this process starts (`daemonClaim`): until the function it returns is called, only\n * this process and its children take the profile's lock; any other command waits for the daemon's socket instead.\n * Another live start's claim stands (its daemon is the one that comes up); a claim that cannot be written is none.\n */\nexport function claimForDaemon(paths: ProfilePaths): () => void {\n if (daemonClaim(paths) !== null) return () => {};\n const mine = String(process.pid), file = claimPath(paths.dir), draft = `${file}.${mine}`;\n try {\n writeFileSync(draft, mine, { mode: 0o600 });\n renameSync(draft, file);\n } catch {\n rmSync(draft, { force: true });\n return () => {};\n }\n const ours = () => { try { return readFileSync(file, \"utf8\").trim() === mine; } catch { return false; } };\n const touch = setInterval(() => {\n if (!ours()) return;\n const now = new Date();\n try { utimesSync(file, now, now); } catch { /* removed meanwhile */ }\n }, CLAIM_TOUCH_MS);\n touch.unref();\n let released = false;\n return () => {\n if (released) return;\n released = true;\n clearInterval(touch);\n if (ours()) rmSync(file, { force: true });\n };\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\n/** A profile this home lacks, as `profile use` and `--profile` both say it: quoted, with how to list or make one. */\nexport const noProfile = (name: string): CliError =>\n new CliError(\"not_found\", `No profile ${JSON.stringify(name)} (ghostly profile list, or ghostly profile create ${name})`);\n\nexport function selectProfile(home: string, name: string): void {\n if (!profileExists(home, name)) throw noProfile(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 *\n * The lock is a link to a file that already holds the pid, so it never exists empty (agents#1642): one made by\n * `openSync` + `writeSync` was empty for a moment, and another process read that as nobody's and removed it under its\n * owner. An empty lock younger than `EMPTY_LOCK_GRACE_MS` is still an older release's being written: busy. A stale\n * lock is moved aside before it is removed, and only when what was moved is the file judged stale: one that vanished,\n * or that another process made since, is no longer removed.\n *\n * The lock stays the bare pid, as older releases read it; beside it, `<lock>.<pid>.start` holds when that process\n * started (`processStart`). A lock left by a process that died without releasing it (kill -9, Ctrl-C of a one-shot, a\n * reboot) whose pid now belongs to another process is then stale too: it held the profile for good, every command busy\n * until someone found the file. It is written before the lock is placed, so a lock of this release never lacks it for\n * a moment; one without it (an older release's) is held while its pid is alive, as before.\n *\n * While a `daemon restart` or `daemon --detach` keeps the profile for the daemon it starts (`daemonClaim`), it is busy\n * for every other process: a one-shot then waits for that daemon's socket (`openOneShot`).\n */\nexport function acquireLock(paths: ProfilePaths): () => void {\n // Kept for the daemon a start brings up (`daemonClaim`): its own process and the daemon it spawns take it, no other.\n const claim = daemonClaim(paths);\n if (claim !== null && claim !== process.pid && claim !== process.ppid) throw new CliError(\"busy\", `Profile ${paths.name} is kept for the daemon that process ${claim} starts`, { pid: claim });\n const mine = String(process.pid);\n const draft = `${paths.lock}.${mine}`;\n const start = startPath(paths.lock, process.pid);\n const started = processStart(process.pid);\n let placed = false;\n writeFileSync(draft, mine, { mode: 0o600 });\n if (started !== null) writeFileSync(start, started, { mode: 0o600 });\n try {\n for (let attempt = 0; attempt < 3; attempt++) {\n if (placeLock(draft, paths.lock, mine)) {\n placed = true;\n heldHere.add(paths.lock);\n let released = false;\n return () => {\n if (released) return;\n released = true;\n heldHere.delete(paths.lock);\n try { if (readFileSync(paths.lock, \"utf8\").trim() === mine) rmSync(paths.lock, { force: true }); } catch { /* gone already */ }\n rmSync(start, { force: true });\n };\n }\n let seen: Stats;\n try { seen = lstatSync(paths.lock); } catch { continue; }\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 if (seen.size === 0 && Date.now() - seen.mtimeMs < EMPTY_LOCK_GRACE_MS) break;\n removeStaleLock(paths.lock, seen);\n }\n } finally {\n rmSync(draft, { force: true });\n if (!placed) rmSync(start, { force: true });\n }\n throw new CliError(\"busy\", `Profile ${paths.name} is in use`);\n}\n\n/** The locks this process holds: a lock naming this pid that is not one of them is a dead holder's whose pid it has now. */\nconst heldHere = new Set<string>();\n\nfunction startPath(lock: string, pid: number): string {\n return `${lock}.${pid}.start`;\n}\n\n/**\n * When the process `pid` started, as a text that is the same for as long as it runs and another for the next process\n * given that pid; null where it cannot be read (Windows, a `/proc` that hides others' processes, no `ps`). On Linux the\n * boot's id and `/proc/<pid>/stat`'s start time (clock ticks since boot); elsewhere `ps -o lstart=`.\n */\nexport function processStart(pid: number): string | null {\n try {\n if (process.platform === \"linux\") {\n const stat = readFileSync(`/proc/${pid}/stat`, \"utf8\");\n // Fields after the command, which may hold spaces and parentheses: the start time is field 22.\n const ticks = stat.slice(stat.lastIndexOf(\")\") + 2).split(\" \")[19];\n if (!ticks || !/^\\d+$/.test(ticks)) return null;\n return `${readFileSync(\"/proc/sys/kernel/random/boot_id\", \"utf8\").trim()} ${ticks}`;\n }\n if (process.platform === \"win32\") return null;\n const lstart = execFileSync(\"ps\", [\"-o\", \"lstart=\", \"-p\", String(pid)], {\n encoding: \"utf8\", stdio: [\"ignore\", \"pipe\", \"ignore\"], timeout: 2_000, env: { ...childEnv(), LC_ALL: \"C\" },\n }).trim();\n return lstart || null;\n } catch {\n return null;\n }\n}\n\n/** How long an empty lock is taken for one an older release is still writing its pid into. */\nconst EMPTY_LOCK_GRACE_MS = 1_000;\n\n/**\n * Links `draft` (which holds `mine`) as the lock; false when there is a lock already. Where the file system has no\n * hard links, the lock is made in place, as before.\n */\nfunction placeLock(draft: string, lock: string, mine: string): boolean {\n try {\n linkSync(draft, lock);\n return true;\n } catch (error) {\n const code = (error as NodeJS.ErrnoException).code;\n if (code === \"EEXIST\") return false;\n if (![\"EPERM\", \"ENOTSUP\", \"EOPNOTSUPP\", \"ENOSYS\"].includes(code ?? \"\")) throw error;\n }\n let fd: number;\n try { fd = openSync(lock, \"wx\", 0o600); } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"EEXIST\") return false;\n throw error;\n }\n writeSync(fd, mine);\n closeSync(fd);\n return true;\n}\n\n/**\n * Removes the lock judged stale (`seen`): it is moved aside first, and removed only when what was moved is that same\n * file and holds no live pid (a freed inode is soon reused). A lock another process made in the meantime is put back.\n */\nfunction removeStaleLock(lock: string, seen: Stats): void {\n const aside = `${lock}.stale.${process.pid}`;\n try { renameSync(lock, aside); } catch { return; }\n try {\n const moved = lstatSync(aside);\n if (moved.ino === seen.ino && moved.dev === seen.dev && holder(aside, lock) === null && moved.size === seen.size) {\n const pid = lockPid(aside);\n if (pid !== null && pid !== process.pid) rmSync(startPath(lock, pid), { force: true });\n return;\n }\n try { linkSync(aside, lock); } catch { /* another lock is there already */ }\n } finally {\n rmSync(aside, { force: true });\n }\n}\n\n/**\n * The pid holding the profile, or null when nobody does: the lock's process is gone, or its pid is another process's\n * now (it started at another time than the lock's holder, or it is this process, which does not hold the lock).\n */\nexport function lockOwner(paths: ProfilePaths): number | null {\n return holder(paths.lock, paths.lock);\n}\n\nfunction lockPid(file: string): number | null {\n let pid: number;\n try { pid = Number(readFileSync(file, \"utf8\").trim()); } catch { return null; }\n return Number.isInteger(pid) && pid > 0 ? pid : null;\n}\n\n/** `file`: the lock, or the stale one moved aside; `lock`: the lock's own path, beside which its start is. */\nfunction holder(file: string, lock: string): number | null {\n const pid = lockPid(file);\n if (pid === null) return null;\n if (pid === process.pid) return heldHere.has(lock) ? pid : null;\n try { process.kill(pid, 0); } catch (error) { if ((error as NodeJS.ErrnoException).code !== \"EPERM\") return null; }\n let recorded: string;\n try { recorded = readFileSync(startPath(lock, pid), \"utf8\").trim(); } catch { return pid; }\n const now = processStart(pid);\n return recorded && now !== null && now !== recorded ? null : pid;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAYA,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,WA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AChH,MAAM,MAAM,QAAQ,KAAK;GACzB,IAAI,QAAQ,QAAQ,QAAQ,QAAQ,KAAK,OAAO,UAAU,MAAM,GAAG,GAAG,EAAE,OAAO,KAAK,CAAC;GACrF;EACF;EACA,IAAI;GAAE,SAAS,OAAO,IAAI;EAAG,QAAQ,CAAsC;CAC7E,UAAU;EACR,OAAO,OAAO,EAAE,OAAO,KAAK,CAAC;CAC/B;AACF;;;;;AAMA,SAAgB,UAAU,OAAoC;CAC5D,OAAO,OAAO,MAAM,MAAM,MAAM,IAAI;AACtC;AAEA,SAAS,QAAQ,MAA6B;CAC5C,IAAI;CACJ,IAAI;EAAE,MAAM,OAAO,aAAa,MAAM,MAAM,CAAC,CAAC,KAAK,CAAC;CAAG,QAAQ;EAAE,OAAO;CAAM;CAC9E,OAAO,OAAO,UAAU,GAAG,KAAK,MAAM,IAAI,MAAM;AAClD;;AAGA,SAAS,OAAO,MAAc,MAA6B;CACzD,MAAM,MAAM,QAAQ,IAAI;CACxB,IAAI,QAAQ,MAAM,OAAO;CACzB,IAAI,QAAQ,QAAQ,KAAK,OAAO,SAAS,IAAI,IAAI,IAAI,MAAM;CAC3D,IAAI;EAAE,QAAQ,KAAK,KAAK,CAAC;CAAG,SAAS,OAAO;EAAE,IAAK,MAAgC,SAAS,SAAS,OAAO;CAAM;CAClH,IAAI;CACJ,IAAI;EAAE,WAAW,aAAa,UAAU,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,KAAK;CAAG,QAAQ;EAAE,OAAO;CAAK;CAC1F,MAAM,MAAM,aAAa,GAAG;CAC5B,OAAO,YAAY,QAAQ,QAAQ,QAAQ,WAAW,OAAO;AAC/D"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { c as boundedIdentityFetch, i as registeredIdentityProviders, s as reserveAdapterIds, t as ownDid, u as testBuild } from "./ownDid-
|
|
3
|
-
import { a as verifiedAtprotoHandle, c as assertDomainRecord, d as chosenResolver, f as resolverById, i as resolveAtprotoHandle, l as assertNip05, p as pkarrRelays, r as resolveAtprotoDid, s as DomainCheckError, t as assertPublicServer, u as assertPublicHost } from "./resolve-
|
|
4
|
-
import { a as PUBKY_RELAYS, c as isConfigured, d as providerForIssuer, i as validForgeLogin, l as issuerFor, n as SSH_FORGE_LABEL, o as audiences, r as checkSshForge, s as clientIdFor, t as SSH_FORGE_HOST, u as oidcProviders } from "./sshForges-
|
|
1
|
+
import { An as pubkyHomeserverOf, At as checkDidJws, Bt as normalizeDid, Ca as dnsProofName, Cd as randomBytes, Cn as isPubkyProofFolder, Ct as shortAtprotoDid, Dd as utf8Encode, Dn as pubkyProofFile, Dt as DID_FILE_MAX_BYTES, Ed as utf8Decode, En as pubkyProofCapability, Et as DID_DOCUMENT_MAX_BYTES, Ft as didWebDocumentUrl, Gt as staticDidDocument, Ht as parseDidDocument, It as didWebFile, Ki as IdentityCheckUnavailable, Kt as strictBase64Url, Lt as didWebFileNames, Mt as didGhostlyServiceEntry, Nt as didJwsAlg, On as pubkyProofPath, Pa as wellKnownUrl, Pt as didSignedMessages, Qt as resolveDidDht, Rt as didWebFileUrl, Sn as isPubkyKey, Ta as domainWellKnownFile, Tn as normalizePubkyKey, Tt as verifyAtprotoRecordProof, Ut as parseDidSignaturePaste, Vt as parseDid, Wt as signingKeys, _t as atprotoProofRecord, at as parseSshSignature, bt as isAtprotoDid, ct as verifySshSignature, dt as decodeAnyBitcoinAddress, ft as ATPROTO_DECLARED_SCOPE, ht as ATPROTO_PROOF_SCOPE, it as parseSshPublicKey, jt as checkDidSignature, ka as normalizeDomain, kn as homeserverWebEndpoint, kt as DidError, lt as verifyBitcoinMessage, mt as ATPROTO_PROOF_COLLECTION, nt as SSHSIG_NAMESPACE, od as openRelayPayload, pt as ATPROTO_FULL_SCOPE, qt as DidDhtError, rd as RELAY_PAYLOAD_MAX_BYTES, rt as SshSigError, st as sshSignCommand, ut as BitcoinAddressError, vt as atprotoProofRkey, wa as domainTxtRecord, wd as toBase64Url, wn as newPubkyProofFolder, wt as AtprotoProofError, xd as fromBase64Url, xn as PUBKY_PROOF_MAX_BYTES, xt as normalizeAtprotoHandle, yt as checkAtprotoProofRecord, zt as didWebHost } from "./src-DJe-OYxd.js";
|
|
2
|
+
import { c as boundedIdentityFetch, i as registeredIdentityProviders, s as reserveAdapterIds, t as ownDid, u as testBuild } from "./ownDid-C1R5Kd8q.js";
|
|
3
|
+
import { a as verifiedAtprotoHandle, c as assertDomainRecord, d as chosenResolver, f as resolverById, i as resolveAtprotoHandle, l as assertNip05, p as pkarrRelays, r as resolveAtprotoDid, s as DomainCheckError, t as assertPublicServer, u as assertPublicHost } from "./resolve-tUzh4lHh.js";
|
|
4
|
+
import { a as PUBKY_RELAYS, c as isConfigured, d as providerForIssuer, i as validForgeLogin, l as issuerFor, n as SSH_FORGE_LABEL, o as audiences, r as checkSshForge, s as clientIdFor, t as SSH_FORGE_HOST, u as oidcProviders } from "./sshForges-C9zTO72R.js";
|
|
5
5
|
import { ed25519 } from "@noble/curves/ed25519.js";
|
|
6
6
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
7
7
|
import { schnorr } from "@noble/curves/secp256k1.js";
|
|
@@ -845,9 +845,9 @@ var PGP_NO_USER_IDS = "This copy of the key has no user IDs (keys.openpgp.org le
|
|
|
845
845
|
/** Armored blocks in pasted text; more BEGIN lines than any real paste has are refused before the regex scans. */
|
|
846
846
|
function armorBlocks(text) {
|
|
847
847
|
if ((text.match(/-----BEGIN PGP /g) ?? []).length > 4) throw new PgpProofError("Paste only what gpg printed: one signature and your public key.");
|
|
848
|
-
return [...text.matchAll(ARMOR)];
|
|
848
|
+
return [...text.matchAll(ARMOR$1)];
|
|
849
849
|
}
|
|
850
|
-
var ARMOR = /-----BEGIN PGP SIGNED MESSAGE-----[\s\S]*?-----END PGP SIGNATURE-----|-----BEGIN PGP ([A-Z ,/0-9]+)-----[\s\S]*?-----END PGP \1-----/g;
|
|
850
|
+
var ARMOR$1 = /-----BEGIN PGP SIGNED MESSAGE-----[\s\S]*?-----END PGP SIGNATURE-----|-----BEGIN PGP ([A-Z ,/0-9]+)-----[\s\S]*?-----END PGP \1-----/g;
|
|
851
851
|
/** The single armored block in pasted text (terminal output may surround it). */
|
|
852
852
|
function armoredBlock(text, what) {
|
|
853
853
|
if (/PRIVATE KEY BLOCK/.test(text)) throw new PgpProofError("This is a PRIVATE key. Never paste it anywhere: Ghostly only needs your public key (gpg --armor --export).");
|
|
@@ -1478,11 +1478,18 @@ function normalizeLogin(forge, input) {
|
|
|
1478
1478
|
if (!validForgeLogin(forge, login)) throw new Error(`Enter a ${SSH_FORGE_LABEL[forge]} username`);
|
|
1479
1479
|
return login;
|
|
1480
1480
|
}
|
|
1481
|
+
/**
|
|
1482
|
+
* The armored block, without what the terminal showed around it (ssh-keygen's "Signing data on standard input", a prompt);
|
|
1483
|
+
* the last one when the command ran more than once there (Add started over, a run without -n ghostly).
|
|
1484
|
+
*/
|
|
1485
|
+
var ARMOR = /-----BEGIN SSH SIGNATURE-----[\s\S]*?-----END SSH SIGNATURE-----/g;
|
|
1486
|
+
var armorIn = (pasted) => pasted.length > 24576 ? pasted : pasted.match(ARMOR)?.pop() ?? pasted;
|
|
1481
1487
|
/** The armor, re-wrapped canonically, so evidence is the same whatever the clipboard did to it. */
|
|
1482
1488
|
function canonicalArmor(pasted) {
|
|
1483
|
-
const
|
|
1489
|
+
const armor = armorIn(pasted);
|
|
1490
|
+
const parsed = parseSshSignature(armor);
|
|
1484
1491
|
if (parsed.namespace !== "ghostly") throw new Error(`That signature is for "${parsed.namespace}", not "${SSHSIG_NAMESPACE}": run the command with -n ${SSHSIG_NAMESPACE}`);
|
|
1485
|
-
return `-----BEGIN SSH SIGNATURE-----\n${
|
|
1492
|
+
return `-----BEGIN SSH SIGNATURE-----\n${armor.replace(/\r\n/g, "\n").trim().split("\n").map((l) => l.trim()).slice(1, -1).join("").match(/.{1,70}/g).join("\n")}\n-----END SSH SIGNATURE-----\n`;
|
|
1486
1493
|
}
|
|
1487
1494
|
/** Exactly the statement; or with one trailing newline ("\r\n" on Windows), which an editor adds when the
|
|
1488
1495
|
* statement is saved to a file and signed there (the Windows route). Nothing else is accepted. */
|
|
@@ -2020,11 +2027,21 @@ async function signInForProof(options) {
|
|
|
2020
2027
|
});
|
|
2021
2028
|
const redirected = await w.authorize(request.url, options.signal);
|
|
2022
2029
|
options.signal.throwIfAborted();
|
|
2023
|
-
|
|
2030
|
+
const idToken = await completeSignIn(options.provider, request, redirected, options);
|
|
2031
|
+
refuseUnchosenClaims(options.provider, idToken, options.reveal);
|
|
2032
|
+
return idToken;
|
|
2024
2033
|
} finally {
|
|
2025
2034
|
w.close();
|
|
2026
2035
|
}
|
|
2027
2036
|
}
|
|
2037
|
+
/** A token the provider filled with more than the person chose to share never becomes evidence: it would go to every contact. */
|
|
2038
|
+
function refuseUnchosenClaims(provider, idToken, reveal) {
|
|
2039
|
+
const { claims } = decodeIdToken(idToken);
|
|
2040
|
+
for (const [claim, coveredBy] of Object.entries(provider.disclosing ?? {})) {
|
|
2041
|
+
if (claims[claim] === void 0 || reveal.includes(coveredBy)) continue;
|
|
2042
|
+
throw new Error(claim === "hd" ? `This is a work or school ${provider.name} account: ${provider.name} adds its organisation’s domain to the sign-in, and your contacts would see it. Choose to share your email too, or sign in with a personal account.` : `${provider.name} added more to the sign-in than you chose to share. Choose to share your ${coveredBy} too, or sign in with another account.`);
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2028
2045
|
//#endregion
|
|
2029
2046
|
//#region ../browser/src/proofs/providers/oidc.ts
|
|
2030
2047
|
/** How long after the statement the sign-in may have happened: time to pick an account and approve. */
|
|
@@ -2348,9 +2365,10 @@ function nobleScript(statement, curve) {
|
|
|
2348
2365
|
`console.log(Buffer.from(${lib.name}.sign(statement, secret)).toString("hex"));`
|
|
2349
2366
|
].join("\n");
|
|
2350
2367
|
}
|
|
2368
|
+
/** OpenSSL alone: the signature comes out as one line of base64 (xxd, for hex, is missing on many Linux systems). */
|
|
2351
2369
|
function opensslCommand(statement, curve) {
|
|
2352
2370
|
const save = `printf '%s' '${statement}' > statement.txt`;
|
|
2353
|
-
return curve === "Ed25519" ? `${save} && openssl pkeyutl -sign -rawin -inkey key.pem -in statement.txt |
|
|
2371
|
+
return curve === "Ed25519" ? `${save} && openssl pkeyutl -sign -rawin -inkey key.pem -in statement.txt | openssl base64 -A` : `${save} && openssl dgst -sha256 -sign key.pem statement.txt | openssl base64 -A`;
|
|
2354
2372
|
}
|
|
2355
2373
|
var signer = {
|
|
2356
2374
|
id: "sign",
|
|
@@ -3787,6 +3805,6 @@ function identityProvider(id, providers = identityProviders()) {
|
|
|
3787
3805
|
return providers.find((p) => p.id === id);
|
|
3788
3806
|
}
|
|
3789
3807
|
//#endregion
|
|
3790
|
-
export { identityProvider as n, identityProviders as r, IDENTITY_PROVIDERS as t };
|
|
3808
|
+
export { parseProofBunker as i, identityProvider as n, identityProviders as r, IDENTITY_PROVIDERS as t };
|
|
3791
3809
|
|
|
3792
|
-
//# sourceMappingURL=registry-
|
|
3810
|
+
//# sourceMappingURL=registry-Da-r6eC3.js.map
|