@arcjet/redact-wasm 1.0.0-beta.1 → 1.0.0-beta.10

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 CHANGED
@@ -18,74 +18,43 @@
18
18
 
19
19
  [Arcjet][arcjet] sensitive information redaction detection engine.
20
20
 
21
- ## Installation
21
+ - [npm package (`@arcjet/redact-wasm`)](https://www.npmjs.com/package/@arcjet/redact-wasm)
22
+ - [GitHub source code (`redact-wasm/` in `arcjet/arcjet-js`)](https://github.com/arcjet/arcjet-js/tree/main/redact-wasm)
22
23
 
23
- ```shell
24
- npm install -S @arcjet/redact-wasm
25
- ```
24
+ ## What is this?
26
25
 
27
- ## Example
28
-
29
- ```ts
30
- import { initializeWasm } from "@arcjet/redact-wasm";
31
- import type { SensitiveInfoEntity } from "@arcjet/redact-wasm";
32
-
33
- function noOpDetect(_tokens: string[]): Array<SensitiveInfoEntity | undefined> {
34
- return [];
35
- }
36
- function noOpReplace(_input: SensitiveInfoEntity): string | undefined {
37
- return undefined;
38
- }
39
-
40
- const wasm = await initializeWasm(noOpDetect, noOpReplace);
41
-
42
- // If WebAssembly isn't available in the environment then it will be undefined.
43
- if (typeof wasm !== "undefined") {
44
- const config = {
45
- entities: [],
46
- contextWindowSize: 1,
47
- skipCustomDetect: true,
48
- skipCustomRedact: true,
49
- };
50
-
51
- const entities = wasm.redact("I am a string", config);
52
- // Do something with entities that should be redacted.
53
- } else {
54
- throw new Error(
55
- "redact failed to run because Wasm is not supported in this environment",
56
- );
57
- }
58
- ```
26
+ This package provides logic in WebAssembly to locally redact sensitive info.
27
+ The files here are generated.
28
+ They are wrapped up into [`@arcjet/redact`][github-arcjet-redact] for use in
29
+ JavaScript.
30
+ For more info on why we maintain our WebAssembly and JavaScript projects like
31
+ this,
32
+ see [“What is this?” in the readme of
33
+ `@arcjet/analyze-wasm`][github-arcjet-analyze-wasm-what].
59
34
 
60
- ## Implementation
35
+ ## When should I use this?
61
36
 
62
- This package provides sensitive information identification and redaction logic implemented as a
63
- WebAssembly module which will run local analysis on the provided string.
37
+ You should not use this but use [`@arcjet/redact`][github-arcjet-redact] instead.
64
38
 
65
- The generated `_virtual/arcjet_analyze_bindings_redact.component.js` file contains the binary inlined as
66
- a base64 [Data URL][mdn-data-url] with the `application/wasm` MIME type.
39
+ ## Install
67
40
 
68
- This was chosen to save on storage space over inlining the file directly as a
69
- Uint8Array, which would take up ~3x the space of the Wasm file. See
70
- [Better Binary Batter: Mixing Base64 and Uint8Array][wasm-base64-blog] for more
71
- details.
41
+ This package is ESM only.
42
+ Install with npm in Node.js:
72
43
 
73
- It is then decoded into an ArrayBuffer to be used directly via WebAssembly's
74
- `compile()` function in our entry point file.
44
+ ```sh
45
+ npm install @arcjet/redact-wasm
46
+ ```
75
47
 
76
- This is all done to avoid trying to read or bundle the Wasm asset in various
77
- ways based on the platform or bundler a user is targeting. One example being
78
- that Next.js requires special `asyncWebAssembly` webpack config to load our
79
- Wasm file if we don't do this.
48
+ ## Use
80
49
 
81
- In the future, we hope to do away with this workaround when all bundlers
82
- properly support consistent asset bundling techniques.
50
+ Use [`@arcjet/redact`][file-redact] instead.
83
51
 
84
52
  ## License
85
53
 
86
- Licensed under the [Apache License, Version 2.0][apache-license].
54
+ [Apache License, Version 2.0][apache-license] © [Arcjet Labs, Inc.][arcjet]
87
55
 
88
- [arcjet]: https://arcjet.com
89
- [mdn-data-url]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs
90
- [wasm-base64-blog]: https://blobfolio.com/2019/better-binary-batter-mixing-base64-and-uint8array/
91
56
  [apache-license]: http://www.apache.org/licenses/LICENSE-2.0
57
+ [arcjet]: https://arcjet.com
58
+ [file-redact]: ../redact/
59
+ [github-arcjet-analyze-wasm-what]: https://github.com/arcjet/arcjet-js/tree/main/analyze-wasm#what-is-this
60
+ [github-arcjet-redact]: https://github.com/arcjet/arcjet-js/tree/main/redact