@chest-gate/cli 0.4.3 → 0.6.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 +74 -8
- package/dist/api.d.ts +36 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +72 -0
- package/dist/api.js.map +1 -0
- package/dist/commands/app.d.ts.map +1 -1
- package/dist/commands/app.js +91 -6
- package/dist/commands/app.js.map +1 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +5 -0
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/gate.d.ts.map +1 -1
- package/dist/commands/gate.js +143 -8
- package/dist/commands/gate.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +12 -2
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/upgrade.d.ts +3 -0
- package/dist/commands/upgrade.d.ts.map +1 -0
- package/dist/commands/upgrade.js +110 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +20 -4
- package/dist/commands/whoami.js.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/manage.d.ts +8 -10
- package/dist/manage.d.ts.map +1 -1
- package/dist/manage.js +47 -107
- package/dist/manage.js.map +1 -1
- package/package.json +1 -1
package/dist/manage.js
CHANGED
|
@@ -1,127 +1,67 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shared helper for
|
|
3
|
-
*
|
|
2
|
+
* Shared helper for owner-scoped management actions (archive, unlist) used
|
|
3
|
+
* by both `chest-gate gate archive|unlist` and `chest-gate app archive|unlist`.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Auth: CLI bearer token (`ca_live_*`), minted by `chest-gate login`. The
|
|
6
|
+
* server checks that the token's owner wallet matches the slug's deployer
|
|
7
|
+
* (gate) or author (app) before mutating. The previous per-action ed25519
|
|
8
|
+
* `X-Dashboard-Sig` flow was removed server-side; sending it now is a
|
|
9
|
+
* silent no-op that fails 401.
|
|
8
10
|
*/
|
|
9
|
-
import { existsSync } from "node:fs";
|
|
10
|
-
import { readFile } from "node:fs/promises";
|
|
11
|
-
import { homedir } from "node:os";
|
|
12
|
-
import { join } from "node:path";
|
|
13
11
|
import chalk from "chalk";
|
|
14
|
-
import {
|
|
15
|
-
import { signDashboardMessage } from "./dashboard-sig.js";
|
|
16
|
-
const WALLET_PATH = join(homedir(), ".chest", "wallet.json");
|
|
17
|
-
const DEFAULT_SERVER = process.env.CHEST_SERVER || "https://gate.chest.sh";
|
|
18
|
-
/**
|
|
19
|
-
* Load the deployer/author secret key. Priority:
|
|
20
|
-
* 1. CHEST_WALLET_KEY env (inline 64-byte JSON array)
|
|
21
|
-
* 2. --wallet-key <path> (raw Solana keypair JSON)
|
|
22
|
-
* 3. ~/.chest/wallet.json (the wallet `chest-gate keypair` writes)
|
|
23
|
-
*
|
|
24
|
-
* Errors if none are present, since management actions can't fall back to
|
|
25
|
-
* creating a fresh wallet (which wouldn't own any existing slug).
|
|
26
|
-
*/
|
|
27
|
-
async function loadDeployerSecretKey(walletKeyPath) {
|
|
28
|
-
const inline = process.env.CHEST_WALLET_KEY;
|
|
29
|
-
if (inline) {
|
|
30
|
-
try {
|
|
31
|
-
return new Uint8Array(JSON.parse(inline));
|
|
32
|
-
}
|
|
33
|
-
catch {
|
|
34
|
-
throw new Error("CHEST_WALLET_KEY must be a JSON array of 64 bytes");
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
const path = walletKeyPath || process.env.CHEST_WALLET_KEY_PATH;
|
|
38
|
-
if (path) {
|
|
39
|
-
const resolved = path.replace(/^~/, process.env.HOME || "");
|
|
40
|
-
return new Uint8Array(JSON.parse(await readFile(resolved, "utf-8")));
|
|
41
|
-
}
|
|
42
|
-
if (!existsSync(WALLET_PATH)) {
|
|
43
|
-
throw new Error(`No wallet found at ${WALLET_PATH}. Run \`chest-gate keypair\` (or pass --wallet-key) ` +
|
|
44
|
-
`with the same wallet that signed the original deploy / publish.`);
|
|
45
|
-
}
|
|
46
|
-
const wallet = JSON.parse(await readFile(WALLET_PATH, "utf-8"));
|
|
47
|
-
return new Uint8Array(wallet.solanaKeypair);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Run a dashboard-signed management action (archive or unlist) against the
|
|
51
|
-
* gate.chest.sh server. The slug must be owned by the loaded keypair.
|
|
52
|
-
*/
|
|
12
|
+
import { api, ApiError, NotLoggedInError } from "./api.js";
|
|
53
13
|
export async function runManageAction(opts) {
|
|
54
|
-
const server = (opts.server || DEFAULT_SERVER).replace(/\/$/, "");
|
|
55
14
|
const slug = opts.slug.toLowerCase();
|
|
56
15
|
const kindPath = opts.kind === "gate" ? "gates" : "apps";
|
|
57
|
-
const
|
|
58
|
-
? opts.op === "archive"
|
|
59
|
-
? "deployment:archive"
|
|
60
|
-
: "deployment:unlist"
|
|
61
|
-
: opts.op === "archive"
|
|
62
|
-
? "app:archive"
|
|
63
|
-
: "app:unlist";
|
|
64
|
-
let secretKey;
|
|
65
|
-
try {
|
|
66
|
-
secretKey = await loadDeployerSecretKey(opts.walletKey);
|
|
67
|
-
}
|
|
68
|
-
catch (err) {
|
|
69
|
-
console.error(chalk.red(` Error: ${err.message}`));
|
|
70
|
-
process.exit(1);
|
|
71
|
-
}
|
|
72
|
-
const wallet = Keypair.fromSecretKey(secretKey).publicKey.toBase58();
|
|
16
|
+
const path = `/api/${kindPath}/${encodeURIComponent(slug)}/${opts.op}`;
|
|
73
17
|
console.log(chalk.gray(" Slug: ") + chalk.white(slug));
|
|
74
|
-
console.log(chalk.gray("
|
|
75
|
-
console.log(chalk.gray(" Action: ") + chalk.white(action));
|
|
76
|
-
console.log(chalk.gray(" Server: ") + chalk.gray(server));
|
|
18
|
+
console.log(chalk.gray(" Action: ") + chalk.white(`${opts.kind}:${opts.op}`));
|
|
77
19
|
console.log();
|
|
78
|
-
const sigBase64 = signDashboardMessage({ wallet, action, resourceId: slug }, secretKey);
|
|
79
|
-
const url = `${server}/api/${kindPath}/${encodeURIComponent(slug)}/${opts.op}?wallet=${encodeURIComponent(wallet)}`;
|
|
80
|
-
const init = {
|
|
81
|
-
method: "POST",
|
|
82
|
-
headers: {
|
|
83
|
-
"X-Dashboard-Sig": sigBase64,
|
|
84
|
-
...(opts.op === "unlist" ? { "Content-Type": "application/json" } : {}),
|
|
85
|
-
},
|
|
86
|
-
...(opts.op === "unlist"
|
|
87
|
-
? { body: JSON.stringify({ unlisted: opts.unlisted ?? true }) }
|
|
88
|
-
: {}),
|
|
89
|
-
};
|
|
90
|
-
let res;
|
|
91
20
|
try {
|
|
92
|
-
|
|
21
|
+
const body = opts.op === "unlist" ? { unlisted: opts.unlisted ?? true } : undefined;
|
|
22
|
+
const result = await api(path, {
|
|
23
|
+
method: "POST",
|
|
24
|
+
body,
|
|
25
|
+
server: opts.server,
|
|
26
|
+
});
|
|
27
|
+
if (opts.op === "archive") {
|
|
28
|
+
if (result.alreadyArchived) {
|
|
29
|
+
console.log(chalk.yellow(` Already archived at ${result.archivedAt}`));
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
console.log(chalk.green(" ✓ Archived"));
|
|
33
|
+
if (typeof result.archivedAt === "string") {
|
|
34
|
+
console.log(chalk.gray(" archivedAt: ") + chalk.gray(result.archivedAt));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
const unlisted = result.unlisted === true;
|
|
39
|
+
console.log(chalk.green(unlisted ? " ✓ Unlisted" : " ✓ Re-listed"));
|
|
40
|
+
}
|
|
93
41
|
}
|
|
94
42
|
catch (err) {
|
|
95
|
-
|
|
43
|
+
handleApiError(err, slug);
|
|
96
44
|
process.exit(1);
|
|
97
45
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
else if (res.status === 404) {
|
|
105
|
-
console.error(chalk.gray(` Slug "${slug}" not found.`));
|
|
106
|
-
}
|
|
107
|
-
else if (res.status === 401) {
|
|
108
|
-
console.error(chalk.gray(" Signature failed verification. Check that ~/.chest/wallet.json holds the deployer / author key."));
|
|
109
|
-
}
|
|
110
|
-
process.exit(1);
|
|
46
|
+
}
|
|
47
|
+
function handleApiError(err, slug) {
|
|
48
|
+
if (err instanceof NotLoggedInError) {
|
|
49
|
+
console.error(chalk.red(` Error: ${err.message}`));
|
|
50
|
+
return;
|
|
111
51
|
}
|
|
112
|
-
if (
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
52
|
+
if (err instanceof ApiError) {
|
|
53
|
+
console.error(chalk.red(` Error ${err.status}: ${err.message}`));
|
|
54
|
+
if (err.status === 401) {
|
|
55
|
+
console.error(chalk.gray(" Re-run `chest-gate login` to mint a fresh token."));
|
|
116
56
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
console.log(chalk.gray(" archivedAt: ") + chalk.gray(body.archivedAt));
|
|
57
|
+
else if (err.status === 403) {
|
|
58
|
+
console.error(chalk.gray(` Your wallet doesn't own slug "${slug}". Log in with the wallet that deployed/published it.`));
|
|
120
59
|
}
|
|
60
|
+
else if (err.status === 404) {
|
|
61
|
+
console.error(chalk.gray(` Slug "${slug}" not found.`));
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
121
64
|
}
|
|
122
|
-
|
|
123
|
-
const unlisted = body.unlisted === true;
|
|
124
|
-
console.log(chalk.green(unlisted ? " ✓ Unlisted" : " ✓ Re-listed"));
|
|
125
|
-
}
|
|
65
|
+
console.error(chalk.red(` Error: ${err.message}`));
|
|
126
66
|
}
|
|
127
67
|
//# sourceMappingURL=manage.js.map
|
package/dist/manage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manage.js","sourceRoot":"","sources":["../src/manage.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"manage.js","sourceR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