@needmoretruth/nmts-cli 0.44.0 → 0.46.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 +2 -2
- package/CHANGELOG.md +73 -0
- package/README.ko.md +6 -3
- package/README.md +15 -3
- package/dist/api-advice.js +17 -2
- package/dist/api.d.ts +22 -0
- package/dist/api.js +49 -1
- package/dist/arg-options.d.ts +14 -0
- package/dist/args.js +11 -2
- package/dist/artifact-about.d.ts +1 -1
- package/dist/collision.d.ts +20 -3
- package/dist/collision.js +21 -3
- package/dist/commands/erase.js +1 -0
- package/dist/commands/get.d.ts +2 -0
- package/dist/commands/get.js +13 -1
- package/dist/commands/handover.d.ts +13 -0
- package/dist/commands/handover.js +328 -0
- package/dist/commands/heavy-run.d.ts +59 -0
- package/dist/commands/heavy-run.js +247 -0
- package/dist/commands/heavy.d.ts +7 -0
- package/dist/commands/heavy.js +123 -0
- package/dist/commands/ls.d.ts +7 -0
- package/dist/commands/ls.js +27 -6
- package/dist/commands/public-code.d.ts +6 -0
- package/dist/commands/public-code.js +46 -0
- package/dist/commands/push-heavy.d.ts +6 -0
- package/dist/commands/push-heavy.js +128 -0
- package/dist/commands/push-tree.d.ts +24 -0
- package/dist/commands/push-tree.js +91 -0
- package/dist/commands/push.d.ts +4 -13
- package/dist/commands/push.js +7 -77
- package/dist/commands/put-heavy.d.ts +9 -0
- package/dist/commands/put-heavy.js +120 -0
- package/dist/commands/put-payer.d.ts +21 -0
- package/dist/commands/put-payer.js +24 -0
- package/dist/commands/put-thumbnail.d.ts +4 -0
- package/dist/commands/put-thumbnail.js +119 -0
- package/dist/commands/put-wallet.d.ts +2 -0
- package/dist/commands/put-wallet.js +3 -2
- package/dist/commands/put.d.ts +10 -2
- package/dist/commands/put.js +13 -7
- package/dist/commands/receive.js +3 -3
- package/dist/commands/s3.js +44 -10
- package/dist/crypto-surface.d.ts +8 -0
- package/dist/crypto-surface.js +3 -0
- package/dist/crypto.d.ts +3 -0
- package/dist/crypto.js +3 -0
- package/dist/download-part.d.ts +32 -1
- package/dist/download-part.js +95 -6
- package/dist/download-range.d.ts +19 -0
- package/dist/download-range.js +108 -0
- package/dist/download-sink.d.ts +15 -0
- package/dist/download.d.ts +14 -0
- package/dist/download.js +19 -4
- package/dist/drive-edit/trash.js +5 -3
- package/dist/drive-edit/tree.d.ts +6 -0
- package/dist/drive-edit/tree.js +10 -0
- package/dist/drive-erase.js +2 -2
- package/dist/drive-paths.d.ts +2 -2
- package/dist/drive-paths.js +2 -2
- package/dist/handover.d.ts +44 -0
- package/dist/handover.js +199 -0
- package/dist/heavy-api.d.ts +36 -0
- package/dist/heavy-api.js +107 -0
- package/dist/heavy-copy.d.ts +72 -0
- package/dist/heavy-copy.js +108 -0
- package/dist/heavy-evm.d.ts +20 -0
- package/dist/heavy-evm.js +106 -0
- package/dist/heavy-self-pay.d.ts +92 -0
- package/dist/heavy-self-pay.js +167 -0
- package/dist/heavy-upload.d.ts +87 -0
- package/dist/heavy-upload.js +154 -0
- package/dist/heavy-wallet-pay.d.ts +39 -0
- package/dist/heavy-wallet-pay.js +73 -0
- package/dist/help-options.js +8 -2
- package/dist/help.js +16 -3
- package/dist/list-tier.d.ts +7 -0
- package/dist/list-tier.js +47 -0
- package/dist/main.js +14 -9
- package/dist/manifest-write.d.ts +4 -3
- package/dist/mcp-tools/files.js +21 -2
- package/dist/mcp-tools/reads.js +9 -1
- package/dist/platform-sign.d.ts +4 -4
- package/dist/platform-sign.js +3 -3
- package/dist/portable.d.ts +17 -1
- package/dist/portable.js +13 -1
- package/dist/product.d.ts +1 -1
- package/dist/product.js +1 -1
- package/dist/recovery-build.js +16 -0
- package/dist/recovery-map-part.d.ts +82 -0
- package/dist/recovery-map-part.js +83 -0
- package/dist/recovery-map.d.ts +5 -40
- package/dist/recovery-map.js +18 -1
- package/dist/recovery-source.d.ts +3 -0
- package/dist/recovery-source.js +9 -0
- package/dist/risk.d.ts +30 -0
- package/dist/risk.js +23 -2
- package/dist/run-log.d.ts +1 -1
- package/dist/run-log.js +7 -1
- package/dist/s3/address.d.ts +20 -0
- package/dist/s3/address.js +97 -0
- package/dist/s3/answer.d.ts +48 -0
- package/dist/s3/answer.js +330 -0
- package/dist/s3/body-deframe.d.ts +49 -0
- package/dist/s3/body-deframe.js +264 -0
- package/dist/s3/body-measure.d.ts +13 -0
- package/dist/s3/body-measure.js +48 -0
- package/dist/s3/body-plan.d.ts +31 -0
- package/dist/s3/body-plan.js +159 -0
- package/dist/s3/body.d.ts +46 -0
- package/dist/s3/body.js +117 -0
- package/dist/s3/call.d.ts +36 -0
- package/dist/s3/call.js +42 -0
- package/dist/s3/checksum.d.ts +26 -0
- package/dist/s3/checksum.js +176 -0
- package/dist/s3/content-type.d.ts +3 -0
- package/dist/s3/content-type.js +49 -0
- package/dist/s3/contract.d.ts +91 -14
- package/dist/s3/drive-conditions.d.ts +47 -0
- package/dist/s3/drive-conditions.js +134 -0
- package/dist/s3/drive-key.d.ts +11 -0
- package/dist/s3/drive-key.js +58 -0
- package/dist/s3/drive-limits.d.ts +33 -0
- package/dist/s3/drive-limits.js +53 -0
- package/dist/s3/drive-lock.d.ts +11 -0
- package/dist/s3/drive-lock.js +47 -0
- package/dist/s3/drive-trashed-name.d.ts +13 -0
- package/dist/s3/drive-trashed-name.js +59 -0
- package/dist/s3/drive-write.d.ts +38 -0
- package/dist/s3/drive-write.js +258 -0
- package/dist/s3/drive.d.ts +59 -25
- package/dist/s3/drive.js +46 -77
- package/dist/s3/listing.d.ts +27 -1
- package/dist/s3/listing.js +62 -20
- package/dist/s3/long-answer.d.ts +12 -0
- package/dist/s3/long-answer.js +104 -0
- package/dist/s3/multipart-assemble.d.ts +17 -0
- package/dist/s3/multipart-assemble.js +68 -0
- package/dist/s3/multipart-sweep.d.ts +15 -0
- package/dist/s3/multipart-sweep.js +87 -0
- package/dist/s3/multipart-view.d.ts +45 -0
- package/dist/s3/multipart-view.js +232 -0
- package/dist/s3/multipart.d.ts +26 -19
- package/dist/s3/multipart.js +193 -78
- package/dist/s3/object-read.d.ts +17 -0
- package/dist/s3/object-read.js +127 -0
- package/dist/s3/object-write.d.ts +35 -0
- package/dist/s3/object-write.js +198 -0
- package/dist/s3/range.d.ts +14 -0
- package/dist/s3/range.js +80 -0
- package/dist/s3/response-sink.d.ts +12 -2
- package/dist/s3/response-sink.js +71 -7
- package/dist/s3/routes.d.ts +0 -1
- package/dist/s3/routes.js +242 -217
- package/dist/s3/same-file.d.ts +4 -1
- package/dist/s3/same-file.js +12 -3
- package/dist/s3/server.d.ts +54 -4
- package/dist/s3/server.js +174 -14
- package/dist/s3/sigv4-canonical.d.ts +91 -0
- package/dist/s3/sigv4-canonical.js +148 -0
- package/dist/s3/sigv4-presigned.d.ts +13 -0
- package/dist/s3/sigv4-presigned.js +82 -0
- package/dist/s3/sigv4.d.ts +26 -27
- package/dist/s3/sigv4.js +137 -102
- package/dist/s3/spool.d.ts +37 -0
- package/dist/s3/spool.js +104 -0
- package/dist/s3/staging.d.ts +90 -7
- package/dist/s3/staging.js +97 -66
- package/dist/s3/xml-multipart.d.ts +38 -0
- package/dist/s3/xml-multipart.js +47 -0
- package/dist/s3/xml-read.d.ts +28 -0
- package/dist/s3/xml-read.js +235 -0
- package/dist/s3/xml.d.ts +45 -2
- package/dist/s3/xml.js +72 -13
- package/dist/s3-gateway.d.ts +11 -5
- package/dist/s3-gateway.js +5 -2
- package/dist/seal.d.ts +1 -1
- package/dist/share.d.ts +5 -0
- package/dist/share.js +1 -1
- package/dist/shared/lib/api/types-heavy.d.ts +167 -0
- package/dist/shared/lib/api/types-heavy.js +60 -0
- package/dist/shared/lib/drive/manifest-codec.d.ts +11 -31
- package/dist/shared/lib/drive/manifest-codec.js +15 -23
- package/dist/shared/lib/drive/manifest-index.d.ts +10 -1
- package/dist/shared/lib/drive/manifest-index.js +30 -8
- package/dist/shared/lib/drive/manifest-wire-extras.d.ts +50 -0
- package/dist/shared/lib/drive/manifest-wire-extras.js +65 -0
- package/dist/shared/lib/drive/preview-classify.d.ts +17 -0
- package/dist/shared/lib/drive/preview-classify.js +96 -0
- package/dist/shared/lib/drive/rebuild-verify.js +1 -0
- package/dist/shared/lib/filecoin/providers.d.ts +25 -0
- package/dist/shared/lib/filecoin/providers.js +58 -0
- package/dist/shared/lib/heavy/download.d.ts +48 -0
- package/dist/shared/lib/heavy/download.js +116 -0
- package/dist/shared/lib/heavy/order-plan.d.ts +77 -0
- package/dist/shared/lib/heavy/order-plan.js +83 -0
- package/dist/shared/lib/heavy/order-runner.d.ts +9 -0
- package/dist/shared/lib/heavy/order-runner.js +300 -0
- package/dist/shared/lib/heavy/order-types.d.ts +90 -0
- package/dist/shared/lib/heavy/order-types.js +6 -0
- package/dist/shared/lib/heavy/order-wire.d.ts +55 -0
- package/dist/shared/lib/heavy/order-wire.js +113 -0
- package/dist/shared/lib/heavy/piece-cid.d.ts +24 -0
- package/dist/shared/lib/heavy/piece-cid.js +55 -0
- package/dist/shared/lib/heavy/sp-upload.d.ts +37 -0
- package/dist/shared/lib/heavy/sp-upload.js +112 -0
- package/dist/shared/lib/heavy/synapse-piece.d.ts +1 -0
- package/dist/shared/lib/heavy/synapse-piece.js +8 -0
- package/dist/shared/lib/share/handover-format.d.ts +129 -0
- package/dist/shared/lib/share/handover-format.js +323 -0
- package/dist/shared/lib/share/shared-file-info.js +1 -0
- package/dist/shared/lib/storage-network.d.ts +4 -4
- package/dist/shared/lib/storage-network.js +7 -7
- package/dist/shared/lib/storage-tier.d.ts +28 -0
- package/dist/shared/lib/storage-tier.js +63 -0
- package/dist/shared/lib/wallet/send-rules.js +1 -0
- package/dist/upload-file.d.ts +8 -0
- package/dist/upload-file.js +57 -25
- package/dist/upload-price-node.d.ts +3 -0
- package/dist/upload-price-node.js +3 -6
- package/dist/upload-price.d.ts +10 -0
- package/dist/upload-price.js +13 -1
- package/dist/upload-run.d.ts +80 -0
- package/dist/upload-run.js +173 -0
- package/dist/upload-steps.js +15 -4
- package/dist/upload-store.d.ts +15 -6
- package/dist/upload-store.js +6 -0
- package/dist/upload-wallet-put.d.ts +11 -4
- package/dist/upload-wallet-put.js +17 -6
- package/dist/upload-wallet.js +4 -0
- package/dist/upload-wire.d.ts +25 -0
- package/dist/upload-wire.js +20 -1
- package/dist/upload.js +28 -13
- package/dist/wallet-sign.js +2 -2
- package/docs/commands/get.md +3 -0
- package/docs/commands/handover.md +38 -0
- package/docs/commands/heavy.md +35 -0
- package/docs/commands/ls.md +5 -0
- package/docs/commands/public-code.md +7 -0
- package/docs/commands/push.md +4 -1
- package/docs/commands/put.md +23 -1
- package/docs/commands/share.md +3 -1
- package/package.json +5 -2
- package/server.json +2 -2
- package/vendor/nmts-crypto/nmts_crypto_wasm.d.ts +17 -1
- package/vendor/nmts-crypto/nmts_crypto_wasm.js +28 -0
- package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm +0 -0
- package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm.d.ts +2 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// NMTS Heavy paid in WAL from one of this key's Sui wallets: the order opened first so its price can
|
|
2
|
+
// be read, the wallet's balances held against that price, and the WAL sent only once every part is
|
|
3
|
+
// stored.
|
|
4
|
+
//
|
|
5
|
+
// ⛔ SHARED BY THIS TOOL AND THE SDK. What differs between them — a person reading the price under a
|
|
6
|
+
// standing wallet agreement, or a program whose call is the agreement — is three hooks, so the
|
|
7
|
+
// order in which money can move is written once.
|
|
8
|
+
//
|
|
9
|
+
// ⛔ THE PRICE SIGNED IS THE PRICE QUOTED. The order is opened once under one idempotency key and the
|
|
10
|
+
// run reopens it under the same key; a price that changed between the two is a refusal, not a
|
|
11
|
+
// signature.
|
|
12
|
+
//
|
|
13
|
+
// ⛔ A KNOWN SHORTFALL STOPS THE RUN BEFORE ANYTHING IS SEALED. An order the wallet cannot pay leaves
|
|
14
|
+
// storage companies holding bytes nobody pays for, and counts against the day's unpaid orders.
|
|
15
|
+
import { NmtsError } from "./errors.js";
|
|
16
|
+
import { createHeavyApi } from "./heavy-api.js";
|
|
17
|
+
import { HEAVY_COPY } from "./heavy-copy.js";
|
|
18
|
+
import { heavyOrderPut, planHeavyFile } from "./heavy-upload.js";
|
|
19
|
+
import { heavyOrderRequest } from "./shared/lib/heavy/order-runner.js";
|
|
20
|
+
import { coinAmount, walCoinType, walletAddress } from "./wallet.js";
|
|
21
|
+
/** Store `files` in one wallet-paid Heavy order. */
|
|
22
|
+
export async function heavyWalletPut(ctx, files, input) {
|
|
23
|
+
const address = await walletAddress(input.code, input.wallet);
|
|
24
|
+
const idempotencyKey = ctx.idempotencyKey ?? globalThis.crypto.randomUUID();
|
|
25
|
+
const plans = files.map((f, index) => ({
|
|
26
|
+
key: `f${index}`,
|
|
27
|
+
parts: planHeavyFile(f.source.size, ctx.rule).map((p) => ({ partIndex: p.partIndex, sealedLen: p.sealedLen })),
|
|
28
|
+
}));
|
|
29
|
+
const shapeOf = (walFrost, treasury) => ({
|
|
30
|
+
coin: "WAL",
|
|
31
|
+
amountBaseUnits: walFrost,
|
|
32
|
+
destination: treasury,
|
|
33
|
+
walType: walCoinType(input.network),
|
|
34
|
+
});
|
|
35
|
+
let quote = null;
|
|
36
|
+
const payment = {
|
|
37
|
+
pay: "wallet",
|
|
38
|
+
payer: address,
|
|
39
|
+
termDays: input.termDays,
|
|
40
|
+
payWallet: async (price) => {
|
|
41
|
+
const amount = BigInt(price.wal_frost);
|
|
42
|
+
if (quote === null || amount !== quote.walFrost || price.treasury !== quote.treasury) {
|
|
43
|
+
throw new NmtsError(HEAVY_COPY.failed("payment_refused", `${amount} ≠ ${quote?.walFrost ?? "?"}`));
|
|
44
|
+
}
|
|
45
|
+
const digest = await (input.sign ?? ((shape) => signWith(input, shape)))(shapeOf(amount, price.treasury));
|
|
46
|
+
input.onPaid?.({ walFrost: amount, suiMist: quote.feeMist ?? 0n });
|
|
47
|
+
return digest;
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
const created = await (ctx.api ?? createHeavyApi(ctx.server, ctx.bearer)).createOrder(heavyOrderRequest(plans, payment, idempotencyKey));
|
|
51
|
+
const price = created.price;
|
|
52
|
+
if (price === undefined)
|
|
53
|
+
throw new NmtsError(HEAVY_COPY.failed("bad_answer", "no price"));
|
|
54
|
+
const walFrost = BigInt(price.wal_frost);
|
|
55
|
+
const reads = input.reads ?? (await import("./wallet-send-chain.js")).sendReads(input.network);
|
|
56
|
+
const [purse, feeMist] = await Promise.all([reads.readWallet(address), reads.estimateFee(shapeOf(walFrost, price.treasury), address)]);
|
|
57
|
+
quote = { orderId: created.order_id, address, treasury: price.treasury, walFrost, feeMist, termDays: input.termDays };
|
|
58
|
+
input.onQuote?.(quote);
|
|
59
|
+
if (!purse.sui.read || !purse.wal.read) {
|
|
60
|
+
throw new NmtsError("A balance could not be read, so this tool cannot tell what can be sent.", { exitCode: 1 });
|
|
61
|
+
}
|
|
62
|
+
if (purse.wal.baseUnits < walFrost || purse.sui.baseUnits < (feeMist ?? 0n)) {
|
|
63
|
+
throw new NmtsError(HEAVY_COPY.walletShort(coinAmount(walFrost), coinAmount(purse.wal.baseUnits), coinAmount(feeMist ?? 0n), coinAmount(purse.sui.baseUnits)), { exitCode: 4 });
|
|
64
|
+
}
|
|
65
|
+
input.approve?.(quote);
|
|
66
|
+
const outcome = await heavyOrderPut({ ...ctx, idempotencyKey }, files, payment);
|
|
67
|
+
return { ...outcome, quote };
|
|
68
|
+
}
|
|
69
|
+
/** The signing module is loaded only when WAL is about to move. */
|
|
70
|
+
async function signWith(input, shape) {
|
|
71
|
+
const { signTransfer } = await import("./wallet-sign.js");
|
|
72
|
+
return signTransfer({ network: input.network, code: input.code, wallet: input.wallet, shape });
|
|
73
|
+
}
|
package/dist/help-options.js
CHANGED
|
@@ -57,6 +57,7 @@ export function optionLines() {
|
|
|
57
57
|
` (whoami). --lang ko for the Korean word list`,
|
|
58
58
|
` --find <text> List only the files whose name contains this text (ls). Folders`,
|
|
59
59
|
` appear only where they hold a match`,
|
|
60
|
+
` --media <kind> image, video or audio: only files of that kind (ls)`,
|
|
60
61
|
` --sort <key> name, size or date. Default: whole paths, ascending (ls)`,
|
|
61
62
|
` --desc Reverse whichever order is in effect (ls)`,
|
|
62
63
|
` --hidden Include entries whose name begins with a dot (push)`,
|
|
@@ -68,17 +69,22 @@ export function optionLines() {
|
|
|
68
69
|
` (whoami --phrase). Default: English`,
|
|
69
70
|
` --board The message board's terms rather than the service's (terms)`,
|
|
70
71
|
` --save Keep the document as a file, under the name the server gives it`,
|
|
71
|
-
` (notices, terms, privacy)`,
|
|
72
|
+
` (notices, terms, privacy). \`public-code --save [file]\` writes the`,
|
|
73
|
+
` public code file`,
|
|
72
74
|
` --force Replace a file that is already there (get, pull, listfile,`,
|
|
73
75
|
` recovery, recovery-list, kit), or rebuild an account this machine`,
|
|
74
76
|
` has seen a list for (rebuild). \`create\` never replaces a file`,
|
|
75
77
|
` --name <name> The name the uploaded file gets in the drive (put), or the name to`,
|
|
76
78
|
` be listed under in the gift hall of fame (wallet hall)`,
|
|
77
79
|
` --to <folder> Destination folder, as \`${BINARY_NAME} ls\` prints it (put, push).`,
|
|
78
|
-
` For \`credits transfer\` it is the account identifier that receives
|
|
80
|
+
` For \`credits transfer\` it is the account identifier that receives;`,
|
|
81
|
+
` for \`handover make\`, a public code or a public code file`,
|
|
79
82
|
` --dry-run Say what it would cost, and stop (put, push, extend), or what it`,
|
|
80
83
|
` would install, and stop (update). With \`extend\` and \`--pay`,
|
|
81
84
|
` wallet\` nothing is signed and the wallet key is never touched`,
|
|
85
|
+
` --thumbnail Send a video's preview picture with it, one frame taken by ffmpeg`,
|
|
86
|
+
` (put); fetch only that picture (get)`,
|
|
87
|
+
` --thumbnail-file <f> The picture to send as the video's preview instead (put)`,
|
|
82
88
|
` --part-size <n> Bytes per part for a large upload (put, push). Default 64MiB.`,
|
|
83
89
|
` A plain number, or one with KiB, MiB or GiB. Bigger parts mean`,
|
|
84
90
|
` fewer purchases; smaller parts use less memory`,
|
package/dist/help.js
CHANGED
|
@@ -56,7 +56,8 @@ export function helpText(version) {
|
|
|
56
56
|
` ai-account Accounts made under this one for an AI to work in: list, create, delete.`,
|
|
57
57
|
` Each has its own NMTS key and its own empty drive. Needs the NMTS key`,
|
|
58
58
|
` extend <path> Buy more storage time for one file — **spends WAL from the wallet**`,
|
|
59
|
-
` public-code The code other accounts send files to. \`--publish\` makes it reachable
|
|
59
|
+
` public-code The code other accounts send files to. \`--publish\` makes it reachable;`,
|
|
60
|
+
` \`--save [file]\` writes your public code file, for handovers`,
|
|
60
61
|
` delete-account A PERSON erases this account's server record — irreversible; needs the`,
|
|
61
62
|
` NMTS key, types a sentence, refused in mode auto`,
|
|
62
63
|
` accept-terms A PERSON accepts a new version of the Terms, by typing its version;`,
|
|
@@ -83,11 +84,19 @@ export function helpText(version) {
|
|
|
83
84
|
` under a name your wallet signs for; \`--remove\` goes back to a`,
|
|
84
85
|
` shortened address. Reading it signs nothing`,
|
|
85
86
|
` put <file> Encrypt one file and upload it, paid with credits — or, with`,
|
|
86
|
-
` \`--pay wallet\`, **signs and spends WAL and SUI from the wallet
|
|
87
|
+
` \`--pay wallet\`, **signs and spends WAL and SUI from the wallet**.`,
|
|
88
|
+
` \`--tier heavy\` keeps it whole in two separate places (NMTS Heavy);`,
|
|
89
|
+
` the default is \`--tier standard\``,
|
|
90
|
+
` \`--tier heavy --pay evm\` pays Filecoin from the key's own EVM wallet;`,
|
|
91
|
+
` \`--copies <1-12>\` (default 2) and \`--providers <id,…>\` choose where`,
|
|
87
92
|
` get <path> Download one file and decrypt it`,
|
|
88
93
|
` pull [folder] Download a whole folder, or the whole account, keeping its shape`,
|
|
89
94
|
` push <directory> Upload a whole directory, keeping its shape — **spends credits**,`,
|
|
90
|
-
` or the wallet with \`--pay wallet
|
|
95
|
+
` or the wallet with \`--pay wallet\`. \`--tier heavy\` as for put`,
|
|
96
|
+
` heavy wallet The EVM wallet this key derives for NMTS Heavy: its address, FIL and`,
|
|
97
|
+
` USDFC balances and its Filecoin Pay deposit. \`--index N\` another wallet`,
|
|
98
|
+
` heavy fund <USDFC> Deposit USDFC from that wallet so \`put --tier heavy --pay evm\` pays`,
|
|
99
|
+
` the storage operators itself — **signs and spends**`,
|
|
91
100
|
` rm <paths> Move things to the trash — restorable for 30 days`,
|
|
92
101
|
` restore <paths> Bring things back out of the trash`,
|
|
93
102
|
` sweep Drop trash entries whose 30 days have run out. Asks first`,
|
|
@@ -111,6 +120,10 @@ export function helpText(version) {
|
|
|
111
120
|
` shares What was shared with this account`,
|
|
112
121
|
` receive <id> Download one file somebody shared with this account`,
|
|
113
122
|
` unshare <id> Withdraw a share you sent, or remove one you were sent`,
|
|
123
|
+
` handover make <path> --to <public code | public code file>`,
|
|
124
|
+
` Write a handover file for one account — NMTS keeps no record of it,`,
|
|
125
|
+
` and it cannot be taken back. Asks every time: answer with --yes`,
|
|
126
|
+
` handover open <file> Save the file a handover file carries. Asks the NMTS server nothing`,
|
|
114
127
|
` env What this machine is, and what it means for the NMTS key`,
|
|
115
128
|
` unlock [name] What this machine has unlocked; \`unlock <name>\` opens one — a person,`,
|
|
116
129
|
` at a terminal. \`lock <name>\` closes it. (\`consent\` is the older name)`,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type StorageTier } from "./shared/lib/storage-tier.ts";
|
|
2
|
+
/** A file's tier from its parts: every part's network must name the same tier. */
|
|
3
|
+
export declare function tierOfParts(networks: readonly (number | undefined)[]): StorageTier | null;
|
|
4
|
+
/** The tier word as the column prints it. */
|
|
5
|
+
export declare function tierLabel(tier: StorageTier | null): string;
|
|
6
|
+
/** Each file id's tier, or null where it could not be read. */
|
|
7
|
+
export declare function tiersOf(server: string, apiKey: string, ids: readonly string[]): Promise<Map<string, StorageTier | null>>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Which tier each listed file is stored on — the `tier` column of `nmts ls --long`.
|
|
2
|
+
//
|
|
3
|
+
// ⛔ THE SEALED LIST DOES NOT KNOW IT. Names and sizes live in the account's sealed list; which
|
|
4
|
+
// storage network holds a file's parts is the server's row. So the long listing asks the server
|
|
5
|
+
// the one question it already answers for a download (`GET /v1/items/{id}/parts`), a few files at
|
|
6
|
+
// a time, and only when `--long` was asked for — a plain `ls` stays one request.
|
|
7
|
+
//
|
|
8
|
+
// ⛔ WHAT CANNOT BE READ IS `?`, NEVER A GUESS. A part on a network this build does not know, a file
|
|
9
|
+
// the server would not describe (a trashed one), or a request that failed — each is shown as `?`
|
|
10
|
+
// rather than called Standard, because calling it Standard would name the wrong network.
|
|
11
|
+
import { request } from "./api.js";
|
|
12
|
+
import { asParts } from "./download-part.js";
|
|
13
|
+
import { tierForNetwork } from "./shared/lib/storage-tier.js";
|
|
14
|
+
/** How many files are asked about at once. */
|
|
15
|
+
const AT_ONCE = 8;
|
|
16
|
+
/** A file's tier from its parts: every part's network must name the same tier. */
|
|
17
|
+
export function tierOfParts(networks) {
|
|
18
|
+
if (networks.length === 0)
|
|
19
|
+
return null;
|
|
20
|
+
const tiers = new Set(networks.map((n) => tierForNetwork(n)));
|
|
21
|
+
const [only] = [...tiers];
|
|
22
|
+
return tiers.size === 1 && only !== undefined ? only : null;
|
|
23
|
+
}
|
|
24
|
+
/** The tier word as the column prints it. */
|
|
25
|
+
export function tierLabel(tier) {
|
|
26
|
+
return tier ?? "?";
|
|
27
|
+
}
|
|
28
|
+
/** Each file id's tier, or null where it could not be read. */
|
|
29
|
+
export async function tiersOf(server, apiKey, ids) {
|
|
30
|
+
const out = new Map();
|
|
31
|
+
let next = 0;
|
|
32
|
+
const worker = async () => {
|
|
33
|
+
for (let id = ids[next]; id !== undefined; id = ids[next]) {
|
|
34
|
+
next += 1;
|
|
35
|
+
try {
|
|
36
|
+
const described = asParts(await request(server, `/v1/items/${encodeURIComponent(id)}/parts`, { token: apiKey }));
|
|
37
|
+
out.set(id, tierOfParts(described.parts.map((p) => p.network)));
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// Not readable is its own answer, and the column says so with `?`.
|
|
41
|
+
out.set(id, null);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
await Promise.all(Array.from({ length: Math.min(AT_ONCE, ids.length) }, worker));
|
|
46
|
+
return out;
|
|
47
|
+
}
|
package/dist/main.js
CHANGED
|
@@ -96,8 +96,7 @@ export async function run(argv) {
|
|
|
96
96
|
json: args.json,
|
|
97
97
|
all: args.all,
|
|
98
98
|
find: args.find,
|
|
99
|
-
sort: args.sort,
|
|
100
|
-
desc: args.desc,
|
|
99
|
+
sort: args.sort, desc: args.desc, long: args.long, media: args.media,
|
|
101
100
|
});
|
|
102
101
|
}
|
|
103
102
|
case "usage": {
|
|
@@ -114,10 +113,12 @@ export async function run(argv) {
|
|
|
114
113
|
server: args.server, network: args.network, json: args.json, to: args.to,
|
|
115
114
|
});
|
|
116
115
|
}
|
|
117
|
-
case "public-code":
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
case "public-code":
|
|
117
|
+
return await (await import("./commands/public-code.js")).publicCode({ server: args.server, network: args.network, publish: args.publish, json: args.json, save: args.save, file: args.operands[0], force: args.force });
|
|
118
|
+
case "handover":
|
|
119
|
+
return await (await import("./commands/handover.js")).handover(args.operands[0], args.operands[1], {
|
|
120
|
+
server: args.server, network: args.network, to: args.to, out: args.out, force: args.force, yes: args.yes, json: args.json,
|
|
121
|
+
});
|
|
121
122
|
case "wallet": {
|
|
122
123
|
const { wallet } = await import("./commands/wallet.js");
|
|
123
124
|
return await wallet(args.operands[0], {
|
|
@@ -172,6 +173,7 @@ export async function run(argv) {
|
|
|
172
173
|
const { get } = await import("./commands/get.js");
|
|
173
174
|
return await get(args.operands[0], {
|
|
174
175
|
server: args.server, network: args.network, out: args.out, force: args.force, json: args.json,
|
|
176
|
+
thumbnail: args.thumbnail,
|
|
175
177
|
});
|
|
176
178
|
}
|
|
177
179
|
case "put": {
|
|
@@ -184,11 +186,11 @@ export async function run(argv) {
|
|
|
184
186
|
dryRun: args.dryRun,
|
|
185
187
|
partSize: args.partSize,
|
|
186
188
|
onCollision: args.onCollision,
|
|
187
|
-
deposit: args.deposit,
|
|
188
|
-
pay: args.pay,
|
|
189
|
-
epochs: args.epochs,
|
|
189
|
+
deposit: args.deposit, pay: args.pay, epochs: args.epochs,
|
|
190
190
|
storage: args.storage, from: args.from,
|
|
191
191
|
json: args.json, wallet: args.wallet, trustServerTipAddress: args.trustServerTipAddress,
|
|
192
|
+
tier: args.tier, copies: args.copies, providers: args.providers, evmWallet: args.evmWallet, days: args.days,
|
|
193
|
+
thumbnail: args.thumbnail, thumbnailFile: args.thumbnailFile,
|
|
192
194
|
});
|
|
193
195
|
}
|
|
194
196
|
case "push": {
|
|
@@ -206,6 +208,7 @@ export async function run(argv) {
|
|
|
206
208
|
epochs: args.epochs,
|
|
207
209
|
storage: args.storage,
|
|
208
210
|
json: args.json, wallet: args.wallet, trustServerTipAddress: args.trustServerTipAddress,
|
|
211
|
+
tier: args.tier, copies: args.copies, providers: args.providers, evmWallet: args.evmWallet, days: args.days,
|
|
209
212
|
});
|
|
210
213
|
}
|
|
211
214
|
case "rm": {
|
|
@@ -347,6 +350,8 @@ export async function run(argv) {
|
|
|
347
350
|
}
|
|
348
351
|
case "platform":
|
|
349
352
|
return (await import("./commands/platform.js")).platform(args.operands[0], { out: args.out });
|
|
353
|
+
case "heavy":
|
|
354
|
+
return await (await import("./commands/heavy.js")).heavy(args.operands[0], args);
|
|
350
355
|
case "s3": {
|
|
351
356
|
const { s3 } = await import("./commands/s3.js");
|
|
352
357
|
return await s3({ server: args.server, network: args.network, port: args.port, json: args.json });
|
package/dist/manifest-write.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ManifestEntry } from "./shared/lib/drive/manifest-codec.ts";
|
|
2
2
|
import { type FindOptions } from "./drive-paths.ts";
|
|
3
|
-
import { type OnCollision } from "./collision.ts";
|
|
3
|
+
import { type CollisionAsk, type OnCollision } from "./collision.ts";
|
|
4
4
|
import { type ManifestIntent, type SettingsPatch } from "./shared/lib/drive/manifest-ops.ts";
|
|
5
5
|
/**
|
|
6
6
|
* ⛔ THE SAME FIELD NAMES `Session` USES, so a session IS a valid input and nothing has to be
|
|
@@ -87,9 +87,10 @@ export interface AddEntryInput extends ListEditInput {
|
|
|
87
87
|
entry: ManifestEntry;
|
|
88
88
|
/**
|
|
89
89
|
* What THIS run asked for when the name is already in use. Absent = whatever this machine is
|
|
90
|
-
* set to (`collision.ts`), which is what an ordinary upload wants.
|
|
90
|
+
* set to (`collision.ts`), which is what an ordinary upload wants. A program's own choice comes
|
|
91
|
+
* as a `ProgramChoice`, and `collision.ts` says why that one is not held to the modes.
|
|
91
92
|
*/
|
|
92
|
-
onCollision?:
|
|
93
|
+
onCollision?: CollisionAsk;
|
|
93
94
|
}
|
|
94
95
|
export interface AddEntryResult {
|
|
95
96
|
/** The version now current. */
|
package/dist/mcp-tools/files.js
CHANGED
|
@@ -61,13 +61,21 @@ export function fileTools(ctx) {
|
|
|
61
61
|
`The reply says where it went.`,
|
|
62
62
|
inputSchema: {
|
|
63
63
|
type: "object",
|
|
64
|
-
properties: {
|
|
64
|
+
properties: {
|
|
65
|
+
path: { type: "string", description: "The file's path inside the account." },
|
|
66
|
+
thumbnail: {
|
|
67
|
+
type: "boolean",
|
|
68
|
+
description: "Fetch the video's preview picture instead of the video, as <path>.thumb.jpg.",
|
|
69
|
+
},
|
|
70
|
+
},
|
|
65
71
|
required: ["path"],
|
|
66
72
|
additionalProperties: false,
|
|
67
73
|
},
|
|
68
74
|
run: (args) => {
|
|
69
75
|
const wanted = needString(args, "path");
|
|
70
|
-
|
|
76
|
+
const thumbnail = args["thumbnail"] === true;
|
|
77
|
+
const out = destinationFor(ctx.outDir, thumbnail ? `${wanted}.thumb.jpg` : wanted);
|
|
78
|
+
return say((write) => get(wanted, { ...common(ctx), out, thumbnail, json: true, write }));
|
|
71
79
|
},
|
|
72
80
|
},
|
|
73
81
|
{
|
|
@@ -118,6 +126,15 @@ export function fileTools(ctx) {
|
|
|
118
126
|
to: { type: "string", description: "An existing folder in the account, as nmts_list prints it." },
|
|
119
127
|
deposit_credits: { type: "integer", description: DEPOSIT_HINT },
|
|
120
128
|
dry_run: { type: "boolean", description: "Say what it would cost and stop. Nothing is sent or charged." },
|
|
129
|
+
thumbnail: {
|
|
130
|
+
type: "boolean",
|
|
131
|
+
description: "For a video: also send one frame of it (taken by ffmpeg) as a small preview file every " +
|
|
132
|
+
"app shows as the video's tile. It is priced and charged like any file.",
|
|
133
|
+
},
|
|
134
|
+
thumbnail_file: {
|
|
135
|
+
type: "string",
|
|
136
|
+
description: "For a video: a picture ON THIS MACHINE to send as its preview instead of a frame.",
|
|
137
|
+
},
|
|
121
138
|
},
|
|
122
139
|
required: ["file"],
|
|
123
140
|
additionalProperties: false,
|
|
@@ -129,6 +146,8 @@ export function fileTools(ctx) {
|
|
|
129
146
|
...(typeof args["to"] === "string" ? { to: args["to"] } : {}),
|
|
130
147
|
...(typeof args["deposit_credits"] === "number" ? { deposit: args["deposit_credits"] } : {}),
|
|
131
148
|
...(args["dry_run"] === true ? { dryRun: true } : {}),
|
|
149
|
+
...(args["thumbnail"] === true ? { thumbnail: true } : {}),
|
|
150
|
+
...(typeof args["thumbnail_file"] === "string" ? { thumbnailFile: args["thumbnail_file"] } : {}),
|
|
132
151
|
write,
|
|
133
152
|
})),
|
|
134
153
|
},
|
package/dist/mcp-tools/reads.js
CHANGED
|
@@ -24,7 +24,9 @@ export function readTools(ctx) {
|
|
|
24
24
|
name: "nmts_list",
|
|
25
25
|
description: "List the files stored in the NMTS account, as JSON. Paths are what nmts_get takes. " +
|
|
26
26
|
"Entries in the trash are left out unless include_trashed is true, and the reply says " +
|
|
27
|
-
"how many were left out. Optionally narrow with a search word and choose
|
|
27
|
+
"how many were left out. Optionally narrow with a search word or a media kind and choose " +
|
|
28
|
+
"an order. A video's preview picture is not listed while its video is: nmts_get with " +
|
|
29
|
+
"thumbnail fetches it.",
|
|
28
30
|
inputSchema: {
|
|
29
31
|
type: "object",
|
|
30
32
|
properties: {
|
|
@@ -36,6 +38,11 @@ export function readTools(ctx) {
|
|
|
36
38
|
description: "Order the listing. Absent means the path order this tool has always printed.",
|
|
37
39
|
},
|
|
38
40
|
descending: { type: "boolean", description: "Reverse the order." },
|
|
41
|
+
media: {
|
|
42
|
+
type: "string",
|
|
43
|
+
enum: ["image", "video", "audio"],
|
|
44
|
+
description: "Keep only files of this kind, judged by the name's extension.",
|
|
45
|
+
},
|
|
39
46
|
},
|
|
40
47
|
additionalProperties: false,
|
|
41
48
|
},
|
|
@@ -46,6 +53,7 @@ export function readTools(ctx) {
|
|
|
46
53
|
...(typeof args["find"] === "string" ? { find: args["find"] } : {}),
|
|
47
54
|
...(typeof args["sort"] === "string" ? { sort: args["sort"] } : {}),
|
|
48
55
|
...(args["descending"] === true ? { desc: true } : {}),
|
|
56
|
+
...(typeof args["media"] === "string" ? { media: args["media"] } : {}),
|
|
49
57
|
write,
|
|
50
58
|
})),
|
|
51
59
|
},
|
package/dist/platform-sign.d.ts
CHANGED
|
@@ -64,9 +64,9 @@ export declare function businessPublicKey(privateKey: string): string;
|
|
|
64
64
|
/**
|
|
65
65
|
* The bytes a business signature covers.
|
|
66
66
|
*
|
|
67
|
-
* `path` is the request
|
|
68
|
-
*
|
|
69
|
-
* the request.
|
|
67
|
+
* `path` is the request target exactly as it is sent — the path AND its query string,
|
|
68
|
+
* `/p1/users?after=…&limit=…`, neither dropped nor put in order. A signature that did not cover a
|
|
69
|
+
* parameter the server then read would be a signature over half the request.
|
|
70
70
|
*
|
|
71
71
|
* ⚠ THE NONCE IS SIGNED AS THE TEXT THAT TRAVELS, base64url, on its own line after the moment —
|
|
72
72
|
* so the sender and the receiver agree about the field without either re-encoding it.
|
|
@@ -82,7 +82,7 @@ export interface BusinessRequest {
|
|
|
82
82
|
accountId: string;
|
|
83
83
|
privateKey: string;
|
|
84
84
|
method: string;
|
|
85
|
-
/** The path as
|
|
85
|
+
/** The path and query string as they will be sent, `/p1/business` or `/p1/users?limit=50`. */
|
|
86
86
|
path: string;
|
|
87
87
|
/** The request body exactly as it will be sent. Empty for a GET. */
|
|
88
88
|
body?: Uint8Array | undefined;
|
package/dist/platform-sign.js
CHANGED
|
@@ -88,9 +88,9 @@ export function businessPublicKey(privateKey) {
|
|
|
88
88
|
/**
|
|
89
89
|
* The bytes a business signature covers.
|
|
90
90
|
*
|
|
91
|
-
* `path` is the request
|
|
92
|
-
*
|
|
93
|
-
* the request.
|
|
91
|
+
* `path` is the request target exactly as it is sent — the path AND its query string,
|
|
92
|
+
* `/p1/users?after=…&limit=…`, neither dropped nor put in order. A signature that did not cover a
|
|
93
|
+
* parameter the server then read would be a signature over half the request.
|
|
94
94
|
*
|
|
95
95
|
* ⚠ THE NONCE IS SIGNED AS THE TEXT THAT TRAVELS, base64url, on its own line after the moment —
|
|
96
96
|
* so the sender and the receiver agree about the field without either re-encoding it.
|
package/dist/portable.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export type { FileList } from "./manifest.ts";
|
|
|
22
22
|
export { addEntry, applyManyToList, applyToList, planAddition } from "./manifest-write.ts";
|
|
23
23
|
export type { AddEntryInput, AddEntryResult, ListEditInput, ListEditResult } from "./manifest-write.ts";
|
|
24
24
|
export type { Manifest, ManifestEntry } from "./shared/lib/drive/manifest-codec.ts";
|
|
25
|
-
export { buildIndex, entryAt, folderIdFor, fullPathOf, isLive, KIND_FILE, KIND_FOLDER, namesIn, normalisePath, trashedAt, } from "./drive-paths.ts";
|
|
25
|
+
export { buildIndex, entryAt, folderIdFor, fullPathOf, isLive, KIND_FILE, KIND_FOLDER, namesIn, normalisePath, shown, trashedAt, } from "./drive-paths.ts";
|
|
26
26
|
export type { FindOptions, ManifestIndex } from "./drive-paths.ts";
|
|
27
27
|
export { setTrashed } from "./item-trash.ts";
|
|
28
28
|
export { businessPublicKey, businessSigningInput, BUSINESS_CONTEXT, BUSINESS_PREFIX, delegationSigningInput, DELEGATION_CONTEXT, DELEGATION_MAX_TTL_SECS, DELEGATION_PREFIX, generateBusinessKeys, mintDelegation, NONCE_LEN, PUBKEY_LEN, rotationProof, rotationSigningInput, ROTATE_CONTEXT, SCOPE_ALL, SCOPE_BITS, scopeMask, signatureHolds, signBusinessRequest, SIGNATURE_LEN, } from "./platform-sign.ts";
|
|
@@ -34,6 +34,7 @@ export type { FileUploadInput, FileUploadStep, PlaintextSource } from "./upload-
|
|
|
34
34
|
export { createUploadApi } from "./upload-api.ts";
|
|
35
35
|
export { CREDIT_BYTES, creditsFor, partSizeFor, planAndPrice, UPLOAD_EPOCHS } from "./upload-price.ts";
|
|
36
36
|
export { clearItemRecord, clearReservation } from "./upload-store.ts";
|
|
37
|
+
export { forgetUpload } from "./upload-run.ts";
|
|
37
38
|
export { UploadError } from "./upload-wire.ts";
|
|
38
39
|
export type { BlobProtocol, UploadApi, UploadResult, UploadStep } from "./upload-wire.ts";
|
|
39
40
|
export type { PaddingRule } from "./shared/lib/crypto/size-padding.ts";
|
|
@@ -56,7 +57,22 @@ export { chainReader } from "./wallet-chain.ts";
|
|
|
56
57
|
export { signerAddress, signExtension, signTransfer } from "./wallet-sign.ts";
|
|
57
58
|
export type { SignTransfer } from "./wallet-sign.ts";
|
|
58
59
|
export { activeWalletOf, walletCountOf, WALLET_INDEX_LIMIT } from "./shared/lib/drive/manifest-settings.ts";
|
|
60
|
+
export { classify } from "./shared/lib/drive/preview-classify.ts";
|
|
59
61
|
export { discoverWallets, WALLET_SCAN_GAP } from "./shared/lib/wallet/discover.ts";
|
|
60
62
|
export type { WalletProbe, WalletScan } from "./shared/lib/wallet/discover.ts";
|
|
61
63
|
export { hasHistory } from "./wallet-list-chain.ts";
|
|
64
|
+
export { DEFAULT_STORAGE_TIER, isStorageTier, networkForTier, parseStorageTier, STORAGE_TIERS, tierForNetwork } from "./shared/lib/storage-tier.ts";
|
|
65
|
+
export type { StorageTier } from "./shared/lib/storage-tier.ts";
|
|
66
|
+
export { heavyCredits, heavyOrderPut, planHeavyFile } from "./heavy-upload.ts";
|
|
67
|
+
export type { HeavyCommitted, HeavyFile, HeavyOrderContext, HeavyOrderOutcome, HeavyPlanPart } from "./heavy-upload.ts";
|
|
68
|
+
export { copiesOf, heavySelfPut, providersOf, selfPayChain, SELF_PAY_DEFAULT_COPIES, SELF_PAY_MAX_COPIES } from "./heavy-self-pay.ts";
|
|
69
|
+
export type { SelfPayContext, SelfPayProgress, SelfPaySynapse } from "./heavy-self-pay.ts";
|
|
70
|
+
export { heavyWalletPut } from "./heavy-wallet-pay.ts";
|
|
71
|
+
export type { HeavyWalletInput, HeavyWalletQuote } from "./heavy-wallet-pay.ts";
|
|
72
|
+
export { evmAccountFor, evmAddressFor, evmAddressOf, evmIndexOf, evmKeyOf, hexKey } from "./heavy-evm.ts";
|
|
73
|
+
/** The EVM account a caller holds, for Heavy paid from its own Filecoin wallet. */
|
|
74
|
+
export type { LocalAccount as EvmAccount } from "viem";
|
|
75
|
+
export { HeavyOrderError } from "./shared/lib/heavy/order-runner.ts";
|
|
76
|
+
export type { HeavyPayment, HeavyProgress } from "./shared/lib/heavy/order-runner.ts";
|
|
77
|
+
export { HEAVY_COPY } from "./heavy-copy.ts";
|
|
62
78
|
export { HOME_URL, PRODUCT_NAME, SOURCE_URL, SUPPORT_EMAIL, VERSION } from "./product.ts";
|
package/dist/portable.js
CHANGED
|
@@ -43,7 +43,7 @@ export { isCryptoGlue, missingExports } from "./crypto-surface.js";
|
|
|
43
43
|
// The sealed file list: reading it, editing it, and walking it by path.
|
|
44
44
|
export { readFileList } from "./manifest.js";
|
|
45
45
|
export { addEntry, applyManyToList, applyToList, planAddition } from "./manifest-write.js";
|
|
46
|
-
export { buildIndex, entryAt, folderIdFor, fullPathOf, isLive, KIND_FILE, KIND_FOLDER, namesIn, normalisePath, trashedAt, } from "./drive-paths.js";
|
|
46
|
+
export { buildIndex, entryAt, folderIdFor, fullPathOf, isLive, KIND_FILE, KIND_FOLDER, namesIn, normalisePath, shown, trashedAt, } from "./drive-paths.js";
|
|
47
47
|
export { setTrashed } from "./item-trash.js";
|
|
48
48
|
// The Platform's two credentials: a business's signature over one request, and the delegation
|
|
49
49
|
// token it mints for one of its users. Making either needs no host and no server — a business
|
|
@@ -59,6 +59,7 @@ export { partKeysOf, uploadFile } from "./upload-file.js";
|
|
|
59
59
|
export { createUploadApi } from "./upload-api.js";
|
|
60
60
|
export { CREDIT_BYTES, creditsFor, partSizeFor, planAndPrice, UPLOAD_EPOCHS } from "./upload-price.js";
|
|
61
61
|
export { clearItemRecord, clearReservation } from "./upload-store.js";
|
|
62
|
+
export { forgetUpload } from "./upload-run.js";
|
|
62
63
|
export { UploadError } from "./upload-wire.js";
|
|
63
64
|
export { DEFAULT_PART_BYTES } from "./seal.js";
|
|
64
65
|
export { createBlobProtocol, readCurrentEpoch } from "./walrus-write.js";
|
|
@@ -84,7 +85,18 @@ export { signerAddress, signExtension, signTransfer } from "./wallet-sign.js";
|
|
|
84
85
|
// numbers as `nmts wallet list` — a second walk, or a second reading of the setting, would be a
|
|
85
86
|
// second answer to a question that has to have exactly one.
|
|
86
87
|
export { activeWalletOf, walletCountOf, WALLET_INDEX_LIMIT } from "./shared/lib/drive/manifest-settings.js";
|
|
88
|
+
export { classify } from "./shared/lib/drive/preview-classify.js";
|
|
87
89
|
export { discoverWallets, WALLET_SCAN_GAP } from "./shared/lib/wallet/discover.js";
|
|
88
90
|
export { hasHistory } from "./wallet-list-chain.js";
|
|
91
|
+
// NMTS Heavy: the tier word every interface reads, an upload paid through an order (credits, or WAL
|
|
92
|
+
// once stored), and developer mode's self-paid road from the key's own EVM wallet (NCF-3 §1.9).
|
|
93
|
+
// ⚠ The Synapse SDK behind the self-paid road is loaded only when that road runs.
|
|
94
|
+
export { DEFAULT_STORAGE_TIER, isStorageTier, networkForTier, parseStorageTier, STORAGE_TIERS, tierForNetwork } from "./shared/lib/storage-tier.js";
|
|
95
|
+
export { heavyCredits, heavyOrderPut, planHeavyFile } from "./heavy-upload.js";
|
|
96
|
+
export { copiesOf, heavySelfPut, providersOf, selfPayChain, SELF_PAY_DEFAULT_COPIES, SELF_PAY_MAX_COPIES } from "./heavy-self-pay.js";
|
|
97
|
+
export { heavyWalletPut } from "./heavy-wallet-pay.js";
|
|
98
|
+
export { evmAccountFor, evmAddressFor, evmAddressOf, evmIndexOf, evmKeyOf, hexKey } from "./heavy-evm.js";
|
|
99
|
+
export { HeavyOrderError } from "./shared/lib/heavy/order-runner.js";
|
|
100
|
+
export { HEAVY_COPY } from "./heavy-copy.js";
|
|
89
101
|
// What this package is.
|
|
90
102
|
export { HOME_URL, PRODUCT_NAME, SOURCE_URL, SUPPORT_EMAIL, VERSION } from "./product.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.46.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.46.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. */
|
package/dist/recovery-build.js
CHANGED
|
@@ -29,6 +29,12 @@ import { NCF3_SHAPE } from "./seal.js";
|
|
|
29
29
|
import { freeCeiling, keepLengths, padmeLen, pow2Len, } from "./shared/lib/crypto/size-padding.js";
|
|
30
30
|
import { buildIndex, KIND_FOLDER, pathOf } from "./shared/lib/drive/manifest-index.js";
|
|
31
31
|
import { NETWORK_WHEN_UNRECORDED, networkName, } from "./shared/lib/storage-network.js";
|
|
32
|
+
import { NETWORK_FILECOIN } from "./shared/lib/storage-network.js";
|
|
33
|
+
import { FILECOIN_CHAIN_FOR_NETWORK } from "./shared/lib/filecoin/providers.js";
|
|
34
|
+
/** The Filecoin chain that goes with this list's chain; null for one this build does not pair. */
|
|
35
|
+
function filecoinChainOf(chain) {
|
|
36
|
+
return chain === "testnet" || chain === "mainnet" ? FILECOIN_CHAIN_FOR_NETWORK[chain] : null;
|
|
37
|
+
}
|
|
32
38
|
import { CREDIT_BYTES } from "./upload-price.js";
|
|
33
39
|
const utf8 = new TextEncoder();
|
|
34
40
|
/** Path of the account root. Every file sits at this or below it. */
|
|
@@ -169,6 +175,16 @@ export function buildRecoveryList(input) {
|
|
|
169
175
|
part.padded_len = p.streamPlaintextLen;
|
|
170
176
|
if (p.sui_object_id !== undefined)
|
|
171
177
|
part.sui_object_id = p.sui_object_id;
|
|
178
|
+
// NRM-5: a Heavy part also names its Filecoin chain — this build's, as for every other network
|
|
179
|
+
// fact in the list — and the companies keeping it, in the order the server stored them. The
|
|
180
|
+
// encoder refuses the part if either is not something a reader accepts.
|
|
181
|
+
if (p.network === NETWORK_FILECOIN) {
|
|
182
|
+
const chain = filecoinChainOf(input.meta.storage.chain);
|
|
183
|
+
if (chain !== null)
|
|
184
|
+
part.chain = chain;
|
|
185
|
+
if (p.copies !== undefined)
|
|
186
|
+
part.copies = p.copies;
|
|
187
|
+
}
|
|
172
188
|
return part;
|
|
173
189
|
});
|
|
174
190
|
// A quilted file is one patch inside one shared blob — by construction one part — so the
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/** The network name a Filecoin part carries — the word the storage-network table registers. */
|
|
2
|
+
export declare const NETWORK_NAME_FILECOIN = "filecoin";
|
|
3
|
+
/** The Filecoin networks a part may name in `chain`. */
|
|
4
|
+
export type ManifestFilecoinChain = "calibration" | "mainnet";
|
|
5
|
+
/** The most copies one part may list; the reader refuses more. */
|
|
6
|
+
export declare const MAX_FILECOIN_COPIES = 12;
|
|
7
|
+
/**
|
|
8
|
+
* One storage company keeping a whole copy of a Filecoin part. The three numbers are decimal
|
|
9
|
+
* STRINGS because the contracts count them as `uint256`; `retrieval_url` is where the company served
|
|
10
|
+
* the piece when the list was written — a hint; the registry on `chain` has its current address.
|
|
11
|
+
*/
|
|
12
|
+
export interface ManifestFilecoinCopy {
|
|
13
|
+
provider_id: string;
|
|
14
|
+
data_set_id: string;
|
|
15
|
+
piece_id: string;
|
|
16
|
+
retrieval_url: string;
|
|
17
|
+
}
|
|
18
|
+
/** One stored piece of a file, in order. */
|
|
19
|
+
export interface ManifestPart {
|
|
20
|
+
/**
|
|
21
|
+
* Where this part belongs: 0 for the first, and the position it must be concatenated at
|
|
22
|
+
* thereafter. Required from NRM-2.
|
|
23
|
+
*
|
|
24
|
+
* It is written down because array order alone cannot be CHECKED. A reader holds each fetched
|
|
25
|
+
* part's 72-byte NCF-3 header, which carries the index sealed under the file key, so with this
|
|
26
|
+
* field it can compare three things that must agree: the position it is writing at, what the
|
|
27
|
+
* list says belongs there, and what the bytes themselves say they are.
|
|
28
|
+
*/
|
|
29
|
+
part_index: number;
|
|
30
|
+
/** Blob id holding this part's stream, in `network`'s own naming (a PieceCID on Filecoin). */
|
|
31
|
+
blob_id?: string;
|
|
32
|
+
/** The REAL bytes this part contributes to the file. */
|
|
33
|
+
plaintext_len: number;
|
|
34
|
+
/**
|
|
35
|
+
* What the stored stream's header DECLARES, when the part was padded and that is larger.
|
|
36
|
+
* Absent means it was not padded. New in NRM-4.
|
|
37
|
+
*
|
|
38
|
+
* ⛔ THE TWO NUMBERS STAY APART so that "the parts sum to exactly `size`" keeps its exact
|
|
39
|
+
* strength. Folded into one, the check softens to "at least", which accepts any size below
|
|
40
|
+
* the real one: the file comes back short and nothing says so.
|
|
41
|
+
*/
|
|
42
|
+
padded_len?: number;
|
|
43
|
+
/** On-chain blob object, when the uploading client captured it. Omitted, never null. */
|
|
44
|
+
sui_object_id?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Which storage network holds `blob_id` — a NAME (`"walrus"`, `"filecoin"`), not a code.
|
|
47
|
+
*
|
|
48
|
+
* A word rather than a number because whoever parses this may be doing so years from now with
|
|
49
|
+
* none of our code beside them, and a bare `1` is not something a stranger can look up.
|
|
50
|
+
*/
|
|
51
|
+
network?: string;
|
|
52
|
+
/** The Filecoin network that issued `blob_id`. On a Filecoin part only, and required there (NRM-5). */
|
|
53
|
+
chain?: ManifestFilecoinChain;
|
|
54
|
+
/** The companies keeping a whole copy, in the order a reader tries them. Filecoin only, 1..=12. */
|
|
55
|
+
copies?: ManifestFilecoinCopy[];
|
|
56
|
+
}
|
|
57
|
+
/** As a writer hands one in: the position is the value, so `part_index` is filled by the encoder. */
|
|
58
|
+
export interface ManifestPartInput extends Omit<ManifestPart, "part_index" | "copies"> {
|
|
59
|
+
part_index?: number;
|
|
60
|
+
copies?: readonly ManifestFilecoinCopy[];
|
|
61
|
+
}
|
|
62
|
+
/** Whether a part uses an NRM-5 form — what makes a document need `v: 5`. */
|
|
63
|
+
export declare function usesFilecoin(part: Pick<ManifestPartInput, "network" | "chain" | "copies">): boolean;
|
|
64
|
+
/** A part's Filecoin form: nothing to write, the two fields to write, or why it cannot be written. */
|
|
65
|
+
export type FilecoinForm = {
|
|
66
|
+
readonly kind: "none";
|
|
67
|
+
} | {
|
|
68
|
+
readonly kind: "filecoin";
|
|
69
|
+
readonly chain: ManifestFilecoinChain;
|
|
70
|
+
readonly copies: ManifestFilecoinCopy[];
|
|
71
|
+
} | {
|
|
72
|
+
readonly kind: "refused";
|
|
73
|
+
readonly why: string;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Decide a part's Filecoin fields, or say why they cannot be written. `why` finishes a sentence
|
|
77
|
+
* that begins "the part …". The reader's rules, in its order: `chain` and `copies` only on a
|
|
78
|
+
* Filecoin part, no Filecoin part in a quilted item, a known chain, a PieceCIDv2 `blob_id`, 1..=12
|
|
79
|
+
* copies, three canonical decimal `uint256` numbers per copy, and a `retrieval_url` of
|
|
80
|
+
* `https://<host>…/piece/<blob_id>` with no query or fragment.
|
|
81
|
+
*/
|
|
82
|
+
export declare function filecoinForm(part: Pick<ManifestPartInput, "network" | "chain" | "copies" | "blob_id">, inQuilt: boolean): FilecoinForm;
|