Skip to content

Commit

Permalink
chore: Distinguish features by plan (#313)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmytton authored Dec 6, 2024
1 parent b261997 commit 503193b
Show file tree
Hide file tree
Showing 10 changed files with 195 additions and 683 deletions.
16 changes: 13 additions & 3 deletions src/content/docs/blueprints/cookie-banner.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ title: "Cookie Banner with Arcjet"
description: "Use Arcjet's IP analysis to show a cookie banner in some jurisdictions."
---

import { Aside } from "@astrojs/starlight/components";
import { Aside, Badge } from "@astrojs/starlight/components";

Cookie banners serve as digital consent notices, informing visitors about data tracking practices. While not universally mandated, they are required in specific jurisdictions, notably the EU under GDPR. Prudent websites implement these notifications selectively, ensuring compliance where necessary while preserving a streamlined user experience in regions without such requirements.
Cookie banners serve as digital consent notices, informing visitors about data
tracking practices. While not universally mandated, they are required in
specific jurisdictions, notably the EU under GDPR. Prudent websites implement
these notifications selectively, ensuring compliance where necessary while
preserving a streamlined user experience in regions without such requirements.

Using Arcjet's IP Geolocation feature it is possible to selectively show the banner's to users resident in jurisdictions that require them, without interfering with the experience of everyone else.
Using Arcjet's IP Geolocation feature it is possible to selectively show the
banner's to users resident in jurisdictions that require them, without
interfering with the experience of everyone else.

Country data is available on the <Badge text="Free" variant="caution" /> plan,
but the region data is only available on the <Badge text="Pro" variant="note" />
and above.

<Aside type="caution">
IP geolocation can be notoriously inaccurate, especially for mobile devices,
Expand Down
21 changes: 12 additions & 9 deletions src/content/docs/blueprints/ip-geolocation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@ title: "Arcjet IP geolocation"
description: "Use Arcjet's IP analysis to customize the response based on the IP location."
---

import { Aside } from "@astrojs/starlight/components";
import { Aside, Badge } from "@astrojs/starlight/components";

Every decision provided by Arcjet includes IP address analysis. You can use this
to customize your response based on the IP location.

## Available fields

- Latitude and longitude.
- Postal code e.g. `94104`.
- City e.g. `San Francisco`.
- Region e.g. `California`.
- Country e.g. `US`.
- Country name e.g. `United States`.
- Continent e.g. `NA`.
- Continent name e.g. `North America`.
- Latitude and longitude. <Badge text="Pro" variant="note" />
- Postal code e.g. `94104`. <Badge text="Pro" variant="note" />
- City e.g. `San Francisco`. <Badge text="Pro" variant="note" />
- Region e.g. `California`. <Badge text="Pro" variant="note" />
- Country e.g. `US`. <Badge text="Free" variant="caution" /> <Badge text="Pro" variant="note" />
- Country name e.g. `United States`. <Badge text="Free" variant="caution" /> <Badge text="Pro" variant="note" />
- Continent e.g. `NA`. <Badge text="Pro" variant="note" />
- Continent name e.g. `North America`. <Badge text="Pro" variant="note" />

Note that the availability of these fields depends on your pricing plan,
indicated by the badge next to each field.

<Aside type="caution">
IP geolocation can be notoriously inaccurate, especially for mobile devices,
Expand Down
12 changes: 7 additions & 5 deletions src/content/docs/blueprints/vpn-proxy-detection.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ title: "VPN & proxy detection"
description: "Use Arcjet's IP analysis to detect VPNs and proxies."
---

import { Aside } from "@astrojs/starlight/components";
import { Aside, Badge } from "@astrojs/starlight/components";

Every decision provided by Arcjet includes IP address analysis. You can use this
to detect VPNs and proxies.

## Available fields

- **IP AS type.** This is the [Autonomous
System](<https://en.wikipedia.org/wiki/Autonomous_system_(Internet)>) associated
with the IP, which can be used to identify VPNs and proxies. This can be one
of `isp`, `hosting`, `business` or `education`.
System](<https://en.wikipedia.org/wiki/Autonomous_system_(Internet)>)
associated with the IP, which can be used to identify VPNs and proxies. This
can be one of `isp`, `hosting`, `business` or `education`. This field is only
available on <Badge text="Pro" variant="note" /> plans and above.
- **IP type.** Arcjet adds one or more categories to the IP address to help you
identify VPNs and proxies. The categories are `vpn`, `proxy`, `tor`,
`hosting`, `relay`.
`hosting`, `relay`. This field is available on the <Badge text="Free"
variant="caution" /> plan and above.

## Checking for data

Expand Down
108 changes: 2 additions & 106 deletions src/content/docs/reference/bun.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import WithRuleTS from "/src/snippets/reference/bun/WithRule.ts?raw";
import WithRuleJS from "/src/snippets/reference/bun/WithRule.js?raw";
import Comments from "/src/components/Comments.astro";
import Requirements from "@/snippets/get-started/bun/Requirements.mdx";
import IPAnalysis from "@/snippets/reference/shared/IPAnalysis.mdx";

[<SDKVersionBun/>](https://www.npmjs.com/package/@arcjet/bun)

Expand Down Expand Up @@ -434,112 +435,7 @@ more information about these properties.

### IP analysis

As of SDK version `1.0.0-alpha.11`, the `ArcjetDecision` object contains an `ip`
property. This includes additional data about the client IP address:

#### IP location

The IP location fields may be `undefined`, but you can use various methods to
check their availability. Using the methods will also refine the type to remove
the need for null or undefined checks.

- `hasLatitude()` (`bool`): returns whether the `latitude` and `accuracyRadius`
fields are available.
- `hasLongitude()` (`bool`): returns whether the `longitude` and
`accuracyRadius` fields are available.
- `hasAccuracyRadius()` (`bool`): returns whether the `longitude`, `latitude`,
and `accuracyRadius` fields are available.
- `hasTimezone()` (`bool`): returns whether the `timezone` field is available.
- `hasPostalCode()` (`bool`): returns whether the `postalCode` field is
available.
- `hasCity()` (`bool`): returns whether the `city` field is available.
- `hasRegion()` (`bool`): returns whether the `region` field is available.
- `hasCountry()` (`bool`): returns whether the `country` and `countryName`
fields are available.
- `hasContinent()` (`bool`): returns whether the `continent` and `continentName`
fields are available.
- `latitude` (`number | undefined`): the latitude of the client IP address.
- `longitude` (`number | undefined`): the longitude of the client IP address.
- `accuracyRadius` (`number | undefined`): how accurate the location is in
kilometers.
- `timezone` (`string | undefined`): the timezone of the client IP address.
- `postalCode` (`string | undefined`): the postal or zip code of the client IP
address.
- `city` (`string | undefined`): the city of the client IP address.
- `region` (`string | undefined`): the region of the client IP address.
- `country` (`string | undefined`): the country code the client IP address.
- `countryName` (`string | undefined`): the country name of the client IP
address.
- `continent` (`string | undefined`): the continent code of the client IP
address.
- `continentName` (`string | undefined`): the continent name of the client IP
address.

##### Location accuracy

IP geolocation can be notoriously inaccurate, especially for mobile devices,
satellite internet providers, and even just normal users. Likewise with the
specific fields like `city` and `region`, which can be very inaccurate. Country
is usually accurate, but there are often cases where IP addresses are
mis-located. These fields are provided for convenience e.g. suggesting a user
location, but should not be relied upon by themselves.

#### IP AS

This is useful for identifying the network operator of the client IP address.
This is useful for understanding whether the client is likely to be automated or
not, or being stricter with requests from certain networks.

The IP AS fields may be `undefined`, but you can use the `hasASN()` method to
check their availability. Using this method will also refine the type to remove
the need for null-ish checks.

- `hasASN()` (`bool`): returns whether all of the ASN fields are available.
- `asn` (`string | undefined`): the autonomous system (AS) number of the client
IP address.
- `asnName` (`string | undefined`): the name of the AS of the client IP address.
- `asnDomain` (`string | undefined`): the domain of the AS of the client IP
address.
- `asnType` (`'isp' | 'hosting' | 'business' | 'education'`): the type of the AS
of the client IP address. Real users are more likely to be on an ISP or
business network rather than a hosting provider. Education networks often have
a single or small number of IP addresses even though there are many users. A
common mistake is to block a single IP because of too many requests when it is
a university or company network using
[NAT](https://en.wikipedia.org/wiki/Carrier-grade_NAT) (Network Address
Translation) to give many users the same IP.
- `asnCountry` (`string | undefined`): the country code of the AS of the client
IP address. This is the administrative country of the AS, not necessarily the
country of the client IP address.

#### IP type

The `service` field may be `undefined`, but you can use the `hasService()`
method to check the availability. Using this method will also refine the type to
remove the need for null-ish checks.

- `hasService()` (`bool`): whether the `service` field is available.
- `service` (`string | undefined`): the name of the service associated with the
IP address—e.g. `Apple Private Relay`.
- `isHosting()` (`bool`): returns whether the IP address of the client is owned
by a hosting provider. Requests originating from a hosting provider IP
significantly increase the likelihood that this is an automated client.
- `isVpn()` (`bool`): returns whether the IP address of the client is owned by a
VPN provider. Many people use VPNs for privacy or work purposes, so by itself
this is not an indicator of the client being automated. However, it does
increase the risk score of the client and depending on your use case it may be
a characteristic you wish to restrict.
- `isProxy()` (`bool`): returns whether the IP address of the client is owned by
a proxy provider. Similar to `isVpn()`, but proxies are more likely to involve
automated traffic.
- `isTor()` (`bool`): returns whether the IP address of the client is known to
be part of the Tor network. As with `isVpn()`, there are legitimate uses for
hiding your identity through Tor, however it is also often a way to hide the
origin of malicious traffic.
- `isRelay()` (`bool`): returns whether the IP address of the client is owned by
a relay service. The most common example is Apple iCloud Relay, which
indicates the client is less likely to be automated because Apple requires a
paid subscription linked to an Apple account in good standing.
<IPAnalysis />

## Error handling

Expand Down
108 changes: 2 additions & 106 deletions src/content/docs/reference/nestjs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import ProxiesTS from "/src/snippets/reference/nestjs/Proxies.ts?raw";
import ConfigurationTS from "/src/snippets/reference/nestjs/Configuration.ts?raw";
import IPLocationTS from "/src/snippets/reference/nestjs/IPLocation.ts?raw";
import NodeVersions from "/src/snippets/reference/node-versions.mdx";
import IPAnalysis from "/src/snippets/reference/shared/IPAnalysis.mdx";

[<SDKVersionNestjs />](https://www.npmjs.com/package/@arcjet/nest)

Expand Down Expand Up @@ -337,112 +338,7 @@ information about these properties.

### IP analysis

As of SDK version `1.0.0-alpha.11`, the `ArcjetDecision` object contains an `ip`
property. This includes additional data about the client IP address:

#### IP location

The IP location fields may be `undefined`, but you can use various methods to
check their availability. Using the methods will also refine the type to remove
the need for null or undefined checks.

- `hasLatitude()` (`bool`): returns whether the `latitude` and `accuracyRadius`
fields are available.
- `hasLongitude()` (`bool`): returns whether the `longitude` and
`accuracyRadius` fields are available.
- `hasAccuracyRadius()` (`bool`): returns whether the `longitude`, `latitude`,
and `accuracyRadius` fields are available.
- `hasTimezone()` (`bool`): returns whether the `timezone` field is available.
- `hasPostalCode()` (`bool`): returns whether the `postalCode` field is
available.
- `hasCity()` (`bool`): returns whether the `city` field is available.
- `hasRegion()` (`bool`): returns whether the `region` field is available.
- `hasCountry()` (`bool`): returns whether the `country` and `countryName`
fields are available.
- `hasContinent()` (`bool`): returns whether the `continent` and `continentName`
fields are available.
- `latitude` (`number | undefined`): the latitude of the client IP address.
- `longitude` (`number | undefined`): the longitude of the client IP address.
- `accuracyRadius` (`number | undefined`): how accurate the location is in
kilometers.
- `timezone` (`string | undefined`): the timezone of the client IP address.
- `postalCode` (`string | undefined`): the postal or zip code of the client IP
address.
- `city` (`string | undefined`): the city of the client IP address.
- `region` (`string | undefined`): the region of the client IP address.
- `country` (`string | undefined`): the country code the client IP address.
- `countryName` (`string | undefined`): the country name of the client IP
address.
- `continent` (`string | undefined`): the continent code of the client IP
address.
- `continentName` (`string | undefined`): the continent name of the client IP
address.

##### Location accuracy

IP geolocation can be notoriously inaccurate, especially for mobile devices,
satellite internet providers, and even just normal users. Likewise with the
specific fields like `city` and `region`, which can be very inaccurate. Country
is usually accurate, but there are often cases where IP addresses are
mis-located. These fields are provided for convenience e.g. suggesting a user
location, but should not be relied upon by themselves.

#### IP AS

This is useful for identifying the network operator of the client IP address.
This is useful for understanding whether the client is likely to be automated or
not, or being stricter with requests from certain networks.

The IP AS fields may be `undefined`, but you can use the `hasASN()` method to
check their availability. Using this method will also refine the type to remove
the need for null-ish checks.

- `hasASN()` (`bool`): returns whether all of the ASN fields are available.
- `asn` (`string | undefined`): the autonomous system (AS) number of the client
IP address.
- `asnName` (`string | undefined`): the name of the AS of the client IP address.
- `asnDomain` (`string | undefined`): the domain of the AS of the client IP
address.
- `asnType` (`'isp' | 'hosting' | 'business' | 'education'`): the type of the AS
of the client IP address. Real users are more likely to be on an ISP or
business network rather than a hosting provider. Education networks often have
a single or small number of IP addresses even though there are many users. A
common mistake is to block a single IP because of too many requests when it is
a university or company network using
[NAT](https://en.wikipedia.org/wiki/Carrier-grade_NAT) (Network Address
Translation) to give many users the same IP.
- `asnCountry` (`string | undefined`): the country code of the AS of the client
IP address. This is the administrative country of the AS, not necessarily the
country of the client IP address.

#### IP type

The `service` field may be `undefined`, but you can use the `hasService()`
method to check the availability. Using this method will also refine the type to
remove the need for null-ish checks.

- `hasService()` (`bool`): whether the `service` field is available.
- `service` (`string | undefined`): the name of the service associated with the
IP address—e.g. `Apple Private Relay`.
- `isHosting()` (`bool`): returns whether the IP address of the client is owned
by a hosting provider. Requests originating from a hosting provider IP
significantly increase the likelihood that this is an automated client.
- `isVpn()` (`bool`): returns whether the IP address of the client is owned by a
VPN provider. Many people use VPNs for privacy or work purposes, so by itself
this is not an indicator of the client being automated. However, it does
increase the risk score of the client and depending on your use case it may be
a characteristic you wish to restrict.
- `isProxy()` (`bool`): returns whether the IP address of the client is owned by
a proxy provider. Similar to `isVpn()`, but proxies are more likely to involve
automated traffic.
- `isTor()` (`bool`): returns whether the IP address of the client is known to
be part of the Tor network. As with `isVpn()`, there are legitimate uses for
hiding your identity through Tor, however it is also often a way to hide the
origin of malicious traffic.
- `isRelay()` (`bool`): returns whether the IP address of the client is owned by
a relay service. The most common example is Apple iCloud Relay, which
indicates the client is less likely to be automated because Apple requires a
paid subscription linked to an Apple account in good standing.
<IPAnalysis />

#### Example

Expand Down
Loading

0 comments on commit 503193b

Please sign in to comment.