@whi/argon2-wasm 0.5.0 → 0.5.1
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/README.md +24 -5
- package/argon2_wasm_workerd.js +9 -0
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -51,16 +51,27 @@ verify(
|
|
|
51
51
|
// returns true
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
###
|
|
54
|
+
### Cloudflare Workers
|
|
55
55
|
|
|
56
56
|
```js
|
|
57
57
|
import { argon2, verify, HashType } from '@whi/argon2-wasm';
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
Works as-is in a Worker bundled by Wrangler: the package's `exports` map has a
|
|
61
|
+
`workerd` condition pointing at a Workers-specific entry, so no manual wasm
|
|
62
|
+
instantiation is needed. This is tested on every build (`tests/e2e`) by installing
|
|
63
|
+
the packed package into a fixture Worker, bundling it with Wrangler, and running it
|
|
64
|
+
in workerd.
|
|
65
|
+
|
|
66
|
+
### Bundlers and Node (ESM)
|
|
67
|
+
|
|
68
|
+
```js
|
|
69
|
+
import { argon2, verify, HashType } from '@whi/argon2-wasm';
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Outside Workers, `import` resolves to wasm-pack's bundler build, which imports the
|
|
73
|
+
wasm as an ES module. In Node that relies on Node's experimental wasm-module
|
|
74
|
+
support (Node prints an `ExperimentalWarning`); use `require` to avoid it.
|
|
64
75
|
|
|
65
76
|
## API
|
|
66
77
|
|
|
@@ -87,6 +98,14 @@ make test # build the package and run the test suite
|
|
|
87
98
|
make pkg # build the publishable package into ./pkg
|
|
88
99
|
```
|
|
89
100
|
|
|
101
|
+
`make test` runs two layers, which can also be run on their own against an
|
|
102
|
+
existing build:
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
npm run test:integration # the built ./pkg in Node, incl. the reference vectors
|
|
106
|
+
npm run test:e2e # the packed tarball in a Wrangler-bundled Worker (workerd)
|
|
107
|
+
```
|
|
108
|
+
|
|
90
109
|
### Crypto invariant — read before changing the hashing dependency or parameters
|
|
91
110
|
|
|
92
111
|
The output bytes of `argon2()` are a frozen contract. Stored credentials are
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* @ts-self-types="./argon2_wasm.d.ts" */
|
|
2
|
+
import wasmModule from "./argon2_wasm_bg.wasm";
|
|
3
|
+
import * as bg from "./argon2_wasm_bg.js";
|
|
4
|
+
|
|
5
|
+
const instance = new WebAssembly.Instance(wasmModule, { "./argon2_wasm_bg.js": bg });
|
|
6
|
+
bg.__wbg_set_wasm(instance.exports);
|
|
7
|
+
instance.exports.__wbindgen_start();
|
|
8
|
+
|
|
9
|
+
export { HashType, argon2, verify } from "./argon2_wasm_bg.js";
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"matthew@webheroes.ca"
|
|
6
6
|
],
|
|
7
7
|
"description": "Argon2 wasm bindings with all inputs exposed",
|
|
8
|
-
"version": "0.5.
|
|
8
|
+
"version": "0.5.1",
|
|
9
9
|
"license": "ISC",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -16,18 +16,21 @@
|
|
|
16
16
|
"argon2_wasm.js",
|
|
17
17
|
"argon2_wasm_bg.js",
|
|
18
18
|
"argon2_wasm.d.ts",
|
|
19
|
-
"argon2_wasm_node.cjs"
|
|
19
|
+
"argon2_wasm_node.cjs",
|
|
20
|
+
"argon2_wasm_workerd.js"
|
|
20
21
|
],
|
|
21
22
|
"main": "argon2_wasm_node.cjs",
|
|
22
23
|
"types": "argon2_wasm.d.ts",
|
|
23
24
|
"sideEffects": [
|
|
24
25
|
"./argon2_wasm.js",
|
|
25
|
-
"./snippets/*"
|
|
26
|
+
"./snippets/*",
|
|
27
|
+
"./argon2_wasm_workerd.js"
|
|
26
28
|
],
|
|
27
29
|
"module": "argon2_wasm.js",
|
|
28
30
|
"exports": {
|
|
29
31
|
".": {
|
|
30
32
|
"types": "./argon2_wasm.d.ts",
|
|
33
|
+
"workerd": "./argon2_wasm_workerd.js",
|
|
31
34
|
"import": "./argon2_wasm.js",
|
|
32
35
|
"require": "./argon2_wasm_node.cjs"
|
|
33
36
|
}
|