@arcjet/redact-wasm 1.0.0-beta.9 → 1.0.0

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