@arcjet/redact-wasm 1.0.0-alpha.34 → 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.
@@ -24,7 +24,7 @@
24
24
  * properly support consistent asset bundling techniques.
25
25
  */
26
26
 
27
- const wasmBase64 = "data:application/wasm;base64,AGFzbQEAAAABDgJgA39/fwBgBH9/f38AAwMCAAEEBQFwAQICBxQDATAAAAExAAEIJGltcG9ydHMBAAofAg0AIAAgASACQQARAAALDwAgACABIAIgA0EBEQEACwAvCXByb2R1Y2VycwEMcHJvY2Vzc2VkLWJ5AQ13aXQtY29tcG9uZW50BzAuMjE5LjEAlQEEbmFtZQATEndpdC1jb21wb25lbnQ6c2hpbQF5AgA6aW5kaXJlY3QtYXJjamV0OnJlZGFjdC9jdXN0b20tcmVkYWN0LWRldGVjdC1zZW5zaXRpdmUtaW5mbwE6aW5kaXJlY3QtYXJjamV0OnJlZGFjdC9jdXN0b20tcmVkYWN0LXJlZGFjdC1zZW5zaXRpdmUtaW5mbw==";
27
+ const wasmBase64 = "data:application/wasm;base64,AGFzbQEAAAABEAJgA39/fwBgBn9/f39/fwADAwIAAQQFAXABAgIHFAMBMAAAATEAAQgkaW1wb3J0cwEACiMCDQAgACABIAJBABEAAAsTACAAIAEgAiADIAQgBUEBEQEACwAvCXByb2R1Y2VycwEMcHJvY2Vzc2VkLWJ5AQ13aXQtY29tcG9uZW50BzAuMjMwLjAAlQEEbmFtZQATEndpdC1jb21wb25lbnQ6c2hpbQF5AgA6aW5kaXJlY3QtYXJjamV0OnJlZGFjdC9jdXN0b20tcmVkYWN0LWRldGVjdC1zZW5zaXRpdmUtaW5mbwE6aW5kaXJlY3QtYXJjamV0OnJlZGFjdC9jdXN0b20tcmVkYWN0LXJlZGFjdC1zZW5zaXRpdmUtaW5mbw==";
28
28
  /**
29
29
  * Returns a WebAssembly.Module for an Arcjet Wasm binary, decoded from a base64
30
30
  * Data URL.
@@ -24,7 +24,7 @@
24
24
  * properly support consistent asset bundling techniques.
25
25
  */
26
26
 
27
- const wasmBase64 = "data:application/wasm;base64,AGFzbQEAAAABDgJgA39/fwBgBH9/f38AAhoDAAEwAAAAATEAAQAIJGltcG9ydHMBcAECAgkIAQBBAAsCAAEALwlwcm9kdWNlcnMBDHByb2Nlc3NlZC1ieQENd2l0LWNvbXBvbmVudAcwLjIxOS4xABwEbmFtZQAVFHdpdC1jb21wb25lbnQ6Zml4dXBz";
27
+ const wasmBase64 = "data:application/wasm;base64,AGFzbQEAAAABEAJgA39/fwBgBn9/f39/fwACGgMAATAAAAABMQABAAgkaW1wb3J0cwFwAQICCQgBAEEACwIAAQAvCXByb2R1Y2VycwEMcHJvY2Vzc2VkLWJ5AQ13aXQtY29tcG9uZW50BzAuMjMwLjAAHARuYW1lABUUd2l0LWNvbXBvbmVudDpmaXh1cHM=";
28
28
  /**
29
29
  * Returns a WebAssembly.Module for an Arcjet Wasm binary, decoded from a base64
30
30
  * Data URL.
package/index.js CHANGED
@@ -3,26 +3,18 @@ import { wasm } from './_virtual/arcjet_analyze_bindings_redact.component.core.j
3
3
  import { wasm as wasm$1 } from './_virtual/arcjet_analyze_bindings_redact.component.core2.js';
4
4
  import { wasm as wasm$2 } from './_virtual/arcjet_analyze_bindings_redact.component.core3.js';
5
5
 
6
- const wasmCache = new Map();
6
+ const componentCoreWasmPromise = wasm();
7
+ const componentCore2WasmPromise = wasm$1();
8
+ const componentCore3WasmPromise = wasm$2();
7
9
  async function moduleFromPath(path) {
8
- const cachedModule = wasmCache.get(path);
9
- if (typeof cachedModule !== "undefined") {
10
- return cachedModule;
11
- }
12
10
  if (path === "arcjet_analyze_bindings_redact.component.core.wasm") {
13
- const mod = await wasm();
14
- wasmCache.set(path, mod);
15
- return mod;
11
+ return componentCoreWasmPromise;
16
12
  }
17
13
  if (path === "arcjet_analyze_bindings_redact.component.core2.wasm") {
18
- const mod = await wasm$1();
19
- wasmCache.set(path, mod);
20
- return mod;
14
+ return componentCore2WasmPromise;
21
15
  }
22
16
  if (path === "arcjet_analyze_bindings_redact.component.core3.wasm") {
23
- const mod = await wasm$2();
24
- wasmCache.set(path, mod);
25
- return mod;
17
+ return componentCore3WasmPromise;
26
18
  }
27
19
  throw new Error(`Unknown path: ${path}`);
28
20
  }
package/package.json CHANGED
@@ -1,7 +1,14 @@
1
1
  {
2
2
  "name": "@arcjet/redact-wasm",
3
- "version": "1.0.0-alpha.34",
3
+ "version": "1.0.0-beta.10",
4
4
  "description": "Arcjet sensitive information redaction detection engine",
5
+ "keywords": [
6
+ "arcjet",
7
+ "redact",
8
+ "utility",
9
+ "util",
10
+ "wasm"
11
+ ],
5
12
  "license": "Apache-2.0",
6
13
  "homepage": "https://arcjet.com",
7
14
  "repository": {
@@ -30,33 +37,35 @@
30
37
  "default": "./index.js"
31
38
  },
32
39
  "files": [
33
- "LICENSE",
34
- "README.md",
35
40
  "_virtual/",
36
41
  "wasm/",
37
- "*.js",
38
- "*.d.ts",
39
- "!*.config.js"
42
+ "edge-light.d.ts",
43
+ "edge-light.js",
44
+ "index.d.ts",
45
+ "index.js",
46
+ "workerd.d.ts",
47
+ "workerd.js"
40
48
  ],
41
49
  "scripts": {
42
- "prepublishOnly": "npm run build",
43
- "jco": "jco transpile wasm/arcjet_analyze_bindings_redact.component.wasm --no-wasi-shim --instantiation async -o wasm",
44
- "build": "npm run jco; rollup --config rollup.config.js",
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",
45
53
  "lint": "eslint .",
46
- "pretest": "npm run build",
47
- "test": "NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests"
54
+ "prepublishOnly": "npm run build",
55
+ "test-api": "node --test",
56
+ "test-coverage": "node --experimental-test-coverage --test",
57
+ "test": "npm run build && npm run lint && npm run test-coverage"
48
58
  },
49
59
  "dependencies": {},
50
60
  "devDependencies": {
51
- "@arcjet/eslint-config": "1.0.0-alpha.34",
52
- "@arcjet/rollup-config": "1.0.0-alpha.34",
53
- "@arcjet/tsconfig": "1.0.0-alpha.34",
61
+ "@arcjet/eslint-config": "1.0.0-beta.10",
62
+ "@arcjet/rollup-config": "1.0.0-beta.10",
63
+ "@arcjet/tsconfig": "1.0.0-beta.10",
54
64
  "@bytecodealliance/jco": "1.5.0",
55
- "@jest/globals": "29.7.0",
56
- "@rollup/wasm-node": "4.28.0",
65
+ "@rollup/wasm-node": "4.46.2",
57
66
  "@types/node": "18.18.0",
58
- "jest": "29.7.0",
59
- "typescript": "5.7.2"
67
+ "eslint": "9.32.0",
68
+ "typescript": "5.9.2"
60
69
  },
61
70
  "publishConfig": {
62
71
  "access": "public",
@@ -97,7 +97,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
97
97
  dataView(memory0).setInt32(arg2 + 0, result5, true);
98
98
  }
99
99
 
100
- function trampoline1(arg0, arg1, arg2, arg3) {
100
+ function trampoline1(arg0, arg1, arg2, arg3, arg4, arg5) {
101
101
  let variant1;
102
102
  switch (arg0) {
103
103
  case 0: {
@@ -138,19 +138,23 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
138
138
  throw new TypeError('invalid variant discriminant for SensitiveInfoEntity');
139
139
  }
140
140
  }
141
- const ret = redactSensitiveInfo(variant1);
142
- var variant3 = ret;
143
- if (variant3 === null || variant3=== undefined) {
144
- dataView(memory0).setInt8(arg3 + 0, 0, true);
141
+ var ptr2 = arg3;
142
+ var len2 = arg4;
143
+ var result2 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr2, len2));
144
+ const ret = redactSensitiveInfo(variant1, result2);
145
+ var variant4 = ret;
146
+ if (variant4 === null || variant4=== undefined) {
147
+ dataView(memory0).setInt8(arg5 + 0, 0, true);
145
148
  } else {
146
- const e = variant3;
147
- dataView(memory0).setInt8(arg3 + 0, 1, true);
148
- var ptr2 = utf8Encode(e, realloc0, memory0);
149
- var len2 = utf8EncodedLen;
150
- dataView(memory0).setInt32(arg3 + 8, len2, true);
151
- dataView(memory0).setInt32(arg3 + 4, ptr2, true);
149
+ const e = variant4;
150
+ dataView(memory0).setInt8(arg5 + 0, 1, true);
151
+ var ptr3 = utf8Encode(e, realloc0, memory0);
152
+ var len3 = utf8EncodedLen;
153
+ dataView(memory0).setInt32(arg5 + 8, len3, true);
154
+ dataView(memory0).setInt32(arg5 + 4, ptr3, true);
152
155
  }
153
156
  }
157
+ let exports2;
154
158
  let postReturn0;
155
159
  Promise.all([module0, module1, module2]).catch(() => {});
156
160
  ({ exports: exports0 } = yield instantiateCore(yield module1));
@@ -162,7 +166,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
162
166
  }));
163
167
  memory0 = exports1.memory;
164
168
  realloc0 = exports1.cabi_realloc;
165
- (yield instantiateCore(yield module2, {
169
+ ({ exports: exports2 } = yield instantiateCore(yield module2, {
166
170
  '': {
167
171
  $imports: exports0.$imports,
168
172
  '0': trampoline0,
@@ -1,6 +1,6 @@
1
1
  export namespace ArcjetRedactCustomRedact {
2
2
  export function detectSensitiveInfo(tokens: Array<string>): Array<SensitiveInfoEntity | undefined>;
3
- export function redactSensitiveInfo(entityType: SensitiveInfoEntity): string | undefined;
3
+ export function redactSensitiveInfo(entityType: SensitiveInfoEntity, plaintext: string): string | undefined;
4
4
  }
5
5
  export type SensitiveInfoEntity = SensitiveInfoEntityEmail | SensitiveInfoEntityPhoneNumber | SensitiveInfoEntityIpAddress | SensitiveInfoEntityCreditCardNumber | SensitiveInfoEntityCustom;
6
6
  export interface SensitiveInfoEntityEmail {
package/wasm.d.ts DELETED
@@ -1,28 +0,0 @@
1
- /**
2
- * Vercel uses the `.wasm?module` suffix to make WebAssembly available in their
3
- * Vercel Functions product.
4
- *
5
- * https://vercel.com/docs/functions/wasm#using-a-webassembly-file
6
- */
7
- declare module "*.wasm?module" {
8
- export default WebAssembly.Module;
9
- }
10
-
11
- /**
12
- * The Cloudflare docs say they support the `.wasm?module` suffix, but that
13
- * seems to no longer be the case with Wrangler 2 so we need to have separate
14
- * imports for just the `.wasm` files.
15
- *
16
- * https://developers.cloudflare.com/workers/runtime-apis/webassembly/javascript/#bundling
17
- */
18
- declare module "*.wasm" {
19
- export default WebAssembly.Module;
20
- }
21
-
22
- /**
23
- * Our Rollup build turns `.wasm?js` imports into JS imports that provide the
24
- * `wasm()` function which decodes a base64 Data URL into a WebAssembly Module
25
- */
26
- declare module "*.wasm?js" {
27
- export function wasm(): Promise<WebAssembly.Module>;
28
- }