@arcjet/protocol
Advanced tools
Comparing version 1.0.0-alpha.11 to 1.0.0-alpha.12
@@ -437,2 +437,5 @@ import { Timestamp } from '@bufbuild/protobuf'; | ||
} | ||
function isShieldRule(rule) { | ||
return rule.type === "SHIELD"; | ||
} | ||
function ArcjetRuleToProtocol(rule) { | ||
@@ -525,2 +528,13 @@ if (isTokenBucketRule(rule)) { | ||
} | ||
if (isShieldRule(rule)) { | ||
return new Rule({ | ||
rule: { | ||
case: "shield", | ||
value: { | ||
mode: ArcjetModeToProtocol(rule.mode), | ||
autoAdded: false, | ||
}, | ||
}, | ||
}); | ||
} | ||
return new Rule(); | ||
@@ -527,0 +541,0 @@ } |
@@ -30,2 +30,3 @@ import { Timestamp } from "@bufbuild/protobuf"; | ||
ArcjetIpDetails, | ||
ArcjetShieldRule, | ||
} from "./index"; | ||
@@ -562,2 +563,8 @@ import { | ||
function isShieldRule<Props extends { email: string }>( | ||
rule: ArcjetRule<Props>, | ||
): rule is ArcjetShieldRule<Props> { | ||
return rule.type === "SHIELD"; | ||
} | ||
export function ArcjetRuleToProtocol<Props extends { [key: string]: unknown }>( | ||
@@ -657,3 +664,15 @@ rule: ArcjetRule<Props>, | ||
if (isShieldRule(rule)) { | ||
return new Rule({ | ||
rule: { | ||
case: "shield", | ||
value: { | ||
mode: ArcjetModeToProtocol(rule.mode), | ||
autoAdded: false, | ||
}, | ||
}, | ||
}); | ||
} | ||
return new Rule(); | ||
} |
@@ -836,3 +836,3 @@ // @generated by protoc-gen-es v1.8.0 | ||
/** | ||
* The rate limit configuration for a path. | ||
* The configuration for a rate limit rule. | ||
* | ||
@@ -965,3 +965,3 @@ * @generated from message proto.decide.v1alpha1.RateLimitRule | ||
/** | ||
* The bot detection configuration. | ||
* The configuration for a bot rule. | ||
* | ||
@@ -1038,3 +1038,3 @@ * @generated from message proto.decide.v1alpha1.BotRule | ||
/** | ||
* The signup protection configuration. | ||
* The configuration for an email rule. | ||
* | ||
@@ -1083,2 +1083,33 @@ * @generated from message proto.decide.v1alpha1.EmailRule | ||
/** | ||
* The configuration for a shield rule. | ||
* | ||
* @generated from message proto.decide.v1alpha1.ShieldRule | ||
*/ | ||
export declare class ShieldRule extends Message<ShieldRule> { | ||
/** | ||
* @generated from field: proto.decide.v1alpha1.Mode mode = 1; | ||
*/ | ||
mode: Mode; | ||
/** | ||
* @generated from field: bool auto_added = 2; | ||
*/ | ||
autoAdded: boolean; | ||
constructor(data?: PartialMessage<ShieldRule>); | ||
static readonly runtime: typeof proto3; | ||
static readonly typeName = "proto.decide.v1alpha1.ShieldRule"; | ||
static readonly fields: FieldList; | ||
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ShieldRule; | ||
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): ShieldRule; | ||
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): ShieldRule; | ||
static equals(a: ShieldRule | PlainMessage<ShieldRule> | undefined, b: ShieldRule | PlainMessage<ShieldRule> | undefined): boolean; | ||
} | ||
/** | ||
* The configuration for Arcjet. | ||
@@ -1110,2 +1141,8 @@ * | ||
case: "email"; | ||
} | { | ||
/** | ||
* @generated from field: proto.decide.v1alpha1.ShieldRule shield = 4; | ||
*/ | ||
value: ShieldRule; | ||
case: "shield"; | ||
} | { case: undefined; value?: undefined }; | ||
@@ -1346,9 +1383,2 @@ | ||
/** | ||
* The fingerprint of the request | ||
* | ||
* @generated from field: string fingerprint = 3; | ||
*/ | ||
fingerprint: string; | ||
/** | ||
* The information provided via an SDK about a request under investigation. | ||
@@ -1434,9 +1464,2 @@ * | ||
/** | ||
* The fingerprint of the request. | ||
* | ||
* @generated from field: string fingerprint = 3; | ||
*/ | ||
fingerprint: string; | ||
/** | ||
* The information provided via an SDK about a request under investigation. | ||
@@ -1443,0 +1466,0 @@ * |
@@ -258,3 +258,3 @@ // @generated by protoc-gen-es v1.8.0 | ||
/** | ||
* The rate limit configuration for a path. | ||
* The configuration for a rate limit rule. | ||
* | ||
@@ -281,3 +281,3 @@ * @generated from message proto.decide.v1alpha1.RateLimitRule | ||
/** | ||
* The bot detection configuration. | ||
* The configuration for a bot rule. | ||
* | ||
@@ -308,3 +308,3 @@ * @generated from message proto.decide.v1alpha1.BotRule | ||
/** | ||
* The signup protection configuration. | ||
* The configuration for an email rule. | ||
* | ||
@@ -324,2 +324,15 @@ * @generated from message proto.decide.v1alpha1.EmailRule | ||
/** | ||
* The configuration for a shield rule. | ||
* | ||
* @generated from message proto.decide.v1alpha1.ShieldRule | ||
*/ | ||
export const ShieldRule = /*@__PURE__*/ proto3.makeMessageType( | ||
"proto.decide.v1alpha1.ShieldRule", | ||
() => [ | ||
{ no: 1, name: "mode", kind: "enum", T: proto3.getEnumType(Mode) }, | ||
{ no: 2, name: "auto_added", kind: "scalar", T: 8 /* ScalarType.BOOL */ }, | ||
], | ||
); | ||
/** | ||
* The configuration for Arcjet. | ||
@@ -335,2 +348,3 @@ * | ||
{ no: 3, name: "email", kind: "message", T: EmailRule, oneof: "rule" }, | ||
{ no: 4, name: "shield", kind: "message", T: ShieldRule, oneof: "rule" }, | ||
], | ||
@@ -402,3 +416,2 @@ ); | ||
{ no: 2, name: "sdk_version", kind: "scalar", T: 9 /* ScalarType.STRING */ }, | ||
{ no: 3, name: "fingerprint", kind: "scalar", T: 9 /* ScalarType.STRING */ }, | ||
{ no: 4, name: "details", kind: "message", T: RequestDetails }, | ||
@@ -432,3 +445,2 @@ { no: 5, name: "rules", kind: "message", T: Rule, repeated: true }, | ||
{ no: 2, name: "sdk_version", kind: "scalar", T: 9 /* ScalarType.STRING */ }, | ||
{ no: 3, name: "fingerprint", kind: "scalar", T: 9 /* ScalarType.STRING */ }, | ||
{ no: 4, name: "details", kind: "message", T: RequestDetails }, | ||
@@ -435,0 +447,0 @@ { no: 5, name: "decision", kind: "message", T: Decision }, |
@@ -333,3 +333,3 @@ type RequiredProps<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>; | ||
export type ArcjetRule<Props extends {} = {}> = { | ||
type: "RATE_LIMIT" | "BOT" | "EMAIL" | string; | ||
type: "RATE_LIMIT" | "BOT" | "EMAIL" | "SHIELD" | string; | ||
mode: ArcjetMode; | ||
@@ -384,2 +384,5 @@ priority: number; | ||
} | ||
export interface ArcjetShieldRule<Props extends {}> extends ArcjetRule<Props> { | ||
type: "SHIELD"; | ||
} | ||
export type ArcjetContext = { | ||
@@ -386,0 +389,0 @@ key: string; |
@@ -666,3 +666,3 @@ import { typeid } from "typeid-js"; | ||
export type ArcjetRule<Props extends {} = {}> = { | ||
type: "RATE_LIMIT" | "BOT" | "EMAIL" | string; | ||
type: "RATE_LIMIT" | "BOT" | "EMAIL" | "SHIELD" | string; | ||
mode: ArcjetMode; | ||
@@ -742,2 +742,6 @@ priority: number; | ||
export interface ArcjetShieldRule<Props extends {}> extends ArcjetRule<Props> { | ||
type: "SHIELD"; | ||
} | ||
export type ArcjetContext = { | ||
@@ -744,0 +748,0 @@ key: string; |
{ | ||
"name": "@arcjet/protocol", | ||
"version": "1.0.0-alpha.11", | ||
"version": "1.0.0-alpha.12", | ||
"description": "The TypeScript & JavaScript interface into the Arcjet protocol", | ||
@@ -46,13 +46,13 @@ "license": "Apache-2.0", | ||
"@connectrpc/connect": "1.4.0", | ||
"typeid-js": "0.5.0" | ||
"typeid-js": "0.7.0" | ||
}, | ||
"devDependencies": { | ||
"@arcjet/eslint-config": "1.0.0-alpha.11", | ||
"@arcjet/rollup-config": "1.0.0-alpha.11", | ||
"@arcjet/tsconfig": "1.0.0-alpha.11", | ||
"@arcjet/eslint-config": "1.0.0-alpha.12", | ||
"@arcjet/rollup-config": "1.0.0-alpha.12", | ||
"@arcjet/tsconfig": "1.0.0-alpha.12", | ||
"@jest/globals": "29.7.0", | ||
"@rollup/wasm-node": "4.14.1", | ||
"@rollup/wasm-node": "4.14.3", | ||
"@types/node": "18.18.0", | ||
"jest": "29.7.0", | ||
"typescript": "5.4.4" | ||
"typescript": "5.4.5" | ||
}, | ||
@@ -59,0 +59,0 @@ "publishConfig": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
162825
4479
+ Addedtypeid-js@0.7.0(transitive)
- Removedtypeid-js@0.5.0(transitive)
Updatedtypeid-js@0.7.0