@ghostlytools/cli 1.1.2 → 1.1.4

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 (32) hide show
  1. package/README.md +6 -6
  2. package/SKILL.md +1 -1
  3. package/dist/assets/argon2id-088uQfnH.js.map +1 -1
  4. package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +1 -1
  5. package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js.map +1 -1
  6. package/dist/assets/breez_sdk_spark_wasm_bg.wasm +0 -0
  7. package/dist/assets/fedimint_client_wasm_bg-BtHHlFpp.js.map +1 -1
  8. package/dist/assets/{hyperdhtRelay-CVLCuqVr.js → hyperdhtRelay-BoxPHp7v.js} +3 -3
  9. package/dist/assets/{hyperdhtRelay-CVLCuqVr.js.map → hyperdhtRelay-BoxPHp7v.js.map} +1 -1
  10. package/dist/assets/legacy_ciphers-JJOu0JXL.js.map +1 -1
  11. package/dist/assets/{mainline-CKFpwXcB.js → mainline-dkA94eh2.js} +2 -2
  12. package/dist/assets/{mainline-CKFpwXcB.js.map → mainline-dkA94eh2.js.map} +1 -1
  13. package/dist/assets/nacl-fast-CDhNCYHs.js.map +1 -1
  14. package/dist/assets/noble_curves-DDWn5AH0.js.map +1 -1
  15. package/dist/assets/noble_hashes-B7AZyFyS.js.map +1 -1
  16. package/dist/assets/openpgp-BBFr-zHQ.js.map +1 -1
  17. package/dist/assets/{server-vGoe9MET.js → server-CXFTDnFI.js} +285 -99
  18. package/dist/assets/server-CXFTDnFI.js.map +1 -0
  19. package/dist/assets/sha512-BYId-G-T.js.map +1 -1
  20. package/dist/assets/{src-CJdPTl7Q.js → src-K3NijMq-.js} +455 -87
  21. package/dist/assets/src-K3NijMq-.js.map +1 -0
  22. package/dist/assets/storage-Bya5b2Xt.js.map +1 -1
  23. package/dist/assets/tree-store-N362nuzZ.js.map +1 -1
  24. package/dist/assets/unbzip2-stream-B1C-JX9L.js.map +1 -1
  25. package/dist/assets/{web-OUQl4Q7L.js → web-DwgdhfcY.js} +16 -16
  26. package/dist/assets/{web-OUQl4Q7L.js.map → web-DwgdhfcY.js.map} +1 -1
  27. package/dist/ghostly.mjs +55 -40
  28. package/dist/ghostly.mjs.map +1 -1
  29. package/examples/call-echo.mjs +1 -1
  30. package/package.json +7 -7
  31. package/dist/assets/server-vGoe9MET.js.map +0 -1
  32. package/dist/assets/src-CJdPTl7Q.js.map +0 -1
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  `ghostly` runs **the Ghostly app's own engine** without a screen: the same chats, groups and protocol as the web app,
4
4
  the extension and the Desktop, on Node. A bot keeps a profile online with `ghostly daemon`, reads what happens with
5
5
  `ghostly listen` (JSON lines), and acts with the other commands (JSON answers). The contract behind it, and why it
6
- is built this way, is [WISP 11xx](../../docs/wisps/11xx-headless.md). A guided tour: [docs/CLI.md](../../docs/CLI.md).
6
+ is built this way, is [WISP 1100](../../docs/wisps/1100-headless.md). A guided tour: [docs/CLI.md](../../docs/CLI.md).
7
7
 
8
8
  > Status: phases 1 to 5 (profiles, pictures and backups, invites, one chat, private and community groups with their
9
9
  > admin tools and hubs, the event stream, hooks and agent turns, wallets and payments, files and voice notes, identity
@@ -90,8 +90,8 @@ The rows are in alphabetical order of their first command, and every command of
90
90
 
91
91
  | Command | What it does |
92
92
  |---|---|
93
- | `button press <chat\|group> <message> <button> [--wait none\|sent\|delivered] [--timeout s]` | Press a button of someone else's question, as a tap in the app does (WISP 4xx · Message Buttons): the reply carries the button's label, and the asker hears `button.pressed`. `<message>` is the question's id (its event or `chat history`), `<button>` a button's id from its `card`. Refused (exit 1) like a tap: closed buttons, a second answer past `--once`, a second press within a second. A one-shot in a chat waits until it went out, as `send`. Answers `{chat \| group, messageId, button, label, replyId, delivery \| edges}` |
94
- | `button update <chat\|group> <message> [--chosen <button>] [--close] [--text <text>] [--force] [--wait none\|confirmed\|sent] [--timeout s]` | Answer a question you sent with `send --button` (WISP 4xx · Message Buttons): `--chosen` shows which button won, `--close` takes presses no more, `--text` changes the text (shown as edited; refused if it looks like a secret, unless `--force`); the buttons and, unless given, the text stay. `<message>` is the `messageId` send gave. Answers `{chat \| group, buttons, messageId, card, edits}` |
93
+ | `button press <chat\|group> <message> <button> [--wait none\|sent\|delivered] [--timeout s]` | Press a button of someone else's question, as a tap in the app does (WISP 406 · Message Buttons): the reply carries the button's label, and the asker hears `button.pressed`. `<message>` is the question's id (its event or `chat history`), `<button>` a button's id from its `card`. Refused (exit 1) like a tap: closed buttons, a second answer past `--once`, a second press within a second. A one-shot in a chat waits until it went out, as `send`. Answers `{chat \| group, messageId, button, label, replyId, delivery \| edges}` |
94
+ | `button update <chat\|group> <message> [--chosen <button>] [--close] [--text <text>] [--force] [--wait none\|confirmed\|sent] [--timeout s]` | Answer a question you sent with `send --button` (WISP 406 · Message Buttons): `--chosen` shows which button won, `--close` takes presses no more, `--text` changes the text (shown as edited; refused if it looks like a secret, unless `--force`); the buttons and, unless given, the text stay. `<message>` is the `messageId` send gave. Answers `{chat \| group, buttons, messageId, card, edits}` |
95
95
  | `call auto [on\|off] [--from <chat>]… [--rate n]` | Answer calls by themselves, from anyone or the chats named (kept in the profile) |
96
96
  | `call hangup [<chat\|call>]`, `call list`, `call flush [<chat\|call>]` | Hang up (or decline); calls on now; drop the audio queued and not played yet |
97
97
  | `call pipe [<chat\|call>]` | A call's audio on stdin and stdout, for shell pipelines (sox, ffmpeg) |
@@ -144,13 +144,13 @@ The rows are in alphabetical order of their first command, and every command of
144
144
  | `profile picture <jpeg> \| --clear` | The picture contacts see (a JPEG within 512 px; 128 px is what the app sends) |
145
145
  | `profile show`, `profile set [--name <name>] [--share-profile \| --no-share-profile]` | The name contacts see |
146
146
  | `react <chat> <message> <emoji> [--remove]` | React to a message with one emoji; a new one replaces yours, `--remove` takes it back |
147
- | `routine send <chat\|group> --name <name> --schedule "every day 01:00" [--cron "0 1 * * *"] [--state active\|paused] [--next <time>] [--run ok\|failed\|skipped[:summary]] [--link url]… [--id id] [--json json\|-\|file]`, `routine update <chat\|group> <routine> [fields…]` | A routine card for something a bot runs on a schedule (WISP 4xx · Status Cards): its name, schedule (and cron line, shown only), state, last run and result, next run and up to 10 recent runs. `--run` records a run now as the last one; `--next` takes milliseconds or a date. Updates merge and are paced as `task update`'s. The app shows it, and runs nothing |
147
+ | `routine send <chat\|group> --name <name> --schedule "every day 01:00" [--cron "0 1 * * *"] [--state active\|paused] [--next <time>] [--run ok\|failed\|skipped[:summary]] [--link url]… [--id id] [--json json\|-\|file]`, `routine update <chat\|group> <routine> [fields…]` | A routine card for something a bot runs on a schedule (WISP 405 · Status Cards): its name, schedule (and cron line, shown only), state, last run and result, next run and up to 10 recent runs. `--run` records a run now as the last one; `--next` takes milliseconds or a date. Updates merge and are paced as `task update`'s. The app shows it, and runs nothing |
148
148
  | `send <chat> [text…] [--reply <message>] [--button id:Label]… [--style id=primary\|neutral\|danger]… [--once] [--id id] [--stdin] [--force] [--wait none\|sent\|delivered] [--timeout s]` | Send text (arguments, or stdin); `--reply` quotes a message of the chat. `--button yes:Yes` (1 to 6; the id ends at the first colon; no two labels alike ignoring case and spaces, and no label that is another button's id, else exit 2) puts buttons under the text, which is the question and what older apps show, so say how to answer in words. `--once`: one answer a person. A question that goes on the DHT floor or into a hold (the contact's app closed) reaches them as text alone; the engine sends its buttons again once the chat is live, as an edit of the buttons alone (no `message.edited` for it). The answer adds `buttons` (the question's id, `ask-…` unless `--id`), `card`, and `pressable`: whether the contact's app shows buttons (null until it says). A press comes back as `button.pressed` ([Events](#events)) |
149
149
  | `service add <name> <http://127.0.0.1:port>`, `service share <service> <chat> [--off]`, `service list`, `service remove\|enable` | Share a web app on this machine, per contact |
150
150
  | `service peer <chat>`, `service open <chat> <service> [--port p]`, `service close <chat> <service>` | A contact's app on a loopback port here (daemon). `url` is a link for your browser, `http://<random>.localhost:<port>/.ghostly-open/<token>`: it sets the service's cookie and shows the app on a host name of its own; any other host name, or a request without that cookie, gets 404. Chrome, Edge and curl reach `*.localhost` names by themselves; Safari and Node's `fetch` on macOS may not (add the name to `/etc/hosts` for them) |
151
151
  | `settings get [--show-secret]`, `settings set <key> <json>` | Relays, Iroh relays, the HyperDHT relay, ICE servers, `sendTyping` (false: contacts are never told you type), … |
152
152
  | `status` | The profile, its chats, whether WebRTC and calls run, the last event seq |
153
- | `task send <chat\|group> --title <title> [--status s] [--progress n \| --steps a/b] [--step "…"] [--item state:text]… [--pr-url url --pr-number n --additions n --deletions n --files n --pr-state s --pr-checks c] [--branch b] [--tag label]… [--parent task] [--link url]… [--id id] [--json json\|-\|file]`, `task update <chat\|group> <task> [fields…]` | A task card for a bot's work (WISP 4xx · Status Cards): a title, a status (queued, running, blocked, done, failed, cancelled), progress, the step it is on, up to 20 steps or log lines (`--item done:Codec`; a lowercase word before the colon must be an item state: pending, running, done, failed or skipped) and its pull request, shown as a small card that apps without cards read as text. Optional, and ignored by apps from before them: where the pull request stands (`--pr-state draft`, `open`, `merged` or `closed`; an open one puts the task in the board's Review column) and its checks (`--pr-checks passing`, `failing` or `pending`), up to 3 tags of 24 characters (`--tag core --tag web`; an update's tags replace the card's), and `--parent <task>`, a task of yours in the same chat that this one is a part of (sent first; its parts stack under it on the board). `send` prints the task's id and message; `update` merges the fields given over the card (an update's `--item` list replaces the card's: give all of them) and edits its message, at most once per 2.5 s (sooner updates merge into the next). `--json` takes the whole card; `null` in it removes a field. Only the CLI sends cards: the app shows them |
153
+ | `task send <chat\|group> --title <title> [--status s] [--progress n \| --steps a/b] [--step "…"] [--item state:text]… [--pr-url url --pr-number n --additions n --deletions n --files n --pr-state s --pr-checks c] [--branch b] [--tag label]… [--parent task] [--link url]… [--id id] [--json json\|-\|file]`, `task update <chat\|group> <task> [fields…]` | A task card for a bot's work (WISP 405 · Status Cards): a title, a status (queued, running, blocked, done, failed, cancelled), progress, the step it is on, up to 20 steps or log lines (`--item done:Codec`; a lowercase word before the colon must be an item state: pending, running, done, failed or skipped) and its pull request, shown as a small card that apps without cards read as text. Optional, and ignored by apps from before them: where the pull request stands (`--pr-state draft`, `open`, `merged` or `closed`; an open one puts the task in the board's Review column) and its checks (`--pr-checks passing`, `failing` or `pending`), up to 3 tags of 24 characters (`--tag core --tag web`; an update's tags replace the card's), and `--parent <task>`, a task of yours in the same chat that this one is a part of (sent first; its parts stack under it on the board). `send` prints the task's id and message; `update` merges the fields given over the card (an update's `--item` list replaces the card's: give all of them) and edits its message, at most once per 2.5 s (sooner updates merge into the next). `--json` takes the whole card; `null` in it removes a field. Only the CLI sends cards: the app shows them |
154
154
  | `typing <chat> [--kind typing\|recording\|thinking] [--status "<text>"] [--for s] [--stop]` | Show the contact you are writing, recording or thinking, or a short status line in its place ("Transcribing your audio…", 40 characters, no links): live chats only, it holds 6 s there; `--for s` keeps it on that long (up to 600 s; a one-shot stays that long); a new kind or status shows at once; a message to the chat or `--stop` ends it |
155
155
  | `wallet create <type> [--network testnet] [--provider id] [--value name=value]… [--stdin] [--invite code] [--api-key key]` | A wallet: `cashu`, `lightning` (a card: its source's form in `--value`), `arkade`, `spark` (on Mainnet, `--api-key` is your Breez API key), `bitcoin` (BDK), `fedimint` (`--invite` is the federation's invite code), `usdt`. With `--stdin`, secret fields come as `name=value` lines on stdin (`api-key=…` too), out of `ps` and the shell's history |
156
156
  | `wallet faucet <type>`, `wallet add-mint <url> [--primary]` | Test coins; another Cashu mint |
@@ -290,7 +290,7 @@ commands, `group.created` events and `engine getState` print it as `<hidden>`; `
290
290
  - Reactions (WISP 400 § Reactions): `message.reaction` (a chat) and `group.reaction` (a group) say each change once:
291
291
  `{messageId, by, emoji, removed, mine}`, with `by` `me`, `peer` or a member key, `emoji` "" when taken back, `mine`
292
292
  when the message is this profile's. `chat history` lists each message's `reactions`: `[{by, emoji, at}]`.
293
- - Buttons (WISP 4xx · Message Buttons): a press on a message you sent with `--button` is a reply whose text is the
293
+ - Buttons (WISP 406 · Message Buttons): a press on a message you sent with `--button` is a reply whose text is the
294
294
  button's label (its `message.received` or `group.message`, with `message.press` and `message.replyTo.button`), then
295
295
  `button.pressed`: `{chat | group, messageId, button, label, by, name, replyId, inferred?, untrusted: {name}}`.
296
296
  `messageId` is the question's, `replyId` the press's, `by` the chat (or a group member's key). `name` is the chat's
package/SKILL.md CHANGED
@@ -360,4 +360,4 @@ Every call of the app's engine is reachable: `ghostly engine --list`, then `ghos
360
360
  Not on the CLI yet: Bark wallets, OpenID Connect proofs, and video in calls (voice only). More:
361
361
  [AI agents on Ghostly](https://ghostly.tools/developers/agents), the
362
362
  [CLI guide](https://github.com/MiguelMedeiros/ghostly/blob/main/docs/CLI.md), the
363
- [package README](https://github.com/MiguelMedeiros/ghostly/blob/main/packages/cli/README.md) and WISP 11xx.
363
+ [package README](https://github.com/MiguelMedeiros/ghostly/blob/main/packages/cli/README.md) and WISP 1100.
@@ -1 +1 @@
1
- {"version":3,"file":"argon2id-088uQfnH.js","names":["globalThis"],"sources":["../../../../node_modules/openpgp/dist/lightweight/argon2id.mjs"],"sourcesContent":["/*! OpenPGP.js v6.3.2 - 2026-09-24 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */\nconst globalThis = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};\n\n// Adapted from the reference implementation in RFC7693\n// Initial port to Javascript by https://github.com/dcposch and https://github.com/emilbayes\n\n// Uint64 values are represented using two Uint32s, stored as little endian\n// NB: Uint32Arrays endianness depends on the underlying system, so for interoperability, conversions between Uint8Array and Uint32Arrays\n// need to be manually handled\n\n// 64-bit unsigned addition (little endian, in place)\n// Sets a[i,i+1] += b[j,j+1]\n// `a` and `b` must be Uint32Array(2)\nfunction ADD64 (a, i, b, j) {\n a[i] += b[j];\n a[i+1] += b[j+1] + (a[i] < b[j]); // add carry\n}\n\n// Increment 64-bit little-endian unsigned value by `c` (in place)\n// `a` must be Uint32Array(2)\nfunction INC64 (a, c) {\n a[0] += c;\n a[1] += (a[0] < c);\n}\n\n// G Mixing function\n// The ROTRs are inlined for speed\nfunction G$1 (v, m, a, b, c, d, ix, iy) {\n ADD64(v, a, v, b); // v[a,a+1] += v[b,b+1]\n ADD64(v, a, m, ix); // v[a, a+1] += x ... x0\n\n // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits\n let xor0 = v[d] ^ v[a];\n let xor1 = v[d + 1] ^ v[a + 1];\n v[d] = xor1;\n v[d + 1] = xor0;\n\n ADD64(v, c, v, d);\n\n // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits\n xor0 = v[b] ^ v[c];\n xor1 = v[b + 1] ^ v[c + 1];\n v[b] = (xor0 >>> 24) ^ (xor1 << 8);\n v[b + 1] = (xor1 >>> 24) ^ (xor0 << 8);\n\n ADD64(v, a, v, b);\n ADD64(v, a, m, iy);\n\n // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits\n xor0 = v[d] ^ v[a];\n xor1 = v[d + 1] ^ v[a + 1];\n v[d] = (xor0 >>> 16) ^ (xor1 << 16);\n v[d + 1] = (xor1 >>> 16) ^ (xor0 << 16);\n\n ADD64(v, c, v, d);\n\n // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits\n xor0 = v[b] ^ v[c];\n xor1 = v[b + 1] ^ v[c + 1];\n v[b] = (xor1 >>> 31) ^ (xor0 << 1);\n v[b + 1] = (xor0 >>> 31) ^ (xor1 << 1);\n}\n\n// Initialization Vector\nconst BLAKE2B_IV32 = new Uint32Array([\n 0xF3BCC908, 0x6A09E667, 0x84CAA73B, 0xBB67AE85,\n 0xFE94F82B, 0x3C6EF372, 0x5F1D36F1, 0xA54FF53A,\n 0xADE682D1, 0x510E527F, 0x2B3E6C1F, 0x9B05688C,\n 0xFB41BD6B, 0x1F83D9AB, 0x137E2179, 0x5BE0CD19\n]);\n\n// These are offsets into a Uint64 buffer.\n// Multiply them all by 2 to make them offsets into a Uint32 buffer\nconst SIGMA = new Uint8Array([\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,\n 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3,\n 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4,\n 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8,\n 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13,\n 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9,\n 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11,\n 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10,\n 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5,\n 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0,\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,\n 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3\n].map(x => x * 2));\n\n// Compression function. 'last' flag indicates last block.\n// Note: we're representing 16 uint64s as 32 uint32s\nfunction compress(S, last) {\n const v = new Uint32Array(32);\n const m = new Uint32Array(S.b.buffer, S.b.byteOffset, 32);\n\n // init work variables\n for (let i = 0; i < 16; i++) {\n v[i] = S.h[i];\n v[i + 16] = BLAKE2B_IV32[i];\n }\n\n // low 64 bits of offset\n v[24] ^= S.t0[0];\n v[25] ^= S.t0[1];\n // high 64 bits not supported (`t1`), offset may not be higher than 2**53-1\n\n // if last block\n const f0 = last ? 0xFFFFFFFF : 0;\n v[28] ^= f0;\n v[29] ^= f0;\n\n // twelve rounds of mixing\n for (let i = 0; i < 12; i++) {\n // ROUND(r)\n const i16 = i << 4;\n G$1(v, m, 0, 8, 16, 24, SIGMA[i16 + 0], SIGMA[i16 + 1]);\n G$1(v, m, 2, 10, 18, 26, SIGMA[i16 + 2], SIGMA[i16 + 3]);\n G$1(v, m, 4, 12, 20, 28, SIGMA[i16 + 4], SIGMA[i16 + 5]);\n G$1(v, m, 6, 14, 22, 30, SIGMA[i16 + 6], SIGMA[i16 + 7]);\n G$1(v, m, 0, 10, 20, 30, SIGMA[i16 + 8], SIGMA[i16 + 9]);\n G$1(v, m, 2, 12, 22, 24, SIGMA[i16 + 10], SIGMA[i16 + 11]);\n G$1(v, m, 4, 14, 16, 26, SIGMA[i16 + 12], SIGMA[i16 + 13]);\n G$1(v, m, 6, 8, 18, 28, SIGMA[i16 + 14], SIGMA[i16 + 15]);\n }\n\n for (let i = 0; i < 16; i++) {\n S.h[i] ^= v[i] ^ v[i + 16];\n }\n}\n\n// Creates a BLAKE2b hashing context\n// Requires an output length between 1 and 64 bytes\n// Takes an optional Uint8Array key\nclass Blake2b {\n constructor(outlen, key, salt, personal) {\n const params = new Uint8Array(64);\n // 0: outlen, keylen, fanout, depth\n // 4: leaf length, sequential mode\n // 8: node offset\n // 12: node offset\n // 16: node depth, inner length, rfu\n // 20: rfu\n // 24: rfu\n // 28: rfu\n // 32: salt\n // 36: salt\n // 40: salt\n // 44: salt\n // 48: personal\n // 52: personal\n // 56: personal\n // 60: personal\n\n // init internal state\n this.S = {\n b: new Uint8Array(BLOCKBYTES),\n h: new Uint32Array(OUTBYTES_MAX / 4),\n t0: new Uint32Array(2), // input counter `t`, lower 64-bits only\n c: 0, // `fill`, pointer within buffer, up to `BLOCKBYTES`\n outlen // output length in bytes\n };\n\n // init parameter block\n params[0] = outlen;\n if (key) params[1] = key.length;\n params[2] = 1; // fanout\n params[3] = 1; // depth\n if (salt) params.set(salt, 32);\n if (personal) params.set(personal, 48);\n const params32 = new Uint32Array(params.buffer, params.byteOffset, params.length / Uint32Array.BYTES_PER_ELEMENT);\n\n // initialize hash state\n for (let i = 0; i < 16; i++) {\n this.S.h[i] = BLAKE2B_IV32[i] ^ params32[i];\n }\n\n // key the hash, if applicable\n if (key) {\n const block = new Uint8Array(BLOCKBYTES);\n block.set(key);\n this.update(block);\n }\n }\n\n // Updates a BLAKE2b streaming hash\n // Requires Uint8Array (byte array)\n update(input) {\n if (!(input instanceof Uint8Array)) throw new Error('Input must be Uint8Array or Buffer')\n // for (let i = 0; i < input.length; i++) {\n // if (this.S.c === BLOCKBYTES) { // buffer full\n // INC64(this.S.t0, this.S.c) // add counters\n // compress(this.S, false)\n // this.S.c = 0 // empty buffer\n // }\n // this.S.b[this.S.c++] = input[i]\n // }\n let i = 0;\n while(i < input.length) {\n if (this.S.c === BLOCKBYTES) { // buffer full\n INC64(this.S.t0, this.S.c); // add counters\n compress(this.S, false);\n this.S.c = 0; // empty buffer\n }\n let left = BLOCKBYTES - this.S.c;\n this.S.b.set(input.subarray(i, i + left), this.S.c); // end index can be out of bounds\n const fill = Math.min(left, input.length - i);\n this.S.c += fill;\n i += fill;\n }\n return this\n }\n\n /**\n * Return a BLAKE2b hash, either filling the given Uint8Array or allocating a new one\n * @param {Uint8Array} [prealloc] - optional preallocated buffer\n * @returns {ArrayBuffer} message digest\n */\n digest(prealloc) {\n INC64(this.S.t0, this.S.c); // mark last block offset\n\n // final block, padded\n this.S.b.fill(0, this.S.c);\n this.S.c = BLOCKBYTES;\n compress(this.S, true);\n\n const out = prealloc || new Uint8Array(this.S.outlen);\n for (let i = 0; i < this.S.outlen; i++) {\n // must be loaded individually since default Uint32 endianness is platform dependant\n out[i] = this.S.h[i >> 2] >> (8 * (i & 3));\n }\n this.S.h = null; // prevent calling `update` after `digest`\n return out.buffer;\n }\n}\n\n\nfunction createHash(outlen, key, salt, personal) {\n if (outlen > OUTBYTES_MAX) throw new Error(`outlen must be at most ${OUTBYTES_MAX} (given: ${outlen})`)\n\n return new Blake2b(outlen, key, salt, personal)\n}\n\nconst OUTBYTES_MAX = 64;\nconst BLOCKBYTES = 128;\n\nconst TYPE = 2; // Argon2id\nconst VERSION = 0x13;\nconst TAGBYTES_MAX = 0xFFFFFFFF; // Math.pow(2, 32) - 1;\nconst TAGBYTES_MIN = 4; // Math.pow(2, 32) - 1;\nconst SALTBYTES_MAX = 0xFFFFFFFF; // Math.pow(2, 32) - 1;\nconst SALTBYTES_MIN = 8;\nconst passwordBYTES_MAX = 0xFFFFFFFF;// Math.pow(2, 32) - 1;\nconst passwordBYTES_MIN = 8;\nconst MEMBYTES_MAX = 0xFFFFFFFF;// Math.pow(2, 32) - 1;\nconst ADBYTES_MAX = 0xFFFFFFFF; // Math.pow(2, 32) - 1; // associated data (optional)\nconst SECRETBYTES_MAX = 32; // key (optional)\n\nconst ARGON2_BLOCK_SIZE = 1024;\nconst ARGON2_PREHASH_DIGEST_LENGTH = 64;\n\nconst isLittleEndian = new Uint8Array(new Uint16Array([0xabcd]).buffer)[0] === 0xcd;\n\n// store n as a little-endian 32-bit Uint8Array inside buf (at buf[i:i+3])\nfunction LE32(buf, n, i) {\n buf[i+0] = n;\n buf[i+1] = n >> 8;\n buf[i+2] = n >> 16;\n buf[i+3] = n >> 24;\n return buf;\n}\n\n/**\n * Store n as a 64-bit LE number in the given buffer (from buf[i] to buf[i+7])\n * @param {Uint8Array} buf\n * @param {Number} n\n * @param {Number} i\n */\nfunction LE64(buf, n, i) {\n if (n > Number.MAX_SAFE_INTEGER) throw new Error(\"LE64: large numbers unsupported\");\n // ECMAScript standard has engines convert numbers to 32-bit integers for bitwise operations\n // shifting by 32 or more bits is not supported (https://stackoverflow.com/questions/6729122/javascript-bit-shift-number-wraps)\n // so we manually extract each byte\n let remainder = n;\n for (let offset = i; offset < i+7; offset++) { // last byte can be ignored as it would overflow MAX_SAFE_INTEGER\n buf[offset] = remainder; // implicit & 0xff\n remainder = (remainder - buf[offset]) / 256;\n }\n return buf;\n}\n\n/**\n * Variable-Length Hash Function H'\n * @param {Number} outlen - T\n * @param {Uint8Array} X - value to hash\n * @param {Uint8Array} res - output buffer, of length `outlength` or larger\n */\nfunction H_(outlen, X, res) {\n const V = new Uint8Array(64); // no need to keep around all V_i\n\n const V1_in = new Uint8Array(4 + X.length);\n LE32(V1_in, outlen, 0);\n V1_in.set(X, 4);\n if (outlen <= 64) {\n // H'^T(A) = H^T(LE32(T)||A)\n createHash(outlen).update(V1_in).digest(res);\n return res\n }\n\n const r = Math.ceil(outlen / 32) - 2;\n\n // Let V_i be a 64-byte block and W_i be its first 32 bytes.\n // V_1 = H^(64)(LE32(T)||A)\n // V_2 = H^(64)(V_1)\n // ...\n // V_r = H^(64)(V_{r-1})\n // V_{r+1} = H^(T-32*r)(V_{r})\n // H'^T(X) = W_1 || W_2 || ... || W_r || V_{r+1}\n for (let i = 0; i < r; i++) {\n createHash(64).update(i === 0 ? V1_in : V).digest(V);\n // store W_i in result buffer already\n res.set(V.subarray(0, 32), i*32);\n }\n // V_{r+1}\n const V_r1 = new Uint8Array(createHash(outlen - 32*r).update(V).digest());\n res.set(V_r1, r*32);\n\n return res;\n}\n\n// compute buf = xs ^ ys\nfunction XOR(wasmContext, buf, xs, ys) {\n wasmContext.fn.XOR(\n buf.byteOffset,\n xs.byteOffset,\n ys.byteOffset,\n );\n return buf\n}\n\n/**\n * @param {Uint8Array} X (read-only)\n * @param {Uint8Array} Y (read-only)\n * @param {Uint8Array} R - output buffer\n * @returns\n */\nfunction G(wasmContext, X, Y, R) {\n wasmContext.fn.G(\n X.byteOffset,\n Y.byteOffset,\n R.byteOffset,\n wasmContext.refs.gZ.byteOffset\n );\n return R;\n}\n\nfunction G2(wasmContext, X, Y, R) {\n wasmContext.fn.G2(\n X.byteOffset,\n Y.byteOffset,\n R.byteOffset,\n wasmContext.refs.gZ.byteOffset\n );\n return R;\n}\n\n// Generator for data-independent J1, J2. Each `next()` invocation returns a new pair of values.\nfunction* makePRNG(wasmContext, pass, lane, slice, m_, totalPasses, segmentLength, segmentOffset) {\n // For each segment, we do the following. First, we compute the value Z as:\n // Z= ( LE64(r) || LE64(l) || LE64(sl) || LE64(m') || LE64(t) || LE64(y) )\n wasmContext.refs.prngTmp.fill(0);\n const Z = wasmContext.refs.prngTmp.subarray(0, 6 * 8);\n LE64(Z, pass, 0);\n LE64(Z, lane, 8);\n LE64(Z, slice, 16);\n LE64(Z, m_, 24);\n LE64(Z, totalPasses, 32);\n LE64(Z, TYPE, 40);\n\n // Then we compute q/(128*SL) 1024-byte values\n // G( ZERO(1024),\n // G( ZERO(1024), Z || LE64(1) || ZERO(968) ) ),\n // ...,\n // G( ZERO(1024),\n // G( ZERO(1024), Z || LE64(q/(128*SL)) || ZERO(968) )),\n for(let i = 1; i <= segmentLength; i++) {\n // tmp.set(Z); // no need to re-copy\n LE64(wasmContext.refs.prngTmp, i, Z.length); // tmp.set(ZER0968) not necessary, memory already zeroed\n const g2 = G2(wasmContext, wasmContext.refs.ZERO1024, wasmContext.refs.prngTmp, wasmContext.refs.prngR );\n\n // each invocation of G^2 outputs 1024 bytes that are to be partitioned into 8-bytes values, take as X1 || X2\n // NB: the first generated pair must be used for the first block of the segment, and so on.\n // Hence, if some blocks are skipped (e.g. during the first pass), the corresponding J1J2 are discarded based on the given segmentOffset.\n for(let k = i === 1 ? segmentOffset*8 : 0; k < g2.length; k += 8) {\n yield g2.subarray(k, k+8);\n }\n }\n return [];\n}\n\nfunction validateParams({ type, version, tagLength, password, salt, ad, secret, parallelism, memorySize, passes }) {\n const assertLength = (name, value, min, max) => {\n if (value < min || value > max) { throw new Error(`${name} size should be between ${min} and ${max} bytes`); }\n };\n\n if (type !== TYPE || version !== VERSION) throw new Error('Unsupported type or version');\n assertLength('password', password, passwordBYTES_MIN, passwordBYTES_MAX);\n assertLength('salt', salt, SALTBYTES_MIN, SALTBYTES_MAX);\n assertLength('tag', tagLength, TAGBYTES_MIN, TAGBYTES_MAX);\n assertLength('memory', memorySize, 8*parallelism, MEMBYTES_MAX);\n // optional fields\n ad && assertLength('associated data', ad, 0, ADBYTES_MAX);\n secret && assertLength('secret', secret, 0, SECRETBYTES_MAX);\n\n return { type, version, tagLength, password, salt, ad, secret, lanes: parallelism, memorySize, passes };\n}\n\nconst KB = 1024;\nconst WASM_PAGE_SIZE = 64 * KB;\n\nfunction argon2id(params, { memory, instance: wasmInstance }) {\n if (!isLittleEndian) throw new Error('BigEndian system not supported'); // optmisations assume LE system\n\n const ctx = validateParams({ type: TYPE, version: VERSION, ...params });\n\n const { G:wasmG, G2:wasmG2, xor:wasmXOR, getLZ:wasmLZ } = wasmInstance.exports;\n const wasmRefs = {};\n const wasmFn = {};\n wasmFn.G = wasmG;\n wasmFn.G2 = wasmG2;\n wasmFn.XOR = wasmXOR;\n\n // The actual number of blocks is m', which is m rounded down to the nearest multiple of 4*p.\n const m_ = 4 * ctx.lanes * Math.floor(ctx.memorySize / (4 * ctx.lanes));\n const requiredMemory = m_ * ARGON2_BLOCK_SIZE + 10 * KB; // Additional KBs for utility references\n if (memory.buffer.byteLength < requiredMemory) {\n const missing = Math.ceil((requiredMemory - memory.buffer.byteLength) / WASM_PAGE_SIZE);\n // If enough memory is available, the `memory.buffer` is internally detached and the reference updated.\n // Otherwise, the operation fails, and the original memory can still be used.\n memory.grow(missing);\n }\n\n let offset = 0;\n // Init wasm memory needed in other functions\n wasmRefs.gZ = new Uint8Array(memory.buffer, offset, ARGON2_BLOCK_SIZE); offset+= wasmRefs.gZ.length;\n wasmRefs.prngR = new Uint8Array(memory.buffer, offset, ARGON2_BLOCK_SIZE); offset+=wasmRefs.prngR.length;\n wasmRefs.prngTmp = new Uint8Array(memory.buffer, offset, ARGON2_BLOCK_SIZE); offset+=wasmRefs.prngTmp.length;\n wasmRefs.ZERO1024 = new Uint8Array(memory.buffer, offset, 1024); offset+=wasmRefs.ZERO1024.length;\n // Init wasm memory needed locally\n const lz = new Uint32Array(memory.buffer, offset, 2); offset+=lz.length * Uint32Array.BYTES_PER_ELEMENT;\n const wasmContext = { fn: wasmFn, refs: wasmRefs };\n const newBlock = new Uint8Array(memory.buffer, offset, ARGON2_BLOCK_SIZE); offset+=newBlock.length;\n const blockMemory = new Uint8Array(memory.buffer, offset, ctx.memorySize * ARGON2_BLOCK_SIZE);\n const allocatedMemory = new Uint8Array(memory.buffer, 0, offset);\n\n // 1. Establish H_0\n const H0 = getH0(ctx);\n\n // 2. Allocate the memory as m' 1024-byte blocks\n // For p lanes, the memory is organized in a matrix B[i][j] of blocks with p rows (lanes) and q = m' / p columns.\n const q = m_ / ctx.lanes;\n const B = new Array(ctx.lanes).fill(null).map(() => new Array(q));\n const initBlock = (i, j) => {\n B[i][j] = blockMemory.subarray(i*q*1024 + j*1024, (i*q*1024 + j*1024) + ARGON2_BLOCK_SIZE);\n return B[i][j];\n };\n\n for (let i = 0; i < ctx.lanes; i++) {\n // const LEi = LE0; // since p = 1 for us\n const tmp = new Uint8Array(H0.length + 8);\n // 3. Compute B[i][0] for all i ranging from (and including) 0 to (not including) p\n // B[i][0] = H'^(1024)(H_0 || LE32(0) || LE32(i))\n tmp.set(H0); LE32(tmp, 0, H0.length); LE32(tmp, i, H0.length + 4);\n H_(ARGON2_BLOCK_SIZE, tmp, initBlock(i, 0));\n // 4. Compute B[i][1] for all i ranging from (and including) 0 to (not including) p\n // B[i][1] = H'^(1024)(H_0 || LE32(1) || LE32(i))\n LE32(tmp, 1, H0.length);\n H_(ARGON2_BLOCK_SIZE, tmp, initBlock(i, 1));\n }\n\n // 5. Compute B[i][j] for all i ranging from (and including) 0 to (not including) p and for all j ranging from (and including) 2\n // to (not including) q. The computation MUST proceed slicewise (Section 3.4) : first, blocks from slice 0 are computed for all lanes\n // (in an arbitrary order of lanes), then blocks from slice 1 are computed, etc.\n const SL = 4; // vertical slices\n const segmentLength = q / SL;\n for (let pass = 0; pass < ctx.passes; pass++) {\n // The intersection of a slice and a lane is called a segment, which has a length of q/SL. Segments of the same slice can be computed in parallel\n for (let sl = 0; sl < SL; sl++) {\n const isDataIndependent = pass === 0 && sl <= 1;\n for (let i = 0; i < ctx.lanes; i++) { // lane\n // On the first slice of the first pass, blocks 0 and 1 are already filled\n let segmentOffset = sl === 0 && pass === 0 ? 2 : 0;\n // no need to generate all J1J2s, use iterator/generator that creates the value on the fly (to save memory)\n const PRNG = isDataIndependent ? makePRNG(wasmContext, pass, i, sl, m_, ctx.passes, segmentLength, segmentOffset) : null;\n for (segmentOffset; segmentOffset < segmentLength; segmentOffset++) {\n const j = sl * segmentLength + segmentOffset;\n const prevBlock = j > 0 ? B[i][j-1] : B[i][q-1]; // B[i][(j-1) mod q]\n\n // we can assume the PRNG is never done\n const J1J2 = isDataIndependent ? PRNG.next().value : prevBlock; // .subarray(0, 8) not required since we only pass the byteOffset to wasm\n // The block indices l and z are determined for each i, j differently for Argon2d, Argon2i, and Argon2id.\n wasmLZ(lz.byteOffset, J1J2.byteOffset, i, ctx.lanes, pass, sl, segmentOffset, SL, segmentLength);\n const l = lz[0]; const z = lz[1];\n // for (let i = 0; i < p; i++ )\n // B[i][j] = G(B[i][j-1], B[l][z])\n // The block indices l and z are determined for each i, j differently for Argon2d, Argon2i, and Argon2id.\n if (pass === 0) initBlock(i, j);\n G(wasmContext, prevBlock, B[l][z], pass > 0 ? newBlock : B[i][j]);\n\n // 6. If the number of passes t is larger than 1, we repeat step 5. However, blocks are computed differently as the old value is XORed with the new one\n if (pass > 0) XOR(wasmContext, B[i][j], newBlock, B[i][j]);\n }\n }\n }\n }\n\n // 7. After t steps have been iterated, the final block C is computed as the XOR of the last column:\n // C = B[0][q-1] XOR B[1][q-1] XOR ... XOR B[p-1][q-1]\n const C = B[0][q-1];\n for(let i = 1; i < ctx.lanes; i++) {\n XOR(wasmContext, C, C, B[i][q-1]);\n }\n\n const tag = H_(ctx.tagLength, C, new Uint8Array(ctx.tagLength));\n // clear memory since the module might be cached\n allocatedMemory.fill(0); // clear sensitive contents\n memory.grow(0); // allow deallocation\n // 8. The output tag is computed as H'^T(C).\n return tag;\n\n}\n\nfunction getH0(ctx) {\n const H = createHash(ARGON2_PREHASH_DIGEST_LENGTH);\n const ZERO32 = new Uint8Array(4);\n const params = new Uint8Array(24);\n LE32(params, ctx.lanes, 0);\n LE32(params, ctx.tagLength, 4);\n LE32(params, ctx.memorySize, 8);\n LE32(params, ctx.passes, 12);\n LE32(params, ctx.version, 16);\n LE32(params, ctx.type, 20);\n\n const toHash = [params];\n if (ctx.password) {\n toHash.push(LE32(new Uint8Array(4), ctx.password.length, 0));\n toHash.push(ctx.password);\n } else {\n toHash.push(ZERO32); // context.password.length\n }\n\n if (ctx.salt) {\n toHash.push(LE32(new Uint8Array(4), ctx.salt.length, 0));\n toHash.push(ctx.salt);\n } else {\n toHash.push(ZERO32); // context.salt.length\n }\n\n if (ctx.secret) {\n toHash.push(LE32(new Uint8Array(4), ctx.secret.length, 0));\n toHash.push(ctx.secret);\n // todo clear secret?\n } else {\n toHash.push(ZERO32); // context.secret.length\n }\n\n if (ctx.ad) {\n toHash.push(LE32(new Uint8Array(4), ctx.ad.length, 0));\n toHash.push(ctx.ad);\n } else {\n toHash.push(ZERO32); // context.ad.length\n }\n H.update(concatArrays(toHash));\n\n const outputBuffer = H.digest();\n return new Uint8Array(outputBuffer);\n}\n\nfunction concatArrays(arrays) {\n if (arrays.length === 1) return arrays[0];\n\n let totalLength = 0;\n for (let i = 0; i < arrays.length; i++) {\n if (!(arrays[i] instanceof Uint8Array)) {\n throw new Error('concatArrays: Data must be in the form of a Uint8Array');\n }\n\n totalLength += arrays[i].length;\n }\n\n const result = new Uint8Array(totalLength);\n let pos = 0;\n arrays.forEach((element) => {\n result.set(element, pos);\n pos += element.length;\n });\n\n return result;\n}\n\nlet isSIMDSupported;\nasync function wasmLoader(memory, getSIMD, getNonSIMD) {\n const importObject = { env: { memory } };\n if (isSIMDSupported === undefined) {\n try {\n const loaded = await getSIMD(importObject);\n isSIMDSupported = true;\n return loaded;\n } catch(e) {\n isSIMDSupported = false;\n }\n }\n\n const loader = isSIMDSupported ? getSIMD : getNonSIMD;\n return loader(importObject);\n}\n\nasync function setupWasm(getSIMD, getNonSIMD) {\n const memory = new WebAssembly.Memory({\n // in pages of 64KiB each\n // these values need to be compatible with those declared when building in `build-wasm`\n initial: 1040, // 65MB\n maximum: 65536, // 4GB\n });\n const wasmModule = await wasmLoader(memory, getSIMD, getNonSIMD);\n\n /**\n * Argon2id hash function\n * @callback computeHash\n * @param {Object} params\n * @param {Uint8Array} params.password - password\n * @param {Uint8Array} params.salt - salt\n * @param {Integer} params.parallelism\n * @param {Integer} params.passes\n * @param {Integer} params.memorySize - in kibibytes\n * @param {Integer} params.tagLength - output tag length\n * @param {Uint8Array} [params.ad] - associated data (optional)\n * @param {Uint8Array} [params.secret] - secret data (optional)\n * @return {Uint8Array} argon2id hash\n */\n const computeHash = (params) => argon2id(params, { instance: wasmModule.instance, memory });\n\n return computeHash;\n}\n\nfunction _loadWasmModule (sync, filepath, src, imports) {\n function _instantiateOrCompile(source, imports, stream) {\n var instantiateFunc = stream ? WebAssembly.instantiateStreaming : WebAssembly.instantiate;\n var compileFunc = stream ? WebAssembly.compileStreaming : WebAssembly.compile;\n\n if (imports) {\n return instantiateFunc(source, imports)\n } else {\n return compileFunc(source)\n }\n }\n\n \nvar buf = null;\n\n\nvar raw = globalThis.atob(src);\nvar rawLength = raw.length;\nbuf = new Uint8Array(new ArrayBuffer(rawLength));\nfor(var i = 0; i < rawLength; i++) {\n buf[i] = raw.charCodeAt(i);\n}\n\n\n\n {\n return _instantiateOrCompile(buf, imports, false)\n }\n}\n\nfunction wasmSIMD(imports){return _loadWasmModule(0, null, 'AGFzbQEAAAABKwdgBH9/f38AYAABf2AAAGADf39/AGAJf39/f39/f39/AX9gAX8AYAF/AX8CEwEDZW52Bm1lbW9yeQIBkAiAgAQDCgkCAwAABAEFBgEEBQFwAQICBgkBfwFBkIjAAgsHfQoDeG9yAAEBRwACAkcyAAMFZ2V0TFoABBlfX2luZGlyZWN0X2Z1bmN0aW9uX3RhYmxlAQALX2luaXRpYWxpemUAABBfX2Vycm5vX2xvY2F0aW9uAAgJc3RhY2tTYXZlAAUMc3RhY2tSZXN0b3JlAAYKc3RhY2tBbGxvYwAHCQcBAEEBCwEACs0gCQMAAQtYAQJ/A0AgACAEQQR0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AVBAWogCGxBACAEG2ogAa0gCiAKfkIgiH5CIIinQX9zaiAHIAhscDYCBCAACwQAIwALBgAgACQACxAAIwAgAGtBcHEiACQAIAALBQBBgAgL', imports)}\n\nfunction wasmNonSIMD(imports){return _loadWasmModule(0, null, 'AGFzbQEAAAABPwhgBH9/f38AYAABf2AAAGADf39/AGARf39/f39/f39/f39/f39/f38AYAl/f39/f39/f38Bf2ABfwBgAX8BfwITAQNlbnYGbWVtb3J5AgGQCICABAMLCgIDBAAABQEGBwEEBQFwAQICBgkBfwFBkIjAAgsHfQoDeG9yAAEBRwADAkcyAAQFZ2V0TFoABRlfX2luZGlyZWN0X2Z1bmN0aW9uX3RhYmxlAQALX2luaXRpYWxpemUAABBfX2Vycm5vX2xvY2F0aW9uAAkJc3RhY2tTYXZlAAYMc3RhY2tSZXN0b3JlAAcKc3RhY2tBbGxvYwAICQcBAEEBCwEACssaCgMAAQtQAQJ/A0AgACAEQQN0IgNqIAIgA2opAwAgASADaikDAIU3AwAgACADQQhyIgNqIAIgA2opAwAgASADaikDAIU3AwAgBEECaiIEQYABRw0ACwveDwICfgF/IAAgAUEDdGoiEyATKQMAIhEgACAFQQN0aiIBKQMAIhJ8IBFCAYZC/v///x+DIBJC/////w+DfnwiETcDACAAIA1BA3RqIgUgESAFKQMAhUIgiSIRNwMAIAAgCUEDdGoiCSARIAkpAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAEgESABKQMAhUIoiSIRNwMAIBMgESATKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACAFIBEgBSkDAIVCMIkiETcDACAJIBEgCSkDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgASARIAEpAwCFQgGJNwMAIAAgAkEDdGoiDSANKQMAIhEgACAGQQN0aiICKQMAIhJ8IBFCAYZC/v///x+DIBJC/////w+DfnwiETcDACAAIA5BA3RqIgYgESAGKQMAhUIgiSIRNwMAIAAgCkEDdGoiCiARIAopAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAIgESACKQMAhUIoiSIRNwMAIA0gESANKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACAGIBEgBikDAIVCMIkiETcDACAKIBEgCikDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgAiARIAIpAwCFQgGJNwMAIAAgA0EDdGoiDiAOKQMAIhEgACAHQQN0aiIDKQMAIhJ8IBFCAYZC/v///x+DIBJC/////w+DfnwiETcDACAAIA9BA3RqIgcgESAHKQMAhUIgiSIRNwMAIAAgC0EDdGoiCyARIAspAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAMgESADKQMAhUIoiSIRNwMAIA4gESAOKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACAHIBEgBykDAIVCMIkiETcDACALIBEgCykDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgAyARIAMpAwCFQgGJNwMAIAAgBEEDdGoiDyAPKQMAIhEgACAIQQN0aiIEKQMAIhJ8IBFCAYZC/v///x+DIBJC/////w+DfnwiETcDACAAIBBBA3RqIgggESAIKQMAhUIgiSIRNwMAIAAgDEEDdGoiACARIAApAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAQgESAEKQMAhUIoiSIRNwMAIA8gESAPKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACAIIBEgCCkDAIVCMIkiETcDACAAIBEgACkDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgBCARIAQpAwCFQgGJNwMAIBMgEykDACIRIAIpAwAiEnwgEUIBhkL+////H4MgEkL/////D4N+fCIRNwMAIAggESAIKQMAhUIgiSIRNwMAIAsgESALKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACACIBEgAikDAIVCKIkiETcDACATIBEgEykDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgCCARIAgpAwCFQjCJIhE3AwAgCyARIAspAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAIgESACKQMAhUIBiTcDACANIA0pAwAiESADKQMAIhJ8IBFCAYZC/v///x+DIBJC/////w+DfnwiETcDACAFIBEgBSkDAIVCIIkiETcDACAAIBEgACkDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgAyARIAMpAwCFQiiJIhE3AwAgDSARIA0pAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAUgESAFKQMAhUIwiSIRNwMAIAAgESAAKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACADIBEgAykDAIVCAYk3AwAgDiAOKQMAIhEgBCkDACISfCARQgGGQv7///8fgyASQv////8Pg358IhE3AwAgBiARIAYpAwCFQiCJIhE3AwAgCSARIAkpAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAQgESAEKQMAhUIoiSIRNwMAIA4gESAOKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACAGIBEgBikDAIVCMIkiETcDACAJIBEgCSkDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgBCARIAQpAwCFQgGJNwMAIA8gDykDACIRIAEpAwAiEnwgEUIBhkL+////H4MgEkL/////D4N+fCIRNwMAIAcgESAHKQMAhUIgiSIRNwMAIAogESAKKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACABIBEgASkDAIVCKIkiETcDACAPIBEgDykDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgByARIAcpAwCFQjCJIhE3AwAgCiARIAopAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAEgESABKQMAhUIBiTcDAAvdCAEPfwNAIAIgBUEDdCIGaiABIAZqKQMAIAAgBmopAwCFNwMAIAIgBkEIciIGaiABIAZqKQMAIAAgBmopAwCFNwMAIAVBAmoiBUGAAUcNAAsDQCADIARBA3QiAGogACACaikDADcDACADIARBAXIiAEEDdCIBaiABIAJqKQMANwMAIAMgBE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wBB7gBB7wBB/gBB/wAQAgNAIAIgAUEDdCIAaiIEIAAgA2opAwAgBCkDAIU3AwAgAiAAQQhyIgRqIgUgAyAEaikDACAFKQMAhTcDACACIABBEHIiBGoiBSADIARqKQMAIAUpAwCFNwMAIAIgAEEYciIAaiIEIAAgA2opAwAgBCkDAIU3AwAgAUEEaiIBQYABRw0ACwsWACAAIAEgAiADEAMgACACIAIgAxADC3sCAX8BfiACIQkgATUCACEKIAQgBXIEQCABKAIEIANwIQkLIAAgCTYCACAAIAdBAWsgBSAEGyAIbCAGQQFrQQBBfyAGGyACIAlGG2oiASAFQQFqIAhsQQAgBBtqIAGtIAogCn5CIIh+QiCIp0F/c2ogByAIbHA2AgQgAAsEACMACwYAIAAkAAsQACMAIABrQXBxIgAkACAACwUAQYAICw==', imports)}\n\nconst loadWasm = async () => setupWasm(\n (instanceObject) => wasmSIMD(instanceObject),\n (instanceObject) => wasmNonSIMD(instanceObject),\n);\n\nexport { loadWasm as default };\n"],"x_google_ignoreList":[0],"mappings":";;AACA,IAAMA,eAAa,OAAO,WAAW,cAAc,SAAS,OAAO,WAAW,cAAc,SAAS,OAAO,SAAS,cAAc,OAAO,CAAC;AAY3I,SAAS,MAAO,GAAG,GAAG,GAAG,GAAG;CAC1B,EAAE,MAAM,EAAE;CACV,EAAE,IAAE,MAAM,EAAE,IAAE,MAAM,EAAE,KAAK,EAAE;AAC/B;AAIA,SAAS,MAAO,GAAG,GAAG;CACpB,EAAE,MAAM;CACR,EAAE,MAAO,EAAE,KAAK;AAClB;AAIA,SAAS,IAAK,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,IAAI;CACtC,MAAM,GAAG,GAAG,GAAG,CAAC;CAChB,MAAM,GAAG,GAAG,GAAG,EAAE;CAGjB,IAAI,OAAO,EAAE,KAAK,EAAE;CACpB,IAAI,OAAO,EAAE,IAAI,KAAK,EAAE,IAAI;CAC5B,EAAE,KAAK;CACP,EAAE,IAAI,KAAK;CAEX,MAAM,GAAG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CAgB/D,MAAM,eAAe,WAAW,SAAS,QAAQ;EAAE,UAAU,WAAW;EAAU;CAAO,CAAC;CAE1F,OAAO;AACT;AAEA,SAAS,gBAAiB,MAAM,UAAU,KAAK,SAAS;CACtD,SAAS,sBAAsB,QAAQ,SAAS,QAAQ;EACtD,IAAI,kBAAkB,SAAS,YAAY,uBAAuB,YAAY;EAC9E,IAAI,cAAc,SAAS,YAAY,mBAAmB,YAAY;EAEtE,IAAI,SACF,OAAO,gBAAgB,QAAQ,OAAO;OAEtC,OAAO,YAAY,MAAM;CAE7B;CAGF,IAAI,MAAM;CAGV,IAAI,MAAMA,aAAW,KAAK,GAAG;CAC7B,IAAI,YAAY,IAAI;CACpB,MAAM,IAAI,WAAW,IAAI,YAAY,SAAS,CAAC;CAC/C,KAAI,IAAI,IAAI,GAAG,IAAI,WAAW,KAC3B,IAAI,KAAK,IAAI,WAAW,CAAC;CAMxB,OAAO,sBAAsB,KAAK,SAAS,KAAK;AAEpD;AAEA,SAAS,SAAS,SAAQ;CAAC,OAAO,gBAAgB,GAAG,MAAM,owLAAowL,OAAO;AAAC;AAEv0L,SAAS,YAAY,SAAQ;CAAC,OAAO,gBAAgB,GAAG,MAAM,gyJAAgyJ,OAAO;AAAC;AAEt2J,IAAM,WAAW,YAAY,WAC1B,mBAAmB,SAAS,cAAc,IAC1C,mBAAmB,YAAY,cAAc,CAChD"}
1
+ {"version":3,"file":"argon2id-088uQfnH.js","names":["globalThis"],"sources":["../../../../node_modules/openpgp/dist/lightweight/argon2id.mjs"],"sourcesContent":["/*! OpenPGP.js v6.3.2 - 2026-09-24 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */\nconst globalThis = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};\n\n// Adapted from the reference implementation in RFC7693\n// Initial port to Javascript by https://github.com/dcposch and https://github.com/emilbayes\n\n// Uint64 values are represented using two Uint32s, stored as little endian\n// NB: Uint32Arrays endianness depends on the underlying system, so for interoperability, conversions between Uint8Array and Uint32Arrays\n// need to be manually handled\n\n// 64-bit unsigned addition (little endian, in place)\n// Sets a[i,i+1] += b[j,j+1]\n// `a` and `b` must be Uint32Array(2)\nfunction ADD64 (a, i, b, j) {\n a[i] += b[j];\n a[i+1] += b[j+1] + (a[i] < b[j]); // add carry\n}\n\n// Increment 64-bit little-endian unsigned value by `c` (in place)\n// `a` must be Uint32Array(2)\nfunction INC64 (a, c) {\n a[0] += c;\n a[1] += (a[0] < c);\n}\n\n// G Mixing function\n// The ROTRs are inlined for speed\nfunction G$1 (v, m, a, b, c, d, ix, iy) {\n ADD64(v, a, v, b); // v[a,a+1] += v[b,b+1]\n ADD64(v, a, m, ix); // v[a, a+1] += x ... x0\n\n // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated to the right by 32 bits\n let xor0 = v[d] ^ v[a];\n let xor1 = v[d + 1] ^ v[a + 1];\n v[d] = xor1;\n v[d + 1] = xor0;\n\n ADD64(v, c, v, d);\n\n // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 24 bits\n xor0 = v[b] ^ v[c];\n xor1 = v[b + 1] ^ v[c + 1];\n v[b] = (xor0 >>> 24) ^ (xor1 << 8);\n v[b + 1] = (xor1 >>> 24) ^ (xor0 << 8);\n\n ADD64(v, a, v, b);\n ADD64(v, a, m, iy);\n\n // v[d,d+1] = (v[d,d+1] xor v[a,a+1]) rotated right by 16 bits\n xor0 = v[d] ^ v[a];\n xor1 = v[d + 1] ^ v[a + 1];\n v[d] = (xor0 >>> 16) ^ (xor1 << 16);\n v[d + 1] = (xor1 >>> 16) ^ (xor0 << 16);\n\n ADD64(v, c, v, d);\n\n // v[b,b+1] = (v[b,b+1] xor v[c,c+1]) rotated right by 63 bits\n xor0 = v[b] ^ v[c];\n xor1 = v[b + 1] ^ v[c + 1];\n v[b] = (xor1 >>> 31) ^ (xor0 << 1);\n v[b + 1] = (xor0 >>> 31) ^ (xor1 << 1);\n}\n\n// Initialization Vector\nconst BLAKE2B_IV32 = new Uint32Array([\n 0xF3BCC908, 0x6A09E667, 0x84CAA73B, 0xBB67AE85,\n 0xFE94F82B, 0x3C6EF372, 0x5F1D36F1, 0xA54FF53A,\n 0xADE682D1, 0x510E527F, 0x2B3E6C1F, 0x9B05688C,\n 0xFB41BD6B, 0x1F83D9AB, 0x137E2179, 0x5BE0CD19\n]);\n\n// These are offsets into a Uint64 buffer.\n// Multiply them all by 2 to make them offsets into a Uint32 buffer\nconst SIGMA = new Uint8Array([\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,\n 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3,\n 11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4,\n 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8,\n 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13,\n 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9,\n 12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11,\n 13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10,\n 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5,\n 10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0,\n 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,\n 14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3\n].map(x => x * 2));\n\n// Compression function. 'last' flag indicates last block.\n// Note: we're representing 16 uint64s as 32 uint32s\nfunction compress(S, last) {\n const v = new Uint32Array(32);\n const m = new Uint32Array(S.b.buffer, S.b.byteOffset, 32);\n\n // init work variables\n for (let i = 0; i < 16; i++) {\n v[i] = S.h[i];\n v[i + 16] = BLAKE2B_IV32[i];\n }\n\n // low 64 bits of offset\n v[24] ^= S.t0[0];\n v[25] ^= S.t0[1];\n // high 64 bits not supported (`t1`), offset may not be higher than 2**53-1\n\n // if last block\n const f0 = last ? 0xFFFFFFFF : 0;\n v[28] ^= f0;\n v[29] ^= f0;\n\n // twelve rounds of mixing\n for (let i = 0; i < 12; i++) {\n // ROUND(r)\n const i16 = i << 4;\n G$1(v, m, 0, 8, 16, 24, SIGMA[i16 + 0], SIGMA[i16 + 1]);\n G$1(v, m, 2, 10, 18, 26, SIGMA[i16 + 2], SIGMA[i16 + 3]);\n G$1(v, m, 4, 12, 20, 28, SIGMA[i16 + 4], SIGMA[i16 + 5]);\n G$1(v, m, 6, 14, 22, 30, SIGMA[i16 + 6], SIGMA[i16 + 7]);\n G$1(v, m, 0, 10, 20, 30, SIGMA[i16 + 8], SIGMA[i16 + 9]);\n G$1(v, m, 2, 12, 22, 24, SIGMA[i16 + 10], SIGMA[i16 + 11]);\n G$1(v, m, 4, 14, 16, 26, SIGMA[i16 + 12], SIGMA[i16 + 13]);\n G$1(v, m, 6, 8, 18, 28, SIGMA[i16 + 14], SIGMA[i16 + 15]);\n }\n\n for (let i = 0; i < 16; i++) {\n S.h[i] ^= v[i] ^ v[i + 16];\n }\n}\n\n// Creates a BLAKE2b hashing context\n// Requires an output length between 1 and 64 bytes\n// Takes an optional Uint8Array key\nclass Blake2b {\n constructor(outlen, key, salt, personal) {\n const params = new Uint8Array(64);\n // 0: outlen, keylen, fanout, depth\n // 4: leaf length, sequential mode\n // 8: node offset\n // 12: node offset\n // 16: node depth, inner length, rfu\n // 20: rfu\n // 24: rfu\n // 28: rfu\n // 32: salt\n // 36: salt\n // 40: salt\n // 44: salt\n // 48: personal\n // 52: personal\n // 56: personal\n // 60: personal\n\n // init internal state\n this.S = {\n b: new Uint8Array(BLOCKBYTES),\n h: new Uint32Array(OUTBYTES_MAX / 4),\n t0: new Uint32Array(2), // input counter `t`, lower 64-bits only\n c: 0, // `fill`, pointer within buffer, up to `BLOCKBYTES`\n outlen // output length in bytes\n };\n\n // init parameter block\n params[0] = outlen;\n if (key) params[1] = key.length;\n params[2] = 1; // fanout\n params[3] = 1; // depth\n if (salt) params.set(salt, 32);\n if (personal) params.set(personal, 48);\n const params32 = new Uint32Array(params.buffer, params.byteOffset, params.length / Uint32Array.BYTES_PER_ELEMENT);\n\n // initialize hash state\n for (let i = 0; i < 16; i++) {\n this.S.h[i] = BLAKE2B_IV32[i] ^ params32[i];\n }\n\n // key the hash, if applicable\n if (key) {\n const block = new Uint8Array(BLOCKBYTES);\n block.set(key);\n this.update(block);\n }\n }\n\n // Updates a BLAKE2b streaming hash\n // Requires Uint8Array (byte array)\n update(input) {\n if (!(input instanceof Uint8Array)) throw new Error('Input must be Uint8Array or Buffer')\n // for (let i = 0; i < input.length; i++) {\n // if (this.S.c === BLOCKBYTES) { // buffer full\n // INC64(this.S.t0, this.S.c) // add counters\n // compress(this.S, false)\n // this.S.c = 0 // empty buffer\n // }\n // this.S.b[this.S.c++] = input[i]\n // }\n let i = 0;\n while(i < input.length) {\n if (this.S.c === BLOCKBYTES) { // buffer full\n INC64(this.S.t0, this.S.c); // add counters\n compress(this.S, false);\n this.S.c = 0; // empty buffer\n }\n let left = BLOCKBYTES - this.S.c;\n this.S.b.set(input.subarray(i, i + left), this.S.c); // end index can be out of bounds\n const fill = Math.min(left, input.length - i);\n this.S.c += fill;\n i += fill;\n }\n return this\n }\n\n /**\n * Return a BLAKE2b hash, either filling the given Uint8Array or allocating a new one\n * @param {Uint8Array} [prealloc] - optional preallocated buffer\n * @returns {ArrayBuffer} message digest\n */\n digest(prealloc) {\n INC64(this.S.t0, this.S.c); // mark last block offset\n\n // final block, padded\n this.S.b.fill(0, this.S.c);\n this.S.c = BLOCKBYTES;\n compress(this.S, true);\n\n const out = prealloc || new Uint8Array(this.S.outlen);\n for (let i = 0; i < this.S.outlen; i++) {\n // must be loaded individually since default Uint32 endianness is platform dependant\n out[i] = this.S.h[i >> 2] >> (8 * (i & 3));\n }\n this.S.h = null; // prevent calling `update` after `digest`\n return out.buffer;\n }\n}\n\n\nfunction createHash(outlen, key, salt, personal) {\n if (outlen > OUTBYTES_MAX) throw new Error(`outlen must be at most ${OUTBYTES_MAX} (given: ${outlen})`)\n\n return new Blake2b(outlen, key, salt, personal)\n}\n\nconst OUTBYTES_MAX = 64;\nconst BLOCKBYTES = 128;\n\nconst TYPE = 2; // Argon2id\nconst VERSION = 0x13;\nconst TAGBYTES_MAX = 0xFFFFFFFF; // Math.pow(2, 32) - 1;\nconst TAGBYTES_MIN = 4; // Math.pow(2, 32) - 1;\nconst SALTBYTES_MAX = 0xFFFFFFFF; // Math.pow(2, 32) - 1;\nconst SALTBYTES_MIN = 8;\nconst passwordBYTES_MAX = 0xFFFFFFFF;// Math.pow(2, 32) - 1;\nconst passwordBYTES_MIN = 8;\nconst MEMBYTES_MAX = 0xFFFFFFFF;// Math.pow(2, 32) - 1;\nconst ADBYTES_MAX = 0xFFFFFFFF; // Math.pow(2, 32) - 1; // associated data (optional)\nconst SECRETBYTES_MAX = 32; // key (optional)\n\nconst ARGON2_BLOCK_SIZE = 1024;\nconst ARGON2_PREHASH_DIGEST_LENGTH = 64;\n\nconst isLittleEndian = new Uint8Array(new Uint16Array([0xabcd]).buffer)[0] === 0xcd;\n\n// store n as a little-endian 32-bit Uint8Array inside buf (at buf[i:i+3])\nfunction LE32(buf, n, i) {\n buf[i+0] = n;\n buf[i+1] = n >> 8;\n buf[i+2] = n >> 16;\n buf[i+3] = n >> 24;\n return buf;\n}\n\n/**\n * Store n as a 64-bit LE number in the given buffer (from buf[i] to buf[i+7])\n * @param {Uint8Array} buf\n * @param {Number} n\n * @param {Number} i\n */\nfunction LE64(buf, n, i) {\n if (n > Number.MAX_SAFE_INTEGER) throw new Error(\"LE64: large numbers unsupported\");\n // ECMAScript standard has engines convert numbers to 32-bit integers for bitwise operations\n // shifting by 32 or more bits is not supported (https://stackoverflow.com/questions/6729122/javascript-bit-shift-number-wraps)\n // so we manually extract each byte\n let remainder = n;\n for (let offset = i; offset < i+7; offset++) { // last byte can be ignored as it would overflow MAX_SAFE_INTEGER\n buf[offset] = remainder; // implicit & 0xff\n remainder = (remainder - buf[offset]) / 256;\n }\n return buf;\n}\n\n/**\n * Variable-Length Hash Function H'\n * @param {Number} outlen - T\n * @param {Uint8Array} X - value to hash\n * @param {Uint8Array} res - output buffer, of length `outlength` or larger\n */\nfunction H_(outlen, X, res) {\n const V = new Uint8Array(64); // no need to keep around all V_i\n\n const V1_in = new Uint8Array(4 + X.length);\n LE32(V1_in, outlen, 0);\n V1_in.set(X, 4);\n if (outlen <= 64) {\n // H'^T(A) = H^T(LE32(T)||A)\n createHash(outlen).update(V1_in).digest(res);\n return res\n }\n\n const r = Math.ceil(outlen / 32) - 2;\n\n // Let V_i be a 64-byte block and W_i be its first 32 bytes.\n // V_1 = H^(64)(LE32(T)||A)\n // V_2 = H^(64)(V_1)\n // ...\n // V_r = H^(64)(V_{r-1})\n // V_{r+1} = H^(T-32*r)(V_{r})\n // H'^T(X) = W_1 || W_2 || ... || W_r || V_{r+1}\n for (let i = 0; i < r; i++) {\n createHash(64).update(i === 0 ? V1_in : V).digest(V);\n // store W_i in result buffer already\n res.set(V.subarray(0, 32), i*32);\n }\n // V_{r+1}\n const V_r1 = new Uint8Array(createHash(outlen - 32*r).update(V).digest());\n res.set(V_r1, r*32);\n\n return res;\n}\n\n// compute buf = xs ^ ys\nfunction XOR(wasmContext, buf, xs, ys) {\n wasmContext.fn.XOR(\n buf.byteOffset,\n xs.byteOffset,\n ys.byteOffset,\n );\n return buf\n}\n\n/**\n * @param {Uint8Array} X (read-only)\n * @param {Uint8Array} Y (read-only)\n * @param {Uint8Array} R - output buffer\n * @returns\n */\nfunction G(wasmContext, X, Y, R) {\n wasmContext.fn.G(\n X.byteOffset,\n Y.byteOffset,\n R.byteOffset,\n wasmContext.refs.gZ.byteOffset\n );\n return R;\n}\n\nfunction G2(wasmContext, X, Y, R) {\n wasmContext.fn.G2(\n X.byteOffset,\n Y.byteOffset,\n R.byteOffset,\n wasmContext.refs.gZ.byteOffset\n );\n return R;\n}\n\n// Generator for data-independent J1, J2. Each `next()` invocation returns a new pair of values.\nfunction* makePRNG(wasmContext, pass, lane, slice, m_, totalPasses, segmentLength, segmentOffset) {\n // For each segment, we do the following. First, we compute the value Z as:\n // Z= ( LE64(r) || LE64(l) || LE64(sl) || LE64(m') || LE64(t) || LE64(y) )\n wasmContext.refs.prngTmp.fill(0);\n const Z = wasmContext.refs.prngTmp.subarray(0, 6 * 8);\n LE64(Z, pass, 0);\n LE64(Z, lane, 8);\n LE64(Z, slice, 16);\n LE64(Z, m_, 24);\n LE64(Z, totalPasses, 32);\n LE64(Z, TYPE, 40);\n\n // Then we compute q/(128*SL) 1024-byte values\n // G( ZERO(1024),\n // G( ZERO(1024), Z || LE64(1) || ZERO(968) ) ),\n // ...,\n // G( ZERO(1024),\n // G( ZERO(1024), Z || LE64(q/(128*SL)) || ZERO(968) )),\n for(let i = 1; i <= segmentLength; i++) {\n // tmp.set(Z); // no need to re-copy\n LE64(wasmContext.refs.prngTmp, i, Z.length); // tmp.set(ZER0968) not necessary, memory already zeroed\n const g2 = G2(wasmContext, wasmContext.refs.ZERO1024, wasmContext.refs.prngTmp, wasmContext.refs.prngR );\n\n // each invocation of G^2 outputs 1024 bytes that are to be partitioned into 8-bytes values, take as X1 || X2\n // NB: the first generated pair must be used for the first block of the segment, and so on.\n // Hence, if some blocks are skipped (e.g. during the first pass), the corresponding J1J2 are discarded based on the given segmentOffset.\n for(let k = i === 1 ? segmentOffset*8 : 0; k < g2.length; k += 8) {\n yield g2.subarray(k, k+8);\n }\n }\n return [];\n}\n\nfunction validateParams({ type, version, tagLength, password, salt, ad, secret, parallelism, memorySize, passes }) {\n const assertLength = (name, value, min, max) => {\n if (value < min || value > max) { throw new Error(`${name} size should be between ${min} and ${max} bytes`); }\n };\n\n if (type !== TYPE || version !== VERSION) throw new Error('Unsupported type or version');\n assertLength('password', password, passwordBYTES_MIN, passwordBYTES_MAX);\n assertLength('salt', salt, SALTBYTES_MIN, SALTBYTES_MAX);\n assertLength('tag', tagLength, TAGBYTES_MIN, TAGBYTES_MAX);\n assertLength('memory', memorySize, 8*parallelism, MEMBYTES_MAX);\n // optional fields\n ad && assertLength('associated data', ad, 0, ADBYTES_MAX);\n secret && assertLength('secret', secret, 0, SECRETBYTES_MAX);\n\n return { type, version, tagLength, password, salt, ad, secret, lanes: parallelism, memorySize, passes };\n}\n\nconst KB = 1024;\nconst WASM_PAGE_SIZE = 64 * KB;\n\nfunction argon2id(params, { memory, instance: wasmInstance }) {\n if (!isLittleEndian) throw new Error('BigEndian system not supported'); // optmisations assume LE system\n\n const ctx = validateParams({ type: TYPE, version: VERSION, ...params });\n\n const { G:wasmG, G2:wasmG2, xor:wasmXOR, getLZ:wasmLZ } = wasmInstance.exports;\n const wasmRefs = {};\n const wasmFn = {};\n wasmFn.G = wasmG;\n wasmFn.G2 = wasmG2;\n wasmFn.XOR = wasmXOR;\n\n // The actual number of blocks is m', which is m rounded down to the nearest multiple of 4*p.\n const m_ = 4 * ctx.lanes * Math.floor(ctx.memorySize / (4 * ctx.lanes));\n const requiredMemory = m_ * ARGON2_BLOCK_SIZE + 10 * KB; // Additional KBs for utility references\n if (memory.buffer.byteLength < requiredMemory) {\n const missing = Math.ceil((requiredMemory - memory.buffer.byteLength) / WASM_PAGE_SIZE);\n // If enough memory is available, the `memory.buffer` is internally detached and the reference updated.\n // Otherwise, the operation fails, and the original memory can still be used.\n memory.grow(missing);\n }\n\n let offset = 0;\n // Init wasm memory needed in other functions\n wasmRefs.gZ = new Uint8Array(memory.buffer, offset, ARGON2_BLOCK_SIZE); offset+= wasmRefs.gZ.length;\n wasmRefs.prngR = new Uint8Array(memory.buffer, offset, ARGON2_BLOCK_SIZE); offset+=wasmRefs.prngR.length;\n wasmRefs.prngTmp = new Uint8Array(memory.buffer, offset, ARGON2_BLOCK_SIZE); offset+=wasmRefs.prngTmp.length;\n wasmRefs.ZERO1024 = new Uint8Array(memory.buffer, offset, 1024); offset+=wasmRefs.ZERO1024.length;\n // Init wasm memory needed locally\n const lz = new Uint32Array(memory.buffer, offset, 2); offset+=lz.length * Uint32Array.BYTES_PER_ELEMENT;\n const wasmContext = { fn: wasmFn, refs: wasmRefs };\n const newBlock = new Uint8Array(memory.buffer, offset, ARGON2_BLOCK_SIZE); offset+=newBlock.length;\n const blockMemory = new Uint8Array(memory.buffer, offset, ctx.memorySize * ARGON2_BLOCK_SIZE);\n const allocatedMemory = new Uint8Array(memory.buffer, 0, offset);\n\n // 1. Establish H_0\n const H0 = getH0(ctx);\n\n // 2. Allocate the memory as m' 1024-byte blocks\n // For p lanes, the memory is organized in a matrix B[i][j] of blocks with p rows (lanes) and q = m' / p columns.\n const q = m_ / ctx.lanes;\n const B = new Array(ctx.lanes).fill(null).map(() => new Array(q));\n const initBlock = (i, j) => {\n B[i][j] = blockMemory.subarray(i*q*1024 + j*1024, (i*q*1024 + j*1024) + ARGON2_BLOCK_SIZE);\n return B[i][j];\n };\n\n for (let i = 0; i < ctx.lanes; i++) {\n // const LEi = LE0; // since p = 1 for us\n const tmp = new Uint8Array(H0.length + 8);\n // 3. Compute B[i][0] for all i ranging from (and including) 0 to (not including) p\n // B[i][0] = H'^(1024)(H_0 || LE32(0) || LE32(i))\n tmp.set(H0); LE32(tmp, 0, H0.length); LE32(tmp, i, H0.length + 4);\n H_(ARGON2_BLOCK_SIZE, tmp, initBlock(i, 0));\n // 4. Compute B[i][1] for all i ranging from (and including) 0 to (not including) p\n // B[i][1] = H'^(1024)(H_0 || LE32(1) || LE32(i))\n LE32(tmp, 1, H0.length);\n H_(ARGON2_BLOCK_SIZE, tmp, initBlock(i, 1));\n }\n\n // 5. Compute B[i][j] for all i ranging from (and including) 0 to (not including) p and for all j ranging from (and including) 2\n // to (not including) q. The computation MUST proceed slicewise (Section 3.4) : first, blocks from slice 0 are computed for all lanes\n // (in an arbitrary order of lanes), then blocks from slice 1 are computed, etc.\n const SL = 4; // vertical slices\n const segmentLength = q / SL;\n for (let pass = 0; pass < ctx.passes; pass++) {\n // The intersection of a slice and a lane is called a segment, which has a length of q/SL. Segments of the same slice can be computed in parallel\n for (let sl = 0; sl < SL; sl++) {\n const isDataIndependent = pass === 0 && sl <= 1;\n for (let i = 0; i < ctx.lanes; i++) { // lane\n // On the first slice of the first pass, blocks 0 and 1 are already filled\n let segmentOffset = sl === 0 && pass === 0 ? 2 : 0;\n // no need to generate all J1J2s, use iterator/generator that creates the value on the fly (to save memory)\n const PRNG = isDataIndependent ? makePRNG(wasmContext, pass, i, sl, m_, ctx.passes, segmentLength, segmentOffset) : null;\n for (segmentOffset; segmentOffset < segmentLength; segmentOffset++) {\n const j = sl * segmentLength + segmentOffset;\n const prevBlock = j > 0 ? B[i][j-1] : B[i][q-1]; // B[i][(j-1) mod q]\n\n // we can assume the PRNG is never done\n const J1J2 = isDataIndependent ? PRNG.next().value : prevBlock; // .subarray(0, 8) not required since we only pass the byteOffset to wasm\n // The block indices l and z are determined for each i, j differently for Argon2d, Argon2i, and Argon2id.\n wasmLZ(lz.byteOffset, J1J2.byteOffset, i, ctx.lanes, pass, sl, segmentOffset, SL, segmentLength);\n const l = lz[0]; const z = lz[1];\n // for (let i = 0; i < p; i++ )\n // B[i][j] = G(B[i][j-1], B[l][z])\n // The block indices l and z are determined for each i, j differently for Argon2d, Argon2i, and Argon2id.\n if (pass === 0) initBlock(i, j);\n G(wasmContext, prevBlock, B[l][z], pass > 0 ? newBlock : B[i][j]);\n\n // 6. If the number of passes t is larger than 1, we repeat step 5. However, blocks are computed differently as the old value is XORed with the new one\n if (pass > 0) XOR(wasmContext, B[i][j], newBlock, B[i][j]);\n }\n }\n }\n }\n\n // 7. After t steps have been iterated, the final block C is computed as the XOR of the last column:\n // C = B[0][q-1] XOR B[1][q-1] XOR ... XOR B[p-1][q-1]\n const C = B[0][q-1];\n for(let i = 1; i < ctx.lanes; i++) {\n XOR(wasmContext, C, C, B[i][q-1]);\n }\n\n const tag = H_(ctx.tagLength, C, new Uint8Array(ctx.tagLength));\n // clear memory since the module might be cached\n allocatedMemory.fill(0); // clear sensitive contents\n memory.grow(0); // allow deallocation\n // 8. The output tag is computed as H'^T(C).\n return tag;\n\n}\n\nfunction getH0(ctx) {\n const H = createHash(ARGON2_PREHASH_DIGEST_LENGTH);\n const ZERO32 = new Uint8Array(4);\n const params = new Uint8Array(24);\n LE32(params, ctx.lanes, 0);\n LE32(params, ctx.tagLength, 4);\n LE32(params, ctx.memorySize, 8);\n LE32(params, ctx.passes, 12);\n LE32(params, ctx.version, 16);\n LE32(params, ctx.type, 20);\n\n const toHash = [params];\n if (ctx.password) {\n toHash.push(LE32(new Uint8Array(4), ctx.password.length, 0));\n toHash.push(ctx.password);\n } else {\n toHash.push(ZERO32); // context.password.length\n }\n\n if (ctx.salt) {\n toHash.push(LE32(new Uint8Array(4), ctx.salt.length, 0));\n toHash.push(ctx.salt);\n } else {\n toHash.push(ZERO32); // context.salt.length\n }\n\n if (ctx.secret) {\n toHash.push(LE32(new Uint8Array(4), ctx.secret.length, 0));\n toHash.push(ctx.secret);\n // todo clear secret?\n } else {\n toHash.push(ZERO32); // context.secret.length\n }\n\n if (ctx.ad) {\n toHash.push(LE32(new Uint8Array(4), ctx.ad.length, 0));\n toHash.push(ctx.ad);\n } else {\n toHash.push(ZERO32); // context.ad.length\n }\n H.update(concatArrays(toHash));\n\n const outputBuffer = H.digest();\n return new Uint8Array(outputBuffer);\n}\n\nfunction concatArrays(arrays) {\n if (arrays.length === 1) return arrays[0];\n\n let totalLength = 0;\n for (let i = 0; i < arrays.length; i++) {\n if (!(arrays[i] instanceof Uint8Array)) {\n throw new Error('concatArrays: Data must be in the form of a Uint8Array');\n }\n\n totalLength += arrays[i].length;\n }\n\n const result = new Uint8Array(totalLength);\n let pos = 0;\n arrays.forEach((element) => {\n result.set(element, pos);\n pos += element.length;\n });\n\n return result;\n}\n\nlet isSIMDSupported;\nasync function wasmLoader(memory, getSIMD, getNonSIMD) {\n const importObject = { env: { memory } };\n if (isSIMDSupported === undefined) {\n try {\n const loaded = await getSIMD(importObject);\n isSIMDSupported = true;\n return loaded;\n } catch(e) {\n isSIMDSupported = false;\n }\n }\n\n const loader = isSIMDSupported ? getSIMD : getNonSIMD;\n return loader(importObject);\n}\n\nasync function setupWasm(getSIMD, getNonSIMD) {\n const memory = new WebAssembly.Memory({\n // in pages of 64KiB each\n // these values need to be compatible with those declared when building in `build-wasm`\n initial: 1040, // 65MB\n maximum: 65536, // 4GB\n });\n const wasmModule = await wasmLoader(memory, getSIMD, getNonSIMD);\n\n /**\n * Argon2id hash function\n * @callback computeHash\n * @param {Object} params\n * @param {Uint8Array} params.password - password\n * @param {Uint8Array} params.salt - salt\n * @param {Integer} params.parallelism\n * @param {Integer} params.passes\n * @param {Integer} params.memorySize - in kibibytes\n * @param {Integer} params.tagLength - output tag length\n * @param {Uint8Array} [params.ad] - associated data (optional)\n * @param {Uint8Array} [params.secret] - secret data (optional)\n * @return {Uint8Array} argon2id hash\n */\n const computeHash = (params) => argon2id(params, { instance: wasmModule.instance, memory });\n\n return computeHash;\n}\n\nfunction _loadWasmModule (sync, filepath, src, imports) {\n function _instantiateOrCompile(source, imports, stream) {\n var instantiateFunc = stream ? WebAssembly.instantiateStreaming : WebAssembly.instantiate;\n var compileFunc = stream ? WebAssembly.compileStreaming : WebAssembly.compile;\n\n if (imports) {\n return instantiateFunc(source, imports)\n } else {\n return compileFunc(source)\n }\n }\n\n \nvar buf = null;\n\n\nvar raw = globalThis.atob(src);\nvar rawLength = raw.length;\nbuf = new Uint8Array(new ArrayBuffer(rawLength));\nfor(var i = 0; i < rawLength; i++) {\n buf[i] = raw.charCodeAt(i);\n}\n\n\n\n {\n return _instantiateOrCompile(buf, imports, false)\n }\n}\n\nfunction wasmSIMD(imports){return _loadWasmModule(0, null, 'AGFzbQEAAAABKwdgBH9/f38AYAABf2AAAGADf39/AGAJf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BHQiAGoiASAAIANq/QAEACAB/QAEAP1R/QsEACACIABBEHIiAWoiDyABIANq/QAEACAP/QAEAP1R/QsEACACIABBIHIiAWoiDyABIANq/QAEACAP/QAEAP1R/QsEACACIABBMHIiAGoiASAAIANq/QAEACAB/QAEAP1R/QsEACAQQQRqIhBBwABHDQALCxYAIAAgASACIAMQAiAAIAIgAiADEAILewIBfwF+IAIhCSABNQIAIQogBCAFcgRAIAEoAgQgA3AhCQsgACAJNgIAIAAgB0EBayAFIAQbIAhsIAZBAWtBAEF/IAYbIAIgCUYbaiIBIAVBAWogCGxBACAEG2ogAa0gCiAKfkIgiH5CIIinQX9zaiAHIAhscDYCBCAACwQAIwALBgAgACQACxAAIwAgAGtBcHEiACQAIAALBQBBgAgL', imports)}\n\nfunction wasmNonSIMD(imports){return _loadWasmModule(0, null, 'AGFzbQEAAAABPwhgBH9/f38AYAABf2AAAGADf39/AGARf39/f39/f39/f39/f39/f38AYAl/f39/f39/f38Bf2ABfwBgAX8BfwITAQNlbnYGbWVtb3J5AgGQCICABAMLCgIDBAAABQEGBwEEBQFwAQICBgkBfwFBkIjAAgsHfQoDeG9yAAEBRwADAkcyAAQFZ2V0TFoABRlfX2luZGlyZWN0X2Z1bmN0aW9uX3RhYmxlAQALX2luaXRpYWxpemUAABBfX2Vycm5vX2xvY2F0aW9uAAkJc3RhY2tTYXZlAAYMc3RhY2tSZXN0b3JlAAcKc3RhY2tBbGxvYwAICQcBAEEBCwEACssaCgMAAQtQAQJ/A0AgACAEQQN0IgNqIAIgA2opAwAgASADaikDAIU3AwAgACADQQhyIgNqIAIgA2opAwAgASADaikDAIU3AwAgBEECaiIEQYABRw0ACwveDwICfgF/IAAgAUEDdGoiEyATKQMAIhEgACAFQQN0aiIBKQMAIhJ8IBFCAYZC/v///x+DIBJC/////w+DfnwiETcDACAAIA1BA3RqIgUgESAFKQMAhUIgiSIRNwMAIAAgCUEDdGoiCSARIAkpAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAEgESABKQMAhUIoiSIRNwMAIBMgESATKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACAFIBEgBSkDAIVCMIkiETcDACAJIBEgCSkDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgASARIAEpAwCFQgGJNwMAIAAgAkEDdGoiDSANKQMAIhEgACAGQQN0aiICKQMAIhJ8IBFCAYZC/v///x+DIBJC/////w+DfnwiETcDACAAIA5BA3RqIgYgESAGKQMAhUIgiSIRNwMAIAAgCkEDdGoiCiARIAopAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAIgESACKQMAhUIoiSIRNwMAIA0gESANKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACAGIBEgBikDAIVCMIkiETcDACAKIBEgCikDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgAiARIAIpAwCFQgGJNwMAIAAgA0EDdGoiDiAOKQMAIhEgACAHQQN0aiIDKQMAIhJ8IBFCAYZC/v///x+DIBJC/////w+DfnwiETcDACAAIA9BA3RqIgcgESAHKQMAhUIgiSIRNwMAIAAgC0EDdGoiCyARIAspAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAMgESADKQMAhUIoiSIRNwMAIA4gESAOKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACAHIBEgBykDAIVCMIkiETcDACALIBEgCykDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgAyARIAMpAwCFQgGJNwMAIAAgBEEDdGoiDyAPKQMAIhEgACAIQQN0aiIEKQMAIhJ8IBFCAYZC/v///x+DIBJC/////w+DfnwiETcDACAAIBBBA3RqIgggESAIKQMAhUIgiSIRNwMAIAAgDEEDdGoiACARIAApAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAQgESAEKQMAhUIoiSIRNwMAIA8gESAPKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACAIIBEgCCkDAIVCMIkiETcDACAAIBEgACkDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgBCARIAQpAwCFQgGJNwMAIBMgEykDACIRIAIpAwAiEnwgEUIBhkL+////H4MgEkL/////D4N+fCIRNwMAIAggESAIKQMAhUIgiSIRNwMAIAsgESALKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACACIBEgAikDAIVCKIkiETcDACATIBEgEykDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgCCARIAgpAwCFQjCJIhE3AwAgCyARIAspAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAIgESACKQMAhUIBiTcDACANIA0pAwAiESADKQMAIhJ8IBFCAYZC/v///x+DIBJC/////w+DfnwiETcDACAFIBEgBSkDAIVCIIkiETcDACAAIBEgACkDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgAyARIAMpAwCFQiiJIhE3AwAgDSARIA0pAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAUgESAFKQMAhUIwiSIRNwMAIAAgESAAKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACADIBEgAykDAIVCAYk3AwAgDiAOKQMAIhEgBCkDACISfCARQgGGQv7///8fgyASQv////8Pg358IhE3AwAgBiARIAYpAwCFQiCJIhE3AwAgCSARIAkpAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAQgESAEKQMAhUIoiSIRNwMAIA4gESAOKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACAGIBEgBikDAIVCMIkiETcDACAJIBEgCSkDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgBCARIAQpAwCFQgGJNwMAIA8gDykDACIRIAEpAwAiEnwgEUIBhkL+////H4MgEkL/////D4N+fCIRNwMAIAcgESAHKQMAhUIgiSIRNwMAIAogESAKKQMAIhJ8IBFC/////w+DIBJCAYZC/v///x+DfnwiETcDACABIBEgASkDAIVCKIkiETcDACAPIBEgDykDACISfCARQv////8PgyASQgGGQv7///8fg358IhE3AwAgByARIAcpAwCFQjCJIhE3AwAgCiARIAopAwAiEnwgEUL/////D4MgEkIBhkL+////H4N+fCIRNwMAIAEgESABKQMAhUIBiTcDAAvdCAEPfwNAIAIgBUEDdCIGaiABIAZqKQMAIAAgBmopAwCFNwMAIAIgBkEIciIGaiABIAZqKQMAIAAgBmopAwCFNwMAIAVBAmoiBUGAAUcNAAsDQCADIARBA3QiAGogACACaikDADcDACADIARBAXIiAEEDdCIBaiABIAJqKQMANwMAIAMgBEECciIBQQN0IgVqIAIgBWopAwA3AwAgAyAEQQNyIgVBA3QiBmogAiAGaikDADcDACADIARBBHIiBkEDdCIHaiACIAdqKQMANwMAIAMgBEEFciIHQQN0IghqIAIgCGopAwA3AwAgAyAEQQZyIghBA3QiCWogAiAJaikDADcDACADIARBB3IiCUEDdCIKaiACIApqKQMANwMAIAMgBEEIciIKQQN0IgtqIAIgC2opAwA3AwAgAyAEQQlyIgtBA3QiDGogAiAMaikDADcDACADIARBCnIiDEEDdCINaiACIA1qKQMANwMAIAMgBEELciINQQN0Ig5qIAIgDmopAwA3AwAgAyAEQQxyIg5BA3QiD2ogAiAPaikDADcDACADIARBDXIiD0EDdCIQaiACIBBqKQMANwMAIAMgBEEOciIQQQN0IhFqIAIgEWopAwA3AwAgAyAEQQ9yIhFBA3QiEmogAiASaikDADcDACADIARB//8DcSAAQf//A3EgAUH//wNxIAVB//8DcSAGQf//A3EgB0H//wNxIAhB//8DcSAJQf//A3EgCkH//wNxIAtB//8DcSAMQf//A3EgDUH//wNxIA5B//8DcSAPQf//A3EgEEH//wNxIBFB//8DcRACIARB8ABJIQAgBEEQaiEEIAANAAtBACEBIANBAEEBQRBBEUEgQSFBMEExQcAAQcEAQdAAQdEAQeAAQeEAQfAAQfEAEAIgA0ECQQNBEkETQSJBI0EyQTNBwgBBwwBB0gBB0wBB4gBB4wBB8gBB8wAQAiADQQRBBUEUQRVBJEElQTRBNUHEAEHFAEHUAEHVAEHkAEHlAEH0AEH1ABACIANBBkEHQRZBF0EmQSdBNkE3QcYAQccAQdYAQdcAQeYAQecAQfYAQfcAEAIgA0EIQQlBGEEZQShBKUE4QTlByABByQBB2ABB2QBB6ABB6QBB+ABB+QAQAiADQQpBC0EaQRtBKkErQTpBO0HKAEHLAEHaAEHbAEHqAEHrAEH6AEH7ABACIANBDEENQRxBHUEsQS1BPEE9QcwAQc0AQdwAQd0AQewAQe0AQfwAQf0AEAIgA0EOQQ9BHkEfQS5BL0E+QT9BzgBBzwBB3gBB3wBB7gBB7wBB/gBB/wAQAgNAIAIgAUEDdCIAaiIEIAAgA2opAwAgBCkDAIU3AwAgAiAAQQhyIgRqIgUgAyAEaikDACAFKQMAhTcDACACIABBEHIiBGoiBSADIARqKQMAIAUpAwCFNwMAIAIgAEEYciIAaiIEIAAgA2opAwAgBCkDAIU3AwAgAUEEaiIBQYABRw0ACwsWACAAIAEgAiADEAMgACACIAIgAxADC3sCAX8BfiACIQkgATUCACEKIAQgBXIEQCABKAIEIANwIQkLIAAgCTYCACAAIAdBAWsgBSAEGyAIbCAGQQFrQQBBfyAGGyACIAlGG2oiASAFQQFqIAhsQQAgBBtqIAGtIAogCn5CIIh+QiCIp0F/c2ogByAIbHA2AgQgAAsEACMACwYAIAAkAAsQACMAIABrQXBxIgAkACAACwUAQYAICw==', imports)}\n\nconst loadWasm = async () => setupWasm(\n (instanceObject) => wasmSIMD(instanceObject),\n (instanceObject) => wasmNonSIMD(instanceObject),\n);\n\nexport { loadWasm as default };\n"],"ignoreList":[0],"mappings":";;AACA,IAAMA,eAAa,OAAO,WAAW,cAAc,SAAS,OAAO,WAAW,cAAc,SAAS,OAAO,SAAS,cAAc,OAAO,CAAC;AAY3I,SAAS,MAAO,GAAG,GAAG,GAAG,GAAG;CAC1B,EAAE,MAAM,EAAE;CACV,EAAE,IAAE,MAAM,EAAE,IAAE,MAAM,EAAE,KAAK,EAAE;AAC/B;AAIA,SAAS,MAAO,G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file":"bark_ffi_wasm_bg-EY2uc0Bx.js","names":["import.meta.ROLLDOWN_FILE_URL_WPGYjwIlzWVNM1bYhOc83w"],"sources":["../../../../node_modules/@secondts/bark/web/bark_ffi_wasm_bg.wasm?url"],"sourcesContent":["export default import.meta.ROLLDOWN_FILE_URL_WPGYjwIlzWVNM1bYhOc83w"],"x_google_ignoreList":[0],"mappings":";AAAA,IAAA,2BAAe,IAAA,IAAA,oCAAA,YAAA,GAAmD,CAAA,CAAnDA"}
1
+ {"version":3,"file":"bark_ffi_wasm_bg-EY2uc0Bx.js","names":["import.meta.ROLLDOWN_FILE_URL_WPGYjwIlzWVNM1bYhOc83w"],"sources":["../../../../node_modules/@secondts/bark/web/bark_ffi_wasm_bg.wasm?url"],"sourcesContent":["export default import.meta.ROLLDOWN_FILE_URL_WPGYjwIlzWVNM1bYhOc83w"],"ignoreList":[0],"mappings":";AAAA,IAAA,2BAAe,IAAA,IAAA,oCAAA,YAAA,GAAmD,CAAA,CAAnDA"}
@@ -1 +1 @@
1
- {"version":3,"file":"bitcoindevkit_bg-B-iLWrmX.js","names":["import.meta.ROLLDOWN_FILE_URL_FKNdLzKnlftW3t_gzo81yw"],"sources":["../../../../node_modules/@bitcoindevkit/bdk-wallet-web/bitcoindevkit_bg.wasm?url"],"sourcesContent":["export default import.meta.ROLLDOWN_FILE_URL_FKNdLzKnlftW3t_gzo81yw"],"x_google_ignoreList":[0],"mappings":";AAAA,IAAA,2BAAe,IAAA,IAAA,oCAAA,YAAA,GAAmD,CAAA,CAAnDA"}
1
+ {"version":3,"file":"bitcoindevkit_bg-B-iLWrmX.js","names":["import.meta.ROLLDOWN_FILE_URL_FKNdLzKnlftW3t_gzo81yw"],"sources":["../../../../node_modules/@bitcoindevkit/bdk-wallet-web/bitcoindevkit_bg.wasm?url"],"sourcesContent":["export default import.meta.ROLLDOWN_FILE_URL_FKNdLzKnlftW3t_gzo81yw"],"ignoreList":[0],"mappings":";AAAA,IAAA,2BAAe,IAAA,IAAA,oCAAA,YAAA,GAAmD,CAAA,CAAnDA"}
@@ -1 +1 @@
1
- {"version":3,"file":"fedimint_client_wasm_bg-BtHHlFpp.js","names":["import.meta.ROLLDOWN_FILE_URL_VRAku6fjghkApIISiBWPzg"],"sources":["../../../../node_modules/@fedimint/fedimint-client-wasm-bundler/fedimint_client_wasm_bg.wasm?url"],"sourcesContent":["export default import.meta.ROLLDOWN_FILE_URL_VRAku6fjghkApIISiBWPzg"],"x_google_ignoreList":[0],"mappings":";AAAA,IAAA,kCAAe,IAAA,IAAA,2CAAA,YAAA,GAAmD,CAAA,CAAnDA"}
1
+ {"version":3,"file":"fedimint_client_wasm_bg-BtHHlFpp.js","names":["import.meta.ROLLDOWN_FILE_URL_VRAku6fjghkApIISiBWPzg"],"sources":["../../../../node_modules/@fedimint/fedimint-client-wasm-bundler/fedimint_client_wasm_bg.wasm?url"],"sourcesContent":["export default import.meta.ROLLDOWN_FILE_URL_VRAku6fjghkApIISiBWPzg"],"ignoreList":[0],"mappings":";AAAA,IAAA,kCAAe,IAAA,IAAA,2CAAA,YAAA,GAAmD,CAAA,CAAnDA"}
@@ -1,5 +1,5 @@
1
- import { Qs as fromBase64Url } from "./src-CJdPTl7Q.js";
2
- import { n as hyperdhtRelayProblem } from "./server-vGoe9MET.js";
1
+ import { $s as fromBase64Url } from "./src-K3NijMq-.js";
2
+ import { n as hyperdhtRelayProblem } from "./server-CXFTDnFI.js";
3
3
  import { ed25519 } from "@noble/curves/ed25519.js";
4
4
  //#region ../browser/src/platform/hyperdhtRelay.ts
5
5
  /**
@@ -339,4 +339,4 @@ async function createRelayedHyperEndpoint(seedB64, url, options = {}) {
339
339
  //#endregion
340
340
  export { createRelayedHyperEndpoint };
341
341
 
342
- //# sourceMappingURL=hyperdhtRelay-CVLCuqVr.js.map
342
+ //# sourceMappingURL=hyperdhtRelay-BoxPHp7v.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"hyperdhtRelay-CVLCuqVr.js","names":[],"sources":["../../../browser/src/platform/hyperdhtRelay.ts"],"sourcesContent":["import { ed25519 } from \"@noble/curves/ed25519.js\";\nimport { fromBase64Url, type BoundChannel, type FrameChannel, type NativeEndpoint } from \"@ghostly/core\";\nimport { hyperdhtRelayProblem } from \"../shared/hyperdhtRelay\";\n\nexport { hyperdhtRelayProblem as relayUrlProblem };\n\n/**\n * HyperDHT (WISP 103) for a browser, through a dht-relay: a server that runs the UDP half of HyperDHT and\n * talks to the browser over one WebSocket. It runs non-custodial: the browser keeps its keys, runs the\n * Noise handshake and the encrypted stream itself, and the relay moves handshake messages and ciphertext.\n * The binding (the handshake hash and both keys) is computed here, at the endpoint, as the Desktop does.\n *\n * What the relay sees: this browser's address, the HyperDHT keys it listens on and dials, and when and how\n * much it sends. Not the frames, not the keys' secrets, not the handshake hash.\n *\n * The wire is the Desktop's (native/transports/hyperdht/endpoint.mjs): the same preface, u32 length-prefixed\n * UTF-8 frames of at most 60 KiB, so a browser and a Desktop talk HyperDHT to each other.\n */\n\nconst PREFACE = \"ghostly/paired-chat/1\";\nconst MAX_FRAME = 60 * 1024;\nconst SEND_BUDGET = 120 * 1024;\nconst HANDSHAKE_MS = 20_000;\nconst RELAY_OPEN_MS = 10_000;\nconst LISTEN_MS = 20_000;\nconst MAX_CHANNELS = 2;\n/**\n * How the relay client is always made: never custodial. dht-relay's default is custodial, which sends every\n * secret key to the relay so it can run the handshake and the stream itself. Nothing here takes this from\n * settings or options; test/hyperdhtRelay.test.ts fails if a secret key ever reaches the relay's wire.\n */\nconst NON_CUSTODIAL = Object.freeze({ custodial: false as const });\n\n/**\n * The descriptor a browser's HyperDHT endpoint gives out: its key, that it is reached only through a relay, and\n * which one (the connection panel names its host; a Desktop dialling it ignores both).\n */\nexport interface RelayedHyperDescriptor { publicKey: string; relayed: true; relay: string }\n\n/** The parts of dht-relay and its streams this adapter uses. */\ninterface SecretSocket {\n handshakeHash: Uint8Array | null;\n publicKey: Uint8Array;\n remotePublicKey: Uint8Array;\n opened?: Promise<boolean>;\n destroyed?: boolean;\n write(data: Uint8Array): boolean;\n destroy(error?: Error): void;\n on(event: string, listener: (...args: never[]) => void): unknown;\n once(event: string, listener: (...args: never[]) => void): unknown;\n off(event: string, listener: (...args: never[]) => void): unknown;\n}\ninterface RelayedServer {\n listen(keyPair: KeyPair): Promise<void>;\n close(): Promise<void>;\n}\ninterface RelayedNode {\n ready(): Promise<void>;\n connect(remotePublicKey: Uint8Array, options: { keyPair: KeyPair }): SecretSocket;\n createServer(options: object, onconnection: (socket: SecretSocket) => void): RelayedServer;\n destroy(): Promise<void>;\n}\ninterface KeyPair { publicKey: Uint8Array; secretKey: Uint8Array }\n\nconst hex = (bytes: Uint8Array) => Array.from(bytes, b => b.toString(16).padStart(2, \"0\")).join(\"\");\nconst fromHex = (text: string) => Uint8Array.from(text.match(/../g)!, byte => parseInt(byte, 16));\n\n/** HyperDHT's key pair for a seed: libsodium's layout (the seed, then the public key). */\nexport function hyperKeyPair(seed: Uint8Array): KeyPair {\n if (seed.length !== 32) throw new Error(\"Invalid HyperDHT seed\");\n const publicKey = ed25519.getPublicKey(seed);\n const secretKey = new Uint8Array(64);\n secretKey.set(seed); secretKey.set(publicKey, 32);\n return { publicKey, secretKey };\n}\n\n/**\n * One WebSocket per relay for the whole app, shared by every chat's endpoint (each listens on its own\n * key). It closes when the last endpoint does. When the relay goes away, every endpoint on it says it is\n * unavailable, and the next one to start opens a new connection.\n */\ninterface RelayClient {\n node: RelayedNode;\n endpoints: Set<{ unavailable(): void }>;\n gone: boolean;\n /** Settles when the relay connection closes. */\n closed: Promise<void>;\n}\nconst clients = new Map<string, Promise<RelayClient>>();\n\nasync function relayClient(url: string, createSocket: (url: string) => WebSocket): Promise<RelayClient> {\n const existing = clients.get(url);\n if (existing) {\n const client = await existing.catch(() => null);\n if (client && !client.gone) return client;\n if (clients.get(url) === existing) clients.delete(url);\n }\n const opening = (async () => {\n const [{ default: RelayedDHT }, { default: WebSocketStream }] = await Promise.all([\n // @ts-expect-error dht-relay ships no types: RelayedNode and SecretSocket above describe what this uses.\n import(\"@hyperswarm/dht-relay\"),\n // @ts-expect-error The same package's WebSocket stream, untyped too.\n import(\"@hyperswarm/dht-relay/ws\"),\n ]);\n const socket = createSocket(url);\n socket.binaryType = \"arraybuffer\";\n await new Promise<void>((resolve, reject) => {\n const timer = setTimeout(() => { socket.close(); reject(new Error(\"The HyperDHT relay did not answer\")); }, RELAY_OPEN_MS);\n socket.addEventListener(\"open\", () => { clearTimeout(timer); resolve(); }, { once: true });\n socket.addEventListener(\"error\", () => { clearTimeout(timer); reject(new Error(\"Could not reach the HyperDHT relay\")); }, { once: true });\n socket.addEventListener(\"close\", () => { clearTimeout(timer); reject(new Error(\"The HyperDHT relay closed the connection\")); }, { once: true });\n });\n // Non-custodial: the relay is told public keys only, never a secret key (dht-relay's default sends them).\n // The node's own key is never used to listen or dial: a random one says nothing about this app.\n const node = new RelayedDHT(new WebSocketStream(true, socket), { ...NON_CUSTODIAL, keyPair: hyperKeyPair(crypto.getRandomValues(new Uint8Array(32))) }) as RelayedNode;\n let closed!: () => void;\n const client: RelayClient = { node, endpoints: new Set(), gone: false, closed: new Promise(resolve => { closed = resolve; }) };\n socket.addEventListener(\"close\", () => {\n client.gone = true; closed();\n if (clients.get(url) === opening) clients.delete(url);\n for (const endpoint of [...client.endpoints]) endpoint.unavailable();\n });\n return client;\n })();\n clients.set(url, opening);\n opening.catch(() => { if (clients.get(url) === opening) clients.delete(url); });\n return opening;\n}\n\nfunction release(url: string, client: RelayClient, endpoint: { unavailable(): void }): void {\n client.endpoints.delete(endpoint);\n if (client.endpoints.size || client.gone) return;\n client.gone = true;\n void clients.get(url)?.then(current => { if (current === client) clients.delete(url); }).catch(() => {});\n void client.node.destroy().catch(() => {});\n}\n\n/** One authenticated stream as a frame channel, with a bounded queue before the session installs its reader. */\nclass RelayedChannel implements FrameChannel {\n private reader: FrameChannel[\"onMessage\"] = null;\n private buffered: string[] = [];\n private closed = false;\n private pendingBytes = 0;\n onClose: FrameChannel[\"onClose\"] = null;\n constructor(private readonly socket: SecretSocket) {\n socket.on(\"drain\", () => { this.pendingBytes = 0; });\n }\n get bufferedAmount(): number { return this.pendingBytes; }\n readonly sendBudget = SEND_BUDGET;\n get onMessage() { return this.reader; }\n set onMessage(reader: FrameChannel[\"onMessage\"]) {\n this.reader = reader;\n if (reader) for (const text of this.buffered.splice(0)) reader(text);\n }\n receive(text: string): boolean {\n if (this.closed) return true;\n if (this.reader) this.reader(text);\n else if (this.buffered.length < 64) this.buffered.push(text);\n else return false;\n return true;\n }\n send(data: string | Uint8Array): void {\n if (typeof data !== \"string\" || this.closed || !data.length) throw new Error(\"Native channel is closed or exceeds its frame budget\");\n const payload = new TextEncoder().encode(data);\n if (payload.length > MAX_FRAME || this.pendingBytes + payload.length > SEND_BUDGET) throw new Error(\"Native channel is closed or exceeds its frame budget\");\n // The stream takes every write; past its high-water mark it says so until it drains.\n if (!writeFrame(this.socket, payload) || this.pendingBytes) this.pendingBytes += payload.length + 4;\n }\n drained(): Promise<void> {\n if (!this.pendingBytes) return Promise.resolve();\n return new Promise((resolve, reject) => {\n const done = () => { this.socket.off(\"close\", gone); resolve(); };\n const gone = () => { this.socket.off(\"drain\", done); reject(new Error(\"Native channel closed\")); };\n this.socket.once(\"drain\", done); this.socket.once(\"close\", gone);\n });\n }\n closedByPeer(): void {\n if (this.closed) return;\n this.closed = true; this.buffered = [];\n this.onClose?.();\n }\n close(): void {\n if (this.closed) return;\n this.socket.destroy();\n this.closedByPeer();\n }\n}\n\nfunction writeFrame(socket: SecretSocket, payload: Uint8Array): boolean {\n const frame = new Uint8Array(4 + payload.length);\n new DataView(frame.buffer).setUint32(0, payload.length);\n frame.set(payload, 4);\n return socket.write(frame);\n}\n\n/**\n * Waits for the peer's preface on an authenticated stream (sending ours as soon as the handshake is\n * done), then hands the channel over with the binding the stream itself gives. A frame of the wrong size,\n * bytes that are not UTF-8 or another protocol close the stream.\n */\nfunction attach(socket: SecretSocket, channels: Set<RelayedChannel>): Promise<BoundChannel> {\n if (channels.size >= MAX_CHANNELS) { socket.destroy(); return Promise.reject(new Error(\"Native connection limit reached\")); }\n const channel = new RelayedChannel(socket);\n channels.add(channel);\n return new Promise<BoundChannel>((resolve, reject) => {\n let buffer = new Uint8Array(0);\n let prefaced = false;\n const decoder = new TextDecoder(\"utf-8\", { fatal: true });\n const timer = setTimeout(() => socket.destroy(new Error(\"HyperDHT handshake timed out\")), HANDSHAKE_MS);\n const fail = (error: Error) => { socket.destroy(error); };\n socket.on(\"error\", (error: Error) => reject(error));\n socket.on(\"close\", () => {\n clearTimeout(timer); channels.delete(channel);\n reject(new Error(\"Native channel closed\"));\n channel.closedByPeer();\n });\n const opened = () => {\n if (socket.handshakeHash?.length !== 64 || socket.publicKey?.length !== 32 || socket.remotePublicKey?.length !== 32) {\n fail(new Error(\"Noise session binding unavailable\")); return;\n }\n writeFrame(socket, new TextEncoder().encode(PREFACE));\n };\n if (socket.opened) void socket.opened.then(ok => { if (ok) opened(); else reject(new Error(\"Noise handshake failed\")); });\n else socket.once(\"open\", opened);\n socket.on(\"data\", (chunk: Uint8Array) => {\n const joined = new Uint8Array(buffer.length + chunk.length);\n joined.set(buffer); joined.set(chunk, buffer.length);\n buffer = joined;\n while (buffer.length >= 4) {\n const length = new DataView(buffer.buffer, buffer.byteOffset, 4).getUint32(0);\n if (length === 0 || length > MAX_FRAME) { fail(new Error(\"Invalid frame length\")); return; }\n if (buffer.length < 4 + length) break;\n let text: string;\n try { text = decoder.decode(buffer.subarray(4, 4 + length)); }\n catch { fail(new Error(\"Invalid UTF-8 frame\")); return; }\n buffer = buffer.slice(4 + length);\n if (!prefaced) {\n if (text !== PREFACE) { fail(new Error(\"Unexpected application protocol\")); return; }\n prefaced = true; clearTimeout(timer);\n resolve({ channel, binding: { transport: \"hyperdht/1\", context: hex(socket.handshakeHash!),\n identities: [hex(socket.publicKey), hex(socket.remotePublicKey)].sort() as [string, string] } });\n } else if (!channel.receive(text)) { fail(new Error(\"Receive queue exceeded\")); return; }\n }\n });\n });\n}\n\nexport interface RelayedHyperOptions {\n /** How to open the WebSocket (tests pass Node's `ws`). Default: the browser's. */\n createSocket?: (url: string) => WebSocket;\n}\n\n/**\n * A chat's HyperDHT endpoint through the relay at `url`: it listens on the key of `seedB64` (the chat's\n * own transport seed, as on the Desktop) and dials a contact's descriptor. Fails, and so is not offered,\n * when the relay cannot be reached or does not let it listen.\n */\nexport async function createRelayedHyperEndpoint(seedB64: string, url: string, options: RelayedHyperOptions = {}): Promise<NativeEndpoint> {\n const problem = hyperdhtRelayProblem(url);\n if (problem) throw new Error(problem);\n const keyPair = hyperKeyPair(fromBase64Url(seedB64));\n const client = await relayClient(url, options.createSocket ?? (address => new WebSocket(address)));\n const channels = new Set<RelayedChannel>();\n let stopped = false;\n let handler: NativeEndpoint[\"onConnection\"] = null;\n const waiting: BoundChannel[] = [];\n let endpoint: NativeEndpoint | null = null;\n const member = {\n unavailable() {\n if (stopped) return;\n stopped = true;\n for (const channel of channels) channel.close();\n endpoint?.onUnavailable?.();\n },\n };\n client.endpoints.add(member);\n const server = client.node.createServer({}, socket => {\n void attach(socket, channels).then(bound => {\n if (stopped) bound.channel.close();\n else if (handler) handler(bound);\n else if (waiting.length < MAX_CHANNELS) waiting.push(bound);\n else bound.channel.close();\n }).catch(() => {});\n });\n try {\n await Promise.race([\n server.listen(keyPair),\n client.closed.then(() => { throw new Error(\"The HyperDHT relay closed the connection\"); }),\n new Promise((_, reject) => setTimeout(() => reject(new Error(\"The HyperDHT relay did not let this chat listen\")), LISTEN_MS)),\n ]);\n if (client.gone) throw new Error(\"The HyperDHT relay closed the connection\");\n } catch (error) {\n stopped = true;\n void server.close().catch(() => {});\n release(url, client, member);\n throw error;\n }\n const descriptor: RelayedHyperDescriptor = { publicKey: hex(keyPair.publicKey), relayed: true, relay: url };\n endpoint = {\n transport: \"hyperdht/1\", descriptor, onDescriptor: null, onUnavailable: null,\n get onConnection() { return handler; },\n set onConnection(value) { handler = value; if (value) for (const bound of waiting.splice(0)) value(bound); },\n async connect(address) {\n const publicKey = (address as { publicKey?: unknown } | null)?.publicKey;\n if (stopped || typeof publicKey !== \"string\" || !/^[a-f0-9]{64}$/.test(publicKey)) throw new Error(\"Invalid HyperDHT endpoint\");\n return attach(client.node.connect(fromHex(publicKey), { keyPair }), channels);\n },\n async close() {\n stopped = true;\n for (const channel of channels) channel.close();\n waiting.length = 0;\n await server.close().catch(() => {});\n release(url, client, member);\n },\n };\n return endpoint;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,IAAM,UAAU;AAChB,IAAM,YAAY;AAClB,IAAM,cAAc;AACpB,IAAM,eAAe;AACrB,IAAM,gBAAgB;AACtB,IAAM,YAAY;AAClB,IAAM,eAAe;;;;;;AAMrB,IAAM,gBAAgB,OAAO,OAAO,EAAE,WAAW,MAAe,CAAC;AAiCjE,IAAM,OAAO,UAAsB,MAAM,KAAK,QAAO,MAAK,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE;AAClG,IAAM,WAAW,SAAiB,WAAW,KAAK,KAAK,MAAM,KAAK,IAAI,SAAQ,SAAS,MAAM,EAAE,CAAC;;AAGhG,SAAgB,aAAa,MAA2B;CACtD,IAAI,KAAK,WAAW,IAAI,MAAM,IAAI,MAAM,uBAAuB;CAC/D,MAAM,YAAY,QAAQ,aAAa,IAAI;CAC3C,MAAM,4BAAY,IAAI,WAAW,EAAE;CACnC,UAAU,IAAI,IAAI;CAAG,UAAU,IAAI,WAAW,EAAE;CAChD,OAAO;EAAE;EAAW;CAAU;AAChC;AAcA,IAAM,0BAAU,IAAI,IAAkC;AAEtD,eAAe,YAAY,KAAa,cAAgE;CACtG,MAAM,WAAW,QAAQ,IAAI,GAAG;CAChC,IAAI,UAAU;EACZ,MAAM,SAAS,MAAM,SAAS,YAAY,IAAI;EAC9C,IAAI,UAAU,CAAC,OAAO,MAAM,OAAO;EACnC,IAAI,QAAQ,IAAI,GAAG,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GAC9C,QAAQ,SAAS;GACjB,MAAM,OAAO,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;GACnC,QAAQ,KAAK,QAAQ,MAAM;EAC7B;CACF;CACA,OAAO;AACT"}
1
+ {"version":3,"file":"hyperdhtRelay-BoxPHp7v.js","names":[],"sources":["../../../browser/src/platform/hyperdhtRelay.ts"],"sourcesContent":["import { ed25519 } from \"@noble/curves/ed25519.js\";\nimport { fromBase64Url, type BoundChannel, type FrameChannel, type NativeEndpoint } from \"@ghostly/core\";\nimport { hyperdhtRelayProblem } from \"../shared/hyperdhtRelay\";\n\nexport { hyperdhtRelayProblem as relayUrlProblem };\n\n/**\n * HyperDHT (WISP 103) for a browser, through a dht-relay: a server that runs the UDP half of HyperDHT and\n * talks to the browser over one WebSocket. It runs non-custodial: the browser keeps its keys, runs the\n * Noise handshake and the encrypted stream itself, and the relay moves handshake messages and ciphertext.\n * The binding (the handshake hash and both keys) is computed here, at the endpoint, as the Desktop does.\n *\n * What the relay sees: this browser's address, the HyperDHT keys it listens on and dials, and when and how\n * much it sends. Not the frames, not the keys' secrets, not the handshake hash.\n *\n * The wire is the Desktop's (native/transports/hyperdht/endpoint.mjs): the same preface, u32 length-prefixed\n * UTF-8 frames of at most 60 KiB, so a browser and a Desktop talk HyperDHT to each other.\n */\n\nconst PREFACE = \"ghostly/paired-chat/1\";\nconst MAX_FRAME = 60 * 1024;\nconst SEND_BUDGET = 120 * 1024;\nconst HANDSHAKE_MS = 20_000;\nconst RELAY_OPEN_MS = 10_000;\nconst LISTEN_MS = 20_000;\nconst MAX_CHANNELS = 2;\n/**\n * How the relay client is always made: never custodial. dht-relay's default is custodial, which sends every\n * secret key to the relay so it can run the handshake and the stream itself. Nothing here takes this from\n * settings or options; test/hyperdhtRelay.test.ts fails if a secret key ever reaches the relay's wire.\n */\nconst NON_CUSTODIAL = Object.freeze({ custodial: false as const });\n\n/**\n * The descriptor a browser's HyperDHT endpoint gives out: its key, that it is reached only through a relay, and\n * which one (the connection panel names its host; a Desktop dialling it ignores both).\n */\nexport interface RelayedHyperDescriptor { publicKey: string; relayed: true; relay: string }\n\n/** The parts of dht-relay and its streams this adapter uses. */\ninterface SecretSocket {\n handshakeHash: Uint8Array | null;\n publicKey: Uint8Array;\n remotePublicKey: Uint8Array;\n opened?: Promise<boolean>;\n destroyed?: boolean;\n write(data: Uint8Array): boolean;\n destroy(error?: Error): void;\n on(event: string, listener: (...args: never[]) => void): unknown;\n once(event: string, listener: (...args: never[]) => void): unknown;\n off(event: string, listener: (...args: never[]) => void): unknown;\n}\ninterface RelayedServer {\n listen(keyPair: KeyPair): Promise<void>;\n close(): Promise<void>;\n}\ninterface RelayedNode {\n ready(): Promise<void>;\n connect(remotePublicKey: Uint8Array, options: { keyPair: KeyPair }): SecretSocket;\n createServer(options: object, onconnection: (socket: SecretSocket) => void): RelayedServer;\n destroy(): Promise<void>;\n}\ninterface KeyPair { publicKey: Uint8Array; secretKey: Uint8Array }\n\nconst hex = (bytes: Uint8Array) => Array.from(bytes, b => b.toString(16).padStart(2, \"0\")).join(\"\");\nconst fromHex = (text: string) => Uint8Array.from(text.match(/../g)!, byte => parseInt(byte, 16));\n\n/** HyperDHT's key pair for a seed: libsodium's layout (the seed, then the public key). */\nexport function hyperKeyPair(seed: Uint8Array): KeyPair {\n if (seed.length !== 32) throw new Error(\"Invalid HyperDHT seed\");\n const publicKey = ed25519.getPublicKey(seed);\n const secretKey = new Uint8Array(64);\n secretKey.set(seed); secretKey.set(publicKey, 32);\n return { publicKey, secretKey };\n}\n\n/**\n * One WebSocket per relay for the whole app, shared by every chat's endpoint (each listens on its own\n * key). It closes when the last endpoint does. When the relay goes away, every endpoint on it says it is\n * unavailable, and the next one to start opens a new connection.\n */\ninterface RelayClient {\n node: RelayedNode;\n endpoints: Set<{ unavailable(): void }>;\n gone: boolean;\n /** Settles when the relay connection closes. */\n closed: Promise<void>;\n}\nconst clients = new Map<string, Promise<RelayClient>>();\n\nasync function relayClient(url: string, createSocket: (url: string) => WebSocket): Promise<RelayClient> {\n const existing = clients.get(url);\n if (existing) {\n const client = await existing.catch(() => null);\n if (client && !client.gone) return client;\n if (clients.get(url) === existing) clients.delete(url);\n }\n const opening = (async () => {\n const [{ default: RelayedDHT }, { default: WebSocketStream }] = await Promise.all([\n // @ts-expect-error dht-relay ships no types: RelayedNode and SecretSocket above describe what this uses.\n import(\"@hyperswarm/dht-relay\"),\n // @ts-expect-error The same package's WebSocket stream, untyped too.\n import(\"@hyperswarm/dht-relay/ws\"),\n ]);\n const socket = createSocket(url);\n socket.binaryType = \"arraybuffer\";\n await new Promise<void>((resolve, reject) => {\n const timer = setTimeout(() => { socket.close(); reject(new Error(\"The HyperDHT relay did not answer\")); }, RELAY_OPEN_MS);\n socket.addEventListener(\"open\", () => { clearTimeout(timer); resolve(); }, { once: true });\n socket.addEventListener(\"error\", () => { clearTimeout(timer); reject(new Error(\"Could not reach the HyperDHT relay\")); }, { once: true });\n socket.addEventListener(\"close\", () => { clearTimeout(timer); reject(new Error(\"The HyperDHT relay closed the connection\")); }, { once: true });\n });\n // Non-custodial: the relay is told public keys only, never a secret key (dht-relay's default sends them).\n // The node's own key is never used to listen or dial: a random one says nothing about this app.\n const node = new RelayedDHT(new WebSocketStream(true, socket), { ...NON_CUSTODIAL, keyPair: hyperKeyPair(crypto.getRandomValues(new Uint8Array(32))) }) as RelayedNode;\n let closed!: () => void;\n const client: RelayClient = { node, endpoints: new Set(), gone: false, closed: new Promise(resolve => { closed = resolve; }) };\n socket.addEventListener(\"close\", () => {\n client.gone = true; closed();\n if (clients.get(url) === opening) clients.delete(url);\n for (const endpoint of [...client.endpoints]) endpoint.unavailable();\n });\n return client;\n })();\n clients.set(url, opening);\n opening.catch(() => { if (clients.get(url) === opening) clients.delete(url); });\n return opening;\n}\n\nfunction release(url: string, client: RelayClient, endpoint: { unavailable(): void }): void {\n client.endpoints.delete(endpoint);\n if (client.endpoints.size || client.gone) return;\n client.gone = true;\n void clients.get(url)?.then(current => { if (current === client) clients.delete(url); }).catch(() => {});\n void client.node.destroy().catch(() => {});\n}\n\n/** One authenticated stream as a frame channel, with a bounded queue before the session installs its reader. */\nclass RelayedChannel implements FrameChannel {\n private reader: FrameChannel[\"onMessage\"] = null;\n private buffered: string[] = [];\n private closed = false;\n private pendingBytes = 0;\n onClose: FrameChannel[\"onClose\"] = null;\n constructor(private readonly socket: SecretSocket) {\n socket.on(\"drain\", () => { this.pendingBytes = 0; });\n }\n get bufferedAmount(): number { return this.pendingBytes; }\n readonly sendBudget = SEND_BUDGET;\n get onMessage() { return this.reader; }\n set onMessage(reader: FrameChannel[\"onMessage\"]) {\n this.reader = reader;\n if (reader) for (const text of this.buffered.splice(0)) reader(text);\n }\n receive(text: string): boolean {\n if (this.closed) return true;\n if (this.reader) this.reader(text);\n else if (this.buffered.length < 64) this.buffered.push(text);\n else return false;\n return true;\n }\n send(data: string | Uint8Array): void {\n if (typeof data !== \"string\" || this.closed || !data.length) throw new Error(\"Native channel is closed or exceeds its frame budget\");\n const payload = new TextEncoder().encode(data);\n if (payload.length > MAX_FRAME || this.pendingBytes + payload.length > SEND_BUDGET) throw new Error(\"Native channel is closed or exceeds its frame budget\");\n // The stream takes every write; past its high-water mark it says so until it drains.\n if (!writeFrame(this.socket, payload) || this.pendingBytes) this.pendingBytes += payload.length + 4;\n }\n drained(): Promise<void> {\n if (!this.pendingBytes) return Promise.resolve();\n return new Promise((resolve, reject) => {\n const done = () => { this.socket.off(\"close\", gone); resolve(); };\n const gone = () => { this.socket.off(\"drain\", done); reject(new Error(\"Native channel closed\")); };\n this.socket.once(\"drain\", done); this.socket.once(\"close\", gone);\n });\n }\n closedByPeer(): void {\n if (this.closed) return;\n this.closed = true; this.buffered = [];\n this.onClose?.();\n }\n close(): void {\n if (this.closed) return;\n this.socket.destroy();\n this.closedByPeer();\n }\n}\n\nfunction writeFrame(socket: SecretSocket, payload: Uint8Array): boolean {\n const frame = new Uint8Array(4 + payload.length);\n new DataView(frame.buffer).setUint32(0, payload.length);\n frame.set(payload, 4);\n return socket.write(frame);\n}\n\n/**\n * Waits for the peer's preface on an authenticated stream (sending ours as soon as the handshake is\n * done), then hands the channel over with the binding the stream itself gives. A frame of the wrong size,\n * bytes that are not UTF-8 or another protocol close the stream.\n */\nfunction attach(socket: SecretSocket, channels: Set<RelayedChannel>): Promise<BoundChannel> {\n if (channels.size >= MAX_CHANNELS) { socket.destroy(); return Promise.reject(new Error(\"Native connection limit reached\")); }\n const channel = new RelayedChannel(socket);\n channels.add(channel);\n return new Promise<BoundChannel>((resolve, reject) => {\n let buffer = new Uint8Array(0);\n let prefaced = false;\n const decoder = new TextDecoder(\"utf-8\", { fatal: true });\n const timer = setTimeout(() => socket.destroy(new Error(\"HyperDHT handshake timed out\")), HANDSHAKE_MS);\n const fail = (error: Error) => { socket.destroy(error); };\n socket.on(\"error\", (error: Error) => reject(error));\n socket.on(\"close\", () => {\n clearTimeout(timer); channels.delete(channel);\n reject(new Error(\"Native channel closed\"));\n channel.closedByPeer();\n });\n const opened = () => {\n if (socket.handshakeHash?.length !== 64 || socket.publicKey?.length !== 32 || socket.remotePublicKey?.length !== 32) {\n fail(new Error(\"Noise session binding unavailable\")); return;\n }\n writeFrame(socket, new TextEncoder().encode(PREFACE));\n };\n if (socket.opened) void socket.opened.then(ok => { if (ok) opened(); else reject(new Error(\"Noise handshake failed\")); });\n else socket.once(\"open\", opened);\n socket.on(\"data\", (chunk: Uint8Array) => {\n const joined = new Uint8Array(buffer.length + chunk.length);\n joined.set(buffer); joined.set(chunk, buffer.length);\n buffer = joined;\n while (buffer.length >= 4) {\n const length = new DataView(buffer.buffer, buffer.byteOffset, 4).getUint32(0);\n if (length === 0 || length > MAX_FRAME) { fail(new Error(\"Invalid frame length\")); return; }\n if (buffer.length < 4 + length) break;\n let text: string;\n try { text = decoder.decode(buffer.subarray(4, 4 + length)); }\n catch { fail(new Error(\"Invalid UTF-8 frame\")); return; }\n buffer = buffer.slice(4 + length);\n if (!prefaced) {\n if (text !== PREFACE) { fail(new Error(\"Unexpected application protocol\")); return; }\n prefaced = true; clearTimeout(timer);\n resolve({ channel, binding: { transport: \"hyperdht/1\", context: hex(socket.handshakeHash!),\n identities: [hex(socket.publicKey), hex(socket.remotePublicKey)].sort() as [string, string] } });\n } else if (!channel.receive(text)) { fail(new Error(\"Receive queue exceeded\")); return; }\n }\n });\n });\n}\n\nexport interface RelayedHyperOptions {\n /** How to open the WebSocket (tests pass Node's `ws`). Default: the browser's. */\n createSocket?: (url: string) => WebSocket;\n}\n\n/**\n * A chat's HyperDHT endpoint through the relay at `url`: it listens on the key of `seedB64` (the chat's\n * own transport seed, as on the Desktop) and dials a contact's descriptor. Fails, and so is not offered,\n * when the relay cannot be reached or does not let it listen.\n */\nexport async function createRelayedHyperEndpoint(seedB64: string, url: string, options: RelayedHyperOptions = {}): Promise<NativeEndpoint> {\n const problem = hyperdhtRelayProblem(url);\n if (problem) throw new Error(problem);\n const keyPair = hyperKeyPair(fromBase64Url(seedB64));\n const client = await relayClient(url, options.createSocket ?? (address => new WebSocket(address)));\n const channels = new Set<RelayedChannel>();\n let stopped = false;\n let handler: NativeEndpoint[\"onConnection\"] = null;\n const waiting: BoundChannel[] = [];\n let endpoint: NativeEndpoint | null = null;\n const member = {\n unavailable() {\n if (stopped) return;\n stopped = true;\n for (const channel of channels) channel.close();\n endpoint?.onUnavailable?.();\n },\n };\n client.endpoints.add(member);\n const server = client.node.createServer({}, socket => {\n void attach(socket, channels).then(bound => {\n if (stopped) bound.channel.close();\n else if (handler) handler(bound);\n else if (waiting.length < MAX_CHANNELS) waiting.push(bound);\n else bound.channel.close();\n }).catch(() => {});\n });\n try {\n await Promise.race([\n server.listen(keyPair),\n client.closed.then(() => { throw new Error(\"The HyperDHT relay closed the connection\"); }),\n new Promise((_, reject) => setTimeout(() => reject(new Error(\"The HyperDHT relay did not let this chat listen\")), LISTEN_MS)),\n ]);\n if (client.gone) throw new Error(\"The HyperDHT relay closed the connection\");\n } catch (error) {\n stopped = true;\n void server.close().catch(() => {});\n release(url, client, member);\n throw error;\n }\n const descriptor: RelayedHyperDescriptor = { publicKey: hex(keyPair.publicKey), relayed: true, relay: url };\n endpoint = {\n transport: \"hyperdht/1\", descriptor, onDescriptor: null, onUnavailable: null,\n get onConnection() { return handler; },\n set onConnection(value) { handler = value; if (value) for (const bound of waiting.splice(0)) value(bound); },\n async connect(address) {\n const publicKey = (address as { publicKey?: unknown } | null)?.publicKey;\n if (stopped || typeof publicKey !== \"string\" || !/^[a-f0-9]{64}$/.test(publicKey)) throw new Error(\"Invalid HyperDHT endpoint\");\n return attach(client.node.connect(fromHex(publicKey), { keyPair }), channels);\n },\n async close() {\n stopped = true;\n for (const channel of channels) channel.close();\n waiting.length = 0;\n await server.close().catch(() => {});\n release(url, client, member);\n },\n };\n return endpoint;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAmBA,IAAM,UAAU;AAChB,IAAM,YAAY;AAClB,IAAM,cAAc;AACpB,IAAM,eAAe;AACrB,IAAM,gBAAgB;AACtB,IAAM,YAAY;AAClB,IAAM,eAAe;;;;;;AAMrB,IAAM,gBAAgB,OAAO,OAAO,EAAE,WAAW,MAAe,CAAC;AAiCjE,IAAM,OAAO,UAAsB,MAAM,KAAK,QAAO,MAAK,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE;AAClG,IAAM,WAAW,SAAiB,WAAW,KAAK,KAAK,MAAM,KAAK,IAAI,SAAQ,SAAS,MAAM,EAAE,CAAC;;AAGhG,SAAgB,aAAa,MAA2B;CACtD,IAAI,KAAK,WAAW,IAAI,MAAM,IAAI,MAAM,uBAAuB;CAC/D,MAAM,YAAY,QAAQ,aAAa,IAAI;CAC3C,MAAM,4BAAY,IAAI,WAAW,EAAE;CACnC,UAAU,IAAI,IAAI;CAAG,UAAU,IAAI,WAAW,EAAE;CAChD,OAAO;EAAE;EAAW;CAAU;AAChC;AAcA,IAAM,0BAAU,IAAI,IAAkC;AAE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