@needmoretruth/nmts-cli 0.54.2 → 0.56.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/CHANGELOG.md +22 -0
- package/README.ko.md +9 -1
- package/README.md +9 -1
- package/dist/artifact-about.d.ts +1 -1
- package/dist/commands/push.js +1 -1
- package/dist/commands/put-wallet.js +12 -12
- package/dist/commands/put.js +1 -1
- package/dist/commands/recovery-list.js +3 -2
- package/dist/crypto-surface.d.ts +2 -0
- package/dist/crypto-surface.js +4 -7
- package/dist/manifest.js +3 -0
- package/dist/node-read.d.ts +2 -0
- package/dist/node-read.js +24 -0
- package/dist/portable.d.ts +2 -0
- package/dist/portable.js +3 -0
- package/dist/product.d.ts +1 -1
- package/dist/product.js +1 -1
- package/dist/read-race.d.ts +35 -0
- package/dist/read-race.js +91 -0
- package/dist/recovery-assemble.d.ts +4 -11
- package/dist/recovery-assemble.js +25 -106
- package/dist/recovery-build.d.ts +7 -1
- package/dist/recovery-build.js +15 -11
- package/dist/recovery-seq.d.ts +2 -2
- package/dist/recovery-seq.js +30 -23
- package/dist/recovery.d.ts +92 -0
- package/dist/recovery.js +202 -0
- package/dist/road-hosts.generated.d.ts +4 -0
- package/dist/road-hosts.generated.js +284 -0
- package/dist/shared/lib/upload/wallet-storage-estimate.d.ts +16 -0
- package/dist/shared/lib/upload/wallet-storage-estimate.js +44 -0
- package/dist/shared/lib/wallet/graphql-history.d.ts +7 -2
- package/dist/shared/lib/wallet/graphql-history.js +7 -2
- package/dist/shared/lib/walrus/credit-tip.d.ts +24 -0
- package/dist/shared/lib/walrus/credit-tip.js +61 -0
- package/dist/shared/lib/walrus/node-certificate.d.ts +18 -0
- package/dist/shared/lib/walrus/node-certificate.js +77 -0
- package/dist/shared/lib/walrus/node-quorum.d.ts +17 -0
- package/dist/shared/lib/walrus/node-quorum.js +103 -0
- package/dist/shared/lib/walrus/tip-config.d.ts +33 -0
- package/dist/shared/lib/walrus/tip-config.js +68 -0
- package/dist/upload-file.d.ts +2 -0
- package/dist/upload-file.js +6 -0
- package/dist/upload-recovery-patch.d.ts +65 -0
- package/dist/upload-recovery-patch.js +250 -0
- package/dist/upload-road.d.ts +26 -4
- package/dist/upload-road.js +79 -17
- package/dist/upload-steps.js +5 -1
- package/dist/upload-wallet-chain.d.ts +1 -1
- package/dist/upload-wallet-chain.js +11 -4
- package/dist/upload-wallet-plan.d.ts +4 -0
- package/dist/upload-wallet-plan.js +18 -8
- package/dist/upload-wallet-put.d.ts +6 -2
- package/dist/upload-wallet-put.js +30 -17
- package/dist/upload-wallet.d.ts +4 -1
- package/dist/upload-wallet.js +12 -3
- package/dist/upload-wire.d.ts +27 -0
- package/dist/upload-wire.js +2 -0
- package/dist/upload.js +3 -3
- package/dist/walrus-write.js +80 -3
- package/dist/walrus.d.ts +20 -4
- package/dist/walrus.js +115 -36
- package/docs/commands/put.md +5 -1
- package/package.json +5 -1
- package/server.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
Each version's entry is what changed for the person or the program using `nmts`. The product's own
|
|
4
4
|
update history, which covers the site and the server too, is at https://nmts.me/updates.
|
|
5
5
|
|
|
6
|
+
## 0.56.0 — 2026-11-10
|
|
7
|
+
|
|
8
|
+
- With the account's storage copy of the recovery list switched on, `put --pay wallet` of a one-part
|
|
9
|
+
file under 64 MiB onto new storage uploads the newest recovery list in the same quilt, as the web
|
|
10
|
+
app does. The standalone recovery program then finds that list with the NMTS key alone. The WAL in
|
|
11
|
+
the review includes the list, and a list that cannot go along never stops the upload.
|
|
12
|
+
- A program can build the recovery list without the command: `@needmoretruth/nmts-cli/recovery`
|
|
13
|
+
exports `makeRecoveryList`, `readRecoveryCopy` and `setRecoveryCopy`, and runs in a browser as well
|
|
14
|
+
as in Node. `nmts recovery-list` writes the same file as before.
|
|
15
|
+
|
|
16
|
+
## 0.55.0 — 2026-11-10
|
|
17
|
+
|
|
18
|
+
- Uploads (`put`, `push`) keep working when every company's upload relay is down. The order is now
|
|
19
|
+
Mysten Labs' relay, then Studio Mirai's relay, then the Walrus storage nodes straight from this
|
|
20
|
+
machine, and NMTS's own relay last. On the direct road the tool encodes the file itself and sends
|
|
21
|
+
about five times its size, with no relay fee; it stops once the storage nodes holding enough of
|
|
22
|
+
the network's shards have confirmed, which is the rule the chain checks.
|
|
23
|
+
- Uploads paid with credits can now go through Studio Mirai's relay too, but only while its fee for
|
|
24
|
+
that upload is at most three times Mysten Labs' fee; above that the upload goes to the storage nodes.
|
|
25
|
+
- `get` and the other downloads read the file from the storage nodes when no aggregator answers.
|
|
26
|
+
- Sui reads fall back to 01NODE and then PublicNode after Suiscan and Mysten Labs.
|
|
27
|
+
|
|
6
28
|
## 0.54.2 — 2026-11-09
|
|
7
29
|
|
|
8
30
|
- When Mysten Labs' upload relay does not answer, uploads (`put`, `push`) now go through NMTS's own
|
package/README.ko.md
CHANGED
|
@@ -50,7 +50,7 @@ nmts --help
|
|
|
50
50
|
|
|
51
51
|
```sh
|
|
52
52
|
npm install -g github:needmoretruth/nmts-cli # 기본 브랜치
|
|
53
|
-
npm install -g github:needmoretruth/nmts-cli#v0.
|
|
53
|
+
npm install -g github:needmoretruth/nmts-cli#v0.56.0 # 버전을 고정할 때
|
|
54
54
|
npm install -g https://github.com/needmoretruth/nmts-cli/releases/latest/download/nmts.tgz
|
|
55
55
|
```
|
|
56
56
|
|
|
@@ -362,6 +362,14 @@ NMTS 키는 들어 있지 않습니다. `kit`은 그 목록과 NMTS 키를 한
|
|
|
362
362
|
목록을 잃은 계정의 파일 목록을 서버의 줄로 다시 짓습니다. 키·해시·날짜·크기는 돌아오고 이름과
|
|
363
363
|
폴더는 돌아오지 않습니다.
|
|
364
364
|
|
|
365
|
+
계정에서 복구 목록의 Walrus 사본을 켜 두었으면(웹 앱에서, 또는 SDK의 `setRecoveryCopy(true)`로)
|
|
366
|
+
64 MiB 미만의 한 조각 파일을 새 저장 자원에 `put --pay wallet`으로 올릴 때 최신 목록이 같은 묶음에
|
|
367
|
+
함께 올라갑니다. 그러면 복구 프로그램이 `--find`로 NMTS 키만 가지고 그 목록을 찾습니다. 검토에
|
|
368
|
+
나오는 값에는 목록이 들어 있습니다. NMTS 키에서 나오지 않는 지갑으로 낸 사본은 이 방법으로
|
|
369
|
+
찾지 못합니다. 명령 없이 프로그램에서 같은 파일을 만들 수도 있습니다.
|
|
370
|
+
`@needmoretruth/nmts-cli/recovery`가 `makeRecoveryList` · `readRecoveryCopy` · `setRecoveryCopy`를
|
|
371
|
+
내보내고, Node와 브라우저에서 모두 돕니다.
|
|
372
|
+
|
|
365
373
|
`nmts rollback`은 파일 목록의 이전 버전을 현재 버전으로 되돌립니다 — 현재 목록이 열리지 않을
|
|
366
374
|
때를 위한 것입니다. 새 버전이 더한 파일은 그 뒤 목록에서 빠지지만 바이트는 그대로 저장돼 있고,
|
|
367
375
|
`nmts rebuild`가 목록에 없는 파일을 찾습니다. `nmts unlock rollback`으로 열기 전에는 잠겨 있고 매번 `--yes`가 필요합니다.
|
package/README.md
CHANGED
|
@@ -51,7 +51,7 @@ default branch, from a pinned version, or from the tarball attached to the
|
|
|
51
51
|
|
|
52
52
|
```sh
|
|
53
53
|
npm install -g github:needmoretruth/nmts-cli # the default branch
|
|
54
|
-
npm install -g github:needmoretruth/nmts-cli#v0.
|
|
54
|
+
npm install -g github:needmoretruth/nmts-cli#v0.56.0 # a pinned version
|
|
55
55
|
npm install -g https://github.com/needmoretruth/nmts-cli/releases/latest/download/nmts.tgz
|
|
56
56
|
```
|
|
57
57
|
|
|
@@ -396,6 +396,14 @@ machine, checks it against the release's checksum file before making it runnable
|
|
|
396
396
|
anything on your PATH. `rebuild` reconstructs a file list from the server's rows for an account
|
|
397
397
|
that has lost its own: keys, hashes, dates and sizes come back; names and folders do not.
|
|
398
398
|
|
|
399
|
+
With the account's storage copy of the recovery list switched on (in the web app, or with the
|
|
400
|
+
SDK's `setRecoveryCopy(true)`), `put --pay wallet` of a one-part file under 64 MiB onto new storage
|
|
401
|
+
uploads the newest list in the same quilt. The recovery program then finds it with `--find` and the
|
|
402
|
+
NMTS key alone. The WAL in the review includes the list. A copy paid from a wallet the NMTS key does
|
|
403
|
+
not derive cannot be found that way. A program can build the same file without the command:
|
|
404
|
+
`@needmoretruth/nmts-cli/recovery` exports `makeRecoveryList`, `readRecoveryCopy` and
|
|
405
|
+
`setRecoveryCopy`, and runs in a browser as well as in Node.
|
|
406
|
+
|
|
399
407
|
`nmts rollback` puts the previous version of the file list back as the current one, for the case
|
|
400
408
|
where the current one will not open. Files the newer version added are out of the list afterwards —
|
|
401
409
|
their bytes are still stored, and `nmts rebuild` finds files the list does not name. It is locked
|
package/dist/artifact-about.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare const CRYPTO_SPEC_URL = "https://github.com/needmoretruth/nmts-re
|
|
|
11
11
|
* is the field's own contract — what the writer says about itself — and a person holding two
|
|
12
12
|
* copies of one account's artefacts can then tell which program made each.
|
|
13
13
|
*/
|
|
14
|
-
export declare const WRITTEN_BY = "nmts-cli 0.
|
|
14
|
+
export declare const WRITTEN_BY = "nmts-cli 0.56.0";
|
|
15
15
|
/** Which of the three artefacts a wrapper is. A reader holding several can sort them. */
|
|
16
16
|
export type ArtifactKind = "recovery-list" | "file-list" | "recovery-kit";
|
|
17
17
|
/**
|
package/dist/commands/push.js
CHANGED
|
@@ -73,7 +73,7 @@ export async function push(target, options = {}) {
|
|
|
73
73
|
const session = await openSession({ server: options.server, network: options.network });
|
|
74
74
|
// ⛔ THE ROAD BEFORE THE PRICE (D50): on NMTS's own relay the parts are 64 MiB, and the credits
|
|
75
75
|
// quoted below are the credits of those parts.
|
|
76
|
-
await chooseUploadRoad({ network: session.network, server: session.server, apiKey: session.apiKey });
|
|
76
|
+
await chooseUploadRoad({ network: session.network, server: session.server, apiKey: session.apiKey, credit: true });
|
|
77
77
|
const partSize = partSizeForRoad(partSizeFor(options.partSize));
|
|
78
78
|
// ⛔ READ BEFORE ANYTHING IS SEALED OR PAID FOR — a typo must not surface after the money.
|
|
79
79
|
const asked = parseAsked(options.onCollision);
|
|
@@ -63,7 +63,7 @@ export async function putWithWallet(target, options) {
|
|
|
63
63
|
const network = resolveNetwork(server, options.network ?? stored?.network);
|
|
64
64
|
// ⛔ THE ROAD BEFORE THE PRICE (D50): on NMTS's own relay the parts are 64 MiB, and the credits
|
|
65
65
|
// quoted below are the credits of those parts.
|
|
66
|
-
await chooseUploadRoad({ network, server, apiKey: key.key });
|
|
66
|
+
await chooseUploadRoad({ network, server, apiKey: key.key, otherCompanies: true });
|
|
67
67
|
const identity = await identityOf(resolved.code);
|
|
68
68
|
const crypt = await loadCrypto();
|
|
69
69
|
const asked = parseAsked(options.onCollision);
|
|
@@ -202,29 +202,29 @@ export async function uploadOneWithWallet(ctx, file, options) {
|
|
|
202
202
|
if (ctx.json)
|
|
203
203
|
return;
|
|
204
204
|
describeUploadReview(say, {
|
|
205
|
-
name: review.name,
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
days: review.days,
|
|
210
|
-
endEpoch: review.endEpoch,
|
|
211
|
-
walNeeded: review.budget.walNeededFrost,
|
|
212
|
-
tipMist: review.tipMist,
|
|
213
|
-
storage: review.storage,
|
|
214
|
-
heldResources: review.heldResources,
|
|
215
|
-
networkCopy: ctx.networkCopy,
|
|
205
|
+
name: review.name, bytes: review.bytes, sealedBytes: review.sealedBytes, parts: review.parts,
|
|
206
|
+
epochs: review.epochs, days: review.days, endEpoch: review.endEpoch,
|
|
207
|
+
walNeeded: review.budget.walNeededFrost, tipMist: review.tipMist, storage: review.storage,
|
|
208
|
+
heldResources: review.heldResources, networkCopy: ctx.networkCopy, carriesRecoveryList: review.carriesRecoveryList,
|
|
216
209
|
}, review.budget);
|
|
217
210
|
},
|
|
218
211
|
agree: (review) => {
|
|
219
212
|
requireWalletGrant("seal", { walFrost: review.budget.walNeededFrost, suiMist: review.budget.suiNeededMist }, new Date(options.now ?? Date.now()));
|
|
220
213
|
},
|
|
221
214
|
onSpend: recordWalletSpend,
|
|
215
|
+
// The copy is a passenger: why it stayed behind is said, and the upload goes on.
|
|
216
|
+
onRecoveryProblem: (message) => (ctx.json ? process.stderr.write(`${message}\n`) : say(` ⚠ ${message}`)),
|
|
222
217
|
});
|
|
223
218
|
}
|
|
224
219
|
finally {
|
|
225
220
|
ctx.progress.done();
|
|
226
221
|
}
|
|
227
222
|
const facts = factsOf(outcome.review);
|
|
223
|
+
if (outcome.kind === "uploaded") {
|
|
224
|
+
facts["recoveryList"] = outcome.recoveryList;
|
|
225
|
+
if (outcome.recoveryList !== null && !ctx.json)
|
|
226
|
+
say(` Recovery list ${outcome.recoveryList} went up with this file.`);
|
|
227
|
+
}
|
|
228
228
|
if (outcome.kind === "review") {
|
|
229
229
|
if (ctx.json)
|
|
230
230
|
say(JSON.stringify({ dryRun: true, name: outcome.review.name, ...facts, signed: false }));
|
package/dist/commands/put.js
CHANGED
|
@@ -109,7 +109,7 @@ export async function put(target, options = {}) {
|
|
|
109
109
|
const network = resolveNetwork(server, options.network ?? stored?.network);
|
|
110
110
|
// ⛔ THE ROAD BEFORE THE PRICE (D50): on NMTS's own relay the parts are 64 MiB, and the credits
|
|
111
111
|
// quoted below are the credits of those parts.
|
|
112
|
-
await chooseUploadRoad({ network, server, apiKey: key.key });
|
|
112
|
+
await chooseUploadRoad({ network, server, apiKey: key.key, credit: true });
|
|
113
113
|
const partSize = partSizeForRoad(partSizeFor(options.partSize));
|
|
114
114
|
const identity = await identityOf(resolved.code);
|
|
115
115
|
const crypt = await loadCrypto();
|
|
@@ -36,8 +36,9 @@ export async function recoveryList(options = {}) {
|
|
|
36
36
|
throw alreadyThere(destination);
|
|
37
37
|
try {
|
|
38
38
|
// ⛔ 0600. These bytes are one account's whole storage index, sealed — and a mode is cheaper to
|
|
39
|
-
// get right than an explanation of why it did not matter.
|
|
40
|
-
|
|
39
|
+
// get right than an explanation of why it did not matter. The library's own bytes, so an
|
|
40
|
+
// app on the SDK and this command hand out the same file (spec 2026-09-20 unit B).
|
|
41
|
+
writeFileSync(destination, file.bytes, {
|
|
41
42
|
flag: options.force === true ? "w" : "wx",
|
|
42
43
|
mode: 0o600,
|
|
43
44
|
});
|
package/dist/crypto-surface.d.ts
CHANGED
|
@@ -258,6 +258,8 @@ export interface CryptoGlue {
|
|
|
258
258
|
link_seal_secret(dataKey: Uint8Array, linkSecret: Uint8Array): Uint8Array;
|
|
259
259
|
/** `S` back from the owner's copy. */
|
|
260
260
|
link_open_secret(dataKey: Uint8Array, sealed: Uint8Array): Uint8Array;
|
|
261
|
+
/** The name the recovery list's patch takes inside a quilt (NCF-3 §2.5), from the data key. */
|
|
262
|
+
recovery_patch_name(dataKey: Uint8Array): string;
|
|
261
263
|
}
|
|
262
264
|
export declare function isCryptoGlue(value: unknown): value is CryptoGlue;
|
|
263
265
|
/** Which of the required functions this object does not have. Empty means it is the engine. */
|
package/dist/crypto-surface.js
CHANGED
|
@@ -45,17 +45,14 @@ const REQUIRED = [
|
|
|
45
45
|
"derive_ai_account_code",
|
|
46
46
|
// Numbered sharing identities (NCF-3 §5.9). Required for the same reason: an engine without them
|
|
47
47
|
// cannot make, show or open with any public code but the first.
|
|
48
|
-
"share_id_seeds",
|
|
49
|
-
"share_public_key_at",
|
|
50
|
-
"share_address_at",
|
|
51
|
-
"share_wrap_dek_as",
|
|
52
|
-
"share_unwrap_dek_as",
|
|
48
|
+
"share_id_seeds", "share_public_key_at", "share_address_at", "share_wrap_dek_as", "share_unwrap_dek_as",
|
|
53
49
|
// The EVM wallets (NCF-3 §1.9), required for the same reason: `put --tier heavy --pay evm` and
|
|
54
50
|
// `heavy wallet` cannot run on a build without it.
|
|
55
51
|
"evm_key_for",
|
|
56
52
|
// Public links (NCF-3 §5.8): `link make`, `link list` and `link open` cannot run without them.
|
|
57
|
-
"link_generate_secret", "link_wrap_dek", "link_unwrap_dek",
|
|
58
|
-
|
|
53
|
+
"link_generate_secret", "link_wrap_dek", "link_unwrap_dek", "link_seal_secret", "link_open_secret",
|
|
54
|
+
// The recovery patch's name: a wallet upload cannot carry the recovery list without it.
|
|
55
|
+
"recovery_patch_name",
|
|
59
56
|
];
|
|
60
57
|
export function isCryptoGlue(value) {
|
|
61
58
|
return missingExports(value).length === 0;
|
package/dist/manifest.js
CHANGED
|
@@ -225,6 +225,9 @@ export async function readFileList(base, apiKey, accountCode, accountId) {
|
|
|
225
225
|
"account sealed. Nothing was changed.",
|
|
226
226
|
});
|
|
227
227
|
}
|
|
228
|
+
// ⛔ The index is packed with zstd whenever the writer had the codec, and this is the first read
|
|
229
|
+
// in a fresh process: the codec registers here, before the index, not only in `openChunks`.
|
|
230
|
+
await host().zstd.register();
|
|
228
231
|
const doc = await decodeFileList(body);
|
|
229
232
|
body.fill(0);
|
|
230
233
|
const io = { server: base, apiKey, accountId, crypt, key };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading straight from the Walrus storage nodes: the last road for a download (D51, 2026-11-09).
|
|
3
|
+
*
|
|
4
|
+
* ⛔ WHY. Every read went through an aggregator, a company's server that asks the nodes for you. On
|
|
5
|
+
* the day none of them answers, a file is still on the nodes; this asks them itself, through the
|
|
6
|
+
* same SDK the uploads use, and decodes the blob here. It is slower and asks many hosts (one per
|
|
7
|
+
* shard holder), so it runs only after every aggregator failed for a reason other than "not found".
|
|
8
|
+
*
|
|
9
|
+
* ⛔ IN ITS OWN FILE, LOADED ONLY WHEN NEEDED. The SDK and its encoder are large; a `get` that an
|
|
10
|
+
* aggregator served never loads them.
|
|
11
|
+
*/
|
|
12
|
+
import { walrus } from "@mysten/walrus";
|
|
13
|
+
import { reachFetch } from "./reach.js";
|
|
14
|
+
import { suiClient } from "./sui-rpc.js";
|
|
15
|
+
/** One blob, or one file inside a quilt, read and decoded from the storage nodes. */
|
|
16
|
+
export async function readFromNodes(network, kind, id) {
|
|
17
|
+
const client = suiClient(network === "mainnet" ? "mainnet" : "testnet").$extend(walrus({ storageNodeClientOptions: { fetch: reachFetch } }));
|
|
18
|
+
if (kind === "blob")
|
|
19
|
+
return client.walrus.readBlob({ blobId: id });
|
|
20
|
+
const [file] = await client.walrus.getFiles({ ids: [id] });
|
|
21
|
+
if (file === undefined)
|
|
22
|
+
throw new Error(`the storage nodes returned nothing for ${id}`);
|
|
23
|
+
return file.bytes();
|
|
24
|
+
}
|
package/dist/portable.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export { codeActivity } from "./public-code-activity.ts";
|
|
|
27
27
|
export type { ActivityDoor, CodeActivity, ReceivedThrough, SentThrough } from "./public-code-activity.ts";
|
|
28
28
|
export { readFileList } from "./manifest.ts";
|
|
29
29
|
export type { FileList } from "./manifest.ts";
|
|
30
|
+
export { makeRecoveryList, nextRecoverySeq, readRecoveryCopy, recordRecoveryList, setRecoveryCopy } from "./recovery.ts";
|
|
31
|
+
export type { MadeRecoveryList, RecoveryAccount, RecoveryCopyState } from "./recovery.ts";
|
|
30
32
|
export { addEntry, applyManyToList, applyToList, planAddition } from "./manifest-write.ts";
|
|
31
33
|
export type { AddEntryInput, AddEntryResult, ListEditInput, ListEditResult } from "./manifest-write.ts";
|
|
32
34
|
export type { Manifest, ManifestEntry } from "./shared/lib/drive/manifest-codec.ts";
|
package/dist/portable.js
CHANGED
|
@@ -50,6 +50,9 @@ export { CODE_INDEX_MAX, openShareAnyCode, openShareWithRing, requireCodeIndex,
|
|
|
50
50
|
export { defaultCode, ensureLiveCode, liveCodes, nextCodeIndex, publishCode, PUBLISH_TRIES, readPublicCodes, revokeCode, } from "./public-codes.js";
|
|
51
51
|
export { codeActivity } from "./public-code-activity.js";
|
|
52
52
|
export { readFileList } from "./manifest.js";
|
|
53
|
+
// The recovery list (spec 2026-09-20 unit B): the file `nmts recovery-list` writes, and its
|
|
54
|
+
// storage-network copy's switch. Also its own entry, `./recovery`.
|
|
55
|
+
export { makeRecoveryList, nextRecoverySeq, readRecoveryCopy, recordRecoveryList, setRecoveryCopy } from "./recovery.js";
|
|
53
56
|
export { addEntry, applyManyToList, applyToList, planAddition } from "./manifest-write.js";
|
|
54
57
|
export { buildIndex, entryAt, folderIdFor, fullPathOf, isLive, KIND_FILE, KIND_FOLDER, namesIn, normalisePath, shown, trashedAt, } from "./drive-paths.js";
|
|
55
58
|
export { setTrashed } from "./item-trash.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.56.0";
|
|
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.56.0";
|
|
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
|
+
/**
|
|
2
|
+
* Asking many aggregators for one object without paying a timeout per dead one (D51, 2026-11-09).
|
|
3
|
+
*
|
|
4
|
+
* ⛔ WHY. The read list became every aggregator in Walrus's operator registry that served the probe
|
|
5
|
+
* blob (dozens). Asked one after another, a dead first row cost its whole timeout before the second
|
|
6
|
+
* was asked. Here the first host is asked at once and the next when one fails or after `hedgeMs`
|
|
7
|
+
* with no answer; the first to send its headers wins, the others are cancelled, and only that one
|
|
8
|
+
* sends a body. A dead row costs `hedgeMs`, not a minute.
|
|
9
|
+
*
|
|
10
|
+
* ⛔ A HOST THAT DOES NOT ANSWER IS GIVEN UP AFTER `headerTimeoutMs`, so hanging rows cannot fill the
|
|
11
|
+
* in-flight cap for long. With every row hanging, the whole list is through in about
|
|
12
|
+
* (rows ÷ cap) × header timeout, and the storage nodes are asked after it (`walrus.ts`).
|
|
13
|
+
*/
|
|
14
|
+
/** What one host said: the response to read, a 404, or something else. */
|
|
15
|
+
export type Reply = {
|
|
16
|
+
response: Response;
|
|
17
|
+
} | "not-found" | "failed";
|
|
18
|
+
export interface RaceOptions {
|
|
19
|
+
/** Ask the next host as well after this long with no answer. */
|
|
20
|
+
hedgeMs: number;
|
|
21
|
+
/** At most this many hosts waiting at once, hanging ones included. */
|
|
22
|
+
maxInFlight: number;
|
|
23
|
+
/** A host with no headers after this long is given up. */
|
|
24
|
+
headerTimeoutMs: number;
|
|
25
|
+
/** This many 404s and no other answer mean the object is not there. */
|
|
26
|
+
notFoundQuorum: number;
|
|
27
|
+
signal?: AbortSignal | undefined;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Race `hosts`. `ask` sends the request with the signal it is given and answers with the reply; the
|
|
31
|
+
* first reply carrying a response wins and is handed to `read`, which turns its body into the value.
|
|
32
|
+
* When `read` throws, that host counts as failed and the race goes on with the hosts not yet asked.
|
|
33
|
+
* Null when nobody gave a body (`tried` holds each host's reason).
|
|
34
|
+
*/
|
|
35
|
+
export declare function raceHosts<T>(hosts: readonly string[], ask: (host: string, signal: AbortSignal) => Promise<Reply>, read: (host: string, response: Response) => Promise<T>, options: RaceOptions): Promise<T | null>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asking many aggregators for one object without paying a timeout per dead one (D51, 2026-11-09).
|
|
3
|
+
*
|
|
4
|
+
* ⛔ WHY. The read list became every aggregator in Walrus's operator registry that served the probe
|
|
5
|
+
* blob (dozens). Asked one after another, a dead first row cost its whole timeout before the second
|
|
6
|
+
* was asked. Here the first host is asked at once and the next when one fails or after `hedgeMs`
|
|
7
|
+
* with no answer; the first to send its headers wins, the others are cancelled, and only that one
|
|
8
|
+
* sends a body. A dead row costs `hedgeMs`, not a minute.
|
|
9
|
+
*
|
|
10
|
+
* ⛔ A HOST THAT DOES NOT ANSWER IS GIVEN UP AFTER `headerTimeoutMs`, so hanging rows cannot fill the
|
|
11
|
+
* in-flight cap for long. With every row hanging, the whole list is through in about
|
|
12
|
+
* (rows ÷ cap) × header timeout, and the storage nodes are asked after it (`walrus.ts`).
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Race `hosts`. `ask` sends the request with the signal it is given and answers with the reply; the
|
|
16
|
+
* first reply carrying a response wins and is handed to `read`, which turns its body into the value.
|
|
17
|
+
* When `read` throws, that host counts as failed and the race goes on with the hosts not yet asked.
|
|
18
|
+
* Null when nobody gave a body (`tried` holds each host's reason).
|
|
19
|
+
*/
|
|
20
|
+
export function raceHosts(hosts, ask, read, options) {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
const queue = [...hosts];
|
|
23
|
+
const live = new Map();
|
|
24
|
+
let notFound = 0;
|
|
25
|
+
let failed = 0;
|
|
26
|
+
let reading = false;
|
|
27
|
+
let done = false;
|
|
28
|
+
let hedge = null;
|
|
29
|
+
const settle = (fn) => {
|
|
30
|
+
if (done)
|
|
31
|
+
return;
|
|
32
|
+
done = true;
|
|
33
|
+
if (hedge)
|
|
34
|
+
clearTimeout(hedge);
|
|
35
|
+
for (const c of live.values())
|
|
36
|
+
c.abort();
|
|
37
|
+
live.clear();
|
|
38
|
+
fn();
|
|
39
|
+
};
|
|
40
|
+
options.signal?.addEventListener("abort", () => settle(() => reject(options.signal?.reason)), { once: true });
|
|
41
|
+
const next = () => {
|
|
42
|
+
if (done || reading)
|
|
43
|
+
return;
|
|
44
|
+
if (hedge)
|
|
45
|
+
clearTimeout(hedge);
|
|
46
|
+
hedge = null;
|
|
47
|
+
if (notFound >= options.notFoundQuorum && failed === 0)
|
|
48
|
+
return settle(() => resolve(null));
|
|
49
|
+
if (queue.length === 0) {
|
|
50
|
+
if (live.size === 0)
|
|
51
|
+
settle(() => resolve(null));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (live.size >= options.maxInFlight)
|
|
55
|
+
return;
|
|
56
|
+
const host = queue.shift() ?? "";
|
|
57
|
+
const controller = new AbortController();
|
|
58
|
+
live.set(host, controller);
|
|
59
|
+
const giveUp = setTimeout(() => controller.abort(new DOMException("no answer in time", "TimeoutError")), options.headerTimeoutMs);
|
|
60
|
+
void ask(host, controller.signal)
|
|
61
|
+
.catch(() => "failed")
|
|
62
|
+
.then((reply) => {
|
|
63
|
+
clearTimeout(giveUp);
|
|
64
|
+
live.delete(host);
|
|
65
|
+
if (done)
|
|
66
|
+
return;
|
|
67
|
+
if (reply === "not-found" || reply === "failed") {
|
|
68
|
+
if (reply === "not-found")
|
|
69
|
+
notFound++;
|
|
70
|
+
else
|
|
71
|
+
failed++;
|
|
72
|
+
return next();
|
|
73
|
+
}
|
|
74
|
+
// The first headers win: the others stop, and only this host sends a body.
|
|
75
|
+
reading = true;
|
|
76
|
+
if (hedge)
|
|
77
|
+
clearTimeout(hedge);
|
|
78
|
+
for (const c of live.values())
|
|
79
|
+
c.abort();
|
|
80
|
+
live.clear();
|
|
81
|
+
read(host, reply.response).then((value) => settle(() => resolve(value)), () => {
|
|
82
|
+
reading = false;
|
|
83
|
+
failed++;
|
|
84
|
+
next();
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
hedge = setTimeout(next, options.hedgeMs);
|
|
88
|
+
};
|
|
89
|
+
next();
|
|
90
|
+
});
|
|
91
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type RecoveryAccount } from "./recovery.ts";
|
|
2
|
+
import type { BuiltRecoveryList } from "./recovery-build.ts";
|
|
2
3
|
import { type Session } from "./session.ts";
|
|
3
4
|
export interface AssembleOptions {
|
|
4
5
|
server?: string | undefined;
|
|
@@ -8,8 +9,7 @@ export interface AssembleOptions {
|
|
|
8
9
|
}
|
|
9
10
|
export interface AssembledRecoveryList {
|
|
10
11
|
session: Session;
|
|
11
|
-
|
|
12
|
-
proof: string;
|
|
12
|
+
account: RecoveryAccount;
|
|
13
13
|
built: BuiltRecoveryList;
|
|
14
14
|
/** This list's own version number. */
|
|
15
15
|
seq: number;
|
|
@@ -19,6 +19,7 @@ export interface AssembledRecoveryList {
|
|
|
19
19
|
file: {
|
|
20
20
|
filename: string;
|
|
21
21
|
content: string;
|
|
22
|
+
bytes: Uint8Array;
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
25
|
export declare function assembleRecoveryList(options?: AssembleOptions): Promise<AssembledRecoveryList>;
|
|
@@ -28,13 +29,5 @@ export declare function assembleRecoveryList(options?: AssembleOptions): Promise
|
|
|
28
29
|
* ⛔ THE FILE FIRST, THE RECORD SECOND — so this takes the path that already exists. The record is
|
|
29
30
|
* what makes an account screen say "your list is up to date"; saying that before the file
|
|
30
31
|
* exists would be a claim about something that may never have been written.
|
|
31
|
-
*
|
|
32
|
-
* ⛔ `kind: "local"` AND NO BLOB ID. This tool keeps the list on the person's own disk and writes
|
|
33
|
-
* no copy to the storage network, and the server refuses a blob id alongside `local` for
|
|
34
|
-
* exactly that reason: a recorded address nothing was written to would let a screen advertise
|
|
35
|
-
* a copy that does not exist.
|
|
36
|
-
*
|
|
37
|
-
* ⛔ THE ATTEMPT IS REMEMBERED WHETHER OR NOT IT LANDS. See `recovery-seq.ts`: a number the server
|
|
38
|
-
* refused must not be the number the next run offers again, or the refusal repeats for ever.
|
|
39
32
|
*/
|
|
40
33
|
export declare function recordRecoveryList(assembled: AssembledRecoveryList, destination: string): Promise<void>;
|
|
@@ -5,104 +5,37 @@
|
|
|
5
5
|
// NMTS key. If those were assembled twice, one of them would eventually be built from a
|
|
6
6
|
// check the other had dropped — and the difference would only show up in a recovery.
|
|
7
7
|
//
|
|
8
|
-
// ⛔ THE
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
// ⛔ THE DATA KEY IS DERIVED HERE AND WIPED HERE. It opens every file in the account; the
|
|
14
|
-
// derivation output it is cut from holds the wallet root and the sign-in secret as well, so it
|
|
15
|
-
// is zeroed on every path out, including the failing one.
|
|
8
|
+
// ⛔ AND THE ASSEMBLY ITSELF IS THE LIBRARY'S (`recovery.ts`, spec 2026-09-20 unit B), so an app
|
|
9
|
+
// on the SDK hands its user the same bytes these commands write. What stays here is what only a
|
|
10
|
+
// terminal has: this machine's session, the agreement that lets it read the code, and the
|
|
11
|
+
// sentence that names the file on disk when the server's record fails.
|
|
16
12
|
import { accountProofFor } from "./account-proof.js";
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
13
|
+
import { ServerError } from "./api.js";
|
|
14
|
+
import { fromUtf8 } from "./bytes.js";
|
|
19
15
|
import { NmtsError } from "./errors.js";
|
|
20
|
-
import {
|
|
21
|
-
import { BINARY_NAME } from "./product.js";
|
|
22
|
-
import { artifactAbout } from "./artifact-about.js";
|
|
23
|
-
import { buildRecoveryList } from "./recovery-build.js";
|
|
24
|
-
import { buildRecoveryMapFile } from "./recovery-map-file.js";
|
|
25
|
-
import { recoveryDocMeta } from "./recovery-map.js";
|
|
26
|
-
import { lastOfferedSeq, rememberOfferedSeq } from "./recovery-seq.js";
|
|
27
|
-
import { readAllRecoverySource } from "./recovery-source.js";
|
|
16
|
+
import { makeRecoveryList, recordRecoveryList as recordWithServer } from "./recovery.js";
|
|
28
17
|
import { openSession } from "./session.js";
|
|
29
|
-
import { AGGREGATOR_HOSTS, suiRpcHost } from "./walrus.js";
|
|
30
|
-
/**
|
|
31
|
-
* Where the bytes this list points at live, for the sealed self-description.
|
|
32
|
-
*
|
|
33
|
-
* ⚠ `aggregators` AND `chain_rpc` ARE HINTS. They are the endpoints this build reads from today —
|
|
34
|
-
* the first thing in the file to go stale — so a reader treats them as candidates AFTER its own
|
|
35
|
-
* built-in defaults, never as instructions. `chain` is the one that changes behaviour: a blob id
|
|
36
|
-
* from testnet and one from mainnet are the same kind of string, and without this a recovery has
|
|
37
|
-
* to try both and let a wrong guess look like missing bytes.
|
|
38
|
-
*/
|
|
39
|
-
function storageFor(network) {
|
|
40
|
-
return {
|
|
41
|
-
network: "walrus",
|
|
42
|
-
chain: network,
|
|
43
|
-
aggregators: [...(AGGREGATOR_HOSTS[network] ?? [])],
|
|
44
|
-
chain_rpc: suiRpcHost(network),
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
18
|
export async function assembleRecoveryList(options = {}) {
|
|
48
|
-
// ⛔ BEFORE THE FIRST READ. Everything created from here on is outside this list.
|
|
49
|
-
const capturedAt = new Date().toISOString();
|
|
50
19
|
const session = await openSession({ server: options.server, network: options.network });
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
exitCode: 4,
|
|
56
|
-
nextStep: `Nothing was written. A recovery list says what each stored file is CALLED and which key ` +
|
|
57
|
-
`opens it, and both come from the account's own file list — the storage network holds ` +
|
|
58
|
-
`neither. Run \`${BINARY_NAME} rebuild\` if this account has stored files but no list.`,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
const source = await readAllRecoverySource({
|
|
20
|
+
// ⛔ THE AGREEMENT IS ASKED HERE, not in the library: a code read from a plain environment
|
|
21
|
+
// variable needs this machine's consent before its proof is built (`account-proof.ts`).
|
|
22
|
+
const accountProof = await accountProofFor({ code: session.code, source: session.source });
|
|
23
|
+
const account = {
|
|
62
24
|
server: session.server,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
const derived = crypt.kdf_derive(crypt.account_code_parse(session.code));
|
|
71
|
-
const [from, to] = DERIVED.dataKey;
|
|
72
|
-
const dataKey = derived.slice(from, to);
|
|
73
|
-
derived.fill(0);
|
|
74
|
-
let built;
|
|
75
|
-
try {
|
|
76
|
-
built = buildRecoveryList({
|
|
77
|
-
crypt,
|
|
78
|
-
dataKey,
|
|
79
|
-
accountId: session.accountId,
|
|
80
|
-
entries: list.manifest.entries,
|
|
81
|
-
source,
|
|
82
|
-
seq,
|
|
83
|
-
generatedAt,
|
|
84
|
-
meta: recoveryDocMeta(artifactAbout("recovery-list"), storageFor(session.network)),
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
finally {
|
|
88
|
-
dataKey.fill(0);
|
|
89
|
-
}
|
|
25
|
+
bearer: session.apiKey,
|
|
26
|
+
code: session.code,
|
|
27
|
+
accountId: session.accountId,
|
|
28
|
+
network: session.network,
|
|
29
|
+
accountProof,
|
|
30
|
+
};
|
|
31
|
+
const made = await makeRecoveryList(account, { onProgress: options.onProgress });
|
|
90
32
|
return {
|
|
91
33
|
session,
|
|
92
|
-
|
|
93
|
-
built,
|
|
94
|
-
seq,
|
|
95
|
-
capturedAt,
|
|
96
|
-
file:
|
|
97
|
-
accountId: session.accountId,
|
|
98
|
-
seq,
|
|
99
|
-
generatedAt,
|
|
100
|
-
// ⛔ READ BACK OUT OF THE DOCUMENT, not assumed. From NRM-3 on the number a document declares
|
|
101
|
-
// depends on what is in it, and a wrapper that stated the newest version this build knows
|
|
102
|
-
// would mislabel every ordinary file.
|
|
103
|
-
nrm: built.doc.v,
|
|
104
|
-
sealed: built.sealed,
|
|
105
|
-
}),
|
|
34
|
+
account,
|
|
35
|
+
built: made.built,
|
|
36
|
+
seq: made.seq,
|
|
37
|
+
capturedAt: made.capturedAt,
|
|
38
|
+
file: { filename: made.file.filename, content: fromUtf8(made.file.content), bytes: made.file.content },
|
|
106
39
|
};
|
|
107
40
|
}
|
|
108
41
|
/**
|
|
@@ -111,25 +44,11 @@ export async function assembleRecoveryList(options = {}) {
|
|
|
111
44
|
* ⛔ THE FILE FIRST, THE RECORD SECOND — so this takes the path that already exists. The record is
|
|
112
45
|
* what makes an account screen say "your list is up to date"; saying that before the file
|
|
113
46
|
* exists would be a claim about something that may never have been written.
|
|
114
|
-
*
|
|
115
|
-
* ⛔ `kind: "local"` AND NO BLOB ID. This tool keeps the list on the person's own disk and writes
|
|
116
|
-
* no copy to the storage network, and the server refuses a blob id alongside `local` for
|
|
117
|
-
* exactly that reason: a recorded address nothing was written to would let a screen advertise
|
|
118
|
-
* a copy that does not exist.
|
|
119
|
-
*
|
|
120
|
-
* ⛔ THE ATTEMPT IS REMEMBERED WHETHER OR NOT IT LANDS. See `recovery-seq.ts`: a number the server
|
|
121
|
-
* refused must not be the number the next run offers again, or the refusal repeats for ever.
|
|
122
47
|
*/
|
|
123
48
|
export async function recordRecoveryList(assembled, destination) {
|
|
124
|
-
const {
|
|
125
|
-
rememberOfferedSeq(session.accountId, seq);
|
|
49
|
+
const { seq } = assembled;
|
|
126
50
|
try {
|
|
127
|
-
await
|
|
128
|
-
method: "PUT",
|
|
129
|
-
token: session.apiKey,
|
|
130
|
-
accountProof: assembled.proof,
|
|
131
|
-
body: { kind: "local", seq, captured_at: assembled.capturedAt },
|
|
132
|
-
});
|
|
51
|
+
await recordWithServer(assembled.account, { seq, capturedAt: assembled.capturedAt });
|
|
133
52
|
}
|
|
134
53
|
catch (error) {
|
|
135
54
|
// ⛔ THE FILE IS GOOD AND THE RECORD IS NOT. Those are two different facts and the person needs
|