@needmoretruth/nmts-cli 0.45.0 → 0.47.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 +8 -8
- package/CHANGELOG.md +78 -0
- package/README.ko.md +6 -3
- package/README.md +31 -11
- 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 +19 -1
- package/dist/args.js +14 -2
- package/dist/artifact-about.d.ts +1 -1
- package/dist/autonomy.js +3 -3
- 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 +15 -0
- package/dist/commands/handover.js +376 -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/link.d.ts +12 -0
- package/dist/commands/link.js +121 -0
- package/dist/commands/ls.d.ts +5 -0
- package/dist/commands/ls.js +9 -1
- package/dist/commands/public-code-manage.d.ts +24 -0
- package/dist/commands/public-code-manage.js +217 -0
- package/dist/commands/public-code.d.ts +12 -1
- package/dist/commands/public-code.js +140 -45
- 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 +14 -8
- package/dist/commands/s3.js +44 -10
- package/dist/commands/share-dispatch.js +14 -1
- package/dist/commands/share.d.ts +2 -0
- package/dist/commands/share.js +45 -35
- package/dist/commands/shares-sent.js +8 -3
- package/dist/crypto-surface.d.ts +35 -0
- package/dist/crypto-surface.js +13 -0
- package/dist/crypto.d.ts +8 -0
- package/dist/crypto.js +8 -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-codes.d.ts +25 -0
- package/dist/handover-codes.js +106 -0
- package/dist/handover.d.ts +62 -0
- package/dist/handover.js +217 -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 +13 -4
- package/dist/help.js +24 -3
- package/dist/links.d.ts +58 -0
- package/dist/links.js +206 -0
- package/dist/list-tier.d.ts +7 -0
- package/dist/list-tier.js +47 -0
- package/dist/main.js +13 -10
- package/dist/manifest-write.d.ts +4 -3
- package/dist/mcp-tools/reads.js +20 -6
- package/dist/mcp-tools/share.js +47 -1
- package/dist/mcp-tools/tiers.js +16 -1
- package/dist/platform-sign.d.ts +4 -4
- package/dist/platform-sign.js +3 -3
- package/dist/portable.d.ts +23 -0
- package/dist/portable.js +19 -0
- package/dist/product.d.ts +1 -1
- package/dist/product.js +1 -1
- package/dist/public-code-activity.d.ts +35 -0
- package/dist/public-code-activity.js +88 -0
- package/dist/public-code-refusals.d.ts +25 -0
- package/dist/public-code-refusals.js +87 -0
- package/dist/public-codes.d.ts +76 -0
- package/dist/public-codes.js +182 -0
- 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 +55 -1
- package/dist/risk.js +55 -3
- 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-codes.d.ts +40 -0
- package/dist/share-codes.js +151 -0
- package/dist/share.d.ts +39 -0
- package/dist/share.js +54 -13
- 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/public-link.d.ts +41 -0
- package/dist/shared/lib/share/public-link.js +107 -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 +54 -0
- package/docs/commands/heavy.md +35 -0
- package/docs/commands/link.md +27 -0
- package/docs/commands/mcp.md +2 -1
- package/docs/commands/public-code.md +25 -6
- package/docs/commands/push.md +4 -1
- package/docs/commands/put.md +15 -1
- package/docs/commands/share.md +8 -3
- package/package.json +5 -2
- package/server.json +2 -2
- package/vendor/nmts-crypto/nmts_crypto_wasm.d.ts +106 -4
- package/vendor/nmts-crypto/nmts_crypto_wasm.js +286 -3
- package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm +0 -0
- package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm.d.ts +12 -1
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// An account's public codes on the server: reading them, publishing the next one, revoking one.
|
|
2
|
+
//
|
|
3
|
+
// ⛔ NO TERMINAL HERE. `nmts public-code …`, `nmts share` and the library's `publicCodes` all come
|
|
4
|
+
// through these functions, so the three answer the same account the same way; what a person is
|
|
5
|
+
// told about a refusal is the command's business (`commands/public-code-manage.ts`), and a
|
|
6
|
+
// program gets the server's own `ServerError` with its code to branch on.
|
|
7
|
+
//
|
|
8
|
+
// ⛔ THE NEXT NUMBER IS THE HIGHEST EVER PLUS ONE, revoked ones included, and nothing is guessed
|
|
9
|
+
// beyond that: the server answers which number it wanted when it refuses one (`INDEX_NOT_NEXT`),
|
|
10
|
+
// and a number whose code was revoked once — by this account before it was erased and made again
|
|
11
|
+
// from the same key — is refused for ever, so publishing walks past it.
|
|
12
|
+
//
|
|
13
|
+
// ⚠ THE DEFAULT CODE IS NOT STORED ANYWHERE. It is the lowest-numbered live one, read
|
|
14
|
+
// off the list every time.
|
|
15
|
+
import { request, ServerError } from "./api.js";
|
|
16
|
+
import { fromBase64Url, toBase64Url } from "./bytes.js";
|
|
17
|
+
import { NmtsError } from "./errors.js";
|
|
18
|
+
import { isRecord } from "./guards.js";
|
|
19
|
+
import { requireCodeIndex, shareKeyRing } from "./share-codes.js";
|
|
20
|
+
/** How many numbers in a row publishing walks past before it stops. */
|
|
21
|
+
export const PUBLISH_TRIES = 64;
|
|
22
|
+
const unreadable = () => new NmtsError("The server listed this account's public codes in a shape this version cannot read.", {
|
|
23
|
+
nextStep: "Nothing was changed. A newer version of this tool may understand it.",
|
|
24
|
+
});
|
|
25
|
+
function whole(value) {
|
|
26
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0)
|
|
27
|
+
throw unreadable();
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
function readRow(value) {
|
|
31
|
+
if (!isRecord(value) || typeof value["address"] !== "string" || typeof value["created_at"] !== "string") {
|
|
32
|
+
throw unreadable();
|
|
33
|
+
}
|
|
34
|
+
const revoked = value["revoked_at"];
|
|
35
|
+
return {
|
|
36
|
+
index: whole(value["index"]),
|
|
37
|
+
address: value["address"],
|
|
38
|
+
createdAt: value["created_at"],
|
|
39
|
+
revokedAt: typeof revoked === "string" ? revoked : null,
|
|
40
|
+
sent: whole(value["sent"] ?? 0),
|
|
41
|
+
received: whole(value["received"] ?? 0),
|
|
42
|
+
support: whole(value["support"] ?? 0),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** `GET /v1/account/public-codes`, read field by field. Codes come back in number order. */
|
|
46
|
+
export async function readPublicCodes(server, token) {
|
|
47
|
+
const answer = await request(server, "/v1/account/public-codes", { token });
|
|
48
|
+
if (!isRecord(answer) || !Array.isArray(answer["codes"]))
|
|
49
|
+
throw unreadable();
|
|
50
|
+
const codes = answer["codes"].map(readRow).sort((a, b) => a.index - b.index);
|
|
51
|
+
return {
|
|
52
|
+
codes,
|
|
53
|
+
liveMax: whole(answer["live_max"]),
|
|
54
|
+
dayCap: whole(answer["day_cap"]),
|
|
55
|
+
madeToday: whole(answer["made_today"] ?? 0),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** The server wants `index` next and refuses it as revoked, so no number can be published. */
|
|
59
|
+
function noNextNumber(index) {
|
|
60
|
+
return new NmtsError(`The server wants public code #${index} next, and refuses it as revoked.`, {
|
|
61
|
+
exitCode: 4,
|
|
62
|
+
nextStep: "Nothing was published. The server has to let this account skip that number; report it.",
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/** The live codes, lowest number first. */
|
|
66
|
+
export function liveCodes(list) {
|
|
67
|
+
return list.codes.filter((c) => c.revokedAt === null);
|
|
68
|
+
}
|
|
69
|
+
/** The code this account shows and sends from unless told otherwise: its lowest-numbered live one. */
|
|
70
|
+
export function defaultCode(list) {
|
|
71
|
+
return liveCodes(list)[0] ?? null;
|
|
72
|
+
}
|
|
73
|
+
/** The number a new code gets: one past the highest ever published, or 0 for an account with none. */
|
|
74
|
+
export function nextCodeIndex(list) {
|
|
75
|
+
return list.codes.reduce((top, c) => Math.max(top, c.index + 1), 0);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Publish this key's code at `from` (default: the next number), revoking `replace` in the same
|
|
79
|
+
* request when it is given. Walks past numbers the server says were revoked, up to `PUBLISH_TRIES`.
|
|
80
|
+
*
|
|
81
|
+
* ⛔ THE IDENTITY IS DERIVED HERE AND NOWHERE ELSE. There is no form of this that takes an identity
|
|
82
|
+
* from a caller: what goes to the server is what this key makes at that number.
|
|
83
|
+
*/
|
|
84
|
+
export async function publishCode(crypt, code, door, from, replace) {
|
|
85
|
+
let index = requireCodeIndex(from);
|
|
86
|
+
// ⛔ ONE RING for the walk: the key's derivation runs once, not once per number tried.
|
|
87
|
+
const ring = shareKeyRing(crypt, code);
|
|
88
|
+
const refusedAsRevoked = new Set();
|
|
89
|
+
try {
|
|
90
|
+
for (let tries = 0; tries < PUBLISH_TRIES; tries += 1) {
|
|
91
|
+
const keys = ring.at(index);
|
|
92
|
+
try {
|
|
93
|
+
const address = toBase64Url(keys.address);
|
|
94
|
+
await request(door.server, "/v1/account/public-codes", {
|
|
95
|
+
token: door.token,
|
|
96
|
+
method: "POST",
|
|
97
|
+
body: {
|
|
98
|
+
index,
|
|
99
|
+
identity: toBase64Url(keys.identity),
|
|
100
|
+
address,
|
|
101
|
+
...(replace === undefined ? {} : { revoke: [requireCodeIndex(replace)] }),
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
return { index, code: keys.display, address };
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
if (!(error instanceof ServerError))
|
|
108
|
+
throw error;
|
|
109
|
+
if (error.code === "PUBLIC_CODE_REVOKED") {
|
|
110
|
+
refusedAsRevoked.add(index);
|
|
111
|
+
index = requireCodeIndex(index + 1);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
// Another device made one in between: the server says which number it wants now.
|
|
115
|
+
const wanted = error.details["next"];
|
|
116
|
+
if (error.code === "INDEX_NOT_NEXT" && typeof wanted === "number" && wanted !== index) {
|
|
117
|
+
// ⚠ A server that wants a number it also refuses as revoked would send this back and forth.
|
|
118
|
+
if (refusedAsRevoked.has(wanted))
|
|
119
|
+
throw noNextNumber(wanted);
|
|
120
|
+
index = requireCodeIndex(wanted);
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
throw error;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
ring.wipe();
|
|
129
|
+
}
|
|
130
|
+
throw new NmtsError(`${PUBLISH_TRIES} public code numbers in a row were refused as revoked.`, {
|
|
131
|
+
nextStep: "Nothing was published. Try again later; if it repeats, report it.",
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Make sure the account has a live code, publishing the next number when it has none — what a
|
|
136
|
+
* first share does before anything else. Answers the list as it now stands, and whether it wrote.
|
|
137
|
+
*/
|
|
138
|
+
export async function ensureLiveCode(crypt, code, door, onPublish) {
|
|
139
|
+
const list = await readPublicCodes(door.server, door.token);
|
|
140
|
+
if (defaultCode(list) !== null)
|
|
141
|
+
return { list, published: null };
|
|
142
|
+
onPublish?.();
|
|
143
|
+
const published = await publishCode(crypt, code, door, nextCodeIndex(list));
|
|
144
|
+
return { list: await readPublicCodes(door.server, door.token), published };
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Whether the code at `address` is on the server's revoked list — or null when the list could not
|
|
148
|
+
* be read (offline, rate-limited, an older server), which is "unknown", not "live".
|
|
149
|
+
*
|
|
150
|
+
* ⛔ ASKED BY BUCKET, NEVER BY CODE. The server keeps SHA-256 of each revoked address; this fetches
|
|
151
|
+
* every mark whose hex starts with the same digit as this address's mark (one of sixteen) and
|
|
152
|
+
* compares here. A question about one code would tell the server who is dealing with whom — the
|
|
153
|
+
* thing a handover exists not to tell it. Needs no credential.
|
|
154
|
+
*/
|
|
155
|
+
export async function revokedOnServer(server, address, buckets = new Map()) {
|
|
156
|
+
try {
|
|
157
|
+
const mark = new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256", new Uint8Array(address)));
|
|
158
|
+
const prefix = (mark[0] ?? 0).toString(16).padStart(2, "0").charAt(0);
|
|
159
|
+
let bucket = buckets.get(prefix);
|
|
160
|
+
if (bucket === undefined) {
|
|
161
|
+
bucket = request(server, `/v1/public-codes/revoked?prefix=${prefix}`, {}).then((answer) => {
|
|
162
|
+
const marks = isRecord(answer) ? answer["fingerprints"] : null;
|
|
163
|
+
if (!Array.isArray(marks))
|
|
164
|
+
throw unreadable();
|
|
165
|
+
return marks.filter((m) => typeof m === "string").map(fromBase64Url);
|
|
166
|
+
});
|
|
167
|
+
buckets.set(prefix, bucket);
|
|
168
|
+
}
|
|
169
|
+
const held = await bucket;
|
|
170
|
+
return held.some((m) => m.length === mark.length && m.every((byte, at) => byte === mark[at]));
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/** `POST /v1/account/public-codes/{index}/revoke`. One way: nothing brings a code back. */
|
|
177
|
+
export async function revokeCode(door, index) {
|
|
178
|
+
await request(door.server, `/v1/account/public-codes/${requireCodeIndex(index)}/revoke`, {
|
|
179
|
+
token: door.token,
|
|
180
|
+
method: "POST",
|
|
181
|
+
});
|
|
182
|
+
}
|
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;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// One stored piece of a file in the recovery list — the wire shape of a part, and the rules its
|
|
2
|
+
// Filecoin form (NRM-5, NMTS Heavy) must meet to be written.
|
|
3
|
+
//
|
|
4
|
+
// ⚠ RESTATED FROM THE BROWSER'S WRITER (`web/src/lib/recovery/manifest-part.ts`), which this package
|
|
5
|
+
// cannot import, and held to the same shared sample the Rust reader and the browser are held to
|
|
6
|
+
// (`crypto/tests/vectors/nrm5-sample.json`). It moved out of `recovery-map.ts` because NRM-5 gave a
|
|
7
|
+
// part two more fields and that file was near its length ceiling; `recovery-map.ts` re-exports it.
|
|
8
|
+
//
|
|
9
|
+
// ⛔ THE READER REFUSES THE WHOLE DOCUMENT over one Filecoin part that breaks these rules, so a list
|
|
10
|
+
// a writer let one through would open nothing — on the day it is somebody's only copy. So the
|
|
11
|
+
// writer applies every rule the reader applies, in the reader's order, and refuses instead.
|
|
12
|
+
/** The network name a Filecoin part carries — the word the storage-network table registers. */
|
|
13
|
+
export const NETWORK_NAME_FILECOIN = "filecoin";
|
|
14
|
+
const FILECOIN_CHAINS = ["calibration", "mainnet"];
|
|
15
|
+
/** The most copies one part may list; the reader refuses more. */
|
|
16
|
+
export const MAX_FILECOIN_COPIES = 12;
|
|
17
|
+
/** 2²⁵⁶ − 1 in decimal: the largest number the provider contracts' `uint256` holds. */
|
|
18
|
+
const U256_MAX_DECIMAL = "115792089237316195423570985008687907853269984665640564039457584007913129639935";
|
|
19
|
+
/** A PieceCIDv2 string: `bafkzcib` then lowercase base32, at most 128 characters. */
|
|
20
|
+
const PIECE_CID = /^bafkzcib[a-z2-7]+$/;
|
|
21
|
+
const MAX_PIECE_CID_LEN = 128;
|
|
22
|
+
/** Whether a part uses an NRM-5 form — what makes a document need `v: 5`. */
|
|
23
|
+
export function usesFilecoin(part) {
|
|
24
|
+
return part.network === NETWORK_NAME_FILECOIN || part.chain !== undefined || part.copies !== undefined;
|
|
25
|
+
}
|
|
26
|
+
const COPY_NUMBERS = ["provider_id", "data_set_id", "piece_id"];
|
|
27
|
+
/**
|
|
28
|
+
* Decide a part's Filecoin fields, or say why they cannot be written. `why` finishes a sentence
|
|
29
|
+
* that begins "the part …". The reader's rules, in its order: `chain` and `copies` only on a
|
|
30
|
+
* Filecoin part, no Filecoin part in a quilted item, a known chain, a PieceCIDv2 `blob_id`, 1..=12
|
|
31
|
+
* copies, three canonical decimal `uint256` numbers per copy, and a `retrieval_url` of
|
|
32
|
+
* `https://<host>…/piece/<blob_id>` with no query or fragment.
|
|
33
|
+
*/
|
|
34
|
+
export function filecoinForm(part, inQuilt) {
|
|
35
|
+
const { chain, copies } = part;
|
|
36
|
+
if (part.network !== NETWORK_NAME_FILECOIN) {
|
|
37
|
+
if (chain === undefined && copies === undefined)
|
|
38
|
+
return { kind: "none" };
|
|
39
|
+
return { kind: "refused", why: `carries chain or copies but is on ${part.network ?? "walrus"}, not filecoin` };
|
|
40
|
+
}
|
|
41
|
+
if (inQuilt)
|
|
42
|
+
return { kind: "refused", why: "is on filecoin but its item is placed in a quilt" };
|
|
43
|
+
if (chain === undefined || !FILECOIN_CHAINS.includes(chain)) {
|
|
44
|
+
return { kind: "refused", why: `is on filecoin and names no known chain (${String(chain)})` };
|
|
45
|
+
}
|
|
46
|
+
const cid = part.blob_id;
|
|
47
|
+
if (typeof cid !== "string" || cid.length > MAX_PIECE_CID_LEN || !PIECE_CID.test(cid)) {
|
|
48
|
+
return { kind: "refused", why: "is on filecoin and its blob_id is not a PieceCIDv2" };
|
|
49
|
+
}
|
|
50
|
+
if (copies === undefined || copies.length < 1 || copies.length > MAX_FILECOIN_COPIES) {
|
|
51
|
+
return { kind: "refused", why: `is on filecoin and lists ${copies?.length ?? 0} copies, outside 1..=${MAX_FILECOIN_COPIES}` };
|
|
52
|
+
}
|
|
53
|
+
for (const [n, copy] of copies.entries()) {
|
|
54
|
+
const bad = COPY_NUMBERS.find((field) => !isU256Decimal(copy[field]));
|
|
55
|
+
if (bad)
|
|
56
|
+
return { kind: "refused", why: `has a copy ${n} whose ${bad} is not a canonical decimal uint256` };
|
|
57
|
+
if (!isRetrievalUrl(copy.retrieval_url, cid)) {
|
|
58
|
+
return { kind: "refused", why: `has a copy ${n} whose retrieval_url is not https://…/piece/<blob_id>` };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// Rebuilt rather than passed through, so a copy handed in with an extra key cannot reach the
|
|
62
|
+
// byte output. The order is kept: it is the order a reader tries them in.
|
|
63
|
+
return {
|
|
64
|
+
kind: "filecoin",
|
|
65
|
+
chain,
|
|
66
|
+
copies: copies.map((c) => ({ provider_id: c.provider_id, data_set_id: c.data_set_id, piece_id: c.piece_id, retrieval_url: c.retrieval_url })),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** Digits only, no leading zero (except `"0"`), at most 2²⁵⁶ − 1 — one spelling per number. */
|
|
70
|
+
function isU256Decimal(s) {
|
|
71
|
+
if (typeof s !== "string" || !/^(0|[1-9][0-9]*)$/.test(s))
|
|
72
|
+
return false;
|
|
73
|
+
return s.length < U256_MAX_DECIMAL.length || (s.length === U256_MAX_DECIMAL.length && s <= U256_MAX_DECIMAL);
|
|
74
|
+
}
|
|
75
|
+
/** `https://<host>…/piece/<cid>`: printable ASCII, no query or fragment — it must name this piece. */
|
|
76
|
+
function isRetrievalUrl(url, cid) {
|
|
77
|
+
if (typeof url !== "string" || !url.startsWith("https://"))
|
|
78
|
+
return false;
|
|
79
|
+
const rest = url.slice("https://".length);
|
|
80
|
+
const slash = rest.indexOf("/");
|
|
81
|
+
const hostEnds = slash < 0 ? rest.length : slash;
|
|
82
|
+
return hostEnds > 0 && rest.endsWith(`/piece/${cid}`) && /^[\x21-\x7e]+$/.test(url) && !/[?#]/.test(url);
|
|
83
|
+
}
|
package/dist/recovery-map.d.ts
CHANGED
|
@@ -1,54 +1,19 @@
|
|
|
1
1
|
import type { ArtifactAbout } from "./artifact-about.ts";
|
|
2
2
|
import { NmtsError } from "./errors.ts";
|
|
3
|
+
import { type ManifestPart, type ManifestPartInput } from "./recovery-map-part.ts";
|
|
3
4
|
/** The newest NRM version this writer knows how to emit. */
|
|
4
|
-
export declare const NRM_VERSION_LATEST =
|
|
5
|
+
export declare const NRM_VERSION_LATEST = 5;
|
|
5
6
|
/** The first NRM version in which every part carries `part_index`. */
|
|
6
7
|
export declare const NRM_VERSION_WITH_PART_INDEX = 2;
|
|
7
8
|
/** The first NRM version in which a quilt placement may be `{ identifier }` alone. */
|
|
8
9
|
export declare const NRM_VERSION_WITH_OWN_QUILT = 3;
|
|
9
10
|
/** The first NRM version in which a part may carry `padded_len`. */
|
|
10
11
|
export declare const NRM_VERSION_WITH_PADDING = 4;
|
|
12
|
+
/** The first NRM version in which a part may be on Filecoin (`network`, `chain`, `copies`). */
|
|
13
|
+
export declare const NRM_VERSION_WITH_FILECOIN = 5;
|
|
11
14
|
/** Practical ceiling from RECOVERY-MANIFEST.md §1 — beyond this the format needs chunk framing. */
|
|
12
15
|
export declare const MANIFEST_ITEM_SOFT_CAP = 100000;
|
|
13
|
-
|
|
14
|
-
export interface ManifestPart {
|
|
15
|
-
/**
|
|
16
|
-
* Where this part belongs: 0 for the first, and the position it must be concatenated at
|
|
17
|
-
* thereafter. Required from NRM-2.
|
|
18
|
-
*
|
|
19
|
-
* It is written down because array order alone cannot be CHECKED. A reader holds each fetched
|
|
20
|
-
* part's 72-byte NCF-3 header, which carries the index sealed under the file key, so with this
|
|
21
|
-
* field it can compare three things that must agree: the position it is writing at, what the
|
|
22
|
-
* list says belongs there, and what the bytes themselves say they are.
|
|
23
|
-
*/
|
|
24
|
-
part_index: number;
|
|
25
|
-
/** Blob id holding this part's stream, in `network`'s own naming. */
|
|
26
|
-
blob_id?: string;
|
|
27
|
-
/** The REAL bytes this part contributes to the file. */
|
|
28
|
-
plaintext_len: number;
|
|
29
|
-
/**
|
|
30
|
-
* What the stored stream's header DECLARES, when the part was padded and that is larger.
|
|
31
|
-
* Absent means it was not padded. New in NRM-4.
|
|
32
|
-
*
|
|
33
|
-
* ⛔ THE TWO NUMBERS STAY APART so that "the parts sum to exactly `size`" keeps its exact
|
|
34
|
-
* strength. Folded into one, the check softens to "at least", which accepts any size below
|
|
35
|
-
* the real one: the file comes back short and nothing says so.
|
|
36
|
-
*/
|
|
37
|
-
padded_len?: number;
|
|
38
|
-
/** On-chain blob object, when the uploading client captured it. Omitted, never null. */
|
|
39
|
-
sui_object_id?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Which storage network holds `blob_id` — a NAME (`"walrus"`), not a code.
|
|
42
|
-
*
|
|
43
|
-
* A word rather than a number because whoever parses this may be doing so years from now with
|
|
44
|
-
* none of our code beside them, and a bare `1` is not something a stranger can look up.
|
|
45
|
-
*/
|
|
46
|
-
network?: string;
|
|
47
|
-
}
|
|
48
|
-
/** As a writer hands one in: the position is the value, so `part_index` is filled by the encoder. */
|
|
49
|
-
export interface ManifestPartInput extends Omit<ManifestPart, "part_index"> {
|
|
50
|
-
part_index?: number;
|
|
51
|
-
}
|
|
16
|
+
export type { ManifestFilecoinCopy, ManifestPart, ManifestPartInput } from "./recovery-map-part.ts";
|
|
52
17
|
/** Quilt placement naming a quilt anywhere on the network. */
|
|
53
18
|
export interface ManifestQuiltAbsolute {
|
|
54
19
|
quilt_blob_id: string;
|
package/dist/recovery-map.js
CHANGED
|
@@ -17,14 +17,17 @@
|
|
|
17
17
|
// real is not restated at all, because `shared/lib/crypto/size-padding.ts` is a byte-for-byte
|
|
18
18
|
// copy of the browser's own file and a gate compares them.
|
|
19
19
|
import { NmtsError } from "./errors.js";
|
|
20
|
+
import { filecoinForm, usesFilecoin } from "./recovery-map-part.js";
|
|
20
21
|
/** The newest NRM version this writer knows how to emit. */
|
|
21
|
-
export const NRM_VERSION_LATEST =
|
|
22
|
+
export const NRM_VERSION_LATEST = 5;
|
|
22
23
|
/** The first NRM version in which every part carries `part_index`. */
|
|
23
24
|
export const NRM_VERSION_WITH_PART_INDEX = 2;
|
|
24
25
|
/** The first NRM version in which a quilt placement may be `{ identifier }` alone. */
|
|
25
26
|
export const NRM_VERSION_WITH_OWN_QUILT = 3;
|
|
26
27
|
/** The first NRM version in which a part may carry `padded_len`. */
|
|
27
28
|
export const NRM_VERSION_WITH_PADDING = 4;
|
|
29
|
+
/** The first NRM version in which a part may be on Filecoin (`network`, `chain`, `copies`). */
|
|
30
|
+
export const NRM_VERSION_WITH_FILECOIN = 5;
|
|
28
31
|
/** Practical ceiling from RECOVERY-MANIFEST.md §1 — beyond this the format needs chunk framing. */
|
|
29
32
|
export const MANIFEST_ITEM_SOFT_CAP = 100_000;
|
|
30
33
|
/** Which form a placement is. One narrowing point, so "exactly one of the two" is decided here. */
|
|
@@ -62,6 +65,10 @@ export class RecoveryListProblem extends NmtsError {
|
|
|
62
65
|
* understood every byte of it.
|
|
63
66
|
*/
|
|
64
67
|
export function minimumVersion(items) {
|
|
68
|
+
// A list holding a Heavy (Filecoin) part is v5: a v4 reader would ask a Walrus aggregator for
|
|
69
|
+
// the piece and be told "not found", the same answer as an expired blob.
|
|
70
|
+
if (items.some((it) => it.parts.some(usesFilecoin)))
|
|
71
|
+
return NRM_VERSION_WITH_FILECOIN;
|
|
65
72
|
if (items.some((it) => it.parts.some((p) => p.padded_len !== undefined))) {
|
|
66
73
|
return NRM_VERSION_WITH_PADDING;
|
|
67
74
|
}
|
|
@@ -144,6 +151,16 @@ export function buildRecoveryListDoc(input) {
|
|
|
144
151
|
part.sui_object_id = p.sui_object_id;
|
|
145
152
|
if (p.network)
|
|
146
153
|
part.network = p.network;
|
|
154
|
+
// NRM-5: the reader refuses the WHOLE document over one bad Filecoin part, so the writer
|
|
155
|
+
// refuses to emit it instead of handing somebody a list that opens nothing.
|
|
156
|
+
const filecoin = filecoinForm(p, it.quilt !== undefined);
|
|
157
|
+
if (filecoin.kind === "refused") {
|
|
158
|
+
throw new RecoveryListProblem(`item ${it.id}: the part at position ${i} ${filecoin.why}`);
|
|
159
|
+
}
|
|
160
|
+
if (filecoin.kind === "filecoin") {
|
|
161
|
+
part.chain = filecoin.chain;
|
|
162
|
+
part.copies = filecoin.copies;
|
|
163
|
+
}
|
|
147
164
|
return part;
|
|
148
165
|
}),
|
|
149
166
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { HeavyCopy } from "./shared/lib/api/types-heavy.ts";
|
|
1
2
|
/** `file_parts.storage_kind` for a quilt patch. 0 is a dedicated blob. */
|
|
2
3
|
export declare const STORAGE_QUILT = 1;
|
|
3
4
|
/** One stored piece of a file, as the server describes it. */
|
|
@@ -11,6 +12,8 @@ export interface SourcePart {
|
|
|
11
12
|
/** What the part OCCUPIES: the sealed stream, header and tags included. */
|
|
12
13
|
sealed_len: number;
|
|
13
14
|
sui_object_id?: string;
|
|
15
|
+
/** Network 1 (NMTS Heavy): the companies keeping a whole copy, as the server recorded them. */
|
|
16
|
+
copies?: HeavyCopy[];
|
|
14
17
|
/**
|
|
15
18
|
* What this part's stored header DECLARES — the plaintext length behind `sealed_len`.
|
|
16
19
|
*
|
package/dist/recovery-source.js
CHANGED
|
@@ -21,6 +21,7 @@ import { request } from "./api.js";
|
|
|
21
21
|
import { NmtsError } from "./errors.js";
|
|
22
22
|
import { isRecord } from "./guards.js";
|
|
23
23
|
import { plaintextLenFromSealed } from "./seal.js";
|
|
24
|
+
import { readCopies } from "./shared/lib/heavy/order-wire.js";
|
|
24
25
|
/** `file_parts.storage_kind` for a quilt patch. 0 is a dedicated blob. */
|
|
25
26
|
export const STORAGE_QUILT = 1;
|
|
26
27
|
function unreadable(what) {
|
|
@@ -70,6 +71,14 @@ function partOf(value, itemId) {
|
|
|
70
71
|
const object = optionalStr(value, "sui_object_id");
|
|
71
72
|
if (object !== undefined)
|
|
72
73
|
part.sui_object_id = object;
|
|
74
|
+
// ⛔ A LIST THAT DOES NOT READ IS A REFUSAL, NOT A SKIP: a Heavy part written without its copies
|
|
75
|
+
// would be refused by every reader, and one written with half of them is a file half-covered.
|
|
76
|
+
if (value["copies"] !== undefined) {
|
|
77
|
+
const copies = readCopies(value["copies"]);
|
|
78
|
+
if (copies === null)
|
|
79
|
+
throw unreadable(`the copies of a stored part of file ${itemId}`);
|
|
80
|
+
part.copies = copies;
|
|
81
|
+
}
|
|
73
82
|
return part;
|
|
74
83
|
}
|
|
75
84
|
function itemOf(value) {
|
package/dist/risk.d.ts
CHANGED
|
@@ -56,6 +56,15 @@ export declare const ACTS: {
|
|
|
56
56
|
readonly "public-code": {
|
|
57
57
|
readonly tier: "none";
|
|
58
58
|
};
|
|
59
|
+
readonly "public-code.list": {
|
|
60
|
+
readonly tier: "none";
|
|
61
|
+
};
|
|
62
|
+
readonly handover: {
|
|
63
|
+
readonly tier: "none";
|
|
64
|
+
};
|
|
65
|
+
readonly link: {
|
|
66
|
+
readonly tier: "none";
|
|
67
|
+
};
|
|
59
68
|
readonly wallet: {
|
|
60
69
|
readonly tier: "none";
|
|
61
70
|
};
|
|
@@ -176,6 +185,10 @@ export declare const ACTS: {
|
|
|
176
185
|
readonly tier: "low";
|
|
177
186
|
readonly what: "Withdraw this share. Whoever had it cannot download it again.";
|
|
178
187
|
};
|
|
188
|
+
readonly "link.revoke": {
|
|
189
|
+
readonly tier: "low";
|
|
190
|
+
readonly what: "Cut a public link.";
|
|
191
|
+
};
|
|
179
192
|
readonly tip: {
|
|
180
193
|
readonly tier: "none";
|
|
181
194
|
};
|
|
@@ -249,7 +262,11 @@ export declare const ACTS: {
|
|
|
249
262
|
};
|
|
250
263
|
readonly "public-code.publish": {
|
|
251
264
|
readonly tier: "medium";
|
|
252
|
-
readonly what: "Publish this account's public code
|
|
265
|
+
readonly what: "Publish this account's public code so other accounts can send files to it.";
|
|
266
|
+
};
|
|
267
|
+
readonly "public-code.new": {
|
|
268
|
+
readonly tier: "medium";
|
|
269
|
+
readonly what: "Make a new public code for this account.";
|
|
253
270
|
};
|
|
254
271
|
readonly "losses.dismiss": {
|
|
255
272
|
readonly tier: "medium";
|
|
@@ -269,6 +286,17 @@ export declare const ACTS: {
|
|
|
269
286
|
readonly what: "Give another account this file.";
|
|
270
287
|
readonly asksItself: true;
|
|
271
288
|
};
|
|
289
|
+
readonly "handover.make": {
|
|
290
|
+
readonly tier: "high";
|
|
291
|
+
readonly lock: "share";
|
|
292
|
+
readonly what: "Give another account this file in a handover file. It cannot be taken back.";
|
|
293
|
+
readonly asksItself: true;
|
|
294
|
+
};
|
|
295
|
+
readonly "link.make": {
|
|
296
|
+
readonly tier: "high";
|
|
297
|
+
readonly lock: "share";
|
|
298
|
+
readonly what: "Anyone with the link can open this file. Cutting the link stops new downloads, but copies already downloaded stay with whoever has them.";
|
|
299
|
+
};
|
|
272
300
|
readonly "login.plain": {
|
|
273
301
|
readonly tier: "high";
|
|
274
302
|
readonly lock: "unsafe-code-storage";
|
|
@@ -299,6 +327,27 @@ export declare const ACTS: {
|
|
|
299
327
|
readonly what: "Sign transactions that spend WAL and SUI from the wallet.";
|
|
300
328
|
readonly standing: true;
|
|
301
329
|
};
|
|
330
|
+
readonly "put.evm": {
|
|
331
|
+
readonly tier: "high";
|
|
332
|
+
readonly lock: "wallet";
|
|
333
|
+
readonly what: "Sign Filecoin storage payments in USDFC from the EVM wallet this key derives.";
|
|
334
|
+
readonly standing: true;
|
|
335
|
+
};
|
|
336
|
+
readonly "push.evm": {
|
|
337
|
+
readonly tier: "high";
|
|
338
|
+
readonly lock: "wallet";
|
|
339
|
+
readonly what: "Sign Filecoin storage payments in USDFC from the EVM wallet this key derives.";
|
|
340
|
+
readonly standing: true;
|
|
341
|
+
};
|
|
342
|
+
readonly heavy: {
|
|
343
|
+
readonly tier: "none";
|
|
344
|
+
};
|
|
345
|
+
readonly "heavy.fund": {
|
|
346
|
+
readonly tier: "high";
|
|
347
|
+
readonly lock: "wallet";
|
|
348
|
+
readonly what: "Deposit USDFC from the EVM wallet this key derives into Filecoin Pay.";
|
|
349
|
+
readonly asksItself: true;
|
|
350
|
+
};
|
|
302
351
|
readonly "wallet.send": {
|
|
303
352
|
readonly tier: "high";
|
|
304
353
|
readonly lock: "wallet";
|
|
@@ -347,6 +396,11 @@ export declare const ACTS: {
|
|
|
347
396
|
readonly what: "Accept a new version of the Terms for this account.";
|
|
348
397
|
readonly asksItself: true;
|
|
349
398
|
};
|
|
399
|
+
readonly "public-code.revoke": {
|
|
400
|
+
readonly tier: "high";
|
|
401
|
+
readonly what: "Revoke a public code of this account. Nobody can send to it again, and nobody can bring it back.";
|
|
402
|
+
readonly asksItself: true;
|
|
403
|
+
};
|
|
350
404
|
readonly "delete-account": {
|
|
351
405
|
readonly tier: "ultra-high";
|
|
352
406
|
readonly what: "Erase this account's server record, permanently.";
|