@arcjet/analyze-wasm 1.0.0-beta.1 → 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.
- package/README.md +45 -22
- package/_virtual/arcjet_analyze_js_req.component.core.js +1 -1
- package/_virtual/arcjet_analyze_js_req.component.core2.js +1 -1
- package/_virtual/arcjet_analyze_js_req.component.core3.js +1 -1
- package/index.js +1 -0
- package/package.json +29 -18
- package/wasm/arcjet_analyze_js_req.component.core.wasm +0 -0
- package/wasm/arcjet_analyze_js_req.component.core2.wasm +0 -0
- package/wasm/arcjet_analyze_js_req.component.core3.wasm +0 -0
- package/wasm/arcjet_analyze_js_req.component.d.ts +4 -1
- package/wasm/arcjet_analyze_js_req.component.js +40 -15
- package/wasm/arcjet_analyze_js_req.component.wasm +0 -0
- package/wasm/interfaces/arcjet-js-req-bot-identifier.d.ts +4 -0
- package/edge-light.ts +0 -55
- package/index.ts +0 -60
- package/wasm.d.ts +0 -28
- package/workerd.ts +0 -56
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* properly support consistent asset bundling techniques.
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
const wasmBase64 = "data:application/wasm;base64,
|
|
27
|
+
const wasmBase64 = "data:application/wasm;base64,AGFzbQEAAAABFQNgA39/fwBgBH9/f38Bf2ACf38BfwMIBwABAgICAgAEBQFwAQcHBygIATAAAAExAAEBMgACATMAAwE0AAQBNQAFATYABggkaW1wb3J0cwEACl0HDQAgACABIAJBABEAAAsPACAAIAEgAiADQQERAQALCwAgACABQQIRAgALCwAgACABQQMRAgALCwAgACABQQQRAgALCwAgACABQQURAgALDQAgACABIAJBBhEAAAsALwlwcm9kdWNlcnMBDHByb2Nlc3NlZC1ieQENd2l0LWNvbXBvbmVudAcwLjIzMC4wALwDBG5hbWUAExJ3aXQtY29tcG9uZW50OnNoaW0BnwMHACxpbmRpcmVjdC1hcmNqZXQ6anMtcmVxL2JvdC1pZGVudGlmaWVyLWRldGVjdAEoaW5kaXJlY3QtYXJjamV0OmpzLXJlcS92ZXJpZnktYm90LXZlcmlmeQI+aW5kaXJlY3QtYXJjamV0OmpzLXJlcS9lbWFpbC12YWxpZGF0b3Itb3ZlcnJpZGVzLWlzLWZyZWUtZW1haWwDRGluZGlyZWN0LWFyY2pldDpqcy1yZXEvZW1haWwtdmFsaWRhdG9yLW92ZXJyaWRlcy1pcy1kaXNwb3NhYmxlLWVtYWlsBD9pbmRpcmVjdC1hcmNqZXQ6anMtcmVxL2VtYWlsLXZhbGlkYXRvci1vdmVycmlkZXMtaGFzLW14LXJlY29yZHMFPWluZGlyZWN0LWFyY2pldDpqcy1yZXEvZW1haWwtdmFsaWRhdG9yLW92ZXJyaWRlcy1oYXMtZ3JhdmF0YXIGPmluZGlyZWN0LWFyY2pldDpqcy1yZXEvc2Vuc2l0aXZlLWluZm9ybWF0aW9uLWlkZW50aWZpZXItZGV0ZWN0";
|
|
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,
|
|
27
|
+
const wasmBase64 = "data:application/wasm;base64,AGFzbQEAAAABFQNgA39/fwBgBH9/f38Bf2ACf38BfwIzCAABMAAAAAExAAEAATIAAgABMwACAAE0AAIAATUAAgABNgAAAAgkaW1wb3J0cwFwAQcHCQ0BAEEACwcAAQIDBAUGAC8JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQHMC4yMzAuMAAcBG5hbWUAFRR3aXQtY29tcG9uZW50OmZpeHVwcw==";
|
|
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
|
@@ -16,6 +16,7 @@ async function moduleFromPath(path) {
|
|
|
16
16
|
if (path === "arcjet_analyze_js_req.component.core3.wasm") {
|
|
17
17
|
return componentCore3WasmPromise;
|
|
18
18
|
}
|
|
19
|
+
// TODO(@wooorm-arcjet): figure out a test case that makes this throw.
|
|
19
20
|
throw new Error(`Unknown path: ${path}`);
|
|
20
21
|
}
|
|
21
22
|
async function initializeWasm(coreImports) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcjet/analyze-wasm",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.10",
|
|
4
4
|
"description": "WebAssembly bindings to Arcjet's local analysis engine",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"analyze",
|
|
7
|
+
"arcjet",
|
|
8
|
+
"attack",
|
|
9
|
+
"limit",
|
|
10
|
+
"protect",
|
|
11
|
+
"verify",
|
|
12
|
+
"wasm"
|
|
13
|
+
],
|
|
5
14
|
"license": "Apache-2.0",
|
|
6
15
|
"homepage": "https://arcjet.com",
|
|
7
16
|
"repository": {
|
|
@@ -30,33 +39,35 @@
|
|
|
30
39
|
"default": "./index.js"
|
|
31
40
|
},
|
|
32
41
|
"files": [
|
|
33
|
-
"LICENSE",
|
|
34
|
-
"README.md",
|
|
35
42
|
"_virtual/",
|
|
36
43
|
"wasm/",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
44
|
+
"edge-light.d.ts",
|
|
45
|
+
"edge-light.js",
|
|
46
|
+
"index.d.ts",
|
|
47
|
+
"index.js",
|
|
48
|
+
"workerd.d.ts",
|
|
49
|
+
"workerd.js"
|
|
41
50
|
],
|
|
42
51
|
"scripts": {
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"build": "npm run jco
|
|
52
|
+
"build:jco": "jco transpile --instantiation async --no-wasi-shim --out-dir wasm/ -- wasm/arcjet_analyze_js_req.component.wasm",
|
|
53
|
+
"build:rollup": "rollup --config rollup.config.js",
|
|
54
|
+
"build": "npm run build:jco && npm run build:rollup",
|
|
46
55
|
"lint": "eslint .",
|
|
47
|
-
"
|
|
48
|
-
"test": "node --test"
|
|
56
|
+
"prepublishOnly": "npm run build",
|
|
57
|
+
"test-api": "node --test",
|
|
58
|
+
"test-coverage": "node --experimental-test-coverage --test",
|
|
59
|
+
"test": "npm run build && npm run lint && npm run test-coverage"
|
|
49
60
|
},
|
|
50
61
|
"dependencies": {},
|
|
51
62
|
"devDependencies": {
|
|
52
|
-
"@arcjet/eslint-config": "1.0.0-beta.
|
|
53
|
-
"@arcjet/rollup-config": "1.0.0-beta.
|
|
54
|
-
"@arcjet/tsconfig": "1.0.0-beta.
|
|
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",
|
|
55
66
|
"@bytecodealliance/jco": "1.5.0",
|
|
56
|
-
"@rollup/wasm-node": "4.
|
|
67
|
+
"@rollup/wasm-node": "4.46.2",
|
|
57
68
|
"@types/node": "18.18.0",
|
|
58
|
-
"
|
|
59
|
-
"typescript": "5.
|
|
69
|
+
"eslint": "9.32.0",
|
|
70
|
+
"typescript": "5.9.2"
|
|
60
71
|
},
|
|
61
72
|
"publishConfig": {
|
|
62
73
|
"access": "public",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { SensitiveInfoEntity } from './interfaces/arcjet-js-req-sensitive-information-identifier.js';
|
|
2
2
|
export { SensitiveInfoEntity };
|
|
3
|
+
import type { BotEntity } from './interfaces/arcjet-js-req-bot-identifier.js';
|
|
4
|
+
export { BotEntity };
|
|
3
5
|
/**
|
|
4
6
|
* # Variants
|
|
5
7
|
*
|
|
@@ -54,7 +56,6 @@ export interface SensitiveInfoResult {
|
|
|
54
56
|
allowed: Array<DetectedSensitiveInfoEntity>,
|
|
55
57
|
denied: Array<DetectedSensitiveInfoEntity>,
|
|
56
58
|
}
|
|
57
|
-
export type BotEntity = string;
|
|
58
59
|
export interface AllowedBotConfig {
|
|
59
60
|
entities: Array<BotEntity>,
|
|
60
61
|
skipCustomDetect: boolean,
|
|
@@ -78,10 +79,12 @@ export interface BotResult {
|
|
|
78
79
|
verified: boolean,
|
|
79
80
|
spoofed: boolean,
|
|
80
81
|
}
|
|
82
|
+
import { ArcjetJsReqBotIdentifier } from './interfaces/arcjet-js-req-bot-identifier.js';
|
|
81
83
|
import { ArcjetJsReqEmailValidatorOverrides } from './interfaces/arcjet-js-req-email-validator-overrides.js';
|
|
82
84
|
import { ArcjetJsReqSensitiveInformationIdentifier } from './interfaces/arcjet-js-req-sensitive-information-identifier.js';
|
|
83
85
|
import { ArcjetJsReqVerifyBot } from './interfaces/arcjet-js-req-verify-bot.js';
|
|
84
86
|
export interface ImportObject {
|
|
87
|
+
'arcjet:js-req/bot-identifier': typeof ArcjetJsReqBotIdentifier,
|
|
85
88
|
'arcjet:js-req/email-validator-overrides': typeof ArcjetJsReqEmailValidatorOverrides,
|
|
86
89
|
'arcjet:js-req/sensitive-information-identifier': typeof ArcjetJsReqSensitiveInformationIdentifier,
|
|
87
90
|
'arcjet:js-req/verify-bot': typeof ArcjetJsReqVerifyBot,
|
|
@@ -42,8 +42,9 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
42
42
|
const module1 = getCoreModule('arcjet_analyze_js_req.component.core2.wasm');
|
|
43
43
|
const module2 = getCoreModule('arcjet_analyze_js_req.component.core3.wasm');
|
|
44
44
|
|
|
45
|
+
const { detect } = imports['arcjet:js-req/bot-identifier'];
|
|
45
46
|
const { hasGravatar, hasMxRecords, isDisposableEmail, isFreeEmail } = imports['arcjet:js-req/email-validator-overrides'];
|
|
46
|
-
const { detect } = imports['arcjet:js-req/sensitive-information-identifier'];
|
|
47
|
+
const { detect: detect$1 } = imports['arcjet:js-req/sensitive-information-identifier'];
|
|
47
48
|
const { verify } = imports['arcjet:js-req/verify-bot'];
|
|
48
49
|
let gen = (function* init () {
|
|
49
50
|
let exports0;
|
|
@@ -51,7 +52,26 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
51
52
|
let memory0;
|
|
52
53
|
let realloc0;
|
|
53
54
|
|
|
54
|
-
function trampoline0(arg0, arg1, arg2
|
|
55
|
+
function trampoline0(arg0, arg1, arg2) {
|
|
56
|
+
var ptr0 = arg0;
|
|
57
|
+
var len0 = arg1;
|
|
58
|
+
var result0 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr0, len0));
|
|
59
|
+
const ret = detect(result0);
|
|
60
|
+
var vec2 = ret;
|
|
61
|
+
var len2 = vec2.length;
|
|
62
|
+
var result2 = realloc0(0, 0, 4, len2 * 8);
|
|
63
|
+
for (let i = 0; i < vec2.length; i++) {
|
|
64
|
+
const e = vec2[i];
|
|
65
|
+
const base = result2 + i * 8;var ptr1 = utf8Encode(e, realloc0, memory0);
|
|
66
|
+
var len1 = utf8EncodedLen;
|
|
67
|
+
dataView(memory0).setInt32(base + 4, len1, true);
|
|
68
|
+
dataView(memory0).setInt32(base + 0, ptr1, true);
|
|
69
|
+
}
|
|
70
|
+
dataView(memory0).setInt32(arg2 + 4, len2, true);
|
|
71
|
+
dataView(memory0).setInt32(arg2 + 0, result2, true);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function trampoline1(arg0, arg1, arg2, arg3) {
|
|
55
75
|
var ptr0 = arg0;
|
|
56
76
|
var len0 = arg1;
|
|
57
77
|
var result0 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr0, len0));
|
|
@@ -85,7 +105,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
85
105
|
return enum2;
|
|
86
106
|
}
|
|
87
107
|
|
|
88
|
-
function
|
|
108
|
+
function trampoline2(arg0, arg1) {
|
|
89
109
|
var ptr0 = arg0;
|
|
90
110
|
var len0 = arg1;
|
|
91
111
|
var result0 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr0, len0));
|
|
@@ -116,7 +136,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
116
136
|
return enum1;
|
|
117
137
|
}
|
|
118
138
|
|
|
119
|
-
function
|
|
139
|
+
function trampoline3(arg0, arg1) {
|
|
120
140
|
var ptr0 = arg0;
|
|
121
141
|
var len0 = arg1;
|
|
122
142
|
var result0 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr0, len0));
|
|
@@ -147,7 +167,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
147
167
|
return enum1;
|
|
148
168
|
}
|
|
149
169
|
|
|
150
|
-
function
|
|
170
|
+
function trampoline4(arg0, arg1) {
|
|
151
171
|
var ptr0 = arg0;
|
|
152
172
|
var len0 = arg1;
|
|
153
173
|
var result0 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr0, len0));
|
|
@@ -178,7 +198,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
178
198
|
return enum1;
|
|
179
199
|
}
|
|
180
200
|
|
|
181
|
-
function
|
|
201
|
+
function trampoline5(arg0, arg1) {
|
|
182
202
|
var ptr0 = arg0;
|
|
183
203
|
var len0 = arg1;
|
|
184
204
|
var result0 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr0, len0));
|
|
@@ -209,7 +229,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
209
229
|
return enum1;
|
|
210
230
|
}
|
|
211
231
|
|
|
212
|
-
function
|
|
232
|
+
function trampoline6(arg0, arg1, arg2) {
|
|
213
233
|
var len1 = arg1;
|
|
214
234
|
var base1 = arg0;
|
|
215
235
|
var result1 = [];
|
|
@@ -220,7 +240,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
220
240
|
var result0 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr0, len0));
|
|
221
241
|
result1.push(result0);
|
|
222
242
|
}
|
|
223
|
-
const ret = detect(result1);
|
|
243
|
+
const ret = detect$1(result1);
|
|
224
244
|
var vec5 = ret;
|
|
225
245
|
var len5 = vec5.length;
|
|
226
246
|
var result5 = realloc0(0, 0, 4, len5 * 16);
|
|
@@ -268,6 +288,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
268
288
|
dataView(memory0).setInt32(arg2 + 4, len5, true);
|
|
269
289
|
dataView(memory0).setInt32(arg2 + 0, result5, true);
|
|
270
290
|
}
|
|
291
|
+
let exports2;
|
|
271
292
|
let postReturn0;
|
|
272
293
|
let postReturn1;
|
|
273
294
|
let postReturn2;
|
|
@@ -276,22 +297,25 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
276
297
|
Promise.all([module0, module1, module2]).catch(() => {});
|
|
277
298
|
({ exports: exports0 } = yield instantiateCore(yield module1));
|
|
278
299
|
({ exports: exports1 } = yield instantiateCore(yield module0, {
|
|
300
|
+
'arcjet:js-req/bot-identifier': {
|
|
301
|
+
detect: exports0['0'],
|
|
302
|
+
},
|
|
279
303
|
'arcjet:js-req/email-validator-overrides': {
|
|
280
|
-
'has-gravatar': exports0['
|
|
281
|
-
'has-mx-records': exports0['
|
|
282
|
-
'is-disposable-email': exports0['
|
|
283
|
-
'is-free-email': exports0['
|
|
304
|
+
'has-gravatar': exports0['5'],
|
|
305
|
+
'has-mx-records': exports0['4'],
|
|
306
|
+
'is-disposable-email': exports0['3'],
|
|
307
|
+
'is-free-email': exports0['2'],
|
|
284
308
|
},
|
|
285
309
|
'arcjet:js-req/sensitive-information-identifier': {
|
|
286
|
-
detect: exports0['
|
|
310
|
+
detect: exports0['6'],
|
|
287
311
|
},
|
|
288
312
|
'arcjet:js-req/verify-bot': {
|
|
289
|
-
verify: exports0['
|
|
313
|
+
verify: exports0['1'],
|
|
290
314
|
},
|
|
291
315
|
}));
|
|
292
316
|
memory0 = exports1.memory;
|
|
293
317
|
realloc0 = exports1.cabi_realloc;
|
|
294
|
-
(yield instantiateCore(yield module2, {
|
|
318
|
+
({ exports: exports2 } = yield instantiateCore(yield module2, {
|
|
295
319
|
'': {
|
|
296
320
|
$imports: exports0.$imports,
|
|
297
321
|
'0': trampoline0,
|
|
@@ -300,6 +324,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
300
324
|
'3': trampoline3,
|
|
301
325
|
'4': trampoline4,
|
|
302
326
|
'5': trampoline5,
|
|
327
|
+
'6': trampoline6,
|
|
303
328
|
},
|
|
304
329
|
}));
|
|
305
330
|
postReturn0 = exports1['cabi_post_detect-bot'];
|
|
Binary file
|
package/edge-light.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { instantiate } from "./wasm/arcjet_analyze_js_req.component.js";
|
|
2
|
-
import type {
|
|
3
|
-
ImportObject,
|
|
4
|
-
DetectedSensitiveInfoEntity,
|
|
5
|
-
SensitiveInfoEntity,
|
|
6
|
-
BotConfig,
|
|
7
|
-
EmailValidationResult,
|
|
8
|
-
BotResult,
|
|
9
|
-
SensitiveInfoResult,
|
|
10
|
-
EmailValidationConfig,
|
|
11
|
-
SensitiveInfoEntities,
|
|
12
|
-
} from "./wasm/arcjet_analyze_js_req.component.js";
|
|
13
|
-
import type { ArcjetJsReqSensitiveInformationIdentifier } from "./wasm/interfaces/arcjet-js-req-sensitive-information-identifier.js";
|
|
14
|
-
|
|
15
|
-
import componentCoreWasm from "./wasm/arcjet_analyze_js_req.component.core.wasm?module";
|
|
16
|
-
import componentCore2Wasm from "./wasm/arcjet_analyze_js_req.component.core2.wasm?module";
|
|
17
|
-
import componentCore3Wasm from "./wasm/arcjet_analyze_js_req.component.core3.wasm?module";
|
|
18
|
-
|
|
19
|
-
type DetectSensitiveInfoFunction =
|
|
20
|
-
typeof ArcjetJsReqSensitiveInformationIdentifier.detect;
|
|
21
|
-
|
|
22
|
-
async function moduleFromPath(path: string): Promise<WebAssembly.Module> {
|
|
23
|
-
if (path === "arcjet_analyze_js_req.component.core.wasm") {
|
|
24
|
-
return componentCoreWasm;
|
|
25
|
-
}
|
|
26
|
-
if (path === "arcjet_analyze_js_req.component.core2.wasm") {
|
|
27
|
-
return componentCore2Wasm;
|
|
28
|
-
}
|
|
29
|
-
if (path === "arcjet_analyze_js_req.component.core3.wasm") {
|
|
30
|
-
return componentCore3Wasm;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
throw new Error(`Unknown path: ${path}`);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export async function initializeWasm(coreImports: ImportObject) {
|
|
37
|
-
try {
|
|
38
|
-
return instantiate(moduleFromPath, coreImports);
|
|
39
|
-
} catch {
|
|
40
|
-
return undefined;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export {
|
|
45
|
-
type BotConfig,
|
|
46
|
-
type DetectedSensitiveInfoEntity,
|
|
47
|
-
type SensitiveInfoEntity,
|
|
48
|
-
type EmailValidationConfig,
|
|
49
|
-
type EmailValidationResult,
|
|
50
|
-
type BotResult,
|
|
51
|
-
type SensitiveInfoResult,
|
|
52
|
-
type SensitiveInfoEntities,
|
|
53
|
-
type DetectSensitiveInfoFunction,
|
|
54
|
-
type ImportObject,
|
|
55
|
-
};
|
package/index.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { instantiate } from "./wasm/arcjet_analyze_js_req.component.js";
|
|
2
|
-
import type {
|
|
3
|
-
ImportObject,
|
|
4
|
-
BotConfig,
|
|
5
|
-
DetectedSensitiveInfoEntity,
|
|
6
|
-
SensitiveInfoEntity,
|
|
7
|
-
EmailValidationResult,
|
|
8
|
-
BotResult,
|
|
9
|
-
SensitiveInfoResult,
|
|
10
|
-
EmailValidationConfig,
|
|
11
|
-
SensitiveInfoEntities,
|
|
12
|
-
} from "./wasm/arcjet_analyze_js_req.component.js";
|
|
13
|
-
import type { ArcjetJsReqSensitiveInformationIdentifier } from "./wasm/interfaces/arcjet-js-req-sensitive-information-identifier.js";
|
|
14
|
-
|
|
15
|
-
import { wasm as componentCoreWasm } from "./wasm/arcjet_analyze_js_req.component.core.wasm?js";
|
|
16
|
-
import { wasm as componentCore2Wasm } from "./wasm/arcjet_analyze_js_req.component.core2.wasm?js";
|
|
17
|
-
import { wasm as componentCore3Wasm } from "./wasm/arcjet_analyze_js_req.component.core3.wasm?js";
|
|
18
|
-
|
|
19
|
-
type DetectSensitiveInfoFunction =
|
|
20
|
-
typeof ArcjetJsReqSensitiveInformationIdentifier.detect;
|
|
21
|
-
|
|
22
|
-
const componentCoreWasmPromise = componentCoreWasm();
|
|
23
|
-
const componentCore2WasmPromise = componentCore2Wasm();
|
|
24
|
-
const componentCore3WasmPromise = componentCore3Wasm();
|
|
25
|
-
|
|
26
|
-
async function moduleFromPath(path: string): Promise<WebAssembly.Module> {
|
|
27
|
-
if (path === "arcjet_analyze_js_req.component.core.wasm") {
|
|
28
|
-
return componentCoreWasmPromise;
|
|
29
|
-
}
|
|
30
|
-
if (path === "arcjet_analyze_js_req.component.core2.wasm") {
|
|
31
|
-
return componentCore2WasmPromise;
|
|
32
|
-
}
|
|
33
|
-
if (path === "arcjet_analyze_js_req.component.core3.wasm") {
|
|
34
|
-
return componentCore3WasmPromise;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
throw new Error(`Unknown path: ${path}`);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export async function initializeWasm(coreImports: ImportObject) {
|
|
41
|
-
try {
|
|
42
|
-
// Await the instantiation to catch the failure
|
|
43
|
-
return instantiate(moduleFromPath, coreImports);
|
|
44
|
-
} catch {
|
|
45
|
-
return undefined;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export {
|
|
50
|
-
type BotConfig,
|
|
51
|
-
type DetectedSensitiveInfoEntity,
|
|
52
|
-
type SensitiveInfoEntity,
|
|
53
|
-
type EmailValidationConfig,
|
|
54
|
-
type EmailValidationResult,
|
|
55
|
-
type BotResult,
|
|
56
|
-
type SensitiveInfoResult,
|
|
57
|
-
type SensitiveInfoEntities,
|
|
58
|
-
type DetectSensitiveInfoFunction,
|
|
59
|
-
type ImportObject,
|
|
60
|
-
};
|
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
|
-
}
|
package/workerd.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { instantiate } from "./wasm/arcjet_analyze_js_req.component.js";
|
|
2
|
-
import type {
|
|
3
|
-
ImportObject,
|
|
4
|
-
BotConfig,
|
|
5
|
-
DetectedSensitiveInfoEntity,
|
|
6
|
-
SensitiveInfoEntity,
|
|
7
|
-
EmailValidationResult,
|
|
8
|
-
BotResult,
|
|
9
|
-
SensitiveInfoResult,
|
|
10
|
-
EmailValidationConfig,
|
|
11
|
-
SensitiveInfoEntities,
|
|
12
|
-
} from "./wasm/arcjet_analyze_js_req.component.js";
|
|
13
|
-
import type { ArcjetJsReqSensitiveInformationIdentifier } from "./wasm/interfaces/arcjet-js-req-sensitive-information-identifier.js";
|
|
14
|
-
|
|
15
|
-
import componentCoreWasm from "./wasm/arcjet_analyze_js_req.component.core.wasm";
|
|
16
|
-
import componentCore2Wasm from "./wasm/arcjet_analyze_js_req.component.core2.wasm";
|
|
17
|
-
import componentCore3Wasm from "./wasm/arcjet_analyze_js_req.component.core3.wasm";
|
|
18
|
-
|
|
19
|
-
type DetectSensitiveInfoFunction =
|
|
20
|
-
typeof ArcjetJsReqSensitiveInformationIdentifier.detect;
|
|
21
|
-
|
|
22
|
-
async function moduleFromPath(path: string): Promise<WebAssembly.Module> {
|
|
23
|
-
if (path === "arcjet_analyze_js_req.component.core.wasm") {
|
|
24
|
-
return componentCoreWasm;
|
|
25
|
-
}
|
|
26
|
-
if (path === "arcjet_analyze_js_req.component.core2.wasm") {
|
|
27
|
-
return componentCore2Wasm;
|
|
28
|
-
}
|
|
29
|
-
if (path === "arcjet_analyze_js_req.component.core3.wasm") {
|
|
30
|
-
return componentCore3Wasm;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
throw new Error(`Unknown path: ${path}`);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export async function initializeWasm(coreImports: ImportObject) {
|
|
37
|
-
try {
|
|
38
|
-
// Await the instantiation to catch the failure
|
|
39
|
-
return instantiate(moduleFromPath, coreImports);
|
|
40
|
-
} catch {
|
|
41
|
-
return undefined;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export {
|
|
46
|
-
type BotConfig,
|
|
47
|
-
type DetectedSensitiveInfoEntity,
|
|
48
|
-
type SensitiveInfoEntity,
|
|
49
|
-
type EmailValidationConfig,
|
|
50
|
-
type EmailValidationResult,
|
|
51
|
-
type BotResult,
|
|
52
|
-
type SensitiveInfoResult,
|
|
53
|
-
type SensitiveInfoEntities,
|
|
54
|
-
type DetectSensitiveInfoFunction,
|
|
55
|
-
type ImportObject,
|
|
56
|
-
};
|