libsodium 0.7.15 → 0.7.16

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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015-2023
1
+ Copyright (c) 2015-2026
2
2
  Ahmad Ben Mrad <batikhsouri at gmail dot org>
3
3
  Frank Denis <j at pureftpd dot org>
4
4
  Ryan Lester <ryan at cyph dot com>
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  The [sodium](https://github.com/jedisct1/libsodium) crypto library
6
6
  compiled to WebAssembly and pure JavaScript using
7
- [Emscripten](https://github.com/kripken/emscripten), with
7
+ [Emscripten](https://github.com/emscripten-core/emscripten), with
8
8
  automatically generated wrappers to make it easy to use in web
9
9
  applications.
10
10
 
@@ -43,11 +43,15 @@ It contains code for commonly used functions.
43
43
  is a superset of the previous script, that contains all functions,
44
44
  including rarely used ones and undocumented ones.
45
45
  - [modules](https://github.com/jedisct1/libsodium.js/tree/master/dist/modules)
46
- includes commonly used functions, and is designed to be loaded as a module.
46
+ includes commonly used functions, and is designed to be loaded as a CommonJS module.
47
47
  `libsodium-wrappers` is the module your application should load, which
48
48
  will in turn automatically load `libsodium` as a dependency.
49
49
  - [modules-sumo](https://github.com/jedisct1/libsodium.js/tree/master/dist/modules-sumo)
50
50
  contains sumo variants of the previous modules.
51
+ - [modules-esm](https://github.com/jedisct1/libsodium.js/tree/master/dist/modules-esm)
52
+ contains ESM (ES modules) versions with `.mjs` extensions.
53
+ - [modules-sumo-esm](https://github.com/jedisct1/libsodium.js/tree/master/dist/modules-sumo-esm)
54
+ contains sumo ESM variants.
51
55
 
52
56
  The modules are also available on npm:
53
57
  - [libsodium-wrappers](https://www.npmjs.com/package/libsodium-wrappers)
@@ -93,7 +97,7 @@ await (async() => {
93
97
 
94
98
  The `sodium.js` file includes both the core libsodium functions, as
95
99
  well as the higher-level JavaScript wrappers. It can be loaded
96
- asynchronusly.
100
+ asynchronously.
97
101
 
98
102
  A `sodium` object should be defined in the global namespace, with the
99
103
  following property:
@@ -159,7 +163,11 @@ let key = sodium.from_hex('724b092810ec86d7e35c9d067702b31ef90bc43a7b59862674991
159
163
 
160
164
  function encrypt_and_prepend_nonce(message) {
161
165
  let nonce = sodium.randombytes_buf(sodium.crypto_secretbox_NONCEBYTES);
162
- return nonce.concat(sodium.crypto_secretbox_easy(message, nonce, key));
166
+ let ciphertext = sodium.crypto_secretbox_easy(message, nonce, key);
167
+ let result = new Uint8Array(nonce.length + ciphertext.length);
168
+ result.set(nonce);
169
+ result.set(ciphertext, nonce.length);
170
+ return result;
163
171
  }
164
172
 
165
173
  function decrypt_after_extracting_nonce(nonce_and_ciphertext) {
@@ -185,13 +193,13 @@ returns the following object:
185
193
 
186
194
  ### Standard vs Sumo version
187
195
 
188
- The standard version (in the `dist/browsers` and `dist/modules`
189
- directories) contains the high-level functions, and is the recommended
190
- one for most projects.
196
+ The standard version (in the `dist/browsers`, `dist/modules`, and
197
+ `dist/modules-esm` directories) contains the high-level functions, and
198
+ is the recommended one for most projects.
191
199
 
192
200
  Alternatively, the "sumo" version, available in the
193
- `dist/browsers-sumo` and `dist/modules-sumo` directories contains all
194
- the symbols from the original library. This includes undocumented,
201
+ `dist/browsers-sumo`, `dist/modules-sumo`, and `dist/modules-sumo-esm`
202
+ directories contains all the symbols from the original library. This includes undocumented,
195
203
  untested, deprecated, low-level and easy to misuse functions.
196
204
 
197
205
  The `crypto_pwhash_*` function set is only included in the sumo version.