Socket
Socket
Sign inDemoInstall

@arcjet/protocol

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/protocol - npm Package Compare versions

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

well-known-bots.d.ts

6

convert.d.ts
import type { ArcjetRule, ArcjetRateLimitRule } from "./index";
import { ArcjetRuleResult, ArcjetBotType, ArcjetConclusion, ArcjetDecision, ArcjetEmailType, ArcjetMode, ArcjetReason, ArcjetRuleState, ArcjetStack, ArcjetIpDetails } from "./index";
import { ArcjetRuleResult, ArcjetConclusion, ArcjetDecision, ArcjetEmailType, ArcjetMode, ArcjetReason, ArcjetRuleState, ArcjetStack, ArcjetIpDetails } from "./index";
import type { IpDetails } from "./proto/decide/v1alpha1/decide_pb.js";
import { BotType, Conclusion, Decision, EmailType, Mode, Reason, Rule, RuleResult, RuleState, SDKStack } from "./proto/decide/v1alpha1/decide_pb.js";
import { Conclusion, Decision, EmailType, Mode, Reason, Rule, RuleResult, RuleState, SDKStack } from "./proto/decide/v1alpha1/decide_pb.js";
export declare function ArcjetModeToProtocol(mode: ArcjetMode): Mode;
export declare function ArcjetBotTypeToProtocol(botType: ArcjetBotType): BotType;
export declare function ArcjetBotTypeFromProtocol(botType: BotType): ArcjetBotType;
export declare function ArcjetEmailTypeToProtocol(emailType: ArcjetEmailType): EmailType;

@@ -9,0 +7,0 @@ export declare function ArcjetEmailTypeFromProtocol(emailType: EmailType): ArcjetEmailType;

import { Timestamp } from '@bufbuild/protobuf';
import { ArcjetReason, ArcjetErrorReason, ArcjetSensitiveInfoReason, ArcjetEmailReason, ArcjetShieldReason, ArcjetEdgeRuleReason, ArcjetBotReason, ArcjetRateLimitReason, ArcjetRuleResult, ArcjetIpDetails, ArcjetErrorDecision, ArcjetChallengeDecision, ArcjetDenyDecision, ArcjetAllowDecision } from './index.js';
import { Mode, BotType, EmailType, SDKStack, RuleState, Conclusion, Reason, RateLimitReason, BotReason, EdgeRuleReason, ShieldReason, EmailReason, ErrorReason, SensitiveInfoReason, RuleResult, Decision, Rule, RateLimitAlgorithm } from './proto/decide/v1alpha1/decide_pb.js';
import { Mode, EmailType, SDKStack, RuleState, Conclusion, Reason, RateLimitReason, BotV2Reason, EdgeRuleReason, ShieldReason, EmailReason, ErrorReason, SensitiveInfoReason, RuleResult, Decision, Rule, RateLimitAlgorithm } from './proto/decide/v1alpha1/decide_pb.js';

@@ -16,38 +16,2 @@ function ArcjetModeToProtocol(mode) {

}
function ArcjetBotTypeToProtocol(botType) {
switch (botType) {
case "NOT_ANALYZED":
return BotType.NOT_ANALYZED;
case "AUTOMATED":
return BotType.AUTOMATED;
case "LIKELY_AUTOMATED":
return BotType.LIKELY_AUTOMATED;
case "LIKELY_NOT_A_BOT":
return BotType.LIKELY_NOT_A_BOT;
case "VERIFIED_BOT":
return BotType.VERIFIED_BOT;
default: {
return BotType.UNSPECIFIED;
}
}
}
function ArcjetBotTypeFromProtocol(botType) {
switch (botType) {
case BotType.UNSPECIFIED:
throw new Error("Invalid BotType");
case BotType.NOT_ANALYZED:
return "NOT_ANALYZED";
case BotType.AUTOMATED:
return "AUTOMATED";
case BotType.LIKELY_AUTOMATED:
return "LIKELY_AUTOMATED";
case BotType.LIKELY_NOT_A_BOT:
return "LIKELY_NOT_A_BOT";
case BotType.VERIFIED_BOT:
return "VERIFIED_BOT";
default: {
throw new Error("Invalid BotType");
}
}
}
function ArcjetEmailTypeToProtocol(emailType) {

@@ -186,13 +150,7 @@ switch (emailType) {

}
case "bot": {
case "botV2": {
const reason = proto.reason.value;
return new ArcjetBotReason({
botType: ArcjetBotTypeFromProtocol(reason.botType),
botScore: reason.botScore,
userAgentMatch: reason.userAgentMatch,
ipHosting: reason.ipHosting,
ipVpn: reason.ipVpn,
ipProxy: reason.ipProxy,
ipTor: reason.ipTor,
ipRelay: reason.ipRelay,
allowed: reason.allowed,
denied: reason.denied,
});

@@ -222,2 +180,5 @@ }

}
case "bot": {
return new ArcjetErrorReason("bot detection v1 is deprecated");
}
case "error": {

@@ -256,12 +217,6 @@ const reason = proto.reason.value;

reason: {
case: "bot",
value: new BotReason({
botType: ArcjetBotTypeToProtocol(reason.botType),
botScore: reason.botScore,
userAgentMatch: reason.userAgentMatch,
ipHosting: reason.ipHosting,
ipVpn: reason.ipVpn,
ipProxy: reason.ipProxy,
ipTor: reason.ipTor,
ipRelay: reason.ipRelay,
case: "botV2",
value: new BotV2Reason({
allowed: reason.allowed,
denied: reason.denied,
}),

@@ -544,21 +499,11 @@ },

if (isBotRule(rule)) {
const block = Array.isArray(rule.block)
? rule.block.map(ArcjetBotTypeToProtocol)
: [];
const add = Array.isArray(rule.add)
? rule.add.map(([key, botType]) => [
key,
ArcjetBotTypeToProtocol(botType),
])
: [];
const allow = Array.isArray(rule.allow) ? rule.allow : [];
const deny = Array.isArray(rule.deny) ? rule.deny : [];
return new Rule({
rule: {
case: "bots",
case: "botV2",
value: {
mode: ArcjetModeToProtocol(rule.mode),
block,
patterns: {
add: Object.fromEntries(add),
remove: rule.remove,
},
allow,
deny,
},

@@ -593,2 +538,2 @@ },

export { ArcjetBotTypeFromProtocol, ArcjetBotTypeToProtocol, ArcjetConclusionFromProtocol, ArcjetConclusionToProtocol, ArcjetDecisionFromProtocol, ArcjetDecisionToProtocol, ArcjetEmailTypeFromProtocol, ArcjetEmailTypeToProtocol, ArcjetIpDetailsFromProtocol, ArcjetModeToProtocol, ArcjetReasonFromProtocol, ArcjetReasonToProtocol, ArcjetRuleResultFromProtocol, ArcjetRuleResultToProtocol, ArcjetRuleStateFromProtocol, ArcjetRuleStateToProtocol, ArcjetRuleToProtocol, ArcjetStackToProtocol, isRateLimitRule };
export { ArcjetConclusionFromProtocol, ArcjetConclusionToProtocol, ArcjetDecisionFromProtocol, ArcjetDecisionToProtocol, ArcjetEmailTypeFromProtocol, ArcjetEmailTypeToProtocol, ArcjetIpDetailsFromProtocol, ArcjetModeToProtocol, ArcjetReasonFromProtocol, ArcjetReasonToProtocol, ArcjetRuleResultFromProtocol, ArcjetRuleResultToProtocol, ArcjetRuleStateFromProtocol, ArcjetRuleStateToProtocol, ArcjetRuleToProtocol, ArcjetStackToProtocol, isRateLimitRule };

@@ -25,3 +25,2 @@ import { Timestamp } from "@bufbuild/protobuf";

ArcjetShieldReason,
ArcjetBotType,
ArcjetConclusion,

@@ -39,4 +38,3 @@ ArcjetDecision,

import {
BotReason,
BotType,
BotV2Reason,
Conclusion,

@@ -73,42 +71,2 @@ Decision,

export function ArcjetBotTypeToProtocol(botType: ArcjetBotType): BotType {
switch (botType) {
case "NOT_ANALYZED":
return BotType.NOT_ANALYZED;
case "AUTOMATED":
return BotType.AUTOMATED;
case "LIKELY_AUTOMATED":
return BotType.LIKELY_AUTOMATED;
case "LIKELY_NOT_A_BOT":
return BotType.LIKELY_NOT_A_BOT;
case "VERIFIED_BOT":
return BotType.VERIFIED_BOT;
default: {
const _exhaustive: never = botType;
return BotType.UNSPECIFIED;
}
}
}
export function ArcjetBotTypeFromProtocol(botType: BotType): ArcjetBotType {
switch (botType) {
case BotType.UNSPECIFIED:
throw new Error("Invalid BotType");
case BotType.NOT_ANALYZED:
return "NOT_ANALYZED";
case BotType.AUTOMATED:
return "AUTOMATED";
case BotType.LIKELY_AUTOMATED:
return "LIKELY_AUTOMATED";
case BotType.LIKELY_NOT_A_BOT:
return "LIKELY_NOT_A_BOT";
case BotType.VERIFIED_BOT:
return "VERIFIED_BOT";
default: {
const _exhaustive: never = botType;
throw new Error("Invalid BotType");
}
}
}
export function ArcjetEmailTypeToProtocol(

@@ -273,13 +231,7 @@ emailType: ArcjetEmailType,

}
case "bot": {
case "botV2": {
const reason = proto.reason.value;
return new ArcjetBotReason({
botType: ArcjetBotTypeFromProtocol(reason.botType),
botScore: reason.botScore,
userAgentMatch: reason.userAgentMatch,
ipHosting: reason.ipHosting,
ipVpn: reason.ipVpn,
ipProxy: reason.ipProxy,
ipTor: reason.ipTor,
ipRelay: reason.ipRelay,
allowed: reason.allowed,
denied: reason.denied,
});

@@ -309,2 +261,5 @@ }

}
case "bot": {
return new ArcjetErrorReason("bot detection v1 is deprecated");
}
case "error": {

@@ -345,12 +300,6 @@ const reason = proto.reason.value;

reason: {
case: "bot",
value: new BotReason({
botType: ArcjetBotTypeToProtocol(reason.botType),
botScore: reason.botScore,
userAgentMatch: reason.userAgentMatch,
ipHosting: reason.ipHosting,
ipVpn: reason.ipVpn,
ipProxy: reason.ipProxy,
ipTor: reason.ipTor,
ipRelay: reason.ipRelay,
case: "botV2",
value: new BotV2Reason({
allowed: reason.allowed,
denied: reason.denied,
}),

@@ -689,21 +638,11 @@ },

if (isBotRule(rule)) {
const block = Array.isArray(rule.block)
? rule.block.map(ArcjetBotTypeToProtocol)
: [];
const add = Array.isArray(rule.add)
? rule.add.map(([key, botType]) => [
key,
ArcjetBotTypeToProtocol(botType),
])
: [];
const allow = Array.isArray(rule.allow) ? rule.allow : [];
const deny = Array.isArray(rule.deny) ? rule.deny : [];
return new Rule({
rule: {
case: "bots",
case: "botV2",
value: {
mode: ArcjetModeToProtocol(rule.mode),
block,
patterns: {
add: Object.fromEntries(add),
remove: rule.remove,
},
allow,
deny,
},

@@ -710,0 +649,0 @@ },

@@ -0,1 +1,2 @@

export type * from "./well-known-bots.js";
type RequiredProps<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;

@@ -9,4 +10,2 @@ type ArcjetEnum<T extends string> = {

export declare const ArcjetRateLimitAlgorithm: ArcjetEnum<ArcjetRateLimitAlgorithm>;
export type ArcjetBotType = "NOT_ANALYZED" | "AUTOMATED" | "LIKELY_AUTOMATED" | "LIKELY_NOT_A_BOT" | "VERIFIED_BOT";
export declare const ArcjetBotType: ArcjetEnum<ArcjetBotType>;
export type ArcjetEmailType = "DISPOSABLE" | "FREE" | "NO_MX_RECORDS" | "NO_GRAVATAR" | "INVALID";

@@ -65,19 +64,7 @@ export declare const ArcjetEmailType: ArcjetEnum<ArcjetEmailType>;

type: "BOT";
botType: ArcjetBotType;
botScore: number;
userAgentMatch: boolean;
ipHosting: boolean;
ipVpn: boolean;
ipProxy: boolean;
ipTor: boolean;
ipRelay: boolean;
allowed: Array<string>;
denied: Array<string>;
constructor(init: {
botType: ArcjetBotType;
botScore?: number;
userAgentMatch?: boolean;
ipHosting?: boolean;
ipVpn?: boolean;
ipProxy?: boolean;
ipTor?: boolean;
ipRelay?: boolean;
allowed: Array<string>;
denied: Array<string>;
});

@@ -401,5 +388,4 @@ }

type: "BOT";
block: ArcjetBotType[];
add: [string, ArcjetBotType][];
remove: string[];
allow: Array<string>;
deny: Array<string>;
}

@@ -430,2 +416,1 @@ export interface ArcjetShieldRule<Props extends {}> extends ArcjetRule<Props> {

};
export {};

@@ -13,9 +13,2 @@ import { typeid } from 'typeid-js';

});
const ArcjetBotType = Object.freeze({
NOT_ANALYZED: "NOT_ANALYZED",
AUTOMATED: "AUTOMATED",
LIKELY_AUTOMATED: "LIKELY_AUTOMATED",
LIKELY_NOT_A_BOT: "LIKELY_NOT_A_BOT",
VERIFIED_BOT: "VERIFIED_BOT",
});
const ArcjetEmailType = {

@@ -108,20 +101,8 @@ DISPOSABLE: "DISPOSABLE",

type = "BOT";
botType;
botScore;
userAgentMatch;
ipHosting;
ipVpn;
ipProxy;
ipTor;
ipRelay;
allowed;
denied;
constructor(init) {
super();
this.botType = init.botType;
this.botScore = init.botScore ?? 0;
this.userAgentMatch = init.userAgentMatch ?? false;
this.ipHosting = init.ipHosting ?? false;
this.ipVpn = init.ipVpn ?? false;
this.ipProxy = init.ipProxy ?? false;
this.ipTor = init.ipTor ?? false;
this.ipRelay = init.ipRelay ?? false;
this.allowed = init.allowed;
this.denied = init.denied;
}

@@ -490,2 +471,2 @@ }

export { ArcjetAllowDecision, ArcjetBotReason, ArcjetBotType, ArcjetChallengeDecision, ArcjetConclusion, ArcjetDecision, ArcjetDenyDecision, ArcjetEdgeRuleReason, ArcjetEmailReason, ArcjetEmailType, ArcjetErrorDecision, ArcjetErrorReason, ArcjetIpDetails, ArcjetMode, ArcjetRateLimitAlgorithm, ArcjetRateLimitReason, ArcjetReason, ArcjetRuleResult, ArcjetRuleState, ArcjetRuleType, ArcjetSensitiveInfoReason, ArcjetSensitiveInfoType, ArcjetShieldReason, ArcjetStack };
export { ArcjetAllowDecision, ArcjetBotReason, ArcjetChallengeDecision, ArcjetConclusion, ArcjetDecision, ArcjetDenyDecision, ArcjetEdgeRuleReason, ArcjetEmailReason, ArcjetEmailType, ArcjetErrorDecision, ArcjetErrorReason, ArcjetIpDetails, ArcjetMode, ArcjetRateLimitAlgorithm, ArcjetRateLimitReason, ArcjetReason, ArcjetRuleResult, ArcjetRuleState, ArcjetRuleType, ArcjetSensitiveInfoReason, ArcjetSensitiveInfoType, ArcjetShieldReason, ArcjetStack };
import { typeid } from "typeid-js";
import { Reason } from "./proto/decide/v1alpha1/decide_pb.js";
// Re-export the Well Known Bots from the generated file
export type * from "./well-known-bots.js";
type RequiredProps<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;

@@ -25,16 +28,2 @@

export type ArcjetBotType =
| "NOT_ANALYZED"
| "AUTOMATED"
| "LIKELY_AUTOMATED"
| "LIKELY_NOT_A_BOT"
| "VERIFIED_BOT";
export const ArcjetBotType: ArcjetEnum<ArcjetBotType> = Object.freeze({
NOT_ANALYZED: "NOT_ANALYZED",
AUTOMATED: "AUTOMATED",
LIKELY_AUTOMATED: "LIKELY_AUTOMATED",
LIKELY_NOT_A_BOT: "LIKELY_NOT_A_BOT",
VERIFIED_BOT: "VERIFIED_BOT",
});
export type ArcjetEmailType =

@@ -187,31 +176,10 @@ | "DISPOSABLE"

botType: ArcjetBotType;
botScore: number;
userAgentMatch: boolean;
ipHosting: boolean;
ipVpn: boolean;
ipProxy: boolean;
ipTor: boolean;
ipRelay: boolean;
allowed: Array<string>;
denied: Array<string>;
constructor(init: {
botType: ArcjetBotType;
botScore?: number;
userAgentMatch?: boolean;
ipHosting?: boolean;
ipVpn?: boolean;
ipProxy?: boolean;
ipTor?: boolean;
ipRelay?: boolean;
}) {
constructor(init: { allowed: Array<string>; denied: Array<string> }) {
super();
this.botType = init.botType;
this.botScore = init.botScore ?? 0;
this.userAgentMatch = init.userAgentMatch ?? false;
this.ipHosting = init.ipHosting ?? false;
this.ipVpn = init.ipVpn ?? false;
this.ipProxy = init.ipProxy ?? false;
this.ipTor = init.ipTor ?? false;
this.ipRelay = init.ipRelay ?? false;
this.allowed = init.allowed;
this.denied = init.denied;
}

@@ -792,5 +760,4 @@ }

block: ArcjetBotType[];
add: [string, ArcjetBotType][];
remove: string[];
allow: Array<string>;
deny: Array<string>;
}

@@ -797,0 +764,0 @@

{
"name": "@arcjet/protocol",
"version": "1.0.0-alpha.23",
"version": "1.0.0-alpha.24",
"description": "The TypeScript & JavaScript interface into the Arcjet protocol",

@@ -49,5 +49,5 @@ "license": "Apache-2.0",

"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",
"@jest/globals": "29.7.0",

@@ -54,0 +54,0 @@ "@rollup/wasm-node": "4.21.2",

@@ -587,3 +587,3 @@ // @generated by protoc-gen-es v1.10.0

/**
* Contains details about sensitive info identified in the body of the
* Contains details about sensitive info identified in the body of the
* request if the sensitive info rule is configured.

@@ -595,2 +595,11 @@ *

case: "sensitiveInfo";
} | {
/**
* Contains details about why the request was considered a bot when the
* decision was made based on a bot (v2) rule.
*
* @generated from field: proto.decide.v1alpha1.BotV2Reason bot_v2 = 8;
*/
value: BotV2Reason;
case: "botV2";
} | { case: undefined; value?: undefined };

@@ -782,2 +791,33 @@

/**
* Details of a bot (v2) decision.
*
* @generated from message proto.decide.v1alpha1.BotV2Reason
*/
export declare class BotV2Reason extends Message<BotV2Reason> {
/**
* @generated from field: repeated string allowed = 1;
*/
allowed: string[];
/**
* @generated from field: repeated string denied = 2;
*/
denied: string[];
constructor(data?: PartialMessage<BotV2Reason>);
static readonly runtime: typeof proto3;
static readonly typeName = "proto.decide.v1alpha1.BotV2Reason";
static readonly fields: FieldList;
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): BotV2Reason;
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): BotV2Reason;
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): BotV2Reason;
static equals(a: BotV2Reason | PlainMessage<BotV2Reason> | undefined, b: BotV2Reason | PlainMessage<BotV2Reason> | undefined): boolean;
}
/**
* Details of an Arcjet Shield decision.

@@ -1153,2 +1193,38 @@ *

/**
* The configuration for a bot (v2) rule.
*
* @generated from message proto.decide.v1alpha1.BotV2Rule
*/
export declare class BotV2Rule extends Message<BotV2Rule> {
/**
* @generated from field: proto.decide.v1alpha1.Mode mode = 1;
*/
mode: Mode;
/**
* @generated from field: repeated string allow = 2;
*/
allow: string[];
/**
* @generated from field: repeated string deny = 3;
*/
deny: string[];
constructor(data?: PartialMessage<BotV2Rule>);
static readonly runtime: typeof proto3;
static readonly typeName = "proto.decide.v1alpha1.BotV2Rule";
static readonly fields: FieldList;
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): BotV2Rule;
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): BotV2Rule;
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): BotV2Rule;
static equals(a: BotV2Rule | PlainMessage<BotV2Rule> | undefined, b: BotV2Rule | PlainMessage<BotV2Rule> | undefined): boolean;
}
/**
* The configuration for an email rule.

@@ -1305,2 +1381,8 @@ *

case: "sensitiveInfo";
} | {
/**
* @generated from field: proto.decide.v1alpha1.BotV2Rule bot_v2 = 6;
*/
value: BotV2Rule;
case: "botV2";
} | { case: undefined; value?: undefined };

@@ -1307,0 +1389,0 @@

@@ -178,2 +178,3 @@ // @generated by protoc-gen-es v1.10.0

{ no: 7, name: "sensitive_info", kind: "message", T: SensitiveInfoReason, oneof: "reason" },
{ no: 8, name: "bot_v2", kind: "message", T: BotV2Reason, oneof: "reason" },
],

@@ -229,2 +230,15 @@ );

/**
* Details of a bot (v2) decision.
*
* @generated from message proto.decide.v1alpha1.BotV2Reason
*/
export const BotV2Reason = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.BotV2Reason",
() => [
{ no: 1, name: "allowed", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
{ no: 2, name: "denied", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
],
);
/**
* Details of an Arcjet Shield decision.

@@ -340,2 +354,16 @@ *

/**
* The configuration for a bot (v2) rule.
*
* @generated from message proto.decide.v1alpha1.BotV2Rule
*/
export const BotV2Rule = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.BotV2Rule",
() => [
{ no: 1, name: "mode", kind: "enum", T: proto3.getEnumType(Mode) },
{ no: 2, name: "allow", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
{ no: 3, name: "deny", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
],
);
/**
* The configuration for an email rule.

@@ -395,2 +423,3 @@ *

{ no: 5, name: "sensitive_info", kind: "message", T: SensitiveInfoRule, oneof: "rule" },
{ no: 6, name: "bot_v2", kind: "message", T: BotV2Rule, oneof: "rule" },
],

@@ -397,0 +426,0 @@ );

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