@arcjet/analyze-wasm 1.0.0-beta.10 → 1.0.0-beta.12

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,AGFzbQEAAAABFQNgA39/fwBgBH9/f38Bf2ACf38BfwMIBwABAgICAgAEBQFwAQcHBygIATAAAAExAAEBMgACATMAAwE0AAQBNQAFATYABggkaW1wb3J0cwEACl0HDQAgACABIAJBABEAAAsPACAAIAEgAiADQQERAQALCwAgACABQQIRAgALCwAgACABQQMRAgALCwAgACABQQQRAgALCwAgACABQQURAgALDQAgACABIAJBBhEAAAsALwlwcm9kdWNlcnMBDHByb2Nlc3NlZC1ieQENd2l0LWNvbXBvbmVudAcwLjIzMC4wALwDBG5hbWUAExJ3aXQtY29tcG9uZW50OnNoaW0BnwMHACxpbmRpcmVjdC1hcmNqZXQ6anMtcmVxL2JvdC1pZGVudGlmaWVyLWRldGVjdAEoaW5kaXJlY3QtYXJjamV0OmpzLXJlcS92ZXJpZnktYm90LXZlcmlmeQI+aW5kaXJlY3QtYXJjamV0OmpzLXJlcS9lbWFpbC12YWxpZGF0b3Itb3ZlcnJpZGVzLWlzLWZyZWUtZW1haWwDRGluZGlyZWN0LWFyY2pldDpqcy1yZXEvZW1haWwtdmFsaWRhdG9yLW92ZXJyaWRlcy1pcy1kaXNwb3NhYmxlLWVtYWlsBD9pbmRpcmVjdC1hcmNqZXQ6anMtcmVxL2VtYWlsLXZhbGlkYXRvci1vdmVycmlkZXMtaGFzLW14LXJlY29yZHMFPWluZGlyZWN0LWFyY2pldDpqcy1yZXEvZW1haWwtdmFsaWRhdG9yLW92ZXJyaWRlcy1oYXMtZ3JhdmF0YXIGPmluZGlyZWN0LWFyY2pldDpqcy1yZXEvc2Vuc2l0aXZlLWluZm9ybWF0aW9uLWlkZW50aWZpZXItZGV0ZWN0";
27
+ const wasmBase64 = "data:application/wasm;base64,AGFzbQEAAAABFQNgA39/fwBgBH9/f38Bf2ACf38BfwMJCAAAAQICAgIABAUBcAEICAcsCQEwAAABMQABATIAAgEzAAMBNAAEATUABQE2AAYBNwAHCCRpbXBvcnRzAQAKawgNACAAIAEgAkEAEQAACw0AIAAgASACQQERAAALDwAgACABIAIgA0ECEQEACwsAIAAgAUEDEQIACwsAIAAgAUEEEQIACwsAIAAgAUEFEQIACwsAIAAgAUEGEQIACw0AIAAgASACQQcRAAALAC8JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQHMC4yMzUuMADvAwRuYW1lABMSd2l0LWNvbXBvbmVudDpzaGltAdIDCAAsaW5kaXJlY3QtYXJjamV0OmpzLXJlcS9ib3QtaWRlbnRpZmllci1kZXRlY3QBMWluZGlyZWN0LWFyY2pldDpqcy1yZXEvZmlsdGVyLW92ZXJyaWRlcy1pcC1sb29rdXACKGluZGlyZWN0LWFyY2pldDpqcy1yZXEvdmVyaWZ5LWJvdC12ZXJpZnkDPmluZGlyZWN0LWFyY2pldDpqcy1yZXEvZW1haWwtdmFsaWRhdG9yLW92ZXJyaWRlcy1pcy1mcmVlLWVtYWlsBERpbmRpcmVjdC1hcmNqZXQ6anMtcmVxL2VtYWlsLXZhbGlkYXRvci1vdmVycmlkZXMtaXMtZGlzcG9zYWJsZS1lbWFpbAU/aW5kaXJlY3QtYXJjamV0OmpzLXJlcS9lbWFpbC12YWxpZGF0b3Itb3ZlcnJpZGVzLWhhcy1teC1yZWNvcmRzBj1pbmRpcmVjdC1hcmNqZXQ6anMtcmVxL2VtYWlsLXZhbGlkYXRvci1vdmVycmlkZXMtaGFzLWdyYXZhdGFyBz5pbmRpcmVjdC1hcmNqZXQ6anMtcmVxL3NlbnNpdGl2ZS1pbmZvcm1hdGlvbi1pZGVudGlmaWVyLWRldGVjdA==";
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,AGFzbQEAAAABFQNgA39/fwBgBH9/f38Bf2ACf38BfwIzCAABMAAAAAExAAEAATIAAgABMwACAAE0AAIAATUAAgABNgAAAAgkaW1wb3J0cwFwAQcHCQ0BAEEACwcAAQIDBAUGAC8JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQHMC4yMzAuMAAcBG5hbWUAFRR3aXQtY29tcG9uZW50OmZpeHVwcw==";
27
+ const wasmBase64 = "data:application/wasm;base64,AGFzbQEAAAABFQNgA39/fwBgBH9/f38Bf2ACf38BfwI4CQABMAAAAAExAAAAATIAAQABMwACAAE0AAIAATUAAgABNgACAAE3AAAACCRpbXBvcnRzAXABCAgJDgEAQQALCAABAgMEBQYHAC8JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQHMC4yMzUuMAAcBG5hbWUAFRR3aXQtY29tcG9uZW50OmZpeHVwcw==";
28
28
  /**
29
29
  * Returns a WebAssembly.Module for an Arcjet Wasm binary, decoded from a base64
30
30
  * Data URL.
package/edge-light.d.ts CHANGED
@@ -1,5 +1,11 @@
1
- import type { ImportObject, DetectedSensitiveInfoEntity, SensitiveInfoEntity, BotConfig, EmailValidationResult, BotResult, SensitiveInfoResult, EmailValidationConfig, SensitiveInfoEntities } from "./wasm/arcjet_analyze_js_req.component.js";
2
- import type { ArcjetJsReqSensitiveInformationIdentifier } from "./wasm/interfaces/arcjet-js-req-sensitive-information-identifier.js";
3
- type DetectSensitiveInfoFunction = typeof ArcjetJsReqSensitiveInformationIdentifier.detect;
1
+ import type { ImportObject } from "./wasm/arcjet_analyze_js_req.component.js";
2
+ /**
3
+ * Initialize the generated WebAssembly component.
4
+ *
5
+ * @param coreImports
6
+ * Things, typically functions, to pass into the component.
7
+ * @returns
8
+ * Promise that resolves to the initialized component.
9
+ */
4
10
  export declare function initializeWasm(coreImports: ImportObject): Promise<import("./wasm/arcjet_analyze_js_req.component.js").Root | undefined>;
5
- export { type BotConfig, type DetectedSensitiveInfoEntity, type SensitiveInfoEntity, type EmailValidationConfig, type EmailValidationResult, type BotResult, type SensitiveInfoResult, type SensitiveInfoEntities, type DetectSensitiveInfoFunction, type ImportObject, };
11
+ export type { BotConfig, BotResult, DetectSensitiveInfoFunction, DetectedSensitiveInfoEntity, EmailValidationConfig, EmailValidationResult, ImportObject, FilterResult, SensitiveInfoEntities, SensitiveInfoEntity, SensitiveInfoResult, } from "./types.js";
package/edge-light.js CHANGED
@@ -15,6 +15,14 @@ async function moduleFromPath(path) {
15
15
  }
16
16
  throw new Error(`Unknown path: ${path}`);
17
17
  }
18
+ /**
19
+ * Initialize the generated WebAssembly component.
20
+ *
21
+ * @param coreImports
22
+ * Things, typically functions, to pass into the component.
23
+ * @returns
24
+ * Promise that resolves to the initialized component.
25
+ */
18
26
  async function initializeWasm(coreImports) {
19
27
  try {
20
28
  return instantiate(moduleFromPath, coreImports);
package/index.d.ts CHANGED
@@ -1,5 +1,11 @@
1
- import type { ImportObject, BotConfig, DetectedSensitiveInfoEntity, SensitiveInfoEntity, EmailValidationResult, BotResult, SensitiveInfoResult, EmailValidationConfig, SensitiveInfoEntities } from "./wasm/arcjet_analyze_js_req.component.js";
2
- import type { ArcjetJsReqSensitiveInformationIdentifier } from "./wasm/interfaces/arcjet-js-req-sensitive-information-identifier.js";
3
- type DetectSensitiveInfoFunction = typeof ArcjetJsReqSensitiveInformationIdentifier.detect;
1
+ import type { ImportObject } from "./wasm/arcjet_analyze_js_req.component.js";
2
+ /**
3
+ * Initialize the generated WebAssembly component.
4
+ *
5
+ * @param coreImports
6
+ * Things, typically functions, to pass into the component.
7
+ * @returns
8
+ * Promise that resolves to the initialized component.
9
+ */
4
10
  export declare function initializeWasm(coreImports: ImportObject): Promise<import("./wasm/arcjet_analyze_js_req.component.js").Root | undefined>;
5
- export { type BotConfig, type DetectedSensitiveInfoEntity, type SensitiveInfoEntity, type EmailValidationConfig, type EmailValidationResult, type BotResult, type SensitiveInfoResult, type SensitiveInfoEntities, type DetectSensitiveInfoFunction, type ImportObject, };
11
+ export type { BotConfig, BotResult, DetectSensitiveInfoFunction, DetectedSensitiveInfoEntity, EmailValidationConfig, EmailValidationResult, ImportObject, FilterResult, SensitiveInfoEntities, SensitiveInfoEntity, SensitiveInfoResult, } from "./types.js";
package/index.js CHANGED
@@ -19,6 +19,14 @@ async function moduleFromPath(path) {
19
19
  // TODO(@wooorm-arcjet): figure out a test case that makes this throw.
20
20
  throw new Error(`Unknown path: ${path}`);
21
21
  }
22
+ /**
23
+ * Initialize the generated WebAssembly component.
24
+ *
25
+ * @param coreImports
26
+ * Things, typically functions, to pass into the component.
27
+ * @returns
28
+ * Promise that resolves to the initialized component.
29
+ */
22
30
  async function initializeWasm(coreImports) {
23
31
  try {
24
32
  // Await the instantiation to catch the failure
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcjet/analyze-wasm",
3
- "version": "1.0.0-beta.10",
3
+ "version": "1.0.0-beta.12",
4
4
  "description": "WebAssembly bindings to Arcjet's local analysis engine",
5
5
  "keywords": [
6
6
  "analyze",
@@ -45,6 +45,8 @@
45
45
  "edge-light.js",
46
46
  "index.d.ts",
47
47
  "index.js",
48
+ "types.d.ts",
49
+ "types.js",
48
50
  "workerd.d.ts",
49
51
  "workerd.js"
50
52
  ],
@@ -60,13 +62,12 @@
60
62
  },
61
63
  "dependencies": {},
62
64
  "devDependencies": {
63
- "@arcjet/eslint-config": "1.0.0-beta.10",
64
- "@arcjet/rollup-config": "1.0.0-beta.10",
65
- "@arcjet/tsconfig": "1.0.0-beta.10",
65
+ "@arcjet/eslint-config": "1.0.0-beta.12",
66
+ "@arcjet/rollup-config": "1.0.0-beta.12",
66
67
  "@bytecodealliance/jco": "1.5.0",
67
- "@rollup/wasm-node": "4.46.2",
68
- "@types/node": "18.18.0",
69
- "eslint": "9.32.0",
68
+ "@rollup/wasm-node": "4.50.0",
69
+ "@types/node": "24.3.0",
70
+ "eslint": "9.34.0",
70
71
  "typescript": "5.9.2"
71
72
  },
72
73
  "publishConfig": {
package/types.d.ts ADDED
@@ -0,0 +1,73 @@
1
+ import type { BotConfig as GeneratedBotConfig, BotResult as GeneratedBotResult, DetectedSensitiveInfoEntity as GeneratedDetectedSensitiveInfoEntity, EmailValidationConfig as GeneratedEmailValidationConfig, EmailValidationResult as GeneratedEmailValidationResult, ImportObject as GeneratedImportObject, FilterResult as GeneratedFilterResult, SensitiveInfoEntities as GeneratedSensitiveInfoEntities, SensitiveInfoEntity as GeneratedSensitiveInfoEntity, SensitiveInfoResult as GeneratedSensitiveInfoResult } from "./wasm/arcjet_analyze_js_req.component.js";
2
+ import type { ArcjetJsReqSensitiveInformationIdentifier } from "./wasm/interfaces/arcjet-js-req-sensitive-information-identifier.js";
3
+ /**
4
+ * Configuration for bot detection.
5
+ * Generated from the WebAssembly component.
6
+ */
7
+ export type BotConfig = GeneratedBotConfig;
8
+ /**
9
+ * Result of bot detection.
10
+ * Generated from the WebAssembly component.
11
+ */
12
+ export type BotResult = GeneratedBotResult;
13
+ /**
14
+ * Function signature for custom entity detection from JavaScript.
15
+ *
16
+ * Generated from the WebAssembly component.
17
+ *
18
+ * This signature corresponds to similar functions from `@arcjet/redact-wasm`
19
+ * and `@arcjet/redact`.
20
+ *
21
+ * @param tokens
22
+ * Tokens to detect in.
23
+ * @returns
24
+ * Array of `undefined` for tokens that are not sensitive or a `string` used as
25
+ * a label for sensitive info.
26
+ */
27
+ export type DetectSensitiveInfoFunction = typeof ArcjetJsReqSensitiveInformationIdentifier.detect;
28
+ /**
29
+ * Span of sensitive info,
30
+ * with `start` and `end` fields relating to the input value,
31
+ * and an `identifiedType` tag for its kind.
32
+ * Generated from the WebAssembly component.
33
+ */
34
+ export type DetectedSensitiveInfoEntity = GeneratedDetectedSensitiveInfoEntity;
35
+ /**
36
+ * Configuration for email validation.
37
+ * Generated from the WebAssembly component.
38
+ */
39
+ export type EmailValidationConfig = GeneratedEmailValidationConfig;
40
+ /**
41
+ * Result of email validation.
42
+ * Generated from the WebAssembly component.
43
+ */
44
+ export type EmailValidationResult = GeneratedEmailValidationResult;
45
+ /**
46
+ * Result of a filter call.
47
+ * Generated from the WebAssembly component.
48
+ */
49
+ export type FilterResult = GeneratedFilterResult;
50
+ /**
51
+ * Object representing the import structure.
52
+ * These are things that can be passed *into* the WebAssembly.
53
+ * Generated from the WebAssembly component.
54
+ */
55
+ export type ImportObject = GeneratedImportObject;
56
+ /**
57
+ * Configuration for sensitive info detection.
58
+ * Generated from the WebAssembly component.
59
+ */
60
+ export type SensitiveInfoEntities = GeneratedSensitiveInfoEntities;
61
+ /**
62
+ * Kind of sensitive info.
63
+ * Consists of each of the tags that can detect be detected natively
64
+ * and a custom tag for values detected from JavaScript.
65
+ * Generated from the WebAssembly component.
66
+ */
67
+ export type SensitiveInfoEntity = GeneratedSensitiveInfoEntity;
68
+ /**
69
+ * Result of sensitive info detection.
70
+ * Generated from the WebAssembly component.
71
+ */
72
+ export type SensitiveInfoResult = GeneratedSensitiveInfoResult;
73
+ export {};
package/types.js ADDED
@@ -0,0 +1 @@
1
+
@@ -79,18 +79,26 @@ export interface BotResult {
79
79
  verified: boolean,
80
80
  spoofed: boolean,
81
81
  }
82
+ export interface FilterResult {
83
+ allowed: boolean,
84
+ matchedExpressions: Array<string>,
85
+ undeterminedExpressions: Array<string>,
86
+ }
82
87
  import { ArcjetJsReqBotIdentifier } from './interfaces/arcjet-js-req-bot-identifier.js';
83
88
  import { ArcjetJsReqEmailValidatorOverrides } from './interfaces/arcjet-js-req-email-validator-overrides.js';
89
+ import { ArcjetJsReqFilterOverrides } from './interfaces/arcjet-js-req-filter-overrides.js';
84
90
  import { ArcjetJsReqSensitiveInformationIdentifier } from './interfaces/arcjet-js-req-sensitive-information-identifier.js';
85
91
  import { ArcjetJsReqVerifyBot } from './interfaces/arcjet-js-req-verify-bot.js';
86
92
  export interface ImportObject {
87
93
  'arcjet:js-req/bot-identifier': typeof ArcjetJsReqBotIdentifier,
88
94
  'arcjet:js-req/email-validator-overrides': typeof ArcjetJsReqEmailValidatorOverrides,
95
+ 'arcjet:js-req/filter-overrides': typeof ArcjetJsReqFilterOverrides,
89
96
  'arcjet:js-req/sensitive-information-identifier': typeof ArcjetJsReqSensitiveInformationIdentifier,
90
97
  'arcjet:js-req/verify-bot': typeof ArcjetJsReqVerifyBot,
91
98
  }
92
99
  export interface Root {
93
100
  detectBot(request: string, options: BotConfig): BotResult,
101
+ matchFilters(request: string, expressions: Array<string>, allowIfMatch: boolean): FilterResult,
94
102
  generateFingerprint(request: string, characteristics: Array<string>): string,
95
103
  validateCharacteristics(request: string, characteristics: Array<string>): void,
96
104
  isValidEmail(candidate: string, options: EmailValidationConfig): EmailValidationResult,
@@ -44,6 +44,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
44
44
 
45
45
  const { detect } = imports['arcjet:js-req/bot-identifier'];
46
46
  const { hasGravatar, hasMxRecords, isDisposableEmail, isFreeEmail } = imports['arcjet:js-req/email-validator-overrides'];
47
+ const { ipLookup } = imports['arcjet:js-req/filter-overrides'];
47
48
  const { detect: detect$1 } = imports['arcjet:js-req/sensitive-information-identifier'];
48
49
  const { verify } = imports['arcjet:js-req/verify-bot'];
49
50
  let gen = (function* init () {
@@ -71,7 +72,25 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
71
72
  dataView(memory0).setInt32(arg2 + 0, result2, true);
72
73
  }
73
74
 
74
- function trampoline1(arg0, arg1, arg2, arg3) {
75
+ function trampoline1(arg0, arg1, arg2) {
76
+ var ptr0 = arg0;
77
+ var len0 = arg1;
78
+ var result0 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr0, len0));
79
+ const ret = ipLookup(result0);
80
+ var variant2 = ret;
81
+ if (variant2 === null || variant2=== undefined) {
82
+ dataView(memory0).setInt8(arg2 + 0, 0, true);
83
+ } else {
84
+ const e = variant2;
85
+ dataView(memory0).setInt8(arg2 + 0, 1, true);
86
+ var ptr1 = utf8Encode(e, realloc0, memory0);
87
+ var len1 = utf8EncodedLen;
88
+ dataView(memory0).setInt32(arg2 + 8, len1, true);
89
+ dataView(memory0).setInt32(arg2 + 4, ptr1, true);
90
+ }
91
+ }
92
+
93
+ function trampoline2(arg0, arg1, arg2, arg3) {
75
94
  var ptr0 = arg0;
76
95
  var len0 = arg1;
77
96
  var result0 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr0, len0));
@@ -105,7 +124,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
105
124
  return enum2;
106
125
  }
107
126
 
108
- function trampoline2(arg0, arg1) {
127
+ function trampoline3(arg0, arg1) {
109
128
  var ptr0 = arg0;
110
129
  var len0 = arg1;
111
130
  var result0 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr0, len0));
@@ -136,7 +155,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
136
155
  return enum1;
137
156
  }
138
157
 
139
- function trampoline3(arg0, arg1) {
158
+ function trampoline4(arg0, arg1) {
140
159
  var ptr0 = arg0;
141
160
  var len0 = arg1;
142
161
  var result0 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr0, len0));
@@ -167,7 +186,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
167
186
  return enum1;
168
187
  }
169
188
 
170
- function trampoline4(arg0, arg1) {
189
+ function trampoline5(arg0, arg1) {
171
190
  var ptr0 = arg0;
172
191
  var len0 = arg1;
173
192
  var result0 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr0, len0));
@@ -198,7 +217,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
198
217
  return enum1;
199
218
  }
200
219
 
201
- function trampoline5(arg0, arg1) {
220
+ function trampoline6(arg0, arg1) {
202
221
  var ptr0 = arg0;
203
222
  var len0 = arg1;
204
223
  var result0 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr0, len0));
@@ -229,7 +248,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
229
248
  return enum1;
230
249
  }
231
250
 
232
- function trampoline6(arg0, arg1, arg2) {
251
+ function trampoline7(arg0, arg1, arg2) {
233
252
  var len1 = arg1;
234
253
  var base1 = arg0;
235
254
  var result1 = [];
@@ -294,6 +313,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
294
313
  let postReturn2;
295
314
  let postReturn3;
296
315
  let postReturn4;
316
+ let postReturn5;
297
317
  Promise.all([module0, module1, module2]).catch(() => {});
298
318
  ({ exports: exports0 } = yield instantiateCore(yield module1));
299
319
  ({ exports: exports1 } = yield instantiateCore(yield module0, {
@@ -301,16 +321,19 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
301
321
  detect: exports0['0'],
302
322
  },
303
323
  'arcjet:js-req/email-validator-overrides': {
304
- 'has-gravatar': exports0['5'],
305
- 'has-mx-records': exports0['4'],
306
- 'is-disposable-email': exports0['3'],
307
- 'is-free-email': exports0['2'],
324
+ 'has-gravatar': exports0['6'],
325
+ 'has-mx-records': exports0['5'],
326
+ 'is-disposable-email': exports0['4'],
327
+ 'is-free-email': exports0['3'],
328
+ },
329
+ 'arcjet:js-req/filter-overrides': {
330
+ 'ip-lookup': exports0['1'],
308
331
  },
309
332
  'arcjet:js-req/sensitive-information-identifier': {
310
- detect: exports0['6'],
333
+ detect: exports0['7'],
311
334
  },
312
335
  'arcjet:js-req/verify-bot': {
313
- verify: exports0['1'],
336
+ verify: exports0['2'],
314
337
  },
315
338
  }));
316
339
  memory0 = exports1.memory;
@@ -325,13 +348,15 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
325
348
  '4': trampoline4,
326
349
  '5': trampoline5,
327
350
  '6': trampoline6,
351
+ '7': trampoline7,
328
352
  },
329
353
  }));
330
354
  postReturn0 = exports1['cabi_post_detect-bot'];
331
- postReturn1 = exports1['cabi_post_generate-fingerprint'];
332
- postReturn2 = exports1['cabi_post_validate-characteristics'];
333
- postReturn3 = exports1['cabi_post_is-valid-email'];
334
- postReturn4 = exports1['cabi_post_detect-sensitive-info'];
355
+ postReturn1 = exports1['cabi_post_match-filters'];
356
+ postReturn2 = exports1['cabi_post_generate-fingerprint'];
357
+ postReturn3 = exports1['cabi_post_validate-characteristics'];
358
+ postReturn4 = exports1['cabi_post_is-valid-email'];
359
+ postReturn5 = exports1['cabi_post_detect-sensitive-info'];
335
360
 
336
361
  function detectBot(arg0, arg1) {
337
362
  var ptr0 = utf8Encode(arg0, realloc0, memory0);
@@ -443,6 +468,76 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
443
468
  return retVal.val;
444
469
  }
445
470
 
471
+ function matchFilters(arg0, arg1, arg2) {
472
+ var ptr0 = utf8Encode(arg0, realloc0, memory0);
473
+ var len0 = utf8EncodedLen;
474
+ var vec2 = arg1;
475
+ var len2 = vec2.length;
476
+ var result2 = realloc0(0, 0, 4, len2 * 8);
477
+ for (let i = 0; i < vec2.length; i++) {
478
+ const e = vec2[i];
479
+ const base = result2 + i * 8;var ptr1 = utf8Encode(e, realloc0, memory0);
480
+ var len1 = utf8EncodedLen;
481
+ dataView(memory0).setInt32(base + 4, len1, true);
482
+ dataView(memory0).setInt32(base + 0, ptr1, true);
483
+ }
484
+ const ret = exports1['match-filters'](ptr0, len0, result2, len2, arg2 ? 1 : 0);
485
+ let variant9;
486
+ switch (dataView(memory0).getUint8(ret + 0, true)) {
487
+ case 0: {
488
+ var bool3 = dataView(memory0).getUint8(ret + 4, true);
489
+ var len5 = dataView(memory0).getInt32(ret + 12, true);
490
+ var base5 = dataView(memory0).getInt32(ret + 8, true);
491
+ var result5 = [];
492
+ for (let i = 0; i < len5; i++) {
493
+ const base = base5 + i * 8;
494
+ var ptr4 = dataView(memory0).getInt32(base + 0, true);
495
+ var len4 = dataView(memory0).getInt32(base + 4, true);
496
+ var result4 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr4, len4));
497
+ result5.push(result4);
498
+ }
499
+ var len7 = dataView(memory0).getInt32(ret + 20, true);
500
+ var base7 = dataView(memory0).getInt32(ret + 16, true);
501
+ var result7 = [];
502
+ for (let i = 0; i < len7; i++) {
503
+ const base = base7 + i * 8;
504
+ var ptr6 = dataView(memory0).getInt32(base + 0, true);
505
+ var len6 = dataView(memory0).getInt32(base + 4, true);
506
+ var result6 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr6, len6));
507
+ result7.push(result6);
508
+ }
509
+ variant9= {
510
+ tag: 'ok',
511
+ val: {
512
+ allowed: bool3 == 0 ? false : (bool3 == 1 ? true : throwInvalidBool()),
513
+ matchedExpressions: result5,
514
+ undeterminedExpressions: result7,
515
+ }
516
+ };
517
+ break;
518
+ }
519
+ case 1: {
520
+ var ptr8 = dataView(memory0).getInt32(ret + 4, true);
521
+ var len8 = dataView(memory0).getInt32(ret + 8, true);
522
+ var result8 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr8, len8));
523
+ variant9= {
524
+ tag: 'err',
525
+ val: result8
526
+ };
527
+ break;
528
+ }
529
+ default: {
530
+ throw new TypeError('invalid variant discriminant for expected');
531
+ }
532
+ }
533
+ const retVal = variant9;
534
+ postReturn1(ret);
535
+ if (typeof retVal === 'object' && retVal.tag === 'err') {
536
+ throw new ComponentError(retVal.val);
537
+ }
538
+ return retVal.val;
539
+ }
540
+
446
541
  function generateFingerprint(arg0, arg1) {
447
542
  var ptr0 = utf8Encode(arg0, realloc0, memory0);
448
543
  var len0 = utf8EncodedLen;
@@ -484,7 +579,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
484
579
  }
485
580
  }
486
581
  const retVal = variant5;
487
- postReturn1(ret);
582
+ postReturn2(ret);
488
583
  if (typeof retVal === 'object' && retVal.tag === 'err') {
489
584
  throw new ComponentError(retVal.val);
490
585
  }
@@ -529,7 +624,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
529
624
  }
530
625
  }
531
626
  const retVal = variant4;
532
- postReturn2(ret);
627
+ postReturn3(ret);
533
628
  if (typeof retVal === 'object' && retVal.tag === 'err') {
534
629
  throw new ComponentError(retVal.val);
535
630
  }
@@ -642,7 +737,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
642
737
  }
643
738
  }
644
739
  const retVal = variant12;
645
- postReturn3(ret);
740
+ postReturn4(ret);
646
741
  if (typeof retVal === 'object' && retVal.tag === 'err') {
647
742
  throw new ComponentError(retVal.val);
648
743
  }
@@ -868,11 +963,11 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
868
963
  allowed: result12,
869
964
  denied: result15,
870
965
  };
871
- postReturn4(ret);
966
+ postReturn5(ret);
872
967
  return retVal;
873
968
  }
874
969
 
875
- return { detectBot, detectSensitiveInfo, generateFingerprint, isValidEmail, validateCharacteristics, };
970
+ return { detectBot, detectSensitiveInfo, generateFingerprint, isValidEmail, matchFilters, validateCharacteristics, };
876
971
  })();
877
972
  let promise, resolve, reject;
878
973
  function runNext (value) {
@@ -0,0 +1,3 @@
1
+ export namespace ArcjetJsReqFilterOverrides {
2
+ export function ipLookup(ip: string): string | undefined;
3
+ }
package/workerd.d.ts CHANGED
@@ -1,5 +1,11 @@
1
- import type { ImportObject, BotConfig, DetectedSensitiveInfoEntity, SensitiveInfoEntity, EmailValidationResult, BotResult, SensitiveInfoResult, EmailValidationConfig, SensitiveInfoEntities } from "./wasm/arcjet_analyze_js_req.component.js";
2
- import type { ArcjetJsReqSensitiveInformationIdentifier } from "./wasm/interfaces/arcjet-js-req-sensitive-information-identifier.js";
3
- type DetectSensitiveInfoFunction = typeof ArcjetJsReqSensitiveInformationIdentifier.detect;
1
+ import type { ImportObject } from "./wasm/arcjet_analyze_js_req.component.js";
2
+ /**
3
+ * Initialize the generated WebAssembly component.
4
+ *
5
+ * @param coreImports
6
+ * Things, typically functions, to pass into the component.
7
+ * @returns
8
+ * Promise that resolves to the initialized component.
9
+ */
4
10
  export declare function initializeWasm(coreImports: ImportObject): Promise<import("./wasm/arcjet_analyze_js_req.component.js").Root | undefined>;
5
- export { type BotConfig, type DetectedSensitiveInfoEntity, type SensitiveInfoEntity, type EmailValidationConfig, type EmailValidationResult, type BotResult, type SensitiveInfoResult, type SensitiveInfoEntities, type DetectSensitiveInfoFunction, type ImportObject, };
11
+ export type { BotConfig, BotResult, DetectSensitiveInfoFunction, DetectedSensitiveInfoEntity, EmailValidationConfig, EmailValidationResult, ImportObject, FilterResult, SensitiveInfoEntities, SensitiveInfoEntity, SensitiveInfoResult, } from "./types.js";
package/workerd.js CHANGED
@@ -15,6 +15,14 @@ async function moduleFromPath(path) {
15
15
  }
16
16
  throw new Error(`Unknown path: ${path}`);
17
17
  }
18
+ /**
19
+ * Initialize the generated WebAssembly component.
20
+ *
21
+ * @param coreImports
22
+ * Things, typically functions, to pass into the component.
23
+ * @returns
24
+ * Promise that resolves to the initialized component.
25
+ */
18
26
  async function initializeWasm(coreImports) {
19
27
  try {
20
28
  // Await the instantiation to catch the failure