@ouro.bot/cli 0.1.0-alpha.1146 → 0.1.0-alpha.1148
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/changelog.json +12 -0
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/dist/heart/daemon/cli-defaults.js +16 -25
- package/dist/heart/versioning/release-sources.js +15 -3
- package/node_modules/@ouro.bot/friends/LICENSE +201 -0
- package/node_modules/@ouro.bot/friends/README.md +674 -0
- package/node_modules/@ouro.bot/friends/changelog.json +125 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/a2a-message.d.ts +39 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/a2a-message.js +54 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/adapter.d.ts +117 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/adapter.js +202 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/agent-card.d.ts +50 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/agent-card.js +32 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/did-key.d.ts +38 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/did-key.js +120 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/did-verifier.d.ts +195 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/did-verifier.js +342 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/did-web.d.ts +26 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/did-web.js +140 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/envelope-binding.d.ts +62 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/envelope-binding.js +79 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/index.d.ts +26 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/index.js +82 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/jcs.d.ts +5 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/jcs.js +84 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/reachability.d.ts +22 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/reachability.js +17 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/roster-verify.d.ts +15 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/roster-verify.js +61 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/seal.d.ts +47 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/seal.js +95 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/sealed-envelope.d.ts +58 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/sealed-envelope.js +113 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/sign.d.ts +42 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/sign.js +87 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/sodium.d.ts +5 -0
- package/node_modules/@ouro.bot/friends/dist/a2a-client/sodium.js +19 -0
- package/node_modules/@ouro.bot/friends/dist/account-roster.d.ts +52 -0
- package/node_modules/@ouro.bot/friends/dist/account-roster.js +108 -0
- package/node_modules/@ouro.bot/friends/dist/agent-peer.d.ts +26 -0
- package/node_modules/@ouro.bot/friends/dist/agent-peer.js +138 -0
- package/node_modules/@ouro.bot/friends/dist/audit.d.ts +42 -0
- package/node_modules/@ouro.bot/friends/dist/audit.js +86 -0
- package/node_modules/@ouro.bot/friends/dist/channel.d.ts +11 -0
- package/node_modules/@ouro.bot/friends/dist/channel.js +161 -0
- package/node_modules/@ouro.bot/friends/dist/connect-authority.d.ts +43 -0
- package/node_modules/@ouro.bot/friends/dist/connect-authority.js +84 -0
- package/node_modules/@ouro.bot/friends/dist/connect.d.ts +56 -0
- package/node_modules/@ouro.bot/friends/dist/connect.js +163 -0
- package/node_modules/@ouro.bot/friends/dist/consent.d.ts +34 -0
- package/node_modules/@ouro.bot/friends/dist/consent.js +65 -0
- package/node_modules/@ouro.bot/friends/dist/coordination.d.ts +116 -0
- package/node_modules/@ouro.bot/friends/dist/coordination.js +329 -0
- package/node_modules/@ouro.bot/friends/dist/delegation-grant.d.ts +21 -0
- package/node_modules/@ouro.bot/friends/dist/delegation-grant.js +39 -0
- package/node_modules/@ouro.bot/friends/dist/file-bundle.d.ts +17 -0
- package/node_modules/@ouro.bot/friends/dist/file-bundle.js +27 -0
- package/node_modules/@ouro.bot/friends/dist/friend-lookup.d.ts +9 -0
- package/node_modules/@ouro.bot/friends/dist/friend-lookup.js +69 -0
- package/node_modules/@ouro.bot/friends/dist/grant-store-file.d.ts +16 -0
- package/node_modules/@ouro.bot/friends/dist/grant-store-file.js +136 -0
- package/node_modules/@ouro.bot/friends/dist/grant-store.d.ts +7 -0
- package/node_modules/@ouro.bot/friends/dist/grant-store.js +8 -0
- package/node_modules/@ouro.bot/friends/dist/grants.d.ts +39 -0
- package/node_modules/@ouro.bot/friends/dist/grants.js +84 -0
- package/node_modules/@ouro.bot/friends/dist/group-context.d.ts +21 -0
- package/node_modules/@ouro.bot/friends/dist/group-context.js +145 -0
- package/node_modules/@ouro.bot/friends/dist/identity.d.ts +17 -0
- package/node_modules/@ouro.bot/friends/dist/identity.js +68 -0
- package/node_modules/@ouro.bot/friends/dist/index.d.ts +73 -0
- package/node_modules/@ouro.bot/friends/dist/index.js +161 -0
- package/node_modules/@ouro.bot/friends/dist/link-identity.d.ts +14 -0
- package/node_modules/@ouro.bot/friends/dist/link-identity.js +157 -0
- package/node_modules/@ouro.bot/friends/dist/mailbox/index.d.ts +105 -0
- package/node_modules/@ouro.bot/friends/dist/mailbox/index.js +205 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/bin.d.ts +2 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/bin.js +16 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/dispatch.d.ts +40 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/dispatch.js +549 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/index.d.ts +6 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/index.js +14 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/run-main.d.ts +7 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/run-main.js +48 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/schemas.d.ts +10 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/schemas.js +445 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/server.d.ts +30 -0
- package/node_modules/@ouro.bot/friends/dist/mcp/server.js +194 -0
- package/node_modules/@ouro.bot/friends/dist/message.d.ts +75 -0
- package/node_modules/@ouro.bot/friends/dist/message.js +99 -0
- package/node_modules/@ouro.bot/friends/dist/mission-result.d.ts +82 -0
- package/node_modules/@ouro.bot/friends/dist/mission-result.js +200 -0
- package/node_modules/@ouro.bot/friends/dist/mission-share.d.ts +94 -0
- package/node_modules/@ouro.bot/friends/dist/mission-share.js +232 -0
- package/node_modules/@ouro.bot/friends/dist/mission-store-file.d.ts +18 -0
- package/node_modules/@ouro.bot/friends/dist/mission-store-file.js +161 -0
- package/node_modules/@ouro.bot/friends/dist/mission-store.d.ts +10 -0
- package/node_modules/@ouro.bot/friends/dist/mission-store.js +9 -0
- package/node_modules/@ouro.bot/friends/dist/missions.d.ts +31 -0
- package/node_modules/@ouro.bot/friends/dist/missions.js +98 -0
- package/node_modules/@ouro.bot/friends/dist/notes.d.ts +11 -0
- package/node_modules/@ouro.bot/friends/dist/notes.js +90 -0
- package/node_modules/@ouro.bot/friends/dist/observability.d.ts +27 -0
- package/node_modules/@ouro.bot/friends/dist/observability.js +31 -0
- package/node_modules/@ouro.bot/friends/dist/outcomes.d.ts +9 -0
- package/node_modules/@ouro.bot/friends/dist/outcomes.js +51 -0
- package/node_modules/@ouro.bot/friends/dist/resolver.d.ts +59 -0
- package/node_modules/@ouro.bot/friends/dist/resolver.js +276 -0
- package/node_modules/@ouro.bot/friends/dist/results.d.ts +10 -0
- package/node_modules/@ouro.bot/friends/dist/results.js +2 -0
- package/node_modules/@ouro.bot/friends/dist/room.d.ts +22 -0
- package/node_modules/@ouro.bot/friends/dist/room.js +40 -0
- package/node_modules/@ouro.bot/friends/dist/roster-store-file.d.ts +16 -0
- package/node_modules/@ouro.bot/friends/dist/roster-store-file.js +125 -0
- package/node_modules/@ouro.bot/friends/dist/roster-store-memory.d.ts +9 -0
- package/node_modules/@ouro.bot/friends/dist/roster-store-memory.js +20 -0
- package/node_modules/@ouro.bot/friends/dist/roster-store.d.ts +29 -0
- package/node_modules/@ouro.bot/friends/dist/roster-store.js +9 -0
- package/node_modules/@ouro.bot/friends/dist/roster-verifier.d.ts +23 -0
- package/node_modules/@ouro.bot/friends/dist/roster-verifier.js +47 -0
- package/node_modules/@ouro.bot/friends/dist/share.d.ts +108 -0
- package/node_modules/@ouro.bot/friends/dist/share.js +278 -0
- package/node_modules/@ouro.bot/friends/dist/standing.d.ts +83 -0
- package/node_modules/@ouro.bot/friends/dist/standing.js +111 -0
- package/node_modules/@ouro.bot/friends/dist/store-file.d.ts +82 -0
- package/node_modules/@ouro.bot/friends/dist/store-file.js +1074 -0
- package/node_modules/@ouro.bot/friends/dist/store.d.ts +43 -0
- package/node_modules/@ouro.bot/friends/dist/store.js +4 -0
- package/node_modules/@ouro.bot/friends/dist/tokens.d.ts +8 -0
- package/node_modules/@ouro.bot/friends/dist/tokens.js +26 -0
- package/node_modules/@ouro.bot/friends/dist/trust-explanation.d.ts +22 -0
- package/node_modules/@ouro.bot/friends/dist/trust-explanation.js +90 -0
- package/node_modules/@ouro.bot/friends/dist/trust-mutation.d.ts +16 -0
- package/node_modules/@ouro.bot/friends/dist/trust-mutation.js +67 -0
- package/node_modules/@ouro.bot/friends/dist/types.d.ts +321 -0
- package/node_modules/@ouro.bot/friends/dist/types.js +55 -0
- package/node_modules/@ouro.bot/friends/dist/util/cap-string.d.ts +7 -0
- package/node_modules/@ouro.bot/friends/dist/util/cap-string.js +35 -0
- package/node_modules/@ouro.bot/friends/dist/verifier.d.ts +11 -0
- package/node_modules/@ouro.bot/friends/dist/verifier.js +29 -0
- package/node_modules/@ouro.bot/friends/dist/whoami.d.ts +7 -0
- package/node_modules/@ouro.bot/friends/dist/whoami.js +39 -0
- package/node_modules/@ouro.bot/friends/package.json +81 -0
- package/node_modules/libsodium/LICENSE +16 -0
- package/node_modules/libsodium/README.md +281 -0
- package/node_modules/libsodium/dist/modules/libsodium.js +1 -0
- package/node_modules/libsodium/dist/modules-esm/libsodium.mjs +1 -0
- package/node_modules/libsodium/package.json +54 -0
- package/node_modules/libsodium-wrappers/LICENSE +16 -0
- package/node_modules/libsodium-wrappers/README.md +281 -0
- package/node_modules/libsodium-wrappers/dist/modules/libsodium-wrappers.d.ts +2155 -0
- package/node_modules/libsodium-wrappers/dist/modules/libsodium-wrappers.js +1 -0
- package/node_modules/libsodium-wrappers/dist/modules-esm/libsodium-wrappers.d.mts +2743 -0
- package/node_modules/libsodium-wrappers/dist/modules-esm/libsodium-wrappers.mjs +1 -0
- package/node_modules/libsodium-wrappers/package.json +74 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +4 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "libsodium",
|
|
3
|
+
"version": "0.8.4",
|
|
4
|
+
"description": "The Sodium cryptographic library compiled to pure JavaScript (raw library, no wrappers)",
|
|
5
|
+
"main": "dist/modules/libsodium.js",
|
|
6
|
+
"module": "dist/modules-esm/libsodium.mjs",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/modules-esm/libsodium.mjs",
|
|
10
|
+
"require": "./dist/modules/libsodium.js",
|
|
11
|
+
"default": "./dist/modules/libsodium.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"files": [
|
|
16
|
+
"dist/modules/libsodium.js",
|
|
17
|
+
"dist/modules-esm/libsodium.mjs",
|
|
18
|
+
"package.json"
|
|
19
|
+
],
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/jedisct1/libsodium.js.git"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"crypto",
|
|
26
|
+
"sodium",
|
|
27
|
+
"libsodium",
|
|
28
|
+
"nacl",
|
|
29
|
+
"chacha20",
|
|
30
|
+
"poly1305",
|
|
31
|
+
"curve25519",
|
|
32
|
+
"ed25519",
|
|
33
|
+
"blake2",
|
|
34
|
+
"siphash",
|
|
35
|
+
"argon2",
|
|
36
|
+
"ecc"
|
|
37
|
+
],
|
|
38
|
+
"author": "Ahmad Ben Mrad (@BatikhSouri)",
|
|
39
|
+
"contributors": [
|
|
40
|
+
"Frank Denis (@jedisct1)",
|
|
41
|
+
"Ryan Lester (@buu700)"
|
|
42
|
+
],
|
|
43
|
+
"license": "ISC",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/jedisct1/libsodium.js/issues"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://github.com/jedisct1/libsodium.js",
|
|
48
|
+
"browser": {
|
|
49
|
+
"fs": false,
|
|
50
|
+
"path": false,
|
|
51
|
+
"stream": false,
|
|
52
|
+
"crypto": false
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Copyright (c) 2015-2026
|
|
2
|
+
Ahmad Ben Mrad <batikhsouri at gmail dot org>
|
|
3
|
+
Frank Denis <j at pureftpd dot org>
|
|
4
|
+
Ryan Lester <ryan at cyph dot com>
|
|
5
|
+
|
|
6
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
7
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
8
|
+
copyright notice and this permission notice appear in all copies.
|
|
9
|
+
|
|
10
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
11
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
12
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
13
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
14
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
15
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
16
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
# libsodium.js
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The [sodium](https://github.com/jedisct1/libsodium) crypto library
|
|
6
|
+
compiled to WebAssembly and pure JavaScript using
|
|
7
|
+
[Emscripten](https://github.com/emscripten-core/emscripten), with
|
|
8
|
+
automatically generated wrappers to make it easy to use in web
|
|
9
|
+
applications.
|
|
10
|
+
|
|
11
|
+
The standard version weighs about 290 KB and the sumo version about 375 KB
|
|
12
|
+
(minified, gzipped, includes pure JS + WebAssembly versions). Both can run in
|
|
13
|
+
a web browser as well as server-side.
|
|
14
|
+
|
|
15
|
+
### Compatibility
|
|
16
|
+
|
|
17
|
+
Supported browsers/JS engines:
|
|
18
|
+
|
|
19
|
+
* Chrome >= 16
|
|
20
|
+
* Edge >= 0.11
|
|
21
|
+
* Firefox >= 21
|
|
22
|
+
* Mobile Safari on iOS >= 8.0 (older versions produce incorrect results)
|
|
23
|
+
* NodeJS
|
|
24
|
+
* Bun
|
|
25
|
+
* Opera >= 15
|
|
26
|
+
* Safari >= 6 (older versions produce incorrect results)
|
|
27
|
+
|
|
28
|
+
This is comparable to the WebCrypto API, which is compatible with a
|
|
29
|
+
similar number of browsers.
|
|
30
|
+
|
|
31
|
+
Signatures and other Edwards25519-based operations are compatible with
|
|
32
|
+
[WasmCrypto](https://github.com/jedisct1/wasm-crypto).
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
The [dist](https://github.com/jedisct1/libsodium.js/tree/master/dist)
|
|
37
|
+
directory contains pre-built scripts. Copy the files from one of its
|
|
38
|
+
subdirectories to your application:
|
|
39
|
+
|
|
40
|
+
- [browsers](https://github.com/jedisct1/libsodium.js/tree/master/dist/browsers)
|
|
41
|
+
includes a single-file script that can be included in web pages.
|
|
42
|
+
It contains code for commonly used functions.
|
|
43
|
+
- [browsers-sumo](https://github.com/jedisct1/libsodium.js/tree/master/dist/browsers-sumo)
|
|
44
|
+
is a superset of the previous script, that contains all functions,
|
|
45
|
+
including rarely used ones and undocumented ones.
|
|
46
|
+
- [modules](https://github.com/jedisct1/libsodium.js/tree/master/dist/modules)
|
|
47
|
+
includes commonly used functions, and is designed to be loaded as a CommonJS module.
|
|
48
|
+
`libsodium-wrappers` is the module your application should load, which
|
|
49
|
+
will in turn automatically load `libsodium` as a dependency.
|
|
50
|
+
- [modules-sumo](https://github.com/jedisct1/libsodium.js/tree/master/dist/modules-sumo)
|
|
51
|
+
contains sumo variants of the previous modules.
|
|
52
|
+
- [modules-esm](https://github.com/jedisct1/libsodium.js/tree/master/dist/modules-esm)
|
|
53
|
+
contains ESM (ES modules) versions with `.mjs` extensions.
|
|
54
|
+
- [modules-sumo-esm](https://github.com/jedisct1/libsodium.js/tree/master/dist/modules-sumo-esm)
|
|
55
|
+
contains sumo ESM variants.
|
|
56
|
+
|
|
57
|
+
The modules are also available on npm:
|
|
58
|
+
- [libsodium-wrappers](https://www.npmjs.com/package/libsodium-wrappers)
|
|
59
|
+
- [libsodium-wrappers-sumo](https://www.npmjs.com/package/libsodium-wrappers-sumo)
|
|
60
|
+
|
|
61
|
+
### Usage (as a module)
|
|
62
|
+
|
|
63
|
+
Load the `libsodium-wrappers` module. The returned object contains a `.ready`
|
|
64
|
+
property: a promise that must be resolved before the sodium functions
|
|
65
|
+
can be used.
|
|
66
|
+
|
|
67
|
+
Example:
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
import sodium from 'libsodium-wrappers';
|
|
71
|
+
|
|
72
|
+
await sodium.ready;
|
|
73
|
+
|
|
74
|
+
let key = sodium.crypto_secretstream_xchacha20poly1305_keygen();
|
|
75
|
+
|
|
76
|
+
let { state: state_out, header } =
|
|
77
|
+
sodium.crypto_secretstream_xchacha20poly1305_init_push(key);
|
|
78
|
+
let c1 = sodium.crypto_secretstream_xchacha20poly1305_push(state_out,
|
|
79
|
+
sodium.from_string('message 1'), null,
|
|
80
|
+
sodium.crypto_secretstream_xchacha20poly1305_TAG_MESSAGE);
|
|
81
|
+
let c2 = sodium.crypto_secretstream_xchacha20poly1305_push(state_out,
|
|
82
|
+
sodium.from_string('message 2'), null,
|
|
83
|
+
sodium.crypto_secretstream_xchacha20poly1305_TAG_FINAL);
|
|
84
|
+
|
|
85
|
+
let state_in = sodium.crypto_secretstream_xchacha20poly1305_init_pull(header, key);
|
|
86
|
+
let r1 = sodium.crypto_secretstream_xchacha20poly1305_pull(state_in, c1);
|
|
87
|
+
let { message: m1_bytes, tag: tag1 } = r1;
|
|
88
|
+
let m1 = sodium.to_string(m1_bytes);
|
|
89
|
+
let r2 = sodium.crypto_secretstream_xchacha20poly1305_pull(state_in, c2);
|
|
90
|
+
let { message: m2_bytes, tag: tag2 } = r2;
|
|
91
|
+
let m2 = sodium.to_string(m2_bytes);
|
|
92
|
+
|
|
93
|
+
console.log(m1);
|
|
94
|
+
console.log(m2);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Named exports:** The ESM modules also provide named exports for helper functions:
|
|
98
|
+
|
|
99
|
+
```js
|
|
100
|
+
import { ready, from_hex, to_hex, from_string, to_string } from 'libsodium-wrappers';
|
|
101
|
+
|
|
102
|
+
await ready;
|
|
103
|
+
const bytes = from_hex('deadbeef');
|
|
104
|
+
console.log(to_hex(bytes));
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Note:** Cryptographic functions (like `crypto_secretbox_easy`) and constants (like `crypto_secretbox_KEYBYTES`) are dynamically added to the module at runtime after `ready` resolves. They cannot be imported as named exports and must be accessed via the default export:
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
import sodium from 'libsodium-wrappers';
|
|
111
|
+
|
|
112
|
+
await sodium.ready;
|
|
113
|
+
// Now crypto functions and constants are available on the sodium object
|
|
114
|
+
const key = sodium.crypto_secretbox_keygen();
|
|
115
|
+
const nonce = sodium.randombytes_buf(sodium.crypto_secretbox_NONCEBYTES);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Usage (in a web browser, via a callback)
|
|
119
|
+
|
|
120
|
+
The `sodium.js` file includes both the core libsodium functions, as
|
|
121
|
+
well as the higher-level JavaScript wrappers. It can be loaded
|
|
122
|
+
asynchronously.
|
|
123
|
+
|
|
124
|
+
A `sodium` object should be defined in the global namespace, with the
|
|
125
|
+
following property:
|
|
126
|
+
|
|
127
|
+
- `onload`: the function to call after the wrapper is initialized.
|
|
128
|
+
|
|
129
|
+
Example:
|
|
130
|
+
|
|
131
|
+
```html
|
|
132
|
+
<script>
|
|
133
|
+
window.sodium = {
|
|
134
|
+
onload: function (sodium) {
|
|
135
|
+
let h = sodium.crypto_generichash(64, sodium.from_string('test'));
|
|
136
|
+
console.log(sodium.to_hex(h));
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
</script>
|
|
140
|
+
<script src="sodium.js" async></script>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
**Important:** If you inline the library directly into your HTML (rather than loading it from a separate file), make sure your page declares UTF-8 encoding:
|
|
144
|
+
|
|
145
|
+
```html
|
|
146
|
+
<meta charset="utf-8">
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Without this, browsers may corrupt the embedded WebAssembly binary data during HTML parsing, leading to errors like "failed to match magic number" or "HEAPU8 is undefined". Also ensure your server sends the `charset=utf-8` header.
|
|
150
|
+
|
|
151
|
+
## Additional helpers
|
|
152
|
+
|
|
153
|
+
* `from_base64()`, `to_base64()` with an optional second parameter
|
|
154
|
+
whose value is one of: `base64_variants.ORIGINAL`, `base64_variants.ORIGINAL_NO_PADDING`,
|
|
155
|
+
`base64_variants.URLSAFE` or `base64_variants.URLSAFE_NO_PADDING`. Default is `base64_variants.URLSAFE_NO_PADDING`.
|
|
156
|
+
* `from_hex()`, `to_hex()`
|
|
157
|
+
* `from_string()`, `to_string()`
|
|
158
|
+
* `pad(<buffer>, <block size>)`, `unpad(<buffer>, <block size>)`
|
|
159
|
+
* `memcmp()` (constant-time check for equality, returns `true` or `false`)
|
|
160
|
+
* `compare()` (constant-time comparison. Values must have the same
|
|
161
|
+
size. Returns `-1`, `0` or `1`)
|
|
162
|
+
* `memzero()` (applies to `Uint8Array` objects)
|
|
163
|
+
* `increment()` (increments an arbitrary-long number stored as a
|
|
164
|
+
little-endian `Uint8Array` - typically to increment nonces)
|
|
165
|
+
* `add()` (adds two arbitrary-long numbers stored as little-endian
|
|
166
|
+
`Uint8Array` vectors)
|
|
167
|
+
* `is_zero()` (constant-time, checks `Uint8Array` objects for all zeros)
|
|
168
|
+
|
|
169
|
+
## API
|
|
170
|
+
|
|
171
|
+
The API exposed by the wrappers is identical to the one of the C
|
|
172
|
+
library, except that buffer lengths never need to be explicitly given.
|
|
173
|
+
|
|
174
|
+
Binary input buffers should be `Uint8Array` objects. However, if a string
|
|
175
|
+
is given instead, the wrappers will automatically convert the string
|
|
176
|
+
to an array containing a UTF-8 representation of the string.
|
|
177
|
+
|
|
178
|
+
Example:
|
|
179
|
+
|
|
180
|
+
```javascript
|
|
181
|
+
var key = sodium.randombytes_buf(sodium.crypto_shorthash_KEYBYTES),
|
|
182
|
+
hash1 = sodium.crypto_shorthash(new Uint8Array([1, 2, 3, 4]), key),
|
|
183
|
+
hash2 = sodium.crypto_shorthash('test', key);
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
If the output is a unique binary buffer, it is returned as a
|
|
187
|
+
`Uint8Array` object.
|
|
188
|
+
|
|
189
|
+
Example (secretbox):
|
|
190
|
+
|
|
191
|
+
```javascript
|
|
192
|
+
let key = sodium.from_hex('724b092810ec86d7e35c9d067702b31ef90bc43a7b598626749914d6a3e033ed');
|
|
193
|
+
|
|
194
|
+
function encrypt_and_prepend_nonce(message) {
|
|
195
|
+
let nonce = sodium.randombytes_buf(sodium.crypto_secretbox_NONCEBYTES);
|
|
196
|
+
let ciphertext = sodium.crypto_secretbox_easy(message, nonce, key);
|
|
197
|
+
let result = new Uint8Array(nonce.length + ciphertext.length);
|
|
198
|
+
result.set(nonce);
|
|
199
|
+
result.set(ciphertext, nonce.length);
|
|
200
|
+
return result;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function decrypt_after_extracting_nonce(nonce_and_ciphertext) {
|
|
204
|
+
if (nonce_and_ciphertext.length < sodium.crypto_secretbox_NONCEBYTES + sodium.crypto_secretbox_MACBYTES) {
|
|
205
|
+
throw "Short message";
|
|
206
|
+
}
|
|
207
|
+
let nonce = nonce_and_ciphertext.slice(0, sodium.crypto_secretbox_NONCEBYTES),
|
|
208
|
+
ciphertext = nonce_and_ciphertext.slice(sodium.crypto_secretbox_NONCEBYTES);
|
|
209
|
+
return sodium.crypto_secretbox_open_easy(ciphertext, nonce, key);
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
In addition, the `from_hex`, `to_hex`, `from_string`, and `to_string`
|
|
214
|
+
functions are available to explicitly convert hexadecimal, and
|
|
215
|
+
arbitrary string representations from/to `Uint8Array` objects.
|
|
216
|
+
|
|
217
|
+
Functions returning more than one output buffer are returning them as
|
|
218
|
+
an object. For example, the `sodium.crypto_box_keypair()` function
|
|
219
|
+
returns the following object:
|
|
220
|
+
```javascript
|
|
221
|
+
{ publicKey: (Uint8Array), privateKey: (Uint8Array), keyType: 'x25519' }
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
This also applies to newer APIs such as:
|
|
225
|
+
```javascript
|
|
226
|
+
{ state: (StateAddress), header: (Uint8Array) }
|
|
227
|
+
{ ciphertext: (Uint8Array), sharedSecret: (Uint8Array) }
|
|
228
|
+
```
|
|
229
|
+
for `crypto_secretstream_xchacha20poly1305_init_push()` and `crypto_kem_enc()`.
|
|
230
|
+
|
|
231
|
+
### Standard vs Sumo version
|
|
232
|
+
|
|
233
|
+
The standard version (in the `dist/browsers`, `dist/modules`, and
|
|
234
|
+
`dist/modules-esm` directories) contains the high-level functions, and
|
|
235
|
+
is the recommended one for most projects.
|
|
236
|
+
|
|
237
|
+
Alternatively, the "sumo" version, available in the
|
|
238
|
+
`dist/browsers-sumo`, `dist/modules-sumo`, and `dist/modules-sumo-esm`
|
|
239
|
+
directories contains all the symbols from the original library. This includes undocumented,
|
|
240
|
+
untested, deprecated, low-level and easy to misuse functions.
|
|
241
|
+
|
|
242
|
+
The `crypto_pwhash_*` function set is only included in the sumo version.
|
|
243
|
+
|
|
244
|
+
The sumo version is slightly larger than the standard version, reserves
|
|
245
|
+
more memory, and should be used only if you really need the extra symbols
|
|
246
|
+
it provides.
|
|
247
|
+
|
|
248
|
+
### Compilation
|
|
249
|
+
|
|
250
|
+
If you want to compile the files yourself, the following dependencies
|
|
251
|
+
need to be installed on your system:
|
|
252
|
+
|
|
253
|
+
* Emscripten
|
|
254
|
+
* binaryen
|
|
255
|
+
* git
|
|
256
|
+
* bun
|
|
257
|
+
* make
|
|
258
|
+
|
|
259
|
+
Running `make` will install the dev dependencies if needed, build the
|
|
260
|
+
standard and sumo distributions, regenerate API docs and TypeScript
|
|
261
|
+
bindings, pack the generated outputs, and rebuild the browser test
|
|
262
|
+
artifacts.
|
|
263
|
+
|
|
264
|
+
### Benchmarks
|
|
265
|
+
|
|
266
|
+
Run `make benchmark` to measure the performance of the cryptographic functions.
|
|
267
|
+
You can also run specific benchmarks with `bun benchmark/index.ts --only <name>`
|
|
268
|
+
(use `--list` to see available benchmarks).
|
|
269
|
+
|
|
270
|
+
## Related projects
|
|
271
|
+
|
|
272
|
+
* [react-native-libsodium](https://github.com/serenity-kit/react-native-libsodium): React Native bindings to Libsodium matching the libsodium-wrappers package API
|
|
273
|
+
|
|
274
|
+
## Authors
|
|
275
|
+
|
|
276
|
+
Built by Ahmad Ben Mrad, Frank Denis and Ryan Lester.
|
|
277
|
+
|
|
278
|
+
## License
|
|
279
|
+
|
|
280
|
+
This wrapper is distributed under the
|
|
281
|
+
[ISC License](https://en.wikipedia.org/wiki/ISC_license).
|