pinecall 0.4.0 → 0.5.0
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 +14 -6
- package/dist/cli/agent-files.d.ts +6 -0
- package/dist/cli/agent-files.d.ts.map +1 -0
- package/dist/cli/agent-files.js +40 -0
- package/dist/cli/agent-files.js.map +1 -0
- package/dist/cli/agent-lines.d.ts +23 -0
- package/dist/cli/agent-lines.d.ts.map +1 -0
- package/dist/cli/agent-lines.js +109 -0
- package/dist/cli/agent-lines.js.map +1 -0
- package/dist/cli/agent-versions.d.ts +12 -0
- package/dist/cli/agent-versions.d.ts.map +1 -0
- package/dist/cli/agent-versions.js +70 -0
- package/dist/cli/agent-versions.js.map +1 -0
- package/dist/cli/agent.d.ts +77 -0
- package/dist/cli/agent.d.ts.map +1 -0
- package/dist/cli/agent.js +192 -0
- package/dist/cli/agent.js.map +1 -0
- package/dist/cli/chat.d.ts +2 -2
- package/dist/cli/chat.d.ts.map +1 -1
- package/dist/cli/chat.js +12 -24
- package/dist/cli/chat.js.map +1 -1
- package/dist/cli/client-for.d.ts +6 -0
- package/dist/cli/client-for.d.ts.map +1 -0
- package/dist/cli/client-for.js +7 -0
- package/dist/cli/client-for.js.map +1 -0
- package/dist/cli/connected.d.ts +4 -4
- package/dist/cli/connected.d.ts.map +1 -1
- package/dist/cli/connected.js +2 -2
- package/dist/cli/connected.js.map +1 -1
- package/dist/cli/dotenv.d.ts +24 -0
- package/dist/cli/dotenv.d.ts.map +1 -0
- package/dist/cli/dotenv.js +69 -0
- package/dist/cli/dotenv.js.map +1 -0
- package/dist/cli/env.d.ts +21 -37
- package/dist/cli/env.d.ts.map +1 -1
- package/dist/cli/env.js +35 -68
- package/dist/cli/env.js.map +1 -1
- package/dist/cli/eval.d.ts +2 -1
- package/dist/cli/eval.d.ts.map +1 -1
- package/dist/cli/eval.js +5 -4
- package/dist/cli/eval.js.map +1 -1
- package/dist/cli/groups.d.ts.map +1 -1
- package/dist/cli/groups.js +0 -1
- package/dist/cli/groups.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +25 -30
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/lexicon.d.ts +14 -0
- package/dist/cli/lexicon.d.ts.map +1 -0
- package/dist/cli/lexicon.js +123 -0
- package/dist/cli/lexicon.js.map +1 -0
- package/dist/cli/line.js +6 -6
- package/dist/cli/line.js.map +1 -1
- package/dist/cli/linking.d.ts +13 -0
- package/dist/cli/linking.d.ts.map +1 -0
- package/dist/cli/linking.js +103 -0
- package/dist/cli/linking.js.map +1 -0
- package/dist/cli/load.js +1 -1
- package/dist/cli/load.js.map +1 -1
- package/dist/cli/login.d.ts +5 -11
- package/dist/cli/login.d.ts.map +1 -1
- package/dist/cli/login.js +31 -140
- package/dist/cli/login.js.map +1 -1
- package/dist/cli/memory-policy.d.ts +9 -0
- package/dist/cli/memory-policy.d.ts.map +1 -0
- package/dist/cli/memory-policy.js +79 -0
- package/dist/cli/memory-policy.js.map +1 -0
- package/dist/cli/memory.d.ts.map +1 -1
- package/dist/cli/memory.js +9 -1
- package/dist/cli/memory.js.map +1 -1
- package/dist/cli/pipeline.d.ts +2 -0
- package/dist/cli/pipeline.d.ts.map +1 -1
- package/dist/cli/pipeline.js +18 -76
- package/dist/cli/pipeline.js.map +1 -1
- package/dist/cli/serve/server.d.ts +1 -1
- package/dist/cli/serve/server.d.ts.map +1 -1
- package/dist/cli/serve/server.js +3 -2
- package/dist/cli/serve/server.js.map +1 -1
- package/dist/cli/serve/sidecar.js +1 -1
- package/dist/cli/serve/sidecar.js.map +1 -1
- package/dist/cli/serve.d.ts +1 -1
- package/dist/cli/serve.d.ts.map +1 -1
- package/dist/cli/serve.js +5 -5
- package/dist/cli/serve.js.map +1 -1
- package/dist/cli/signed-in.d.ts +36 -0
- package/dist/cli/signed-in.d.ts.map +1 -0
- package/dist/cli/signed-in.js +60 -0
- package/dist/cli/signed-in.js.map +1 -0
- package/dist/cli/simulate.d.ts.map +1 -1
- package/dist/cli/simulate.js +7 -6
- package/dist/cli/simulate.js.map +1 -1
- package/dist/cli/{run-console.d.ts → start-console.d.ts} +2 -2
- package/dist/cli/start-console.d.ts.map +1 -0
- package/dist/cli/{run-console.js → start-console.js} +3 -3
- package/dist/cli/start-console.js.map +1 -0
- package/dist/cli/{run-screens.d.ts → start-screens.d.ts} +2 -2
- package/dist/cli/start-screens.d.ts.map +1 -0
- package/dist/cli/{run-screens.js → start-screens.js} +3 -3
- package/dist/cli/start-screens.js.map +1 -0
- package/dist/cli/{run.d.ts → start.d.ts} +3 -3
- package/dist/cli/start.d.ts.map +1 -0
- package/dist/cli/{run.js → start.js} +31 -35
- package/dist/cli/start.js.map +1 -0
- package/dist/cli/supervise.d.ts +1 -1
- package/dist/cli/supervise.d.ts.map +1 -1
- package/dist/cli/supervise.js +1 -1
- package/dist/cli/supervise.js.map +1 -1
- package/dist/cli/testing/gateway.d.ts +3 -0
- package/dist/cli/testing/gateway.d.ts.map +1 -1
- package/dist/cli/testing/gateway.js +2 -4
- package/dist/cli/testing/gateway.js.map +1 -1
- package/dist/cli/tuned.d.ts +8 -0
- package/dist/cli/tuned.d.ts.map +1 -0
- package/dist/cli/tuned.js +66 -0
- package/dist/cli/tuned.js.map +1 -0
- package/dist/cli/ui/chatting.d.ts +1 -1
- package/dist/cli/ui/chatting.d.ts.map +1 -1
- package/dist/cli/ui/chatting.js +11 -10
- package/dist/cli/ui/chatting.js.map +1 -1
- package/dist/cli/ui/console/assets/{index-DhcpHPdk.js → index--8qx-Pi4.js} +16 -12
- package/dist/cli/ui/console/assets/index-DmN15Axn.css +1 -0
- package/dist/cli/ui/console/index.html +2 -2
- package/dist/cli/ui/doors.d.ts +2 -2
- package/dist/cli/ui/doors.d.ts.map +1 -1
- package/dist/cli/ui/doors.js +2 -2
- package/dist/cli/ui/doors.js.map +1 -1
- package/dist/cli/ui/drifting.d.ts +1 -1
- package/dist/cli/ui/drifting.js +1 -1
- package/dist/cli/ui/knowing.d.ts +1 -1
- package/dist/cli/ui/knowing.js +3 -3
- package/dist/cli/ui/knowing.js.map +1 -1
- package/dist/cli/ui/promoting.d.ts +1 -1
- package/dist/cli/ui/promoting.js +1 -1
- package/dist/cli/ui/remembering.d.ts +1 -1
- package/dist/cli/ui/remembering.js +3 -3
- package/dist/cli/ui/remembering.js.map +1 -1
- package/dist/cli/ui/reproducing.d.ts +1 -1
- package/dist/cli/ui/reproducing.js +1 -1
- package/dist/cli/ui/simulating.d.ts +1 -1
- package/dist/cli/ui/simulating.js +4 -4
- package/dist/cli/ui/simulating.js.map +1 -1
- package/dist/cli/ui/testing.d.ts +1 -1
- package/dist/cli/ui/testing.js +3 -3
- package/dist/cli/ui/testing.js.map +1 -1
- package/dist/cli/whoami.d.ts +6 -2
- package/dist/cli/whoami.d.ts.map +1 -1
- package/dist/cli/whoami.js +6 -5
- package/dist/cli/whoami.js.map +1 -1
- package/dist/cli/world.d.ts +14 -24
- package/dist/cli/world.d.ts.map +1 -1
- package/dist/cli/world.js +21 -36
- package/dist/cli/world.js.map +1 -1
- package/dist/client/agent.d.ts +1 -1
- package/dist/client/agent.js +2 -2
- package/dist/client/agent.js.map +1 -1
- package/dist/client/client.d.ts +9 -1
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +5 -2
- package/dist/client/client.js.map +1 -1
- package/dist/client/connection.d.ts +3 -0
- package/dist/client/connection.d.ts.map +1 -1
- package/dist/client/connection.js +2 -1
- package/dist/client/connection.js.map +1 -1
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/observe.d.ts +3 -0
- package/dist/client/observe.d.ts.map +1 -1
- package/dist/client/observe.js +2 -1
- package/dist/client/observe.js.map +1 -1
- package/dist/client/signed.d.ts +15 -0
- package/dist/client/signed.d.ts.map +1 -0
- package/dist/client/signed.js +19 -0
- package/dist/client/signed.js.map +1 -0
- package/dist/views/render.d.ts +1 -1
- package/dist/views/render.js +1 -1
- package/package.json +2 -2
- package/dist/cli/config.d.ts +0 -16
- package/dist/cli/config.d.ts.map +0 -1
- package/dist/cli/config.js +0 -125
- package/dist/cli/config.js.map +0 -1
- package/dist/cli/credentials.d.ts +0 -41
- package/dist/cli/credentials.d.ts.map +0 -1
- package/dist/cli/credentials.js +0 -98
- package/dist/cli/credentials.js.map +0 -1
- package/dist/cli/gateway.d.ts +0 -12
- package/dist/cli/gateway.d.ts.map +0 -1
- package/dist/cli/gateway.js +0 -67
- package/dist/cli/gateway.js.map +0 -1
- package/dist/cli/keys.d.ts +0 -28
- package/dist/cli/keys.d.ts.map +0 -1
- package/dist/cli/keys.js +0 -137
- package/dist/cli/keys.js.map +0 -1
- package/dist/cli/profiles.d.ts +0 -122
- package/dist/cli/profiles.d.ts.map +0 -1
- package/dist/cli/profiles.js +0 -312
- package/dist/cli/profiles.js.map +0 -1
- package/dist/cli/run-console.d.ts.map +0 -1
- package/dist/cli/run-console.js.map +0 -1
- package/dist/cli/run-screens.d.ts.map +0 -1
- package/dist/cli/run-screens.js.map +0 -1
- package/dist/cli/run.d.ts.map +0 -1
- package/dist/cli/run.js.map +0 -1
- package/dist/cli/ui/console/assets/index-iylvEP0_.css +0 -1
package/dist/cli/config.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/cli/config.ts"],"names":[],"mappings":"AAAA,uGAAuG;AAEvG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAY,UAAU,EAAyD,MAAM,eAAe,CAAC;AAO5G,eAAO,MAAM,KAAK,EAAE,KAwBnB,CAAC;AAEF,8FAA8F;AAC9F,MAAM,WAAW,OAAO;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,mFAAmF;AACnF,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,GAAE,OAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAQ5E;AAED,6EAA6E;AAC7E,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,GAAE,OAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAO5E;AAsFD,OAAO,EAAE,UAAU,EAAE,CAAC"}
|
package/dist/cli/config.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
/** `pinecall config` and `pinecall use`: the gateways this machine knows, and which one is in hand. */
|
|
2
|
-
import { activate, activeName, forget, inWorld, readConfig } from "./profiles.js";
|
|
3
|
-
const USAGE = `usage: pinecall config the gateways this machine knows
|
|
4
|
-
pinecall config rm <name> forget one
|
|
5
|
-
pinecall use <org> the org the next verb goes to
|
|
6
|
-
pinecall use <org> <world> and the world: sandbox, or production`;
|
|
7
|
-
export const group = {
|
|
8
|
-
purpose: "the gateways this machine knows, and which one the next verb goes to",
|
|
9
|
-
usage: `${USAGE}
|
|
10
|
-
|
|
11
|
-
One file — ~/.pinecall/config.json — holds them, and \`pinecall login\` writes one per ORG you
|
|
12
|
-
belong to, named after the org, with your key in both of its worlds (\`--as <name>\` and a
|
|
13
|
-
machine's key keep ONE profile, holding the key in hand). Nothing is exported, and there is no
|
|
14
|
-
order of precedence to remember: the profile with the ▸ is the one every verb uses until
|
|
15
|
-
\`pinecall use\` moves it, and \`--profile <name>\` on any one verb sends that command elsewhere.
|
|
16
|
-
|
|
17
|
-
It prints no key. What a listing may say about one is that it is there, and its fingerprint is
|
|
18
|
-
the Keys screen's business — not a prefix, not a hint. The org and the world beside each name
|
|
19
|
-
are what the login wrote down from \`whoami\`, kept as a label so this list reads without a
|
|
20
|
-
network; "sandbox (and production)" is a profile holding both worlds' keys.
|
|
21
|
-
|
|
22
|
-
\`use <org> <world>\` is a line in this file and never a trip to the gateway; a profile with no
|
|
23
|
-
key for that world is refused, and \`pinecall login\` again keeps both.
|
|
24
|
-
|
|
25
|
-
\`config rm\` takes a row out — a gateway that has moved, a key that was revoked — and the ▸ with
|
|
26
|
-
it when it was the active one. It keeps the gateway this machine is pointed at (\`pinecall
|
|
27
|
-
gateway\`), and forgets nothing else: the key itself is stopped from the Keys screen, and a row
|
|
28
|
-
left behind is a key somebody will trust tomorrow and a refusal they will read as the gateway's
|
|
29
|
-
fault.`,
|
|
30
|
-
run,
|
|
31
|
-
};
|
|
32
|
-
/** `config` with nothing after it prints them all; `use <name>` moves the mark. */
|
|
33
|
-
export async function run(argv, how = {}) {
|
|
34
|
-
const out = how.out ?? process.stdout;
|
|
35
|
-
const err = how.err ?? process.stderr;
|
|
36
|
-
const [named, ...rest] = argv;
|
|
37
|
-
if (named === undefined)
|
|
38
|
-
return listed(out, how.home);
|
|
39
|
-
if (named === "rm")
|
|
40
|
-
return dropped(rest[0], out, err, how.home);
|
|
41
|
-
if (rest[0] !== undefined)
|
|
42
|
-
return moved(named, rest[0], out, err, how.home);
|
|
43
|
-
return chosen(named, out, err, how.home);
|
|
44
|
-
}
|
|
45
|
-
/** The same verb under the name a person reaches for: `pinecall use box`. */
|
|
46
|
-
export async function use(argv, how = {}) {
|
|
47
|
-
const [named] = argv;
|
|
48
|
-
if (named === undefined) {
|
|
49
|
-
(how.err ?? process.stderr).write(`${USAGE}\n`);
|
|
50
|
-
return 2;
|
|
51
|
-
}
|
|
52
|
-
return await run(argv, how);
|
|
53
|
-
}
|
|
54
|
-
function listed(out, home) {
|
|
55
|
-
const config = readConfig(home);
|
|
56
|
-
const names = Object.keys(config.profiles).sort();
|
|
57
|
-
if (names.length === 0) {
|
|
58
|
-
out.write("no gateway yet: `pinecall login`\n");
|
|
59
|
-
return 0;
|
|
60
|
-
}
|
|
61
|
-
const rows = names.map((name) => [
|
|
62
|
-
name === config.active ? `▸ ${name}` : ` ${name}`,
|
|
63
|
-
config.profiles[name].url,
|
|
64
|
-
said(config.profiles[name]),
|
|
65
|
-
]);
|
|
66
|
-
for (const line of asColumns(rows))
|
|
67
|
-
out.write(`${line}\n`);
|
|
68
|
-
return 0;
|
|
69
|
-
}
|
|
70
|
-
function dropped(name, out, err, home) {
|
|
71
|
-
if (name === undefined) {
|
|
72
|
-
err.write(`${USAGE}\n`);
|
|
73
|
-
return 2;
|
|
74
|
-
}
|
|
75
|
-
if (forget(name, home)) {
|
|
76
|
-
out.write(`forgot ${name}\n`);
|
|
77
|
-
return 0;
|
|
78
|
-
}
|
|
79
|
-
return noSuchProfile(name, err, home);
|
|
80
|
-
}
|
|
81
|
-
function chosen(name, out, err, home) {
|
|
82
|
-
if (activate(name, home)) {
|
|
83
|
-
out.write(`▸ ${name}\n`);
|
|
84
|
-
return 0;
|
|
85
|
-
}
|
|
86
|
-
return noSuchProfile(name, err, home);
|
|
87
|
-
}
|
|
88
|
-
// One login keeps both worlds' keys, so this is a line in a file and never a trip to the gateway.
|
|
89
|
-
function moved(name, world, out, err, home) {
|
|
90
|
-
if (world !== "sandbox" && world !== "production") {
|
|
91
|
-
err.write(`a world is sandbox or production, not ${world}\n`);
|
|
92
|
-
return 2;
|
|
93
|
-
}
|
|
94
|
-
const answer = inWorld(name, world, home);
|
|
95
|
-
if (answer === "unknown")
|
|
96
|
-
return noSuchProfile(name, err, home);
|
|
97
|
-
if (answer === "nokey") {
|
|
98
|
-
err.write(`${name} holds no ${world} key: \`pinecall login\` again keeps both worlds\n`);
|
|
99
|
-
return 2;
|
|
100
|
-
}
|
|
101
|
-
out.write(`▸ ${name} · ${world}\n`);
|
|
102
|
-
if (world === "production")
|
|
103
|
-
out.write(" you look at production from here; what answers its numbers is the box's own key\n");
|
|
104
|
-
return 0;
|
|
105
|
-
}
|
|
106
|
-
/** The one refusal both `use` and `rm` give, naming what this machine does know. */
|
|
107
|
-
function noSuchProfile(name, err, home) {
|
|
108
|
-
const known = Object.keys(readConfig(home).profiles).sort();
|
|
109
|
-
const has = known.length === 0 ? "none yet: `pinecall login`" : known.join(" · ");
|
|
110
|
-
err.write(`no profile called ${name}: ${has}\n`);
|
|
111
|
-
return 2;
|
|
112
|
-
}
|
|
113
|
-
/** Whose org and which world, as the gateway last said them. A label, never a check. */
|
|
114
|
-
function said(profile) {
|
|
115
|
-
const other = profile.env === "production" ? "sandbox" : "production";
|
|
116
|
-
const world = profile.env !== undefined && profile.keys?.[other] !== undefined ? `${profile.env} (and ${other})` : profile.env;
|
|
117
|
-
return [profile.org, world].filter((word) => word !== undefined).join(" · ");
|
|
118
|
-
}
|
|
119
|
-
/** Every column as wide as its widest value: nothing is cut to make a table line up. */
|
|
120
|
-
function asColumns(rows) {
|
|
121
|
-
const widths = rows[0].map((_, column) => Math.max(...rows.map((row) => (row[column] ?? "").length)));
|
|
122
|
-
return rows.map((row) => row.map((value, column) => (value ?? "").padEnd(widths[column])).join(" ").trimEnd());
|
|
123
|
-
}
|
|
124
|
-
export { activeName };
|
|
125
|
-
//# sourceMappingURL=config.js.map
|
package/dist/cli/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/cli/config.ts"],"names":[],"mappings":"AAAA,uGAAuG;AAGvG,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAA4B,MAAM,eAAe,CAAC;AAE5G,MAAM,KAAK,GAAG;;;0EAG4D,CAAC;AAE3E,MAAM,CAAC,MAAM,KAAK,GAAU;IAC1B,OAAO,EAAE,sEAAsE;IAC/E,KAAK,EAAE,GAAG,KAAK;;;;;;;;;;;;;;;;;;;;SAoBR;IACP,GAAG;CACJ,CAAC;AASF,mFAAmF;AACnF,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,IAAc,EAAE,GAAG,GAAY,EAAE;IACzD,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;IACtC,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,OAAO,CA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E,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/** ~/.pinecall: the keys this machine keeps — the gateways it logged in to, and the local one. */
|
|
2
|
-
/** The directory both files live in: ~/.pinecall, or the one PINECALL_HOME names instead. */
|
|
3
|
-
export declare function pinecallHome(env?: NodeJS.ProcessEnv): string;
|
|
4
|
-
/** One gateway this machine has logged in to: the key, the org it opened, and when it was kept. */
|
|
5
|
-
export interface GatewayEntry {
|
|
6
|
-
api_key: string;
|
|
7
|
-
org: string;
|
|
8
|
-
logged_in_at: string;
|
|
9
|
-
/** The phone this person calls FROM, so a ring in the sandbox reaches their own agent rather
|
|
10
|
-
* than whoever holds the line. Said once with `pinecall line from`, and re-sent by every
|
|
11
|
-
* `pinecall run` — the gateway keeps it beside its live table, not in a row. */
|
|
12
|
-
calling?: string;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* The credentials file as it is on disk.
|
|
16
|
-
*
|
|
17
|
-
* `api_key` is v1's own field — one key, no URL — and it is still read by the v1 CLI on this same
|
|
18
|
-
* machine. Nothing here writes over it: a login adds a row under `gateways` and leaves the rest of
|
|
19
|
-
* the file exactly as it found it.
|
|
20
|
-
*/
|
|
21
|
-
export interface Credentials {
|
|
22
|
-
api_key?: string;
|
|
23
|
-
gateways: Record<string, GatewayEntry>;
|
|
24
|
-
}
|
|
25
|
-
/** The whole file. A missing one, an unreadable one and a broken one are all an empty table. */
|
|
26
|
-
export declare function readCredentials(home?: string): Credentials;
|
|
27
|
-
/** One gateway's row, by the URL as `normalised` writes it. Nothing logged in is nothing here. */
|
|
28
|
-
export declare function gatewayFor(url: string, home?: string): GatewayEntry | undefined;
|
|
29
|
-
/** Keep one gateway's key, the rest of the file untouched, and the file readable by nobody else. */
|
|
30
|
-
export declare function writeGateway(url: string, entry: Omit<GatewayEntry, "logged_in_at">, home?: string): void;
|
|
31
|
-
/**
|
|
32
|
-
* Remember which phone this person calls from, on the row for this gateway.
|
|
33
|
-
*
|
|
34
|
-
* A row only, never a login: `line from` is said by somebody already logged in, and rewriting the
|
|
35
|
-
* key here would be a second place that decides what the key is. Nothing happens for a gateway
|
|
36
|
-
* with no row — you cannot say which phone is yours at a gateway you have not signed in to.
|
|
37
|
-
*/
|
|
38
|
-
export declare function writeCalling(url: string, calling: string | undefined, home?: string): boolean;
|
|
39
|
-
/** The URL as a key in the table: lowercase scheme and host, and no trailing slash. */
|
|
40
|
-
export declare function normalised(url: string): string;
|
|
41
|
-
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/cli/credentials.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAgBlG,6FAA6F;AAC7F,wBAAgB,YAAY,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAEzE;AAED,mGAAmG;AACnG,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB;;oFAEgF;IAChF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CACxC;AAED,gGAAgG;AAChG,wBAAgB,eAAe,CAAC,IAAI,GAAE,MAAuB,GAAG,WAAW,CAO1E;AAED,kGAAkG;AAClG,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,MAAuB,GAAG,YAAY,GAAG,SAAS,CAE/F;AAED,oGAAoG;AACpG,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,cAAc,CAAC,EACzC,IAAI,GAAE,MAAuB,GAC5B,IAAI,CASN;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,GAAE,MAAuB,GAAG,OAAO,CAW7G;AAED,uFAAuF;AACvF,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO9C"}
|
package/dist/cli/credentials.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/** ~/.pinecall: the keys this machine keeps — the gateways it logged in to, and the local one. */
|
|
2
|
-
import { chmodSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
-
import { homedir, userInfo } from "node:os";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
// The directory is a person's, not a machine's: 0700 so another account on the same box cannot
|
|
6
|
-
// list it, and 0600 on every file so it cannot read one whose name it guessed.
|
|
7
|
-
const DIRECTORY_MODE = 0o700;
|
|
8
|
-
const FILE_MODE = 0o600;
|
|
9
|
-
// Every bit outside the owner's. A file that has one of them is readable by somebody else, and a
|
|
10
|
-
// key somebody else can read is not a key we are willing to send anywhere.
|
|
11
|
-
const OTHERS = 0o077;
|
|
12
|
-
const CREDENTIALS = "credentials";
|
|
13
|
-
/** The directory both files live in: ~/.pinecall, or the one PINECALL_HOME names instead. */
|
|
14
|
-
export function pinecallHome(env = process.env) {
|
|
15
|
-
return env["PINECALL_HOME"] ?? join(homedir(), ".pinecall");
|
|
16
|
-
}
|
|
17
|
-
/** The whole file. A missing one, an unreadable one and a broken one are all an empty table. */
|
|
18
|
-
export function readCredentials(home = pinecallHome()) {
|
|
19
|
-
const read = parsed(join(home, CREDENTIALS));
|
|
20
|
-
if (read === undefined)
|
|
21
|
-
return { gateways: {} };
|
|
22
|
-
const gateways = read["gateways"];
|
|
23
|
-
const kept = { gateways: isTable(gateways) ? gateways : {} };
|
|
24
|
-
if (typeof read["api_key"] === "string")
|
|
25
|
-
kept.api_key = read["api_key"];
|
|
26
|
-
return kept;
|
|
27
|
-
}
|
|
28
|
-
/** One gateway's row, by the URL as `normalised` writes it. Nothing logged in is nothing here. */
|
|
29
|
-
export function gatewayFor(url, home = pinecallHome()) {
|
|
30
|
-
return readCredentials(home).gateways[normalised(url)];
|
|
31
|
-
}
|
|
32
|
-
/** Keep one gateway's key, the rest of the file untouched, and the file readable by nobody else. */
|
|
33
|
-
export function writeGateway(url, entry, home = pinecallHome()) {
|
|
34
|
-
const kept = readCredentials(home);
|
|
35
|
-
kept.gateways[normalised(url)] = { ...entry, logged_in_at: new Date().toISOString() };
|
|
36
|
-
mkdirSync(home, { recursive: true, mode: DIRECTORY_MODE });
|
|
37
|
-
const path = join(home, CREDENTIALS);
|
|
38
|
-
writeFileSync(path, `${JSON.stringify(kept, null, 2)}\n`, { mode: FILE_MODE });
|
|
39
|
-
// writeFileSync's mode applies only when it creates the file, so a file that was already there
|
|
40
|
-
// keeps whatever mode it had — including one an editor widened.
|
|
41
|
-
chmodSync(path, FILE_MODE);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Remember which phone this person calls from, on the row for this gateway.
|
|
45
|
-
*
|
|
46
|
-
* A row only, never a login: `line from` is said by somebody already logged in, and rewriting the
|
|
47
|
-
* key here would be a second place that decides what the key is. Nothing happens for a gateway
|
|
48
|
-
* with no row — you cannot say which phone is yours at a gateway you have not signed in to.
|
|
49
|
-
*/
|
|
50
|
-
export function writeCalling(url, calling, home = pinecallHome()) {
|
|
51
|
-
const kept = readCredentials(home);
|
|
52
|
-
const row = kept.gateways[normalised(url)];
|
|
53
|
-
if (row === undefined)
|
|
54
|
-
return false;
|
|
55
|
-
kept.gateways[normalised(url)] = { ...row, ...(calling === undefined ? {} : { calling }) };
|
|
56
|
-
if (calling === undefined)
|
|
57
|
-
delete kept.gateways[normalised(url)]?.calling;
|
|
58
|
-
mkdirSync(home, { recursive: true, mode: DIRECTORY_MODE });
|
|
59
|
-
const path = join(home, CREDENTIALS);
|
|
60
|
-
writeFileSync(path, `${JSON.stringify(kept, null, 2)}\n`, { mode: FILE_MODE });
|
|
61
|
-
chmodSync(path, FILE_MODE);
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
/** The URL as a key in the table: lowercase scheme and host, and no trailing slash. */
|
|
65
|
-
export function normalised(url) {
|
|
66
|
-
try {
|
|
67
|
-
const parsedUrl = new URL(url);
|
|
68
|
-
return `${parsedUrl.origin}${parsedUrl.pathname}`.replace(/\/+$/, "");
|
|
69
|
-
}
|
|
70
|
-
catch {
|
|
71
|
-
return url.replace(/\/+$/, "");
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
// One JSON object off disk, or nothing: a file that is not there, cannot be read or does not parse
|
|
75
|
-
// are the same answer to every caller here, and none of them is worth an exception.
|
|
76
|
-
function parsed(path) {
|
|
77
|
-
try {
|
|
78
|
-
const read = JSON.parse(readFileSync(path, "utf8"));
|
|
79
|
-
return isTable(read) ? read : undefined;
|
|
80
|
-
}
|
|
81
|
-
catch {
|
|
82
|
-
return undefined;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
// Owned by this account and readable by nobody else.
|
|
86
|
-
function ours(path) {
|
|
87
|
-
try {
|
|
88
|
-
const about = statSync(path);
|
|
89
|
-
return about.uid === userInfo().uid && (about.mode & OTHERS) === 0;
|
|
90
|
-
}
|
|
91
|
-
catch {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function isTable(value) {
|
|
96
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
97
|
-
}
|
|
98
|
-
//# sourceMappingURL=credentials.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/cli/credentials.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAElG,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,M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AM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC7B,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACrE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,OAAO,CAAC,KAAc;IAC7B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
package/dist/cli/gateway.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** `pinecall gateway [url]`: which gateway this machine talks to, and pointing it at another one. */
|
|
2
|
-
import type { Group } from "./groups.js";
|
|
3
|
-
export declare const group: Group;
|
|
4
|
-
/** What the verb can be told besides the argv. Tests only: where to print, and which home. */
|
|
5
|
-
export interface Pointing {
|
|
6
|
-
out?: NodeJS.WritableStream;
|
|
7
|
-
err?: NodeJS.WritableStream;
|
|
8
|
-
home?: string;
|
|
9
|
-
}
|
|
10
|
-
/** With nothing after it, where this machine is pointed; with a URL, point it there. */
|
|
11
|
-
export declare function run(argv: string[], how?: Pointing): number;
|
|
12
|
-
//# sourceMappingURL=gateway.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../../src/cli/gateway.ts"],"names":[],"mappings":"AAAA,qGAAqG;AAGrG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAMzC,eAAO,MAAM,KAAK,EAAE,KAkBnB,CAAC;AAEF,8FAA8F;AAC9F,MAAM,WAAW,QAAQ;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,wFAAwF;AACxF,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,GAAE,QAAa,GAAG,MAAM,CAmB9D"}
|
package/dist/cli/gateway.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/** `pinecall gateway [url]`: which gateway this machine talks to, and pointing it at another one. */
|
|
2
|
-
import { CLOUD_URL } from "./env.js";
|
|
3
|
-
import { chooseGateway, chosenGateway, nameFor, readConfig } from "./profiles.js";
|
|
4
|
-
const USAGE = `usage: pinecall gateway where this machine is pointed
|
|
5
|
-
pinecall gateway <url> point it at your own box, then \`pinecall login\``;
|
|
6
|
-
export const group = {
|
|
7
|
-
purpose: "which gateway this machine talks to, and pointing it at another",
|
|
8
|
-
usage: `${USAGE}
|
|
9
|
-
|
|
10
|
-
Every verb goes to ${CLOUD_URL} until this says otherwise, so a person who is on the cloud
|
|
11
|
-
types \`pinecall login\` and nothing else — no URL to remember, no URL to mistype.
|
|
12
|
-
|
|
13
|
-
Somebody running their own box says so ONCE, here, and every verb that runs before this machine
|
|
14
|
-
holds a key goes there: the login and the refusal a verb prints when it has no key.
|
|
15
|
-
It is remembered as \`gateway\` in ~/.pinecall/config.json, beside the profiles; \`pinecall gateway\`
|
|
16
|
-
with nothing after it prints which, and \`pinecall config rm\` leaves it alone. An address with
|
|
17
|
-
no scheme is read as https, and only the origin is kept. A URL typed on \`pinecall login <url>\`
|
|
18
|
-
still wins, for that one command.
|
|
19
|
-
|
|
20
|
-
Once a login has kept a profile, every verb goes where the ACTIVE profile points — an org you
|
|
21
|
-
are signed in to is a profile, \`pinecall use <org>\` moves between them, and this verb is not
|
|
22
|
-
what you want. This one is for the gateway you have not signed in to yet.`,
|
|
23
|
-
run,
|
|
24
|
-
};
|
|
25
|
-
/** With nothing after it, where this machine is pointed; with a URL, point it there. */
|
|
26
|
-
export function run(argv, how = {}) {
|
|
27
|
-
const out = how.out ?? process.stdout;
|
|
28
|
-
const err = how.err ?? process.stderr;
|
|
29
|
-
const [named, ...rest] = argv;
|
|
30
|
-
if (rest.length > 0) {
|
|
31
|
-
err.write(`${USAGE}\n`);
|
|
32
|
-
return 2;
|
|
33
|
-
}
|
|
34
|
-
if (named === undefined)
|
|
35
|
-
return said(out, how.home);
|
|
36
|
-
const url = asAUrl(named);
|
|
37
|
-
if (url === null) {
|
|
38
|
-
err.write(`not a gateway URL: ${named} — it is the address of a box, like https://voz.clinica.com\n`);
|
|
39
|
-
return 2;
|
|
40
|
-
}
|
|
41
|
-
chooseGateway(url, how.home);
|
|
42
|
-
const known = readConfig(how.home).profiles[nameFor(url, readConfig(how.home))] !== undefined;
|
|
43
|
-
out.write(`▸ ${url}\n`);
|
|
44
|
-
out.write(known ? " signed in already: `pinecall use <org>` moves between them\n" : " `pinecall login` signs this machine in there\n");
|
|
45
|
-
return 0;
|
|
46
|
-
}
|
|
47
|
-
// Where the next verb goes, and where that answer came from: a person debugging a refusal reads
|
|
48
|
-
// this line first, and a "default" that looks chosen is how an hour goes missing.
|
|
49
|
-
function said(out, home) {
|
|
50
|
-
const chosen = chosenGateway(home);
|
|
51
|
-
out.write(chosen === undefined ? `▸ ${CLOUD_URL} (the default)\n` : `▸ ${chosen} (this machine's own)\n`);
|
|
52
|
-
return 0;
|
|
53
|
-
}
|
|
54
|
-
/** A URL a gateway could live at, or null. An address with no scheme is read as https. */
|
|
55
|
-
function asAUrl(said) {
|
|
56
|
-
const text = /^[a-z][a-z0-9+.-]*:\/\//i.test(said) ? said : `https://${said}`;
|
|
57
|
-
try {
|
|
58
|
-
const url = new URL(text);
|
|
59
|
-
if (url.protocol !== "http:" && url.protocol !== "https:")
|
|
60
|
-
return null;
|
|
61
|
-
return url.origin;
|
|
62
|
-
}
|
|
63
|
-
catch {
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=gateway.js.map
|
package/dist/cli/gateway.js.map
DELETED
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run on, shown once. */
|
|
2
|
-
import type { Group } from "./groups.js";
|
|
3
|
-
export declare const group: Group;
|
|
4
|
-
/** What the verb can be told besides the argv: where to print, and which environment. */
|
|
5
|
-
export interface Issuing {
|
|
6
|
-
out?: NodeJS.WritableStream;
|
|
7
|
-
err?: NodeJS.WritableStream;
|
|
8
|
-
env?: NodeJS.ProcessEnv;
|
|
9
|
-
}
|
|
10
|
-
/** One row of the listing, as the gateway answers it: the fingerprint, and never the key. */
|
|
11
|
-
interface Listed {
|
|
12
|
-
fingerprint: string;
|
|
13
|
-
label: string | null;
|
|
14
|
-
env: string;
|
|
15
|
-
scopes: string[];
|
|
16
|
-
subject: string | null;
|
|
17
|
-
name: string | null;
|
|
18
|
-
created_at: string;
|
|
19
|
-
revoked_at: string | null;
|
|
20
|
-
}
|
|
21
|
-
/** Read the sub-verb and do it: one key minted, the org's keys listed, or one stopped. */
|
|
22
|
-
export declare function run(argv: string[], how?: Issuing): Promise<number>;
|
|
23
|
-
/** The fingerprint as the listing prints it: enough to tell two keys apart, short enough to read. */
|
|
24
|
-
export declare function shortened(fingerprint: string): string;
|
|
25
|
-
/** One row as a terminal reads it: what it is, where it opens, whose it is, and its standing. */
|
|
26
|
-
export declare function aLine(row: Listed): string;
|
|
27
|
-
export {};
|
|
28
|
-
//# sourceMappingURL=keys.d.ts.map
|
package/dist/cli/keys.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../src/cli/keys.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAKlG,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAsBzC,eAAO,MAAM,KAAK,EAAE,KAkBnB,CAAC;AAEF,yFAAyF;AACzF,MAAM,WAAW,OAAO;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACzB;AAED,6FAA6F;AAC7F,UAAU,MAAM;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAWD,0FAA0F;AAC1F,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,GAAE,OAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAgB5E;AA8ED,qGAAqG;AACrG,wBAAgB,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAErD;AAID,iGAAiG;AACjG,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIzC"}
|
package/dist/cli/keys.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/** `pinecall keys issue | list | revoke`: the API keys this org's machines run on, shown once. */
|
|
2
|
-
import { parseArgs } from "node:util";
|
|
3
|
-
import { theDoor } from "./env.js";
|
|
4
|
-
import { asked } from "./testing/gateway.js";
|
|
5
|
-
import { refusal } from "./whoami.js";
|
|
6
|
-
const USAGE = `usage: pinecall keys issue --label "<what it is for>" [--env production|sandbox] [--scope <scope>]…
|
|
7
|
-
pinecall keys list
|
|
8
|
-
pinecall keys revoke <fingerprint>`;
|
|
9
|
-
// The doors, on this terminal's own key. An org issues its own: the operator's /v1/ops/orgs door
|
|
10
|
-
// is the box's way in and a tenant never holds its key. runtime docs/protocol/gateway-api.md §7.
|
|
11
|
-
const KEYS = "/v1/keys";
|
|
12
|
-
// The one sentence that matters here. It is printed under every key issued, because the table
|
|
13
|
-
// keeps the sha256 and no door, here or anywhere, reads one back.
|
|
14
|
-
const PRINTED_ONCE = "copy it now: the gateway keeps the fingerprint, and the key is never shown again";
|
|
15
|
-
// What a key with no label is in the listing. The column is still a column.
|
|
16
|
-
const NO_LABEL = "—";
|
|
17
|
-
const REVOKED = "revoked";
|
|
18
|
-
const LIVE = "live";
|
|
19
|
-
export const group = {
|
|
20
|
-
purpose: "issue | list | revoke the API keys this org's machines run on",
|
|
21
|
-
usage: `${USAGE}
|
|
22
|
-
|
|
23
|
-
A key issued here is a MACHINE's: a server, a CI job, a box. It names nobody — people get
|
|
24
|
-
keys by logging in — and it holds \`app\` in production unless --scope says otherwise, which
|
|
25
|
-
is the shape a deployment has. Your own key does not hold \`app\` in production: a deployed
|
|
26
|
-
agent is held by the process somebody put on a box, not by whoever is logged in.
|
|
27
|
-
|
|
28
|
-
So this is the last step before a deploy: issue one, put it in the box's environment as
|
|
29
|
-
\`pinecall login --key-stdin\`, and that \`pinecall run\` is the one that answers your numbers.
|
|
30
|
-
|
|
31
|
-
issue prints the key once and never again. list prints fingerprints, labels, worlds, whose
|
|
32
|
-
each is and whether it is revoked — never a key. revoke takes a fingerprint as list prints it:
|
|
33
|
-
the first twelve characters, or more of them when two keys share those. The row and its history
|
|
34
|
-
stay, so the calls it wrote stay readable. A key may not issue a scope
|
|
35
|
-
it does not itself open.`,
|
|
36
|
-
run,
|
|
37
|
-
};
|
|
38
|
-
/** Read the sub-verb and do it: one key minted, the org's keys listed, or one stopped. */
|
|
39
|
-
export async function run(argv, how = {}) {
|
|
40
|
-
const out = how.out ?? process.stdout;
|
|
41
|
-
const err = how.err ?? process.stderr;
|
|
42
|
-
const verb = argv[0];
|
|
43
|
-
const door = theDoor(how.env ?? process.env, err);
|
|
44
|
-
if (door === undefined)
|
|
45
|
-
return 1;
|
|
46
|
-
try {
|
|
47
|
-
if (verb === "issue")
|
|
48
|
-
return await issue(argv.slice(1), door, out, err);
|
|
49
|
-
if (verb === "list")
|
|
50
|
-
return await list(door, out);
|
|
51
|
-
if (verb === "revoke")
|
|
52
|
-
return await revoke(argv[1], door, out, err);
|
|
53
|
-
}
|
|
54
|
-
catch (refused) {
|
|
55
|
-
err.write(`${refusal(refused)}\n`);
|
|
56
|
-
return 1;
|
|
57
|
-
}
|
|
58
|
-
err.write(`${USAGE}\n`);
|
|
59
|
-
return 2;
|
|
60
|
-
}
|
|
61
|
-
/** Mint one, print it once, and say what it opens — so the next paste is into the right box. */
|
|
62
|
-
async function issue(argv, door, out, err) {
|
|
63
|
-
const { values } = parseArgs({
|
|
64
|
-
args: argv,
|
|
65
|
-
options: {
|
|
66
|
-
label: { type: "string" },
|
|
67
|
-
env: { type: "string" },
|
|
68
|
-
scope: { type: "string", multiple: true },
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
if (values.label === undefined) {
|
|
72
|
-
err.write(`${USAGE}\n`);
|
|
73
|
-
err.write("missing: --label, because a key you can tell apart is a key you will revoke\n");
|
|
74
|
-
return 2;
|
|
75
|
-
}
|
|
76
|
-
const body = { label: values.label };
|
|
77
|
-
if (values.env !== undefined)
|
|
78
|
-
body["env"] = values.env;
|
|
79
|
-
if (values.scope !== undefined)
|
|
80
|
-
body["scopes"] = values.scope;
|
|
81
|
-
const made = await asked(door, KEYS, { method: "POST", body });
|
|
82
|
-
out.write(`${made.key}\n`);
|
|
83
|
-
out.write(` ${made.env} · ${made.label ?? NO_LABEL} · ${made.scopes.join(" · ")}\n`);
|
|
84
|
-
out.write(` ${PRINTED_ONCE}\n`);
|
|
85
|
-
return 0;
|
|
86
|
-
}
|
|
87
|
-
/** Every key of the org, oldest first, as fingerprints — the word `revoke` takes. */
|
|
88
|
-
async function list(door, out) {
|
|
89
|
-
const rows = await asked(door, KEYS);
|
|
90
|
-
if (rows.length === 0) {
|
|
91
|
-
out.write("no key of this org: `pinecall keys issue --label \"…\"` mints the first\n");
|
|
92
|
-
return 0;
|
|
93
|
-
}
|
|
94
|
-
for (const row of rows)
|
|
95
|
-
out.write(`${aLine(row)}\n`);
|
|
96
|
-
return 0;
|
|
97
|
-
}
|
|
98
|
-
// The listing prints the first twelve characters, because a full sha256 is unreadable in a
|
|
99
|
-
// column — so the word a person copies off the screen is NOT the word the door takes, and
|
|
100
|
-
// `pinecall keys revoke <what list printed>` answered 404 for every key there was. The door stays
|
|
101
|
-
// strict, and this resolves what was typed against the org's own rows before it knocks.
|
|
102
|
-
const NO_SUCH_FINGERPRINT = "no key of this org begins with {said}: `pinecall keys list` prints them";
|
|
103
|
-
const TWO_KEYS = "{said} names more than one key: {which}";
|
|
104
|
-
/** Stop one key. A fingerprint that is not this org's is the 404 a stranger's is. */
|
|
105
|
-
async function revoke(said, door, out, err) {
|
|
106
|
-
if (said === undefined) {
|
|
107
|
-
err.write(`${USAGE}\n`);
|
|
108
|
-
return 2;
|
|
109
|
-
}
|
|
110
|
-
const rows = await asked(door, KEYS);
|
|
111
|
-
const found = rows.filter((row) => row.fingerprint.startsWith(said));
|
|
112
|
-
if (found.length === 0) {
|
|
113
|
-
err.write(`${NO_SUCH_FINGERPRINT.replace("{said}", said)}\n`);
|
|
114
|
-
return 1;
|
|
115
|
-
}
|
|
116
|
-
if (found.length > 1) {
|
|
117
|
-
const which = found.map((row) => shortened(row.fingerprint)).join(" · ");
|
|
118
|
-
err.write(`${TWO_KEYS.replace("{said}", said).replace("{which}", which)}\n`);
|
|
119
|
-
return 1;
|
|
120
|
-
}
|
|
121
|
-
const whole = found[0].fingerprint;
|
|
122
|
-
await asked(door, `${KEYS}/${encodeURIComponent(whole)}/revoke`, { method: "POST" });
|
|
123
|
-
out.write(`revoked ${shortened(whole)}\n`);
|
|
124
|
-
return 0;
|
|
125
|
-
}
|
|
126
|
-
/** The fingerprint as the listing prints it: enough to tell two keys apart, short enough to read. */
|
|
127
|
-
export function shortened(fingerprint) {
|
|
128
|
-
return fingerprint.slice(0, FINGERPRINT_CHARS);
|
|
129
|
-
}
|
|
130
|
-
const FINGERPRINT_CHARS = 12;
|
|
131
|
-
/** One row as a terminal reads it: what it is, where it opens, whose it is, and its standing. */
|
|
132
|
-
export function aLine(row) {
|
|
133
|
-
const whose = row.name ?? (row.subject === null ? "a machine" : row.subject);
|
|
134
|
-
const standing = row.revoked_at === null ? LIVE : REVOKED;
|
|
135
|
-
return `${shortened(row.fingerprint)} ${row.env.padEnd(11)} ${(row.label ?? NO_LABEL).padEnd(20)} ${whose.padEnd(14)} ${standing}`;
|
|
136
|
-
}
|
|
137
|
-
//# sourceMappingURL=keys.js.map
|
package/dist/cli/keys.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/cli/keys.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAElG,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,OAAO,EAAE,KAAK,EAAa,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,KAAK,GAAG;;0CAE4B,CAAC;AAE3C,iGAAiG;AACjG,iGAAiG;AACjG,MAAM,IAAI,GAAG,UAAU,CAAC;AAExB,8FAA8F;AAC9F,kEAAkE;AAClE,MAAM,YAAY,GAAG,kFAAkF,CAAC;AAExG,4EAA4E;AAC5E,MAAM,QAAQ,GAAG,GAAG,CAAC;AAErB,MAAM,OAAO,GAAG,SAAS,CAAC;AAC1B,MAAM,IAAI,GAAG,MAAM,CAAC;AAEpB,MAAM,CAAC,MAAM,KAAK,GAAU;IAC1B,OAAO,EAAE,+DAA+D;IACxE,KAAK,EAAE,GAAG,KAAK;;;;;;;;;;;;;;2BAcU;IACzB,GAAG;CACJ,CAAC;AA8BF,0FAA0F;AAC1F,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,IAAc,EAAE,GAAG,GAAY,EAAE;IACzD,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;I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