@needmoretruth/nmts-cli 0.40.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 (47) hide show
  1. package/CHANGELOG.md +16 -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/login-passphrase.d.ts +13 -0
  15. package/dist/commands/login-passphrase.js +64 -0
  16. package/dist/commands/login.d.ts +3 -0
  17. package/dist/commands/login.js +15 -55
  18. package/dist/commands/openers-attach.d.ts +38 -0
  19. package/dist/commands/openers-attach.js +97 -0
  20. package/dist/commands/openers.d.ts +23 -0
  21. package/dist/commands/openers.js +195 -0
  22. package/dist/crypto-surface.d.ts +28 -0
  23. package/dist/crypto-surface.js +7 -0
  24. package/dist/help.js +15 -0
  25. package/dist/main.js +11 -12
  26. package/dist/openers/doors.d.ts +65 -0
  27. package/dist/openers/doors.js +97 -0
  28. package/dist/openers/hints.d.ts +22 -0
  29. package/dist/openers/hints.js +11 -0
  30. package/dist/openers/sign.d.ts +56 -0
  31. package/dist/openers/sign.js +202 -0
  32. package/dist/openers/wallet.d.ts +71 -0
  33. package/dist/openers/wallet.js +210 -0
  34. package/dist/openers-key-file.d.ts +14 -0
  35. package/dist/openers-key-file.js +99 -0
  36. package/dist/openers.d.ts +7 -0
  37. package/dist/openers.js +21 -0
  38. package/dist/product.d.ts +1 -1
  39. package/dist/product.js +1 -1
  40. package/dist/risk.d.ts +11 -0
  41. package/dist/risk.js +15 -0
  42. package/docs/commands/openers.md +31 -0
  43. package/package.json +5 -1
  44. package/vendor/nmts-crypto/nmts_crypto_wasm.d.ts +54 -0
  45. package/vendor/nmts-crypto/nmts_crypto_wasm.js +108 -0
  46. package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm +0 -0
  47. package/vendor/nmts-crypto/nmts_crypto_wasm_bg.wasm.d.ts +4 -0
@@ -0,0 +1,99 @@
1
+ // The only wallet a terminal has: one `suiprivkey1…` line in a file this run is pointed at.
2
+ //
3
+ // ⛔ THE VALUE IS NEVER AN ARGUMENT AND NEVER PRINTED. A secret on a command line is readable by
4
+ // any process on the machine and is recorded by the shell, which is why every option table in
5
+ // this tool names paths and not values (`args.ts`). What this file takes is a PATH; what it
6
+ // hands back is a function that signs one message, and an address.
7
+ //
8
+ // ⛔ AND THE KEY DOES NOT COME BACK OUT. `wallet-sign.ts` keeps that rule for the wallets this
9
+ // account's own NMTS key derives; this is the other kind — somebody else's wallet, held for one
10
+ // run — and the rule is the same: the keypair is built inside a closure, asked for signatures
11
+ // over one message, and never returned, logged or copied.
12
+ //
13
+ // ⛔ IT CATCHES ITS OWN PARSER. `errors.ts` says why: an unknown error's message goes to stderr
14
+ // verbatim, and a decoder that fails on a secret-bearing file has been measured quoting the
15
+ // input back. Every failure below is this tool's own sentence, naming the path and never the
16
+ // contents.
17
+ //
18
+ // ⚠ NODE ONLY, WHICH IS WHY IT IS NOT IN `openers/`. That folder is bundled into a page by the
19
+ // SDK's browser entry; a page's wallet is an extension, and this one is a file on a disk.
20
+ import { readFileSync } from "node:fs";
21
+ import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
22
+ import { Secp256k1Keypair } from "@mysten/sui/keypairs/secp256k1";
23
+ import { Secp256r1Keypair } from "@mysten/sui/keypairs/secp256r1";
24
+ import { decodeSuiPrivateKey } from "@mysten/sui/cryptography";
25
+ import { NmtsError } from "./errors.js";
26
+ /**
27
+ * The wallet held in `path`, ready to sign the opener message.
28
+ *
29
+ * The file holds one `suiprivkey1…` line — what `sui keytool export` writes and what every Sui
30
+ * tool reads. Surrounding whitespace and a trailing newline are ignored, because writing a secret
31
+ * to a file with `echo` appends one and refusing it would be a puzzle with no clue.
32
+ */
33
+ export function walletFromKeyFile(path) {
34
+ const keypair = keypairFrom(readOneLine(path), path);
35
+ return {
36
+ address: keypair.toSuiAddress(),
37
+ // ⛔ THE CLOSURE HOLDS THE KEYPAIR AND NOTHING HOLDS THE CLOSURE PAST THE RUN. What it answers
38
+ // is the wallet standard's own pair — the serialized signature, and the bytes it signed, so
39
+ // that the layer above compares them against the message it built rather than trusting it.
40
+ sign: async (message) => keypair.signPersonalMessage(message),
41
+ };
42
+ }
43
+ /** The first line with anything on it, or this tool's own refusal. */
44
+ function readOneLine(path) {
45
+ let raw;
46
+ try {
47
+ raw = readFileSync(path, "utf8");
48
+ }
49
+ catch {
50
+ // ⛔ THE CAUSE IS NOT CARRIED. Node's own message for a read failure quotes the path, which is
51
+ // fine, but a decoding failure inside it would quote the contents, which is not.
52
+ throw new NmtsError(`Could not read ${path}.`, {
53
+ exitCode: 2,
54
+ // Copy facts — the next step. Facts: the file holds one line beginning `suiprivkey1`, it is
55
+ // read and never copied or written to, and nothing was signed.
56
+ nextStep: "Nothing was signed. Point --sui-key-file at a file holding one `suiprivkey1…` line.",
57
+ });
58
+ }
59
+ const line = raw.split("\n").map((l) => l.trim()).find((l) => l !== "");
60
+ if (line === undefined || !line.startsWith("suiprivkey1")) {
61
+ throw new NmtsError(`${path} does not hold a Sui private key.`, {
62
+ exitCode: 2,
63
+ nextStep: "Nothing was signed. The file holds one line beginning `suiprivkey1`.",
64
+ });
65
+ }
66
+ return line;
67
+ }
68
+ /** The keypair that line names, for the three schemes an opener may use. */
69
+ function keypairFrom(line, path) {
70
+ let decoded;
71
+ try {
72
+ decoded = decodeSuiPrivateKey(line);
73
+ }
74
+ catch {
75
+ throw new NmtsError(`${path} does not hold a Sui private key this version can read.`, {
76
+ exitCode: 2,
77
+ nextStep: "Nothing was signed. The line is the one `sui keytool export` writes.",
78
+ });
79
+ }
80
+ const { scheme, secretKey } = decoded;
81
+ try {
82
+ if (scheme === "ED25519")
83
+ return Ed25519Keypair.fromSecretKey(secretKey);
84
+ if (scheme === "Secp256k1")
85
+ return Secp256k1Keypair.fromSecretKey(secretKey);
86
+ if (scheme === "Secp256r1")
87
+ return Secp256r1Keypair.fromSecretKey(secretKey);
88
+ }
89
+ finally {
90
+ // The keypair copied what it needed; this buffer is the only other one.
91
+ secretKey.fill(0);
92
+ }
93
+ // ⚠ An allow list, exactly as the layer above keeps: a scheme nobody has judged is refused for
94
+ // being unknown rather than let through for being new.
95
+ throw new NmtsError(`WALLET_UNKNOWN_SCHEME: ${path} holds a ${scheme} key.`, {
96
+ exitCode: 4,
97
+ nextStep: "Nothing was signed. An opener is held by an Ed25519, secp256k1 or secp256r1 wallet.",
98
+ });
99
+ }
@@ -0,0 +1,7 @@
1
+ export type { OpenerHints } from "./openers/hints.ts";
2
+ export { fetchSlot, KIND_PASSKEY, KIND_WALLET, listOpeners, putOpener, removeOpener, } from "./openers/doors.ts";
3
+ export type { OpenerAccess, OpenerInfo, OpenerListing } from "./openers/doors.ts";
4
+ export { openerMessage, withRepeatedSignature, withSignature } from "./openers/sign.ts";
5
+ export type { SignedMessage, SignWallet, WalletOpener, WalletSignature } from "./openers/sign.ts";
6
+ export { addWallet, refuseIfWalletOpensAnAccount, removeWallet, signInWithWallet, walletSlot, } from "./openers/wallet.ts";
7
+ export type { AttachedWallet, WalletSignIn } from "./openers/wallet.ts";
@@ -0,0 +1,21 @@
1
+ // Wallet sign-in without a terminal: the message, the signature's judgement, and the four doors an
2
+ // opener travels through — decided and handed back rather than printed.
3
+ //
4
+ // ⛔ ONE IMPLEMENTATION, FOUR CALLERS, which is the whole reason this entry exists. `nmts login
5
+ // --wallet`, `nmts openers`, the SDK and a page are surfaces over these functions: the prompt,
6
+ // the key file, the button, the exit code belong to them. A second implementation of "which
7
+ // bytes are signed, what is compared, when the key bytes are wiped" would be a second place for
8
+ // rules about the account's root secret to be got right — and the copy nobody re-reads is the
9
+ // one that quietly disagrees.
10
+ //
11
+ // ⛔ WHAT A CALLER IMPORTS IS THIS NAME — `@needmoretruth/nmts-cli/openers` — so the pieces in
12
+ // `openers/` can be split and joined without a single caller changing. Nothing in the folder
13
+ // reaches for `node:`: the SDK's browser entry bundles what this exports, and the one thing
14
+ // that does touch a disk (reading a `suiprivkey1…` file) is the command line's own.
15
+ //
16
+ // ⛔ AND NOTHING IN THE FOLDER KEEPS A SIGNATURE. It is lent to one piece of work and dropped;
17
+ // nothing exported from here answers with it, and `cli/test/openers.test.ts` proves that the
18
+ // objects these functions return cannot reach one.
19
+ export { fetchSlot, KIND_PASSKEY, KIND_WALLET, listOpeners, putOpener, removeOpener, } from "./openers/doors.js";
20
+ export { openerMessage, withRepeatedSignature, withSignature } from "./openers/sign.js";
21
+ export { addWallet, refuseIfWalletOpensAnAccount, removeWallet, signInWithWallet, walletSlot, } from "./openers/wallet.js";
package/dist/product.d.ts CHANGED
@@ -9,7 +9,7 @@ export declare const BINARY_NAME = "nmts";
9
9
  * beside it. Here rather than in `main.ts` because the MCP server has to say it too, and a
10
10
  * command importing the entry point is a cycle waiting to bite.
11
11
  */
12
- export declare const VERSION = "0.40.0";
12
+ export declare const VERSION = "0.41.0";
13
13
  /** Where the product lives, for messages that need to send somebody somewhere real. */
14
14
  export declare const HOME_URL = "https://nmts.me";
15
15
  /** The source, so a person holding only the built program can find what it was built from. */
package/dist/product.js CHANGED
@@ -18,7 +18,7 @@ export const BINARY_NAME = "nmts";
18
18
  * beside it. Here rather than in `main.ts` because the MCP server has to say it too, and a
19
19
  * command importing the entry point is a cycle waiting to bite.
20
20
  */
21
- export const VERSION = "0.40.0";
21
+ export const VERSION = "0.41.0";
22
22
  /** Where the product lives, for messages that need to send somebody somewhere real. */
23
23
  export const HOME_URL = "https://nmts.me";
24
24
  /** The source, so a person holding only the built program can find what it was built from. */
package/dist/risk.d.ts CHANGED
@@ -110,6 +110,9 @@ export declare const ACTS: {
110
110
  readonly key: {
111
111
  readonly tier: "none";
112
112
  };
113
+ readonly openers: {
114
+ readonly tier: "none";
115
+ };
113
116
  readonly env: {
114
117
  readonly tier: "none";
115
118
  };
@@ -233,6 +236,14 @@ export declare const ACTS: {
233
236
  readonly tier: "medium";
234
237
  readonly what: "Make a business key pair and write its private half to a file on this disk.";
235
238
  };
239
+ readonly "openers.add": {
240
+ readonly tier: "medium";
241
+ readonly what: "Let this wallet open this account and every file in it.";
242
+ };
243
+ readonly "openers.remove": {
244
+ readonly tier: "medium";
245
+ readonly what: "Stop this wallet opening this account from now on.";
246
+ };
236
247
  readonly "public-code.publish": {
237
248
  readonly tier: "medium";
238
249
  readonly what: "Publish this account's public code. Publishing cannot be undone.";
package/dist/risk.js CHANGED
@@ -55,6 +55,9 @@ export const ACTS = {
55
55
  unlabel: { tier: "none" },
56
56
  devices: { tier: "none" },
57
57
  key: { tier: "none" },
58
+ // Reading the inventory of roads into the account. It presents the NMTS key's own proof, like
59
+ // the two acts below, and changes nothing.
60
+ openers: { tier: "none" },
58
61
  env: { tier: "none" },
59
62
  mode: { tier: "none" },
60
63
  unlock: { tier: "none" },
@@ -98,6 +101,16 @@ export const ACTS = {
98
101
  // a browser, nothing is spent, and the file is never replaced — so it is not the tier that
99
102
  // waits for an unlock.
100
103
  "platform.keygen": { tier: "medium", what: "Make a business key pair and write its private half to a file on this disk." },
104
+ // ⛔ MEDIUM, BESIDE `key.new` AND `key.revoke`, AND FOR THE SAME REASONS. Adding an opener makes
105
+ // a standing way into the account that outlives the run — wider than a key, because what it
106
+ // opens is the files; removing one stops something that may be in use. Neither spends, and
107
+ // neither reaches a third party, which is where `high` begins.
108
+ // Copy facts — both `what` sentences — the gate asks them in the second person. Facts for the
109
+ // first: this wallet will open every file in the account from any machine until it is removed.
110
+ // For the second: that wallet stops opening the account from now on, and a wallet that opened it
111
+ // once has held the NMTS key — removal cannot unknow that.
112
+ "openers.add": { tier: "medium", what: "Let this wallet open this account and every file in it." },
113
+ "openers.remove": { tier: "medium", what: "Stop this wallet opening this account from now on." },
101
114
  "public-code.publish": { tier: "medium", what: "Publish this account's public code. Publishing cannot be undone." },
102
115
  "losses.dismiss": { tier: "medium", what: "Put this loss notice down. It will not be shown again." },
103
116
  // ⛔ MEDIUM AND NOT HIGH. It moves value, so it is not `low`; but it moves it INSIDE one person's
@@ -177,6 +190,8 @@ export function actOf(args) {
177
190
  return args.pay === "wallet" ? "push.wallet" : "push";
178
191
  case "key":
179
192
  return sub === "new" ? "key.new" : sub === "revoke" ? "key.revoke" : "key";
193
+ case "openers":
194
+ return sub === "add" ? "openers.add" : sub === "remove" ? "openers.remove" : "openers";
180
195
  case "trial":
181
196
  return sub === "apply" ? "trial.apply" : "trial";
182
197
  case "credits":
@@ -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.40.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,10 @@
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
+ },
88
92
  "./storage-control": {
89
93
  "types": "./dist/storage-control.d.ts",
90
94
  "default": "./dist/storage-control.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;