@needmoretruth/nmts-cli 0.42.0 → 0.44.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/AGENTS.md +1 -1
- package/CHANGELOG.md +41 -0
- package/README.ko.md +8 -2
- package/README.md +8 -2
- package/dist/account.d.ts +7 -3
- package/dist/account.js +46 -19
- package/dist/arg-options.d.ts +16 -0
- package/dist/args.js +5 -2
- package/dist/artifact-about.d.ts +1 -1
- package/dist/commands/ai-account.d.ts +34 -0
- package/dist/commands/ai-account.js +260 -0
- package/dist/commands/balance.d.ts +68 -0
- package/dist/commands/balance.js +11 -1
- package/dist/commands/extend.d.ts +3 -0
- package/dist/commands/extend.js +1 -0
- package/dist/commands/login.js +2 -2
- package/dist/commands/push-wallet.js +4 -1
- package/dist/commands/push.d.ts +3 -0
- package/dist/commands/put-payer.d.ts +3 -1
- package/dist/commands/put-payer.js +13 -1
- package/dist/commands/put-wallet.d.ts +31 -0
- package/dist/commands/put-wallet.js +84 -10
- package/dist/commands/put.d.ts +5 -0
- package/dist/commands/whoami.d.ts +4 -0
- package/dist/commands/whoami.js +14 -1
- package/dist/crypto-surface.d.ts +11 -0
- package/dist/crypto-surface.js +6 -0
- package/dist/drive-edit/tree.d.ts +12 -0
- package/dist/drive-edit/tree.js +25 -4
- package/dist/drive-erase.d.ts +5 -3
- package/dist/drive-erase.js +7 -2
- package/dist/help-options.d.ts +2 -0
- package/dist/help-options.js +142 -0
- package/dist/help.js +10 -123
- package/dist/main.js +14 -19
- package/dist/mcp-tools/reads.js +4 -3
- package/dist/portable.d.ts +1 -1
- package/dist/portable.js +1 -1
- package/dist/product.d.ts +1 -1
- package/dist/product.js +1 -1
- package/dist/refill-source.d.ts +69 -0
- package/dist/refill-source.js +143 -0
- package/dist/risk.d.ts +12 -0
- package/dist/risk.js +16 -0
- package/dist/shared/lib/wallet/activity.js +23 -1
- package/dist/standing-tip.d.ts +26 -0
- package/dist/standing-tip.js +31 -0
- package/dist/storage-control/extend.d.ts +10 -0
- package/dist/storage-control/extend.js +1 -1
- package/dist/upload-store.d.ts +10 -0
- package/dist/upload-wallet-plan.d.ts +8 -0
- package/dist/upload-wallet-plan.js +12 -3
- package/dist/upload-wallet-put.d.ts +16 -0
- package/dist/upload-wallet-put.js +4 -2
- package/dist/upload-wallet.d.ts +11 -0
- package/dist/upload-wallet.js +14 -0
- package/dist/wallet-sign-external.d.ts +120 -0
- package/dist/wallet-sign-external.js +221 -0
- package/dist/wallet-sign.js +3 -1
- package/dist/walrus.d.ts +9 -1
- package/dist/walrus.js +17 -3
- package/docs/commands/ai-account.md +25 -0
- package/docs/commands/login.md +4 -3
- package/docs/commands/verify.md +1 -1
- package/docs/commands/whoami.md +4 -0
- package/examples/podman.sh +48 -0
- package/package.json +6 -1
- package/server.json +2 -2
- package/vendor/nmts-crypto/nmts_crypto_wasm.d.ts +42 -6
- package/vendor/nmts-crypto/nmts_crypto_wasm.js +105 -2
- package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm +0 -0
- package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm.d.ts +9 -4
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// Paying with a wallet this tool holds no key to: the caller signs, this file submits and judges.
|
|
2
|
+
//
|
|
3
|
+
// ⛔ WHY IT IS NOT IN `wallet-sign.ts`. That file is the one place a key is derived from the NMTS
|
|
4
|
+
// key, and every signature in it is made by a keypair it builds itself. Here the key is somebody
|
|
5
|
+
// else's — a browser extension, a hardware wallet, a remote signer — and nothing below ever
|
|
6
|
+
// holds one. The TRANSACTIONS ARE THE SAME BUILDERS those signers use, so a wallet-paid upload
|
|
7
|
+
// buys exactly the same thing whoever signs it; what differs is who is asked.
|
|
8
|
+
//
|
|
9
|
+
// ⛔ THE NMTS KEY ARRIVES HERE AND IS NOT READ. The seams carry `code` and `wallet` because the
|
|
10
|
+
// keypair signers need them; every function below names only the fields it uses, so a reader can
|
|
11
|
+
// see that the account's key plays no part in a transaction somebody else's wallet signs.
|
|
12
|
+
//
|
|
13
|
+
// ⛔ THE SENDER IS THE PAYER'S ADDRESS, AND IT IS THE ADDRESS THE PRICE WAS MEASURED AGAINST. An
|
|
14
|
+
// upload and an extension take `payer` before they read a balance (`upload-wallet-put.ts`,
|
|
15
|
+
// `storage-control/extend.ts`), so the quote, both balances, the measured fee and the sentence
|
|
16
|
+
// that says where to send coins all name this wallet. A signer used without that payer would
|
|
17
|
+
// price one wallet and sign with another — which is why neither is reachable without the other.
|
|
18
|
+
//
|
|
19
|
+
// ⛔ ONE SIGNATURE IS SUBMITTED ONCE, HOWEVER OFTEN THE LINE DROPS. A transaction's digest is a hash
|
|
20
|
+
// of its bytes, so the same bytes are the same transaction: a submission whose reply was lost is
|
|
21
|
+
// looked up by that digest before anything is sent again. Re-signing instead would pay twice for
|
|
22
|
+
// a registration and be refused as "already certified" for a certification.
|
|
23
|
+
//
|
|
24
|
+
// ⛔ A DIGEST IS NOT A SUCCESS. A transaction that executed and FAILED has one, and its fee is
|
|
25
|
+
// spent; the effects are read and a failure is said as one, exactly as the keypair signers do.
|
|
26
|
+
//
|
|
27
|
+
// ⛔ EVERY TRANSACTION IS ONE CALL TO THE CALLER'S FUNCTION. Nothing here batches signatures,
|
|
28
|
+
// approves one silently or keeps a record of what was spent: a wallet outside this process
|
|
29
|
+
// decides each time, and a part of a file is a signature of its own.
|
|
30
|
+
//
|
|
31
|
+
// ⚠ WHAT IS SUBMITTED IS WHAT THE WALLET ANSWERED WITH. The wallet standard has a wallet hand back
|
|
32
|
+
// the bytes it signed, and some wallets adjust a transaction before signing one (a sponsor, a gas
|
|
33
|
+
// station); the signature is over those bytes, so those are the bytes that go to the chain. The
|
|
34
|
+
// effects read afterwards are what judge the result.
|
|
35
|
+
import { Transaction, TransactionDataBuilder } from "@mysten/sui/transactions";
|
|
36
|
+
import { fromBase64 } from "@mysten/sui/utils";
|
|
37
|
+
import { NmtsError } from "./errors.js";
|
|
38
|
+
import { walrusClient } from "./extend-chain.js";
|
|
39
|
+
import { isRecord } from "./guards.js";
|
|
40
|
+
import { isTransient, keepTrying } from "./net-retry.js";
|
|
41
|
+
import { storageOpTransaction } from "./storage-control-chain.js";
|
|
42
|
+
import { certifyTransaction, createdBlob, payingClient, registerTransaction } from "./upload-wallet-chain.js";
|
|
43
|
+
function why(error) {
|
|
44
|
+
return error instanceof Error ? error.message : String(error);
|
|
45
|
+
}
|
|
46
|
+
/** What a refused execution said, or null when the effects say it went through. */
|
|
47
|
+
function refusedBecause(result) {
|
|
48
|
+
const status = isRecord(result.effects) ? result.effects["status"] : undefined;
|
|
49
|
+
if (!isRecord(status) || status["status"] !== "failure")
|
|
50
|
+
return null;
|
|
51
|
+
const reason = status["error"];
|
|
52
|
+
return typeof reason === "string" ? reason : "no reason was given";
|
|
53
|
+
}
|
|
54
|
+
/** `sui:mainnet` or `sui:testnet` — what a wallet is told the transaction is for. */
|
|
55
|
+
function chainOf(network) {
|
|
56
|
+
return `sui:${network === "mainnet" ? "mainnet" : "testnet"}`;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* One transaction, from bytes to a judged result: ask the wallet, submit it once, read the effects.
|
|
60
|
+
*
|
|
61
|
+
* ⛔ THE ONLY THING THAT CAN THROW BEFORE A SIGNATURE EXISTS IS THE WALLET SAYING NO, and it is
|
|
62
|
+
* named `WALLET_REFUSED` rather than passed on as whatever the wallet threw: a person who
|
|
63
|
+
* declined is not a broken wallet, and a caller that cannot tell them apart shows the wrong
|
|
64
|
+
* sentence to somebody who did exactly what they meant to.
|
|
65
|
+
*/
|
|
66
|
+
export async function signAndSubmit(client, payer, input) {
|
|
67
|
+
let answered;
|
|
68
|
+
try {
|
|
69
|
+
answered = await payer.signTransaction({ bytes: input.bytes, chain: chainOf(input.network) });
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
throw new NmtsError(`WALLET_REFUSED: the wallet did not sign — ${why(error)}`, {
|
|
73
|
+
exitCode: 4,
|
|
74
|
+
nextStep: `${input.refusals.unsigned} A wallet refuses when somebody declines it, when it is on another network, or when it cannot sign this shape at all.`,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const signed = typeof answered.bytes === "string" ? fromBase64(answered.bytes) : answered.bytes;
|
|
78
|
+
const digest = TransactionDataBuilder.getDigestFromBytes(signed);
|
|
79
|
+
const options = { showEffects: true, showObjectChanges: true };
|
|
80
|
+
let sent = false;
|
|
81
|
+
const result = await keepTrying(async () => {
|
|
82
|
+
if (sent) {
|
|
83
|
+
// The attempt before this one may have reached the chain and lost only its reply. An
|
|
84
|
+
// unknown digest and a node that did not answer look the same here, and both mean "send
|
|
85
|
+
// the same bytes again" — which is safe precisely because they are the same bytes.
|
|
86
|
+
const seen = await client.getTransactionBlock({ digest, options }).catch(() => null);
|
|
87
|
+
if (seen !== null)
|
|
88
|
+
return seen;
|
|
89
|
+
}
|
|
90
|
+
sent = true;
|
|
91
|
+
return client.executeTransactionBlock({ transactionBlock: signed, signature: answered.signature, options });
|
|
92
|
+
}, { ...input.retry, retryable: isTransient });
|
|
93
|
+
// ⛔ SUCCESS IS ALREADY DECIDED BY THE EFFECTS BELOW. This wait is for what happens NEXT — the
|
|
94
|
+
// relay being told the digest, the blob object being read back — because a node that has not
|
|
95
|
+
// indexed the transaction yet answers those as if nothing had happened. A wait that times out
|
|
96
|
+
// changes nothing about what was signed, so it is not a failure of this transaction.
|
|
97
|
+
await client.waitForTransaction({ digest: result.digest }).catch(() => undefined);
|
|
98
|
+
const refused = refusedBecause(result);
|
|
99
|
+
if (refused !== null) {
|
|
100
|
+
throw new NmtsError(`${input.refusals.refused.what}: ${refused}.`, {
|
|
101
|
+
exitCode: 1,
|
|
102
|
+
nextStep: input.refusals.refused.nextStep,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The two halves of a wallet-paid upload, signed by a wallet outside this tool: registering one
|
|
109
|
+
* part's blob (which buys the storage or binds a held resource, and pays the relay's tip) and
|
|
110
|
+
* certifying it (gas only).
|
|
111
|
+
*
|
|
112
|
+
* ⛔ THE BUILDERS ARE `upload-wallet-chain.ts`'s OWN — the same ones the measured fee came from and
|
|
113
|
+
* the same ones the keypair signers use. What is registered, bought and tipped is therefore the
|
|
114
|
+
* same transaction whichever wallet signs it.
|
|
115
|
+
*/
|
|
116
|
+
export function externalBlobSigners(payer) {
|
|
117
|
+
return {
|
|
118
|
+
register: async ({ network, relayUrl, epochs, storage, part }) => {
|
|
119
|
+
const client = payingClient(network, relayUrl);
|
|
120
|
+
const tx = await registerTransaction(client, network, { epochs, storage, part, sender: payer.address });
|
|
121
|
+
const result = await signAndSubmit(client, payer, {
|
|
122
|
+
network,
|
|
123
|
+
bytes: await tx.build({ client }),
|
|
124
|
+
refusals: {
|
|
125
|
+
unsigned: "No storage was bought, nothing was sent, and the tip was not paid.",
|
|
126
|
+
refused: {
|
|
127
|
+
what: "The storage network refused the registration",
|
|
128
|
+
nextStep: `Nothing is stored and no storage was bought. The transaction fee was spent. The usual ` +
|
|
129
|
+
`causes are too little WAL or SUI in the paying wallet — ${payer.address} — or a held ` +
|
|
130
|
+
`storage resource too small for this part once encoded.`,
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
});
|
|
134
|
+
// The blob object is found by its type in what the transaction created, not by position.
|
|
135
|
+
return { digest: result.digest, ...(await createdBlob(client, result.objectChanges)) };
|
|
136
|
+
},
|
|
137
|
+
certify: async ({ network, relayUrl, blobId, blobObjectId, certificate }) => {
|
|
138
|
+
const client = payingClient(network, relayUrl);
|
|
139
|
+
const tx = certifyTransaction(client, { blobId, blobObjectId, certificate });
|
|
140
|
+
tx.setSender(payer.address);
|
|
141
|
+
const result = await signAndSubmit(client, payer, {
|
|
142
|
+
network,
|
|
143
|
+
bytes: await tx.build({ client }),
|
|
144
|
+
refusals: {
|
|
145
|
+
unsigned: "The storage is bought and the bytes are on the network; only the certification is unsigned. " +
|
|
146
|
+
"Running the same upload again asks for that one signature and buys nothing.",
|
|
147
|
+
refused: {
|
|
148
|
+
what: "The storage network refused the certification",
|
|
149
|
+
nextStep: `The storage is bought and the bytes are on the network; only the certification failed, ` +
|
|
150
|
+
`and its fee was spent. Running the same upload again certifies again, which costs gas ` +
|
|
151
|
+
`and nothing else.`,
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
return result.digest;
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Extending every blob under one file by `epochs`, in ONE transaction signed by a wallet outside
|
|
161
|
+
* this tool. The ids are de-duplicated: naming a blob twice pays for the same epochs twice.
|
|
162
|
+
*
|
|
163
|
+
* ⚠ The transaction is the shape `extend-chain.ts` measured the fee of — sender, de-duplicated ids,
|
|
164
|
+
* one fragment per blob — so what is approved is what was priced.
|
|
165
|
+
*/
|
|
166
|
+
export function externalExtendSigner(payer) {
|
|
167
|
+
return async ({ network, objectIds, epochs }) => {
|
|
168
|
+
const unique = [...new Set(objectIds)];
|
|
169
|
+
if (unique.length === 0) {
|
|
170
|
+
throw new NmtsError("There is nothing on this file that can be extended.", { exitCode: 4 });
|
|
171
|
+
}
|
|
172
|
+
if (!Number.isSafeInteger(epochs) || epochs <= 0) {
|
|
173
|
+
throw new NmtsError("An extension must be a positive whole number of epochs.", { exitCode: 2 });
|
|
174
|
+
}
|
|
175
|
+
const client = walrusClient(network);
|
|
176
|
+
const tx = new Transaction();
|
|
177
|
+
// The sender goes first: the fragments below pick this address's WAL when they resolve.
|
|
178
|
+
tx.setSender(payer.address);
|
|
179
|
+
for (const blobObjectId of unique)
|
|
180
|
+
tx.add(client.walrus.extendBlob({ blobObjectId, epochs }));
|
|
181
|
+
const result = await signAndSubmit(client, payer, {
|
|
182
|
+
network,
|
|
183
|
+
bytes: await tx.build({ client }),
|
|
184
|
+
refusals: {
|
|
185
|
+
unsigned: "The storage was NOT extended and the file still ends when it did. Nothing was spent.",
|
|
186
|
+
refused: {
|
|
187
|
+
what: "The storage network refused the extension",
|
|
188
|
+
nextStep: `The storage was NOT extended and the file still ends when it did. The transaction fee was ` +
|
|
189
|
+
`spent. The usual causes are too little WAL or SUI in the paying wallet — ${payer.address} — ` +
|
|
190
|
+
`or a length the network will no longer sell.`,
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
return result.digest;
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Cutting, joining or handing over a storage resource, signed by a wallet outside this tool.
|
|
199
|
+
*
|
|
200
|
+
* ⛔ THE RESOURCE MUST BE THAT WALLET'S. The review reads the resources at the address it was given
|
|
201
|
+
* and this signs as the same address, so a resource held somewhere else is refused by the chain
|
|
202
|
+
* rather than half-done here.
|
|
203
|
+
*/
|
|
204
|
+
export function externalStorageOpSigner(payer) {
|
|
205
|
+
return async ({ network, shape, walrusPackageId }) => {
|
|
206
|
+
const client = walrusClient(network);
|
|
207
|
+
const tx = storageOpTransaction(shape, { walrusPackageId, sender: payer.address });
|
|
208
|
+
const result = await signAndSubmit(client, payer, {
|
|
209
|
+
network,
|
|
210
|
+
bytes: await tx.build({ client }),
|
|
211
|
+
refusals: {
|
|
212
|
+
unsigned: "Nothing changed on the resource and nothing was spent.",
|
|
213
|
+
refused: {
|
|
214
|
+
what: "The chain refused it",
|
|
215
|
+
nextStep: "Nothing changed on the resource. The transaction fee was spent.",
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
});
|
|
219
|
+
return result.digest;
|
|
220
|
+
};
|
|
221
|
+
}
|
package/dist/wallet-sign.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
// ⛔ THE ONE FILE IN THIS TOOL THAT
|
|
1
|
+
// ⛔ THE ONE FILE IN THIS TOOL THAT HOLDS A KEY AND SIGNS WITH IT. (A wallet outside this tool signs
|
|
2
|
+
// through `wallet-sign-external.ts`, which builds the same transactions and holds no key at all.)
|
|
3
|
+
// Everything it can do moves real assets and cannot be
|
|
2
4
|
// reversed by anybody, including NMTS. It signs FIVE SHAPES and no others: extending a file's
|
|
3
5
|
// storage (`signExtension`), sending SUI or WAL to an address (`signTransfer`), swapping one for
|
|
4
6
|
// the other on a venue (`signSwap`), and the two halves of a wallet-paid upload — registering one
|
package/dist/walrus.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Curated Walrus aggregator (read) endpoints per network, preference order.
|
|
3
|
+
*
|
|
4
|
+
* ⭐ 2026-09-22: a SECOND one per network, so "if one is down we move on" is true rather than
|
|
5
|
+
* written. Both came from the canonical operator registry (https://docs.wal.app/operators.json)
|
|
6
|
+
* and both answered `GET /v1/api` with 200 the same day. The browser's table carries the full
|
|
7
|
+
* provenance and the reason each host and not another; this copy exists because this package
|
|
8
|
+
* imports nothing from that tree, and `deploy/check-walrus-hosts.mjs` set-compares the two.
|
|
9
|
+
*/
|
|
2
10
|
export declare const AGGREGATOR_HOSTS: Readonly<Record<string, readonly string[]>>;
|
|
3
11
|
/**
|
|
4
12
|
* Curated Walrus upload-relay (write) endpoints per network, preference order.
|
package/dist/walrus.js
CHANGED
|
@@ -14,10 +14,24 @@ import { AGGREGATOR_ENV_VAR, RELAY_ENV_VAR, SUI_RPC_ENV_VAR } from "./env-vars.j
|
|
|
14
14
|
import { NmtsError } from "./errors.js";
|
|
15
15
|
import { host as runtime } from "./host.js";
|
|
16
16
|
import { reach, reachFetch } from "./reach.js";
|
|
17
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Curated Walrus aggregator (read) endpoints per network, preference order.
|
|
19
|
+
*
|
|
20
|
+
* ⭐ 2026-09-22: a SECOND one per network, so "if one is down we move on" is true rather than
|
|
21
|
+
* written. Both came from the canonical operator registry (https://docs.wal.app/operators.json)
|
|
22
|
+
* and both answered `GET /v1/api` with 200 the same day. The browser's table carries the full
|
|
23
|
+
* provenance and the reason each host and not another; this copy exists because this package
|
|
24
|
+
* imports nothing from that tree, and `deploy/check-walrus-hosts.mjs` set-compares the two.
|
|
25
|
+
*/
|
|
18
26
|
export const AGGREGATOR_HOSTS = {
|
|
19
|
-
testnet: [
|
|
20
|
-
|
|
27
|
+
testnet: [
|
|
28
|
+
"https://aggregator.walrus-testnet.walrus.space",
|
|
29
|
+
"https://walrus-testnet-aggregator.nodeinfra.com",
|
|
30
|
+
],
|
|
31
|
+
mainnet: [
|
|
32
|
+
"https://aggregator.walrus-mainnet.walrus.space",
|
|
33
|
+
"https://sui-walrus-mainnet-aggregator.bwarelabs.com",
|
|
34
|
+
],
|
|
21
35
|
};
|
|
22
36
|
/**
|
|
23
37
|
* Curated Walrus upload-relay (write) endpoints per network, preference order.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# nmts ai-account — accounts made under this one for an AI to work in
|
|
2
|
+
|
|
3
|
+
Commands: ai-account
|
|
4
|
+
Tiers: ai-account=none · ai-account.create=high · ai-account.delete=ultra-high
|
|
5
|
+
|
|
6
|
+
An AI account is an ordinary NMTS account with its own NMTS key, its own wallet and its own empty
|
|
7
|
+
drive, made under this one. It exists so that a program never has to be handed this account's key,
|
|
8
|
+
which would hand it the files, the wallet and the right to erase. Files reach it by being shared
|
|
9
|
+
with it; credits and coins reach it the way they reach any account.
|
|
10
|
+
|
|
11
|
+
All three verbs need the NMTS key on this machine and prove it the way a sign-in does. An API key
|
|
12
|
+
cannot reach any of them, on purpose: an agent that could make AI accounts could make more of
|
|
13
|
+
itself, and revoking its key would mean nothing.
|
|
14
|
+
|
|
15
|
+
`ai-account` and `ai-account list` read, and print one line per account: its place (1 to 3), its
|
|
16
|
+
account id, whether it is active or stopped, and the day it was made.
|
|
17
|
+
|
|
18
|
+
`ai-account create [place]` makes one at the lowest free place, or at the place you name. The new
|
|
19
|
+
account's NMTS key is derived here from this account's key and that place — it is never sent — and
|
|
20
|
+
printed once. The same place always gives the same key back, so a place that is erased can be
|
|
21
|
+
re-used and a key that is lost can be derived again. The first one under an account is made in a
|
|
22
|
+
browser instead: turning the feature on costs a human check no terminal can pass.
|
|
23
|
+
|
|
24
|
+
`ai-account delete <account id>` erases one and everything in it, permanently. It types the same
|
|
25
|
+
sentence erasing an account does, and no auto mode reaches it.
|
package/docs/commands/login.md
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
Commands: login
|
|
4
4
|
Tiers: login=none · login.plain=high(unsafe-code-storage) · login.env=high(plain-env)
|
|
5
5
|
|
|
6
|
-
`nmts login`
|
|
7
|
-
(`NMTS_API_KEY_FILE`, `NMTS_API_KEY`) with the
|
|
8
|
-
|
|
6
|
+
`nmts login` takes the NMTS key or its 15-word recovery phrase, stores the key sealed under a
|
|
7
|
+
passphrase, checks whichever API key it finds (`NMTS_API_KEY_FILE`, `NMTS_API_KEY`) with the
|
|
8
|
+
server, and stores that too. It prints the key's public handle and never the key. It does not
|
|
9
|
+
replace a stored key unless the run says so.
|
|
9
10
|
|
|
10
11
|
Every later command needs the passphrase, from `NMTS_PASSPHRASE` or a terminal. A sealed key with
|
|
11
12
|
no passphrase in reach is not a usable credential; `nmts env` says which case this machine is in.
|
package/docs/commands/verify.md
CHANGED
|
@@ -4,7 +4,7 @@ Commands: verify
|
|
|
4
4
|
Tiers: verify=none
|
|
5
5
|
|
|
6
6
|
The server keeps "has a person checked in lately" as a separate question from "is this a valid
|
|
7
|
-
key", and the answer expires every
|
|
7
|
+
key", and the answer expires every twelve weeks. It does not gate the work: reading, writing,
|
|
8
8
|
listing, folders, the trash, the recovery files and the wallet's balances never ask about it.
|
|
9
9
|
Exactly three things do — making another account, the free trial, and creating a share — and
|
|
10
10
|
while it is lapsed the account runs in a tighter rate tier (slower, not refused) and some requests
|
package/docs/commands/whoami.md
CHANGED
|
@@ -10,3 +10,7 @@ to a program.
|
|
|
10
10
|
key — so it is locked until a person runs `nmts unlock reveal` at a terminal, and then asked about
|
|
11
11
|
on every run in every mode but skip-permissions. Never write the NMTS key anywhere it can be read
|
|
12
12
|
again: a log, a commit, a file, a message. It is the only key to the account and cannot be rotated.
|
|
13
|
+
|
|
14
|
+
`--reveal --phrase` prints the same key as its 15-word recovery phrase (BIP-39, the English list;
|
|
15
|
+
`--lang ko` for the Korean one). It is the key in words, under the same lock and the same warning:
|
|
16
|
+
whoever reads the phrase opens the account.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Running this tool in a rootless Podman container, with the NMTS key handed in as a secret.
|
|
3
|
+
#
|
|
4
|
+
# sh examples/podman.sh ls
|
|
5
|
+
# sh examples/podman.sh put ./notes.txt
|
|
6
|
+
#
|
|
7
|
+
# ⛔ THE KEY IS NEVER AN ENVIRONMENT VALUE. `podman inspect` prints a container's whole environment,
|
|
8
|
+
# and so does `docker inspect`; a variable holding the key hands it to anybody who can run
|
|
9
|
+
# either. What the variable below holds is a PATH. The key itself arrives on a tmpfs that Podman
|
|
10
|
+
# mounts for this container alone, and it is not in the image, not in the history, and not in the
|
|
11
|
+
# inspect output.
|
|
12
|
+
#
|
|
13
|
+
# ⛔ NOTHING HERE NEEDS ROOT. Podman builds, stores the secret and runs the container as the user
|
|
14
|
+
# who invoked it; the image runs as an ordinary user inside that. `sudo` on any line of this file
|
|
15
|
+
# would make the config volume root's and the tool unable to write to it.
|
|
16
|
+
#
|
|
17
|
+
# ⚠ THE SECRET IS STORED UNTIL IT IS REMOVED. `podman secret rm nmts-key` takes it out again. It
|
|
18
|
+
# lives in the invoking user's own Podman store, readable by that user — the same standing as the
|
|
19
|
+
# file it came from, which is why this is worth nothing if that file is world-readable.
|
|
20
|
+
set -eu
|
|
21
|
+
|
|
22
|
+
# The file on THIS machine that holds the NMTS key. The same variable name the tool reads on a
|
|
23
|
+
# machine with no container, so one habit covers both.
|
|
24
|
+
key_file="${NMTS_ACCOUNT_CODE_FILE:?name the file holding your NMTS key in NMTS_ACCOUNT_CODE_FILE}"
|
|
25
|
+
image=nmts
|
|
26
|
+
secret=nmts-key
|
|
27
|
+
volume=nmts-config
|
|
28
|
+
|
|
29
|
+
# Built from the repository this file is in — there is no published image.
|
|
30
|
+
podman image exists "$image" || podman build -t "$image" .
|
|
31
|
+
|
|
32
|
+
# ⚠ Created only when it is not there. `podman secret create` on a name that exists is an error, and
|
|
33
|
+
# a script that swallowed it would keep using a secret made from an older file.
|
|
34
|
+
podman secret inspect "$secret" >/dev/null 2>&1 || podman secret create "$secret" "$key_file"
|
|
35
|
+
|
|
36
|
+
# ⛔ THE CONFIG DIRECTORY OUTLIVES THE CONTAINER, and it has to. Unlocks and the mode live there; a
|
|
37
|
+
# container that is removed takes them with it, so the wallet and sharing would ask again on
|
|
38
|
+
# every run and an upload would be refused in a mode nobody set.
|
|
39
|
+
#
|
|
40
|
+
# ⚠ `--secret <name>` mounts the value at /run/secrets/<name>. A bind mount reaches the same place
|
|
41
|
+
# — `--mount type=bind,src=$key_file,dst=/run/secrets/nmts-key,ro` — for a host that keeps its
|
|
42
|
+
# secrets somewhere Podman's store is not.
|
|
43
|
+
exec podman run --rm \
|
|
44
|
+
--secret "$secret" \
|
|
45
|
+
-e NMTS_ACCOUNT_CODE_FILE=/run/secrets/nmts-key \
|
|
46
|
+
-v "$volume":/config \
|
|
47
|
+
-e NMTS_CONFIG_DIR=/config \
|
|
48
|
+
"$image" "$@"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needmoretruth/nmts-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.0",
|
|
4
4
|
"description": "Command-line and MCP access to NMTS (NeedMoreTruthStorage, https://nmts.me): open-source, end-to-end encrypted storage on the Walrus network. No fee to NMTS; you pay the network from your own wallet. For people and for their agents.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"publishConfig": {
|
|
@@ -109,6 +109,10 @@
|
|
|
109
109
|
"types": "./dist/wallet-sign.d.ts",
|
|
110
110
|
"default": "./dist/wallet-sign.js"
|
|
111
111
|
},
|
|
112
|
+
"./wallet-sign-external": {
|
|
113
|
+
"types": "./dist/wallet-sign-external.d.ts",
|
|
114
|
+
"default": "./dist/wallet-sign-external.js"
|
|
115
|
+
},
|
|
112
116
|
"./vendor/nmts-crypto/*": "./vendor/nmts-crypto/*",
|
|
113
117
|
"./package.json": "./package.json"
|
|
114
118
|
},
|
|
@@ -118,6 +122,7 @@
|
|
|
118
122
|
"files": [
|
|
119
123
|
"dist",
|
|
120
124
|
"vendor",
|
|
125
|
+
"examples",
|
|
121
126
|
"README.md",
|
|
122
127
|
"AGENTS.md",
|
|
123
128
|
"docs",
|
package/server.json
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
"url": "https://github.com/needmoretruth/nmts-cli",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.44.0",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
14
14
|
"identifier": "@needmoretruth/nmts-cli",
|
|
15
|
-
"version": "0.
|
|
15
|
+
"version": "0.44.0",
|
|
16
16
|
"transport": {
|
|
17
17
|
"type": "stdio"
|
|
18
18
|
},
|
|
@@ -138,11 +138,18 @@ export function account_code_display(code_bytes: Uint8Array): string;
|
|
|
138
138
|
export function account_code_generate(): string;
|
|
139
139
|
|
|
140
140
|
/**
|
|
141
|
-
* Parses+validates a user-entered account code (any spacing/case)
|
|
142
|
-
* bytes. Errors if the check symbol
|
|
141
|
+
* Parses+validates a user-entered account code (any spacing/case) OR its 15-word recovery
|
|
142
|
+
* phrase, returning the 20 raw bytes. Errors if the check symbol or the phrase's
|
|
143
|
+
* checksum fails. A phrase error's message starts with `phrase:` (`phrase:count:12` ·
|
|
144
|
+
* `phrase:word:5` · `phrase:checksum`) so a screen can say which one.
|
|
143
145
|
*/
|
|
144
146
|
export function account_code_parse(input: string): Uint8Array;
|
|
145
147
|
|
|
148
|
+
/**
|
|
149
|
+
* The 15-word recovery phrase for 20 raw account-code bytes, in `en` or `ko`.
|
|
150
|
+
*/
|
|
151
|
+
export function account_code_phrase(code_bytes: Uint8Array, lang: string): string;
|
|
152
|
+
|
|
146
153
|
/**
|
|
147
154
|
* Unpadded base64url of arbitrary bytes. The textual `accountId` is
|
|
148
155
|
* `b64_encode(account_id_16_bytes)`.
|
|
@@ -303,6 +310,30 @@ export function opener_open(serialized_signature: Uint8Array, slot: Uint8Array):
|
|
|
303
310
|
*/
|
|
304
311
|
export function opener_seal(serialized_signature: Uint8Array, nmts_key: Uint8Array): Uint8Array;
|
|
305
312
|
|
|
313
|
+
/**
|
|
314
|
+
* The 16-byte LOCATOR a passkey's 32-byte PRF result yields — what a passkey sign-in asks the
|
|
315
|
+
* server for (NCF-3 §1.7). Throws for a result of any other length.
|
|
316
|
+
*/
|
|
317
|
+
export function passkey_locator(prf: Uint8Array): Uint8Array;
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* The 20 NMTS-key bytes inside a passkey's slot. One indistinguishable refusal for a different
|
|
321
|
+
* passkey or altered bytes, for the reason `opener_open` gives.
|
|
322
|
+
*/
|
|
323
|
+
export function passkey_open(prf: Uint8Array, slot: Uint8Array): Uint8Array;
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* The PRF salt every NMTS passkey is asked about (NCF-3 §1.7): SHA-256 of
|
|
327
|
+
* `nmts/v3/passkey-prf/1`. The page passes these 32 bytes as WebAuthn `prf.eval.first`.
|
|
328
|
+
*/
|
|
329
|
+
export function passkey_prf_salt(): Uint8Array;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* The 62-byte SLOT holding `nmts_key` under a passkey's PRF result — kind `0x02`, a fresh nonce
|
|
333
|
+
* from WebCrypto, the same layout as a wallet's slot.
|
|
334
|
+
*/
|
|
335
|
+
export function passkey_seal(prf: Uint8Array, nmts_key: Uint8Array): Uint8Array;
|
|
336
|
+
|
|
306
337
|
/**
|
|
307
338
|
* The name this account's recovery manifest is stored under inside a quilt (NCF-3 §2.5).
|
|
308
339
|
*
|
|
@@ -465,9 +496,6 @@ export interface InitOutput {
|
|
|
465
496
|
readonly __wbg_sha256hasher_free: (a: number, b: number) => void;
|
|
466
497
|
readonly __wbg_streamdecryptor_free: (a: number, b: number) => void;
|
|
467
498
|
readonly __wbg_streamencryptor_free: (a: number, b: number) => void;
|
|
468
|
-
readonly account_code_display: (a: number, b: number) => [number, number, number, number];
|
|
469
|
-
readonly account_code_generate: () => [number, number];
|
|
470
|
-
readonly account_code_parse: (a: number, b: number) => [number, number, number, number];
|
|
471
499
|
readonly b64_encode: (a: number, b: number) => [number, number];
|
|
472
500
|
readonly derive_ai_account_code: (a: number, b: number, c: number) => [number, number, number, number];
|
|
473
501
|
readonly device_wrap_key: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
@@ -505,12 +533,20 @@ export interface InitOutput {
|
|
|
505
533
|
readonly streamencryptor_push: (a: number, b: number, c: number) => [number, number, number, number];
|
|
506
534
|
readonly streamencryptor_resumeFromHeader: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
507
535
|
readonly verify_part_set: (a: number, b: number) => [number, number];
|
|
508
|
-
readonly voucher_hash_from_input: (a: number, b: number) => [number, number];
|
|
509
536
|
readonly wallet_seed_for: (a: number, b: number, c: number) => [number, number, number, number];
|
|
510
537
|
readonly opener_locator: (a: number, b: number) => [number, number, number, number];
|
|
511
538
|
readonly opener_message: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
512
539
|
readonly opener_open: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
513
540
|
readonly opener_seal: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
541
|
+
readonly passkey_locator: (a: number, b: number) => [number, number, number, number];
|
|
542
|
+
readonly passkey_open: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
543
|
+
readonly passkey_prf_salt: () => [number, number];
|
|
544
|
+
readonly passkey_seal: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
545
|
+
readonly account_code_display: (a: number, b: number) => [number, number, number, number];
|
|
546
|
+
readonly account_code_generate: () => [number, number];
|
|
547
|
+
readonly account_code_parse: (a: number, b: number) => [number, number, number, number];
|
|
548
|
+
readonly account_code_phrase: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
549
|
+
readonly voucher_hash_from_input: (a: number, b: number) => [number, number];
|
|
514
550
|
readonly __wbindgen_exn_store: (a: number) => void;
|
|
515
551
|
readonly __externref_table_alloc: () => number;
|
|
516
552
|
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
@@ -314,8 +314,10 @@ export function account_code_generate() {
|
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
/**
|
|
317
|
-
* Parses+validates a user-entered account code (any spacing/case)
|
|
318
|
-
* bytes. Errors if the check symbol
|
|
317
|
+
* Parses+validates a user-entered account code (any spacing/case) OR its 15-word recovery
|
|
318
|
+
* phrase, returning the 20 raw bytes. Errors if the check symbol or the phrase's
|
|
319
|
+
* checksum fails. A phrase error's message starts with `phrase:` (`phrase:count:12` ·
|
|
320
|
+
* `phrase:word:5` · `phrase:checksum`) so a screen can say which one.
|
|
319
321
|
* @param {string} input
|
|
320
322
|
* @returns {Uint8Array}
|
|
321
323
|
*/
|
|
@@ -331,6 +333,35 @@ export function account_code_parse(input) {
|
|
|
331
333
|
return v2;
|
|
332
334
|
}
|
|
333
335
|
|
|
336
|
+
/**
|
|
337
|
+
* The 15-word recovery phrase for 20 raw account-code bytes, in `en` or `ko`.
|
|
338
|
+
* @param {Uint8Array} code_bytes
|
|
339
|
+
* @param {string} lang
|
|
340
|
+
* @returns {string}
|
|
341
|
+
*/
|
|
342
|
+
export function account_code_phrase(code_bytes, lang) {
|
|
343
|
+
let deferred4_0;
|
|
344
|
+
let deferred4_1;
|
|
345
|
+
try {
|
|
346
|
+
const ptr0 = passArray8ToWasm0(code_bytes, wasm.__wbindgen_malloc);
|
|
347
|
+
const len0 = WASM_VECTOR_LEN;
|
|
348
|
+
const ptr1 = passStringToWasm0(lang, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
349
|
+
const len1 = WASM_VECTOR_LEN;
|
|
350
|
+
const ret = wasm.account_code_phrase(ptr0, len0, ptr1, len1);
|
|
351
|
+
var ptr3 = ret[0];
|
|
352
|
+
var len3 = ret[1];
|
|
353
|
+
if (ret[3]) {
|
|
354
|
+
ptr3 = 0; len3 = 0;
|
|
355
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
356
|
+
}
|
|
357
|
+
deferred4_0 = ptr3;
|
|
358
|
+
deferred4_1 = len3;
|
|
359
|
+
return getStringFromWasm0(ptr3, len3);
|
|
360
|
+
} finally {
|
|
361
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
334
365
|
/**
|
|
335
366
|
* Unpadded base64url of arbitrary bytes. The textual `accountId` is
|
|
336
367
|
* `b64_encode(account_id_16_bytes)`.
|
|
@@ -707,6 +738,78 @@ export function opener_seal(serialized_signature, nmts_key) {
|
|
|
707
738
|
return v3;
|
|
708
739
|
}
|
|
709
740
|
|
|
741
|
+
/**
|
|
742
|
+
* The 16-byte LOCATOR a passkey's 32-byte PRF result yields — what a passkey sign-in asks the
|
|
743
|
+
* server for (NCF-3 §1.7). Throws for a result of any other length.
|
|
744
|
+
* @param {Uint8Array} prf
|
|
745
|
+
* @returns {Uint8Array}
|
|
746
|
+
*/
|
|
747
|
+
export function passkey_locator(prf) {
|
|
748
|
+
const ptr0 = passArray8ToWasm0(prf, wasm.__wbindgen_malloc);
|
|
749
|
+
const len0 = WASM_VECTOR_LEN;
|
|
750
|
+
const ret = wasm.passkey_locator(ptr0, len0);
|
|
751
|
+
if (ret[3]) {
|
|
752
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
753
|
+
}
|
|
754
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
755
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
756
|
+
return v2;
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* The 20 NMTS-key bytes inside a passkey's slot. One indistinguishable refusal for a different
|
|
761
|
+
* passkey or altered bytes, for the reason `opener_open` gives.
|
|
762
|
+
* @param {Uint8Array} prf
|
|
763
|
+
* @param {Uint8Array} slot
|
|
764
|
+
* @returns {Uint8Array}
|
|
765
|
+
*/
|
|
766
|
+
export function passkey_open(prf, slot) {
|
|
767
|
+
const ptr0 = passArray8ToWasm0(prf, wasm.__wbindgen_malloc);
|
|
768
|
+
const len0 = WASM_VECTOR_LEN;
|
|
769
|
+
const ptr1 = passArray8ToWasm0(slot, wasm.__wbindgen_malloc);
|
|
770
|
+
const len1 = WASM_VECTOR_LEN;
|
|
771
|
+
const ret = wasm.passkey_open(ptr0, len0, ptr1, len1);
|
|
772
|
+
if (ret[3]) {
|
|
773
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
774
|
+
}
|
|
775
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
776
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
777
|
+
return v3;
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* The PRF salt every NMTS passkey is asked about (NCF-3 §1.7): SHA-256 of
|
|
782
|
+
* `nmts/v3/passkey-prf/1`. The page passes these 32 bytes as WebAuthn `prf.eval.first`.
|
|
783
|
+
* @returns {Uint8Array}
|
|
784
|
+
*/
|
|
785
|
+
export function passkey_prf_salt() {
|
|
786
|
+
const ret = wasm.passkey_prf_salt();
|
|
787
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
788
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
789
|
+
return v1;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* The 62-byte SLOT holding `nmts_key` under a passkey's PRF result — kind `0x02`, a fresh nonce
|
|
794
|
+
* from WebCrypto, the same layout as a wallet's slot.
|
|
795
|
+
* @param {Uint8Array} prf
|
|
796
|
+
* @param {Uint8Array} nmts_key
|
|
797
|
+
* @returns {Uint8Array}
|
|
798
|
+
*/
|
|
799
|
+
export function passkey_seal(prf, nmts_key) {
|
|
800
|
+
const ptr0 = passArray8ToWasm0(prf, wasm.__wbindgen_malloc);
|
|
801
|
+
const len0 = WASM_VECTOR_LEN;
|
|
802
|
+
const ptr1 = passArray8ToWasm0(nmts_key, wasm.__wbindgen_malloc);
|
|
803
|
+
const len1 = WASM_VECTOR_LEN;
|
|
804
|
+
const ret = wasm.passkey_seal(ptr0, len0, ptr1, len1);
|
|
805
|
+
if (ret[3]) {
|
|
806
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
807
|
+
}
|
|
808
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
809
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
810
|
+
return v3;
|
|
811
|
+
}
|
|
812
|
+
|
|
710
813
|
/**
|
|
711
814
|
* The name this account's recovery manifest is stored under inside a quilt (NCF-3 §2.5).
|
|
712
815
|
*
|
|
Binary file
|