Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@arcjet/protocol

Package Overview
Dependencies
Maintainers
2
Versions
29
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.10 to 1.0.0-alpha.11

5

convert.d.ts

@@ -1,3 +0,3 @@

import { ArcjetRuleResult, ArcjetBotType, ArcjetConclusion, ArcjetDecision, ArcjetEmailType, ArcjetMode, ArcjetReason, ArcjetRuleState, ArcjetStack, ArcjetRule } from "./index";
import { BotType, Conclusion, Decision, EmailType, Mode, Reason, Rule, RuleResult, RuleState, SDKStack } from "./gen/es/decide/v1alpha1/decide_pb.js";
import { ArcjetRuleResult, ArcjetBotType, ArcjetConclusion, ArcjetDecision, ArcjetEmailType, ArcjetMode, ArcjetReason, ArcjetRuleState, ArcjetStack, ArcjetRule, ArcjetIpDetails } from "./index";
import { BotType, Conclusion, Decision, EmailType, IpDetails, Mode, Reason, Rule, RuleResult, RuleState, SDKStack } from "./gen/es/decide/v1alpha1/decide_pb.js";
export declare function ArcjetModeToProtocol(mode: ArcjetMode): Mode;

@@ -18,2 +18,3 @@ export declare function ArcjetBotTypeToProtocol(botType: ArcjetBotType): BotType;

export declare function ArcjetDecisionToProtocol(decision: ArcjetDecision): Decision;
export declare function ArcjetIpDetailsFromProtocol(ipDetails?: IpDetails): ArcjetIpDetails;
export declare function ArcjetDecisionFromProtocol(decision?: Decision): ArcjetDecision;

@@ -20,0 +21,0 @@ export declare function ArcjetRuleToProtocol<Props extends {

55

convert.js
import { Timestamp } from '@bufbuild/protobuf';
import { ArcjetReason, ArcjetErrorReason, ArcjetEmailReason, ArcjetShieldReason, ArcjetEdgeRuleReason, ArcjetBotReason, ArcjetRateLimitReason, ArcjetRuleResult, ArcjetErrorDecision, ArcjetChallengeDecision, ArcjetDenyDecision, ArcjetAllowDecision } from './index.js';
import { ArcjetReason, ArcjetErrorReason, 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, RuleResult, Decision, Rule, RateLimitAlgorithm } from './gen/es/decide/v1alpha1/decide_pb.js';

@@ -312,2 +312,46 @@

}
function ArcjetIpDetailsFromProtocol(ipDetails) {
if (!ipDetails) {
return new ArcjetIpDetails();
}
// A default value from the Decide service means we don't have data for the
// field so we translate to `undefined`. Some fields have interconnected logic
// that determines if the default value can be provided to users.
return new ArcjetIpDetails({
// If we have a non-0 latitude, or a 0 latitude with a non-0 accuracy radius
// then we have a latitude from the Decide service
latitude: ipDetails.latitude || ipDetails.accuracyRadius
? ipDetails.latitude
: undefined,
// If we have a non-0 longitude, or a 0 longitude with a non-0 accuracy
// radius then we have a longitude from the Decide service
longitude: ipDetails.longitude || ipDetails.accuracyRadius
? ipDetails.longitude
: undefined,
// If we have a non-0 latitude/longitude/accuracyRadius, we assume that the
// accuracyRadius value was set
accuracyRadius: ipDetails.longitude || ipDetails.latitude || ipDetails.accuracyRadius
? ipDetails.accuracyRadius
: undefined,
timezone: ipDetails.timezone !== "" ? ipDetails.timezone : undefined,
postalCode: ipDetails.postalCode !== "" ? ipDetails.postalCode : undefined,
city: ipDetails.city !== "" ? ipDetails.city : undefined,
region: ipDetails.region !== "" ? ipDetails.region : undefined,
country: ipDetails.country !== "" ? ipDetails.country : undefined,
countryName: ipDetails.countryName !== "" ? ipDetails.countryName : undefined,
continent: ipDetails.continent !== "" ? ipDetails.continent : undefined,
continentName: ipDetails.continentName !== "" ? ipDetails.continentName : undefined,
asn: ipDetails.asn !== "" ? ipDetails.asn : undefined,
asnName: ipDetails.asnName !== "" ? ipDetails.asnName : undefined,
asnDomain: ipDetails.asnDomain !== "" ? ipDetails.asnDomain : undefined,
asnType: ipDetails.asnType !== "" ? ipDetails.asnType : undefined,
asnCountry: ipDetails.asnCountry !== "" ? ipDetails.asnCountry : undefined,
service: ipDetails.service !== "" ? ipDetails.service : undefined,
isHosting: ipDetails.isHosting,
isVpn: ipDetails.isVpn,
isProxy: ipDetails.isProxy,
isTor: ipDetails.isTor,
isRelay: ipDetails.isRelay,
});
}
function ArcjetDecisionFromProtocol(decision) {

@@ -319,2 +363,3 @@ if (typeof decision === "undefined") {

results: [],
ip: new ArcjetIpDetails(),
});

@@ -332,2 +377,3 @@ }

results,
ip: ArcjetIpDetailsFromProtocol(decision.ipDetails),
});

@@ -340,2 +386,3 @@ case Conclusion.DENY:

results,
ip: ArcjetIpDetailsFromProtocol(decision.ipDetails),
});

@@ -348,2 +395,3 @@ case Conclusion.CHALLENGE:

results,
ip: ArcjetIpDetailsFromProtocol(decision.ipDetails),
});

@@ -356,2 +404,3 @@ case Conclusion.ERROR:

results,
ip: ArcjetIpDetailsFromProtocol(decision.ipDetails),
});

@@ -364,2 +413,3 @@ case Conclusion.UNSPECIFIED:

results,
ip: ArcjetIpDetailsFromProtocol(decision.ipDetails),
});

@@ -372,2 +422,3 @@ default:

results: [],
ip: ArcjetIpDetailsFromProtocol(decision.ipDetails),
});

@@ -484,2 +535,2 @@ }

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

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

ArcjetSlidingWindowRateLimitRule,
ArcjetIpDetails,
} from "./index";

@@ -40,2 +41,3 @@ import {

ErrorReason,
IpDetails,
Mode,

@@ -406,2 +408,55 @@ RateLimitAlgorithm,

export function ArcjetIpDetailsFromProtocol(
ipDetails?: IpDetails,
): ArcjetIpDetails {
if (!ipDetails) {
return new ArcjetIpDetails();
}
// A default value from the Decide service means we don't have data for the
// field so we translate to `undefined`. Some fields have interconnected logic
// that determines if the default value can be provided to users.
return new ArcjetIpDetails({
// If we have a non-0 latitude, or a 0 latitude with a non-0 accuracy radius
// then we have a latitude from the Decide service
latitude:
ipDetails.latitude || ipDetails.accuracyRadius
? ipDetails.latitude
: undefined,
// If we have a non-0 longitude, or a 0 longitude with a non-0 accuracy
// radius then we have a longitude from the Decide service
longitude:
ipDetails.longitude || ipDetails.accuracyRadius
? ipDetails.longitude
: undefined,
// If we have a non-0 latitude/longitude/accuracyRadius, we assume that the
// accuracyRadius value was set
accuracyRadius:
ipDetails.longitude || ipDetails.latitude || ipDetails.accuracyRadius
? ipDetails.accuracyRadius
: undefined,
timezone: ipDetails.timezone !== "" ? ipDetails.timezone : undefined,
postalCode: ipDetails.postalCode !== "" ? ipDetails.postalCode : undefined,
city: ipDetails.city !== "" ? ipDetails.city : undefined,
region: ipDetails.region !== "" ? ipDetails.region : undefined,
country: ipDetails.country !== "" ? ipDetails.country : undefined,
countryName:
ipDetails.countryName !== "" ? ipDetails.countryName : undefined,
continent: ipDetails.continent !== "" ? ipDetails.continent : undefined,
continentName:
ipDetails.continentName !== "" ? ipDetails.continentName : undefined,
asn: ipDetails.asn !== "" ? ipDetails.asn : undefined,
asnName: ipDetails.asnName !== "" ? ipDetails.asnName : undefined,
asnDomain: ipDetails.asnDomain !== "" ? ipDetails.asnDomain : undefined,
asnType: ipDetails.asnType !== "" ? ipDetails.asnType : undefined,
asnCountry: ipDetails.asnCountry !== "" ? ipDetails.asnCountry : undefined,
service: ipDetails.service !== "" ? ipDetails.service : undefined,
isHosting: ipDetails.isHosting,
isVpn: ipDetails.isVpn,
isProxy: ipDetails.isProxy,
isTor: ipDetails.isTor,
isRelay: ipDetails.isRelay,
});
}
export function ArcjetDecisionFromProtocol(

@@ -415,2 +470,3 @@ decision?: Decision,

results: [],
ip: new ArcjetIpDetails(),
});

@@ -430,2 +486,3 @@ }

results,
ip: ArcjetIpDetailsFromProtocol(decision.ipDetails),
});

@@ -438,2 +495,3 @@ case Conclusion.DENY:

results,
ip: ArcjetIpDetailsFromProtocol(decision.ipDetails),
});

@@ -446,2 +504,3 @@ case Conclusion.CHALLENGE:

results,
ip: ArcjetIpDetailsFromProtocol(decision.ipDetails),
});

@@ -454,2 +513,3 @@ case Conclusion.ERROR:

results,
ip: ArcjetIpDetailsFromProtocol(decision.ipDetails),
});

@@ -462,2 +522,3 @@ case Conclusion.UNSPECIFIED:

results,
ip: ArcjetIpDetailsFromProtocol(decision.ipDetails),
});

@@ -470,2 +531,3 @@ default:

results: [],
ip: ArcjetIpDetailsFromProtocol(decision.ipDetails),
});

@@ -472,0 +534,0 @@ }

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

// @generated by protoc-gen-connect-es v1.3.0
// @generated by protoc-gen-connect-es v1.4.0
// @generated from file decide/v1alpha1/decide.proto (package proto.decide.v1alpha1, syntax proto3)

@@ -3,0 +3,0 @@ /* eslint-disable */

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

// @generated by protoc-gen-connect-es v1.3.0
// @generated by protoc-gen-connect-es v1.4.0
// @generated from file decide/v1alpha1/decide.proto (package proto.decide.v1alpha1, syntax proto3)

@@ -3,0 +3,0 @@ /* eslint-disable */

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

// @generated by protoc-gen-es v1.7.1
// @generated by protoc-gen-es v1.8.0
// @generated from file decide/v1alpha1/decide.proto (package proto.decide.v1alpha1, syntax proto3)

@@ -183,4 +183,4 @@ /* eslint-disable */

/**
* The rule was run and the outcome was
* taken into consideration for the end decision
* The rule was run and the outcome was taken into consideration for the end
* decision
*

@@ -199,4 +199,4 @@ * @generated from enum value: RULE_STATE_RUN = 1;

/**
* The rule was run but not actioned on,
* meaning the outcome didn't affect the end decision
* The rule was run but not actioned on, meaning the outcome didn't affect
* the end decision
*

@@ -317,6 +317,183 @@ * @generated from enum value: RULE_STATE_DRY_RUN = 3;

/**
* Additional information from Arcjet about the IP address associated with a
* request.
*
* @generated from message proto.decide.v1alpha1.IpDetails
*/
export declare class IpDetails extends Message<IpDetails> {
/**
* The estimated latitude of the IP address - see accuracy_radius for the
* margin of error.
*
* @generated from field: double latitude = 1;
*/
latitude: number;
/**
* The estimated longitude of the IP address - see accuracy_radius for the
* margin of error.
*
* @generated from field: double longitude = 2;
*/
longitude: number;
/**
* The accuracy radius of the IP address location in kilometers.
*
* @generated from field: int32 accuracy_radius = 3;
*/
accuracyRadius: number;
/**
* The timezone of the IP address.
*
* @generated from field: string timezone = 4;
*/
timezone: string;
/**
* The postal code of the IP address.
*
* @generated from field: string postal_code = 5;
*/
postalCode: string;
/**
* The city the IP address is located in.
*
* @generated from field: string city = 6;
*/
city: string;
/**
* The region the IP address is located in.
*
* @generated from field: string region = 7;
*/
region: string;
/**
* The country code the IP address is located in.
*
* @generated from field: string country = 8;
*/
country: string;
/**
* The country name the IP address is located in.
*
* @generated from field: string country_name = 9;
*/
countryName: string;
/**
* The continent code the IP address is located in.
*
* @generated from field: string continent = 10;
*/
continent: string;
/**
* The continent name the IP address is located in.
*
* @generated from field: string continent_name = 11;
*/
continentName: string;
/**
* The AS number the IP address belongs to.
*
* @generated from field: string asn = 12;
*/
asn: string;
/**
* The AS name the IP address belongs to.
*
* @generated from field: string asn_name = 13;
*/
asnName: string;
/**
* The AS domain the IP address belongs to.
*
* @generated from field: string asn_domain = 14;
*/
asnDomain: string;
/**
* The ASN type: ISP, hosting, business, or education
*
* @generated from field: string asn_type = 15;
*/
asnType: string;
/**
* The ASN country code the IP address belongs to.
*
* @generated from field: string asn_country = 16;
*/
asnCountry: string;
/**
* The name of the service the IP address belongs to.
*
* @generated from field: string service = 17;
*/
service: string;
/**
* Whether the IP address belongs to a hosting provider.
*
* @generated from field: bool is_hosting = 18;
*/
isHosting: boolean;
/**
* Whether the IP address belongs to a VPN provider.
*
* @generated from field: bool is_vpn = 19;
*/
isVpn: boolean;
/**
* Whether the IP address belongs to a proxy provider.
*
* @generated from field: bool is_proxy = 20;
*/
isProxy: boolean;
/**
* Whether the IP address belongs to a Tor node.
*
* @generated from field: bool is_tor = 21;
*/
isTor: boolean;
/**
* Whether the IP address belongs to a relay service.
*
* @generated from field: bool is_relay = 22;
*/
isRelay: boolean;
constructor(data?: PartialMessage<IpDetails>);
static readonly runtime: typeof proto3;
static readonly typeName = "proto.decide.v1alpha1.IpDetails";
static readonly fields: FieldList;
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): IpDetails;
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): IpDetails;
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): IpDetails;
static equals(a: IpDetails | PlainMessage<IpDetails> | undefined, b: IpDetails | PlainMessage<IpDetails> | undefined): boolean;
}
/**
* The reason for the decision. This is populated based on the selected rules
* for deny or challenge responses. Additional details can be found in the
* field and by logging into the Arcjet dashboard and searching for the
* decision ID.
* for deny or challenge responses. Additional details can be found in the field
* and by logging into the Arcjet dashboard and searching for the decision ID.
*

@@ -340,4 +517,4 @@ * @generated from message proto.decide.v1alpha1.Reason

/**
* Contains details about the edge rules which were triggered when
* the decision was made based on an edge rule.
* Contains details about the edge rules which were triggered when the
* decision was made based on an edge rule.
*

@@ -350,4 +527,4 @@ * @generated from field: proto.decide.v1alpha1.EdgeRuleReason edge_rule = 2;

/**
* Contains details about why the request was considered a bot when
* the decision was made based on a bot rule.
* Contains details about why the request was considered a bot when the
* decision was made based on a bot rule.
*

@@ -368,4 +545,4 @@ * @generated from field: proto.decide.v1alpha1.BotReason bot = 3;

/**
* Contains details about the email when the decision was made based
* on an email rule.
* Contains details about the email when the decision was made based on
* an email rule.
*

@@ -470,3 +647,3 @@ * @generated from field: proto.decide.v1alpha1.EmailReason email = 5;

/**
* Details of an edge rule decision. Unimplmented.
* Details of an edge rule decision. Unimplemented.
*

@@ -1125,4 +1302,4 @@ * @generated from message proto.decide.v1alpha1.EdgeRuleReason

/**
* The duration in seconds this decision should be considered valid,
* also known as time-to-live.
* The duration in seconds this decision should be considered valid, also
* known as time-to-live.
*

@@ -1133,2 +1310,9 @@ * @generated from field: uint32 ttl = 5;

/**
* Details about the IP address that informed our conclusion.
*
* @generated from field: proto.decide.v1alpha1.IpDetails ip_details = 6;
*/
ipDetails?: IpDetails;
constructor(data?: PartialMessage<Decision>);

@@ -1135,0 +1319,0 @@

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

// @generated by protoc-gen-es v1.7.1
// @generated by protoc-gen-es v1.8.0
// @generated from file decide/v1alpha1/decide.proto (package proto.decide.v1alpha1, syntax proto3)

@@ -15,3 +15,3 @@ /* eslint-disable */

*/
export const BotType = proto3.makeEnum(
export const BotType = /*@__PURE__*/ proto3.makeEnum(
"proto.decide.v1alpha1.BotType",

@@ -33,3 +33,3 @@ [

*/
export const EmailType = proto3.makeEnum(
export const EmailType = /*@__PURE__*/ proto3.makeEnum(
"proto.decide.v1alpha1.EmailType",

@@ -54,3 +54,3 @@ [

*/
export const Mode = proto3.makeEnum(
export const Mode = /*@__PURE__*/ proto3.makeEnum(
"proto.decide.v1alpha1.Mode",

@@ -67,3 +67,3 @@ [

*/
export const RuleState = proto3.makeEnum(
export const RuleState = /*@__PURE__*/ proto3.makeEnum(
"proto.decide.v1alpha1.RuleState",

@@ -85,3 +85,3 @@ [

*/
export const Conclusion = proto3.makeEnum(
export const Conclusion = /*@__PURE__*/ proto3.makeEnum(
"proto.decide.v1alpha1.Conclusion",

@@ -102,3 +102,3 @@ [

*/
export const SDKStack = proto3.makeEnum(
export const SDKStack = /*@__PURE__*/ proto3.makeEnum(
"proto.decide.v1alpha1.SDKStack",

@@ -117,3 +117,3 @@ [

*/
export const RateLimitAlgorithm = proto3.makeEnum(
export const RateLimitAlgorithm = /*@__PURE__*/ proto3.makeEnum(
"proto.decide.v1alpha1.RateLimitAlgorithm",

@@ -129,10 +129,43 @@ [

/**
* Additional information from Arcjet about the IP address associated with a
* request.
*
* @generated from message proto.decide.v1alpha1.IpDetails
*/
export const IpDetails = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.IpDetails",
() => [
{ no: 1, name: "latitude", kind: "scalar", T: 1 /* ScalarType.DOUBLE */ },
{ no: 2, name: "longitude", kind: "scalar", T: 1 /* ScalarType.DOUBLE */ },
{ no: 3, name: "accuracy_radius", kind: "scalar", T: 5 /* ScalarType.INT32 */ },
{ no: 4, name: "timezone", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 5, name: "postal_code", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 6, name: "city", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 7, name: "region", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 8, name: "country", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 9, name: "country_name", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 10, name: "continent", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 11, name: "continent_name", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 12, name: "asn", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 13, name: "asn_name", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 14, name: "asn_domain", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 15, name: "asn_type", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 16, name: "asn_country", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 17, name: "service", kind: "scalar", T: 9 /* ScalarType.STRING */ },
{ no: 18, name: "is_hosting", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
{ no: 19, name: "is_vpn", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
{ no: 20, name: "is_proxy", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
{ no: 21, name: "is_tor", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
{ no: 22, name: "is_relay", kind: "scalar", T: 8 /* ScalarType.BOOL */ },
],
);
/**
* The reason for the decision. This is populated based on the selected rules
* for deny or challenge responses. Additional details can be found in the
* field and by logging into the Arcjet dashboard and searching for the
* decision ID.
* for deny or challenge responses. Additional details can be found in the field
* and by logging into the Arcjet dashboard and searching for the decision ID.
*
* @generated from message proto.decide.v1alpha1.Reason
*/
export const Reason = proto3.makeMessageType(
export const Reason = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.Reason",

@@ -154,3 +187,3 @@ () => [

*/
export const RateLimitReason = proto3.makeMessageType(
export const RateLimitReason = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.RateLimitReason",

@@ -168,7 +201,7 @@ () => [

/**
* Details of an edge rule decision. Unimplmented.
* Details of an edge rule decision. Unimplemented.
*
* @generated from message proto.decide.v1alpha1.EdgeRuleReason
*/
export const EdgeRuleReason = proto3.makeMessageType(
export const EdgeRuleReason = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.EdgeRuleReason",

@@ -183,3 +216,3 @@ [],

*/
export const BotReason = proto3.makeMessageType(
export const BotReason = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.BotReason",

@@ -203,3 +236,3 @@ () => [

*/
export const ShieldReason = proto3.makeMessageType(
export const ShieldReason = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.ShieldReason",

@@ -217,3 +250,3 @@ () => [

*/
export const EmailReason = proto3.makeMessageType(
export const EmailReason = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.EmailReason",

@@ -230,3 +263,3 @@ () => [

*/
export const ErrorReason = proto3.makeMessageType(
export const ErrorReason = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.ErrorReason",

@@ -243,3 +276,3 @@ () => [

*/
export const RateLimitRule = proto3.makeMessageType(
export const RateLimitRule = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.RateLimitRule",

@@ -266,3 +299,3 @@ () => [

*/
export const BotRule = proto3.makeMessageType(
export const BotRule = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.BotRule",

@@ -279,3 +312,3 @@ () => [

*/
export const BotRule_Patterns = proto3.makeMessageType(
export const BotRule_Patterns = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.BotRule.Patterns",

@@ -294,3 +327,3 @@ () => [

*/
export const EmailRule = proto3.makeMessageType(
export const EmailRule = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.EmailRule",

@@ -310,3 +343,3 @@ () => [

*/
export const Rule = proto3.makeMessageType(
export const Rule = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.Rule",

@@ -323,3 +356,3 @@ () => [

*/
export const RuleResult = proto3.makeMessageType(
export const RuleResult = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.RuleResult",

@@ -340,3 +373,3 @@ () => [

*/
export const RequestDetails = proto3.makeMessageType(
export const RequestDetails = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.RequestDetails",

@@ -363,3 +396,3 @@ () => [

*/
export const Decision = proto3.makeMessageType(
export const Decision = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.Decision",

@@ -372,2 +405,3 @@ () => [

{ no: 5, name: "ttl", kind: "scalar", T: 13 /* ScalarType.UINT32 */ },
{ no: 6, name: "ip_details", kind: "message", T: IpDetails },
],

@@ -381,3 +415,3 @@ );

*/
export const DecideRequest = proto3.makeMessageType(
export const DecideRequest = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.DecideRequest",

@@ -398,3 +432,3 @@ () => [

*/
export const DecideResponse = proto3.makeMessageType(
export const DecideResponse = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.DecideResponse",

@@ -412,3 +446,3 @@ () => [

*/
export const ReportRequest = proto3.makeMessageType(
export const ReportRequest = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.ReportRequest",

@@ -431,3 +465,3 @@ () => [

*/
export const ReportResponse = proto3.makeMessageType(
export const ReportResponse = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.ReportResponse",

@@ -434,0 +468,0 @@ () => [

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

type RequiredProps<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;
type ArcjetEnum<T extends string> = {

@@ -105,2 +106,129 @@ readonly [Key in T]: T;

}
export declare class ArcjetIpDetails {
/**
* The estimated latitude of the IP address within the `accuracyRadius` margin
* of error.
*/
latitude?: number;
/**
* The estimated longitude of the IP address - see accuracy_radius for the
* margin of error.
*/
longitude?: number;
/**
* The accuracy radius of the IP address location in kilometers.
*/
accuracyRadius?: number;
/**
* The timezone of the IP address.
*/
timezone?: string;
/**
* The postal code of the IP address.
*/
postalCode?: string;
/**
* The city the IP address is located in.
*/
city?: string;
/**
* The region the IP address is located in.
*/
region?: string;
/**
* The country code the IP address is located in.
*/
country?: string;
/**
* The country name the IP address is located in.
*/
countryName?: string;
/**
* The continent code the IP address is located in.
*/
continent?: string;
/**
* The continent name the IP address is located in.
*/
continentName?: string;
/**
* The AS number the IP address belongs to.
*/
asn?: string;
/**
* The AS name the IP address belongs to.
*/
asnName?: string;
/**
* The AS domain the IP address belongs to.
*/
asnDomain?: string;
/**
* The ASN type: ISP, hosting, business, or education
*/
asnType?: string;
/**
* The ASN country code the IP address belongs to.
*/
asnCountry?: string;
/**
* The name of the service the IP address belongs to.
*/
service?: string;
constructor(init?: {
latitude?: number;
longitude?: number;
accuracyRadius?: number;
timezone?: string;
postalCode?: string;
city?: string;
region?: string;
country?: string;
countryName?: string;
continent?: string;
continentName?: string;
asn?: string;
asnName?: string;
asnDomain?: string;
asnType?: string;
asnCountry?: string;
service?: string;
isHosting?: boolean;
isVpn?: boolean;
isProxy?: boolean;
isTor?: boolean;
isRelay?: boolean;
});
hasLatitude(): this is RequiredProps<this, "latitude" | "accuracyRadius">;
hasLongitude(): this is RequiredProps<this, "longitude" | "accuracyRadius">;
hasAccuracyRadius(): this is RequiredProps<this, "latitude" | "longitude" | "accuracyRadius">;
hasTimezone(): this is RequiredProps<this, "timezone">;
hasPostalCode(): this is RequiredProps<this, "postalCode">;
hasCity(): this is RequiredProps<this, "city">;
hasRegion(): this is RequiredProps<this, "region">;
hasCountry(): this is RequiredProps<this, "country" | "countryName">;
hasContintent(): this is RequiredProps<this, "continent" | "continentName">;
hasASN(): this is RequiredProps<this, "asn" | "asnName" | "asnDomain" | "asnType" | "asnCountry">;
hasService(): this is RequiredProps<this, "service">;
/**
* @returns `true` if the IP address belongs to a hosting provider.
*/
isHosting(): boolean;
/**
* @returns `true` if the IP address belongs to a VPN provider.
*/
isVpn(): boolean;
/**
* @returns `true` if the IP address belongs to a proxy provider.
*/
isProxy(): boolean;
/**
* @returns `true` if the IP address belongs to a Tor node.
*/
isTor(): boolean;
/**
* @returns `true` if the the IP address belongs to a relay service.
*/
isRelay(): boolean;
}
/**

@@ -130,2 +258,6 @@ * Represents a decision returned by the Arcjet SDK.

results: ArcjetRuleResult[];
/**
* Details about the IP address that informed the `conclusion`.
*/
ip: ArcjetIpDetails;
abstract conclusion: ArcjetConclusion;

@@ -137,2 +269,3 @@ abstract reason: ArcjetReason;

ttl: number;
ip?: ArcjetIpDetails;
});

@@ -152,2 +285,3 @@ isAllowed(): this is ArcjetAllowDecision | ArcjetErrorDecision;

reason: ArcjetReason;
ip?: ArcjetIpDetails;
});

@@ -163,2 +297,3 @@ }

reason: ArcjetReason;
ip?: ArcjetIpDetails;
});

@@ -174,2 +309,3 @@ }

reason: ArcjetReason;
ip?: ArcjetIpDetails;
});

@@ -185,2 +321,3 @@ }

reason: ArcjetErrorReason;
ip?: ArcjetIpDetails;
});

@@ -187,0 +324,0 @@ }

@@ -179,2 +179,205 @@ import { typeid } from 'typeid-js';

}
class ArcjetIpDetails {
/**
* The estimated latitude of the IP address within the `accuracyRadius` margin
* of error.
*/
latitude;
/**
* The estimated longitude of the IP address - see accuracy_radius for the
* margin of error.
*/
longitude;
/**
* The accuracy radius of the IP address location in kilometers.
*/
accuracyRadius;
/**
* The timezone of the IP address.
*/
timezone;
/**
* The postal code of the IP address.
*/
postalCode;
/**
* The city the IP address is located in.
*/
city;
/**
* The region the IP address is located in.
*/
region;
/**
* The country code the IP address is located in.
*/
country;
/**
* The country name the IP address is located in.
*/
countryName;
/**
* The continent code the IP address is located in.
*/
continent;
/**
* The continent name the IP address is located in.
*/
continentName;
/**
* The AS number the IP address belongs to.
*/
asn;
/**
* The AS name the IP address belongs to.
*/
asnName;
/**
* The AS domain the IP address belongs to.
*/
asnDomain;
/**
* The ASN type: ISP, hosting, business, or education
*/
asnType;
/**
* The ASN country code the IP address belongs to.
*/
asnCountry;
/**
* The name of the service the IP address belongs to.
*/
service;
constructor(init = {}) {
this.latitude = init.latitude;
this.longitude = init.longitude;
this.accuracyRadius = init.accuracyRadius;
this.timezone = init.timezone;
this.postalCode = init.postalCode;
this.city = init.city;
this.region = init.region;
this.country = init.country;
this.countryName = init.countryName;
this.continent = init.continent;
this.continentName = init.continentName;
this.asn = init.asn;
this.asnName = init.asnName;
this.asnDomain = init.asnDomain;
this.asnType = init.asnType;
this.asnCountry = init.asnCountry;
this.service = init.service;
// TypeScript creates symbols on the class when using `private` or `#`
// identifiers for tracking these properties. We don't want to end up with
// the same issues as Next.js with private symbols so we use
// `Object.defineProperties` here and then `@ts-expect-error` when we access
// the values. This is mostly to improve the editor experience, as props
// starting with `_` are sorted to the top of autocomplete.
Object.defineProperties(this, {
_isHosting: {
configurable: false,
enumerable: false,
writable: false,
value: init.isHosting ?? false,
},
_isVpn: {
configurable: false,
enumerable: false,
writable: false,
value: init.isVpn ?? false,
},
_isProxy: {
configurable: false,
enumerable: false,
writable: false,
value: init.isProxy ?? false,
},
_isTor: {
configurable: false,
enumerable: false,
writable: false,
value: init.isTor ?? false,
},
_isRelay: {
configurable: false,
enumerable: false,
writable: false,
value: init.isRelay ?? false,
},
});
}
hasLatitude() {
return typeof this.latitude !== "undefined";
}
hasLongitude() {
return typeof this.longitude !== "undefined";
}
hasAccuracyRadius() {
return typeof this.accuracyRadius !== "undefined";
}
hasTimezone() {
return typeof this.timezone !== "undefined";
}
hasPostalCode() {
return typeof this.postalCode !== "undefined";
}
// TODO: If we have city, what other data are we sure to have?
hasCity() {
return typeof this.city !== "undefined";
}
// TODO: If we have region, what other data are we sure to have?
hasRegion() {
return typeof this.region !== "undefined";
}
// If we have country, we should have country name
// TODO: If we have country, should we also have continent?
hasCountry() {
return typeof this.country !== "undefined";
}
// If we have continent, we should have continent name
hasContintent() {
return typeof this.continent !== "undefined";
}
// If we have ASN, we should have every piece of ASN information.
hasASN() {
return typeof this.asn !== "undefined";
}
hasService() {
return typeof this.service !== "undefined";
}
/**
* @returns `true` if the IP address belongs to a hosting provider.
*/
isHosting() {
// @ts-expect-error because we attach this with Object.defineProperties
return this._isHosting;
}
/**
* @returns `true` if the IP address belongs to a VPN provider.
*/
isVpn() {
// @ts-expect-error because we attach this with Object.defineProperties
return this._isVpn;
}
/**
* @returns `true` if the IP address belongs to a proxy provider.
*/
isProxy() {
// @ts-expect-error because we attach this with Object.defineProperties
return this._isProxy;
}
/**
* @returns `true` if the IP address belongs to a Tor node.
*/
isTor() {
// @ts-expect-error because we attach this with Object.defineProperties
return this._isTor;
}
/**
* @returns `true` if the the IP address belongs to a relay service.
*/
isRelay() {
// @ts-expect-error because we attach this with Object.defineProperties
return this._isRelay;
}
}
/**

@@ -204,2 +407,6 @@ * Represents a decision returned by the Arcjet SDK.

results;
/**
* Details about the IP address that informed the `conclusion`.
*/
ip;
constructor(init) {

@@ -214,2 +421,3 @@ if (typeof init.id === "string") {

this.ttl = init.ttl;
this.ip = init.ip ?? new ArcjetIpDetails();
}

@@ -262,2 +470,2 @@ isAllowed() {

export { ArcjetAllowDecision, ArcjetBotReason, ArcjetBotType, ArcjetChallengeDecision, ArcjetConclusion, ArcjetDecision, ArcjetDenyDecision, ArcjetEdgeRuleReason, ArcjetEmailReason, ArcjetEmailType, ArcjetErrorDecision, ArcjetErrorReason, ArcjetMode, ArcjetRateLimitAlgorithm, ArcjetRateLimitReason, ArcjetReason, ArcjetRuleResult, ArcjetRuleState, ArcjetRuleType, ArcjetShieldReason, ArcjetStack };
export { ArcjetAllowDecision, ArcjetBotReason, ArcjetBotType, ArcjetChallengeDecision, ArcjetConclusion, ArcjetDecision, ArcjetDenyDecision, ArcjetEdgeRuleReason, ArcjetEmailReason, ArcjetEmailType, ArcjetErrorDecision, ArcjetErrorReason, ArcjetIpDetails, ArcjetMode, ArcjetRateLimitAlgorithm, ArcjetRateLimitReason, ArcjetReason, ArcjetRuleResult, ArcjetRuleState, ArcjetRuleType, ArcjetShieldReason, ArcjetStack };
import { typeid } from "typeid-js";
import { Reason } from "./gen/es/decide/v1alpha1/decide_pb.js";
type RequiredProps<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;
type ArcjetEnum<T extends string> = { readonly [Key in T]: T };

@@ -263,2 +265,254 @@

export class ArcjetIpDetails {
/**
* The estimated latitude of the IP address within the `accuracyRadius` margin
* of error.
*/
latitude?: number;
/**
* The estimated longitude of the IP address - see accuracy_radius for the
* margin of error.
*/
longitude?: number;
/**
* The accuracy radius of the IP address location in kilometers.
*/
accuracyRadius?: number;
/**
* The timezone of the IP address.
*/
timezone?: string;
/**
* The postal code of the IP address.
*/
postalCode?: string;
/**
* The city the IP address is located in.
*/
city?: string;
/**
* The region the IP address is located in.
*/
region?: string;
/**
* The country code the IP address is located in.
*/
country?: string;
/**
* The country name the IP address is located in.
*/
countryName?: string;
/**
* The continent code the IP address is located in.
*/
continent?: string;
/**
* The continent name the IP address is located in.
*/
continentName?: string;
/**
* The AS number the IP address belongs to.
*/
asn?: string;
/**
* The AS name the IP address belongs to.
*/
asnName?: string;
/**
* The AS domain the IP address belongs to.
*/
asnDomain?: string;
/**
* The ASN type: ISP, hosting, business, or education
*/
asnType?: string;
/**
* The ASN country code the IP address belongs to.
*/
asnCountry?: string;
/**
* The name of the service the IP address belongs to.
*/
service?: string;
constructor(
init: {
latitude?: number;
longitude?: number;
accuracyRadius?: number;
timezone?: string;
postalCode?: string;
city?: string;
region?: string;
country?: string;
countryName?: string;
continent?: string;
continentName?: string;
asn?: string;
asnName?: string;
asnDomain?: string;
asnType?: string;
asnCountry?: string;
service?: string;
isHosting?: boolean;
isVpn?: boolean;
isProxy?: boolean;
isTor?: boolean;
isRelay?: boolean;
} = {},
) {
this.latitude = init.latitude;
this.longitude = init.longitude;
this.accuracyRadius = init.accuracyRadius;
this.timezone = init.timezone;
this.postalCode = init.postalCode;
this.city = init.city;
this.region = init.region;
this.country = init.country;
this.countryName = init.countryName;
this.continent = init.continent;
this.continentName = init.continentName;
this.asn = init.asn;
this.asnName = init.asnName;
this.asnDomain = init.asnDomain;
this.asnType = init.asnType;
this.asnCountry = init.asnCountry;
this.service = init.service;
// TypeScript creates symbols on the class when using `private` or `#`
// identifiers for tracking these properties. We don't want to end up with
// the same issues as Next.js with private symbols so we use
// `Object.defineProperties` here and then `@ts-expect-error` when we access
// the values. This is mostly to improve the editor experience, as props
// starting with `_` are sorted to the top of autocomplete.
Object.defineProperties(this, {
_isHosting: {
configurable: false,
enumerable: false,
writable: false,
value: init.isHosting ?? false,
},
_isVpn: {
configurable: false,
enumerable: false,
writable: false,
value: init.isVpn ?? false,
},
_isProxy: {
configurable: false,
enumerable: false,
writable: false,
value: init.isProxy ?? false,
},
_isTor: {
configurable: false,
enumerable: false,
writable: false,
value: init.isTor ?? false,
},
_isRelay: {
configurable: false,
enumerable: false,
writable: false,
value: init.isRelay ?? false,
},
});
}
hasLatitude(): this is RequiredProps<this, "latitude" | "accuracyRadius"> {
return typeof this.latitude !== "undefined";
}
hasLongitude(): this is RequiredProps<this, "longitude" | "accuracyRadius"> {
return typeof this.longitude !== "undefined";
}
hasAccuracyRadius(): this is RequiredProps<
this,
"latitude" | "longitude" | "accuracyRadius"
> {
return typeof this.accuracyRadius !== "undefined";
}
hasTimezone(): this is RequiredProps<this, "timezone"> {
return typeof this.timezone !== "undefined";
}
hasPostalCode(): this is RequiredProps<this, "postalCode"> {
return typeof this.postalCode !== "undefined";
}
// TODO: If we have city, what other data are we sure to have?
hasCity(): this is RequiredProps<this, "city"> {
return typeof this.city !== "undefined";
}
// TODO: If we have region, what other data are we sure to have?
hasRegion(): this is RequiredProps<this, "region"> {
return typeof this.region !== "undefined";
}
// If we have country, we should have country name
// TODO: If we have country, should we also have continent?
hasCountry(): this is RequiredProps<this, "country" | "countryName"> {
return typeof this.country !== "undefined";
}
// If we have continent, we should have continent name
hasContintent(): this is RequiredProps<this, "continent" | "continentName"> {
return typeof this.continent !== "undefined";
}
// If we have ASN, we should have every piece of ASN information.
hasASN(): this is RequiredProps<
this,
"asn" | "asnName" | "asnDomain" | "asnType" | "asnCountry"
> {
return typeof this.asn !== "undefined";
}
hasService(): this is RequiredProps<this, "service"> {
return typeof this.service !== "undefined";
}
/**
* @returns `true` if the IP address belongs to a hosting provider.
*/
isHosting(): boolean {
// @ts-expect-error because we attach this with Object.defineProperties
return this._isHosting;
}
/**
* @returns `true` if the IP address belongs to a VPN provider.
*/
isVpn(): boolean {
// @ts-expect-error because we attach this with Object.defineProperties
return this._isVpn;
}
/**
* @returns `true` if the IP address belongs to a proxy provider.
*/
isProxy(): boolean {
// @ts-expect-error because we attach this with Object.defineProperties
return this._isProxy;
}
/**
* @returns `true` if the IP address belongs to a Tor node.
*/
isTor(): boolean {
// @ts-expect-error because we attach this with Object.defineProperties
return this._isTor;
}
/**
* @returns `true` if the the IP address belongs to a relay service.
*/
isRelay(): boolean {
// @ts-expect-error because we attach this with Object.defineProperties
return this._isRelay;
}
}
/**

@@ -289,6 +543,16 @@ * Represents a decision returned by the Arcjet SDK.

/**
* Details about the IP address that informed the `conclusion`.
*/
ip: ArcjetIpDetails;
abstract conclusion: ArcjetConclusion;
abstract reason: ArcjetReason;
constructor(init: { id?: string; results: ArcjetRuleResult[]; ttl: number }) {
constructor(init: {
id?: string;
results: ArcjetRuleResult[];
ttl: number;
ip?: ArcjetIpDetails;
}) {
if (typeof init.id === "string") {

@@ -302,2 +566,3 @@ this.id = init.id;

this.ttl = init.ttl;
this.ip = init.ip ?? new ArcjetIpDetails();
}

@@ -331,2 +596,3 @@

reason: ArcjetReason;
ip?: ArcjetIpDetails;
}) {

@@ -348,2 +614,3 @@ super(init);

reason: ArcjetReason;
ip?: ArcjetIpDetails;
}) {

@@ -364,2 +631,3 @@ super(init);

reason: ArcjetReason;
ip?: ArcjetIpDetails;
}) {

@@ -381,2 +649,3 @@ super(init);

reason: ArcjetErrorReason;
ip?: ArcjetIpDetails;
}) {

@@ -383,0 +652,0 @@ super(init);

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

@@ -44,3 +44,3 @@ "license": "Apache-2.0",

"dependencies": {
"@bufbuild/protobuf": "1.7.2",
"@bufbuild/protobuf": "1.8.0",
"@connectrpc/connect": "1.4.0",

@@ -50,10 +50,10 @@ "typeid-js": "0.5.0"

"devDependencies": {
"@arcjet/eslint-config": "1.0.0-alpha.10",
"@arcjet/rollup-config": "1.0.0-alpha.10",
"@arcjet/tsconfig": "1.0.0-alpha.10",
"@arcjet/eslint-config": "1.0.0-alpha.11",
"@arcjet/rollup-config": "1.0.0-alpha.11",
"@arcjet/tsconfig": "1.0.0-alpha.11",
"@jest/globals": "29.7.0",
"@rollup/wasm-node": "4.13.0",
"@rollup/wasm-node": "4.14.1",
"@types/node": "18.18.0",
"jest": "29.7.0",
"typescript": "5.4.2"
"typescript": "5.4.4"
},

@@ -60,0 +60,0 @@ "publishConfig": {

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