@needmoretruth/nmts-cli 0.55.0 → 0.57.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 +20 -0
- package/README.ko.md +9 -1
- package/README.md +9 -1
- package/dist/artifact-about.d.ts +1 -1
- package/dist/commands/put-wallet.js +11 -11
- package/dist/commands/receive.js +30 -87
- package/dist/commands/recovery-list.js +3 -2
- package/dist/commands/share.d.ts +7 -0
- package/dist/commands/share.js +58 -180
- package/dist/commands/shares-sent.js +4 -29
- package/dist/crypto-surface.d.ts +2 -0
- package/dist/crypto-surface.js +4 -7
- package/dist/links.d.ts +5 -0
- package/dist/links.js +6 -1
- package/dist/platform-sign.d.ts +7 -1
- package/dist/platform-sign.js +12 -1
- package/dist/portable.d.ts +4 -0
- package/dist/portable.js +5 -0
- package/dist/product.d.ts +1 -1
- package/dist/product.js +1 -1
- 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/sharing-inbox.d.ts +52 -0
- package/dist/sharing-inbox.js +146 -0
- package/dist/sharing.d.ts +52 -0
- package/dist/sharing.js +218 -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-steps.js +4 -1
- 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 +11 -3
- package/dist/upload-wire.d.ts +22 -0
- package/dist/upload-wire.js +2 -0
- package/dist/walrus-write.js +12 -0
- package/docs/commands/put.md +5 -1
- package/package.json +9 -1
- package/server.json +2 -2
|
@@ -92,14 +92,16 @@ export interface WalletPutSeams {
|
|
|
92
92
|
agree?: ((review: WalletPutReview) => void) | undefined;
|
|
93
93
|
/** Told what left the wallet, after each signature. */
|
|
94
94
|
onSpend?: ((spend: Spend) => void) | undefined;
|
|
95
|
+
/** Told why the recovery list did not ride along, when it was switched on and did not. */
|
|
96
|
+
onRecoveryProblem?: ((message: string) => void) | undefined;
|
|
95
97
|
}
|
|
96
98
|
/** What this upload would buy, in the order somebody deciding needs it. Base units throughout. */
|
|
97
99
|
export interface WalletPutReview {
|
|
98
100
|
name: string;
|
|
99
|
-
/** Plaintext bytes. */
|
|
100
101
|
bytes: number;
|
|
101
|
-
/** Bytes the storage network holds,
|
|
102
|
+
/** Bytes the storage network holds, sealing and padding included — the quilt, when the list rides. */
|
|
102
103
|
sealedBytes: number;
|
|
104
|
+
carriesRecoveryList: boolean;
|
|
103
105
|
parts: number;
|
|
104
106
|
epochs: number;
|
|
105
107
|
/** The term in days, read from the network's own clock. */
|
|
@@ -131,6 +133,8 @@ export type WalletPutOutcome = {
|
|
|
131
133
|
fileListVersion: number;
|
|
132
134
|
/** True when every part was already signed for by an earlier run: this call spent nothing. */
|
|
133
135
|
resumed: boolean;
|
|
136
|
+
/** The number of the recovery list that rode in this upload's quilt; null when none did. */
|
|
137
|
+
recoveryList: number | null;
|
|
134
138
|
};
|
|
135
139
|
/**
|
|
136
140
|
* Price, agree, sign, upload and record ONE file, paid from the wallet the NMTS key derives.
|
|
@@ -41,6 +41,7 @@ import { createUploadApi } from "./upload-api.js";
|
|
|
41
41
|
import { uploadFile } from "./upload-file.js";
|
|
42
42
|
import { CREDIT_BYTES, planAndPrice } from "./upload-price.js";
|
|
43
43
|
import { forgetUpload } from "./upload-run.js";
|
|
44
|
+
import { planWalletRide } from "./upload-recovery-patch.js";
|
|
44
45
|
import { walletRail } from "./upload-wallet.js";
|
|
45
46
|
import { chooseUploadEpochs, daysOf, parseStorageAsk, pickResource, uploadBudget, uploadShortfallNextStep, } from "./upload-wallet-plan.js";
|
|
46
47
|
import { UploadError } from "./upload-wire.js";
|
|
@@ -75,7 +76,15 @@ export async function walletPut(ctx, file, seams = {}) {
|
|
|
75
76
|
}
|
|
76
77
|
const epochs = chooseUploadEpochs(seams.epochs, window);
|
|
77
78
|
const endEpoch = window.clock.current + epochs;
|
|
78
|
-
|
|
79
|
+
// ⛔ THE RIDE IS PLANNED BEFORE THE PRICE: a riding list makes the quilt what is registered, so
|
|
80
|
+
// the quilt is quoted, reviewed, checked and told to the ledger (`upload-recovery-patch.ts`).
|
|
81
|
+
// The file is quoted too: a list that cannot ride after all sends it, for less than agreed.
|
|
82
|
+
const range = plan[0];
|
|
83
|
+
const riding = storageAsk === null && range !== undefined && plan.length === 1
|
|
84
|
+
? await planWalletRide(ctx, protocol, seams.onRecoveryProblem, { ...file, streamPlaintextLen: sealFor(range), sealedLen: sealedBytes }) : null;
|
|
85
|
+
const quiltLen = riding?.quiltLen ?? null, lens = quiltLen === null ? sealedLens : [quiltLen];
|
|
86
|
+
const quoted = await reads.quoteParts(quiltLen === null ? sealedLens : [quiltLen, ...sealedLens], epochs);
|
|
87
|
+
const quotes = quoted.slice(0, lens.length);
|
|
79
88
|
// ⛔ THE ADDRESS THAT IS PRICED IS THE ADDRESS THAT SIGNS — the same wallet the rail carries,
|
|
80
89
|
// whether that is a number this key derives or a wallet the caller holds the key to.
|
|
81
90
|
const address = ctx.payer?.address ?? (await walletAddress(ctx.code, ctx.wallet));
|
|
@@ -108,7 +117,7 @@ export async function walletPut(ctx, file, seams = {}) {
|
|
|
108
117
|
reads.readWallet(address),
|
|
109
118
|
reads.estimateRegisterGas({
|
|
110
119
|
sender: address,
|
|
111
|
-
sealedLen: Math.max(...
|
|
120
|
+
sealedLen: Math.max(...lens),
|
|
112
121
|
epochs,
|
|
113
122
|
storage: storage.kind === "buy"
|
|
114
123
|
? storage
|
|
@@ -119,7 +128,8 @@ export async function walletPut(ctx, file, seams = {}) {
|
|
|
119
128
|
const review = {
|
|
120
129
|
name: file.name,
|
|
121
130
|
bytes: file.source.size,
|
|
122
|
-
sealedBytes,
|
|
131
|
+
sealedBytes: lens.reduce((sum, len) => sum + len, 0),
|
|
132
|
+
carriesRecoveryList: quiltLen !== null,
|
|
123
133
|
parts: plan.length,
|
|
124
134
|
epochs,
|
|
125
135
|
days: daysOf(window, epochs),
|
|
@@ -148,6 +158,20 @@ export async function walletPut(ctx, file, seams = {}) {
|
|
|
148
158
|
seams.agree?.(review);
|
|
149
159
|
const sign = seams.sign ?? (await signers());
|
|
150
160
|
const onSpend = seams.onSpend ?? (() => undefined);
|
|
161
|
+
const rail = walletRail({
|
|
162
|
+
network: ctx.network,
|
|
163
|
+
code: ctx.code,
|
|
164
|
+
wallet: ctx.wallet,
|
|
165
|
+
...(ctx.payer === undefined ? {} : { payer: ctx.payer }),
|
|
166
|
+
relayUrl: protocol.relayUrl,
|
|
167
|
+
epochs,
|
|
168
|
+
storage,
|
|
169
|
+
quotes: quoted,
|
|
170
|
+
feeMist,
|
|
171
|
+
signRegister: sign.register,
|
|
172
|
+
signCertify: sign.certify,
|
|
173
|
+
onSpend,
|
|
174
|
+
});
|
|
151
175
|
const derived = ctx.crypt.kdf_derive(ctx.crypt.account_code_parse(ctx.code));
|
|
152
176
|
const dataKey = derived.slice(DERIVED.dataKey[0], DERIVED.dataKey[1]);
|
|
153
177
|
derived.fill(0);
|
|
@@ -168,20 +192,7 @@ export async function walletPut(ctx, file, seams = {}) {
|
|
|
168
192
|
partSize: ctx.partSize,
|
|
169
193
|
padding: { rule: ctx.rule, unitBytes: CREDIT_BYTES },
|
|
170
194
|
...(seams.onStep === undefined ? {} : { onStep: seams.onStep }),
|
|
171
|
-
buy:
|
|
172
|
-
network: ctx.network,
|
|
173
|
-
code: ctx.code,
|
|
174
|
-
wallet: ctx.wallet,
|
|
175
|
-
...(ctx.payer === undefined ? {} : { payer: ctx.payer }),
|
|
176
|
-
relayUrl: protocol.relayUrl,
|
|
177
|
-
epochs,
|
|
178
|
-
storage,
|
|
179
|
-
quotes,
|
|
180
|
-
feeMist,
|
|
181
|
-
signRegister: sign.register,
|
|
182
|
-
signCertify: sign.certify,
|
|
183
|
-
onSpend,
|
|
184
|
-
}),
|
|
195
|
+
buy: riding === null ? rail : riding.ride.wrap(rail),
|
|
185
196
|
});
|
|
186
197
|
}
|
|
187
198
|
finally {
|
|
@@ -223,6 +234,8 @@ export async function walletPut(ctx, file, seams = {}) {
|
|
|
223
234
|
replaced: added.replaced?.id ?? null,
|
|
224
235
|
fileListVersion: added.seq,
|
|
225
236
|
resumed: result.resumed,
|
|
237
|
+
// After the list names the file, so the account screen and the next list agree.
|
|
238
|
+
recoveryList: riding === null ? null : await riding.ride.record(),
|
|
226
239
|
};
|
|
227
240
|
}
|
|
228
241
|
async function defaultReads(network, relayUrl) {
|
package/dist/upload-wallet.d.ts
CHANGED
|
@@ -25,7 +25,10 @@ export interface WalletRailContext {
|
|
|
25
25
|
epochs: number;
|
|
26
26
|
/** Where the storage comes from. A held resource serves one blob, so it applies to a one-part file. */
|
|
27
27
|
storage: StorageChoice;
|
|
28
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* What was quoted, by sealed length — what the grant ledger is told after each signature. Bytes of
|
|
30
|
+
* a length not here are refused before anything is signed.
|
|
31
|
+
*/
|
|
29
32
|
quotes: readonly PartQuote[];
|
|
30
33
|
/** The measured register fee, added to the ledger with the tip; null adds the tip alone. */
|
|
31
34
|
feeMist: bigint | null;
|
package/dist/upload-wallet.js
CHANGED
|
@@ -80,6 +80,17 @@ async function buyAndPushPartWithWallet(ctx, input) {
|
|
|
80
80
|
return paidPart((await readReservationRecord(key)) ?? existing, true);
|
|
81
81
|
}
|
|
82
82
|
// ── fresh, or interrupted before the signature ──
|
|
83
|
+
// ⛔ ONLY BYTES WHOSE PRICE WAS AGREED ARE REGISTERED. Storage is bought for the length the
|
|
84
|
+
// signature names, and a length nobody quoted would spend what nobody reviewed.
|
|
85
|
+
const quote = ctx.quotes.find((q) => q.sealedLen === sealed.length);
|
|
86
|
+
if (quote === undefined) {
|
|
87
|
+
throw new UploadError({
|
|
88
|
+
phase: "reserve",
|
|
89
|
+
message: `These ${sealed.length} bytes are not the ones this upload was priced for.`,
|
|
90
|
+
paid: false,
|
|
91
|
+
nextStep: "Nothing was signed. Running the same command again prices them first.",
|
|
92
|
+
});
|
|
93
|
+
}
|
|
83
94
|
onStep?.({ step: "encoding", bytes: sealed.length });
|
|
84
95
|
let meta;
|
|
85
96
|
try {
|
|
@@ -119,9 +130,6 @@ async function buyAndPushPartWithWallet(ctx, input) {
|
|
|
119
130
|
// ⛔ BEFORE THE SIGNATURE. See the module header.
|
|
120
131
|
await writeReservation(key, record, sealed);
|
|
121
132
|
onStep?.({ step: "reserving" });
|
|
122
|
-
const quote = ctx.quotes[input.part.index];
|
|
123
|
-
if (quote === undefined)
|
|
124
|
-
throw new NmtsError("unreachable: a part with no quote");
|
|
125
133
|
let registered;
|
|
126
134
|
try {
|
|
127
135
|
registered = await ctx.signRegister({
|
package/dist/upload-wire.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export interface Certificate {
|
|
|
16
16
|
serialized_message_b64: string;
|
|
17
17
|
signature_b64: string;
|
|
18
18
|
}
|
|
19
|
+
/** The largest sealed file a recovery list rides with — the browser's quilt line (`upload-recovery-patch.ts`). */
|
|
20
|
+
export declare const RIDE_CEILING_BYTES: number;
|
|
19
21
|
/** The Walrus protocol seam. The real one is in `walrus-write.ts`; the tests supply a fake. */
|
|
20
22
|
export interface BlobProtocol {
|
|
21
23
|
computeMetadata(input: {
|
|
@@ -34,6 +36,21 @@ export interface BlobProtocol {
|
|
|
34
36
|
*/
|
|
35
37
|
relayUrl?: string;
|
|
36
38
|
}): Promise<Certificate>;
|
|
39
|
+
/**
|
|
40
|
+
* Lay several byte runs out as one quilt, with each patch's place in it. Optional: a protocol
|
|
41
|
+
* without it uploads files as their own blobs, and no recovery list rides along.
|
|
42
|
+
*/
|
|
43
|
+
encodeQuilt?(blobs: readonly {
|
|
44
|
+
contents: Uint8Array;
|
|
45
|
+
identifier: string;
|
|
46
|
+
}[]): Promise<{
|
|
47
|
+
quilt: Uint8Array;
|
|
48
|
+
patches: readonly {
|
|
49
|
+
identifier: string;
|
|
50
|
+
startIndex: number;
|
|
51
|
+
endIndex: number;
|
|
52
|
+
}[];
|
|
53
|
+
}>;
|
|
37
54
|
}
|
|
38
55
|
/** The reservation as the server describes it. */
|
|
39
56
|
export interface ReserveReply {
|
|
@@ -238,6 +255,11 @@ export interface PaidPart {
|
|
|
238
255
|
suiObjectId?: string;
|
|
239
256
|
/** Wallet rail only: the epoch the bought storage ends at, read from the blob object. */
|
|
240
257
|
endEpoch?: number;
|
|
258
|
+
/**
|
|
259
|
+
* Set when the part is one patch of a quilt — `blobId` is then the quilt and `sealedLen` this
|
|
260
|
+
* part's own stream, not the quilt's length.
|
|
261
|
+
*/
|
|
262
|
+
patchId?: string;
|
|
241
263
|
}
|
|
242
264
|
/** What finished. The caller writes the file list, THEN clears the records. */
|
|
243
265
|
export interface UploadResult {
|
package/dist/upload-wire.js
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
// and means the file that DOES spend stays short enough to read in one sitting.
|
|
7
7
|
import { HttpError, ServerError } from "./api.js";
|
|
8
8
|
import { NmtsError } from "./errors.js";
|
|
9
|
+
/** The largest sealed file a recovery list rides with — the browser's quilt line (`upload-recovery-patch.ts`). */
|
|
10
|
+
export const RIDE_CEILING_BYTES = 64 * 1024 * 1024;
|
|
9
11
|
/**
|
|
10
12
|
* A failure that names its phase — and, crucially, whether the account has already paid.
|
|
11
13
|
*
|
package/dist/walrus-write.js
CHANGED
|
@@ -157,6 +157,18 @@ export function createBlobProtocol(network, bodyBytes, onSent) {
|
|
|
157
157
|
signature_b64: toBase64Url(certificate.signature),
|
|
158
158
|
};
|
|
159
159
|
},
|
|
160
|
+
async encodeQuilt(blobs) {
|
|
161
|
+
// ⛔ THE SDK'S OWN LAYOUT, the one the browser's `writeFilesFlow` uses — patches sorted by
|
|
162
|
+
// identifier, the shard count read from the chain — so an aggregator reads a patch of this
|
|
163
|
+
// quilt by name exactly as it reads one the browser wrote (spec 2026-09-20 unit B).
|
|
164
|
+
const { quilt, index } = await client.walrus
|
|
165
|
+
.encodeQuilt({ blobs: blobs.map((b) => ({ contents: b.contents, identifier: b.identifier })) })
|
|
166
|
+
.catch((error) => fail("The storage network's encoder could not build the quilt", error));
|
|
167
|
+
return {
|
|
168
|
+
quilt,
|
|
169
|
+
patches: index.patches.map((p) => ({ identifier: p.identifier, startIndex: p.startIndex, endIndex: p.endIndex })),
|
|
170
|
+
};
|
|
171
|
+
},
|
|
160
172
|
};
|
|
161
173
|
}
|
|
162
174
|
/**
|
package/docs/commands/put.md
CHANGED
|
@@ -33,7 +33,11 @@ run (`null` in `--json` when it could not be measured, never 0), both balances,
|
|
|
33
33
|
fit|whole|<object id>` uses a free storage resource the wallet holds for a one-part file: `fit`
|
|
34
34
|
cuts it to size and leaves the rest free, `whole` binds all of it with the file. Do not choose
|
|
35
35
|
`--storage` for the person: the leftover is their decision. `--epochs` and `--storage` without
|
|
36
|
-
`--pay wallet` exit 2.
|
|
36
|
+
`--pay wallet` exit 2. With the account's storage copy of the recovery list on, a one-part file
|
|
37
|
+
under 64 MiB onto new storage goes up with the newest recovery list in the same quilt, as in the web
|
|
38
|
+
app, and `nmts-recovery --find` finds that list with the NMTS key alone. The review's WAL includes
|
|
39
|
+
it. If the list is left out, a warning says why and the file goes up on its own; `--json` reports
|
|
40
|
+
`recoveryList` (its number, or `null`).
|
|
37
41
|
|
|
38
42
|
**`--tier heavy`** stores the file on NMTS Heavy instead of NMTS Standard: each part is kept whole in
|
|
39
43
|
two separate places on Filecoin rather than spread across Walrus storage nodes. It is paid the same
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needmoretruth/nmts-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.57.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": {
|
|
@@ -45,6 +45,14 @@
|
|
|
45
45
|
"types": "./dist/portable.d.ts",
|
|
46
46
|
"default": "./dist/portable.js"
|
|
47
47
|
},
|
|
48
|
+
"./recovery": {
|
|
49
|
+
"types": "./dist/recovery.d.ts",
|
|
50
|
+
"default": "./dist/recovery.js"
|
|
51
|
+
},
|
|
52
|
+
"./share": {
|
|
53
|
+
"types": "./dist/sharing.d.ts",
|
|
54
|
+
"default": "./dist/sharing.js"
|
|
55
|
+
},
|
|
48
56
|
"./host": {
|
|
49
57
|
"types": "./dist/host.d.ts",
|
|
50
58
|
"default": "./dist/host.js"
|
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.57.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.57.0",
|
|
16
16
|
"transport": {
|
|
17
17
|
"type": "stdio"
|
|
18
18
|
},
|