@arcjet/analyze-wasm 1.0.0-beta.1 → 1.0.0-beta.11
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/edge-light.d.ts +10 -4
- package/edge-light.js +8 -0
- package/index.d.ts +10 -4
- package/index.js +9 -0
- package/package.json +31 -19
- package/types.d.ts +73 -0
- package/types.js +1 -0
- 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 +9 -1
- package/wasm/arcjet_analyze_js_req.component.js +106 -22
- package/wasm/arcjet_analyze_js_req.component.wasm +0 -0
- package/wasm/interfaces/arcjet-js-req-bot-identifier.d.ts +4 -0
- package/workerd.d.ts +10 -4
- package/workerd.js +8 -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/f38Bf2ACf38BfwMIBwABAgICAgAEBQFwAQcHBygIATAAAAExAAEBMgACATMAAwE0AAQBNQAFATYABggkaW1wb3J0cwEACl0HDQAgACABIAJBABEAAAsPACAAIAEgAiADQQERAQALCwAgACABQQIRAgALCwAgACABQQMRAgALCwAgACABQQQRAgALCwAgACABQQURAgALDQAgACABIAJBBhEAAAsALwlwcm9kdWNlcnMBDHByb2Nlc3NlZC1ieQENd2l0LWNvbXBvbmVudAcwLjIzNS4wALwDBG5hbWUAExJ3aXQtY29tcG9uZW50OnNoaW0BnwMHACxpbmRpcmVjdC1hcmNqZXQ6anMtcmVxL2JvdC1pZGVudGlmaWVyLWRldGVjdAEoaW5kaXJlY3QtYXJjamV0OmpzLXJlcS92ZXJpZnktYm90LXZlcmlmeQI+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/f38Bf2ACf38BfwIzCAABMAAAAAExAAEAATIAAgABMwACAAE0AAIAATUAAgABNgAAAAgkaW1wb3J0cwFwAQcHCQ0BAEEACwcAAQIDBAUGAC8JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQHMC4yMzUuMAAcBG5hbWUAFRR3aXQtY29tcG9uZW50OmZpeHVwcw==";
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
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 {
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
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 {
|
|
11
|
+
export type { BotConfig, BotResult, DetectSensitiveInfoFunction, DetectedSensitiveInfoEntity, EmailValidationConfig, EmailValidationResult, ImportObject, FilterResult, SensitiveInfoEntities, SensitiveInfoEntity, SensitiveInfoResult, } from "./types.js";
|
package/index.js
CHANGED
|
@@ -16,8 +16,17 @@ 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
|
}
|
|
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
|
+
*/
|
|
21
30
|
async function initializeWasm(coreImports) {
|
|
22
31
|
try {
|
|
23
32
|
// Await the instantiation to catch the failure
|
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.11",
|
|
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,36 @@
|
|
|
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
|
+
"types.d.ts",
|
|
49
|
+
"types.js",
|
|
50
|
+
"workerd.d.ts",
|
|
51
|
+
"workerd.js"
|
|
41
52
|
],
|
|
42
53
|
"scripts": {
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"build": "npm run jco
|
|
54
|
+
"build:jco": "jco transpile --instantiation async --no-wasi-shim --out-dir wasm/ -- wasm/arcjet_analyze_js_req.component.wasm",
|
|
55
|
+
"build:rollup": "rollup --config rollup.config.js",
|
|
56
|
+
"build": "npm run build:jco && npm run build:rollup",
|
|
46
57
|
"lint": "eslint .",
|
|
47
|
-
"
|
|
48
|
-
"test": "node --test"
|
|
58
|
+
"prepublishOnly": "npm run build",
|
|
59
|
+
"test-api": "node --test",
|
|
60
|
+
"test-coverage": "node --experimental-test-coverage --test",
|
|
61
|
+
"test": "npm run build && npm run lint && npm run test-coverage"
|
|
49
62
|
},
|
|
50
63
|
"dependencies": {},
|
|
51
64
|
"devDependencies": {
|
|
52
|
-
"@arcjet/eslint-config": "1.0.0-beta.
|
|
53
|
-
"@arcjet/rollup-config": "1.0.0-beta.
|
|
54
|
-
"@arcjet/tsconfig": "1.0.0-beta.1",
|
|
65
|
+
"@arcjet/eslint-config": "1.0.0-beta.11",
|
|
66
|
+
"@arcjet/rollup-config": "1.0.0-beta.11",
|
|
55
67
|
"@bytecodealliance/jco": "1.5.0",
|
|
56
|
-
"@rollup/wasm-node": "4.
|
|
57
|
-
"@types/node": "
|
|
58
|
-
"
|
|
59
|
-
"typescript": "5.
|
|
68
|
+
"@rollup/wasm-node": "4.50.0",
|
|
69
|
+
"@types/node": "24.3.0",
|
|
70
|
+
"eslint": "9.34.0",
|
|
71
|
+
"typescript": "5.9.2"
|
|
60
72
|
},
|
|
61
73
|
"publishConfig": {
|
|
62
74
|
"access": "public",
|
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
|
+
|
|
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,16 +79,23 @@ export interface BotResult {
|
|
|
78
79
|
verified: boolean,
|
|
79
80
|
spoofed: boolean,
|
|
80
81
|
}
|
|
82
|
+
export interface FilterResult {
|
|
83
|
+
allowed: boolean,
|
|
84
|
+
matchedExpressions: Array<string>,
|
|
85
|
+
}
|
|
86
|
+
import { ArcjetJsReqBotIdentifier } from './interfaces/arcjet-js-req-bot-identifier.js';
|
|
81
87
|
import { ArcjetJsReqEmailValidatorOverrides } from './interfaces/arcjet-js-req-email-validator-overrides.js';
|
|
82
88
|
import { ArcjetJsReqSensitiveInformationIdentifier } from './interfaces/arcjet-js-req-sensitive-information-identifier.js';
|
|
83
89
|
import { ArcjetJsReqVerifyBot } from './interfaces/arcjet-js-req-verify-bot.js';
|
|
84
90
|
export interface ImportObject {
|
|
91
|
+
'arcjet:js-req/bot-identifier': typeof ArcjetJsReqBotIdentifier,
|
|
85
92
|
'arcjet:js-req/email-validator-overrides': typeof ArcjetJsReqEmailValidatorOverrides,
|
|
86
93
|
'arcjet:js-req/sensitive-information-identifier': typeof ArcjetJsReqSensitiveInformationIdentifier,
|
|
87
94
|
'arcjet:js-req/verify-bot': typeof ArcjetJsReqVerifyBot,
|
|
88
95
|
}
|
|
89
96
|
export interface Root {
|
|
90
97
|
detectBot(request: string, options: BotConfig): BotResult,
|
|
98
|
+
matchFilters(request: string, expressions: Array<string>, allowIfMatch: boolean): FilterResult,
|
|
91
99
|
generateFingerprint(request: string, characteristics: Array<string>): string,
|
|
92
100
|
validateCharacteristics(request: string, characteristics: Array<string>): void,
|
|
93
101
|
isValidEmail(candidate: string, options: EmailValidationConfig): EmailValidationResult,
|
|
@@ -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,12 +324,13 @@ 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'];
|
|
306
|
-
postReturn1 = exports1['
|
|
307
|
-
postReturn2 = exports1['
|
|
308
|
-
postReturn3 = exports1['
|
|
331
|
+
postReturn1 = exports1['cabi_post_is-valid-email'];
|
|
332
|
+
postReturn2 = exports1['cabi_post_generate-fingerprint'];
|
|
333
|
+
postReturn3 = exports1['cabi_post_validate-characteristics'];
|
|
309
334
|
postReturn4 = exports1['cabi_post_detect-sensitive-info'];
|
|
310
335
|
|
|
311
336
|
function detectBot(arg0, arg1) {
|
|
@@ -418,6 +443,65 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
418
443
|
return retVal.val;
|
|
419
444
|
}
|
|
420
445
|
|
|
446
|
+
function matchFilters(arg0, arg1, arg2) {
|
|
447
|
+
var ptr0 = utf8Encode(arg0, realloc0, memory0);
|
|
448
|
+
var len0 = utf8EncodedLen;
|
|
449
|
+
var vec2 = arg1;
|
|
450
|
+
var len2 = vec2.length;
|
|
451
|
+
var result2 = realloc0(0, 0, 4, len2 * 8);
|
|
452
|
+
for (let i = 0; i < vec2.length; i++) {
|
|
453
|
+
const e = vec2[i];
|
|
454
|
+
const base = result2 + i * 8;var ptr1 = utf8Encode(e, realloc0, memory0);
|
|
455
|
+
var len1 = utf8EncodedLen;
|
|
456
|
+
dataView(memory0).setInt32(base + 4, len1, true);
|
|
457
|
+
dataView(memory0).setInt32(base + 0, ptr1, true);
|
|
458
|
+
}
|
|
459
|
+
const ret = exports1['match-filters'](ptr0, len0, result2, len2, arg2 ? 1 : 0);
|
|
460
|
+
let variant7;
|
|
461
|
+
switch (dataView(memory0).getUint8(ret + 0, true)) {
|
|
462
|
+
case 0: {
|
|
463
|
+
var bool3 = dataView(memory0).getUint8(ret + 4, true);
|
|
464
|
+
var len5 = dataView(memory0).getInt32(ret + 12, true);
|
|
465
|
+
var base5 = dataView(memory0).getInt32(ret + 8, true);
|
|
466
|
+
var result5 = [];
|
|
467
|
+
for (let i = 0; i < len5; i++) {
|
|
468
|
+
const base = base5 + i * 8;
|
|
469
|
+
var ptr4 = dataView(memory0).getInt32(base + 0, true);
|
|
470
|
+
var len4 = dataView(memory0).getInt32(base + 4, true);
|
|
471
|
+
var result4 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr4, len4));
|
|
472
|
+
result5.push(result4);
|
|
473
|
+
}
|
|
474
|
+
variant7= {
|
|
475
|
+
tag: 'ok',
|
|
476
|
+
val: {
|
|
477
|
+
allowed: bool3 == 0 ? false : (bool3 == 1 ? true : throwInvalidBool()),
|
|
478
|
+
matchedExpressions: result5,
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
break;
|
|
482
|
+
}
|
|
483
|
+
case 1: {
|
|
484
|
+
var ptr6 = dataView(memory0).getInt32(ret + 4, true);
|
|
485
|
+
var len6 = dataView(memory0).getInt32(ret + 8, true);
|
|
486
|
+
var result6 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr6, len6));
|
|
487
|
+
variant7= {
|
|
488
|
+
tag: 'err',
|
|
489
|
+
val: result6
|
|
490
|
+
};
|
|
491
|
+
break;
|
|
492
|
+
}
|
|
493
|
+
default: {
|
|
494
|
+
throw new TypeError('invalid variant discriminant for expected');
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
const retVal = variant7;
|
|
498
|
+
postReturn1(ret);
|
|
499
|
+
if (typeof retVal === 'object' && retVal.tag === 'err') {
|
|
500
|
+
throw new ComponentError(retVal.val);
|
|
501
|
+
}
|
|
502
|
+
return retVal.val;
|
|
503
|
+
}
|
|
504
|
+
|
|
421
505
|
function generateFingerprint(arg0, arg1) {
|
|
422
506
|
var ptr0 = utf8Encode(arg0, realloc0, memory0);
|
|
423
507
|
var len0 = utf8EncodedLen;
|
|
@@ -459,7 +543,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
459
543
|
}
|
|
460
544
|
}
|
|
461
545
|
const retVal = variant5;
|
|
462
|
-
|
|
546
|
+
postReturn2(ret);
|
|
463
547
|
if (typeof retVal === 'object' && retVal.tag === 'err') {
|
|
464
548
|
throw new ComponentError(retVal.val);
|
|
465
549
|
}
|
|
@@ -504,7 +588,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
504
588
|
}
|
|
505
589
|
}
|
|
506
590
|
const retVal = variant4;
|
|
507
|
-
|
|
591
|
+
postReturn3(ret);
|
|
508
592
|
if (typeof retVal === 'object' && retVal.tag === 'err') {
|
|
509
593
|
throw new ComponentError(retVal.val);
|
|
510
594
|
}
|
|
@@ -617,7 +701,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
617
701
|
}
|
|
618
702
|
}
|
|
619
703
|
const retVal = variant12;
|
|
620
|
-
|
|
704
|
+
postReturn1(ret);
|
|
621
705
|
if (typeof retVal === 'object' && retVal.tag === 'err') {
|
|
622
706
|
throw new ComponentError(retVal.val);
|
|
623
707
|
}
|
|
@@ -847,7 +931,7 @@ function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.insta
|
|
|
847
931
|
return retVal;
|
|
848
932
|
}
|
|
849
933
|
|
|
850
|
-
return { detectBot, detectSensitiveInfo, generateFingerprint, isValidEmail, validateCharacteristics, };
|
|
934
|
+
return { detectBot, detectSensitiveInfo, generateFingerprint, isValidEmail, matchFilters, validateCharacteristics, };
|
|
851
935
|
})();
|
|
852
936
|
let promise, resolve, reject;
|
|
853
937
|
function runNext (value) {
|
|
Binary file
|
package/workerd.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import type { ImportObject
|
|
2
|
-
|
|
3
|
-
|
|
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 {
|
|
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
|
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
|
-
};
|