@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.
@@ -0,0 +1,16 @@
1
+ export namespace ArcjetJsReqEmailValidatorOverrides {
2
+ export function isFreeEmail(domain: string): ValidatorResponse;
3
+ export function isDisposableEmail(domain: string): ValidatorResponse;
4
+ export function hasMxRecords(domain: string): ValidatorResponse;
5
+ export function hasGravatar(email: string): ValidatorResponse;
6
+ }
7
+ /**
8
+ * # Variants
9
+ *
10
+ * ## `"yes"`
11
+ *
12
+ * ## `"no"`
13
+ *
14
+ * ## `"unknown"`
15
+ */
16
+ export type ValidatorResponse = 'yes' | 'no' | 'unknown';
@@ -0,0 +1,4 @@
1
+ export namespace ArcjetJsReqLogger {
2
+ export function debug(msg: string): void;
3
+ export function error(msg: string): void;
4
+ }
@@ -0,0 +1,20 @@
1
+ export namespace ArcjetJsReqSensitiveInformationIdentifier {
2
+ export function detect(tokens: Array<string>): Array<SensitiveInfoEntity | undefined>;
3
+ }
4
+ export type SensitiveInfoEntity = SensitiveInfoEntityEmail | SensitiveInfoEntityPhoneNumber | SensitiveInfoEntityIpAddress | SensitiveInfoEntityCreditCardNumber | SensitiveInfoEntityCustom;
5
+ export interface SensitiveInfoEntityEmail {
6
+ tag: 'email',
7
+ }
8
+ export interface SensitiveInfoEntityPhoneNumber {
9
+ tag: 'phone-number',
10
+ }
11
+ export interface SensitiveInfoEntityIpAddress {
12
+ tag: 'ip-address',
13
+ }
14
+ export interface SensitiveInfoEntityCreditCardNumber {
15
+ tag: 'credit-card-number',
16
+ }
17
+ export interface SensitiveInfoEntityCustom {
18
+ tag: 'custom',
19
+ val: string,
20
+ }
@@ -0,0 +1,13 @@
1
+ export namespace ArcjetJsReqVerifyBot {
2
+ export function verify(botId: string, ip: string): ValidatorResponse;
3
+ }
4
+ /**
5
+ * # Variants
6
+ *
7
+ * ## `"verified"`
8
+ *
9
+ * ## `"spoofed"`
10
+ *
11
+ * ## `"unverifiable"`
12
+ */
13
+ export type ValidatorResponse = 'verified' | 'spoofed' | 'unverifiable';
package/wasm.d.ts ADDED
@@ -0,0 +1,28 @@
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.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/workerd.js ADDED
@@ -0,0 +1,28 @@
1
+ import { instantiate } from './wasm/arcjet_analyze_js_req.component.js';
2
+ import componentCoreWasm from './wasm/arcjet_analyze_js_req.component.core.wasm';
3
+ import componentCore2Wasm from './wasm/arcjet_analyze_js_req.component.core2.wasm';
4
+ import componentCore3Wasm from './wasm/arcjet_analyze_js_req.component.core3.wasm';
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
+ // Await the instantiation to catch the failure
21
+ return instantiate(moduleFromPath, coreImports);
22
+ }
23
+ catch {
24
+ return undefined;
25
+ }
26
+ }
27
+
28
+ export { initializeWasm };
package/workerd.ts ADDED
@@ -0,0 +1,56 @@
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
+ };