@needmoretruth/nmts-cli 0.46.0 → 0.48.1
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/AGENTS.md +8 -8
- package/CHANGELOG.md +32 -1
- package/README.ko.md +1 -1
- package/README.md +19 -11
- package/dist/arg-options.d.ts +11 -1
- package/dist/args.js +7 -1
- package/dist/artifact-about.d.ts +1 -1
- package/dist/autonomy.js +3 -3
- package/dist/commands/handover.d.ts +2 -0
- package/dist/commands/handover.js +65 -17
- package/dist/commands/link.d.ts +12 -0
- package/dist/commands/link.js +121 -0
- package/dist/commands/links.d.ts +7 -0
- package/dist/commands/links.js +71 -0
- package/dist/commands/public-code-manage.d.ts +24 -0
- package/dist/commands/public-code-manage.js +217 -0
- package/dist/commands/public-code.d.ts +7 -2
- package/dist/commands/public-code.js +104 -55
- package/dist/commands/receive.js +11 -5
- package/dist/commands/share-dispatch.js +18 -1
- package/dist/commands/share.d.ts +2 -0
- package/dist/commands/share.js +45 -35
- package/dist/commands/shares-sent.js +8 -3
- package/dist/crypto-surface.d.ts +27 -0
- package/dist/crypto-surface.js +10 -0
- package/dist/crypto.d.ts +5 -0
- package/dist/crypto.js +5 -0
- package/dist/handover-codes.d.ts +25 -0
- package/dist/handover-codes.js +106 -0
- package/dist/handover.d.ts +21 -3
- package/dist/handover.js +47 -29
- package/dist/help-options.js +9 -2
- package/dist/help.js +11 -1
- package/dist/links.d.ts +67 -0
- package/dist/links.js +226 -0
- package/dist/main.js +6 -6
- package/dist/mcp-tools/reads.js +20 -6
- package/dist/mcp-tools/share.js +47 -1
- package/dist/mcp-tools/tiers.js +16 -1
- package/dist/portable.d.ts +8 -0
- package/dist/portable.js +8 -0
- package/dist/product.d.ts +1 -1
- package/dist/product.js +1 -1
- package/dist/public-code-activity.d.ts +35 -0
- package/dist/public-code-activity.js +88 -0
- package/dist/public-code-refusals.d.ts +25 -0
- package/dist/public-code-refusals.js +87 -0
- package/dist/public-codes.d.ts +76 -0
- package/dist/public-codes.js +182 -0
- package/dist/risk.d.ts +36 -1
- package/dist/risk.js +38 -1
- package/dist/share-codes.d.ts +40 -0
- package/dist/share-codes.js +151 -0
- package/dist/share.d.ts +34 -0
- package/dist/share.js +53 -12
- package/dist/shared/lib/share/public-link.d.ts +41 -0
- package/dist/shared/lib/share/public-link.js +107 -0
- package/docs/commands/handover.md +17 -1
- package/docs/commands/link.md +34 -0
- package/docs/commands/mcp.md +2 -1
- package/docs/commands/public-code.md +21 -9
- package/docs/commands/share.md +6 -3
- package/package.json +1 -1
- package/server.json +2 -2
- package/vendor/nmts-crypto/nmts_crypto_wasm.d.ts +91 -5
- package/vendor/nmts-crypto/nmts_crypto_wasm.js +259 -4
- package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm +0 -0
- package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm.d.ts +11 -1
package/dist/help.js
CHANGED
|
@@ -58,6 +58,10 @@ export function helpText(version) {
|
|
|
58
58
|
` extend <path> Buy more storage time for one file — **spends WAL from the wallet**`,
|
|
59
59
|
` public-code The code other accounts send files to. \`--publish\` makes it reachable;`,
|
|
60
60
|
` \`--save [file]\` writes your public code file, for handovers`,
|
|
61
|
+
` public-code list Every code this NMTS key has published, live and revoked`,
|
|
62
|
+
` public-code new Publish the next code. \`--replace <n>\` revokes that one in the same step`,
|
|
63
|
+
` public-code revoke <n>`,
|
|
64
|
+
` Revoke a code: nobody can send to it again. Asks every time`,
|
|
61
65
|
` delete-account A PERSON erases this account's server record — irreversible; needs the`,
|
|
62
66
|
` NMTS key, types a sentence, refused in mode auto`,
|
|
63
67
|
` accept-terms A PERSON accepts a new version of the Terms, by typing its version;`,
|
|
@@ -123,7 +127,13 @@ export function helpText(version) {
|
|
|
123
127
|
` handover make <path> --to <public code | public code file>`,
|
|
124
128
|
` Write a handover file for one account — NMTS keeps no record of it,`,
|
|
125
129
|
` and it cannot be taken back. Asks every time: answer with --yes`,
|
|
126
|
-
` handover open <file> Save the file a handover file carries.
|
|
130
|
+
` handover open <file> Save the file a handover file carries. Needs no API key`,
|
|
131
|
+
` link make <path> Make a public link to a file`,
|
|
132
|
+
` link list <path> List a file's public links`,
|
|
133
|
+
` link revoke <id> Cut a public link`,
|
|
134
|
+
` links List every live public link this account holds, with each file's path`,
|
|
135
|
+
` links revoke-all Cut every live public link at once`,
|
|
136
|
+
` link open <link> Download and decrypt a file from a public link, without logging in`,
|
|
127
137
|
` env What this machine is, and what it means for the NMTS key`,
|
|
128
138
|
` unlock [name] What this machine has unlocked; \`unlock <name>\` opens one — a person,`,
|
|
129
139
|
` at a terminal. \`lock <name>\` closes it. (\`consent\` is the older name)`,
|
package/dist/links.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { PlaintextSink } from "./download-sink.ts";
|
|
2
|
+
import type { ManifestEntry } from "./shared/lib/drive/manifest-codec.ts";
|
|
3
|
+
import type { ReadOptions } from "./walrus.ts";
|
|
4
|
+
/** The account a link is made or listed for — the same four things every account call takes. */
|
|
5
|
+
export interface LinkAccount {
|
|
6
|
+
readonly server: string;
|
|
7
|
+
/** API key or delegation token. */
|
|
8
|
+
readonly bearer: string;
|
|
9
|
+
/** The NMTS key, display form. Its dataKey opens the file key and seals the owner's copy of `S`. */
|
|
10
|
+
readonly code: string;
|
|
11
|
+
}
|
|
12
|
+
export interface MadeLink {
|
|
13
|
+
/** The whole link, secret included. */
|
|
14
|
+
link: string;
|
|
15
|
+
id: string;
|
|
16
|
+
createdAt: string;
|
|
17
|
+
expiresAt: string | null;
|
|
18
|
+
}
|
|
19
|
+
export interface ListedLink {
|
|
20
|
+
id: string;
|
|
21
|
+
/** The server's id for the file the link opens. */
|
|
22
|
+
itemId: string;
|
|
23
|
+
/** The whole link again, or null when it is cut (or its sealed secret did not open). */
|
|
24
|
+
link: string | null;
|
|
25
|
+
showsName: boolean;
|
|
26
|
+
createdAt: string;
|
|
27
|
+
expiresAt: string | null;
|
|
28
|
+
/** When it was cut, and by whom: `owner` · `operator` · `report`. */
|
|
29
|
+
cutAt: string | null;
|
|
30
|
+
cutBy: string | null;
|
|
31
|
+
downloads: number;
|
|
32
|
+
}
|
|
33
|
+
/** Make a link to one file of the account's list. */
|
|
34
|
+
export declare function makeLink(account: LinkAccount, entry: ManifestEntry, options: {
|
|
35
|
+
showName: boolean;
|
|
36
|
+
expiresDays: number | null;
|
|
37
|
+
now?: Date;
|
|
38
|
+
}): Promise<MadeLink>;
|
|
39
|
+
/** Every link the account made to one file, newest first, cut ones included. */
|
|
40
|
+
export declare function listLinks(account: LinkAccount, itemId: string): Promise<ListedLink[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Every LIVE link the account holds, across all its files, newest first. Each names its file by
|
|
43
|
+
* `itemId`; the file's name is in the account's own sealed list, which the server cannot read.
|
|
44
|
+
*/
|
|
45
|
+
export declare function listLiveLinks(account: LinkAccount): Promise<ListedLink[]>;
|
|
46
|
+
/** Cut every live link the account holds, in one request: all or none. Returns how many were cut. */
|
|
47
|
+
export declare function revokeAllLinks(account: LinkAccount): Promise<number>;
|
|
48
|
+
/** Cut one of the account's links. Cutting one that is already cut is not an error. */
|
|
49
|
+
export declare function revokeLink(account: LinkAccount, id: string): Promise<void>;
|
|
50
|
+
export interface OpenedLinkFile {
|
|
51
|
+
/** The file's name, or null when the owner hid it. */
|
|
52
|
+
name: string | null;
|
|
53
|
+
bytes: number;
|
|
54
|
+
parts: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Open a link and deliver its file to `sink`, checked against the owner's digest. No account.
|
|
58
|
+
*
|
|
59
|
+
* `name` is told the file's name (or null) before a byte is fetched, so the caller can pick the sink.
|
|
60
|
+
*/
|
|
61
|
+
export declare function openLink(input: {
|
|
62
|
+
link: string;
|
|
63
|
+
server: string;
|
|
64
|
+
chain: string;
|
|
65
|
+
sink: (name: string | null) => PlaintextSink;
|
|
66
|
+
read?: ReadOptions;
|
|
67
|
+
}): Promise<OpenedLinkFile>;
|
package/dist/links.js
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
// Public links (NCF-3 §5.8): make one, list them,
|
|
2
|
+
// cut one, and open one without an account — the code under `nmts link` and the SDK's four methods.
|
|
3
|
+
//
|
|
4
|
+
// A link is `<server>/l/<token>#<secret>`. The token names the server's row; the secret `S` opens the
|
|
5
|
+
// file key that row holds, and it is in the part after `#` that no server is sent. The shapes (link
|
|
6
|
+
// text, the sealed document) are the browser's own, copied byte for byte into `shared/`.
|
|
7
|
+
//
|
|
8
|
+
// ⛔ MAKING ONE SENDS NO SECRET. Every value in the request is an envelope made here: the file key
|
|
9
|
+
// under `S`, the document and the digest under the file key (§5.4's two re-seals), and `S` under
|
|
10
|
+
// this account's dataKey so the owner can print the same link again (`list`).
|
|
11
|
+
//
|
|
12
|
+
// ⛔ OPENING ONE ASKS FOR THE TOKEN AND NOTHING ELSE, with no session: whoever holds the link opens
|
|
13
|
+
// the file. The pieces are read from Walrus as for any download, and the whole file is checked
|
|
14
|
+
// against the digest the owner sealed before anything is delivered.
|
|
15
|
+
import { request, ServerError } from "./api.js";
|
|
16
|
+
import { fromBase64Url, fromUtf8, toBase64Url, utf8 } from "./bytes.js";
|
|
17
|
+
import { AAD, DERIVED, loadCrypto } from "./crypto.js";
|
|
18
|
+
import { fetchKnownParts } from "./download.js";
|
|
19
|
+
import { asParts } from "./download-part.js";
|
|
20
|
+
import { NmtsError } from "./errors.js";
|
|
21
|
+
import { isRecord } from "./guards.js";
|
|
22
|
+
import { buildPublicLink, decodeLinkDocument, encodeLinkDocument, linkExpiresAt, parsePublicLink, } from "./shared/lib/share/public-link.js";
|
|
23
|
+
/** Run `use` with this account's dataKey, and wipe it however `use` ends. */
|
|
24
|
+
async function withDataKey(crypt, code, use) {
|
|
25
|
+
const derived = crypt.kdf_derive(crypt.account_code_parse(code));
|
|
26
|
+
const dataKey = derived.slice(DERIVED.dataKey[0], DERIVED.dataKey[1]);
|
|
27
|
+
derived.fill(0);
|
|
28
|
+
try {
|
|
29
|
+
return await use(dataKey);
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
dataKey.fill(0);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const text = (value) => (typeof value === "string" ? value : null);
|
|
36
|
+
/** Make a link to one file of the account's list. */
|
|
37
|
+
export async function makeLink(account, entry, options) {
|
|
38
|
+
if (entry.dekWrapped === undefined || entry.contentHashCt === undefined) {
|
|
39
|
+
const missing = entry.dekWrapped === undefined ? "key, so nobody could open the link" : "hash, so a download could not be checked";
|
|
40
|
+
throw new NmtsError(`No link can be made to "${entry.name}": the file list holds no ${missing}.`, {
|
|
41
|
+
exitCode: 4,
|
|
42
|
+
nextStep: "Nothing was made.",
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const { dekWrapped, contentHashCt } = entry;
|
|
46
|
+
const crypt = await loadCrypto();
|
|
47
|
+
const secret = crypt.link_generate_secret();
|
|
48
|
+
try {
|
|
49
|
+
const body = await withDataKey(crypt, account.code, async (dataKey) => {
|
|
50
|
+
const dek = crypt.envelope_open(dataKey, utf8(AAD.dekWrap), fromBase64Url(dekWrapped));
|
|
51
|
+
const digest = crypt.envelope_open(dataKey, utf8(AAD.contentHash), fromBase64Url(contentHashCt));
|
|
52
|
+
try {
|
|
53
|
+
const doc = encodeLinkDocument({ name: options.showName ? entry.name : null, size: entry.size });
|
|
54
|
+
const expiresAt = linkExpiresAt(options.expiresDays, options.now ?? new Date());
|
|
55
|
+
return {
|
|
56
|
+
item_id: entry.id,
|
|
57
|
+
wrapped: toBase64Url(crypt.link_wrap_dek(secret, dek)),
|
|
58
|
+
name: toBase64Url(crypt.envelope_seal(dek, utf8(AAD.shareName), utf8(doc))),
|
|
59
|
+
disclosed_name: options.showName,
|
|
60
|
+
hash: toBase64Url(crypt.envelope_seal(dek, utf8(AAD.shareContentHash), digest)),
|
|
61
|
+
owner_secret: toBase64Url(crypt.link_seal_secret(dataKey, secret)),
|
|
62
|
+
...(expiresAt === undefined ? {} : { expires_at: expiresAt }),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
dek.fill(0);
|
|
67
|
+
digest.fill(0);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
const answer = await request(account.server, "/v1/share-links", { method: "POST", body, token: account.bearer });
|
|
71
|
+
const id = isRecord(answer) ? text(answer["link_id"]) : null;
|
|
72
|
+
const createdAt = isRecord(answer) ? text(answer["created_at"]) : null;
|
|
73
|
+
if (id === null || createdAt === null) {
|
|
74
|
+
throw new NmtsError("The server's answer did not name the new link.");
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
link: buildPublicLink(account.server, id, toBase64Url(secret)),
|
|
78
|
+
id,
|
|
79
|
+
createdAt,
|
|
80
|
+
expiresAt: isRecord(answer) ? text(answer["expires_at"]) : null,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
secret.fill(0);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** Every link the account made to one file, newest first, cut ones included. */
|
|
88
|
+
export async function listLinks(account, itemId) {
|
|
89
|
+
const answer = await request(account.server, `/v1/share-links?item_id=${encodeURIComponent(itemId)}`, {
|
|
90
|
+
token: account.bearer,
|
|
91
|
+
});
|
|
92
|
+
return listedFrom(account, answer);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Every LIVE link the account holds, across all its files, newest first. Each names its file by
|
|
96
|
+
* `itemId`; the file's name is in the account's own sealed list, which the server cannot read.
|
|
97
|
+
*/
|
|
98
|
+
export async function listLiveLinks(account) {
|
|
99
|
+
return listedFrom(account, await request(account.server, "/v1/share-links/live", { token: account.bearer }));
|
|
100
|
+
}
|
|
101
|
+
/** Cut every live link the account holds, in one request: all or none. Returns how many were cut. */
|
|
102
|
+
export async function revokeAllLinks(account) {
|
|
103
|
+
const answer = await request(account.server, "/v1/share-links", { method: "DELETE", token: account.bearer });
|
|
104
|
+
const cut = isRecord(answer) ? answer["cut"] : null;
|
|
105
|
+
if (typeof cut !== "number")
|
|
106
|
+
throw new NmtsError("The server's answer did not say how many links were cut.");
|
|
107
|
+
return cut;
|
|
108
|
+
}
|
|
109
|
+
/** A list answer's rows, each with its whole link rebuilt from the owner's sealed copy of `S`. */
|
|
110
|
+
async function listedFrom(account, answer) {
|
|
111
|
+
const rows = isRecord(answer) ? answer["links"] : null;
|
|
112
|
+
if (!Array.isArray(rows))
|
|
113
|
+
throw new NmtsError("The server listed the links in a shape this version cannot read.");
|
|
114
|
+
const crypt = await loadCrypto();
|
|
115
|
+
return withDataKey(crypt, account.code, async (dataKey) => rows.map((row) => {
|
|
116
|
+
if (!isRecord(row))
|
|
117
|
+
throw new NmtsError("The server listed the links in a shape this version cannot read.");
|
|
118
|
+
const id = text(row["link_id"]) ?? "";
|
|
119
|
+
const cutAt = text(row["revoked_at"]);
|
|
120
|
+
const sealed = text(row["owner_secret"]);
|
|
121
|
+
let link = null;
|
|
122
|
+
if (cutAt === null && sealed !== null) {
|
|
123
|
+
try {
|
|
124
|
+
const secret = crypt.link_open_secret(dataKey, fromBase64Url(sealed));
|
|
125
|
+
link = buildPublicLink(account.server, id, toBase64Url(secret));
|
|
126
|
+
secret.fill(0);
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
// A secret that does not open is a row without a link, not a list that fails.
|
|
130
|
+
link = null;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
id,
|
|
135
|
+
itemId: text(row["item_id"]) ?? "",
|
|
136
|
+
link,
|
|
137
|
+
showsName: row["disclosed_name"] === true,
|
|
138
|
+
createdAt: text(row["created_at"]) ?? "",
|
|
139
|
+
expiresAt: text(row["expires_at"]),
|
|
140
|
+
cutAt,
|
|
141
|
+
cutBy: text(row["revoked_by"]),
|
|
142
|
+
downloads: typeof row["downloads"] === "number" ? row["downloads"] : 0,
|
|
143
|
+
};
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
146
|
+
/** Cut one of the account's links. Cutting one that is already cut is not an error. */
|
|
147
|
+
export async function revokeLink(account, id) {
|
|
148
|
+
await request(account.server, `/v1/share-links/${encodeURIComponent(id)}`, { method: "DELETE", token: account.bearer });
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Open a link and deliver its file to `sink`, checked against the owner's digest. No account.
|
|
152
|
+
*
|
|
153
|
+
* `name` is told the file's name (or null) before a byte is fetched, so the caller can pick the sink.
|
|
154
|
+
*/
|
|
155
|
+
export async function openLink(input) {
|
|
156
|
+
const parts = parsePublicLink(input.link);
|
|
157
|
+
if (parts === null) {
|
|
158
|
+
throw new NmtsError("That is not a whole public link.", {
|
|
159
|
+
exitCode: 2,
|
|
160
|
+
nextStep: "Copy all of it, including the part after #: a link ends in /l/<token>#<secret>.",
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
let answer;
|
|
164
|
+
try {
|
|
165
|
+
answer = await request(input.server, `/v1/share-links/${encodeURIComponent(parts.token)}`);
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
if (error instanceof ServerError && error.status === 404)
|
|
169
|
+
throw new NmtsError("This link does not exist.", { exitCode: 4 });
|
|
170
|
+
if (error instanceof ServerError && error.status === 410)
|
|
171
|
+
throw new NmtsError("This link has been cut.", { exitCode: 4 });
|
|
172
|
+
throw error;
|
|
173
|
+
}
|
|
174
|
+
if (!isRecord(answer))
|
|
175
|
+
throw new NmtsError("The server's answer was not an object.");
|
|
176
|
+
const wrapped = text(answer["wrapped"]);
|
|
177
|
+
const sealedName = text(answer["name"]);
|
|
178
|
+
const sealedHash = text(answer["hash"]);
|
|
179
|
+
if (wrapped === null || sealedName === null || sealedHash === null) {
|
|
180
|
+
throw new NmtsError("The server described this link in a shape this version cannot read.");
|
|
181
|
+
}
|
|
182
|
+
const network = answer["network"] === "mainnet" || answer["network"] === "testnet" ? answer["network"] : input.chain;
|
|
183
|
+
const described = asParts(answer);
|
|
184
|
+
const crypt = await loadCrypto();
|
|
185
|
+
const secret = fromBase64Url(parts.secret);
|
|
186
|
+
let dek;
|
|
187
|
+
try {
|
|
188
|
+
dek = crypt.link_unwrap_dek(secret, fromBase64Url(wrapped));
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
throw new NmtsError("This link is incomplete or damaged: the part after # does not open the file.", {
|
|
192
|
+
exitCode: 4,
|
|
193
|
+
nextStep: "Nothing was fetched. Ask the person who sent it for the whole link.",
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
finally {
|
|
197
|
+
secret.fill(0);
|
|
198
|
+
}
|
|
199
|
+
let digest;
|
|
200
|
+
let doc;
|
|
201
|
+
try {
|
|
202
|
+
doc = decodeLinkDocument(fromUtf8(crypt.envelope_open(dek, utf8(AAD.shareName), fromBase64Url(sealedName))));
|
|
203
|
+
digest = crypt.envelope_open(dek, utf8(AAD.shareContentHash), fromBase64Url(sealedHash));
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
doc = null;
|
|
207
|
+
digest = new Uint8Array(0);
|
|
208
|
+
}
|
|
209
|
+
if (doc === null || digest.length === 0) {
|
|
210
|
+
dek.fill(0);
|
|
211
|
+
throw new NmtsError("This link is damaged: the file's name and size stored with it do not open.", {
|
|
212
|
+
exitCode: 4,
|
|
213
|
+
nextStep: "Nothing was fetched. Ask the person who sent it for a new link.",
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
const fetched = await fetchKnownParts({
|
|
217
|
+
parts: [...described.parts].sort((a, b) => a.part_index - b.part_index),
|
|
218
|
+
size: doc.size,
|
|
219
|
+
dek,
|
|
220
|
+
expected: digest,
|
|
221
|
+
chain: network,
|
|
222
|
+
sink: input.sink(doc.name),
|
|
223
|
+
...(input.read === undefined ? {} : { read: input.read }),
|
|
224
|
+
});
|
|
225
|
+
return { name: doc.name, bytes: fetched.byteCount, parts: fetched.partCount };
|
|
226
|
+
}
|
package/dist/main.js
CHANGED
|
@@ -99,10 +99,8 @@ export async function run(argv) {
|
|
|
99
99
|
sort: args.sort, desc: args.desc, long: args.long, media: args.media,
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
|
-
case "usage":
|
|
103
|
-
|
|
104
|
-
return await usage({ server: args.server, network: args.network, json: args.json });
|
|
105
|
-
}
|
|
102
|
+
case "usage":
|
|
103
|
+
return await (await import("./commands/usage.js")).usage({ server: args.server, network: args.network, json: args.json });
|
|
106
104
|
case "balance": {
|
|
107
105
|
const { balance } = await import("./commands/balance.js");
|
|
108
106
|
return await balance({ server: args.server, network: args.network, json: args.json });
|
|
@@ -114,10 +112,10 @@ export async function run(argv) {
|
|
|
114
112
|
});
|
|
115
113
|
}
|
|
116
114
|
case "public-code":
|
|
117
|
-
return await (await import("./commands/public-code.js")).
|
|
115
|
+
return await (await import("./commands/public-code.js")).runPublicCode(args);
|
|
118
116
|
case "handover":
|
|
119
117
|
return await (await import("./commands/handover.js")).handover(args.operands[0], args.operands[1], {
|
|
120
|
-
server: args.server, network: args.network, to: args.to, out: args.out, force: args.force, yes: args.yes, json: args.json,
|
|
118
|
+
server: args.server, network: args.network, to: args.to, out: args.out, as: args.as, force: args.force, yes: args.yes, json: args.json,
|
|
121
119
|
});
|
|
122
120
|
case "wallet": {
|
|
123
121
|
const { wallet } = await import("./commands/wallet.js");
|
|
@@ -295,6 +293,8 @@ export async function run(argv) {
|
|
|
295
293
|
case "share":
|
|
296
294
|
case "shares":
|
|
297
295
|
case "unshare":
|
|
296
|
+
case "link":
|
|
297
|
+
case "links":
|
|
298
298
|
case "receive": {
|
|
299
299
|
const { runShare } = await import("./commands/share-dispatch.js");
|
|
300
300
|
return await runShare(args.command, args);
|
package/dist/mcp-tools/reads.js
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
// do next will call them repeatedly, and a surface where "just checking" costs money teaches
|
|
6
6
|
// the opposite of the habit this tool wants.
|
|
7
7
|
import { publicCode } from "../commands/public-code.js";
|
|
8
|
+
import { listCodes } from "../commands/public-code-manage.js";
|
|
9
|
+
import { isRecord } from "../guards.js";
|
|
8
10
|
import { balance } from "../commands/balance.js";
|
|
9
11
|
import { devices } from "../commands/devices.js";
|
|
10
12
|
import { legal, notices } from "../commands/documents.js";
|
|
@@ -122,13 +124,25 @@ export function readTools(ctx) {
|
|
|
122
124
|
},
|
|
123
125
|
{
|
|
124
126
|
name: "nmts_public_code",
|
|
125
|
-
description: "The account's PUBLIC
|
|
126
|
-
"
|
|
127
|
-
"
|
|
128
|
-
"
|
|
127
|
+
description: "The account's PUBLIC CODES — the values other accounts send files to. `code` is the " +
|
|
128
|
+
"default one (the lowest-numbered live code) and whether it is published; `codes` lists " +
|
|
129
|
+
"every code with its number, whether it is live or revoked, and how many shares and " +
|
|
130
|
+
"messages went through it; `live`, `liveMax`, `madeToday` and `dayCap` are the server's " +
|
|
131
|
+
"ceilings. With `activity`, each code also lists its shares. Until a code is published " +
|
|
132
|
+
"nobody can send to this account; nmts_public_code_new publishes one. ⚠ Not the NMTS " +
|
|
129
133
|
"key, which opens every file and is never given away.",
|
|
130
|
-
inputSchema:
|
|
131
|
-
|
|
134
|
+
inputSchema: {
|
|
135
|
+
type: "object",
|
|
136
|
+
properties: {
|
|
137
|
+
activity: { type: "boolean", description: "List each code's sent and received shares too." },
|
|
138
|
+
},
|
|
139
|
+
additionalProperties: false,
|
|
140
|
+
},
|
|
141
|
+
run: async (args) => {
|
|
142
|
+
const head = JSON.parse(await say((write) => publicCode({ ...common(ctx), json: true, write })));
|
|
143
|
+
const all = JSON.parse(await say((write) => listCodes({ ...common(ctx), json: true, activity: args["activity"] === true, write })));
|
|
144
|
+
return JSON.stringify({ ...(isRecord(head) ? head : {}), ...(isRecord(all) ? all : {}) });
|
|
145
|
+
},
|
|
132
146
|
},
|
|
133
147
|
{
|
|
134
148
|
name: "nmts_shares",
|
package/dist/mcp-tools/share.js
CHANGED
|
@@ -31,10 +31,51 @@
|
|
|
31
31
|
// ⛔ THE RECIPIENT'S PUBLIC CODE IS NOT CHECKED AGAINST A PERSON. A share sent to a well-formed
|
|
32
32
|
// code that belongs to somebody else is sent, and is not recallable. Confirm it with whoever
|
|
33
33
|
// gave it to you, out of band, before calling this.
|
|
34
|
+
import { newCode, revokeCodeCommand } from "../commands/public-code-manage.js";
|
|
34
35
|
import { share, unshare } from "../commands/share.js";
|
|
35
36
|
import { common, needString, say } from "./context.js";
|
|
37
|
+
/** A code's number from a tool call, as the command takes it. The schema already said it is an integer. */
|
|
38
|
+
function numberArg(args, name) {
|
|
39
|
+
const value = args[name];
|
|
40
|
+
return typeof value === "number" ? String(value) : undefined;
|
|
41
|
+
}
|
|
36
42
|
export function shareTools(ctx) {
|
|
37
43
|
return [
|
|
44
|
+
{
|
|
45
|
+
name: "nmts_public_code_new",
|
|
46
|
+
description: "Make a new public code for this account — the next number from the same NMTS key — and " +
|
|
47
|
+
"publish it, so other accounts can send files to it. `replace` names a live code to revoke " +
|
|
48
|
+
"in the same step: nobody can send to that one again and nobody can bring it back. The " +
|
|
49
|
+
"server caps how many codes are live at once and how many are made per UTC day; the reply " +
|
|
50
|
+
"of nmts_public_code says both.",
|
|
51
|
+
inputSchema: {
|
|
52
|
+
type: "object",
|
|
53
|
+
properties: {
|
|
54
|
+
replace: {
|
|
55
|
+
type: "integer",
|
|
56
|
+
description: "The number of a live code to revoke in the same step, from nmts_public_code.",
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
additionalProperties: false,
|
|
60
|
+
},
|
|
61
|
+
run: (args) => say((write) => newCode({ ...common(ctx), json: true, yes: true, replace: numberArg(args, "replace"), write })),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "nmts_public_code_revoke",
|
|
65
|
+
description: "Revoke one of this account's public codes, by its number from nmts_public_code. Nobody can " +
|
|
66
|
+
"send to it again and nobody can bring it back; files already received with it stay and " +
|
|
67
|
+
"still open. The account's last live code cannot be revoked — make a new one with " +
|
|
68
|
+
"nmts_public_code_new and `replace` instead.",
|
|
69
|
+
inputSchema: {
|
|
70
|
+
type: "object",
|
|
71
|
+
properties: {
|
|
72
|
+
index: { type: "integer", description: "The code's number, from nmts_public_code." },
|
|
73
|
+
},
|
|
74
|
+
required: ["index"],
|
|
75
|
+
additionalProperties: false,
|
|
76
|
+
},
|
|
77
|
+
run: (args) => say((write) => revokeCodeCommand(numberArg(args, "index"), { ...common(ctx), json: true, yes: true, write })),
|
|
78
|
+
},
|
|
38
79
|
{
|
|
39
80
|
name: "nmts_share",
|
|
40
81
|
description: "Give another NMTS account the key to one file in this account. ⛔ IT CANNOT BE TAKEN " +
|
|
@@ -53,6 +94,11 @@ export function shareTools(ctx) {
|
|
|
53
94
|
type: "string",
|
|
54
95
|
description: "The recipient's PUBLIC CODE, given to you by them. Not their NMTS key.",
|
|
55
96
|
},
|
|
97
|
+
as: {
|
|
98
|
+
type: "integer",
|
|
99
|
+
description: "Which of this account's live public codes sends it, by number from nmts_public_code. " +
|
|
100
|
+
"Absent: the lowest-numbered live one.",
|
|
101
|
+
},
|
|
56
102
|
},
|
|
57
103
|
required: ["path", "public_code"],
|
|
58
104
|
additionalProperties: false,
|
|
@@ -60,7 +106,7 @@ export function shareTools(ctx) {
|
|
|
60
106
|
run: async (args) => {
|
|
61
107
|
const path = needString(args, "path");
|
|
62
108
|
const code = needString(args, "public_code");
|
|
63
|
-
return say((write) => share(path, code, { ...common(ctx), json: true, write }));
|
|
109
|
+
return say((write) => share(path, code, { ...common(ctx), json: true, as: numberArg(args, "as"), write }));
|
|
64
110
|
},
|
|
65
111
|
},
|
|
66
112
|
{
|
package/dist/mcp-tools/tiers.js
CHANGED
|
@@ -12,6 +12,11 @@ import { unlocked } from "../gate.js";
|
|
|
12
12
|
import { BINARY_NAME } from "../product.js";
|
|
13
13
|
import { ACTS } from "../risk.js";
|
|
14
14
|
const READ = { act: "ls", readOnly: true };
|
|
15
|
+
/** The revoke question, naming the code by its number — the same words `nmts public-code revoke` asks. */
|
|
16
|
+
function revokeQuestion(index) {
|
|
17
|
+
return (`Revoke public code #${String(index)}? Nobody can send to it again, and nobody can bring it back. ` +
|
|
18
|
+
"Files already received with it stay.");
|
|
19
|
+
}
|
|
15
20
|
export const TOOL_TIERS = {
|
|
16
21
|
nmts_whoami: { act: "whoami", readOnly: true },
|
|
17
22
|
nmts_list: READ,
|
|
@@ -24,6 +29,15 @@ export const TOOL_TIERS = {
|
|
|
24
29
|
nmts_wallet_storage: { act: "wallet", readOnly: true },
|
|
25
30
|
nmts_devices: { act: "devices", readOnly: true },
|
|
26
31
|
nmts_public_code: { act: "public-code", readOnly: true },
|
|
32
|
+
// ⛔ A REPLACEMENT IS A REVOKE, and is asked as one — the act follows the arguments.
|
|
33
|
+
nmts_public_code_new: {
|
|
34
|
+
act: (args) => (typeof args["replace"] === "number" ? "public-code.revoke" : "public-code.new"),
|
|
35
|
+
question: (args) => typeof args["replace"] === "number"
|
|
36
|
+
? `Make a new public code for this account and revoke public code #${String(args["replace"])}? ` +
|
|
37
|
+
"Nobody can send to that one again, and nobody can bring it back. Files already received with it stay."
|
|
38
|
+
: "Make a new public code for this account. Go ahead?",
|
|
39
|
+
},
|
|
40
|
+
nmts_public_code_revoke: { act: "public-code.revoke", question: (args) => revokeQuestion(args["index"]) },
|
|
27
41
|
nmts_shares: { act: "shares", readOnly: true },
|
|
28
42
|
nmts_shares_sent: { act: "shares", readOnly: true },
|
|
29
43
|
nmts_notices: { act: "notices", readOnly: true },
|
|
@@ -54,7 +68,8 @@ export const TOOL_TIERS = {
|
|
|
54
68
|
nmts_restore: { act: "restore" },
|
|
55
69
|
nmts_share: {
|
|
56
70
|
act: "share",
|
|
57
|
-
question: (args) => `Share "${String(args["path"])}" with the NMTS account whose public code is ${String(args["public_code"])}
|
|
71
|
+
question: (args) => `Share "${String(args["path"])}" with the NMTS account whose public code is ${String(args["public_code"])}` +
|
|
72
|
+
`${typeof args["as"] === "number" ? `, from this account's public code #${String(args["as"])}` : ""}?\n\n` +
|
|
58
73
|
"Whoever holds that code can then download the file. Withdrawing the share afterwards stops " +
|
|
59
74
|
"further downloads and cannot reach a copy already fetched. The code is not checked against " +
|
|
60
75
|
"a person — if it is the wrong one, the file goes to whoever holds it.",
|
package/dist/portable.d.ts
CHANGED
|
@@ -17,6 +17,12 @@ export type { AccountIdentity } from "./account.ts";
|
|
|
17
17
|
export { AAD, DERIVED, loadCrypto } from "./crypto.ts";
|
|
18
18
|
export type { CryptoGlue } from "./crypto.ts";
|
|
19
19
|
export { isCryptoGlue, missingExports } from "./crypto-surface.ts";
|
|
20
|
+
export { CODE_INDEX_MAX, openShareAnyCode, openShareWithRing, requireCodeIndex, shareKeyRing, shareKeysAt, type ShareKeyRing, } from "./share-codes.ts";
|
|
21
|
+
export type { ShareKeys, ShareSealed } from "./share.ts";
|
|
22
|
+
export { defaultCode, ensureLiveCode, liveCodes, nextCodeIndex, publishCode, PUBLISH_TRIES, readPublicCodes, revokeCode, } from "./public-codes.ts";
|
|
23
|
+
export type { CodeDoor, PublicCodeList, PublicCodeRow, PublishedCode } from "./public-codes.ts";
|
|
24
|
+
export { codeActivity } from "./public-code-activity.ts";
|
|
25
|
+
export type { ActivityDoor, CodeActivity, ReceivedThrough, SentThrough } from "./public-code-activity.ts";
|
|
20
26
|
export { readFileList } from "./manifest.ts";
|
|
21
27
|
export type { FileList } from "./manifest.ts";
|
|
22
28
|
export { addEntry, applyManyToList, applyToList, planAddition } from "./manifest-write.ts";
|
|
@@ -51,6 +57,8 @@ export type { PlaintextSink } from "./download-sink.ts";
|
|
|
51
57
|
export { AGGREGATOR_ENV_VAR, readBlob, RELAY_ENV_VAR, SUI_RPC_ENV_VAR } from "./walrus.ts";
|
|
52
58
|
export { relayHost, storageNodesThrough, suiRpcHosts } from "./walrus.ts";
|
|
53
59
|
export type { ReadOptions } from "./walrus.ts";
|
|
60
|
+
export { listLinks, listLiveLinks, makeLink, openLink, revokeAllLinks, revokeLink } from "./links.ts";
|
|
61
|
+
export type { LinkAccount, ListedLink, MadeLink, OpenedLinkFile } from "./links.ts";
|
|
54
62
|
export { coinAmount, readBalances, walCoinType, walletAddress } from "./wallet.ts";
|
|
55
63
|
export type { ChainReader, CoinBalance, WalletBalances } from "./wallet.ts";
|
|
56
64
|
export { chainReader } from "./wallet-chain.ts";
|
package/dist/portable.js
CHANGED
|
@@ -41,6 +41,12 @@ export { AAD, DERIVED, loadCrypto } from "./crypto.js";
|
|
|
41
41
|
// runs its answer through this rather than trusting it.
|
|
42
42
|
export { isCryptoGlue, missingExports } from "./crypto-surface.js";
|
|
43
43
|
// The sealed file list: reading it, editing it, and walking it by path.
|
|
44
|
+
// Public codes (spec 2026-09-23): the numbered codes one key derives, the account's list of them on
|
|
45
|
+
// the server, and what each one was used for. `openShareAnyCode` is what opens a share whose code is
|
|
46
|
+
// not named — it tries the numbers it is given.
|
|
47
|
+
export { CODE_INDEX_MAX, openShareAnyCode, openShareWithRing, requireCodeIndex, shareKeyRing, shareKeysAt, } from "./share-codes.js";
|
|
48
|
+
export { defaultCode, ensureLiveCode, liveCodes, nextCodeIndex, publishCode, PUBLISH_TRIES, readPublicCodes, revokeCode, } from "./public-codes.js";
|
|
49
|
+
export { codeActivity } from "./public-code-activity.js";
|
|
44
50
|
export { readFileList } from "./manifest.js";
|
|
45
51
|
export { addEntry, applyManyToList, applyToList, planAddition } from "./manifest-write.js";
|
|
46
52
|
export { buildIndex, entryAt, folderIdFor, fullPathOf, isLive, KIND_FILE, KIND_FOLDER, namesIn, normalisePath, shown, trashedAt, } from "./drive-paths.js";
|
|
@@ -75,6 +81,8 @@ export { AGGREGATOR_ENV_VAR, readBlob, RELAY_ENV_VAR, SUI_RPC_ENV_VAR } from "./
|
|
|
75
81
|
// to rather than finding out from a request that went somewhere else. Each reads what the
|
|
76
82
|
// caller said first, then the environment, then the network's own.
|
|
77
83
|
export { relayHost, storageNodesThrough, suiRpcHosts } from "./walrus.js";
|
|
84
|
+
// Public links (NCF-3 §5.8): make, list, cut, and open without an account — `nmts link`'s four.
|
|
85
|
+
export { listLinks, listLiveLinks, makeLink, openLink, revokeAllLinks, revokeLink } from "./links.js";
|
|
78
86
|
// The wallet the NMTS key derives: reading it, and signing with it.
|
|
79
87
|
export { coinAmount, readBalances, walCoinType, walletAddress } from "./wallet.js";
|
|
80
88
|
export { chainReader } from "./wallet-chain.js";
|
package/dist/product.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare const BINARY_NAME = "nmts";
|
|
|
9
9
|
* beside it. Here rather than in `main.ts` because the MCP server has to say it too, and a
|
|
10
10
|
* command importing the entry point is a cycle waiting to bite.
|
|
11
11
|
*/
|
|
12
|
-
export declare const VERSION = "0.
|
|
12
|
+
export declare const VERSION = "0.48.1";
|
|
13
13
|
/** Where the product lives, for messages that need to send somebody somewhere real. */
|
|
14
14
|
export declare const HOME_URL = "https://nmts.me";
|
|
15
15
|
/** The source, so a person holding only the built program can find what it was built from. */
|
package/dist/product.js
CHANGED
|
@@ -18,7 +18,7 @@ export const BINARY_NAME = "nmts";
|
|
|
18
18
|
* beside it. Here rather than in `main.ts` because the MCP server has to say it too, and a
|
|
19
19
|
* command importing the entry point is a cycle waiting to bite.
|
|
20
20
|
*/
|
|
21
|
-
export const VERSION = "0.
|
|
21
|
+
export const VERSION = "0.48.1";
|
|
22
22
|
/** Where the product lives, for messages that need to send somebody somewhere real. */
|
|
23
23
|
export const HOME_URL = "https://nmts.me";
|
|
24
24
|
/** The source, so a person holding only the built program can find what it was built from. */
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { CryptoGlue } from "./crypto.ts";
|
|
2
|
+
import type { PublicCodeList } from "./public-codes.ts";
|
|
3
|
+
/** One share sent from a code. */
|
|
4
|
+
export interface SentThrough {
|
|
5
|
+
id: string;
|
|
6
|
+
itemId: string;
|
|
7
|
+
/** Where the file sits in this account, or null when the list no longer holds it. */
|
|
8
|
+
path: string | null;
|
|
9
|
+
/** The recipient's code in the form a person reads, or as the server sent it if it will not parse. */
|
|
10
|
+
recipient: string;
|
|
11
|
+
recipientRevoked: boolean;
|
|
12
|
+
createdAt: string;
|
|
13
|
+
}
|
|
14
|
+
/** One share received with a code. */
|
|
15
|
+
export interface ReceivedThrough {
|
|
16
|
+
id: string;
|
|
17
|
+
/** The name its sender sealed, or null when it would not open — `problem` says why. */
|
|
18
|
+
name: string | null;
|
|
19
|
+
sender: string | null;
|
|
20
|
+
senderRevoked: boolean;
|
|
21
|
+
createdAt: string;
|
|
22
|
+
problem: string | null;
|
|
23
|
+
}
|
|
24
|
+
export interface CodeActivity {
|
|
25
|
+
sent: SentThrough[];
|
|
26
|
+
received: ReceivedThrough[];
|
|
27
|
+
}
|
|
28
|
+
/** Where to ask and as whom — the account the code opens, on its server. */
|
|
29
|
+
export interface ActivityDoor {
|
|
30
|
+
server: string;
|
|
31
|
+
token: string;
|
|
32
|
+
accountId: string;
|
|
33
|
+
}
|
|
34
|
+
/** Every code's shares, by number. A code with none has two empty lists. */
|
|
35
|
+
export declare function codeActivity(crypt: CryptoGlue, code: string, door: ActivityDoor, list: PublicCodeList): Promise<Map<number, CodeActivity>>;
|