@needmoretruth/nmts-cli 0.45.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 +61 -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 +8 -0
- package/dist/args.js +7 -1
- 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/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 +5 -0
- package/dist/commands/ls.js +9 -1
- 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.d.ts +2 -2
- package/dist/commands/put.js +8 -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/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 +4 -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 +12 -10
- package/dist/manifest-write.d.ts +4 -3
- package/dist/platform-sign.d.ts +4 -4
- package/dist/platform-sign.js +3 -3
- package/dist/portable.d.ts +15 -0
- package/dist/portable.js +11 -0
- 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/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 +9 -4
- package/dist/upload-wallet-put.js +16 -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/handover.md +38 -0
- package/docs/commands/heavy.md +35 -0
- package/docs/commands/public-code.md +7 -0
- package/docs/commands/push.md +4 -1
- package/docs/commands/put.md +15 -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,87 @@
|
|
|
1
|
+
import type { CryptoGlue } from "./crypto.ts";
|
|
2
|
+
import { commitHeavyItem } from "./heavy-api.ts";
|
|
3
|
+
import { type FileSecrets } from "./seal.ts";
|
|
4
|
+
import type { HeavyOrderApi } from "./shared/lib/api/types-heavy.ts";
|
|
5
|
+
import { type PaddingRule } from "./shared/lib/crypto/size-padding.ts";
|
|
6
|
+
import { type HeavyPayment, type HeavyProgress, type HeavyRunDeps, type HeavyRunResult } from "./shared/lib/heavy/order-runner.ts";
|
|
7
|
+
import { type PlaintextSource } from "./upload-file.ts";
|
|
8
|
+
/** One file of a Heavy upload, and where it goes in the drive. */
|
|
9
|
+
export interface HeavyFile {
|
|
10
|
+
source: PlaintextSource;
|
|
11
|
+
name: string;
|
|
12
|
+
parentId: string | null;
|
|
13
|
+
/** The destination as typed — carried back for the caller's own messages. */
|
|
14
|
+
destination: string;
|
|
15
|
+
}
|
|
16
|
+
/** One part of a Heavy file: where it is in the plaintext, what it seals from, what it seals to. */
|
|
17
|
+
export interface HeavyPlanPart {
|
|
18
|
+
partIndex: number;
|
|
19
|
+
offset: number;
|
|
20
|
+
length: number;
|
|
21
|
+
/** The plaintext length the stream declares: the last part padded, and never under 39 bytes. */
|
|
22
|
+
sealFrom: number;
|
|
23
|
+
sealedLen: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* How a file is cut for Heavy: 512 MiB parts, the last one padded by the account's own rule —
|
|
27
|
+
* exactly as Standard pads — and raised to the 39 bytes a legal piece needs.
|
|
28
|
+
*
|
|
29
|
+
* ⛔ ONLY THE LAST PART IS PADDED, for the reason `upload-file.ts` gives: a reader recovers where the
|
|
30
|
+
* padding is from the file's size, and that answer is unique only while every earlier part is full.
|
|
31
|
+
*/
|
|
32
|
+
export declare function planHeavyFile(size: number, rule: PaddingRule): HeavyPlanPart[];
|
|
33
|
+
/** What a credit-paid Heavy upload of these sizes costs: every slot is charged on its own, as the server does —
|
|
34
|
+
* half the Standard price, rounded up, at least 1 per slot — Heavy credits are priced for people, not at cost. */
|
|
35
|
+
export declare function heavyCredits(parts: readonly HeavyPlanPart[]): number;
|
|
36
|
+
/** One file, read once for its digest, with its key made and its parts planned. */
|
|
37
|
+
export interface PreparedHeavyFile {
|
|
38
|
+
file: HeavyFile;
|
|
39
|
+
plan: HeavyPlanPart[];
|
|
40
|
+
secrets: FileSecrets;
|
|
41
|
+
}
|
|
42
|
+
/** Read each file once for its content digest, and make its key. ⛔ The caller wipes `secrets.dek`. */
|
|
43
|
+
export declare function prepareHeavyFiles(crypt: CryptoGlue, dataKey: Uint8Array, rule: PaddingRule, files: readonly HeavyFile[]): Promise<PreparedHeavyFile[]>;
|
|
44
|
+
export declare function wipe(prepared: readonly PreparedHeavyFile[]): void;
|
|
45
|
+
/** Seal one part of a prepared file. A fresh stream, so a fresh nonce, every call. */
|
|
46
|
+
export declare function sealHeavyPart(crypt: CryptoGlue, prepared: PreparedHeavyFile, part: HeavyPlanPart): Promise<Uint8Array<ArrayBuffer>>;
|
|
47
|
+
/** The PieceCID, from the Filecoin tooling's own library — loaded only now, never at start-up. */
|
|
48
|
+
export declare function pieceCidOfBytes(bytes: Blob | Uint8Array): Promise<string>;
|
|
49
|
+
export interface HeavyOrderContext {
|
|
50
|
+
server: string;
|
|
51
|
+
bearer: string;
|
|
52
|
+
crypt: CryptoGlue;
|
|
53
|
+
/** The account's data key. Borrowed — the caller wipes it. */
|
|
54
|
+
dataKey: Uint8Array;
|
|
55
|
+
rule: PaddingRule;
|
|
56
|
+
onProgress?: ((event: HeavyProgress) => void) | undefined;
|
|
57
|
+
signal?: AbortSignal | undefined;
|
|
58
|
+
/** The key an order was already opened under (to show its price first); absent = a fresh one. */
|
|
59
|
+
idempotencyKey?: string | undefined;
|
|
60
|
+
/** ⚠ Seams, not options: the order routes and the runner's edges, for tests. */
|
|
61
|
+
api?: HeavyOrderApi | undefined;
|
|
62
|
+
deps?: Partial<Omit<HeavyRunDeps, "api" | "seal">> | undefined;
|
|
63
|
+
commit?: typeof commitHeavyItem | undefined;
|
|
64
|
+
}
|
|
65
|
+
/** One committed Heavy file: what the caller writes into the sealed list. */
|
|
66
|
+
export interface HeavyCommitted {
|
|
67
|
+
itemId: string;
|
|
68
|
+
name: string;
|
|
69
|
+
parentId: string | null;
|
|
70
|
+
destination: string;
|
|
71
|
+
plaintextLen: number;
|
|
72
|
+
dekWrapped: string;
|
|
73
|
+
contentHashCt: string;
|
|
74
|
+
sealedBytes: number;
|
|
75
|
+
parts: number;
|
|
76
|
+
}
|
|
77
|
+
export interface HeavyOrderOutcome {
|
|
78
|
+
run: HeavyRunResult;
|
|
79
|
+
files: HeavyCommitted[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Upload these files as ONE Heavy order and commit each of them.
|
|
83
|
+
*
|
|
84
|
+
* ⛔ IT DOES NOT WRITE THE SEALED LIST — the caller does, before anything else, exactly as with
|
|
85
|
+
* `uploadFile`. A committed file the list does not name is invisible to the person.
|
|
86
|
+
*/
|
|
87
|
+
export declare function heavyOrderPut(ctx: HeavyOrderContext, files: readonly HeavyFile[], payment: HeavyPayment): Promise<HeavyOrderOutcome>;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// NMTS Heavy, paid through an ORDER — credits, or WAL from the wallet once everything is stored.
|
|
2
|
+
// Files in, sealed here, placed and uploaded by the shared order runner, committed as files.
|
|
3
|
+
//
|
|
4
|
+
// ⛔ THE ORDER OF THINGS IS THE SHARED RUNNER'S (`shared/lib/heavy/order-runner.ts`), byte for byte
|
|
5
|
+
// the browser's: open the order, per slot seal → PieceCID → place → upload → wait until stored,
|
|
6
|
+
// then pay when the wallet pays. This file supplies the edges — the sealer, the PieceCID, the
|
|
7
|
+
// upload through this package's `fetch`, the api — and commits each file afterwards.
|
|
8
|
+
//
|
|
9
|
+
// ⛔ ONE KEY PER FILE, MADE ONCE AND HELD FOR THE RUN. Every part of a file is sealed under it, and it
|
|
10
|
+
// is wiped on every way out. There is no resume across runs: sealing is not deterministic, so a
|
|
11
|
+
// second run is a second order (the server removes an unbound order's pieces after a day and
|
|
12
|
+
// gives back the credits for slots that were never stored).
|
|
13
|
+
//
|
|
14
|
+
// ⛔ THE BYTES NEVER PASS THROUGH THE SERVER. They go from this process to the storage company the
|
|
15
|
+
// server named, and the company checks them against the PieceCID computed here.
|
|
16
|
+
//
|
|
17
|
+
// ⛔ NO `node:` IMPORT. The SDK's browser entry reaches this file through `portable.ts`.
|
|
18
|
+
import { sha256 } from "@noble/hashes/sha2.js";
|
|
19
|
+
import { NmtsError } from "./errors.js";
|
|
20
|
+
import { commitHeavyItem, createHeavyApi } from "./heavy-api.js";
|
|
21
|
+
import { reachFetch } from "./reach.js";
|
|
22
|
+
import { fileSecrets, NCF3_SHAPE, sealedLenFor, sealPart } from "./seal.js";
|
|
23
|
+
import { paddedPlaintextLen } from "./shared/lib/crypto/size-padding.js";
|
|
24
|
+
import { HEAVY_MIN_SEAL_FROM_BYTES, HEAVY_PART_SIZE_BYTES, runHeavyOrder, } from "./shared/lib/heavy/order-runner.js";
|
|
25
|
+
import { uploadPieceToProvider } from "./shared/lib/heavy/sp-upload.js";
|
|
26
|
+
import { planParts } from "./shared/lib/upload/part-plan.js";
|
|
27
|
+
import { padded } from "./upload-file.js";
|
|
28
|
+
import { CREDIT_BYTES, creditsFor } from "./upload-price.js";
|
|
29
|
+
/**
|
|
30
|
+
* How a file is cut for Heavy: 512 MiB parts, the last one padded by the account's own rule —
|
|
31
|
+
* exactly as Standard pads — and raised to the 39 bytes a legal piece needs.
|
|
32
|
+
*
|
|
33
|
+
* ⛔ ONLY THE LAST PART IS PADDED, for the reason `upload-file.ts` gives: a reader recovers where the
|
|
34
|
+
* padding is from the file's size, and that answer is unique only while every earlier part is full.
|
|
35
|
+
*/
|
|
36
|
+
export function planHeavyFile(size, rule) {
|
|
37
|
+
if (!Number.isSafeInteger(size) || size <= 0) {
|
|
38
|
+
throw new NmtsError("An empty file cannot be uploaded.", {
|
|
39
|
+
nextStep: "The storage network has nothing to store and would refuse the reservation.",
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const plan = planParts(size, HEAVY_PART_SIZE_BYTES);
|
|
43
|
+
return plan.map((range) => {
|
|
44
|
+
const isLast = range.partIndex === plan.length - 1;
|
|
45
|
+
const rounded = isLast
|
|
46
|
+
? paddedPlaintextLen(range.length, rule, { unitBytes: CREDIT_BYTES, shape: NCF3_SHAPE })
|
|
47
|
+
: range.length;
|
|
48
|
+
const sealFrom = Math.max(rounded, HEAVY_MIN_SEAL_FROM_BYTES);
|
|
49
|
+
return { partIndex: range.partIndex, offset: range.offset, length: range.length, sealFrom, sealedLen: sealedLenFor(sealFrom) };
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/** What a credit-paid Heavy upload of these sizes costs: every slot is charged on its own, as the server does —
|
|
53
|
+
* half the Standard price, rounded up, at least 1 per slot — Heavy credits are priced for people, not at cost. */
|
|
54
|
+
export function heavyCredits(parts) {
|
|
55
|
+
return parts.reduce((sum, part) => sum + Math.max(1, Math.ceil(creditsFor(part.sealedLen) / 2)), 0);
|
|
56
|
+
}
|
|
57
|
+
/** Read each file once for its content digest, and make its key. ⛔ The caller wipes `secrets.dek`. */
|
|
58
|
+
export async function prepareHeavyFiles(crypt, dataKey, rule, files) {
|
|
59
|
+
const out = [];
|
|
60
|
+
try {
|
|
61
|
+
for (const file of files) {
|
|
62
|
+
const plan = planHeavyFile(file.source.size, rule);
|
|
63
|
+
const digest = sha256.create();
|
|
64
|
+
for await (const chunk of file.source.read(0, file.source.size))
|
|
65
|
+
digest.update(chunk);
|
|
66
|
+
const hashed = digest.digest();
|
|
67
|
+
out.push({ file, plan, secrets: fileSecrets(crypt, dataKey, hashed) });
|
|
68
|
+
hashed.fill(0);
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
wipe(out);
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export function wipe(prepared) {
|
|
78
|
+
for (const one of prepared)
|
|
79
|
+
one.secrets.dek.fill(0);
|
|
80
|
+
}
|
|
81
|
+
/** Seal one part of a prepared file. A fresh stream, so a fresh nonce, every call. */
|
|
82
|
+
export function sealHeavyPart(crypt, prepared, part) {
|
|
83
|
+
return sealPart(crypt, prepared.secrets.dek, padded(prepared.file.source.read(part.offset, part.length), part.length, part.sealFrom), { index: part.partIndex, total: prepared.plan.length, plaintextLen: part.sealFrom });
|
|
84
|
+
}
|
|
85
|
+
/** The PieceCID, from the Filecoin tooling's own library — loaded only now, never at start-up. */
|
|
86
|
+
export async function pieceCidOfBytes(bytes) {
|
|
87
|
+
const { pieceCidOf } = await import("./shared/lib/heavy/piece-cid.js");
|
|
88
|
+
return pieceCidOf(bytes);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Upload these files as ONE Heavy order and commit each of them.
|
|
92
|
+
*
|
|
93
|
+
* ⛔ IT DOES NOT WRITE THE SEALED LIST — the caller does, before anything else, exactly as with
|
|
94
|
+
* `uploadFile`. A committed file the list does not name is invisible to the person.
|
|
95
|
+
*/
|
|
96
|
+
export async function heavyOrderPut(ctx, files, payment) {
|
|
97
|
+
const prepared = await prepareHeavyFiles(ctx.crypt, ctx.dataKey, ctx.rule, files);
|
|
98
|
+
try {
|
|
99
|
+
const byKey = new Map(prepared.map((p, index) => [`f${index}`, p]));
|
|
100
|
+
const seal = async (job) => {
|
|
101
|
+
const one = byKey.get(job.fileKey);
|
|
102
|
+
const part = one?.plan[job.partIndex];
|
|
103
|
+
if (one === undefined || part === undefined)
|
|
104
|
+
throw new NmtsError(`Slot ${job.slot} names no part of this upload.`);
|
|
105
|
+
return sealHeavyPart(ctx.crypt, one, part);
|
|
106
|
+
};
|
|
107
|
+
const run = await runHeavyOrder({
|
|
108
|
+
files: prepared.map((p, index) => ({
|
|
109
|
+
key: `f${index}`,
|
|
110
|
+
parts: p.plan.map((part) => ({ partIndex: part.partIndex, sealedLen: part.sealedLen })),
|
|
111
|
+
})),
|
|
112
|
+
payment,
|
|
113
|
+
...(ctx.idempotencyKey === undefined ? {} : { idempotencyKey: ctx.idempotencyKey }),
|
|
114
|
+
...(ctx.onProgress === undefined ? {} : { onProgress: ctx.onProgress }),
|
|
115
|
+
...(ctx.signal === undefined ? {} : { signal: ctx.signal }),
|
|
116
|
+
}, {
|
|
117
|
+
api: ctx.api ?? createHeavyApi(ctx.server, ctx.bearer),
|
|
118
|
+
seal,
|
|
119
|
+
pieceCid: pieceCidOfBytes,
|
|
120
|
+
upload: (input) => uploadPieceToProvider({ ...input, fetchImpl: reachFetch }),
|
|
121
|
+
...ctx.deps,
|
|
122
|
+
});
|
|
123
|
+
const commit = ctx.commit ?? commitHeavyItem;
|
|
124
|
+
const committed = [];
|
|
125
|
+
for (const [index, one] of prepared.entries()) {
|
|
126
|
+
const parts = run.files[index]?.parts;
|
|
127
|
+
if (parts === undefined)
|
|
128
|
+
throw new NmtsError(`The order came back without file ${index + 1}.`);
|
|
129
|
+
const itemId = await commit({
|
|
130
|
+
server: ctx.server,
|
|
131
|
+
bearer: ctx.bearer,
|
|
132
|
+
idempotencyKey: `nmts-heavy-${run.orderId}-${index}`,
|
|
133
|
+
dekWrapped: one.secrets.dekWrapped,
|
|
134
|
+
contentHashCt: one.secrets.contentHashCt,
|
|
135
|
+
parts,
|
|
136
|
+
});
|
|
137
|
+
committed.push({
|
|
138
|
+
itemId,
|
|
139
|
+
name: one.file.name,
|
|
140
|
+
parentId: one.file.parentId,
|
|
141
|
+
destination: one.file.destination,
|
|
142
|
+
plaintextLen: one.file.source.size,
|
|
143
|
+
dekWrapped: one.secrets.dekWrapped,
|
|
144
|
+
contentHashCt: one.secrets.contentHashCt,
|
|
145
|
+
sealedBytes: one.plan.reduce((sum, part) => sum + part.sealedLen, 0),
|
|
146
|
+
parts: one.plan.length,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return { run, files: committed };
|
|
150
|
+
}
|
|
151
|
+
finally {
|
|
152
|
+
wipe(prepared);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type HeavyFile, type HeavyOrderContext, type HeavyOrderOutcome } from "./heavy-upload.ts";
|
|
2
|
+
import type { Network } from "./network.ts";
|
|
3
|
+
import type { SendReads, TransferShape } from "./wallet-send-chain.ts";
|
|
4
|
+
/** What the opened order asks, and what the paying wallet holds against it. */
|
|
5
|
+
export interface HeavyWalletQuote {
|
|
6
|
+
orderId: string;
|
|
7
|
+
/** The Sui address that sends the WAL. */
|
|
8
|
+
address: string;
|
|
9
|
+
/** Where the WAL goes. */
|
|
10
|
+
treasury: string;
|
|
11
|
+
walFrost: bigint;
|
|
12
|
+
/** The transfer's measured fee in MIST, or null when it could not be measured. */
|
|
13
|
+
feeMist: bigint | null;
|
|
14
|
+
termDays: number;
|
|
15
|
+
}
|
|
16
|
+
export interface HeavyWalletInput {
|
|
17
|
+
code: string;
|
|
18
|
+
network: Network;
|
|
19
|
+
/** Which of this key's wallets pays. */
|
|
20
|
+
wallet: number;
|
|
21
|
+
/** 1..=365. */
|
|
22
|
+
termDays: number;
|
|
23
|
+
/** Told the quote as soon as it is known — before the checks, so a refusal follows what was shown. */
|
|
24
|
+
onQuote?: ((quote: HeavyWalletQuote) => void) | undefined;
|
|
25
|
+
/** Asked once the balances cover the quote, before anything is sealed; throwing stops the run. */
|
|
26
|
+
approve?: ((quote: HeavyWalletQuote) => void) | undefined;
|
|
27
|
+
/** Told once the WAL has left. */
|
|
28
|
+
onPaid?: ((spent: {
|
|
29
|
+
walFrost: bigint;
|
|
30
|
+
suiMist: bigint;
|
|
31
|
+
}) => void) | undefined;
|
|
32
|
+
/** ⚠ Seams, not options: the chain's reads and the transfer's signature, for tests. */
|
|
33
|
+
reads?: SendReads | undefined;
|
|
34
|
+
sign?: ((shape: TransferShape) => Promise<string>) | undefined;
|
|
35
|
+
}
|
|
36
|
+
/** Store `files` in one wallet-paid Heavy order. */
|
|
37
|
+
export declare function heavyWalletPut(ctx: HeavyOrderContext, files: readonly HeavyFile[], input: HeavyWalletInput): Promise<HeavyOrderOutcome & {
|
|
38
|
+
quote: HeavyWalletQuote;
|
|
39
|
+
}>;
|
|
@@ -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
|
@@ -69,14 +69,16 @@ export function optionLines() {
|
|
|
69
69
|
` (whoami --phrase). Default: English`,
|
|
70
70
|
` --board The message board's terms rather than the service's (terms)`,
|
|
71
71
|
` --save Keep the document as a file, under the name the server gives it`,
|
|
72
|
-
` (notices, terms, privacy)`,
|
|
72
|
+
` (notices, terms, privacy). \`public-code --save [file]\` writes the`,
|
|
73
|
+
` public code file`,
|
|
73
74
|
` --force Replace a file that is already there (get, pull, listfile,`,
|
|
74
75
|
` recovery, recovery-list, kit), or rebuild an account this machine`,
|
|
75
76
|
` has seen a list for (rebuild). \`create\` never replaces a file`,
|
|
76
77
|
` --name <name> The name the uploaded file gets in the drive (put), or the name to`,
|
|
77
78
|
` be listed under in the gift hall of fame (wallet hall)`,
|
|
78
79
|
` --to <folder> Destination folder, as \`${BINARY_NAME} ls\` prints it (put, push).`,
|
|
79
|
-
` 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`,
|
|
80
82
|
` --dry-run Say what it would cost, and stop (put, push, extend), or what it`,
|
|
81
83
|
` would install, and stop (update). With \`extend\` and \`--pay`,
|
|
82
84
|
` wallet\` nothing is signed and the wallet key is never touched`,
|
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,9 +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,
|
|
101
|
-
media: args.media,
|
|
99
|
+
sort: args.sort, desc: args.desc, long: args.long, media: args.media,
|
|
102
100
|
});
|
|
103
101
|
}
|
|
104
102
|
case "usage": {
|
|
@@ -115,10 +113,12 @@ export async function run(argv) {
|
|
|
115
113
|
server: args.server, network: args.network, json: args.json, to: args.to,
|
|
116
114
|
});
|
|
117
115
|
}
|
|
118
|
-
case "public-code":
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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
|
+
});
|
|
122
122
|
case "wallet": {
|
|
123
123
|
const { wallet } = await import("./commands/wallet.js");
|
|
124
124
|
return await wallet(args.operands[0], {
|
|
@@ -186,11 +186,10 @@ export async function run(argv) {
|
|
|
186
186
|
dryRun: args.dryRun,
|
|
187
187
|
partSize: args.partSize,
|
|
188
188
|
onCollision: args.onCollision,
|
|
189
|
-
deposit: args.deposit,
|
|
190
|
-
pay: args.pay,
|
|
191
|
-
epochs: args.epochs,
|
|
189
|
+
deposit: args.deposit, pay: args.pay, epochs: args.epochs,
|
|
192
190
|
storage: args.storage, from: args.from,
|
|
193
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,
|
|
194
193
|
thumbnail: args.thumbnail, thumbnailFile: args.thumbnailFile,
|
|
195
194
|
});
|
|
196
195
|
}
|
|
@@ -209,6 +208,7 @@ export async function run(argv) {
|
|
|
209
208
|
epochs: args.epochs,
|
|
210
209
|
storage: args.storage,
|
|
211
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,
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
214
|
case "rm": {
|
|
@@ -350,6 +350,8 @@ export async function run(argv) {
|
|
|
350
350
|
}
|
|
351
351
|
case "platform":
|
|
352
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);
|
|
353
355
|
case "s3": {
|
|
354
356
|
const { s3 } = await import("./commands/s3.js");
|
|
355
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/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
|
@@ -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";
|
|
@@ -60,4 +61,18 @@ export { classify } from "./shared/lib/drive/preview-classify.ts";
|
|
|
60
61
|
export { discoverWallets, WALLET_SCAN_GAP } from "./shared/lib/wallet/discover.ts";
|
|
61
62
|
export type { WalletProbe, WalletScan } from "./shared/lib/wallet/discover.ts";
|
|
62
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";
|
|
63
78
|
export { HOME_URL, PRODUCT_NAME, SOURCE_URL, SUPPORT_EMAIL, VERSION } from "./product.ts";
|