Socket
Socket
Sign inDemoInstall

@arcjet/analyze

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arcjet/analyze - npm Package Compare versions

Comparing version 1.0.0-alpha.23 to 1.0.0-alpha.24

2

_virtual/arcjet_analyze_js_req.component.core2.js

@@ -27,3 +27,3 @@ // @generated by wasm2module - DO NOT EDIT

const wasmBase64 = "data:application/wasm;base64,AGFzbQEAAAABEgNgAn9/AGACf38Bf2ADf39/AAMIBwAAAQEBAQIEBQFwAQcHBygIATAAAAExAAEBMgACATMAAwE0AAQBNQAFATYABggkaW1wb3J0cwEAClcHCwAgACABQQARAAALCwAgACABQQERAAALCwAgACABQQIRAQALCwAgACABQQMRAQALCwAgACABQQQRAQALCwAgACABQQURAQALDQAgACABIAJBBhECAAsALwlwcm9kdWNlcnMBDHByb2Nlc3NlZC1ieQENd2l0LWNvbXBvbmVudAcwLjIxMC4wAK4DBG5hbWUAExJ3aXQtY29tcG9uZW50OnNoaW0BkQMHACNpbmRpcmVjdC1hcmNqZXQ6anMtcmVxL2xvZ2dlci1kZWJ1ZwEjaW5kaXJlY3QtYXJjamV0OmpzLXJlcS9sb2dnZXItZXJyb3ICPmluZGlyZWN0LWFyY2pldDpqcy1yZXEvZW1haWwtdmFsaWRhdG9yLW92ZXJyaWRlcy1pcy1mcmVlLWVtYWlsA0RpbmRpcmVjdC1hcmNqZXQ6anMtcmVxL2VtYWlsLXZhbGlkYXRvci1vdmVycmlkZXMtaXMtZGlzcG9zYWJsZS1lbWFpbAQ/aW5kaXJlY3QtYXJjamV0OmpzLXJlcS9lbWFpbC12YWxpZGF0b3Itb3ZlcnJpZGVzLWhhcy1teC1yZWNvcmRzBT1pbmRpcmVjdC1hcmNqZXQ6anMtcmVxL2VtYWlsLXZhbGlkYXRvci1vdmVycmlkZXMtaGFzLWdyYXZhdGFyBj5pbmRpcmVjdC1hcmNqZXQ6anMtcmVxL3NlbnNpdGl2ZS1pbmZvcm1hdGlvbi1pZGVudGlmaWVyLWRldGVjdA==";
const wasmBase64 = "data:application/wasm;base64,AGFzbQEAAAABEgNgAn9/AGACf38Bf2ADf39/AAMIBwAAAQEBAQIEBQFwAQcHBygIATAAAAExAAEBMgACATMAAwE0AAQBNQAFATYABggkaW1wb3J0cwEAClcHCwAgACABQQARAAALCwAgACABQQERAAALCwAgACABQQIRAQALCwAgACABQQMRAQALCwAgACABQQQRAQALCwAgACABQQURAQALDQAgACABIAJBBhECAAsALwlwcm9kdWNlcnMBDHByb2Nlc3NlZC1ieQENd2l0LWNvbXBvbmVudAcwLjIxNS4wAK4DBG5hbWUAExJ3aXQtY29tcG9uZW50OnNoaW0BkQMHACNpbmRpcmVjdC1hcmNqZXQ6anMtcmVxL2xvZ2dlci1kZWJ1ZwEjaW5kaXJlY3QtYXJjamV0OmpzLXJlcS9sb2dnZXItZXJyb3ICPmluZGlyZWN0LWFyY2pldDpqcy1yZXEvZW1haWwtdmFsaWRhdG9yLW92ZXJyaWRlcy1pcy1mcmVlLWVtYWlsA0RpbmRpcmVjdC1hcmNqZXQ6anMtcmVxL2VtYWlsLXZhbGlkYXRvci1vdmVycmlkZXMtaXMtZGlzcG9zYWJsZS1lbWFpbAQ/aW5kaXJlY3QtYXJjamV0OmpzLXJlcS9lbWFpbC12YWxpZGF0b3Itb3ZlcnJpZGVzLWhhcy1teC1yZWNvcmRzBT1pbmRpcmVjdC1hcmNqZXQ6anMtcmVxL2VtYWlsLXZhbGlkYXRvci1vdmVycmlkZXMtaGFzLWdyYXZhdGFyBj5pbmRpcmVjdC1hcmNqZXQ6anMtcmVxL3NlbnNpdGl2ZS1pbmZvcm1hdGlvbi1pZGVudGlmaWVyLWRldGVjdA==";
/**

@@ -30,0 +30,0 @@ * Returns a WebAssembly.Module for an Arcjet Wasm binary, decoded from a base64

@@ -27,3 +27,3 @@ // @generated by wasm2module - DO NOT EDIT

const wasmBase64 = "data:application/wasm;base64,AGFzbQEAAAABEgNgAn9/AGACf38Bf2ADf39/AAIzCAABMAAAAAExAAAAATIAAQABMwABAAE0AAEAATUAAQABNgACAAgkaW1wb3J0cwFwAQcHCQ0BAEEACwcAAQIDBAUGAC8JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQHMC4yMTAuMAAcBG5hbWUAFRR3aXQtY29tcG9uZW50OmZpeHVwcw==";
const wasmBase64 = "data:application/wasm;base64,AGFzbQEAAAABEgNgAn9/AGACf38Bf2ADf39/AAIzCAABMAAAAAExAAAAATIAAQABMwABAAE0AAEAATUAAQABNgACAAgkaW1wb3J0cwFwAQcHCQ0BAEEACwcAAQIDBAUGAC8JcHJvZHVjZXJzAQxwcm9jZXNzZWQtYnkBDXdpdC1jb21wb25lbnQHMC4yMTUuMAAcBG5hbWUAFRR3aXQtY29tcG9uZW50OmZpeHVwcw==";
/**

@@ -30,0 +30,0 @@ * Returns a WebAssembly.Module for an Arcjet Wasm binary, decoded from a base64

import type { ArcjetLogger } from "@arcjet/protocol";
import type { EmailValidationConfig, BotDetectionResult, BotType, EmailValidationResult, DetectedSensitiveInfoEntity, SensitiveInfoEntities, SensitiveInfoEntity, SensitiveInfoResult } from "./wasm/arcjet_analyze_js_req.component.js";
import type { EmailValidationConfig, EmailValidationResult, DetectedSensitiveInfoEntity, SensitiveInfoEntities, SensitiveInfoEntity, SensitiveInfoResult, BotConfig, BotResult } from "./wasm/arcjet_analyze_js_req.component.js";
import type { ArcjetJsReqSensitiveInformationIdentifier } from "./wasm/interfaces/arcjet-js-req-sensitive-information-identifier.js";

@@ -20,17 +20,4 @@ type AnalyzeRequest = {

type DetectSensitiveInfoFunction = typeof ArcjetJsReqSensitiveInformationIdentifier.detect;
export { type EmailValidationConfig, type BotType,
export { type EmailValidationConfig, type BotConfig, type DetectedSensitiveInfoEntity, type SensitiveInfoEntity, type DetectSensitiveInfoFunction, };
/**
* Represents the result of the bot detection.
*
* @property `botType` - What type of bot this is. This will be one of `BotType`.
* @property `botScore` - A score ranging from 0 to 99 representing the degree of
* certainty. The higher the number within the type category, the greater the
* degree of certainty. E.g. `BotType.Automated` with a score of 1 means we are
* sure the request was made by an automated bot. `BotType.LikelyNotABot` with a
* score of 30 means we don't think this request was a bot, but it's lowest
* confidence level. `BotType.LikelyNotABot` with a score of 99 means we are
* almost certain this request was not a bot.
*/
type BotDetectionResult, type DetectedSensitiveInfoEntity, type SensitiveInfoEntity, type DetectSensitiveInfoFunction, };
/**
* Generate a fingerprint for the client. This is used to identify the client

@@ -44,3 +31,3 @@ * across multiple requests.

export declare function isValidEmail(context: AnalyzeContext, candidate: string, options?: EmailValidationConfig): Promise<EmailValidationResult>;
export declare function detectBot(context: AnalyzeContext, headers: string, patterns_add: string, patterns_remove: string): Promise<BotDetectionResult>;
export declare function detectBot(context: AnalyzeContext, request: AnalyzeRequest, options: BotConfig): Promise<BotResult>;
export declare function detectSensitiveInfo(context: AnalyzeContext, candidate: string, entities: SensitiveInfoEntities, contextWindowSize: number, detect?: DetectSensitiveInfoFunction): Promise<SensitiveInfoResult>;

@@ -97,3 +97,3 @@ import { instantiate } from './wasm/arcjet_analyze_js_req.component.js';

else {
// Skip the local evaluation of the rule if WASM is not available
// Skip the local evaluation of the rule if Wasm is not available
return {

@@ -105,12 +105,12 @@ validity: "valid",

}
async function detectBot(context, headers, patterns_add, patterns_remove) {
async function detectBot(context, request, options) {
const analyze = await init(context);
if (typeof analyze !== "undefined") {
return analyze.detectBot(headers, patterns_add, patterns_remove);
return analyze.detectBot(JSON.stringify(request), options);
}
else {
// TODO: Fallback to JS if we don't have WASM?
// Skip the local evaluation of the rule if Wasm is not available
return {
botType: "not-analyzed",
botScore: 0,
allowed: [],
denied: [],
};

@@ -117,0 +117,0 @@ }

@@ -7,4 +7,2 @@ import type { ArcjetLogger } from "@arcjet/protocol";

EmailValidationConfig,
BotDetectionResult,
BotType,
EmailValidationResult,

@@ -15,2 +13,4 @@ DetectedSensitiveInfoEntity,

SensitiveInfoResult,
BotConfig,
BotResult,
} from "./wasm/arcjet_analyze_js_req.component.js";

@@ -120,16 +120,3 @@ import type { ArcjetJsReqSensitiveInformationIdentifier } from "./wasm/interfaces/arcjet-js-req-sensitive-information-identifier.js";

type EmailValidationConfig,
type BotType,
/**
* Represents the result of the bot detection.
*
* @property `botType` - What type of bot this is. This will be one of `BotType`.
* @property `botScore` - A score ranging from 0 to 99 representing the degree of
* certainty. The higher the number within the type category, the greater the
* degree of certainty. E.g. `BotType.Automated` with a score of 1 means we are
* sure the request was made by an automated bot. `BotType.LikelyNotABot` with a
* score of 30 means we don't think this request was a bot, but it's lowest
* confidence level. `BotType.LikelyNotABot` with a score of 99 means we are
* almost certain this request was not a bot.
*/
type BotDetectionResult,
type BotConfig,
type DetectedSensitiveInfoEntity,

@@ -179,3 +166,3 @@ type SensitiveInfoEntity,

} else {
// Skip the local evaluation of the rule if WASM is not available
// Skip the local evaluation of the rule if Wasm is not available
return {

@@ -190,18 +177,18 @@ validity: "valid",

context: AnalyzeContext,
headers: string,
patterns_add: string,
patterns_remove: string,
): Promise<BotDetectionResult> {
request: AnalyzeRequest,
options: BotConfig,
): Promise<BotResult> {
const analyze = await init(context);
if (typeof analyze !== "undefined") {
return analyze.detectBot(headers, patterns_add, patterns_remove);
return analyze.detectBot(JSON.stringify(request), options);
} else {
// TODO: Fallback to JS if we don't have WASM?
// Skip the local evaluation of the rule if Wasm is not available
return {
botType: "not-analyzed",
botScore: 0,
allowed: [],
denied: [],
};
}
}
export async function detectSensitiveInfo(

@@ -208,0 +195,0 @@ context: AnalyzeContext,

import type { ArcjetLogger } from "@arcjet/protocol";
import type { EmailValidationConfig, BotDetectionResult, BotType, EmailValidationResult, DetectedSensitiveInfoEntity, SensitiveInfoEntities, SensitiveInfoEntity, SensitiveInfoResult } from "./wasm/arcjet_analyze_js_req.component.js";
import type { EmailValidationConfig, EmailValidationResult, DetectedSensitiveInfoEntity, SensitiveInfoEntities, SensitiveInfoEntity, SensitiveInfoResult, BotConfig, BotResult } from "./wasm/arcjet_analyze_js_req.component.js";
import type { ArcjetJsReqSensitiveInformationIdentifier } from "./wasm/interfaces/arcjet-js-req-sensitive-information-identifier.js";

@@ -20,17 +20,4 @@ type AnalyzeRequest = {

type DetectSensitiveInfoFunction = typeof ArcjetJsReqSensitiveInformationIdentifier.detect;
export { type EmailValidationConfig, type BotType,
export { type EmailValidationConfig, type BotConfig, type DetectedSensitiveInfoEntity, type SensitiveInfoEntity, type DetectSensitiveInfoFunction, };
/**
* Represents the result of the bot detection.
*
* @property `botType` - What type of bot this is. This will be one of `BotType`.
* @property `botScore` - A score ranging from 0 to 99 representing the degree of
* certainty. The higher the number within the type category, the greater the
* degree of certainty. E.g. `BotType.Automated` with a score of 1 means we are
* sure the request was made by an automated bot. `BotType.LikelyNotABot` with a
* score of 30 means we don't think this request was a bot, but it's lowest
* confidence level. `BotType.LikelyNotABot` with a score of 99 means we are
* almost certain this request was not a bot.
*/
type BotDetectionResult, type DetectedSensitiveInfoEntity, type SensitiveInfoEntity, type DetectSensitiveInfoFunction, };
/**
* Generate a fingerprint for the client. This is used to identify the client

@@ -44,3 +31,3 @@ * across multiple requests.

export declare function isValidEmail(context: AnalyzeContext, candidate: string, options?: EmailValidationConfig): Promise<EmailValidationResult>;
export declare function detectBot(context: AnalyzeContext, headers: string, patterns_add: string, patterns_remove: string): Promise<BotDetectionResult>;
export declare function detectBot(context: AnalyzeContext, request: AnalyzeRequest, options: BotConfig): Promise<BotResult>;
export declare function detectSensitiveInfo(context: AnalyzeContext, candidate: string, entities: SensitiveInfoEntities, contextWindowSize: number, detect?: DetectSensitiveInfoFunction): Promise<SensitiveInfoResult>;

@@ -116,12 +116,12 @@ import { instantiate } from './wasm/arcjet_analyze_js_req.component.js';

}
async function detectBot(context, headers, patterns_add, patterns_remove) {
async function detectBot(context, request, options) {
const analyze = await init(context);
if (typeof analyze !== "undefined") {
return analyze.detectBot(headers, patterns_add, patterns_remove);
return analyze.detectBot(JSON.stringify(request), options);
}
else {
// TODO: Fallback to JS if we don't have WASM?
// Skip the local evaluation of the rule if Wasm is not available
return {
botType: "not-analyzed",
botScore: 0,
allowed: [],
denied: [],
};

@@ -128,0 +128,0 @@ }

@@ -7,4 +7,2 @@ import type { ArcjetLogger } from "@arcjet/protocol";

EmailValidationConfig,
BotDetectionResult,
BotType,
EmailValidationResult,

@@ -15,2 +13,4 @@ DetectedSensitiveInfoEntity,

SensitiveInfoResult,
BotConfig,
BotResult,
} from "./wasm/arcjet_analyze_js_req.component.js";

@@ -134,16 +134,3 @@ import type { ArcjetJsReqSensitiveInformationIdentifier } from "./wasm/interfaces/arcjet-js-req-sensitive-information-identifier.js";

type EmailValidationConfig,
type BotType,
/**
* Represents the result of the bot detection.
*
* @property `botType` - What type of bot this is. This will be one of `BotType`.
* @property `botScore` - A score ranging from 0 to 99 representing the degree of
* certainty. The higher the number within the type category, the greater the
* degree of certainty. E.g. `BotType.Automated` with a score of 1 means we are
* sure the request was made by an automated bot. `BotType.LikelyNotABot` with a
* score of 30 means we don't think this request was a bot, but it's lowest
* confidence level. `BotType.LikelyNotABot` with a score of 99 means we are
* almost certain this request was not a bot.
*/
type BotDetectionResult,
type BotConfig,
type DetectedSensitiveInfoEntity,

@@ -203,15 +190,14 @@ type SensitiveInfoEntity,

context: AnalyzeContext,
headers: string,
patterns_add: string,
patterns_remove: string,
): Promise<BotDetectionResult> {
request: AnalyzeRequest,
options: BotConfig,
): Promise<BotResult> {
const analyze = await init(context);
if (typeof analyze !== "undefined") {
return analyze.detectBot(headers, patterns_add, patterns_remove);
return analyze.detectBot(JSON.stringify(request), options);
} else {
// TODO: Fallback to JS if we don't have WASM?
// Skip the local evaluation of the rule if Wasm is not available
return {
botType: "not-analyzed",
botScore: 0,
allowed: [],
denied: [],
};

@@ -218,0 +204,0 @@ }

{
"name": "@arcjet/analyze",
"version": "1.0.0-alpha.23",
"version": "1.0.0-alpha.24",
"description": "Arcjet local analysis engine",

@@ -51,8 +51,8 @@ "license": "Apache-2.0",

"dependencies": {
"@arcjet/protocol": "1.0.0-alpha.23"
"@arcjet/protocol": "1.0.0-alpha.24"
},
"devDependencies": {
"@arcjet/eslint-config": "1.0.0-alpha.23",
"@arcjet/rollup-config": "1.0.0-alpha.23",
"@arcjet/tsconfig": "1.0.0-alpha.23",
"@arcjet/eslint-config": "1.0.0-alpha.24",
"@arcjet/rollup-config": "1.0.0-alpha.24",
"@arcjet/tsconfig": "1.0.0-alpha.24",
"@bytecodealliance/jco": "1.5.0",

@@ -59,0 +59,0 @@ "@jest/globals": "29.7.0",

@@ -6,22 +6,2 @@ import type { SensitiveInfoEntity } from './interfaces/arcjet-js-req-sensitive-information-identifier.js';

*
* ## `"unspecified"`
*
* ## `"not-analyzed"`
*
* ## `"automated"`
*
* ## `"likely-automated"`
*
* ## `"likely-not-a-bot"`
*
* ## `"verified-bot"`
*/
export type BotType = 'unspecified' | 'not-analyzed' | 'automated' | 'likely-automated' | 'likely-not-a-bot' | 'verified-bot';
export interface BotDetectionResult {
botType: BotType,
botScore: number,
}
/**
* # Variants
*
* ## `"valid"`

@@ -64,2 +44,24 @@ *

}
export type BotEntity = string;
export interface AllowedBotConfig {
entities: Array<BotEntity>,
skipCustomDetect: boolean,
}
export interface DeniedBotConfig {
entities: Array<BotEntity>,
skipCustomDetect: boolean,
}
export type BotConfig = BotConfigAllowedBotConfig | BotConfigDeniedBotConfig;
export interface BotConfigAllowedBotConfig {
tag: 'allowed-bot-config',
val: AllowedBotConfig,
}
export interface BotConfigDeniedBotConfig {
tag: 'denied-bot-config',
val: DeniedBotConfig,
}
export interface BotResult {
allowed: Array<BotEntity>,
denied: Array<BotEntity>,
}
import { ArcjetJsReqEmailValidatorOverrides } from './interfaces/arcjet-js-req-email-validator-overrides.js';

@@ -74,3 +76,3 @@ import { ArcjetJsReqLogger } from './interfaces/arcjet-js-req-logger.js';

export interface Root {
detectBot(headers: string, patternsAdd: string, patternsRemove: string): BotDetectionResult,
detectBot(request: string, options: BotConfig): BotResult,
generateFingerprint(request: string, characteristics: Array<string>): string,

@@ -77,0 +79,0 @@ isValidEmail(candidate: string, options: EmailValidationConfig): EmailValidationResult,

function instantiate(getCoreModule, imports, instantiateCore = WebAssembly.instantiate) {
function clampGuest(i, min, max) {
if (i < min || i > max) throw new TypeError(`must be between ${min} and ${max}`);
return i;
}
class ComponentError extends Error {

@@ -292,48 +287,82 @@ constructor (value) {

function detectBot(arg0, arg1, arg2) {
function detectBot(arg0, arg1) {
var ptr0 = utf8Encode(arg0, realloc0, memory0);
var len0 = utf8EncodedLen;
var ptr1 = utf8Encode(arg1, realloc0, memory0);
var len1 = utf8EncodedLen;
var ptr2 = utf8Encode(arg2, realloc0, memory0);
var len2 = utf8EncodedLen;
const ret = exports1['detect-bot'](ptr0, len0, ptr1, len1, ptr2, len2);
let variant5;
var variant7 = arg1;
let variant7_0;
let variant7_1;
let variant7_2;
let variant7_3;
switch (variant7.tag) {
case 'allowed-bot-config': {
const e = variant7.val;
var {entities: v1_0, skipCustomDetect: v1_1 } = e;
var vec3 = v1_0;
var len3 = vec3.length;
var result3 = realloc0(0, 0, 4, len3 * 8);
for (let i = 0; i < vec3.length; i++) {
const e = vec3[i];
const base = result3 + i * 8;var ptr2 = utf8Encode(e, realloc0, memory0);
var len2 = utf8EncodedLen;
dataView(memory0).setInt32(base + 4, len2, true);
dataView(memory0).setInt32(base + 0, ptr2, true);
}
variant7_0 = 0;
variant7_1 = result3;
variant7_2 = len3;
variant7_3 = v1_1 ? 1 : 0;
break;
}
case 'denied-bot-config': {
const e = variant7.val;
var {entities: v4_0, skipCustomDetect: v4_1 } = e;
var vec6 = v4_0;
var len6 = vec6.length;
var result6 = realloc0(0, 0, 4, len6 * 8);
for (let i = 0; i < vec6.length; i++) {
const e = vec6[i];
const base = result6 + i * 8;var ptr5 = utf8Encode(e, realloc0, memory0);
var len5 = utf8EncodedLen;
dataView(memory0).setInt32(base + 4, len5, true);
dataView(memory0).setInt32(base + 0, ptr5, true);
}
variant7_0 = 1;
variant7_1 = result6;
variant7_2 = len6;
variant7_3 = v4_1 ? 1 : 0;
break;
}
default: {
throw new TypeError(`invalid variant tag value \`${JSON.stringify(variant7.tag)}\` (received \`${variant7}\`) specified for \`BotConfig\``);
}
}
const ret = exports1['detect-bot'](ptr0, len0, variant7_0, variant7_1, variant7_2, variant7_3);
let variant13;
switch (dataView(memory0).getUint8(ret + 0, true)) {
case 0: {
let enum3;
switch (dataView(memory0).getUint8(ret + 4, true)) {
case 0: {
enum3 = 'unspecified';
break;
}
case 1: {
enum3 = 'not-analyzed';
break;
}
case 2: {
enum3 = 'automated';
break;
}
case 3: {
enum3 = 'likely-automated';
break;
}
case 4: {
enum3 = 'likely-not-a-bot';
break;
}
case 5: {
enum3 = 'verified-bot';
break;
}
default: {
throw new TypeError('invalid discriminant specified for BotType');
}
var len9 = dataView(memory0).getInt32(ret + 8, true);
var base9 = dataView(memory0).getInt32(ret + 4, true);
var result9 = [];
for (let i = 0; i < len9; i++) {
const base = base9 + i * 8;
var ptr8 = dataView(memory0).getInt32(base + 0, true);
var len8 = dataView(memory0).getInt32(base + 4, true);
var result8 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr8, len8));
result9.push(result8);
}
variant5= {
var len11 = dataView(memory0).getInt32(ret + 16, true);
var base11 = dataView(memory0).getInt32(ret + 12, true);
var result11 = [];
for (let i = 0; i < len11; i++) {
const base = base11 + i * 8;
var ptr10 = dataView(memory0).getInt32(base + 0, true);
var len10 = dataView(memory0).getInt32(base + 4, true);
var result10 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr10, len10));
result11.push(result10);
}
variant13= {
tag: 'ok',
val: {
botType: enum3,
botScore: clampGuest(dataView(memory0).getUint8(ret + 5, true), 0, 255),
allowed: result9,
denied: result11,
}

@@ -344,8 +373,8 @@ };

case 1: {
var ptr4 = dataView(memory0).getInt32(ret + 4, true);
var len4 = dataView(memory0).getInt32(ret + 8, true);
var result4 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr4, len4));
variant5= {
var ptr12 = dataView(memory0).getInt32(ret + 4, true);
var len12 = dataView(memory0).getInt32(ret + 8, true);
var result12 = utf8Decoder.decode(new Uint8Array(memory0.buffer, ptr12, len12));
variant13= {
tag: 'err',
val: result4
val: result12
};

@@ -358,3 +387,3 @@ break;

}
const retVal = variant5;
const retVal = variant13;
postReturn0(ret);

@@ -361,0 +390,0 @@ if (typeof retVal === 'object' && retVal.tag === 'err') {

import type { ArcjetLogger } from "@arcjet/protocol";
import type { EmailValidationConfig, BotDetectionResult, BotType, EmailValidationResult, DetectedSensitiveInfoEntity, SensitiveInfoEntities, SensitiveInfoEntity, SensitiveInfoResult } from "./wasm/arcjet_analyze_js_req.component.js";
import type { EmailValidationConfig, EmailValidationResult, DetectedSensitiveInfoEntity, SensitiveInfoEntities, SensitiveInfoEntity, SensitiveInfoResult, BotConfig, BotResult } from "./wasm/arcjet_analyze_js_req.component.js";
import type { ArcjetJsReqSensitiveInformationIdentifier } from "./wasm/interfaces/arcjet-js-req-sensitive-information-identifier.js";

@@ -20,17 +20,4 @@ type AnalyzeRequest = {

type DetectSensitiveInfoFunction = typeof ArcjetJsReqSensitiveInformationIdentifier.detect;
export { type EmailValidationConfig, type BotType,
export { type EmailValidationConfig, type BotConfig, type DetectedSensitiveInfoEntity, type SensitiveInfoEntity, type DetectSensitiveInfoFunction, };
/**
* Represents the result of the bot detection.
*
* @property `botType` - What type of bot this is. This will be one of `BotType`.
* @property `botScore` - A score ranging from 0 to 99 representing the degree of
* certainty. The higher the number within the type category, the greater the
* degree of certainty. E.g. `BotType.Automated` with a score of 1 means we are
* sure the request was made by an automated bot. `BotType.LikelyNotABot` with a
* score of 30 means we don't think this request was a bot, but it's lowest
* confidence level. `BotType.LikelyNotABot` with a score of 99 means we are
* almost certain this request was not a bot.
*/
type BotDetectionResult, type DetectedSensitiveInfoEntity, type SensitiveInfoEntity, type DetectSensitiveInfoFunction, };
/**
* Generate a fingerprint for the client. This is used to identify the client

@@ -44,3 +31,3 @@ * across multiple requests.

export declare function isValidEmail(context: AnalyzeContext, candidate: string, options?: EmailValidationConfig): Promise<EmailValidationResult>;
export declare function detectBot(context: AnalyzeContext, headers: string, patterns_add: string, patterns_remove: string): Promise<BotDetectionResult>;
export declare function detectBot(context: AnalyzeContext, request: AnalyzeRequest, options: BotConfig): Promise<BotResult>;
export declare function detectSensitiveInfo(context: AnalyzeContext, candidate: string, entities: SensitiveInfoEntities, contextWindowSize: number, detect?: DetectSensitiveInfoFunction): Promise<SensitiveInfoResult>;

@@ -97,3 +97,3 @@ import { instantiate } from './wasm/arcjet_analyze_js_req.component.js';

else {
// Skip the local evaluation of the rule if WASM is not available
// Skip the local evaluation of the rule if Wasm is not available
return {

@@ -105,12 +105,12 @@ validity: "valid",

}
async function detectBot(context, headers, patterns_add, patterns_remove) {
async function detectBot(context, request, options) {
const analyze = await init(context);
if (typeof analyze !== "undefined") {
return analyze.detectBot(headers, patterns_add, patterns_remove);
return analyze.detectBot(JSON.stringify(request), options);
}
else {
// TODO: Fallback to JS if we don't have WASM?
// Skip the local evaluation of the rule if Wasm is not available
return {
botType: "not-analyzed",
botScore: 0,
allowed: [],
denied: [],
};

@@ -117,0 +117,0 @@ }

@@ -7,4 +7,2 @@ import type { ArcjetLogger } from "@arcjet/protocol";

EmailValidationConfig,
BotDetectionResult,
BotType,
EmailValidationResult,

@@ -15,2 +13,4 @@ DetectedSensitiveInfoEntity,

SensitiveInfoResult,
BotConfig,
BotResult,
} from "./wasm/arcjet_analyze_js_req.component.js";

@@ -120,16 +120,3 @@ import type { ArcjetJsReqSensitiveInformationIdentifier } from "./wasm/interfaces/arcjet-js-req-sensitive-information-identifier.js";

type EmailValidationConfig,
type BotType,
/**
* Represents the result of the bot detection.
*
* @property `botType` - What type of bot this is. This will be one of `BotType`.
* @property `botScore` - A score ranging from 0 to 99 representing the degree of
* certainty. The higher the number within the type category, the greater the
* degree of certainty. E.g. `BotType.Automated` with a score of 1 means we are
* sure the request was made by an automated bot. `BotType.LikelyNotABot` with a
* score of 30 means we don't think this request was a bot, but it's lowest
* confidence level. `BotType.LikelyNotABot` with a score of 99 means we are
* almost certain this request was not a bot.
*/
type BotDetectionResult,
type BotConfig,
type DetectedSensitiveInfoEntity,

@@ -179,3 +166,3 @@ type SensitiveInfoEntity,

} else {
// Skip the local evaluation of the rule if WASM is not available
// Skip the local evaluation of the rule if Wasm is not available
return {

@@ -190,15 +177,14 @@ validity: "valid",

context: AnalyzeContext,
headers: string,
patterns_add: string,
patterns_remove: string,
): Promise<BotDetectionResult> {
request: AnalyzeRequest,
options: BotConfig,
): Promise<BotResult> {
const analyze = await init(context);
if (typeof analyze !== "undefined") {
return analyze.detectBot(headers, patterns_add, patterns_remove);
return analyze.detectBot(JSON.stringify(request), options);
} else {
// TODO: Fallback to JS if we don't have WASM?
// Skip the local evaluation of the rule if Wasm is not available
return {
botType: "not-analyzed",
botScore: 0,
allowed: [],
denied: [],
};

@@ -205,0 +191,0 @@ }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc