@veqen/sdk 0.0.0-stage → 0.1.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 +21 -2
- package/package.json +26 -4
- package/src/index.d.ts +134 -0
- package/src/index.js +118 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Keyveve, Inc.
|
|
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,22 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @veqen/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Official JavaScript/TypeScript client for [Veqen](https://veqen-app.com). Catch disposable emails, typos, datacenter and Tor IPs, and VoIP numbers with one call. Zero dependencies; runs on Node 20+ and server runtimes with fetch and crypto.randomUUID. Keep API keys out of browser code.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install https://veqen-app.com/static/sdk/veqen-sdk-0.1.0.tgz
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```javascript
|
|
10
|
+
import { Veqen } from "@veqen/sdk";
|
|
11
|
+
|
|
12
|
+
const veqen = new Veqen(); // reads VEQEN_API_KEY
|
|
13
|
+
const { risk } = await veqen.signup({ email: "jane@mailinator.com", ip: "185.220.101.1" });
|
|
14
|
+
|
|
15
|
+
if (risk.verdict === "refuse") {
|
|
16
|
+
// block, or ask for a different email
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Methods: `email()`, `emails()`, `ip()`, `phone()`, `domain()`, `signup()`, `account()`, `usage()`. Errors throw `VeqenError` with `.status`, `.type` and `.requestId`. 429 and 5xx responses are retried automatically.
|
|
21
|
+
|
|
22
|
+
Docs: https://veqen-app.com/docs
|
package/package.json
CHANGED
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veqen/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Official client for the Veqen signup-check API: disposable emails, datacenter IPs, VoIP numbers and more.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/index.js",
|
|
7
|
+
"types": "./src/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./src/index.d.ts",
|
|
11
|
+
"default": "./src/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": ["src"],
|
|
15
|
+
"engines": { "node": ">=20" },
|
|
16
|
+
"scripts": {
|
|
17
|
+
"test": "node --test"
|
|
18
|
+
},
|
|
19
|
+
"keywords": ["email validation", "disposable email", "fraud", "signup", "ip lookup", "phone validation", "vpn detection", "mcp"],
|
|
20
|
+
"homepage": "https://veqen-app.com/docs/sdks",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/Keyveve/veqen-sdks.git",
|
|
24
|
+
"directory": "js"
|
|
25
|
+
},
|
|
26
|
+
"bugs": { "url": "https://github.com/Keyveve/veqen-sdks/issues" },
|
|
27
|
+
"license": "MIT"
|
|
28
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
export type Verdict = "admit" | "review" | "refuse";
|
|
2
|
+
|
|
3
|
+
export interface Reason {
|
|
4
|
+
code: string;
|
|
5
|
+
impact: number;
|
|
6
|
+
message: string;
|
|
7
|
+
source?: "email" | "ip" | "phone" | "signup" | null;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface Risk {
|
|
11
|
+
score: number;
|
|
12
|
+
level: "low" | "medium" | "high";
|
|
13
|
+
verdict: Verdict;
|
|
14
|
+
reasons: Reason[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface DomainInfo {
|
|
18
|
+
exists: boolean;
|
|
19
|
+
accepts_mail: boolean | null;
|
|
20
|
+
mx: string[];
|
|
21
|
+
null_mx: boolean;
|
|
22
|
+
spf: boolean;
|
|
23
|
+
dmarc: boolean;
|
|
24
|
+
registered_at: string | null;
|
|
25
|
+
age_days: number | null;
|
|
26
|
+
registrar: string | null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface EmailCheck {
|
|
30
|
+
email: string;
|
|
31
|
+
valid_syntax: boolean;
|
|
32
|
+
syntax_error?: string | null;
|
|
33
|
+
normalized?: string | null;
|
|
34
|
+
canonical?: string | null;
|
|
35
|
+
local_part?: string | null;
|
|
36
|
+
domain?: string | null;
|
|
37
|
+
disposable?: boolean | null;
|
|
38
|
+
free_provider?: boolean | null;
|
|
39
|
+
role_account?: boolean | null;
|
|
40
|
+
plus_addressed?: boolean | null;
|
|
41
|
+
did_you_mean?: string | null;
|
|
42
|
+
domain_info?: DomainInfo | null;
|
|
43
|
+
mailbox?: { checked: boolean; result: "deliverable" | "undeliverable" | "catch_all" | "unknown"; smtp_code?: number | null; reason?: string | null } | null;
|
|
44
|
+
risk: Risk;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface IpCheck {
|
|
48
|
+
ip: string;
|
|
49
|
+
valid: boolean;
|
|
50
|
+
version?: number | null;
|
|
51
|
+
type?: "public" | "private" | "loopback" | "link_local" | "multicast" | "reserved" | "special" | null;
|
|
52
|
+
location?: {
|
|
53
|
+
country_code: string | null;
|
|
54
|
+
country: string | null;
|
|
55
|
+
in_eu: boolean | null;
|
|
56
|
+
region: string | null;
|
|
57
|
+
city: string | null;
|
|
58
|
+
continent: string | null;
|
|
59
|
+
latitude: number | null;
|
|
60
|
+
longitude: number | null;
|
|
61
|
+
} | null;
|
|
62
|
+
network?: {
|
|
63
|
+
asn: number | null;
|
|
64
|
+
organization: string | null;
|
|
65
|
+
kind: "cloud" | "hosting" | "cdn" | "vpn_hosting" | "isp" | "unknown";
|
|
66
|
+
kind_label: string;
|
|
67
|
+
known_network: string | null;
|
|
68
|
+
} | null;
|
|
69
|
+
flags?: { hosting: boolean; vpn_likely: boolean; relay: boolean; tor: boolean } | null;
|
|
70
|
+
risk: Risk;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface PhoneCheck {
|
|
74
|
+
input: string;
|
|
75
|
+
valid: boolean;
|
|
76
|
+
possible: boolean;
|
|
77
|
+
error?: string | null;
|
|
78
|
+
e164?: string | null;
|
|
79
|
+
international?: string | null;
|
|
80
|
+
national?: string | null;
|
|
81
|
+
calling_code?: number | null;
|
|
82
|
+
country_code?: string | null;
|
|
83
|
+
country?: string | null;
|
|
84
|
+
location?: string | null;
|
|
85
|
+
line_type?: string | null;
|
|
86
|
+
line_type_label?: string | null;
|
|
87
|
+
carrier?: string | null;
|
|
88
|
+
time_zones: string[];
|
|
89
|
+
risk: Risk;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface DomainCheck extends Partial<DomainInfo> {
|
|
93
|
+
input: string;
|
|
94
|
+
valid: boolean;
|
|
95
|
+
domain?: string | null;
|
|
96
|
+
disposable?: boolean | null;
|
|
97
|
+
free_provider?: boolean | null;
|
|
98
|
+
risk: Risk;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface SignupCheck {
|
|
102
|
+
email: EmailCheck | null;
|
|
103
|
+
ip: IpCheck | null;
|
|
104
|
+
phone: PhoneCheck | null;
|
|
105
|
+
risk: Risk;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface VeqenOptions {
|
|
109
|
+
apiKey?: string;
|
|
110
|
+
baseUrl?: string;
|
|
111
|
+
timeoutMs?: number;
|
|
112
|
+
maxRetries?: number;
|
|
113
|
+
fetch?: typeof fetch;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export class VeqenError extends Error {
|
|
117
|
+
status: number;
|
|
118
|
+
type: string;
|
|
119
|
+
requestId: string | null;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export class Veqen {
|
|
123
|
+
constructor(options?: VeqenOptions);
|
|
124
|
+
email(email: string, options?: { verifyMailbox?: boolean; idempotencyKey?: string }): Promise<EmailCheck>;
|
|
125
|
+
emails(emails: string[], options?: { verifyMailbox?: boolean }): Promise<EmailCheck[]>;
|
|
126
|
+
ip(ip: string, options?: { idempotencyKey?: string }): Promise<IpCheck>;
|
|
127
|
+
phone(phone: string, options?: { country?: string; idempotencyKey?: string }): Promise<PhoneCheck>;
|
|
128
|
+
domain(domain: string, options?: { idempotencyKey?: string }): Promise<DomainCheck>;
|
|
129
|
+
signup(input: { email?: string; ip?: string; phone?: string; phoneCountry?: string; verifyMailbox?: boolean; idempotencyKey?: string }): Promise<SignupCheck>;
|
|
130
|
+
account(): Promise<{ email: string; balance: { free: number; paid: number; total: number }; free_monthly_credits: number; free_resets_at: string; costs: Record<string, number>; rate_limit_per_second: number }>;
|
|
131
|
+
usage(days?: number): Promise<{ days: { date: string; credits: number; calls: number; by_check: Record<string, number> }[]; total_credits: number; total_calls: number }>;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export default Veqen;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// Official JavaScript/TypeScript client for the Veqen signup-check API. Works anywhere `fetch` exists.
|
|
2
|
+
|
|
3
|
+
const DEFAULT_BASE_URL = "https://veqen-app.com";
|
|
4
|
+
const RETRY_STATUSES = new Set([429, 500, 502, 503, 504]);
|
|
5
|
+
const VERSION = "0.1.0";
|
|
6
|
+
|
|
7
|
+
export class VeqenError extends Error {
|
|
8
|
+
constructor(status, type, message, requestId) {
|
|
9
|
+
super(`${status} ${type}: ${message}`);
|
|
10
|
+
this.name = "VeqenError";
|
|
11
|
+
this.status = status;
|
|
12
|
+
this.type = type;
|
|
13
|
+
this.requestId = requestId;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
18
|
+
const env = (name) => (typeof process !== "undefined" && process.env ? process.env[name] : undefined);
|
|
19
|
+
|
|
20
|
+
export class Veqen {
|
|
21
|
+
constructor(options = {}) {
|
|
22
|
+
this.apiKey = options.apiKey ?? env("VEQEN_API_KEY");
|
|
23
|
+
if (!this.apiKey) throw new Error("Pass { apiKey } or set VEQEN_API_KEY.");
|
|
24
|
+
this.baseUrl = (options.baseUrl ?? env("VEQEN_BASE_URL") ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
25
|
+
this.timeoutMs = options.timeoutMs ?? 10000;
|
|
26
|
+
this.maxRetries = options.maxRetries ?? 2;
|
|
27
|
+
this.fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
email(email, { verifyMailbox = false, idempotencyKey } = {}) {
|
|
31
|
+
return this.#post("/v1/email/check", { email, verify_mailbox: verifyMailbox }, idempotencyKey);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async emails(emails, { verifyMailbox = false } = {}) {
|
|
35
|
+
const results = [];
|
|
36
|
+
for (let start = 0; start < emails.length; start += 100) {
|
|
37
|
+
const chunk = emails.slice(start, start + 100);
|
|
38
|
+
const data = await this.#post("/v1/email/batch", { emails: chunk, verify_mailbox: verifyMailbox });
|
|
39
|
+
results.push(...data.results);
|
|
40
|
+
}
|
|
41
|
+
return results;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
ip(ip, { idempotencyKey } = {}) {
|
|
45
|
+
return this.#post("/v1/ip/check", { ip }, idempotencyKey);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
phone(phone, { country, idempotencyKey } = {}) {
|
|
49
|
+
return this.#post("/v1/phone/check", { phone, country }, idempotencyKey);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
domain(domain, { idempotencyKey } = {}) {
|
|
53
|
+
return this.#post("/v1/domain/check", { domain }, idempotencyKey);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
signup({ email, ip, phone, phoneCountry, verifyMailbox = false, idempotencyKey } = {}) {
|
|
57
|
+
const body = { email, ip, phone, phone_country: phoneCountry, verify_mailbox: verifyMailbox };
|
|
58
|
+
for (const key of Object.keys(body)) if (body[key] === undefined || body[key] === null || body[key] === "") delete body[key];
|
|
59
|
+
return this.#post("/v1/signup/check", body, idempotencyKey);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
account() {
|
|
63
|
+
return this.#request("GET", "/v1/account");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
usage(days = 30) {
|
|
67
|
+
return this.#request("GET", `/v1/usage?days=${encodeURIComponent(days)}`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
#post(path, body, idempotencyKey) {
|
|
71
|
+
// One key per logical call, shared by all retries to prevent double charging.
|
|
72
|
+
return this.#request("POST", path, body, idempotencyKey ?? globalThis.crypto.randomUUID());
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async #request(method, path, body, idempotencyKey) {
|
|
76
|
+
const headers = {
|
|
77
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
78
|
+
Accept: "application/json",
|
|
79
|
+
"User-Agent": `veqen-js/${VERSION}`,
|
|
80
|
+
};
|
|
81
|
+
if (body !== undefined) headers["Content-Type"] = "application/json";
|
|
82
|
+
if (idempotencyKey) headers["Idempotency-Key"] = idempotencyKey;
|
|
83
|
+
|
|
84
|
+
for (let attempt = 0; ; attempt += 1) {
|
|
85
|
+
let response;
|
|
86
|
+
try {
|
|
87
|
+
response = await this.fetch(`${this.baseUrl}${path}`, {
|
|
88
|
+
method,
|
|
89
|
+
headers,
|
|
90
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
91
|
+
signal: AbortSignal.timeout(this.timeoutMs),
|
|
92
|
+
});
|
|
93
|
+
} catch (error) {
|
|
94
|
+
if (attempt >= this.maxRetries) throw error;
|
|
95
|
+
await sleep(Math.min(250 * 2 ** (attempt + 1), 4000));
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (RETRY_STATUSES.has(response.status) && attempt < this.maxRetries) {
|
|
99
|
+
const retryAfter = Number(response.headers.get("Retry-After"));
|
|
100
|
+
await sleep(retryAfter > 0 ? retryAfter * 1000 : Math.min(250 * 2 ** (attempt + 1), 4000));
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
let data = null;
|
|
104
|
+
try {
|
|
105
|
+
data = await response.json();
|
|
106
|
+
} catch {
|
|
107
|
+
data = null;
|
|
108
|
+
}
|
|
109
|
+
if (!response.ok) {
|
|
110
|
+
const error = (data && data.error) || {};
|
|
111
|
+
throw new VeqenError(response.status, error.type || "http_error", error.message || response.statusText, response.headers.get("X-Request-Id"));
|
|
112
|
+
}
|
|
113
|
+
return data;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export default Veqen;
|