@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 +24 -58
- package/_virtual/arcjet_analyze_bindings_redact.component.core.js +1 -1
- package/_virtual/arcjet_analyze_bindings_redact.component.core2.js +1 -1
- package/_virtual/arcjet_analyze_bindings_redact.component.core3.js +1 -1
- package/index.d.ts +29 -2
- package/index.js +13 -0
- package/package.json +11 -10
- package/wasm/arcjet_analyze_bindings_redact.component.core.wasm +0 -0
- package/wasm/arcjet_analyze_bindings_redact.component.core2.wasm +0 -0
- package/wasm/arcjet_analyze_bindings_redact.component.core3.wasm +0 -0
- package/wasm/arcjet_analyze_bindings_redact.component.wasm +0 -0
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
|
-
##
|
|
24
|
+
## What is this?
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
##
|
|
35
|
+
## When should I use this?
|
|
64
36
|
|
|
65
|
-
|
|
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
|
-
|
|
69
|
-
a base64 [Data URL][mdn-data-url] with the `application/wasm` MIME type.
|
|
39
|
+
## Install
|
|
70
40
|
|
|
71
|
-
This
|
|
72
|
-
|
|
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
|
-
|
|
77
|
-
|
|
44
|
+
```sh
|
|
45
|
+
npm install @arcjet/redact-wasm
|
|
46
|
+
```
|
|
78
47
|
|
|
79
|
-
|
|
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
|
-
|
|
85
|
-
properly support consistent asset bundling techniques.
|
|
50
|
+
Use [`@arcjet/redact`][file-redact] instead.
|
|
86
51
|
|
|
87
52
|
## License
|
|
88
53
|
|
|
89
|
-
|
|
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
|