@visitorquery/react 0.0.3

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/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # @visitorquery/react
2
+
3
+ Use this package to prevent fraud and abuse by visitors hiding behind proxies and VPNs. With a simple call to `useVisitorQuery` your website or app will be making a request to our servers which will respond with a boolean value indicating wether the current user is behind a proxy or VPN. 99.999% of the fraud online is done by individuals hiding behind proxies and VPNs.
4
+
5
+ Our checks are not list based like other services who iterate over a database of known proxy IP addresses. We are using deep packet inspection to detect, in real time, such traffic which is why the api call must be originating from the client's device/browser.
6
+
7
+ This plugin requires a valid api key (Public api key). To obtain one please visit our website at [visitorquery.com](https://visitorquery.com) and pick a suitable plan.
8
+
9
+ Example usage on our own website (nextjs), on the checkout page, before openning the payment dialog:
10
+
11
+ ```typescript
12
+ import {useVisitorQuery} from "@visitorquery/react";
13
+
14
+ export default function CheckoutComponent() {
15
+ const visitorQuery = useVisitorQuery(
16
+ // use your project's PUBLIC api key here
17
+ process.env.NEXT_PUBLIC_VISITOR_QUERY_API_KEY!,
18
+ );
19
+
20
+ useEffect(() => {
21
+ if (visitorQuery.is === true && visitorQuery.confidence > 0.6) {
22
+ // decide what to do with the visitor
23
+ return;
24
+ }
25
+ }, [visitorQuery]);
26
+
27
+ return (
28
+ <div>
29
+ {visitorQuery.is &&(
30
+ <p>You are behind a proxy</p>
31
+ )}
32
+ </div>
33
+ )
34
+ }
35
+ ```
@@ -0,0 +1,5 @@
1
+ export type TResponse = {
2
+ is: boolean;
3
+ confidence: number;
4
+ };
5
+ export declare function useVisitorQuery(publicApiKey: string, endpoint?: string): TResponse;
package/dist/index.js ADDED
@@ -0,0 +1,26 @@
1
+ // src/index.ts
2
+ import { useState, useEffect } from "react";
3
+ function useVisitorQuery(publicApiKey, endpoint = "https://main.check.visitorquery.com/") {
4
+ const [visitorQuery, setVisitorQuery] = useState({
5
+ is: false,
6
+ confidence: 0
7
+ });
8
+ useEffect(() => {
9
+ const fetchData = async () => {
10
+ try {
11
+ const response = await fetch(endpoint, {
12
+ headers: { "X-Api-Key": publicApiKey }
13
+ });
14
+ const data = await response.json();
15
+ setVisitorQuery(data);
16
+ } catch (error) {
17
+ console.error(`Error fetching visitorquery data: ${error}`);
18
+ }
19
+ };
20
+ fetchData().catch(console.error);
21
+ }, [publicApiKey, endpoint]);
22
+ return visitorQuery;
23
+ }
24
+ export {
25
+ useVisitorQuery
26
+ };
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "version": "0.0.3",
3
+ "name": "@visitorquery/react",
4
+ "module": "src/index.ts",
5
+ "type": "module",
6
+ "devDependencies": {
7
+ "@types/bun": "latest"
8
+ },
9
+ "access": "public",
10
+ "main": "dist/index.js",
11
+ "types": "dist/index.d.ts",
12
+ "scripts": {
13
+ "build": "bun build --target=node ./src/index.ts --outfile=dist/index.js --external react --external react-dom && bun run build:declaration",
14
+ "build:declaration": "tsc --emitDeclarationOnly --project tsconfig.types.json",
15
+ "postbuild": "rimraf tsconfig.types.tsbuildinfo",
16
+ "release": "git fetch --tags -f && standard-version && git push --follow-tags origin master",
17
+ "publish": "npm publish --access public"
18
+ },
19
+ "peerDependencies": {
20
+ "@types/react": "^19.0.10",
21
+ "react": "^19.0.0",
22
+ "react-dom": "^19.0.0",
23
+ "typescript": "^5.0.0"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/visitorquery/react-hook.git"
28
+ },
29
+ "keywords": [
30
+ "fraud",
31
+ "antifraud",
32
+ "chargeback",
33
+ "proxy",
34
+ "visitorquery",
35
+ "vpn",
36
+ "detect"
37
+ ],
38
+ "author": "VisitorQuery",
39
+ "license": "MIT",
40
+ "files": [
41
+ "dist/*.js",
42
+ "dist/*.d.ts"
43
+ ]
44
+ }