Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Introduce DisplayType component that outputs pretty-printed types #306

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat: Leverage DisplayType component to display some types
blaine-arcjet committed Dec 4, 2024

Verified

This commit was signed with the committer’s verified signature.
synfinatic Aaron Turner
commit 4ffee77dd7997df3f9499b1a650254eade03584f
19 changes: 7 additions & 12 deletions src/content/docs/email-validation/reference.mdx
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@ ajToc:
import { Aside } from "@astrojs/starlight/components";
import SlotByFramework from "@/components/SlotByFramework";
import TextByFramework from "@/components/TextByFramework";
import DisplayType from "@/components/DisplayType.astro";

import DecisionLogBun from "@/snippets/email-validation/reference/bun/DecisionLog.mdx";
import DecisionLogNestJs from "@/snippets/email-validation/reference/nestjs/DecisionLog.mdx";
@@ -51,19 +52,13 @@ reduce the amount of spam or fraudulent accounts.
Email validation is configured by specifying the email types you wish to block
and whether you wish to modify certain validation options.

The configuration definition is:
The `arcjet` client can be configured with one or more Email validation rules,
which are constructed with the `validateEmail(options: EmailOptions)` function
and configured by `EmailOptions`:

```ts
type EmailOptions = {
mode?: "LIVE" | "DRY_RUN";
block?: ArcjetEmailType[];
requireTopLevelDomain?: boolean; // default: true
allowDomainLiteral?: boolean; // default: false
};
```

The `arcjet` client is configured with one or many `validateEmail` rules which
take `EmailOptions`.
<DisplayType type="EmailOptions" from="arcjet" />
<DisplayType type="ArcjetMode" from="arcjet" />
<DisplayType type="ArcjetEmailType" from="arcjet" />

<Aside type="note">
When specifying multiple rules, the order of the rules is ignored. Rule
43 changes: 27 additions & 16 deletions src/content/docs/sensitive-info/reference.mdx
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@ ajToc:

import SlotByFramework from "@/components/SlotByFramework";
import TextByFramework from "@/components/TextByFramework";
import DisplayType from "@/components/DisplayType.astro";

import NestJsDecoratorRoutes from "@/snippets/sensitive-info/reference/nestjs/DecoratorRoutes.mdx";
import PerRouteVsMiddlewareNextJs from "@/snippets/sensitive-info/reference/nextjs/PerRouteVsMiddleware.mdx";
@@ -92,32 +93,42 @@ sensitive information such as PII that you do not wish to handle.

## Configuration

Sensitive Info is configured by specifying which mode you want it to run in.
Sensitive information detection is configured by allowing or denying a subset of
sensitive information. The `allow` and `deny` lists are mutually-exclusive, such
that using `allow` will result in a `DENY` decision for any detected sensitive
information that is not specified in the `allow` list and using `deny` will
result in an `ALLOW` decision for any detected sensitive information that is not
specified in the `deny` list.

The configuration definition is:
The `arcjet` client can be configured with one or more Sensitive information
rules, which are constructed with the
`sensitiveInfo(options: SensitiveInfoOptionsAllow | SensitiveInfoOptionsDeny)`
function and configured by `SensitiveInfoOptionsAllow` or
`SensitiveInfoOptionsDeny`:

```ts
type SensitiveInfoOptions = {
type SensitiveInfoOptionsAllow = {
mode?: "LIVE" | "DRY_RUN";
allow?: Array<SensitiveInfoType>; // Cannot be specified if `deny` is present
deny?: Array<SensitiveInfoType>;// Cannot be specified if `allow` is present
allow?: Array<ArcjetSensitiveInfoType>;
contextWindowSize?: number;
// You can also provide a custom detection function to detect other types
// of sensitive information (see below).
detect?: (tokens: string[]) -> Array<SensitiveInfoType | undefined>;
};
```

The `arcjet` client is configured with one or more `sensitiveInfo` rules which take
one or many `SensitiveInfoOptions`.

The `SensitiveInfoType` enum allows the following values:

- `EMAIL`
- `CREDIT_CARD`
- `IP_ADDRESS`
- `PHONE_NUMBER`
```ts
type SensitiveInfoOptionsDeny = {
mode?: "LIVE" | "DRY_RUN";
deny?: Array<ArcjetSensitiveInfoType>;
contextWindowSize?: number;
// You can also provide a custom detection function to detect other types
// of sensitive information (see below).
detect?: (tokens: string[]) -> Array<SensitiveInfoType | undefined>;
};
```

You can also provide a custom detection function to detect other types of
sensitive information (see below).
<DisplayType type="ArcjetSensitiveInfoType" from="arcjet" />

:::note
When specifying multiple rules, the order of the rules is ignored. Rule
15 changes: 6 additions & 9 deletions src/content/docs/shield/reference.mdx
Original file line number Diff line number Diff line change
@@ -60,6 +60,7 @@ ajToc:

import SlotByFramework from "@/components/SlotByFramework";
import TextByFramework from "@/components/TextByFramework";
import DisplayType from "@/components/DisplayType.astro";

import DecisionLogBun from "@/snippets/shield/reference/bun/DecisionLog.mdx";
import ErrorsBun from "@/snippets/shield/reference/bun/Errors.mdx";
@@ -87,16 +88,12 @@ Arcjet Shield protects your application against common attacks, including the

Shield is configured by specifying which mode you want it to run in.

The configuration definition is:
The `arcjet` client can be configured with one or more Shield rules, which are
constructed with the `shield(options: ShieldOptions)` function and configured by
`ShieldOptions`:

```ts
type ShieldOptions = {
mode?: "LIVE" | "DRY_RUN";
};
```

The `arcjet` client is configured with one or more `shield` rules which take
one or many `ShieldOptions`.
<DisplayType type="ShieldOptions" from="arcjet" />
<DisplayType type="ArcjetMode" from="arcjet" />

:::note
When specifying multiple rules, the order of the rules is ignored. Rule