@arcjet/analyze 1.0.0-alpha.21 → 1.0.0-alpha.22

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,AGFzbQEAAAABDAJgAn9/AGACf38BfwMHBgAAAQEBAQQFAXABBgYHJAcBMAAAATEAAQEyAAIBMwADATQABAE1AAUIJGltcG9ydHMBAApJBgsAIAAgAUEAEQAACwsAIAAgAUEBEQAACwsAIAAgAUECEQEACwsAIAAgAUEDEQEACwsAIAAgAUEEEQEACwsAIAAgAUEFEQEACwAvCXByb2R1Y2VycwEMcHJvY2Vzc2VkLWJ5AQ13aXQtY29tcG9uZW50BzAuMjEwLjAA7gIEbmFtZQATEndpdC1jb21wb25lbnQ6c2hpbQHRAgYAI2luZGlyZWN0LWFyY2pldDpqcy1yZXEvbG9nZ2VyLWRlYnVnASNpbmRpcmVjdC1hcmNqZXQ6anMtcmVxL2xvZ2dlci1lcnJvcgI+aW5kaXJlY3QtYXJjamV0OmpzLXJlcS9lbWFpbC12YWxpZGF0b3Itb3ZlcnJpZGVzLWlzLWZyZWUtZW1haWwDRGluZGlyZWN0LWFyY2pldDpqcy1yZXEvZW1haWwtdmFsaWRhdG9yLW92ZXJyaWRlcy1pcy1kaXNwb3NhYmxlLWVtYWlsBD9pbmRpcmVjdC1hcmNqZXQ6anMtcmVxL2VtYWlsLXZhbGlkYXRvci1vdmVycmlkZXMtaGFzLW14LXJlY29yZHMFPWluZGlyZWN0LWFyY2pldDpqcy1yZXEvZW1haWwtdmFsaWRhdG9yLW92ZXJyaWRlcy1oYXMtZ3JhdmF0YXI=";
27
+ const wasmBase64 = "data:application/wasm;base64,AGFzbQEAAAABEgNgAn9/AGACf38Bf2ADf39/AAMIBwAAAQEBAQIEBQFwAQcHBygIATAAAAExAAEBMgACATMAAwE0AAQBNQAFATYABggkaW1wb3J0cwEAClcHCwAgACABQQARAAALCwAgACABQQERAAALCwAgACABQQIRAQALCwAgACABQQMRAQALCwAgACABQQQRAQALCwAgACABQQURAQALDQAgACABIAJBBhECAAsALwlwcm9kdWNlcnMBDHByb2Nlc3NlZC1ieQENd2l0LWNvbXBvbmVudAcwLjIxMC4wAK4DBG5hbWUAExJ3aXQtY29tcG9uZW50OnNoaW0BkQMHACNpbmRpcmVjdC1hcmNqZXQ6anMtcmVxL2xvZ2dlci1kZWJ1ZwEjaW5kaXJlY3QtYXJjamV0OmpzLXJlcS9sb2dnZXItZXJyb3ICPmluZGlyZWN0LWFyY2pldDpqcy1yZXEvZW1haWwtdmFsaWRhdG9yLW92ZXJyaWRlcy1pcy1mcmVlLWVtYWlsA0RpbmRpcmVjdC1hcmNqZXQ6anMtcmVxL2VtYWlsLXZhbGlkYXRvci1vdmVycmlkZXMtaXMtZGlzcG9zYWJsZS1lbWFpbAQ/aW5kaXJlY3QtYXJjamV0OmpzLXJlcS9lbWFpbC12YWxpZGF0b3Itb3ZlcnJpZGVzLWhhcy1teC1yZWNvcmRzBT1pbmRpcmVjdC1hcmNqZXQ6anMtcmVxL2VtYWlsLXZhbGlkYXRvci1vdmVycmlkZXMtaGFzLWdyYXZhdGFyBj5pbmRpcmVjdC1hcmNqZXQ6anMtcmVxL3NlbnNpdGl2ZS1pbmZvcm1hdGlvbi1pZGVudGlmaWVyLWRldGVjdA==";
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,AGFzbQEAAAABDAJgAn9/AGACf38BfwIuBwABMAAAAAExAAAAATIAAQABMwABAAE0AAEAATUAAQAIJGltcG9ydHMBcAEGBgkMAQBBAAsGAAECAwQFAC8JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQHMC4yMTAuMAAcBG5hbWUAFRR3aXQtY29tcG9uZW50OmZpeHVwcw==";
27
+ const wasmBase64 = "data:application/wasm;base64,AGFzbQEAAAABEgNgAn9/AGACf38Bf2ADf39/AAIzCAABMAAAAAExAAAAATIAAQABMwABAAE0AAEAATUAAQABNgACAAgkaW1wb3J0cwFwAQcHCQ0BAEEACwcAAQIDBAUGAC8JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQHMC4yMTAuMAAcBG5hbWUAFRR3aXQtY29tcG9uZW50OmZpeHVwcw==";
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,9 +1,11 @@
1
1
  import type { ArcjetLogger, ArcjetRequestDetails } from "@arcjet/protocol";
2
- import type { EmailValidationConfig, BotDetectionResult, BotType, EmailValidationResult } from "./wasm/arcjet_analyze_js_req.component.js";
2
+ import type { EmailValidationConfig, BotDetectionResult, BotType, EmailValidationResult, DetectedSensitiveInfoEntity, SensitiveInfoEntities, SensitiveInfoEntity, SensitiveInfoResult } from "./wasm/arcjet_analyze_js_req.component.js";
3
+ import type { ArcjetJsReqSensitiveInformationIdentifier } from "./wasm/interfaces/arcjet-js-req-sensitive-information-identifier.js";
3
4
  interface AnalyzeContext {
4
5
  log: ArcjetLogger;
5
6
  characteristics: string[];
6
7
  }
8
+ type DetectSensitiveInfoFunction = typeof ArcjetJsReqSensitiveInformationIdentifier.detect;
7
9
  export { type EmailValidationConfig, type BotType,
8
10
  /**
9
11
  * Represents the result of the bot detection.
@@ -17,7 +19,7 @@ export { type EmailValidationConfig, type BotType,
17
19
  * confidence level. `BotType.LikelyNotABot` with a score of 99 means we are
18
20
  * almost certain this request was not a bot.
19
21
  */
20
- type BotDetectionResult, };
22
+ type BotDetectionResult, type DetectedSensitiveInfoEntity, type SensitiveInfoEntity, type DetectSensitiveInfoFunction, };
21
23
  /**
22
24
  * Generate a fingerprint for the client. This is used to identify the client
23
25
  * across multiple requests.
@@ -28,3 +30,4 @@ type BotDetectionResult, };
28
30
  export declare function generateFingerprint(context: AnalyzeContext, request: Partial<ArcjetRequestDetails>): Promise<string>;
29
31
  export declare function isValidEmail(context: AnalyzeContext, candidate: string, options?: EmailValidationConfig): Promise<EmailValidationResult>;
30
32
  export declare function detectBot(context: AnalyzeContext, headers: string, patterns_add: string, patterns_remove: string): Promise<BotDetectionResult>;
33
+ export declare function detectSensitiveInfo(context: AnalyzeContext, candidate: string, entities: SensitiveInfoEntities, contextWindowSize: number, detect?: DetectSensitiveInfoFunction): Promise<SensitiveInfoResult>;
package/edge-light.js CHANGED
@@ -22,8 +22,14 @@ async function moduleFromPath(path) {
22
22
  }
23
23
  throw new Error(`Unknown path: ${path}`);
24
24
  }
25
- async function init(context) {
25
+ function noOpDetect() {
26
+ return [];
27
+ }
28
+ async function init(context, detectSensitiveInfo) {
26
29
  const { log } = context;
30
+ if (typeof detectSensitiveInfo !== "function") {
31
+ detectSensitiveInfo = noOpDetect;
32
+ }
27
33
  const coreImports = {
28
34
  "arcjet:js-req/logger": {
29
35
  debug(msg) {
@@ -50,6 +56,9 @@ async function init(context) {
50
56
  return "unknown";
51
57
  },
52
58
  },
59
+ "arcjet:js-req/sensitive-information-identifier": {
60
+ detect: detectSensitiveInfo,
61
+ },
53
62
  };
54
63
  try {
55
64
  return instantiate(moduleFromPath, coreImports);
@@ -104,5 +113,19 @@ async function detectBot(context, headers, patterns_add, patterns_remove) {
104
113
  };
105
114
  }
106
115
  }
116
+ async function detectSensitiveInfo(context, candidate, entities, contextWindowSize, detect) {
117
+ const analyze = await init(context, detect);
118
+ if (typeof analyze !== "undefined") {
119
+ const skipCustomDetect = typeof detect !== "function";
120
+ return analyze.detectSensitiveInfo(candidate, {
121
+ entities,
122
+ contextWindowSize,
123
+ skipCustomDetect,
124
+ });
125
+ }
126
+ else {
127
+ throw new Error("SENSITIVE_INFO rule failed to run because Wasm is not supported in this environment.");
128
+ }
129
+ }
107
130
 
108
- export { detectBot, generateFingerprint, isValidEmail };
131
+ export { detectBot, detectSensitiveInfo, generateFingerprint, isValidEmail };
package/edge-light.ts CHANGED
@@ -1,13 +1,18 @@
1
1
  import type { ArcjetLogger, ArcjetRequestDetails } from "@arcjet/protocol";
2
2
 
3
- import * as core from "./wasm/arcjet_analyze_js_req.component.js";
3
+ import { instantiate } from "./wasm/arcjet_analyze_js_req.component.js";
4
4
  import type {
5
5
  ImportObject,
6
6
  EmailValidationConfig,
7
7
  BotDetectionResult,
8
8
  BotType,
9
9
  EmailValidationResult,
10
+ DetectedSensitiveInfoEntity,
11
+ SensitiveInfoEntities,
12
+ SensitiveInfoEntity,
13
+ SensitiveInfoResult,
10
14
  } from "./wasm/arcjet_analyze_js_req.component.js";
15
+ import type { ArcjetJsReqSensitiveInformationIdentifier } from "./wasm/interfaces/arcjet-js-req-sensitive-information-identifier.js";
11
16
 
12
17
  import componentCoreWasm from "./wasm/arcjet_analyze_js_req.component.core.wasm?module";
13
18
  import componentCore2Wasm from "./wasm/arcjet_analyze_js_req.component.core2.wasm?module";
@@ -26,6 +31,9 @@ interface AnalyzeContext {
26
31
  characteristics: string[];
27
32
  }
28
33
 
34
+ type DetectSensitiveInfoFunction =
35
+ typeof ArcjetJsReqSensitiveInformationIdentifier.detect;
36
+
29
37
  async function moduleFromPath(path: string): Promise<WebAssembly.Module> {
30
38
  if (path === "arcjet_analyze_js_req.component.core.wasm") {
31
39
  return componentCoreWasm;
@@ -40,9 +48,20 @@ async function moduleFromPath(path: string): Promise<WebAssembly.Module> {
40
48
  throw new Error(`Unknown path: ${path}`);
41
49
  }
42
50
 
43
- async function init(context: AnalyzeContext) {
51
+ function noOpDetect(): SensitiveInfoEntity[] {
52
+ return [];
53
+ }
54
+
55
+ async function init(
56
+ context: AnalyzeContext,
57
+ detectSensitiveInfo?: DetectSensitiveInfoFunction,
58
+ ) {
44
59
  const { log } = context;
45
60
 
61
+ if (typeof detectSensitiveInfo !== "function") {
62
+ detectSensitiveInfo = noOpDetect;
63
+ }
64
+
46
65
  const coreImports: ImportObject = {
47
66
  "arcjet:js-req/logger": {
48
67
  debug(msg) {
@@ -69,10 +88,13 @@ async function init(context: AnalyzeContext) {
69
88
  return "unknown";
70
89
  },
71
90
  },
91
+ "arcjet:js-req/sensitive-information-identifier": {
92
+ detect: detectSensitiveInfo,
93
+ },
72
94
  };
73
95
 
74
96
  try {
75
- return core.instantiate(moduleFromPath, coreImports);
97
+ return instantiate(moduleFromPath, coreImports);
76
98
  } catch {
77
99
  log.debug("WebAssembly is not supported in this runtime");
78
100
  }
@@ -94,6 +116,9 @@ export {
94
116
  * almost certain this request was not a bot.
95
117
  */
96
118
  type BotDetectionResult,
119
+ type DetectedSensitiveInfoEntity,
120
+ type SensitiveInfoEntity,
121
+ type DetectSensitiveInfoFunction,
97
122
  };
98
123
 
99
124
  /**
@@ -161,3 +186,25 @@ export async function detectBot(
161
186
  };
162
187
  }
163
188
  }
189
+ export async function detectSensitiveInfo(
190
+ context: AnalyzeContext,
191
+ candidate: string,
192
+ entities: SensitiveInfoEntities,
193
+ contextWindowSize: number,
194
+ detect?: DetectSensitiveInfoFunction,
195
+ ): Promise<SensitiveInfoResult> {
196
+ const analyze = await init(context, detect);
197
+
198
+ if (typeof analyze !== "undefined") {
199
+ const skipCustomDetect = typeof detect !== "function";
200
+ return analyze.detectSensitiveInfo(candidate, {
201
+ entities,
202
+ contextWindowSize,
203
+ skipCustomDetect,
204
+ });
205
+ } else {
206
+ throw new Error(
207
+ "SENSITIVE_INFO rule failed to run because Wasm is not supported in this environment.",
208
+ );
209
+ }
210
+ }
package/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import type { ArcjetLogger, ArcjetRequestDetails } from "@arcjet/protocol";
2
- import type { EmailValidationConfig, BotDetectionResult, BotType, EmailValidationResult } from "./wasm/arcjet_analyze_js_req.component.js";
2
+ import type { EmailValidationConfig, BotDetectionResult, BotType, EmailValidationResult, DetectedSensitiveInfoEntity, SensitiveInfoEntities, SensitiveInfoEntity, SensitiveInfoResult } from "./wasm/arcjet_analyze_js_req.component.js";
3
+ import type { ArcjetJsReqSensitiveInformationIdentifier } from "./wasm/interfaces/arcjet-js-req-sensitive-information-identifier.js";
3
4
  interface AnalyzeContext {
4
5
  log: ArcjetLogger;
5
6
  characteristics: string[];
6
7
  }
8
+ type DetectSensitiveInfoFunction = typeof ArcjetJsReqSensitiveInformationIdentifier.detect;
7
9
  export { type EmailValidationConfig, type BotType,
8
10
  /**
9
11
  * Represents the result of the bot detection.
@@ -17,7 +19,7 @@ export { type EmailValidationConfig, type BotType,
17
19
  * confidence level. `BotType.LikelyNotABot` with a score of 99 means we are
18
20
  * almost certain this request was not a bot.
19
21
  */
20
- type BotDetectionResult, };
22
+ type BotDetectionResult, type DetectedSensitiveInfoEntity, type SensitiveInfoEntity, type DetectSensitiveInfoFunction, };
21
23
  /**
22
24
  * Generate a fingerprint for the client. This is used to identify the client
23
25
  * across multiple requests.
@@ -28,3 +30,4 @@ type BotDetectionResult, };
28
30
  export declare function generateFingerprint(context: AnalyzeContext, request: Partial<ArcjetRequestDetails>): Promise<string>;
29
31
  export declare function isValidEmail(context: AnalyzeContext, candidate: string, options?: EmailValidationConfig): Promise<EmailValidationResult>;
30
32
  export declare function detectBot(context: AnalyzeContext, headers: string, patterns_add: string, patterns_remove: string): Promise<BotDetectionResult>;
33
+ export declare function detectSensitiveInfo(context: AnalyzeContext, candidate: string, entities: SensitiveInfoEntities, contextWindowSize: number, detect?: DetectSensitiveInfoFunction): Promise<SensitiveInfoResult>;
package/index.js CHANGED
@@ -34,8 +34,14 @@ async function moduleFromPath(path) {
34
34
  }
35
35
  throw new Error(`Unknown path: ${path}`);
36
36
  }
37
- async function init(context) {
37
+ function noOpDetect() {
38
+ return [];
39
+ }
40
+ async function init(context, detectSensitiveInfo) {
38
41
  const { log } = context;
42
+ if (typeof detectSensitiveInfo !== "function") {
43
+ detectSensitiveInfo = noOpDetect;
44
+ }
39
45
  const coreImports = {
40
46
  "arcjet:js-req/logger": {
41
47
  debug(msg) {
@@ -62,6 +68,9 @@ async function init(context) {
62
68
  return "unknown";
63
69
  },
64
70
  },
71
+ "arcjet:js-req/sensitive-information-identifier": {
72
+ detect: detectSensitiveInfo,
73
+ },
65
74
  };
66
75
  try {
67
76
  return instantiate(moduleFromPath, coreImports);
@@ -116,5 +125,19 @@ async function detectBot(context, headers, patterns_add, patterns_remove) {
116
125
  };
117
126
  }
118
127
  }
128
+ async function detectSensitiveInfo(context, candidate, entities, contextWindowSize, detect) {
129
+ const analyze = await init(context, detect);
130
+ if (typeof analyze !== "undefined") {
131
+ const skipCustomDetect = typeof detect !== "function";
132
+ return analyze.detectSensitiveInfo(candidate, {
133
+ entities,
134
+ contextWindowSize,
135
+ skipCustomDetect,
136
+ });
137
+ }
138
+ else {
139
+ throw new Error("SENSITIVE_INFO rule failed to run because Wasm is not supported in this environment.");
140
+ }
141
+ }
119
142
 
120
- export { detectBot, generateFingerprint, isValidEmail };
143
+ export { detectBot, detectSensitiveInfo, generateFingerprint, isValidEmail };
package/index.ts CHANGED
@@ -1,13 +1,18 @@
1
1
  import type { ArcjetLogger, ArcjetRequestDetails } from "@arcjet/protocol";
2
2
 
3
- import * as core from "./wasm/arcjet_analyze_js_req.component.js";
3
+ import { instantiate } from "./wasm/arcjet_analyze_js_req.component.js";
4
4
  import type {
5
5
  ImportObject,
6
6
  EmailValidationConfig,
7
7
  BotDetectionResult,
8
8
  BotType,
9
9
  EmailValidationResult,
10
+ DetectedSensitiveInfoEntity,
11
+ SensitiveInfoEntities,
12
+ SensitiveInfoEntity,
13
+ SensitiveInfoResult,
10
14
  } from "./wasm/arcjet_analyze_js_req.component.js";
15
+ import type { ArcjetJsReqSensitiveInformationIdentifier } from "./wasm/interfaces/arcjet-js-req-sensitive-information-identifier.js";
11
16
 
12
17
  import { wasm as componentCoreWasm } from "./wasm/arcjet_analyze_js_req.component.core.wasm?js";
13
18
  import { wasm as componentCore2Wasm } from "./wasm/arcjet_analyze_js_req.component.core2.wasm?js";
@@ -26,6 +31,9 @@ interface AnalyzeContext {
26
31
  characteristics: string[];
27
32
  }
28
33
 
34
+ type DetectSensitiveInfoFunction =
35
+ typeof ArcjetJsReqSensitiveInformationIdentifier.detect;
36
+
29
37
  // TODO: Do we actually need this wasmCache or does `import` cache correctly?
30
38
  const wasmCache = new Map<string, WebAssembly.Module>();
31
39
 
@@ -54,9 +62,20 @@ async function moduleFromPath(path: string): Promise<WebAssembly.Module> {
54
62
  throw new Error(`Unknown path: ${path}`);
55
63
  }
56
64
 
57
- async function init(context: AnalyzeContext) {
65
+ function noOpDetect(): SensitiveInfoEntity[] {
66
+ return [];
67
+ }
68
+
69
+ async function init(
70
+ context: AnalyzeContext,
71
+ detectSensitiveInfo?: DetectSensitiveInfoFunction,
72
+ ) {
58
73
  const { log } = context;
59
74
 
75
+ if (typeof detectSensitiveInfo !== "function") {
76
+ detectSensitiveInfo = noOpDetect;
77
+ }
78
+
60
79
  const coreImports: ImportObject = {
61
80
  "arcjet:js-req/logger": {
62
81
  debug(msg) {
@@ -83,10 +102,13 @@ async function init(context: AnalyzeContext) {
83
102
  return "unknown";
84
103
  },
85
104
  },
105
+ "arcjet:js-req/sensitive-information-identifier": {
106
+ detect: detectSensitiveInfo,
107
+ },
86
108
  };
87
109
 
88
110
  try {
89
- return core.instantiate(moduleFromPath, coreImports);
111
+ return instantiate(moduleFromPath, coreImports);
90
112
  } catch {
91
113
  log.debug("WebAssembly is not supported in this runtime");
92
114
  }
@@ -108,6 +130,9 @@ export {
108
130
  * almost certain this request was not a bot.
109
131
  */
110
132
  type BotDetectionResult,
133
+ type DetectedSensitiveInfoEntity,
134
+ type SensitiveInfoEntity,
135
+ type DetectSensitiveInfoFunction,
111
136
  };
112
137
 
113
138
  /**
@@ -175,3 +200,26 @@ export async function detectBot(
175
200
  };
176
201
  }
177
202
  }
203
+
204
+ export async function detectSensitiveInfo(
205
+ context: AnalyzeContext,
206
+ candidate: string,
207
+ entities: SensitiveInfoEntities,
208
+ contextWindowSize: number,
209
+ detect?: DetectSensitiveInfoFunction,
210
+ ): Promise<SensitiveInfoResult> {
211
+ const analyze = await init(context, detect);
212
+
213
+ if (typeof analyze !== "undefined") {
214
+ const skipCustomDetect = typeof detect !== "function";
215
+ return analyze.detectSensitiveInfo(candidate, {
216
+ entities,
217
+ contextWindowSize,
218
+ skipCustomDetect,
219
+ });
220
+ } else {
221
+ throw new Error(
222
+ "SENSITIVE_INFO rule failed to run because Wasm is not supported in this environment.",
223
+ );
224
+ }
225
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcjet/analyze",
3
- "version": "1.0.0-alpha.21",
3
+ "version": "1.0.0-alpha.22",
4
4
  "description": "Arcjet local analysis engine",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://arcjet.com",
@@ -51,15 +51,15 @@
51
51
  "./wasm/arcjet_analyze_js_req_bg.js"
52
52
  ],
53
53
  "dependencies": {
54
- "@arcjet/protocol": "1.0.0-alpha.21"
54
+ "@arcjet/protocol": "1.0.0-alpha.22"
55
55
  },
56
56
  "devDependencies": {
57
- "@arcjet/eslint-config": "1.0.0-alpha.21",
58
- "@arcjet/rollup-config": "1.0.0-alpha.21",
59
- "@arcjet/tsconfig": "1.0.0-alpha.21",
60
- "@bytecodealliance/jco": "1.2.4",
57
+ "@arcjet/eslint-config": "1.0.0-alpha.22",
58
+ "@arcjet/rollup-config": "1.0.0-alpha.22",
59
+ "@arcjet/tsconfig": "1.0.0-alpha.22",
60
+ "@bytecodealliance/jco": "1.4.4",
61
61
  "@jest/globals": "29.7.0",
62
- "@rollup/wasm-node": "4.20.0",
62
+ "@rollup/wasm-node": "4.21.0",
63
63
  "@types/node": "18.18.0",
64
64
  "jest": "29.7.0",
65
65
  "typescript": "5.5.4"
@@ -1,3 +1,5 @@
1
+ import type { SensitiveInfoEntity } from './interfaces/arcjet-js-req-sensitive-information-identifier.js';
2
+ export { SensitiveInfoEntity };
1
3
  /**
2
4
  * # Variants
3
5
  *
@@ -28,23 +30,49 @@ export interface BotDetectionResult {
28
30
  export type EmailValidity = 'valid' | 'invalid';
29
31
  export interface EmailValidationResult {
30
32
  validity: EmailValidity,
31
- blocked: string[],
33
+ blocked: Array<string>,
32
34
  }
33
35
  export interface EmailValidationConfig {
34
36
  requireTopLevelDomain: boolean,
35
37
  allowDomainLiteral: boolean,
36
- blockedEmails: string[],
38
+ blockedEmails: Array<string>,
39
+ }
40
+ export type SensitiveInfoEntities = SensitiveInfoEntitiesAllow | SensitiveInfoEntitiesDeny;
41
+ export interface SensitiveInfoEntitiesAllow {
42
+ tag: 'allow',
43
+ val: Array<SensitiveInfoEntity>,
44
+ }
45
+ export interface SensitiveInfoEntitiesDeny {
46
+ tag: 'deny',
47
+ val: Array<SensitiveInfoEntity>,
48
+ }
49
+ export interface SensitiveInfoConfig {
50
+ entities: SensitiveInfoEntities,
51
+ contextWindowSize?: number,
52
+ skipCustomDetect: boolean,
53
+ }
54
+ export interface DetectedSensitiveInfoEntity {
55
+ start: number,
56
+ end: number,
57
+ identifiedType: SensitiveInfoEntity,
58
+ }
59
+ export interface SensitiveInfoResult {
60
+ allowed: Array<DetectedSensitiveInfoEntity>,
61
+ denied: Array<DetectedSensitiveInfoEntity>,
37
62
  }
38
63
  import { ArcjetJsReqEmailValidatorOverrides } from './interfaces/arcjet-js-req-email-validator-overrides.js';
39
64
  import { ArcjetJsReqLogger } from './interfaces/arcjet-js-req-logger.js';
65
+ import { ArcjetJsReqSensitiveInformationIdentifier } from './interfaces/arcjet-js-req-sensitive-information-identifier.js';
40
66
  export interface ImportObject {
41
67
  'arcjet:js-req/email-validator-overrides': typeof ArcjetJsReqEmailValidatorOverrides,
42
68
  'arcjet:js-req/logger': typeof ArcjetJsReqLogger,
69
+ 'arcjet:js-req/sensitive-information-identifier': typeof ArcjetJsReqSensitiveInformationIdentifier,
43
70
  }
44
71
  export interface Root {
45
72
  detectBot(headers: string, patternsAdd: string, patternsRemove: string): BotDetectionResult,
46
- generateFingerprint(request: string, characteristics: string[]): string,
73
+ generateFingerprint(request: string, characteristics: Array<string>): string,
47
74
  isValidEmail(candidate: string, options: EmailValidationConfig): EmailValidationResult,
75
+ detectSensitiveInfo(content: string, options: SensitiveInfoConfig): SensitiveInfoResult,
48
76
  }
49
77
 
50
78
  /**
@@ -67,8 +95,13 @@ export interface Root {
67
95
  * on the web, for example.
68
96
  */
69
97
  export function instantiate(
70
- getCoreModule: (path: string) => Promise<WebAssembly.Module>,
98
+ getCoreModule: (path: string) => WebAssembly.Module,
99
+ imports: ImportObject,
100
+ instantiateCore?: (module: WebAssembly.Module, imports: Record<string, any>) => WebAssembly.Instance
101
+ ): Root;
102
+ export function instantiate(
103
+ getCoreModule: (path: string) => WebAssembly.Module | Promise<WebAssembly.Module>,
71
104
  imports: ImportObject,
72
- instantiateCore?: (module: WebAssembly.Module, imports: Record<string, any>) => Promise<WebAssembly.Instance>
73
- ): Promise<Root>;
105
+ instantiateCore?: (module: WebAssembly.Module, imports: Record<string, any>) => WebAssembly.Instance | Promise<WebAssembly.Instance>
106
+ ): Root | Promise<Root>;
74
107