diff --git a/protocol/convert.ts b/protocol/convert.ts index a3d47350e..05162444a 100644 --- a/protocol/convert.ts +++ b/protocol/convert.ts @@ -10,7 +10,7 @@ import { ArcjetErrorReason, ArcjetRateLimitReason, ArcjetRuleResult, - ArcjetSuspiciousReason, + ArcjetShieldReason, ArcjetBotType, ArcjetConclusion, ArcjetDecision, @@ -40,7 +40,7 @@ import { RuleResult, RuleState, SDKStack, - SuspiciousReason, + ShieldReason, } from "./gen/es/decide/v1alpha1/decide_pb.js"; export function ArcjetModeToProtocol(mode: ArcjetMode) { @@ -256,10 +256,10 @@ export function ArcjetReasonFromProtocol(proto?: Reason) { case "edgeRule": { return new ArcjetEdgeRuleReason(); } - case "suspicious": { + case "shield": { const reason = proto.reason.value; - return new ArcjetSuspiciousReason({ - wafTriggered: reason.wafTriggered, + return new ArcjetShieldReason({ + shieldTriggered: reason.shieldTriggered, }); } case "email": { @@ -326,12 +326,12 @@ export function ArcjetReasonToProtocol(reason: ArcjetReason): Reason { }); } - if (reason.isSuspicious()) { + if (reason.isShield()) { return new Reason({ reason: { - case: "suspicious", - value: new SuspiciousReason({ - wafTriggered: reason.wafTriggered, + case: "shield", + value: new ShieldReason({ + shieldTriggered: reason.shieldTriggered, }), }, }); diff --git a/protocol/gen/es/decide/v1alpha1/decide_connect.d.ts b/protocol/gen/es/decide/v1alpha1/decide_connect.d.ts index cfac1ffd4..aaf6886b6 100644 --- a/protocol/gen/es/decide/v1alpha1/decide_connect.d.ts +++ b/protocol/gen/es/decide/v1alpha1/decide_connect.d.ts @@ -1,4 +1,4 @@ -// @generated by protoc-gen-connect-es v1.1.3 +// @generated by protoc-gen-connect-es v1.3.0 // @generated from file decide/v1alpha1/decide.proto (package proto.decide.v1alpha1, syntax proto3) /* eslint-disable */ // @ts-nocheck diff --git a/protocol/gen/es/decide/v1alpha1/decide_connect.js b/protocol/gen/es/decide/v1alpha1/decide_connect.js index c929a052a..f1e9ef228 100644 --- a/protocol/gen/es/decide/v1alpha1/decide_connect.js +++ b/protocol/gen/es/decide/v1alpha1/decide_connect.js @@ -1,4 +1,4 @@ -// @generated by protoc-gen-connect-es v1.1.3 +// @generated by protoc-gen-connect-es v1.3.0 // @generated from file decide/v1alpha1/decide.proto (package proto.decide.v1alpha1, syntax proto3) /* eslint-disable */ // @ts-nocheck diff --git a/protocol/gen/es/decide/v1alpha1/decide_pb.d.ts b/protocol/gen/es/decide/v1alpha1/decide_pb.d.ts index 2e98489c0..dce2b30ce 100644 --- a/protocol/gen/es/decide/v1alpha1/decide_pb.d.ts +++ b/protocol/gen/es/decide/v1alpha1/decide_pb.d.ts @@ -1,4 +1,4 @@ -// @generated by protoc-gen-es v1.4.2 +// @generated by protoc-gen-es v1.7.1 // @generated from file decide/v1alpha1/decide.proto (package proto.decide.v1alpha1, syntax proto3) /* eslint-disable */ // @ts-nocheck @@ -327,13 +327,12 @@ export declare class Reason extends Message { case: "bot"; } | { /** - * Contains details about why the request was considered suspicious - * when the decision was based on a WAF rule. + * Contains details about why Arcjet Shield was triggered. * - * @generated from field: proto.decide.v1alpha1.SuspiciousReason suspicious = 4; + * @generated from field: proto.decide.v1alpha1.ShieldReason shield = 4; */ - value: SuspiciousReason; - case: "suspicious"; + value: ShieldReason; + case: "shield"; } | { /** * Contains details about the email when the decision was made based @@ -518,33 +517,41 @@ export declare class BotReason extends Message { } /** - * Details of why we consider the request suspicious. + * Details of an Arcjet Shield decision. * - * @generated from message proto.decide.v1alpha1.SuspiciousReason + * @generated from message proto.decide.v1alpha1.ShieldReason */ -export declare class SuspiciousReason extends Message { +export declare class ShieldReason extends Message { /** - * Whether the WAF was triggered. Log into the Arcjet dashboard and search - * for the decision ID to find more details about the WAF rules which were + * Whether Arcjet Shield was triggered. Log into the Arcjet dashboard and + * search for the decision ID to find more details about which rules were * triggered. * - * @generated from field: bool waf_triggered = 1; + * @generated from field: bool shield_triggered = 1; */ - wafTriggered: boolean; + shieldTriggered: boolean; - constructor(data?: PartialMessage); + /** + * Whether the request was considered suspicious based on background + * analysis of the request + * + * @generated from field: bool suspicious = 2; + */ + suspicious: boolean; + + constructor(data?: PartialMessage); static readonly runtime: typeof proto3; - static readonly typeName = "proto.decide.v1alpha1.SuspiciousReason"; + static readonly typeName = "proto.decide.v1alpha1.ShieldReason"; static readonly fields: FieldList; - static fromBinary(bytes: Uint8Array, options?: Partial): SuspiciousReason; + static fromBinary(bytes: Uint8Array, options?: Partial): ShieldReason; - static fromJson(jsonValue: JsonValue, options?: Partial): SuspiciousReason; + static fromJson(jsonValue: JsonValue, options?: Partial): ShieldReason; - static fromJsonString(jsonString: string, options?: Partial): SuspiciousReason; + static fromJsonString(jsonString: string, options?: Partial): ShieldReason; - static equals(a: SuspiciousReason | PlainMessage | undefined, b: SuspiciousReason | PlainMessage | undefined): boolean; + static equals(a: ShieldReason | PlainMessage | undefined, b: ShieldReason | PlainMessage | undefined): boolean; } /** diff --git a/protocol/gen/es/decide/v1alpha1/decide_pb.js b/protocol/gen/es/decide/v1alpha1/decide_pb.js index 634f4a527..3c409dcfd 100644 --- a/protocol/gen/es/decide/v1alpha1/decide_pb.js +++ b/protocol/gen/es/decide/v1alpha1/decide_pb.js @@ -1,4 +1,4 @@ -// @generated by protoc-gen-es v1.4.2 +// @generated by protoc-gen-es v1.7.1 // @generated from file decide/v1alpha1/decide.proto (package proto.decide.v1alpha1, syntax proto3) /* eslint-disable */ // @ts-nocheck @@ -119,7 +119,7 @@ export const Reason = proto3.makeMessageType( { no: 1, name: "rate_limit", kind: "message", T: RateLimitReason, oneof: "reason" }, { no: 2, name: "edge_rule", kind: "message", T: EdgeRuleReason, oneof: "reason" }, { no: 3, name: "bot", kind: "message", T: BotReason, oneof: "reason" }, - { no: 4, name: "suspicious", kind: "message", T: SuspiciousReason, oneof: "reason" }, + { no: 4, name: "shield", kind: "message", T: ShieldReason, oneof: "reason" }, { no: 5, name: "email", kind: "message", T: EmailReason, oneof: "reason" }, { no: 6, name: "error", kind: "message", T: ErrorReason, oneof: "reason" }, ], @@ -170,14 +170,15 @@ export const BotReason = proto3.makeMessageType( ); /** - * Details of why we consider the request suspicious. + * Details of an Arcjet Shield decision. * - * @generated from message proto.decide.v1alpha1.SuspiciousReason + * @generated from message proto.decide.v1alpha1.ShieldReason */ -export const SuspiciousReason = proto3.makeMessageType( - "proto.decide.v1alpha1.SuspiciousReason", +export const ShieldReason = proto3.makeMessageType( + "proto.decide.v1alpha1.ShieldReason", () => [ - { no: 1, name: "waf_triggered", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + { no: 1, name: "shield_triggered", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, + { no: 2, name: "suspicious", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, ], ); diff --git a/protocol/index.ts b/protocol/index.ts index dcb12ad74..2de3b4ed4 100644 --- a/protocol/index.ts +++ b/protocol/index.ts @@ -67,7 +67,7 @@ export const ArcjetRuleType: ArcjetEnum = Object.freeze({ }); export class ArcjetReason { - type?: "RATE_LIMIT" | "BOT" | "EDGE_RULE" | "SUSPICIOUS" | "EMAIL" | "ERROR"; + type?: "RATE_LIMIT" | "BOT" | "EDGE_RULE" | "SHIELD" | "EMAIL" | "ERROR"; isRateLimit(): this is ArcjetRateLimitReason { return this.type === "RATE_LIMIT"; @@ -81,8 +81,8 @@ export class ArcjetReason { return this.type === "EDGE_RULE"; } - isSuspicious(): this is ArcjetSuspiciousReason { - return this.type === "SUSPICIOUS"; + isShield(): this is ArcjetShieldReason { + return this.type === "SHIELD"; } isEmail(): this is ArcjetEmailReason { @@ -156,15 +156,15 @@ export class ArcjetEdgeRuleReason extends ArcjetReason { type: "EDGE_RULE" = "EDGE_RULE"; } -export class ArcjetSuspiciousReason extends ArcjetReason { - type: "SUSPICIOUS" = "SUSPICIOUS"; +export class ArcjetShieldReason extends ArcjetReason { + type: "SHIELD" = "SHIELD"; - wafTriggered: boolean; + shieldTriggered: boolean; - constructor(init: { wafTriggered?: boolean }) { + constructor(init: { shieldTriggered?: boolean }) { super(); - this.wafTriggered = init.wafTriggered ?? false; + this.shieldTriggered = init.shieldTriggered ?? false; } } @@ -256,7 +256,7 @@ export class ArcjetRuleResult { * one of `"ALLOW"`, `"DENY"`, `"CHALLENGE"`, or `"ERROR"`. * @property `reason` - A structured data type about the reason for the * decision. One of: {@link ArcjetRateLimitReason}, {@link ArcjetEdgeRuleReason}, - * {@link ArcjetBotReason}, {@link ArcjetSuspiciousReason}, + * {@link ArcjetBotReason}, {@link ArcjetShieldReason}, * {@link ArcjetEmailReason}, or {@link ArcjetErrorReason}. * @property `ttl` - The duration in milliseconds this decision should be * considered valid, also known as time-to-live. diff --git a/protocol/test/convert.test.ts b/protocol/test/convert.test.ts index 62e53b6fd..a89fe0542 100644 --- a/protocol/test/convert.test.ts +++ b/protocol/test/convert.test.ts @@ -47,7 +47,7 @@ import { ArcjetRateLimitReason, ArcjetReason, ArcjetRuleResult, - ArcjetSuspiciousReason, + ArcjetShieldReason, } from "../index.js"; import { Timestamp } from "@bufbuild/protobuf"; @@ -315,14 +315,14 @@ describe("convert", () => { ArcjetReasonFromProtocol( new Reason({ reason: { - case: "suspicious", + case: "shield", value: { - wafTriggered: true, + shieldTriggered: true, }, }, }), ), - ).toBeInstanceOf(ArcjetSuspiciousReason); + ).toBeInstanceOf(ArcjetShieldReason); expect(ArcjetReasonFromProtocol(new Reason())).toBeInstanceOf(ArcjetReason); expect( ArcjetReasonFromProtocol( @@ -432,15 +432,13 @@ describe("convert", () => { }), ); expect( - ArcjetReasonToProtocol( - new ArcjetSuspiciousReason({ wafTriggered: true }), - ), + ArcjetReasonToProtocol(new ArcjetShieldReason({ shieldTriggered: true })), ).toEqual( new Reason({ reason: { - case: "suspicious", + case: "shield", value: { - wafTriggered: true, + shieldTriggered: true, }, }, }),