Skip to content

Commit

Permalink
chore(protocol)!: Remove received_at and decision fields from Report (#…
Browse files Browse the repository at this point in the history
…1988)

This updates our protocol package to the latest protobuf definition which removes the `decision` from `ReportResponse` to send less data down the wire which also reduces the amount of data we need to deserialize.

This means that the decision `id` field in the report log will be undefined in older SDKs so I've marked this as breaking.

It also removed `received_at` because our usage was inconsistent. We may revisit this in the future.
  • Loading branch information
blaine-arcjet authored Oct 22, 2024
1 parent 794344e commit 3da543e
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 32 deletions.
4 changes: 1 addition & 3 deletions protocol/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Transport } from "@connectrpc/connect";
import { createPromiseClient } from "@connectrpc/connect";
import { Timestamp } from "@bufbuild/protobuf";
import {
ArcjetDecisionFromProtocol,
ArcjetDecisionToProtocol,
Expand Down Expand Up @@ -152,7 +151,6 @@ export function createClient(options: ClientOptions): Client {
},
decision: ArcjetDecisionToProtocol(decision),
rules: rules.map(ArcjetRuleToProtocol),
receivedAt: Timestamp.now(),
});

log.debug("Report request to %s", baseUrl);
Expand All @@ -167,7 +165,7 @@ export function createClient(options: ClientOptions): Client {
.then((response) => {
log.debug(
{
id: response.decision?.id,
id: decision.id,
fingerprint: context.fingerprint,
path: details.path,
runtime: context.runtime,
Expand Down
12 changes: 0 additions & 12 deletions protocol/proto/decide/v1alpha1/decide_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1732,11 +1732,6 @@ export declare class ReportRequest extends Message<ReportRequest> {
*/
rules: Rule[];

/**
* @generated from field: google.protobuf.Timestamp received_at = 7;
*/
receivedAt?: Timestamp;

/**
* The characteristics that should be used for fingerprinting.
*
Expand Down Expand Up @@ -1765,13 +1760,6 @@ export declare class ReportRequest extends Message<ReportRequest> {
* @generated from message proto.decide.v1alpha1.ReportResponse
*/
export declare class ReportResponse extends Message<ReportResponse> {
/**
* The decision reported about the request under investigation.
*
* @generated from field: proto.decide.v1alpha1.Decision decision = 1;
*/
decision?: Decision;

/**
* Any extra information returned by the Arcjet analysis.
*
Expand Down
2 changes: 0 additions & 2 deletions protocol/proto/decide/v1alpha1/decide_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,6 @@ export const ReportRequest = /*@__PURE__*/ proto3.makeMessageType(
{ no: 4, name: "details", kind: "message", T: RequestDetails },
{ no: 5, name: "decision", kind: "message", T: Decision },
{ no: 6, name: "rules", kind: "message", T: Rule, repeated: true },
{ no: 7, name: "received_at", kind: "message", T: Timestamp },
{ no: 8, name: "characteristics", kind: "scalar", T: 9 /* ScalarType.STRING */, repeated: true },
],
);
Expand All @@ -531,7 +530,6 @@ export const ReportRequest = /*@__PURE__*/ proto3.makeMessageType(
export const ReportResponse = /*@__PURE__*/ proto3.makeMessageType(
"proto.decide.v1alpha1.ReportResponse",
() => [
{ no: 1, name: "decision", kind: "message", T: Decision },
{ no: 2, name: "extra", kind: "map", K: 9 /* ScalarType.STRING */, V: {kind: "scalar", T: 9 /* ScalarType.STRING */} },
],
);
Expand Down
15 changes: 0 additions & 15 deletions protocol/test/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {
ArcjetReason,
ArcjetRuleResult,
} from "../index.js";
import { Timestamp } from "@bufbuild/protobuf";

function deferred(): [Promise<void>, () => void, (reason?: unknown) => void] {
let resolve: () => void;
Expand Down Expand Up @@ -700,7 +699,6 @@ describe("createClient", () => {
characteristics: [],
getBody: () => Promise.resolve(undefined),
};
const receivedAt = Timestamp.now();
const details = {
ip: "172.100.1.1",
method: "GET",
Expand Down Expand Up @@ -753,7 +751,6 @@ describe("createClient", () => {
reason: new Reason(),
ruleResults: [],
},
receivedAt,
}),
expect.anything(),
);
Expand All @@ -771,7 +768,6 @@ describe("createClient", () => {
characteristics: [],
getBody: () => Promise.resolve(undefined),
};
const receivedAt = Timestamp.now();
const details = {
ip: "172.100.1.1",
method: "GET",
Expand Down Expand Up @@ -823,7 +819,6 @@ describe("createClient", () => {
reason: new Reason(),
ruleResults: [],
},
receivedAt,
}),
expect.anything(),
);
Expand All @@ -841,7 +836,6 @@ describe("createClient", () => {
characteristics: [],
getBody: () => Promise.resolve(undefined),
};
const receivedAt = Timestamp.now();
const details = {
ip: "172.100.1.1",
method: "GET",
Expand Down Expand Up @@ -900,7 +894,6 @@ describe("createClient", () => {
}),
ruleResults: [],
},
receivedAt,
}),
expect.anything(),
);
Expand All @@ -918,7 +911,6 @@ describe("createClient", () => {
characteristics: [],
getBody: () => Promise.resolve(undefined),
};
const receivedAt = Timestamp.now();
const details = {
ip: "172.100.1.1",
method: "GET",
Expand Down Expand Up @@ -970,7 +962,6 @@ describe("createClient", () => {
reason: new Reason(),
ruleResults: [],
},
receivedAt,
}),
expect.anything(),
);
Expand All @@ -988,7 +979,6 @@ describe("createClient", () => {
characteristics: [],
getBody: () => Promise.resolve(undefined),
};
const receivedAt = Timestamp.now();
const details = {
ip: "172.100.1.1",
method: "GET",
Expand Down Expand Up @@ -1036,7 +1026,6 @@ describe("createClient", () => {
reason: new Reason(),
ruleResults: [],
},
receivedAt,
}),
expect.anything(),
);
Expand All @@ -1054,7 +1043,6 @@ describe("createClient", () => {
characteristics: [],
getBody: () => Promise.resolve(undefined),
};
const receivedAt = Timestamp.now();
const details = {
ip: "172.100.1.1",
method: "GET",
Expand Down Expand Up @@ -1128,7 +1116,6 @@ describe("createClient", () => {
],
},
rules: [new Rule()],
receivedAt,
}),
expect.anything(),
);
Expand Down Expand Up @@ -1253,7 +1240,6 @@ describe("createClient", () => {
characteristics: ["ip.src"],
getBody: () => Promise.resolve(undefined),
};
const receivedAt = Timestamp.now();
const details = {
ip: "172.100.1.1",
method: "GET",
Expand Down Expand Up @@ -1322,7 +1308,6 @@ describe("createClient", () => {
],
},
rules: [],
receivedAt,
characteristics: ["ip.src"],
}),
expect.anything(),
Expand Down

0 comments on commit 3da543e

Please sign in to comment.