vpndetection-better-auth 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +125 -2
- package/dist/index.d.ts +65 -0
- package/dist/index.js +118 -0
- package/dist/index.js.map +1 -0
- package/package.json +60 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mslm Dev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,126 @@
|
|
|
1
|
-
#
|
|
1
|
+
# [<img src="https://s3.vpndetection.io/vpndetection-public/brand/mark.svg" alt="VPNDetection" height="28"/>](https://vpndetection.io/) VPNDetection Better Auth Plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/vpndetection-better-auth)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
The official [Better Auth](https://www.better-auth.com) plugin for the [VPNDetection](https://vpndetection.io) API: it checks the address behind each sign-up for VPN, Tor, proxy and hosting use, and refuses the ones you choose with a 403.
|
|
7
|
+
|
|
8
|
+
## Getting Started
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install vpndetection-better-auth
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Requires Node.js 22 or newer and Better Auth 1.7 or newer. TypeScript types are included.
|
|
15
|
+
|
|
16
|
+
**Start with a free API key**, no card needed: create one in the [console](https://app.vpndetection.io). A free key checks VPN, Tor and relays on its organization's quota. Hosting networks and the proxy flags are the Data plan's ([pricing](https://vpndetection.io/pricing)). Past the quota, each lookup raises `quota_exceeded` until the quota resets, and the plugin lets the sign-up through and logs it ([When a lookup fails](#when-a-lookup-fails)).
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { betterAuth } from 'better-auth';
|
|
20
|
+
import { vpndetection } from 'vpndetection-better-auth';
|
|
21
|
+
|
|
22
|
+
export const auth = betterAuth({
|
|
23
|
+
emailAndPassword: { enabled: true },
|
|
24
|
+
plugins: [
|
|
25
|
+
vpndetection({
|
|
26
|
+
apiKey: process.env.VPNDETECTION_API_KEY,
|
|
27
|
+
blockCondition: [{ isVpn: true }, { isTor: true }],
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
A refused sign-up gets a `403` with the code `VPNDETECTION_BLOCKED` and the message `Access from this network is not allowed.`, which `message` replaces. No user is created. The same check runs when your server calls `auth.api.signUpEmail` with the request's headers.
|
|
34
|
+
|
|
35
|
+
## What it checks
|
|
36
|
+
|
|
37
|
+
By default only `/sign-up/email`. `paths` takes Better Auth's endpoint paths, and one ending in `*` matches every path that starts with it:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
vpndetection({
|
|
41
|
+
apiKey: process.env.VPNDETECTION_API_KEY,
|
|
42
|
+
blockCondition: { isVpn: true },
|
|
43
|
+
paths: ['/sign-up/email', '/sign-in/*'],
|
|
44
|
+
})
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
A sign-in through a social provider is checked at `/sign-in/social`, before Better Auth knows whether the account is new, so adding it checks sign-ins as well as sign-ups.
|
|
48
|
+
|
|
49
|
+
## Blocking
|
|
50
|
+
|
|
51
|
+
A condition is written in the shape of a result, and only the members you name count:
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
blockCondition: { isVpn: true } // any VPN
|
|
55
|
+
blockCondition: [{ isVpn: true }, { isTor: true }, { isRelay: true }] // a list is OR
|
|
56
|
+
blockCondition: { isVpn: true, vpn: { provider: 'nordvpn' } } // one provider, on the Data plan
|
|
57
|
+
blockCondition: { isHosting: true } // a datacenter, on the Data plan
|
|
58
|
+
blockCondition: { isIspproxy: true } // an ISP proxy, on the Data plan
|
|
59
|
+
blockCondition: { isResproxy: true, resproxy: { hits: { gte: 5 } } } // a numeric threshold, on the Data plan
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Values match by equality, strings without regard to case, and an array means any of them. `{ gte, gt, lte, lt }` compares numbers. A member set to `false` or `null` is ignored, and a condition that constrains nothing is refused when the plugin is built, since it would refuse every sign-up.
|
|
63
|
+
|
|
64
|
+
Without a `blockCondition` nobody is refused, and `onLookup` gets each answer to record or act on:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
vpndetection({
|
|
68
|
+
apiKey: process.env.VPNDETECTION_API_KEY,
|
|
69
|
+
onLookup: (lookup, request) => {
|
|
70
|
+
console.log(request.path, lookup.ip, lookup.result?.isVpn);
|
|
71
|
+
},
|
|
72
|
+
})
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Where the client address comes from
|
|
76
|
+
|
|
77
|
+
By default the plugin reads the address Better Auth itself resolves, as its rate limiter does, so it follows your `advanced.ipAddress` settings. Better Auth reads `X-Forwarded-For` and takes it only when it holds one address, unless you list your proxies in `trustedProxies`, when it walks the chain from the right past them:
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
betterAuth({
|
|
81
|
+
advanced: {
|
|
82
|
+
ipAddress: {
|
|
83
|
+
trustedProxies: ['10.0.0.0/8'], // your load balancer
|
|
84
|
+
// ipAddressHeaders: ['cf-connecting-ip'], // or the header your edge writes
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
plugins: [vpndetection({ apiKey: process.env.VPNDETECTION_API_KEY, blockCondition: { isVpn: true } })],
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
When Better Auth resolves no address, the plugin looks nothing up, lets the sign-up through and warns once. Outside production Better Auth falls back to `127.0.0.1`, which is a private address and is answered locally without a lookup.
|
|
92
|
+
|
|
93
|
+
`ipSelector` replaces Better Auth's address with your own choice:
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
import { headerIpSelector, xffIpSelector } from 'vpndetection-better-auth';
|
|
97
|
+
|
|
98
|
+
vpndetection({ ipSelector: headerIpSelector('CF-Connecting-IP') }) // behind Cloudflare
|
|
99
|
+
vpndetection({ ipSelector: xffIpSelector({ depth: 1 }) }) // the address your nearest proxy saw
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
The left-most `X-Forwarded-For` entry is whatever the visitor sent, so `xffIpSelector()` without a `depth` is only safe when an edge you control overwrites the header.
|
|
103
|
+
|
|
104
|
+
## When a lookup fails
|
|
105
|
+
|
|
106
|
+
A lookup that fails (a network error, a timeout, a spent quota, an outage of ours) lets the sign-up through and logs it through Better Auth's logger, a spent quota at error level and at most once a minute, however many sign-ups it fails. `failClosed: true` refuses the sign-up instead. A lookup holds the request for at most 2.5 seconds (`timeoutMs`) and is not retried (`retries`).
|
|
107
|
+
|
|
108
|
+
Each answer is cached per address for the client's default time, so a burst of sign-ups from one address makes one lookup. Pass `client` to share an existing `VPNDetection` client and its cache.
|
|
109
|
+
|
|
110
|
+
## Absent is not false
|
|
111
|
+
|
|
112
|
+
A free key's answers leave out the hosting flag, the five proxy flags (`isIspproxy` among them) and the AS's `type`, and `isVpn` can be absent from an answer too. A field the answer leaves out is `undefined`, never `false`, and a condition on it never matches: the plugin warns once (`onMissingField`, `'throw'` to make it an error, `'ignore'` to say nothing).
|
|
113
|
+
|
|
114
|
+
## Other Libraries
|
|
115
|
+
|
|
116
|
+
There are official VPNDetection client libraries available for many languages including PHP, Python, Go, Java, Ruby, and many popular frameworks such as Express, Next.js, Django, Rails, and Laravel. See our GitHub at https://github.com/vpndetection-io for more.
|
|
117
|
+
|
|
118
|
+
## About VPNDetection
|
|
119
|
+
|
|
120
|
+
VPN Detection API: Accurate anonymity detection identifying VPNs, residential proxies, hosting servers, Tor nodes, CDNs, relays and more.
|
|
121
|
+
|
|
122
|
+
[<picture><source media="(prefers-color-scheme: dark)" srcset="https://s3.vpndetection.io/vpndetection-public/brand/logo-dark.svg"><img src="https://s3.vpndetection.io/vpndetection-public/brand/logo.svg" alt="VPNDetection" height="40"/></picture>](https://vpndetection.io/)
|
|
123
|
+
|
|
124
|
+
## License
|
|
125
|
+
|
|
126
|
+
This project is licensed under the [MIT License](LICENSE).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { BetterAuthPlugin } from 'better-auth';
|
|
2
|
+
import { getIP } from 'better-auth/api';
|
|
3
|
+
import type { IpSelector, Lookup, MiddlewareOptions } from 'vpndetection/middleware';
|
|
4
|
+
export type { BlockCondition, IpSelector, Lookup, NumericBound } from 'vpndetection/middleware';
|
|
5
|
+
/** The paths checked when `paths` is not given: an email and password sign-up. */
|
|
6
|
+
export declare const DEFAULT_PATHS: readonly string[];
|
|
7
|
+
/** The error code a refused request answers with, beside its message. */
|
|
8
|
+
export declare const BLOCKED_CODE = "VPNDETECTION_BLOCKED";
|
|
9
|
+
/**
|
|
10
|
+
* What a hook sees of the request it runs for: its headers, the request itself when it came over HTTP,
|
|
11
|
+
* and Better Auth's options, which say how Better Auth reads a client address.
|
|
12
|
+
*/
|
|
13
|
+
export interface AuthRequest {
|
|
14
|
+
path: string;
|
|
15
|
+
headers?: Headers;
|
|
16
|
+
request?: Request;
|
|
17
|
+
options: Parameters<typeof getIP>[1];
|
|
18
|
+
}
|
|
19
|
+
export interface Options extends MiddlewareOptions<AuthRequest> {
|
|
20
|
+
/**
|
|
21
|
+
* The endpoints to check, as Better Auth names them. Defaults to `['/sign-up/email']`. A path ending in
|
|
22
|
+
* `*` matches every path that starts with what comes before it: `'/sign-in/*'` checks every sign-in.
|
|
23
|
+
*/
|
|
24
|
+
paths?: readonly string[];
|
|
25
|
+
/** The message a refused request answers with. Defaults to `Access from this network is not allowed.` */
|
|
26
|
+
message?: string;
|
|
27
|
+
/** Called with the answer of every lookup the plugin makes, refused or not, before it refuses one. */
|
|
28
|
+
onLookup?: (lookup: Lookup, request: AuthRequest) => void | Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Check the visitor behind a sign-up against VPNDetection, and refuse one whose answer matches
|
|
32
|
+
* `blockCondition` with a `403`.
|
|
33
|
+
*
|
|
34
|
+
* Without a `blockCondition` it refuses nobody, and only hands each answer to `onLookup`.
|
|
35
|
+
*
|
|
36
|
+
* A lookup that fails (network, a timeout, a spent quota, an outage of ours) lets the request through and is
|
|
37
|
+
* logged through Better Auth's logger, unless you set `failClosed`. A key past its organization's quota is
|
|
38
|
+
* one: the client raises `quota_exceeded`, no condition is evaluated, and it is logged at error level at most
|
|
39
|
+
* once a minute, however many sign-ups it fails.
|
|
40
|
+
*/
|
|
41
|
+
export declare function vpndetection(options?: Options): BetterAuthPlugin;
|
|
42
|
+
/**
|
|
43
|
+
* The address Better Auth itself resolves, as its rate limiter does: the headers named in
|
|
44
|
+
* `advanced.ipAddress.ipAddressHeaders` (`X-Forwarded-For` by default), walked past
|
|
45
|
+
* `advanced.ipAddress.trustedProxies`. With no trusted proxy set, Better Auth takes `X-Forwarded-For` only
|
|
46
|
+
* when it holds one address, and with `disableIpTracking` it resolves none, which leaves every request
|
|
47
|
+
* unchecked with a warning. Set those options for your edge, or pick another selector.
|
|
48
|
+
*/
|
|
49
|
+
export declare const defaultIpSelector: IpSelector<AuthRequest>;
|
|
50
|
+
/**
|
|
51
|
+
* An address from `X-Forwarded-For`.
|
|
52
|
+
*
|
|
53
|
+
* **The left-most entry is whatever the caller sent**, since proxies append, so this is only trustworthy
|
|
54
|
+
* when an edge you control overwrites the header. When you know how many proxies sit in front, count from
|
|
55
|
+
* the right instead: `xffIpSelector({ depth: 1 })` is the address your nearest proxy saw.
|
|
56
|
+
*/
|
|
57
|
+
export declare const xffIpSelector: (options?: {
|
|
58
|
+
depth?: number;
|
|
59
|
+
}) => IpSelector<AuthRequest>;
|
|
60
|
+
/**
|
|
61
|
+
* An address from a single-value header your edge writes: `headerIpSelector('CF-Connecting-IP')` behind
|
|
62
|
+
* Cloudflare, `headerIpSelector('True-Client-IP')` behind Akamai. Falls back to Better Auth's own address
|
|
63
|
+
* when the header is absent.
|
|
64
|
+
*/
|
|
65
|
+
export declare const headerIpSelector: (name: string) => IpSelector<AuthRequest>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { APIError, createAuthMiddleware, getIP } from 'better-auth/api';
|
|
3
|
+
import { VPNDetection } from 'vpndetection';
|
|
4
|
+
import { bindSelectors, createCore } from 'vpndetection/middleware';
|
|
5
|
+
const VERSION = createRequire(import.meta.url)('../package.json').version;
|
|
6
|
+
const USER_AGENT = `vpndetection-better-auth/${VERSION}`;
|
|
7
|
+
/** The paths checked when `paths` is not given: an email and password sign-up. */
|
|
8
|
+
export const DEFAULT_PATHS = ['/sign-up/email'];
|
|
9
|
+
/** The error code a refused request answers with, beside its message. */
|
|
10
|
+
export const BLOCKED_CODE = 'VPNDETECTION_BLOCKED';
|
|
11
|
+
/**
|
|
12
|
+
* Check the visitor behind a sign-up against VPNDetection, and refuse one whose answer matches
|
|
13
|
+
* `blockCondition` with a `403`.
|
|
14
|
+
*
|
|
15
|
+
* Without a `blockCondition` it refuses nobody, and only hands each answer to `onLookup`.
|
|
16
|
+
*
|
|
17
|
+
* A lookup that fails (network, a timeout, a spent quota, an outage of ours) lets the request through and is
|
|
18
|
+
* logged through Better Auth's logger, unless you set `failClosed`. A key past its organization's quota is
|
|
19
|
+
* one: the client raises `quota_exceeded`, no condition is evaluated, and it is logged at error level at most
|
|
20
|
+
* once a minute, however many sign-ups it fails.
|
|
21
|
+
*/
|
|
22
|
+
export function vpndetection(options = {}) {
|
|
23
|
+
let logger;
|
|
24
|
+
const warn = options.onWarn ?? ((message) => (logger?.warn ?? console.warn)(message));
|
|
25
|
+
const error = options.onError ?? ((message) => (logger?.error ?? console.error)(message));
|
|
26
|
+
const client = options.client ?? new VPNDetection({
|
|
27
|
+
apiKey: options.apiKey,
|
|
28
|
+
baseUrl: options.baseUrl,
|
|
29
|
+
cache: options.cache,
|
|
30
|
+
fetch: named((input, init) => globalThis.fetch(input, init)),
|
|
31
|
+
});
|
|
32
|
+
const core = createCore({ ...options, client: client, onWarn: warn, onError: error }, defaultIpSelector, selectors.userAgentSelector);
|
|
33
|
+
const matches = pathMatcher(options.paths ?? DEFAULT_PATHS);
|
|
34
|
+
const message = options.message ?? 'Access from this network is not allowed.';
|
|
35
|
+
return {
|
|
36
|
+
id: 'vpndetection',
|
|
37
|
+
init: (ctx) => {
|
|
38
|
+
logger = {
|
|
39
|
+
warn: (text) => ctx.logger.warn(text),
|
|
40
|
+
error: (text) => ctx.logger.error(text),
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
hooks: {
|
|
44
|
+
before: [{
|
|
45
|
+
matcher: (ctx) => ctx.path !== undefined && matches(ctx.path),
|
|
46
|
+
handler: createAuthMiddleware(async (ctx) => {
|
|
47
|
+
const request = {
|
|
48
|
+
path: ctx.path ?? '',
|
|
49
|
+
headers: ctx.headers,
|
|
50
|
+
request: ctx.request,
|
|
51
|
+
options: ctx.context.options,
|
|
52
|
+
};
|
|
53
|
+
const lookup = await core.evaluate(request);
|
|
54
|
+
if (lookup === undefined) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
// A spent quota and a capped answer are logged by the core, at error level once a minute;
|
|
58
|
+
// any other failure here, on each request.
|
|
59
|
+
if (lookup.error !== undefined && lookup.error.kind !== 'quota_exceeded') {
|
|
60
|
+
warn(`vpndetection: lookup of ${lookup.ip ?? 'no address'} for ${request.path} failed, `
|
|
61
|
+
+ `${lookup.blocked ? 'refused (failClosed)' : 'let through'}: ${lookup.error.message}`);
|
|
62
|
+
}
|
|
63
|
+
await options.onLookup?.(lookup, request);
|
|
64
|
+
if (lookup.blocked) {
|
|
65
|
+
throw APIError.from('FORBIDDEN', { message: message, code: BLOCKED_CODE });
|
|
66
|
+
}
|
|
67
|
+
}),
|
|
68
|
+
}],
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const view = (request) => ({
|
|
73
|
+
header: (name) => (request.headers ?? request.request?.headers)?.get(name) ?? undefined,
|
|
74
|
+
frameworkIp: () => getIP(request.request ?? request.headers ?? new Headers(), request.options) ?? undefined,
|
|
75
|
+
});
|
|
76
|
+
const selectors = bindSelectors(view);
|
|
77
|
+
/**
|
|
78
|
+
* The address Better Auth itself resolves, as its rate limiter does: the headers named in
|
|
79
|
+
* `advanced.ipAddress.ipAddressHeaders` (`X-Forwarded-For` by default), walked past
|
|
80
|
+
* `advanced.ipAddress.trustedProxies`. With no trusted proxy set, Better Auth takes `X-Forwarded-For` only
|
|
81
|
+
* when it holds one address, and with `disableIpTracking` it resolves none, which leaves every request
|
|
82
|
+
* unchecked with a warning. Set those options for your edge, or pick another selector.
|
|
83
|
+
*/
|
|
84
|
+
export const defaultIpSelector = selectors.defaultIpSelector;
|
|
85
|
+
/**
|
|
86
|
+
* An address from `X-Forwarded-For`.
|
|
87
|
+
*
|
|
88
|
+
* **The left-most entry is whatever the caller sent**, since proxies append, so this is only trustworthy
|
|
89
|
+
* when an edge you control overwrites the header. When you know how many proxies sit in front, count from
|
|
90
|
+
* the right instead: `xffIpSelector({ depth: 1 })` is the address your nearest proxy saw.
|
|
91
|
+
*/
|
|
92
|
+
export const xffIpSelector = selectors.xffIpSelector;
|
|
93
|
+
/**
|
|
94
|
+
* An address from a single-value header your edge writes: `headerIpSelector('CF-Connecting-IP')` behind
|
|
95
|
+
* Cloudflare, `headerIpSelector('True-Client-IP')` behind Akamai. Falls back to Better Auth's own address
|
|
96
|
+
* when the header is absent.
|
|
97
|
+
*/
|
|
98
|
+
export const headerIpSelector = selectors.headerIpSelector;
|
|
99
|
+
function pathMatcher(paths) {
|
|
100
|
+
for (const p of paths) {
|
|
101
|
+
if (typeof p !== 'string' || !p.startsWith('/')) {
|
|
102
|
+
throw new Error(`vpndetection: each of paths must start with "/", got ${JSON.stringify(p)}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const exact = new Set(paths.filter((p) => !p.endsWith('*')));
|
|
106
|
+
const prefixes = paths.filter((p) => p.endsWith('*')).map((p) => p.slice(0, -1));
|
|
107
|
+
return (path) => exact.has(path) || prefixes.some((prefix) => path.startsWith(prefix));
|
|
108
|
+
}
|
|
109
|
+
// Names this plugin before the SDK in every lookup's User-Agent, as the SDK leaves room for.
|
|
110
|
+
function named(inner) {
|
|
111
|
+
return (input, init) => {
|
|
112
|
+
const request = new Request(input, init);
|
|
113
|
+
const sdk = request.headers.get('User-Agent');
|
|
114
|
+
request.headers.set('User-Agent', sdk === null ? USER_AGENT : `${USER_AGENT} ${sdk}`);
|
|
115
|
+
return inner(request);
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,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AO,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACnB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACzC,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAC9C,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,IAAI,GAAG,EAAE,CAAC,CAAC;QACtF,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC;IAC1B,CAAC,CAAC;AACN,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vpndetection-better-auth",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Official Better Auth plugin for the VPNDetection API. Check each sign-up for VPN, proxy, Tor and hosting addresses, and refuse the ones you choose.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://vpndetection.io",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/vpndetection-io/sdk-nodejs-better-auth.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/vpndetection-io/sdk-nodejs-better-auth/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"better-auth",
|
|
17
|
+
"better-auth-plugin",
|
|
18
|
+
"authentication",
|
|
19
|
+
"sign-up",
|
|
20
|
+
"vpn",
|
|
21
|
+
"vpn-detection",
|
|
22
|
+
"proxy-detection",
|
|
23
|
+
"tor",
|
|
24
|
+
"ip-intelligence",
|
|
25
|
+
"fraud-prevention",
|
|
26
|
+
"hosting"
|
|
27
|
+
],
|
|
28
|
+
"main": "./dist/index.js",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"default": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./package.json": "./package.json"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"README.md",
|
|
40
|
+
"LICENSE"
|
|
41
|
+
],
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=22"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"vpndetection": "^6.1.0"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"better-auth": ">=1.7"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@mslmio/eslint-config": "^1.1.0",
|
|
53
|
+
"@types/node": "^26.2.0",
|
|
54
|
+
"better-auth": "1.7.28",
|
|
55
|
+
"eslint": "^10.10.0",
|
|
56
|
+
"typescript": "^6.0.3"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "rm -rf dist && tsc",
|
|
60
|
+
"lint": "eslint",
|
|
61
|
+
"test": "pnpm run build && node --test test/*.test.mjs"
|
|
62
|
+
}
|
|
6
63
|
}
|