Skip to content

Commit

Permalink
Merging 6ea8a38 into trunk-temp/pr-2394/c2bda00f-b4da-46e7-ad90-88f20…
Browse files Browse the repository at this point in the history
…8bba80b
  • Loading branch information
trunk-io[bot] authored Dec 3, 2024
2 parents 63fadcf + 6ea8a38 commit 7e50b57
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 14 deletions.
20 changes: 18 additions & 2 deletions arcjet-bun/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import core from "arcjet";
import type {
ArcjetDecision,
ArcjetOptions,
ArcjetOptions as CoreOptions,
Primitive,
Product,
ArcjetRequest,
Expand Down Expand Up @@ -107,6 +107,22 @@ export function createRemoteClient(options?: RemoteClientOptions) {
});
}

/**
* The options used to configure an {@link ArcjetBun} client.
*/
export type ArcjetOptions<
Rules extends [...Array<Primitive | Product>],
Characteristics extends readonly string[],
> = Simplify<
CoreOptions<Rules, Characteristics> & {
/**
* One or more IP Address of trusted proxies in front of the application.
* These addresses will be excluded when Arcjet detects a public IP address.
*/
proxies?: Array<string>;
}
>;

/**
* The ArcjetBun client provides a public `protect()` method to
* make a decision about how a Bun.sh request should be handled.
Expand Down Expand Up @@ -205,7 +221,7 @@ export default function arcjet<
ip: ipCache.get(request),
headers,
},
{ platform: platform(env) },
{ platform: platform(env), proxies: options.proxies },
);
if (ip === "") {
// If the `ip` is empty but we're in development mode, we default the IP
Expand Down
20 changes: 18 additions & 2 deletions arcjet-deno/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import core from "arcjet";
import type {
ArcjetDecision,
ArcjetOptions,
ArcjetOptions as CoreOptions,
Primitive,
Product,
ArcjetRequest,
Expand Down Expand Up @@ -108,6 +108,22 @@ export function createRemoteClient(options?: RemoteClientOptions) {
});
}

/**
* The options used to configure an {@link ArcjetDeno} client.
*/
export type ArcjetOptions<
Rules extends [...Array<Primitive | Product>],
Characteristics extends readonly string[],
> = Simplify<
CoreOptions<Rules, Characteristics> & {
/**
* One or more IP Address of trusted proxies in front of the application.
* These addresses will be excluded when Arcjet detects a public IP address.
*/
proxies?: Array<string>;
}
>;

/**
* The ArcjetDeno client provides a public `protect()` method to
* make a decision about how a Deno request should be handled.
Expand Down Expand Up @@ -207,7 +223,7 @@ export default function arcjet<
ip: ipCache.get(request),
headers,
},
{ platform: platform(env) },
{ platform: platform(env), proxies: options.proxies },
);
if (ip === "") {
// If the `ip` is empty but we're in development mode, we default the IP
Expand Down
20 changes: 18 additions & 2 deletions arcjet-nest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "reflect-metadata";
import core from "arcjet";
import type {
ArcjetDecision,
ArcjetOptions,
ArcjetOptions as CoreOptions,
Primitive,
Product,
ArcjetRequest,
Expand Down Expand Up @@ -157,6 +157,22 @@ function cookiesToString(cookies: string | string[] | undefined): string {
return cookies;
}

/**
* The options used to configure an {@link ArcjetNest} client.
*/
export type ArcjetOptions<
Rules extends [...Array<Primitive | Product>],
Characteristics extends readonly string[],
> = Simplify<
CoreOptions<Rules, Characteristics> & {
/**
* One or more IP Address of trusted proxies in front of the application.
* These addresses will be excluded when Arcjet detects a public IP address.
*/
proxies?: Array<string>;
}
>;

/**
* The ArcjetNest client provides a public `protect()` method to
* make a decision about how a NestJS request should be handled.
Expand Down Expand Up @@ -222,7 +238,7 @@ function arcjet<
socket: request.socket,
headers,
},
{ platform: platform(process.env) },
{ platform: platform(process.env), proxies: options.proxies },
);
if (ip === "") {
// If the `ip` is empty but we're in development mode, we default the IP
Expand Down
20 changes: 18 additions & 2 deletions arcjet-next/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { NextMiddlewareResult } from "next/dist/server/web/types.js";
import core from "arcjet";
import type {
ArcjetDecision,
ArcjetOptions,
ArcjetOptions as CoreOptions,
Primitive,
Product,
ArcjetRequest,
Expand Down Expand Up @@ -190,6 +190,22 @@ function cookiesToString(cookies?: ArcjetNextRequest["cookies"]): string {
.join("; ");
}

/**
* The options used to configure an {@link ArcjetNest} client.
*/
export type ArcjetOptions<
Rules extends [...Array<Primitive | Product>],
Characteristics extends readonly string[],
> = Simplify<
CoreOptions<Rules, Characteristics> & {
/**
* One or more IP Address of trusted proxies in front of the application.
* These addresses will be excluded when Arcjet detects a public IP address.
*/
proxies?: Array<string>;
}
>;

/**
* The ArcjetNext client provides a public `protect()` method to
* make a decision about how a Next.js request should be handled.
Expand Down Expand Up @@ -263,7 +279,7 @@ export default function arcjet<
requestContext: request.requestContext,
headers,
},
{ platform: platform(process.env) },
{ platform: platform(process.env), proxies: options.proxies },
);
if (ip === "") {
// If the `ip` is empty but we're in development mode, we default the IP
Expand Down
20 changes: 18 additions & 2 deletions arcjet-node/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import core from "arcjet";
import type {
ArcjetDecision,
ArcjetOptions,
ArcjetOptions as CoreOptions,
Primitive,
Product,
ArcjetRequest,
Expand Down Expand Up @@ -138,6 +138,22 @@ function cookiesToString(cookies: string | string[] | undefined): string {
return cookies;
}

/**
* The options used to configure an {@link ArcjetNode} client.
*/
export type ArcjetOptions<
Rules extends [...Array<Primitive | Product>],
Characteristics extends readonly string[],
> = Simplify<
CoreOptions<Rules, Characteristics> & {
/**
* One or more IP Address of trusted proxies in front of the application.
* These addresses will be excluded when Arcjet detects a public IP address.
*/
proxies?: Array<string>;
}
>;

/**
* The ArcjetNode client provides a public `protect()` method to
* make a decision about how a Node.js request should be handled.
Expand Down Expand Up @@ -210,7 +226,7 @@ export default function arcjet<
socket: request.socket,
headers,
},
{ platform: platform(process.env) },
{ platform: platform(process.env), proxies: options.proxies },
);
if (ip === "") {
// If the `ip` is empty but we're in development mode, we default the IP
Expand Down
20 changes: 18 additions & 2 deletions arcjet-remix/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import core from "arcjet";
import type {
ArcjetDecision,
ArcjetOptions,
ArcjetOptions as CoreOptions,
Primitive,
Product,
ArcjetRequest,
Expand Down Expand Up @@ -109,6 +109,22 @@ export type ArcjetRemixRequest = {
context: { [key: string]: unknown };
};

/**
* The options used to configure an {@link ArcjetRemix} client.
*/
export type ArcjetOptions<
Rules extends [...Array<Primitive | Product>],
Characteristics extends readonly string[],
> = Simplify<
CoreOptions<Rules, Characteristics> & {
/**
* One or more IP Address of trusted proxies in front of the application.
* These addresses will be excluded when Arcjet detects a public IP address.
*/
proxies?: Array<string>;
}
>;

/**
* The ArcjetRemix client provides a public `protect()` method to
* make a decision about how a Remix request should be handled.
Expand Down Expand Up @@ -182,7 +198,7 @@ export default function arcjet<
ip: context?.ip,
headers,
},
{ platform: platform(process.env) },
{ platform: platform(process.env), proxies: options.proxies },
);
if (ip === "") {
// If the `ip` is empty but we're in development mode, we default the IP
Expand Down
20 changes: 18 additions & 2 deletions arcjet-sveltekit/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import core from "arcjet";
import type {
ArcjetDecision,
ArcjetOptions,
ArcjetOptions as CoreOptions,
Primitive,
Product,
ArcjetRequest,
Expand Down Expand Up @@ -126,6 +126,22 @@ function cookiesToString(
.join("; ");
}

/**
* The options used to configure an {@link ArcjetSvelteKit} client.
*/
export type ArcjetOptions<
Rules extends [...Array<Primitive | Product>],
Characteristics extends readonly string[],
> = Simplify<
CoreOptions<Rules, Characteristics> & {
/**
* One or more IP Address of trusted proxies in front of the application.
* These addresses will be excluded when Arcjet detects a public IP address.
*/
proxies?: Array<string>;
}
>;

/**
* The ArcjetSvelteKit client provides a public `protect()` method to
* make a decision about how a SvelteKit request should be handled.
Expand Down Expand Up @@ -197,7 +213,7 @@ export default function arcjet<
ip: event.getClientAddress(),
headers,
},
{ platform: platform(env) },
{ platform: platform(env), proxies: options.proxies },
);
if (ip === "") {
// If the `ip` is empty but we're in development mode, we default the IP
Expand Down

0 comments on commit 7e50b57

Please sign in to comment.