@needmoretruth/nmts-cli 0.39.0 → 0.41.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.
Files changed (65) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.ko.md +27 -1
  3. package/README.md +29 -1
  4. package/dist/api-advice.js +6 -0
  5. package/dist/api.d.ts +10 -1
  6. package/dist/api.js +12 -2
  7. package/dist/arg-options.d.ts +21 -0
  8. package/dist/args.js +12 -1
  9. package/dist/artifact-about.d.ts +1 -1
  10. package/dist/commands/create-link.d.ts +9 -0
  11. package/dist/commands/create-link.js +31 -1
  12. package/dist/commands/create.d.ts +9 -0
  13. package/dist/commands/create.js +17 -0
  14. package/dist/commands/extend.d.ts +3 -3
  15. package/dist/commands/extend.js +52 -161
  16. package/dist/commands/login-passphrase.d.ts +13 -0
  17. package/dist/commands/login-passphrase.js +64 -0
  18. package/dist/commands/login.d.ts +3 -0
  19. package/dist/commands/login.js +15 -55
  20. package/dist/commands/openers-attach.d.ts +38 -0
  21. package/dist/commands/openers-attach.js +97 -0
  22. package/dist/commands/openers.d.ts +23 -0
  23. package/dist/commands/openers.js +195 -0
  24. package/dist/commands/wallet-storage-ops.d.ts +2 -2
  25. package/dist/commands/wallet-storage-ops.js +108 -134
  26. package/dist/commands/wallet-storage.d.ts +3 -8
  27. package/dist/commands/wallet-storage.js +16 -37
  28. package/dist/crypto-surface.d.ts +28 -0
  29. package/dist/crypto-surface.js +7 -0
  30. package/dist/help.js +15 -0
  31. package/dist/main.js +11 -12
  32. package/dist/openers/doors.d.ts +65 -0
  33. package/dist/openers/doors.js +97 -0
  34. package/dist/openers/hints.d.ts +22 -0
  35. package/dist/openers/hints.js +11 -0
  36. package/dist/openers/sign.d.ts +56 -0
  37. package/dist/openers/sign.js +202 -0
  38. package/dist/openers/wallet.d.ts +71 -0
  39. package/dist/openers/wallet.js +210 -0
  40. package/dist/openers-key-file.d.ts +14 -0
  41. package/dist/openers-key-file.js +99 -0
  42. package/dist/openers.d.ts +7 -0
  43. package/dist/openers.js +21 -0
  44. package/dist/product.d.ts +1 -1
  45. package/dist/product.js +1 -1
  46. package/dist/risk.d.ts +11 -0
  47. package/dist/risk.js +15 -0
  48. package/dist/storage-control/extend.d.ts +124 -0
  49. package/dist/storage-control/extend.js +189 -0
  50. package/dist/storage-control/hints.d.ts +20 -0
  51. package/dist/storage-control/hints.js +11 -0
  52. package/dist/storage-control/list.d.ts +55 -0
  53. package/dist/storage-control/list.js +71 -0
  54. package/dist/storage-control/reshape.d.ts +120 -0
  55. package/dist/storage-control/reshape.js +188 -0
  56. package/dist/storage-control-chain.d.ts +1 -1
  57. package/dist/storage-control.d.ts +13 -0
  58. package/dist/storage-control.js +24 -0
  59. package/dist/wallet-storage-chain.d.ts +1 -1
  60. package/docs/commands/openers.md +31 -0
  61. package/package.json +9 -1
  62. package/vendor/nmts-crypto/nmts_crypto_wasm.d.ts +54 -0
  63. package/vendor/nmts-crypto/nmts_crypto_wasm.js +108 -0
  64. package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm +0 -0
  65. package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm.d.ts +4 -0
@@ -0,0 +1,188 @@
1
+ // Cutting a storage resource, joining two of them, and handing one over — decided, priced, signed
2
+ // and handed back rather than printed.
3
+ //
4
+ // ⛔ ONE IMPLEMENTATION, TWO CALLERS, which is the whole reason this file exists. `nmts wallet
5
+ // storage split|merge|transfer` is a terminal's shape: it prints a review, asks for `--yes` and
6
+ // answers an exit code. The SDK is somebody else's program and needs the same acts with none of
7
+ // those. A second implementation of "what may be joined with what" would be a second place for
8
+ // the contract's rules to be got right, and the copy nobody re-reads is the one that quietly
9
+ // disagrees — about transactions that spend a fee and cannot be undone.
10
+ //
11
+ // ⛔ THE ORDER IS THE SAFETY, and it is here rather than in either caller: ① the resources are READ
12
+ // from the chain and the named ones must be this wallet's ② the browser's rules judge the request
13
+ // and say why not ③ the exact transaction is dry-run for its fee, and a refusal there ends the
14
+ // run ④ the review is handed out ⑤ `dryRun` stops here ⑥ `agree` is the gate — whatever it throws
15
+ // stops the run with nothing signed ⑦ only then the signature.
16
+ //
17
+ // ⛔ HANDING ONE OVER MOVES NO FILE. What goes is size and remaining time; a file's bytes are sealed
18
+ // with keys the NMTS key derives and stay unreadable to whoever receives the resource. It cannot
19
+ // be undone and NMTS cannot recall it.
20
+ //
21
+ // ⚠ NOTHING HERE WRITES TO A STREAM, ASKS ANYBODY ANYTHING OR PICKS AN EXIT CODE, and nothing
22
+ // reaches for `node:` — the chain and the signature are loaded only when no seam was supplied.
23
+ import { NmtsError } from "../errors.js";
24
+ import { canFuse } from "../shared/lib/storage-control/plan.js";
25
+ import { isValidSuiAddress } from "../shared/lib/wallet/send-rules.js";
26
+ import { formatBytes, readOrRefuse } from "./list.js";
27
+ /** Why two resources cannot be joined, in the contract's own terms. */
28
+ const FUSE_WHY = {
29
+ same: "those are the same resource.",
30
+ differentSize: "their periods differ and so do their sizes — the contract joins sizes only over an identical period, and periods only at an identical size.",
31
+ differentPeriod: "their periods differ.",
32
+ notAdjacent: "their sizes are equal but their periods do not touch — one has to end where the other starts.",
33
+ };
34
+ /**
35
+ * Judge one request against the resources this wallet actually holds.
36
+ *
37
+ * ⛔ EVERY REFUSAL HAPPENS HERE, BEFORE THE CHAIN IS ASKED ANYTHING. Letting the contract refuse it
38
+ * instead leaves somebody having paid gas with no idea why — the rule the browser's own
39
+ * judgement (`shared/lib/storage-control/plan.ts`) was written for.
40
+ */
41
+ export function planStorageOp(held, ask, hints = {}) {
42
+ const one = (id) => {
43
+ const found = held.find((r) => r.objectId === id);
44
+ if (found === undefined) {
45
+ throw new NmtsError(`This wallet holds no free storage resource ${id}.`, {
46
+ exitCode: 4,
47
+ nextStep: hints.notHeld ??
48
+ "Nothing was signed. A storage listing shows the free ones it holds; a resource bound " +
49
+ "inside a file is not free.",
50
+ });
51
+ }
52
+ return found;
53
+ };
54
+ // ⛔ THE JUDGEMENT IS HERE AND THE WORD FOR IT IS THE CALLER'S. What was too big has a different
55
+ // name at a prompt and in a program, and neither should be told about the other's.
56
+ const tooBig = (what, limit) => hints.cut?.(what, limit) ??
57
+ new NmtsError(what === "size"
58
+ ? `A cut by size keeps above 0 and below the resource's ${limit}.`
59
+ : `A cut by period keeps a whole number of epochs above 0 and below the resource's ${limit}.`, { exitCode: 2, nextStep: "Nothing was signed. The rest becomes a second resource, so there has to be a rest." });
60
+ const shapeOf = (r) => ({
61
+ sizeBytes: r.sizeBytes,
62
+ startEpoch: r.startEpoch,
63
+ endEpoch: r.endEpoch,
64
+ });
65
+ if (ask.kind === "splitSize") {
66
+ const r = one(ask.objectId);
67
+ if (ask.keepBytes <= 0 || ask.keepBytes >= r.sizeBytes)
68
+ throw tooBig("size", formatBytes(r.sizeBytes));
69
+ return {
70
+ op: "split",
71
+ shape: { kind: "splitSize", objectId: ask.objectId, keepBytes: ask.keepBytes },
72
+ action: "reshape",
73
+ named: [r],
74
+ result: {
75
+ kind: "split",
76
+ keeps: { ...shapeOf(r), sizeBytes: ask.keepBytes },
77
+ creates: { ...shapeOf(r), sizeBytes: r.sizeBytes - ask.keepBytes },
78
+ },
79
+ };
80
+ }
81
+ if (ask.kind === "splitEpochs") {
82
+ const r = one(ask.objectId);
83
+ const span = r.endEpoch - r.startEpoch;
84
+ if (!Number.isSafeInteger(ask.keepEpochs) || ask.keepEpochs <= 0 || ask.keepEpochs >= span) {
85
+ throw tooBig("period", String(span));
86
+ }
87
+ const at = r.startEpoch + ask.keepEpochs;
88
+ return {
89
+ op: "split",
90
+ shape: { kind: "splitEpoch", objectId: ask.objectId, splitEpoch: at },
91
+ action: "reshape",
92
+ named: [r],
93
+ result: {
94
+ kind: "split",
95
+ keeps: { ...shapeOf(r), endEpoch: at },
96
+ creates: { ...shapeOf(r), startEpoch: at },
97
+ },
98
+ };
99
+ }
100
+ if (ask.kind === "merge") {
101
+ const first = one(ask.first);
102
+ const second = one(ask.second);
103
+ const verdict = canFuse(first, second);
104
+ if (!verdict.can) {
105
+ throw new NmtsError(`These two cannot be joined: ${FUSE_WHY[verdict.why]}`, {
106
+ exitCode: 4,
107
+ nextStep: "Nothing was signed. A storage listing shows each one's size and period.",
108
+ });
109
+ }
110
+ return {
111
+ op: "merge",
112
+ shape: { kind: "fuse", first: ask.first, second: ask.second, how: verdict.kind },
113
+ action: "reshape",
114
+ named: [first, second],
115
+ result: {
116
+ kind: "merge",
117
+ how: verdict.kind,
118
+ consumed: ask.second,
119
+ becomes: verdict.kind === "amount"
120
+ ? { ...shapeOf(first), sizeBytes: first.sizeBytes + second.sizeBytes }
121
+ : {
122
+ sizeBytes: first.sizeBytes,
123
+ startEpoch: Math.min(first.startEpoch, second.startEpoch),
124
+ endEpoch: Math.max(first.endEpoch, second.endEpoch),
125
+ },
126
+ },
127
+ };
128
+ }
129
+ const r = one(ask.objectId);
130
+ // ⛔ THE ADDRESS IS JUDGED BEFORE THE CHAIN IS ASKED. A resource sent to a mistyped address is
131
+ // gone: nothing here, and nobody at NMTS, can recall it.
132
+ if (!isValidSuiAddress(ask.to)) {
133
+ throw new NmtsError("That is not a Sui address: it is 0x followed by 64 hexadecimal characters.", {
134
+ exitCode: 2,
135
+ nextStep: "Nothing was signed. Check the address it should go to.",
136
+ });
137
+ }
138
+ return {
139
+ op: "transfer",
140
+ shape: { kind: "transfer", objectId: ask.objectId, to: ask.to },
141
+ action: "give",
142
+ named: [r],
143
+ result: { kind: "transfer", moves: shapeOf(r), to: ask.to },
144
+ };
145
+ }
146
+ /** Read, judge, price and — unless somebody stops it — sign one change to a storage resource. */
147
+ export async function reshapeStorage(context, ask, seams = {}) {
148
+ const reads = seams.reads === undefined
149
+ ? (await import("../storage-control-chain.js")).storageOpsReads(context.network)
150
+ : seams.reads(context.network);
151
+ // ① The resources, and which epoch it is.
152
+ const read = await readOrRefuse(() => reads.readStorage(context.address), seams.hints ?? {});
153
+ // ② The request, judged.
154
+ const plan = planStorageOp(read.items, ask, seams.hints ?? {});
155
+ const walrusPackageId = await reads.walrusPackageId();
156
+ // ③ The dry run: the fee, or the contract's own refusal.
157
+ const verdict = await reads.dryRun(plan.shape, context.address);
158
+ if (verdict.refusal !== null) {
159
+ throw new NmtsError(`The chain would refuse this: ${verdict.refusal}`, {
160
+ exitCode: 4,
161
+ nextStep: "Nothing was signed and no fee was spent.",
162
+ });
163
+ }
164
+ // ④ The review.
165
+ const review = {
166
+ plan,
167
+ address: context.address,
168
+ network: context.network,
169
+ currentEpoch: read.currentEpoch,
170
+ feeMist: verdict.feeMist,
171
+ };
172
+ seams.onReview?.(review);
173
+ // ⑤ Stopped here, with nothing signed.
174
+ if (seams.dryRun === true)
175
+ return { kind: "review", review };
176
+ // ⑥ The gate.
177
+ seams.agree?.(review);
178
+ // ⑦ The signature.
179
+ const sign = seams.sign ?? (await import("../wallet-sign.js")).signStorageOp;
180
+ const digest = await sign({
181
+ network: context.network,
182
+ code: context.code,
183
+ wallet: context.wallet,
184
+ shape: plan.shape,
185
+ walrusPackageId,
186
+ });
187
+ return { kind: "done", review, digest };
188
+ }
@@ -1,6 +1,6 @@
1
1
  import { Transaction } from "@mysten/sui/transactions";
2
2
  import type { Network } from "./network.ts";
3
- import type { StorageRead } from "./commands/wallet-storage.ts";
3
+ import type { StorageRead } from "./storage-control/list.ts";
4
4
  export type StorageOpShape = {
5
5
  kind: "splitSize";
6
6
  objectId: string;
@@ -0,0 +1,13 @@
1
+ export type { StorageHints } from "./storage-control/hints.ts";
2
+ export { formatBytes, listStorage, readOrRefuse } from "./storage-control/list.ts";
3
+ export type { ReadWalletStorage, StorageItem, StorageListing, StorageRead, StorageStatus, } from "./storage-control/list.ts";
4
+ export { applyExtension, nothingToExtend, planExtension } from "./storage-control/extend.ts";
5
+ export type { ExtendApplySeams, ExtendFacts, ExtendInput, ExtendOutcome, ExtendPlan, ExtendPlanSeams, } from "./storage-control/extend.ts";
6
+ export { planStorageOp, reshapeStorage } from "./storage-control/reshape.ts";
7
+ export type { ReshapeContext, ReshapeOutcome, ReshapeSeams, StorageOp, StorageOpAsk, StorageOpPlan, StorageOpResult, StorageOpReview, StorageShape, } from "./storage-control/reshape.ts";
8
+ export type { StorageOpShape, StorageOpsReads } from "./storage-control-chain.ts";
9
+ export type { StorageResource } from "./shared/lib/storage-control/chain.ts";
10
+ export { DEFAULT_EXTEND_EPOCHS } from "./extend-plan.ts";
11
+ export type { ExtendReads, SignExtension } from "./extend-plan.ts";
12
+ export type { Budget } from "./extend-budget.ts";
13
+ export type { SignStorageOp } from "./wallet-sign-seams.ts";
@@ -0,0 +1,24 @@
1
+ // Storage control without a terminal: what a wallet holds, extending a file's term, and cutting,
2
+ // joining and handing over a resource — decided, priced, signed and handed back rather than printed.
3
+ //
4
+ // ⛔ ONE IMPLEMENTATION, TWO CALLERS, which is the whole reason this entry exists. `nmts extend` and
5
+ // `nmts wallet storage …` are a terminal over these functions: the review a person reads, the
6
+ // question that is asked, the wallet unlock this machine keeps, the exit code. The SDK is
7
+ // somebody else's program and needs the same acts with none of those. A second implementation of
8
+ // "what may be joined with what", or of the order an extension is bought in, would be a second
9
+ // place for rules about money that does not come back to be got right — and the copy nobody
10
+ // re-reads is the one that quietly disagrees.
11
+ //
12
+ // ⛔ NOTHING HERE WRITES TO A STREAM, PICKS AN EXIT CODE OR ASKS ANYBODY ANYTHING. Every refusal is
13
+ // thrown and every outcome is returned; the words a person reads are the caller's, and so is the
14
+ // agreement — a terminal asks for one, a program makes it by calling.
15
+ //
16
+ // ⚠ THE PIECES LIVE IN `storage-control/`, AND THIS IS THE DOOR TO THEM. What a caller imports is
17
+ // this name — `@needmoretruth/nmts-cli/storage-control` — so the pieces can be split and joined
18
+ // without a single caller changing. Nothing in the folder reaches for `node:`: the SDK's browser
19
+ // entry bundles what this exports, and the chain and the signer are loaded only when no seam was
20
+ // supplied.
21
+ export { formatBytes, listStorage, readOrRefuse } from "./storage-control/list.js";
22
+ export { applyExtension, nothingToExtend, planExtension } from "./storage-control/extend.js";
23
+ export { planStorageOp, reshapeStorage } from "./storage-control/reshape.js";
24
+ export { DEFAULT_EXTEND_EPOCHS } from "./extend-plan.js";
@@ -1,3 +1,3 @@
1
- import type { StorageRead } from "./commands/wallet-storage.ts";
1
+ import type { StorageRead } from "./storage-control/list.ts";
2
2
  import type { Network } from "./network.ts";
3
3
  export declare function readWalletStorage(network: Network, address: string): Promise<StorageRead>;
@@ -0,0 +1,31 @@
1
+ # nmts openers — the wallets that open this account
2
+
3
+ Commands: openers
4
+ Tiers: openers=none · openers.add=medium · openers.remove=medium
5
+
6
+ An opener is a second way into the account. The account keeps its NMTS key, and that key is still
7
+ the root; an opener is a copy of it on the NMTS server, locked so that only one wallet's signature of
8
+ one fixed message opens it. NMTS cannot open the copy and does not learn which wallet it belongs to.
9
+
10
+ `nmts openers` lists what this account has — a locator, the kind, the day it was added — and how
11
+ many it may have. `nmts openers add --sui-key-file <file>` attaches a wallet, and
12
+ `nmts openers remove <locator>` takes one off. All three need the NMTS key beside the API key.
13
+
14
+ The file holds one `suiprivkey1…` line. The wallet's key is read, used to sign, never printed, and
15
+ never accepted as an option value. `--account <n>` (default 1) picks which of that wallet's accounts
16
+ and `--app <name>` makes a key for one product only; both are inside the signed message, so another
17
+ value is another signature and another account.
18
+
19
+ Attaching asks the wallet to sign the same message twice and refuses unless the two signatures are
20
+ the same bytes: a wallet that signs differently each time would lock a copy it could never open
21
+ again. A multi-signature account, a zkLogin account and a passkey account are refused by name.
22
+
23
+ Whoever holds an attached wallet can open every file in this account, from any machine, until it is
24
+ removed. Removing stops it from then on. It does not undo the past: a wallet that opened the account
25
+ once has held the NMTS key.
26
+
27
+ A locator that begins with `-` needs `--` before it: `nmts openers remove -- -4FEW…`. The line the
28
+ tool prints after an attach already carries it when it is needed.
29
+
30
+ `nmts login --wallet --sui-key-file <file>` signs in with an attached wallet, and
31
+ `nmts create --wallet --sui-key-file <file>` makes an account and attaches the wallet to it.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@needmoretruth/nmts-cli",
3
- "version": "0.39.0",
3
+ "version": "0.41.0",
4
4
  "description": "Command-line and MCP access to NMTS (NeedMoreTruthStorage, https://nmts.me): open-source, end-to-end encrypted storage on the Walrus network. No fee to NMTS; you pay the network from your own wallet. For people and for their agents.",
5
5
  "license": "Apache-2.0",
6
6
  "publishConfig": {
@@ -85,6 +85,14 @@
85
85
  "types": "./dist/drive-erase.d.ts",
86
86
  "default": "./dist/drive-erase.js"
87
87
  },
88
+ "./openers": {
89
+ "types": "./dist/openers.d.ts",
90
+ "default": "./dist/openers.js"
91
+ },
92
+ "./storage-control": {
93
+ "types": "./dist/storage-control.d.ts",
94
+ "default": "./dist/storage-control.js"
95
+ },
88
96
  "./s3-gateway": {
89
97
  "types": "./dist/s3-gateway.d.ts",
90
98
  "default": "./dist/s3-gateway.js"
@@ -253,6 +253,56 @@ export function header_plaintext_len(header: Uint8Array): number;
253
253
  */
254
254
  export function kdf_derive(code_bytes: Uint8Array): Uint8Array;
255
255
 
256
+ /**
257
+ * The 16-byte LOCATOR a wallet signature yields — the name the server files this opener's slot
258
+ * under, and the name a sign-in asks for it back by (NCF-3 §1.7).
259
+ *
260
+ * Accepts flag `0x00` Ed25519 (97 bytes), `0x01` secp256k1 and `0x02` secp256r1 (98). Refuses
261
+ * `0x03` multisig, `0x05` zkLogin, `0x06` passkey, any other flag, and an accepted flag at the
262
+ * wrong length — each with its own message, because the caller has to tell a person which one it
263
+ * was and what to do instead.
264
+ *
265
+ * ⚠ It does NOT verify the signature. Checking it against the address in the message is the
266
+ * caller's step, with the Sui library.
267
+ */
268
+ export function opener_locator(serialized_signature: Uint8Array): Uint8Array;
269
+
270
+ /**
271
+ * The EXACT bytes a Sui wallet is asked to sign to open an NMTS account (NCF-3 §1.7). LF endings,
272
+ * no trailing newline, ASCII.
273
+ *
274
+ * ⛔ Built HERE rather than in JavaScript, and that is why this export exists at all: the browser,
275
+ * the command line and the recovery tool must ask for the same bytes, and one character of drift
276
+ * between them is a slot that no longer opens. One implementation, one message.
277
+ *
278
+ * Throws when `address` is not `0x` + 64 LOWERCASE hex, when `account` is 0, or when `app` is not
279
+ * 1–64 characters of `a-z0-9.-` starting and ending alphanumeric — and never repairs any of them,
280
+ * because all three are inside the bytes a person reads in the wallet popup.
281
+ */
282
+ export function opener_message(address: string, account: number, app?: string | null): Uint8Array;
283
+
284
+ /**
285
+ * The 20 NMTS-KEY bytes inside `slot`, opened with this wallet's signature (NCF-3 §1.7).
286
+ *
287
+ * Throws with a named reason for a slot of the wrong length or an unknown version, and with one
288
+ * indistinguishable "this signature does not open this slot" for a different wallet, a different
289
+ * message or altered bytes — telling those three apart would tell somebody holding a fetched slot
290
+ * whether their guess was getting warmer.
291
+ *
292
+ * ⛔ What comes back IS the account. The caller hands it straight to the sign-in path and drops
293
+ * it; it is never sent anywhere and never logged.
294
+ */
295
+ export function opener_open(serialized_signature: Uint8Array, slot: Uint8Array): Uint8Array;
296
+
297
+ /**
298
+ * The 62-byte SLOT holding `nmts_key` (the account's 20 key bytes) under this wallet's signature
299
+ * (NCF-3 §1.7): `version(1) || kind(1) || nonce(24) || XChaCha20-Poly1305(20 + 16)`.
300
+ *
301
+ * The nonce is drawn here from the browser's WebCrypto; there is no caller-nonce path in this
302
+ * build. The result is what goes to the server, and the server can do nothing with it.
303
+ */
304
+ export function opener_seal(serialized_signature: Uint8Array, nmts_key: Uint8Array): Uint8Array;
305
+
256
306
  /**
257
307
  * The name this account's recovery manifest is stored under inside a quilt (NCF-3 §2.5).
258
308
  *
@@ -457,6 +507,10 @@ export interface InitOutput {
457
507
  readonly verify_part_set: (a: number, b: number) => [number, number];
458
508
  readonly voucher_hash_from_input: (a: number, b: number) => [number, number];
459
509
  readonly wallet_seed_for: (a: number, b: number, c: number) => [number, number, number, number];
510
+ readonly opener_locator: (a: number, b: number) => [number, number, number, number];
511
+ readonly opener_message: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
512
+ readonly opener_open: (a: number, b: number, c: number, d: number) => [number, number, number, number];
513
+ readonly opener_seal: (a: number, b: number, c: number, d: number) => [number, number, number, number];
460
514
  readonly __wbindgen_exn_store: (a: number) => void;
461
515
  readonly __externref_table_alloc: () => number;
462
516
  readonly __wbindgen_externrefs: WebAssembly.Table;
@@ -599,6 +599,114 @@ export function kdf_derive(code_bytes) {
599
599
  return v2;
600
600
  }
601
601
 
602
+ /**
603
+ * The 16-byte LOCATOR a wallet signature yields — the name the server files this opener's slot
604
+ * under, and the name a sign-in asks for it back by (NCF-3 §1.7).
605
+ *
606
+ * Accepts flag `0x00` Ed25519 (97 bytes), `0x01` secp256k1 and `0x02` secp256r1 (98). Refuses
607
+ * `0x03` multisig, `0x05` zkLogin, `0x06` passkey, any other flag, and an accepted flag at the
608
+ * wrong length — each with its own message, because the caller has to tell a person which one it
609
+ * was and what to do instead.
610
+ *
611
+ * ⚠ It does NOT verify the signature. Checking it against the address in the message is the
612
+ * caller's step, with the Sui library.
613
+ * @param {Uint8Array} serialized_signature
614
+ * @returns {Uint8Array}
615
+ */
616
+ export function opener_locator(serialized_signature) {
617
+ const ptr0 = passArray8ToWasm0(serialized_signature, wasm.__wbindgen_malloc);
618
+ const len0 = WASM_VECTOR_LEN;
619
+ const ret = wasm.opener_locator(ptr0, len0);
620
+ if (ret[3]) {
621
+ throw takeFromExternrefTable0(ret[2]);
622
+ }
623
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
624
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
625
+ return v2;
626
+ }
627
+
628
+ /**
629
+ * The EXACT bytes a Sui wallet is asked to sign to open an NMTS account (NCF-3 §1.7). LF endings,
630
+ * no trailing newline, ASCII.
631
+ *
632
+ * ⛔ Built HERE rather than in JavaScript, and that is why this export exists at all: the browser,
633
+ * the command line and the recovery tool must ask for the same bytes, and one character of drift
634
+ * between them is a slot that no longer opens. One implementation, one message.
635
+ *
636
+ * Throws when `address` is not `0x` + 64 LOWERCASE hex, when `account` is 0, or when `app` is not
637
+ * 1–64 characters of `a-z0-9.-` starting and ending alphanumeric — and never repairs any of them,
638
+ * because all three are inside the bytes a person reads in the wallet popup.
639
+ * @param {string} address
640
+ * @param {number} account
641
+ * @param {string | null} [app]
642
+ * @returns {Uint8Array}
643
+ */
644
+ export function opener_message(address, account, app) {
645
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
646
+ const len0 = WASM_VECTOR_LEN;
647
+ var ptr1 = isLikeNone(app) ? 0 : passStringToWasm0(app, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
648
+ var len1 = WASM_VECTOR_LEN;
649
+ const ret = wasm.opener_message(ptr0, len0, account, ptr1, len1);
650
+ if (ret[3]) {
651
+ throw takeFromExternrefTable0(ret[2]);
652
+ }
653
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
654
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
655
+ return v3;
656
+ }
657
+
658
+ /**
659
+ * The 20 NMTS-KEY bytes inside `slot`, opened with this wallet's signature (NCF-3 §1.7).
660
+ *
661
+ * Throws with a named reason for a slot of the wrong length or an unknown version, and with one
662
+ * indistinguishable "this signature does not open this slot" for a different wallet, a different
663
+ * message or altered bytes — telling those three apart would tell somebody holding a fetched slot
664
+ * whether their guess was getting warmer.
665
+ *
666
+ * ⛔ What comes back IS the account. The caller hands it straight to the sign-in path and drops
667
+ * it; it is never sent anywhere and never logged.
668
+ * @param {Uint8Array} serialized_signature
669
+ * @param {Uint8Array} slot
670
+ * @returns {Uint8Array}
671
+ */
672
+ export function opener_open(serialized_signature, slot) {
673
+ const ptr0 = passArray8ToWasm0(serialized_signature, wasm.__wbindgen_malloc);
674
+ const len0 = WASM_VECTOR_LEN;
675
+ const ptr1 = passArray8ToWasm0(slot, wasm.__wbindgen_malloc);
676
+ const len1 = WASM_VECTOR_LEN;
677
+ const ret = wasm.opener_open(ptr0, len0, ptr1, len1);
678
+ if (ret[3]) {
679
+ throw takeFromExternrefTable0(ret[2]);
680
+ }
681
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
682
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
683
+ return v3;
684
+ }
685
+
686
+ /**
687
+ * The 62-byte SLOT holding `nmts_key` (the account's 20 key bytes) under this wallet's signature
688
+ * (NCF-3 §1.7): `version(1) || kind(1) || nonce(24) || XChaCha20-Poly1305(20 + 16)`.
689
+ *
690
+ * The nonce is drawn here from the browser's WebCrypto; there is no caller-nonce path in this
691
+ * build. The result is what goes to the server, and the server can do nothing with it.
692
+ * @param {Uint8Array} serialized_signature
693
+ * @param {Uint8Array} nmts_key
694
+ * @returns {Uint8Array}
695
+ */
696
+ export function opener_seal(serialized_signature, nmts_key) {
697
+ const ptr0 = passArray8ToWasm0(serialized_signature, wasm.__wbindgen_malloc);
698
+ const len0 = WASM_VECTOR_LEN;
699
+ const ptr1 = passArray8ToWasm0(nmts_key, wasm.__wbindgen_malloc);
700
+ const len1 = WASM_VECTOR_LEN;
701
+ const ret = wasm.opener_seal(ptr0, len0, ptr1, len1);
702
+ if (ret[3]) {
703
+ throw takeFromExternrefTable0(ret[2]);
704
+ }
705
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
706
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
707
+ return v3;
708
+ }
709
+
602
710
  /**
603
711
  * The name this account's recovery manifest is stored under inside a quilt (NCF-3 §2.5).
604
712
  *
@@ -46,6 +46,10 @@ export const streamencryptor_resumeFromHeader: (a: number, b: number, c: number,
46
46
  export const verify_part_set: (a: number, b: number) => [number, number];
47
47
  export const voucher_hash_from_input: (a: number, b: number) => [number, number];
48
48
  export const wallet_seed_for: (a: number, b: number, c: number) => [number, number, number, number];
49
+ export const opener_locator: (a: number, b: number) => [number, number, number, number];
50
+ export const opener_message: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
51
+ export const opener_open: (a: number, b: number, c: number, d: number) => [number, number, number, number];
52
+ export const opener_seal: (a: number, b: number, c: number, d: number) => [number, number, number, number];
49
53
  export const __wbindgen_exn_store: (a: number) => void;
50
54
  export const __externref_table_alloc: () => number;
51
55
  export const __wbindgen_externrefs: WebAssembly.Table;