@arcjet/analyze-wasm 1.0.0-beta.1
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/LICENSE +201 -0
- package/README.md +62 -0
- package/_virtual/arcjet_analyze_js_req.component.core.js +42 -0
- package/_virtual/arcjet_analyze_js_req.component.core2.js +42 -0
- package/_virtual/arcjet_analyze_js_req.component.core3.js +42 -0
- package/edge-light.d.ts +5 -0
- package/edge-light.js +27 -0
- package/edge-light.ts +55 -0
- package/index.d.ts +5 -0
- package/index.js +31 -0
- package/index.ts +60 -0
- package/package.json +65 -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 +126 -0
- package/wasm/arcjet_analyze_js_req.component.js +875 -0
- package/wasm/arcjet_analyze_js_req.component.wasm +0 -0
- package/wasm/interfaces/arcjet-js-req-email-validator-overrides.d.ts +16 -0
- package/wasm/interfaces/arcjet-js-req-logger.d.ts +4 -0
- package/wasm/interfaces/arcjet-js-req-sensitive-information-identifier.d.ts +20 -0
- package/wasm/interfaces/arcjet-js-req-verify-bot.d.ts +13 -0
- package/wasm.d.ts +28 -0
- package/workerd.d.ts +5 -0
- package/workerd.js +28 -0
- package/workerd.ts +56 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// @generated by wasm2module - DO NOT EDIT
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This file contains an Arcjet Wasm binary inlined as a base64
|
|
7
|
+
* [Data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs)
|
|
8
|
+
* with the application/wasm MIME type.
|
|
9
|
+
*
|
|
10
|
+
* This was chosen to save on storage space over inlining the file directly as
|
|
11
|
+
* a Uint8Array, which would take up ~3x the space of the Wasm file. See
|
|
12
|
+
* https://blobfolio.com/2019/better-binary-batter-mixing-base64-and-uint8array/
|
|
13
|
+
* for more details.
|
|
14
|
+
*
|
|
15
|
+
* It is then decoded into an ArrayBuffer to be used directly via WebAssembly's
|
|
16
|
+
* `compile()` function in our entry point file.
|
|
17
|
+
*
|
|
18
|
+
* This is all done to avoid trying to read or bundle the Wasm asset in various
|
|
19
|
+
* ways based on the platform or bundler a user is targeting. One example being
|
|
20
|
+
* that Next.js requires special `asyncWebAssembly` webpack config to load our
|
|
21
|
+
* Wasm file if we don't do this.
|
|
22
|
+
*
|
|
23
|
+
* In the future, we hope to do away with this workaround when all bundlers
|
|
24
|
+
* properly support consistent asset bundling techniques.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const wasmBase64 = "data:application/wasm;base64,AGFzbQEAAAABFQNgBH9/f38Bf2ACf38Bf2ADf39/AAMHBgABAQEBAgQFAXABBgYHJAcBMAAAATEAAQEyAAIBMwADATQABAE1AAUIJGltcG9ydHMBAApPBg8AIAAgASACIANBABEAAAsLACAAIAFBAREBAAsLACAAIAFBAhEBAAsLACAAIAFBAxEBAAsLACAAIAFBBBEBAAsNACAAIAEgAkEFEQIACwAvCXByb2R1Y2VycwEMcHJvY2Vzc2VkLWJ5AQ13aXQtY29tcG9uZW50BzAuMjE5LjEAjgMEbmFtZQATEndpdC1jb21wb25lbnQ6c2hpbQHxAgYAKGluZGlyZWN0LWFyY2pldDpqcy1yZXEvdmVyaWZ5LWJvdC12ZXJpZnkBPmluZGlyZWN0LWFyY2pldDpqcy1yZXEvZW1haWwtdmFsaWRhdG9yLW92ZXJyaWRlcy1pcy1mcmVlLWVtYWlsAkRpbmRpcmVjdC1hcmNqZXQ6anMtcmVxL2VtYWlsLXZhbGlkYXRvci1vdmVycmlkZXMtaXMtZGlzcG9zYWJsZS1lbWFpbAM/aW5kaXJlY3QtYXJjamV0OmpzLXJlcS9lbWFpbC12YWxpZGF0b3Itb3ZlcnJpZGVzLWhhcy1teC1yZWNvcmRzBD1pbmRpcmVjdC1hcmNqZXQ6anMtcmVxL2VtYWlsLXZhbGlkYXRvci1vdmVycmlkZXMtaGFzLWdyYXZhdGFyBT5pbmRpcmVjdC1hcmNqZXQ6anMtcmVxL3NlbnNpdGl2ZS1pbmZvcm1hdGlvbi1pZGVudGlmaWVyLWRldGVjdA==";
|
|
28
|
+
/**
|
|
29
|
+
* Returns a WebAssembly.Module for an Arcjet Wasm binary, decoded from a base64
|
|
30
|
+
* Data URL.
|
|
31
|
+
*/
|
|
32
|
+
// TODO: Switch back to top-level await when our platforms all support it
|
|
33
|
+
async function wasm() {
|
|
34
|
+
// This uses fetch to decode the wasm data url, but disabling cache so files
|
|
35
|
+
// larger than 2mb don't fail to parse in the Next.js App Router
|
|
36
|
+
const wasmDecode = await fetch(wasmBase64, { cache: "no-store" });
|
|
37
|
+
const buf = await wasmDecode.arrayBuffer();
|
|
38
|
+
// And then we return it as a WebAssembly.Module
|
|
39
|
+
return WebAssembly.compile(buf);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { wasm };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// @generated by wasm2module - DO NOT EDIT
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
// @ts-nocheck
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This file contains an Arcjet Wasm binary inlined as a base64
|
|
7
|
+
* [Data URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs)
|
|
8
|
+
* with the application/wasm MIME type.
|
|
9
|
+
*
|
|
10
|
+
* This was chosen to save on storage space over inlining the file directly as
|
|
11
|
+
* a Uint8Array, which would take up ~3x the space of the Wasm file. See
|
|
12
|
+
* https://blobfolio.com/2019/better-binary-batter-mixing-base64-and-uint8array/
|
|
13
|
+
* for more details.
|
|
14
|
+
*
|
|
15
|
+
* It is then decoded into an ArrayBuffer to be used directly via WebAssembly's
|
|
16
|
+
* `compile()` function in our entry point file.
|
|
17
|
+
*
|
|
18
|
+
* This is all done to avoid trying to read or bundle the Wasm asset in various
|
|
19
|
+
* ways based on the platform or bundler a user is targeting. One example being
|
|
20
|
+
* that Next.js requires special `asyncWebAssembly` webpack config to load our
|
|
21
|
+
* Wasm file if we don't do this.
|
|
22
|
+
*
|
|
23
|
+
* In the future, we hope to do away with this workaround when all bundlers
|
|
24
|
+
* properly support consistent asset bundling techniques.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const wasmBase64 = "data:application/wasm;base64,AGFzbQEAAAABFQNgBH9/f38Bf2ACf38Bf2ADf39/AAIuBwABMAAAAAExAAEAATIAAQABMwABAAE0AAEAATUAAgAIJGltcG9ydHMBcAEGBgkMAQBBAAsGAAECAwQFAC8JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQHMC4yMTkuMQAcBG5hbWUAFRR3aXQtY29tcG9uZW50OmZpeHVwcw==";
|
|
28
|
+
/**
|
|
29
|
+
* Returns a WebAssembly.Module for an Arcjet Wasm binary, decoded from a base64
|
|
30
|
+
* Data URL.
|
|
31
|
+
*/
|
|
32
|
+
// TODO: Switch back to top-level await when our platforms all support it
|
|
33
|
+
async function wasm() {
|
|
34
|
+
// This uses fetch to decode the wasm data url, but disabling cache so files
|
|
35
|
+
// larger than 2mb don't fail to parse in the Next.js App Router
|
|
36
|
+
const wasmDecode = await fetch(wasmBase64, { cache: "no-store" });
|
|
37
|
+
const buf = await wasmDecode.arrayBuffer();
|
|
38
|
+
// And then we return it as a WebAssembly.Module
|
|
39
|
+
return WebAssembly.compile(buf);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export { wasm };
|
package/edge-light.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
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;
|
|
4
|
+
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, };
|
package/edge-light.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { instantiate } from './wasm/arcjet_analyze_js_req.component.js';
|
|
2
|
+
import componentCoreWasm from './wasm/arcjet_analyze_js_req.component.core.wasm?module';
|
|
3
|
+
import componentCore2Wasm from './wasm/arcjet_analyze_js_req.component.core2.wasm?module';
|
|
4
|
+
import componentCore3Wasm from './wasm/arcjet_analyze_js_req.component.core3.wasm?module';
|
|
5
|
+
|
|
6
|
+
async function moduleFromPath(path) {
|
|
7
|
+
if (path === "arcjet_analyze_js_req.component.core.wasm") {
|
|
8
|
+
return componentCoreWasm;
|
|
9
|
+
}
|
|
10
|
+
if (path === "arcjet_analyze_js_req.component.core2.wasm") {
|
|
11
|
+
return componentCore2Wasm;
|
|
12
|
+
}
|
|
13
|
+
if (path === "arcjet_analyze_js_req.component.core3.wasm") {
|
|
14
|
+
return componentCore3Wasm;
|
|
15
|
+
}
|
|
16
|
+
throw new Error(`Unknown path: ${path}`);
|
|
17
|
+
}
|
|
18
|
+
async function initializeWasm(coreImports) {
|
|
19
|
+
try {
|
|
20
|
+
return instantiate(moduleFromPath, coreImports);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { initializeWasm };
|
package/edge-light.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
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.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
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;
|
|
4
|
+
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, };
|
package/index.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { instantiate } from './wasm/arcjet_analyze_js_req.component.js';
|
|
2
|
+
import { wasm } from './_virtual/arcjet_analyze_js_req.component.core.js';
|
|
3
|
+
import { wasm as wasm$1 } from './_virtual/arcjet_analyze_js_req.component.core2.js';
|
|
4
|
+
import { wasm as wasm$2 } from './_virtual/arcjet_analyze_js_req.component.core3.js';
|
|
5
|
+
|
|
6
|
+
const componentCoreWasmPromise = wasm();
|
|
7
|
+
const componentCore2WasmPromise = wasm$1();
|
|
8
|
+
const componentCore3WasmPromise = wasm$2();
|
|
9
|
+
async function moduleFromPath(path) {
|
|
10
|
+
if (path === "arcjet_analyze_js_req.component.core.wasm") {
|
|
11
|
+
return componentCoreWasmPromise;
|
|
12
|
+
}
|
|
13
|
+
if (path === "arcjet_analyze_js_req.component.core2.wasm") {
|
|
14
|
+
return componentCore2WasmPromise;
|
|
15
|
+
}
|
|
16
|
+
if (path === "arcjet_analyze_js_req.component.core3.wasm") {
|
|
17
|
+
return componentCore3WasmPromise;
|
|
18
|
+
}
|
|
19
|
+
throw new Error(`Unknown path: ${path}`);
|
|
20
|
+
}
|
|
21
|
+
async function initializeWasm(coreImports) {
|
|
22
|
+
try {
|
|
23
|
+
// Await the instantiation to catch the failure
|
|
24
|
+
return instantiate(moduleFromPath, coreImports);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { initializeWasm };
|
package/index.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
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/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@arcjet/analyze-wasm",
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
|
+
"description": "WebAssembly bindings to Arcjet's local analysis engine",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"homepage": "https://arcjet.com",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/arcjet/arcjet-js.git",
|
|
10
|
+
"directory": "analyze-wasm"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/arcjet/arcjet-js/issues",
|
|
14
|
+
"email": "support@arcjet.com"
|
|
15
|
+
},
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "Arcjet",
|
|
18
|
+
"email": "support@arcjet.com",
|
|
19
|
+
"url": "https://arcjet.com"
|
|
20
|
+
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=18"
|
|
23
|
+
},
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "./index.js",
|
|
26
|
+
"types": "./index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
"edge-light": "./edge-light.js",
|
|
29
|
+
"workerd": "./workerd.js",
|
|
30
|
+
"default": "./index.js"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"LICENSE",
|
|
34
|
+
"README.md",
|
|
35
|
+
"_virtual/",
|
|
36
|
+
"wasm/",
|
|
37
|
+
"*.js",
|
|
38
|
+
"*.d.ts",
|
|
39
|
+
"*.ts",
|
|
40
|
+
"!*.config.js"
|
|
41
|
+
],
|
|
42
|
+
"scripts": {
|
|
43
|
+
"prepublishOnly": "npm run build",
|
|
44
|
+
"jco": "jco transpile wasm/arcjet_analyze_js_req.component.wasm --no-wasi-shim --instantiation async -o wasm",
|
|
45
|
+
"build": "npm run jco; rollup --config rollup.config.js",
|
|
46
|
+
"lint": "eslint .",
|
|
47
|
+
"pretest": "npm run build",
|
|
48
|
+
"test": "node --test"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@arcjet/eslint-config": "1.0.0-beta.1",
|
|
53
|
+
"@arcjet/rollup-config": "1.0.0-beta.1",
|
|
54
|
+
"@arcjet/tsconfig": "1.0.0-beta.1",
|
|
55
|
+
"@bytecodealliance/jco": "1.5.0",
|
|
56
|
+
"@rollup/wasm-node": "4.30.1",
|
|
57
|
+
"@types/node": "18.18.0",
|
|
58
|
+
"expect": "29.7.0",
|
|
59
|
+
"typescript": "5.7.3"
|
|
60
|
+
},
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"access": "public",
|
|
63
|
+
"tag": "latest"
|
|
64
|
+
}
|
|
65
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import type { SensitiveInfoEntity } from './interfaces/arcjet-js-req-sensitive-information-identifier.js';
|
|
2
|
+
export { SensitiveInfoEntity };
|
|
3
|
+
/**
|
|
4
|
+
* # Variants
|
|
5
|
+
*
|
|
6
|
+
* ## `"valid"`
|
|
7
|
+
*
|
|
8
|
+
* ## `"invalid"`
|
|
9
|
+
*/
|
|
10
|
+
export type EmailValidity = 'valid' | 'invalid';
|
|
11
|
+
export interface EmailValidationResult {
|
|
12
|
+
validity: EmailValidity,
|
|
13
|
+
blocked: Array<string>,
|
|
14
|
+
}
|
|
15
|
+
export interface AllowEmailValidationConfig {
|
|
16
|
+
requireTopLevelDomain: boolean,
|
|
17
|
+
allowDomainLiteral: boolean,
|
|
18
|
+
allow: Array<string>,
|
|
19
|
+
}
|
|
20
|
+
export interface DenyEmailValidationConfig {
|
|
21
|
+
requireTopLevelDomain: boolean,
|
|
22
|
+
allowDomainLiteral: boolean,
|
|
23
|
+
deny: Array<string>,
|
|
24
|
+
}
|
|
25
|
+
export type EmailValidationConfig = EmailValidationConfigAllowEmailValidationConfig | EmailValidationConfigDenyEmailValidationConfig;
|
|
26
|
+
export interface EmailValidationConfigAllowEmailValidationConfig {
|
|
27
|
+
tag: 'allow-email-validation-config',
|
|
28
|
+
val: AllowEmailValidationConfig,
|
|
29
|
+
}
|
|
30
|
+
export interface EmailValidationConfigDenyEmailValidationConfig {
|
|
31
|
+
tag: 'deny-email-validation-config',
|
|
32
|
+
val: DenyEmailValidationConfig,
|
|
33
|
+
}
|
|
34
|
+
export type SensitiveInfoEntities = SensitiveInfoEntitiesAllow | SensitiveInfoEntitiesDeny;
|
|
35
|
+
export interface SensitiveInfoEntitiesAllow {
|
|
36
|
+
tag: 'allow',
|
|
37
|
+
val: Array<SensitiveInfoEntity>,
|
|
38
|
+
}
|
|
39
|
+
export interface SensitiveInfoEntitiesDeny {
|
|
40
|
+
tag: 'deny',
|
|
41
|
+
val: Array<SensitiveInfoEntity>,
|
|
42
|
+
}
|
|
43
|
+
export interface SensitiveInfoConfig {
|
|
44
|
+
entities: SensitiveInfoEntities,
|
|
45
|
+
contextWindowSize?: number,
|
|
46
|
+
skipCustomDetect: boolean,
|
|
47
|
+
}
|
|
48
|
+
export interface DetectedSensitiveInfoEntity {
|
|
49
|
+
start: number,
|
|
50
|
+
end: number,
|
|
51
|
+
identifiedType: SensitiveInfoEntity,
|
|
52
|
+
}
|
|
53
|
+
export interface SensitiveInfoResult {
|
|
54
|
+
allowed: Array<DetectedSensitiveInfoEntity>,
|
|
55
|
+
denied: Array<DetectedSensitiveInfoEntity>,
|
|
56
|
+
}
|
|
57
|
+
export type BotEntity = string;
|
|
58
|
+
export interface AllowedBotConfig {
|
|
59
|
+
entities: Array<BotEntity>,
|
|
60
|
+
skipCustomDetect: boolean,
|
|
61
|
+
}
|
|
62
|
+
export interface DeniedBotConfig {
|
|
63
|
+
entities: Array<BotEntity>,
|
|
64
|
+
skipCustomDetect: boolean,
|
|
65
|
+
}
|
|
66
|
+
export type BotConfig = BotConfigAllowedBotConfig | BotConfigDeniedBotConfig;
|
|
67
|
+
export interface BotConfigAllowedBotConfig {
|
|
68
|
+
tag: 'allowed-bot-config',
|
|
69
|
+
val: AllowedBotConfig,
|
|
70
|
+
}
|
|
71
|
+
export interface BotConfigDeniedBotConfig {
|
|
72
|
+
tag: 'denied-bot-config',
|
|
73
|
+
val: DeniedBotConfig,
|
|
74
|
+
}
|
|
75
|
+
export interface BotResult {
|
|
76
|
+
allowed: Array<BotEntity>,
|
|
77
|
+
denied: Array<BotEntity>,
|
|
78
|
+
verified: boolean,
|
|
79
|
+
spoofed: boolean,
|
|
80
|
+
}
|
|
81
|
+
import { ArcjetJsReqEmailValidatorOverrides } from './interfaces/arcjet-js-req-email-validator-overrides.js';
|
|
82
|
+
import { ArcjetJsReqSensitiveInformationIdentifier } from './interfaces/arcjet-js-req-sensitive-information-identifier.js';
|
|
83
|
+
import { ArcjetJsReqVerifyBot } from './interfaces/arcjet-js-req-verify-bot.js';
|
|
84
|
+
export interface ImportObject {
|
|
85
|
+
'arcjet:js-req/email-validator-overrides': typeof ArcjetJsReqEmailValidatorOverrides,
|
|
86
|
+
'arcjet:js-req/sensitive-information-identifier': typeof ArcjetJsReqSensitiveInformationIdentifier,
|
|
87
|
+
'arcjet:js-req/verify-bot': typeof ArcjetJsReqVerifyBot,
|
|
88
|
+
}
|
|
89
|
+
export interface Root {
|
|
90
|
+
detectBot(request: string, options: BotConfig): BotResult,
|
|
91
|
+
generateFingerprint(request: string, characteristics: Array<string>): string,
|
|
92
|
+
validateCharacteristics(request: string, characteristics: Array<string>): void,
|
|
93
|
+
isValidEmail(candidate: string, options: EmailValidationConfig): EmailValidationResult,
|
|
94
|
+
detectSensitiveInfo(content: string, options: SensitiveInfoConfig): SensitiveInfoResult,
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Instantiates this component with the provided imports and
|
|
99
|
+
* returns a map of all the exports of the component.
|
|
100
|
+
*
|
|
101
|
+
* This function is intended to be similar to the
|
|
102
|
+
* `WebAssembly.instantiate` function. The second `imports`
|
|
103
|
+
* argument is the "import object" for wasm, except here it
|
|
104
|
+
* uses component-model-layer types instead of core wasm
|
|
105
|
+
* integers/numbers/etc.
|
|
106
|
+
*
|
|
107
|
+
* The first argument to this function, `getCoreModule`, is
|
|
108
|
+
* used to compile core wasm modules within the component.
|
|
109
|
+
* Components are composed of core wasm modules and this callback
|
|
110
|
+
* will be invoked per core wasm module. The caller of this
|
|
111
|
+
* function is responsible for reading the core wasm module
|
|
112
|
+
* identified by `path` and returning its compiled
|
|
113
|
+
* `WebAssembly.Module` object. This would use `compileStreaming`
|
|
114
|
+
* on the web, for example.
|
|
115
|
+
*/
|
|
116
|
+
export function instantiate(
|
|
117
|
+
getCoreModule: (path: string) => WebAssembly.Module,
|
|
118
|
+
imports: ImportObject,
|
|
119
|
+
instantiateCore?: (module: WebAssembly.Module, imports: Record<string, any>) => WebAssembly.Instance
|
|
120
|
+
): Root;
|
|
121
|
+
export function instantiate(
|
|
122
|
+
getCoreModule: (path: string) => WebAssembly.Module | Promise<WebAssembly.Module>,
|
|
123
|
+
imports: ImportObject,
|
|
124
|
+
instantiateCore?: (module: WebAssembly.Module, imports: Record<string, any>) => WebAssembly.Instance | Promise<WebAssembly.Instance>
|
|
125
|
+
): Root | Promise<Root>;
|
|
126
|
+
|