@arcjet/redact-wasm 1.7.0 → 1.8.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.
Files changed (29) hide show
  1. package/{_virtual → dist/_virtual/_./wasm}/arcjet_analyze_bindings_redact.component.core.js +7 -37
  2. package/dist/_virtual/_./wasm/arcjet_analyze_bindings_redact.component.core2.js +12 -0
  3. package/dist/_virtual/_./wasm/arcjet_analyze_bindings_redact.component.core3.js +12 -0
  4. package/dist/edge-light.d.ts +9 -0
  5. package/dist/edge-light.js +24 -0
  6. package/dist/index.d.ts +37 -0
  7. package/dist/index.js +37 -0
  8. package/dist/wasm/arcjet_analyze_bindings_redact.component.d.ts +45 -0
  9. package/dist/wasm/arcjet_analyze_bindings_redact.component.js +273 -0
  10. package/dist/wasm/interfaces/arcjet-redact-custom-redact.d.ts +24 -0
  11. package/dist/wasm.d.ts +52 -0
  12. package/dist/workerd.d.ts +9 -0
  13. package/dist/workerd.js +24 -0
  14. package/package.json +41 -40
  15. package/_virtual/arcjet_analyze_bindings_redact.component.core2.js +0 -42
  16. package/_virtual/arcjet_analyze_bindings_redact.component.core3.js +0 -42
  17. package/edge-light.d.ts +0 -6
  18. package/edge-light.js +0 -34
  19. package/index.d.ts +0 -33
  20. package/index.js +0 -50
  21. package/wasm/arcjet_analyze_bindings_redact.component.d.ts +0 -53
  22. package/wasm/arcjet_analyze_bindings_redact.component.js +0 -334
  23. package/wasm/arcjet_analyze_bindings_redact.component.wasm +0 -0
  24. package/wasm/interfaces/arcjet-redact-custom-redact.d.ts +0 -21
  25. package/workerd.d.ts +0 -6
  26. package/workerd.js +0 -34
  27. /package/{wasm → dist/wasm}/arcjet_analyze_bindings_redact.component.core.wasm +0 -0
  28. /package/{wasm → dist/wasm}/arcjet_analyze_bindings_redact.component.core2.wasm +0 -0
  29. /package/{wasm → dist/wasm}/arcjet_analyze_bindings_redact.component.core3.wasm +0 -0
package/package.json CHANGED
@@ -1,72 +1,73 @@
1
1
  {
2
2
  "name": "@arcjet/redact-wasm",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "description": "Arcjet sensitive information redaction detection engine",
5
5
  "keywords": [
6
6
  "arcjet",
7
7
  "redact",
8
- "utility",
9
8
  "util",
9
+ "utility",
10
10
  "wasm"
11
11
  ],
12
- "license": "Apache-2.0",
13
12
  "homepage": "https://arcjet.com",
14
- "repository": {
15
- "type": "git",
16
- "url": "git+https://github.com/arcjet/arcjet-js.git",
17
- "directory": "redact-wasm"
18
- },
19
13
  "bugs": {
20
14
  "url": "https://github.com/arcjet/arcjet-js/issues",
21
15
  "email": "support@arcjet.com"
22
16
  },
17
+ "license": "Apache-2.0",
23
18
  "author": {
24
19
  "name": "Arcjet",
25
20
  "email": "support@arcjet.com",
26
21
  "url": "https://arcjet.com"
27
22
  },
28
- "engines": {
29
- "node": ">=22.21.0 <23 || >=24.5.0"
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/arcjet/arcjet-js.git",
26
+ "directory": "redact-wasm"
30
27
  },
28
+ "files": [
29
+ "dist"
30
+ ],
31
31
  "type": "module",
32
- "main": "./index.js",
33
- "types": "./index.d.ts",
32
+ "main": "./dist/index.js",
33
+ "types": "./dist/index.d.ts",
34
34
  "exports": {
35
- "edge-light": "./edge-light.js",
36
- "workerd": "./workerd.js",
37
- "default": "./index.js"
35
+ ".": {
36
+ "edge-light": {
37
+ "types": "./dist/edge-light.d.ts",
38
+ "default": "./dist/edge-light.js"
39
+ },
40
+ "workerd": {
41
+ "types": "./dist/workerd.d.ts",
42
+ "default": "./dist/workerd.js"
43
+ },
44
+ "default": {
45
+ "types": "./dist/index.d.ts",
46
+ "default": "./dist/index.js"
47
+ }
48
+ },
49
+ "./package.json": "./package.json"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public",
53
+ "tag": "latest"
38
54
  },
39
- "files": [
40
- "_virtual/",
41
- "wasm/",
42
- "edge-light.d.ts",
43
- "edge-light.js",
44
- "index.d.ts",
45
- "index.js",
46
- "workerd.d.ts",
47
- "workerd.js"
48
- ],
49
55
  "scripts": {
50
- "build:jco": "jco transpile --instantiation async --no-wasi-shim --out-dir wasm/ -- wasm/arcjet_analyze_bindings_redact.component.wasm",
51
- "build:rollup": "rollup --config rollup.config.js",
52
- "build": "npm run build:jco && npm run build:rollup",
53
- "lint": "eslint .",
54
- "test-api": "node --test -- test/*.test.js",
55
- "test-coverage": "node --experimental-test-coverage --test -- test/*.test.js",
56
- "test": "npm run build && npm run lint && npm run test-coverage"
56
+ "build:jco": "jco transpile --instantiation async --no-wasi-shim --out-dir src/wasm/ -- src/wasm/arcjet_analyze_bindings_redact.component.wasm",
57
+ "build": "npm run build:jco && tsdown",
58
+ "typecheck": "tsgo --noEmit",
59
+ "test-api": "node --test -- test/*.test.ts",
60
+ "test-coverage": "node --experimental-test-coverage --test -- test/*.test.ts",
61
+ "test": "npm run build && npm run test-coverage"
57
62
  },
58
63
  "dependencies": {},
59
64
  "devDependencies": {
60
- "@arcjet/eslint-config": "1.7.0",
61
- "@arcjet/rollup-config": "1.7.0",
62
65
  "@bytecodealliance/jco": "1.5.0",
63
- "@rollup/wasm-node": "4.62.2",
64
66
  "@types/node": "22.19.21",
65
- "eslint": "9.39.4",
66
- "typescript": "5.9.3"
67
+ "tsdown": "0.22.3",
68
+ "typescript": "6.0.3"
67
69
  },
68
- "publishConfig": {
69
- "access": "public",
70
- "tag": "latest"
70
+ "engines": {
71
+ "node": ">=22.21.0 <23 || >=24.5.0"
71
72
  }
72
73
  }
@@ -1,42 +0,0 @@
1
- // @generated by wasm2module - DO NOT EDIT
2
- /* eslint-disable */
3
- // @ts-nocheck
4
-
5
- /**
6
- * This file contains an Arcjet Wasm binary inlined as a base64
7
- * [Data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs)
8
- * with the application/wasm MIME type.
9
- *
10
- * This was chosen to save on storage space over inlining the file directly as
11
- * a Uint8Array, which would take up ~3x the space of the Wasm file. See
12
- * https://blobfolio.com/2019/better-binary-batter-mixing-base64-and-uint8array/
13
- * for more details.
14
- *
15
- * It is then decoded into an ArrayBuffer to be used directly via WebAssembly's
16
- * `compile()` function in our entry point file.
17
- *
18
- * This is all done to avoid trying to read or bundle the Wasm asset in various
19
- * ways based on the platform or bundler a user is targeting. One example being
20
- * that Next.js requires special `asyncWebAssembly` webpack config to load our
21
- * Wasm file if we don't do this.
22
- *
23
- * In the future, we hope to do away with this workaround when all bundlers
24
- * properly support consistent asset bundling techniques.
25
- */
26
-
27
- const wasmBase64 = "data:application/wasm;base64,AGFzbQEAAAABEAJgA39/fwBgBn9/f39/fwADAwIAAQQFAXABAgIHFAMBMAAAATEAAQgkaW1wb3J0cwEACiMCDQAgACABIAJBABEAAAsTACAAIAEgAiADIAQgBUEBEQEACwAvCXByb2R1Y2VycwEMcHJvY2Vzc2VkLWJ5AQ13aXQtY29tcG9uZW50BzAuMjQ0LjA=";
28
- /**
29
- * Returns a WebAssembly.Module for an Arcjet Wasm binary, decoded from a base64
30
- * Data URL.
31
- */
32
- // TODO: Switch back to top-level await when our platforms all support it
33
- async function wasm() {
34
- // This uses fetch to decode the wasm data url, but disabling cache so files
35
- // larger than 2mb don't fail to parse in the Next.js App Router
36
- const wasmDecode = await fetch(wasmBase64, { cache: "no-store" });
37
- const buf = await wasmDecode.arrayBuffer();
38
- // And then we return it as a WebAssembly.Module
39
- return WebAssembly.compile(buf);
40
- }
41
-
42
- export { wasm };
@@ -1,42 +0,0 @@
1
- // @generated by wasm2module - DO NOT EDIT
2
- /* eslint-disable */
3
- // @ts-nocheck
4
-
5
- /**
6
- * This file contains an Arcjet Wasm binary inlined as a base64
7
- * [Data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs)
8
- * with the application/wasm MIME type.
9
- *
10
- * This was chosen to save on storage space over inlining the file directly as
11
- * a Uint8Array, which would take up ~3x the space of the Wasm file. See
12
- * https://blobfolio.com/2019/better-binary-batter-mixing-base64-and-uint8array/
13
- * for more details.
14
- *
15
- * It is then decoded into an ArrayBuffer to be used directly via WebAssembly's
16
- * `compile()` function in our entry point file.
17
- *
18
- * This is all done to avoid trying to read or bundle the Wasm asset in various
19
- * ways based on the platform or bundler a user is targeting. One example being
20
- * that Next.js requires special `asyncWebAssembly` webpack config to load our
21
- * Wasm file if we don't do this.
22
- *
23
- * In the future, we hope to do away with this workaround when all bundlers
24
- * properly support consistent asset bundling techniques.
25
- */
26
-
27
- const wasmBase64 = "data:application/wasm;base64,AGFzbQEAAAABEAJgA39/fwBgBn9/f39/fwACGgMAATAAAAABMQABAAgkaW1wb3J0cwFwAQICCQgBAEEACwIAAQAvCXByb2R1Y2VycwEMcHJvY2Vzc2VkLWJ5AQ13aXQtY29tcG9uZW50BzAuMjQ0LjA=";
28
- /**
29
- * Returns a WebAssembly.Module for an Arcjet Wasm binary, decoded from a base64
30
- * Data URL.
31
- */
32
- // TODO: Switch back to top-level await when our platforms all support it
33
- async function wasm() {
34
- // This uses fetch to decode the wasm data url, but disabling cache so files
35
- // larger than 2mb don't fail to parse in the Next.js App Router
36
- const wasmDecode = await fetch(wasmBase64, { cache: "no-store" });
37
- const buf = await wasmDecode.arrayBuffer();
38
- // And then we return it as a WebAssembly.Module
39
- return WebAssembly.compile(buf);
40
- }
41
-
42
- export { wasm };
package/edge-light.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import type { RedactedSensitiveInfoEntity, RedactSensitiveInfoConfig, SensitiveInfoEntity } from "./wasm/arcjet_analyze_bindings_redact.component.js";
2
- import type { ArcjetRedactCustomRedact } from "./wasm/interfaces/arcjet-redact-custom-redact.js";
3
- export declare function initializeWasm(detect: CustomDetect, replace: CustomRedact): Promise<import("./wasm/arcjet_analyze_bindings_redact.component.js").Root | undefined>;
4
- type CustomDetect = typeof ArcjetRedactCustomRedact.detectSensitiveInfo;
5
- type CustomRedact = typeof ArcjetRedactCustomRedact.redactSensitiveInfo;
6
- export { type CustomDetect, type CustomRedact, type RedactedSensitiveInfoEntity, type RedactSensitiveInfoConfig, type SensitiveInfoEntity, };
package/edge-light.js DELETED
@@ -1,34 +0,0 @@
1
- import { instantiate } from './wasm/arcjet_analyze_bindings_redact.component.js';
2
- import componentCoreWasm from './wasm/arcjet_analyze_bindings_redact.component.core.wasm?module';
3
- import componentCore2Wasm from './wasm/arcjet_analyze_bindings_redact.component.core2.wasm?module';
4
- import componentCore3Wasm from './wasm/arcjet_analyze_bindings_redact.component.core3.wasm?module';
5
-
6
- async function moduleFromPath(path) {
7
- if (path === "arcjet_analyze_bindings_redact.component.core.wasm") {
8
- return componentCoreWasm;
9
- }
10
- if (path === "arcjet_analyze_bindings_redact.component.core2.wasm") {
11
- return componentCore2Wasm;
12
- }
13
- if (path === "arcjet_analyze_bindings_redact.component.core3.wasm") {
14
- return componentCore3Wasm;
15
- }
16
- throw new Error(`Unknown path: ${path}`);
17
- }
18
- async function initializeWasm(detect, replace) {
19
- const coreImports = {
20
- "arcjet:redact/custom-redact": {
21
- detectSensitiveInfo: detect,
22
- redactSensitiveInfo: replace,
23
- },
24
- };
25
- try {
26
- // Await the instantiation to catch the failure
27
- return await instantiate(moduleFromPath, coreImports);
28
- }
29
- catch {
30
- console.debug("WebAssembly is not supported in this runtime");
31
- }
32
- }
33
-
34
- export { initializeWasm };
package/index.d.ts DELETED
@@ -1,33 +0,0 @@
1
- import type { ArcjetRedactCustomRedact } from "./wasm/interfaces/arcjet-redact-custom-redact.js";
2
- /**
3
- * Initialize the WebAssembly.
4
- *
5
- * @param detect
6
- * Custom detection function.
7
- * @param replace
8
- * Custom replacement function.
9
- * @returns
10
- * Promise to the initialized WebAssembly instance.
11
- */
12
- export declare function initializeWasm(detect: CustomDetect, replace: CustomRedact): Promise<import("./wasm/arcjet_analyze_bindings_redact.component.js").Root | undefined>;
13
- /**
14
- * Detect sensitive info.
15
- *
16
- * @param tokens
17
- * Tokens to detect in.
18
- * @returns
19
- * Array of detected entities.
20
- */
21
- type CustomDetect = typeof ArcjetRedactCustomRedact.detectSensitiveInfo;
22
- /**
23
- * Redact sensitive info.
24
- *
25
- * @param entityType
26
- * Entity to redact.
27
- * @param plaintext
28
- * The plaintext string to redact.
29
- * @returns
30
- * Redacted string.
31
- */
32
- type CustomRedact = typeof ArcjetRedactCustomRedact.redactSensitiveInfo;
33
- export type { RedactedSensitiveInfoEntity, RedactSensitiveInfoConfig, SensitiveInfoEntity, } from "./wasm/arcjet_analyze_bindings_redact.component.js";
package/index.js DELETED
@@ -1,50 +0,0 @@
1
- import { instantiate } from './wasm/arcjet_analyze_bindings_redact.component.js';
2
- import { wasm } from './_virtual/arcjet_analyze_bindings_redact.component.core.js';
3
- import { wasm as wasm$1 } from './_virtual/arcjet_analyze_bindings_redact.component.core2.js';
4
- import { wasm as wasm$2 } from './_virtual/arcjet_analyze_bindings_redact.component.core3.js';
5
-
6
- // Support `?js` and such:
7
- //
8
- /// <reference types="./wasm.js" />
9
- const componentCoreWasmPromise = wasm();
10
- const componentCore2WasmPromise = wasm$1();
11
- const componentCore3WasmPromise = wasm$2();
12
- async function moduleFromPath(path) {
13
- if (path === "arcjet_analyze_bindings_redact.component.core.wasm") {
14
- return componentCoreWasmPromise;
15
- }
16
- if (path === "arcjet_analyze_bindings_redact.component.core2.wasm") {
17
- return componentCore2WasmPromise;
18
- }
19
- if (path === "arcjet_analyze_bindings_redact.component.core3.wasm") {
20
- return componentCore3WasmPromise;
21
- }
22
- throw new Error(`Unknown path: ${path}`);
23
- }
24
- /**
25
- * Initialize the WebAssembly.
26
- *
27
- * @param detect
28
- * Custom detection function.
29
- * @param replace
30
- * Custom replacement function.
31
- * @returns
32
- * Promise to the initialized WebAssembly instance.
33
- */
34
- async function initializeWasm(detect, replace) {
35
- const coreImports = {
36
- "arcjet:redact/custom-redact": {
37
- detectSensitiveInfo: detect,
38
- redactSensitiveInfo: replace,
39
- },
40
- };
41
- try {
42
- // Await the instantiation to catch the failure
43
- return await instantiate(moduleFromPath, coreImports);
44
- }
45
- catch {
46
- console.debug("WebAssembly is not supported in this runtime");
47
- }
48
- }
49
-
50
- export { initializeWasm };
@@ -1,53 +0,0 @@
1
- import type { SensitiveInfoEntity } from './interfaces/arcjet-redact-custom-redact.js';
2
- export { SensitiveInfoEntity };
3
- export interface RedactSensitiveInfoConfig {
4
- entities?: Array<SensitiveInfoEntity>,
5
- contextWindowSize?: number,
6
- skipCustomDetect: boolean,
7
- skipCustomRedact: boolean,
8
- }
9
- export interface RedactedSensitiveInfoEntity {
10
- original: string,
11
- redacted: string,
12
- start: number,
13
- end: number,
14
- identifiedType: SensitiveInfoEntity,
15
- }
16
- import { ArcjetRedactCustomRedact } from './interfaces/arcjet-redact-custom-redact.js';
17
- export interface ImportObject {
18
- 'arcjet:redact/custom-redact': typeof ArcjetRedactCustomRedact,
19
- }
20
- export interface Root {
21
- redact(content: string, options: RedactSensitiveInfoConfig): Array<RedactedSensitiveInfoEntity>,
22
- }
23
-
24
- /**
25
- * Instantiates this component with the provided imports and
26
- * returns a map of all the exports of the component.
27
- *
28
- * This function is intended to be similar to the
29
- * `WebAssembly.instantiate` function. The second `imports`
30
- * argument is the "import object" for wasm, except here it
31
- * uses component-model-layer types instead of core wasm
32
- * integers/numbers/etc.
33
- *
34
- * The first argument to this function, `getCoreModule`, is
35
- * used to compile core wasm modules within the component.
36
- * Components are composed of core wasm modules and this callback
37
- * will be invoked per core wasm module. The caller of this
38
- * function is responsible for reading the core wasm module
39
- * identified by `path` and returning its compiled
40
- * `WebAssembly.Module` object. This would use `compileStreaming`
41
- * on the web, for example.
42
- */
43
- export function instantiate(
44
- getCoreModule: (path: string) => WebAssembly.Module,
45
- imports: ImportObject,
46
- instantiateCore?: (module: WebAssembly.Module, imports: Record<string, any>) => WebAssembly.Instance
47
- ): Root;
48
- export function instantiate(
49
- getCoreModule: (path: string) => WebAssembly.Module | Promise<WebAssembly.Module>,
50
- imports: ImportObject,
51
- instantiateCore?: (module: WebAssembly.Module, imports: Record<string, any>) => WebAssembly.Instance | Promise<WebAssembly.Instance>
52
- ): Root | Promise<Root>;
53
-