@isvalid-dev/sdk 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 +175 -0
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +808 -0
- package/dist/index.d.ts +808 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/package.json +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 isvalid.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
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# @isvalid-dev/sdk
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for the [isvalid.dev](https://isvalid.dev) validation API.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Zero dependencies** — native `fetch` only (Node 18+, browsers)
|
|
8
|
+
- **Full TypeScript types** for every endpoint response
|
|
9
|
+
- **ESM + CJS** dual export
|
|
10
|
+
- **Tiny** — ~1.5 KB minified + brotli
|
|
11
|
+
- **Automatic retry** with exponential backoff for 429/5xx
|
|
12
|
+
- **Custom error classes** for auth and rate limit errors
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @isvalid-dev/sdk
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { createClient } from '@isvalid-dev/sdk';
|
|
24
|
+
|
|
25
|
+
const iv = createClient({ apiKey: 'your-api-key' });
|
|
26
|
+
|
|
27
|
+
// Simple validation
|
|
28
|
+
const email = await iv.email('user@example.com', { checkMx: true });
|
|
29
|
+
// => { valid: true, local: 'user', domain: 'example.com', mxValid: true }
|
|
30
|
+
|
|
31
|
+
const iban = await iv.iban('DE89370400440532013000');
|
|
32
|
+
// => { valid: true, countryCode: 'DE', bankName: 'Commerzbank', ... }
|
|
33
|
+
|
|
34
|
+
const vat = await iv.vat('DE123456789', { checkVies: true });
|
|
35
|
+
// => { valid: true, countryCode: 'DE', isEU: true, vies: { checked: true, valid: true, ... } }
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Namespaced Methods
|
|
39
|
+
|
|
40
|
+
Some endpoints support callable + property access pattern:
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
// LEI
|
|
44
|
+
const lei = await iv.lei('5493001KJTIIGC8Y1R12');
|
|
45
|
+
const search = await iv.lei.search('Apple', { country: 'US', limit: 5 });
|
|
46
|
+
const lous = await iv.lei.lous();
|
|
47
|
+
|
|
48
|
+
// Country / Currency / Language
|
|
49
|
+
const country = await iv.country('PL');
|
|
50
|
+
const countries = await iv.country.list();
|
|
51
|
+
|
|
52
|
+
const currency = await iv.currency('USD');
|
|
53
|
+
const currencies = await iv.currency.list();
|
|
54
|
+
|
|
55
|
+
const language = await iv.language('en');
|
|
56
|
+
const languages = await iv.language.list();
|
|
57
|
+
|
|
58
|
+
// IATA
|
|
59
|
+
const flight = await iv.iata.flight('LH1234');
|
|
60
|
+
const airline = await iv.iata.airline('LH');
|
|
61
|
+
const airlines = await iv.iata.airline.list();
|
|
62
|
+
const airport = await iv.iata.airport('WAW');
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Country-Specific Endpoints
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
// Poland
|
|
69
|
+
await iv.pl.pesel('44051401358');
|
|
70
|
+
await iv.pl.regon('012345678', { lookup: true });
|
|
71
|
+
await iv.pl.krs('0000123456', { lookup: true });
|
|
72
|
+
|
|
73
|
+
// Brazil
|
|
74
|
+
await iv.br.cnpj('11.222.333/0001-81');
|
|
75
|
+
await iv.br.cpf('123.456.789-09');
|
|
76
|
+
|
|
77
|
+
// Other
|
|
78
|
+
await iv.au.abn('51824753556');
|
|
79
|
+
await iv.es.nif('12345678Z');
|
|
80
|
+
await iv.in.gstin('27AAPFU0939F1ZV');
|
|
81
|
+
await iv.us.npi('1234567893');
|
|
82
|
+
await iv.gb.sortCode('12-34-56');
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Network & Financial
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
// Network
|
|
89
|
+
await iv.net.ip('192.168.1.1');
|
|
90
|
+
await iv.net.mac('00:1B:44:11:3A:B7');
|
|
91
|
+
|
|
92
|
+
// Financial
|
|
93
|
+
await iv.isin('US0378331005');
|
|
94
|
+
await iv.dti('B1234567Z');
|
|
95
|
+
await iv.bic('DEUTDEFF');
|
|
96
|
+
await iv.cusip('037833100');
|
|
97
|
+
await iv.creditCard('4111111111111111'); // POST endpoint
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## All Simple Endpoints
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
iv.email(value, opts?) iv.iban(value, opts?) iv.isin(value)
|
|
104
|
+
iv.dti(value) iv.vat(value, opts?) iv.gps(value)
|
|
105
|
+
iv.phone(value, opts?) iv.url(value) iv.ean(value)
|
|
106
|
+
iv.isbn(value) iv.issn(value) iv.bic(value)
|
|
107
|
+
iv.cusip(value) iv.cfi(value) iv.mic(value)
|
|
108
|
+
iv.nuts(value) iv.uuid(value, opts?) iv.jwt(value)
|
|
109
|
+
iv.vin(value) iv.imei(value) iv.semver(value)
|
|
110
|
+
iv.color(value) iv.boolean(value) iv.date(value, opts?)
|
|
111
|
+
iv.btcAddress(value) iv.postalCode(value, opts?)
|
|
112
|
+
iv.aba(value) iv.iso6346(value) iv.sscc(value)
|
|
113
|
+
iv.gln(value) iv.qr(value) iv.creditCard(number)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## Configuration
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
const iv = createClient({
|
|
120
|
+
apiKey: 'your-api-key',
|
|
121
|
+
baseUrl: 'https://api.isvalid.dev', // default
|
|
122
|
+
timeout: 15000, // default: 10000 (10s)
|
|
123
|
+
retry: {
|
|
124
|
+
maxRetries: 5, // default: 3
|
|
125
|
+
initialDelayMs: 1000, // default: 500
|
|
126
|
+
maxDelayMs: 30000, // default: 10000
|
|
127
|
+
retryOn: [429, 500, 502, 503], // default
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// Disable retry
|
|
132
|
+
const iv = createClient({ apiKey: '...', retry: false });
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Error Handling
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
import { IsValidError, IsValidAuthError, IsValidRateLimitError } from '@isvalid-dev/sdk';
|
|
139
|
+
|
|
140
|
+
try {
|
|
141
|
+
await iv.email('test@example.com');
|
|
142
|
+
} catch (err) {
|
|
143
|
+
if (err instanceof IsValidRateLimitError) {
|
|
144
|
+
console.log('Rate limited, retry after:', err.retryAfter, 'seconds');
|
|
145
|
+
} else if (err instanceof IsValidAuthError) {
|
|
146
|
+
console.log('Invalid API key');
|
|
147
|
+
} else if (err instanceof IsValidError) {
|
|
148
|
+
console.log('API error:', err.status, err.body.error);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Type Safety
|
|
154
|
+
|
|
155
|
+
All responses are discriminated unions based on `valid`:
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
const result = await iv.iban('PL61109010140000071219812874');
|
|
159
|
+
|
|
160
|
+
if (result.valid) {
|
|
161
|
+
// TypeScript knows all fields are available
|
|
162
|
+
console.log(result.countryCode); // 'PL'
|
|
163
|
+
console.log(result.bankName); // string | null
|
|
164
|
+
} else {
|
|
165
|
+
// result is { valid: false }
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## API Reference
|
|
170
|
+
|
|
171
|
+
Full endpoint documentation: [isvalid.dev/docs](https://isvalid.dev/docs)
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
MIT
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
'use strict';var i=class extends Error{constructor(e,s){super(s.error),this.name="IsValidError",this.status=e,this.body=s;}},c=class extends i{constructor(e){super(401,e),this.name="IsValidAuthError";}},m=class extends i{constructor(e,s=null){super(429,e),this.name="IsValidRateLimitError",this.retryAfter=s;}};var H="https://api.isvalid.dev",S=1e4,l={maxRetries:3,initialDelayMs:500,maxDelayMs:1e4,retryOn:[429,500,502,503]};function E(t){return t===false?false:t?{maxRetries:t.maxRetries??l.maxRetries,initialDelayMs:t.initialDelayMs??l.initialDelayMs,maxDelayMs:t.maxDelayMs??l.maxDelayMs,retryOn:t.retryOn??l.retryOn}:l}function M(t){return new Promise(e=>setTimeout(e,t))}function U(t,e,s){let r=e*2**t,o=Math.random()*e;return Math.min(r+o,s)}var u=class{constructor(e){this.baseUrl=(e.baseUrl??H).replace(/\/+$/,""),this.apiKey=e.apiKey,this.retry=E(e.retry),this.timeout=e.timeout??S;}async get(e,s){let r=this.buildUrl(e,s);return this.request(r,{method:"GET"})}async post(e,s){let r=this.buildUrl(e);return this.request(r,{method:"POST",body:JSON.stringify(s),headers:{"Content-Type":"application/json"}})}buildUrl(e,s){let r=new URL(e,this.baseUrl);if(s)for(let[o,a]of Object.entries(s))a!==void 0&&r.searchParams.set(o,a);return r.toString()}async request(e,s){let r={Authorization:`Bearer ${this.apiKey}`,Accept:"application/json",...s.headers},o=this.retry?this.retry.maxRetries+1:1;for(let a=0;a<o;a++){let n=await fetch(e,{...s,headers:r,signal:AbortSignal.timeout(this.timeout)});if(n.ok)return await n.json();if(this.retry&&a<this.retry.maxRetries&&this.retry.retryOn.includes(n.status)){let p=n.headers.get("Retry-After"),A=p?parseInt(p,10)*1e3:U(a,this.retry.initialDelayMs,this.retry.maxDelayMs);await M(A);continue}let g=await n.json().catch(()=>({error:n.statusText}));if(n.status===401)throw new c(g);if(n.status===429){let p=n.headers.get("Retry-After");throw new m(g,p?parseInt(p,10):null)}throw new i(n.status,g)}throw new i(0,{error:"Max retries exceeded"})}};function f(t){let e=(s=>t.get("/v0/lei",{value:s}));return e.search=(s,r)=>t.get("/v0/lei/search",{q:s,country:r?.country,entityStatus:r?.entityStatus,page:r?.page?.toString(),limit:r?.limit?.toString()}),e.lous=()=>t.get("/v0/lei/lous"),e}function R(t){let e=(s=>t.get("/v0/country",{value:s}));return e.list=()=>t.get("/v0/country/list"),e}function h(t){let e=(s=>t.get("/v0/currency",{value:s}));return e.list=()=>t.get("/v0/currency/list"),e}function d(t){let e=(s=>t.get("/v0/language",{value:s}));return e.list=()=>t.get("/v0/language/list"),e}function N(t){let e=(s=>t.get("/v0/iata/airline",{value:s}));return e.list=()=>t.get("/v0/iata/airline/list"),{flight:s=>t.get("/v0/iata/flight",{value:s}),airline:e,airport:s=>t.get("/v0/iata/airport",{value:s})}}function C(t){return {ip:e=>t.get("/v0/net/ip",{value:e}),mac:e=>t.get("/v0/net/mac",{value:e})}}function v(t){return {pesel:e=>t.get("/v0/pl/pesel",{value:e}),regon:(e,s)=>t.get("/v0/pl/regon",{value:e,lookup:s?.lookup?.toString()}),krs:(e,s)=>t.get("/v0/pl/krs",{value:e,lookup:s?.lookup?.toString()})}}function b(t){return {cnpj:e=>t.get("/v0/br/cnpj",{value:e}),cpf:e=>t.get("/v0/br/cpf",{value:e})}}function P(t){return {abn:e=>t.get("/v0/au/abn",{value:e})}}function x(t){return {nif:e=>t.get("/v0/es/nif",{value:e})}}function I(t){return {gstin:e=>t.get("/v0/in/gstin",{value:e})}}function j(t){return {npi:e=>t.get("/v0/us/npi",{value:e})}}function L(t){return {sortCode:e=>t.get("/v0/gb/sort-code",{value:e})}}var y=class{constructor(e){this.client=new u(e),this.lei=f(this.client),this.country=R(this.client),this.currency=h(this.client),this.language=d(this.client),this.iata=N(this.client),this.net=C(this.client),this.pl=v(this.client),this.br=b(this.client),this.au=P(this.client),this.es=x(this.client),this.in=I(this.client),this.us=j(this.client),this.gb=L(this.client);}email(e,s){return this.client.get("/v0/email",{value:e,checkMx:s?.checkMx?.toString()})}iban(e,s){return this.client.get("/v0/iban",{value:e,countryCode:s?.countryCode})}isin(e){return this.client.get("/v0/isin",{value:e})}dti(e){return this.client.get("/v0/dti",{value:e})}vat(e,s){return this.client.get("/v0/vat",{value:e,countryCode:s?.countryCode,checkVies:s?.checkVies?.toString()})}gps(e){return this.client.get("/v0/gps",{value:e})}phone(e,s){return this.client.get("/v0/phone",{value:e,countryCode:s?.countryCode})}url(e){return this.client.get("/v0/url",{value:e})}ean(e){return this.client.get("/v0/ean",{value:e})}isbn(e){return this.client.get("/v0/isbn",{value:e})}issn(e){return this.client.get("/v0/issn",{value:e})}bic(e){return this.client.get("/v0/bic",{value:e})}cusip(e){return this.client.get("/v0/cusip",{value:e})}cfi(e){return this.client.get("/v0/cfi",{value:e})}mic(e){return this.client.get("/v0/mic",{value:e})}nuts(e){return this.client.get("/v0/nuts",{value:e})}uuid(e,s){return this.client.get("/v0/uuid",{value:e,version:s?.version?.toString()})}jwt(e){return this.client.get("/v0/jwt",{value:e})}vin(e){return this.client.get("/v0/vin",{value:e})}imei(e){return this.client.get("/v0/imei",{value:e})}semver(e){return this.client.get("/v0/semver",{value:e})}color(e){return this.client.get("/v0/color",{value:e})}boolean(e){return this.client.get("/v0/boolean",{value:e})}date(e,s){return this.client.get("/v0/date",{value:e,format:s?.format})}btcAddress(e){return this.client.get("/v0/btc-address",{value:e})}postalCode(e,s){return this.client.get("/v0/postal-code",{value:e,countryCode:s?.countryCode})}aba(e){return this.client.get("/v0/aba",{value:e})}iso6346(e){return this.client.get("/v0/iso6346",{value:e})}sscc(e){return this.client.get("/v0/sscc",{value:e})}gln(e){return this.client.get("/v0/gln",{value:e})}qr(e){return this.client.get("/v0/qr",{value:e})}creditCard(e){return this.client.post("/v0/credit-card",{number:e})}};function me(t){return new y(t)}
|
|
2
|
+
exports.IsValid=y;exports.IsValidAuthError=c;exports.IsValidError=i;exports.IsValidRateLimitError=m;exports.createClient=me;//# sourceMappingURL=index.cjs.map
|
|
3
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/client.ts","../src/namespaces/lei.ts","../src/namespaces/country.ts","../src/namespaces/currency.ts","../src/namespaces/language.ts","../src/namespaces/iata.ts","../src/namespaces/net.ts","../src/namespaces/pl.ts","../src/namespaces/br.ts","../src/namespaces/au.ts","../src/namespaces/es.ts","../src/namespaces/in.ts","../src/namespaces/us.ts","../src/namespaces/gb.ts","../src/index.ts"],"names":["IsValidError","status","body","IsValidAuthError","IsValidRateLimitError","retryAfter","DEFAULT_BASE_URL","DEFAULT_TIMEOUT","DEFAULT_RETRY","resolveRetry","cfg","delay","ms","r","backoffDelay","attempt","initial","max","base","jitter","HttpClient","config","path","params","url","k","v","init","headers","maxAttempts","res","retryAfterHeader","retryMs","ra","createLeiNamespace","client","lei","value","query","opts","createCountryNamespace","country","createCurrencyNamespace","currency","createLanguageNamespace","language","createIataNamespace","airline","createNetNamespace","createPlNamespace","createBrNamespace","createAuNamespace","createEsNamespace","createInNamespace","createUsNamespace","createGbNamespace","IsValid","number","createClient"],"mappings":"aAAO,IAAMA,EAAN,cAA2B,KAAM,CAItC,WAAA,CAAYC,CAAAA,CAAgBC,EAAyB,CACnD,KAAA,CAAMA,CAAAA,CAAK,KAAK,EAChB,IAAA,CAAK,IAAA,CAAO,eACZ,IAAA,CAAK,MAAA,CAASD,EACd,IAAA,CAAK,IAAA,CAAOC,EACd,CACF,EAEaC,CAAAA,CAAN,cAA+BH,CAAa,CACjD,WAAA,CAAYE,EAAyB,CACnC,KAAA,CAAM,GAAA,CAAKA,CAAI,EACf,IAAA,CAAK,IAAA,CAAO,mBACd,CACF,CAAA,CAEaE,EAAN,cAAoCJ,CAAa,CAGtD,WAAA,CAAYE,EAAyBG,CAAAA,CAA4B,IAAA,CAAM,CACrE,KAAA,CAAM,GAAA,CAAKH,CAAI,CAAA,CACf,IAAA,CAAK,IAAA,CAAO,uBAAA,CACZ,KAAK,UAAA,CAAaG,EACpB,CACF,ECXA,IAAMC,EAAmB,yBAAA,CACnBC,CAAAA,CAAkB,GAAA,CAClBC,CAAAA,CAAuC,CAC3C,UAAA,CAAY,CAAA,CACZ,eAAgB,GAAA,CAChB,UAAA,CAAY,IACZ,OAAA,CAAS,CAAC,GAAA,CAAK,GAAA,CAAK,IAAK,GAAG,CAC9B,EAEA,SAASC,CAAAA,CAAaC,EAAqE,CACzF,OAAIA,CAAAA,GAAQ,KAAA,CAAc,MACrBA,CAAAA,CACE,CACL,WAAYA,CAAAA,CAAI,UAAA,EAAcF,EAAc,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AC,CACrD,CAEA,WAAWA,CAAAA,CAAeE,CAAAA,CAA8D,CACtF,OAAO,KAAK,MAAA,CAAO,GAAA,CAAI,kBAAmB,CAAE,KAAA,CAAAF,EAAO,WAAA,CAAaE,CAAAA,EAAM,WAAY,CAAC,CACrF,CAEA,GAAA,CAAIF,EAAqC,CACvC,OAAO,KAAK,MAAA,CAAO,GAAA,CAAI,SAAA,CAAW,CAAE,MAAAA,CAAM,CAAC,CAC7C,CAEA,OAAA,CAAQA,EAAyC,CAC/C,OAAO,IAAA,CAAK,MAAA,CAAO,IAAI,aAAA,CAAe,CAAE,MAAAA,CAAM,CAAC,CACjD,CAEA,IAAA,CAAKA,CAAAA,CAAsC,CACzC,OAAO,IAAA,CAAK,MAAA,CAAO,IAAI,UAAA,CAAY,CAAE,MAAAA,CAAM,CAAC,CAC9C,CAEA,IAAIA,CAAAA,CAAqC,CACvC,OAAO,IAAA,CAAK,MAAA,CAAO,IAAI,SAAA,CAAW,CAAE,KAAA,CAAAA,CAAM,CAAC,CAC7C,CAEA,GAAGA,CAAAA,CAAoC,CACrC,OAAO,IAAA,CAAK,MAAA,CAAO,GAAA,CAAI,QAAA,CAAU,CAAE,KAAA,CAAAA,CAAM,CAAC,CAC5C,CAEA,WAAWoB,CAAAA,CAA6C,CACtD,OAAO,IAAA,CAAK,OAAO,IAAA,CAAK,iBAAA,CAAmB,CAAE,MAAA,CAAAA,CAAO,CAAC,CACvD,CACF,EAEO,SAASC,GAAarC,CAAAA,CAAgC,CAC3D,OAAO,IAAImC,CAAAA,CAAQnC,CAAM,CAC3B","file":"index.cjs","sourcesContent":["export class IsValidError extends Error {\n readonly status: number;\n readonly body: { error: string };\n\n constructor(status: number, body: { error: string }) {\n super(body.error);\n this.name = 'IsValidError';\n this.status = status;\n this.body = body;\n }\n}\n\nexport class IsValidAuthError extends IsValidError {\n constructor(body: { error: string }) {\n super(401, body);\n this.name = 'IsValidAuthError';\n }\n}\n\nexport class IsValidRateLimitError extends IsValidError {\n readonly retryAfter: number | null;\n\n constructor(body: { error: string }, retryAfter: number | null = null) {\n super(429, body);\n this.name = 'IsValidRateLimitError';\n this.retryAfter = retryAfter;\n }\n}\n","import { IsValidError, IsValidAuthError, IsValidRateLimitError } from './errors.js';\n\nexport interface RetryConfig {\n maxRetries?: number;\n initialDelayMs?: number;\n maxDelayMs?: number;\n retryOn?: number[];\n}\n\nexport interface IsValidConfig {\n apiKey: string;\n baseUrl?: string;\n timeout?: number;\n retry?: RetryConfig | false;\n}\n\nconst DEFAULT_BASE_URL = 'https://api.isvalid.dev';\nconst DEFAULT_TIMEOUT = 10_000;\nconst DEFAULT_RETRY: Required<RetryConfig> = {\n maxRetries: 3,\n initialDelayMs: 500,\n maxDelayMs: 10_000,\n retryOn: [429, 500, 502, 503],\n};\n\nfunction resolveRetry(cfg: RetryConfig | false | undefined): Required<RetryConfig> | false {\n if (cfg === false) return false;\n if (!cfg) return DEFAULT_RETRY;\n return {\n maxRetries: cfg.maxRetries ?? DEFAULT_RETRY.maxRetries,\n initialDelayMs: cfg.initialDelayMs ?? DEFAULT_RETRY.initialDelayMs,\n maxDelayMs: cfg.maxDelayMs ?? DEFAULT_RETRY.maxDelayMs,\n retryOn: cfg.retryOn ?? DEFAULT_RETRY.retryOn,\n };\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise((r) => setTimeout(r, ms));\n}\n\nfunction backoffDelay(attempt: number, initial: number, max: number): number {\n const base = initial * 2 ** attempt;\n const jitter = Math.random() * initial;\n return Math.min(base + jitter, max);\n}\n\nexport class HttpClient {\n private readonly baseUrl: string;\n private readonly apiKey: string;\n private readonly retry: Required<RetryConfig> | false;\n private readonly timeout: number;\n\n constructor(config: IsValidConfig) {\n this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, '');\n this.apiKey = config.apiKey;\n this.retry = resolveRetry(config.retry);\n this.timeout = config.timeout ?? DEFAULT_TIMEOUT;\n }\n\n async get<T>(path: string, params?: Record<string, string | undefined>): Promise<T> {\n const url = this.buildUrl(path, params);\n return this.request<T>(url, { method: 'GET' });\n }\n\n async post<T>(path: string, body: unknown): Promise<T> {\n const url = this.buildUrl(path);\n return this.request<T>(url, {\n method: 'POST',\n body: JSON.stringify(body),\n headers: { 'Content-Type': 'application/json' },\n });\n }\n\n private buildUrl(path: string, params?: Record<string, string | undefined>): string {\n const url = new URL(path, this.baseUrl);\n if (params) {\n for (const [k, v] of Object.entries(params)) {\n if (v !== undefined) url.searchParams.set(k, v);\n }\n }\n return url.toString();\n }\n\n private async request<T>(url: string, init: RequestInit): Promise<T> {\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.apiKey}`,\n Accept: 'application/json',\n ...(init.headers as Record<string, string> | undefined),\n };\n\n const maxAttempts = this.retry ? this.retry.maxRetries + 1 : 1;\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n const res = await fetch(url, {\n ...init,\n headers,\n signal: AbortSignal.timeout(this.timeout),\n });\n\n if (res.ok) {\n return (await res.json()) as T;\n }\n\n if (this.retry && attempt < this.retry.maxRetries && this.retry.retryOn.includes(res.status)) {\n const retryAfterHeader = res.headers.get('Retry-After');\n const retryMs = retryAfterHeader\n ? parseInt(retryAfterHeader, 10) * 1000\n : backoffDelay(attempt, this.retry.initialDelayMs, this.retry.maxDelayMs);\n await delay(retryMs);\n continue;\n }\n\n const body = await res.json().catch(() => ({ error: res.statusText })) as { error: string };\n\n if (res.status === 401) throw new IsValidAuthError(body);\n if (res.status === 429) {\n const ra = res.headers.get('Retry-After');\n throw new IsValidRateLimitError(body, ra ? parseInt(ra, 10) : null);\n }\n throw new IsValidError(res.status, body);\n }\n\n throw new IsValidError(0, { error: 'Max retries exceeded' });\n }\n}\n","import type { HttpClient } from '../client.js';\nimport type { LeiResponse, LeiSearchOptions, LeiSearchResponse, LeiLousResponse } from '../types/lei.js';\n\nexport interface LeiNamespace {\n (value: string): Promise<LeiResponse>;\n search(query: string, opts?: LeiSearchOptions): Promise<LeiSearchResponse>;\n lous(): Promise<LeiLousResponse>;\n}\n\nexport function createLeiNamespace(client: HttpClient): LeiNamespace {\n const lei = ((value: string) =>\n client.get<LeiResponse>('/v0/lei', { value })\n ) as LeiNamespace;\n\n lei.search = (query: string, opts?: LeiSearchOptions) =>\n client.get<LeiSearchResponse>('/v0/lei/search', {\n q: query,\n country: opts?.country,\n entityStatus: opts?.entityStatus,\n page: opts?.page?.toString(),\n limit: opts?.limit?.toString(),\n });\n\n lei.lous = () => client.get<LeiLousResponse>('/v0/lei/lous');\n\n return lei;\n}\n","import type { HttpClient } from '../client.js';\nimport type { CountryResponse, CountryListItem } from '../types/country.js';\n\nexport interface CountryNamespace {\n (value: string): Promise<CountryResponse>;\n list(): Promise<CountryListItem[]>;\n}\n\nexport function createCountryNamespace(client: HttpClient): CountryNamespace {\n const country = ((value: string) =>\n client.get<CountryResponse>('/v0/country', { value })\n ) as CountryNamespace;\n\n country.list = () => client.get<CountryListItem[]>('/v0/country/list');\n\n return country;\n}\n","import type { HttpClient } from '../client.js';\nimport type { CurrencyResponse, CurrencyListItem } from '../types/currency.js';\n\nexport interface CurrencyNamespace {\n (value: string): Promise<CurrencyResponse>;\n list(): Promise<CurrencyListItem[]>;\n}\n\nexport function createCurrencyNamespace(client: HttpClient): CurrencyNamespace {\n const currency = ((value: string) =>\n client.get<CurrencyResponse>('/v0/currency', { value })\n ) as CurrencyNamespace;\n\n currency.list = () => client.get<CurrencyListItem[]>('/v0/currency/list');\n\n return currency;\n}\n","import type { HttpClient } from '../client.js';\nimport type { LanguageResponse, LanguageListItem } from '../types/language.js';\n\nexport interface LanguageNamespace {\n (value: string): Promise<LanguageResponse>;\n list(): Promise<LanguageListItem[]>;\n}\n\nexport function createLanguageNamespace(client: HttpClient): LanguageNamespace {\n const language = ((value: string) =>\n client.get<LanguageResponse>('/v0/language', { value })\n ) as LanguageNamespace;\n\n language.list = () => client.get<LanguageListItem[]>('/v0/language/list');\n\n return language;\n}\n","import type { HttpClient } from '../client.js';\nimport type {\n IataFlightResponse, IataAirlineResponse, IataAirlineListItem, IataAirportResponse,\n} from '../types/iata.js';\n\nexport interface IataAirlineNamespace {\n (value: string): Promise<IataAirlineResponse>;\n list(): Promise<IataAirlineListItem[]>;\n}\n\nexport interface IataNamespace {\n flight(value: string): Promise<IataFlightResponse>;\n airline: IataAirlineNamespace;\n airport(value: string): Promise<IataAirportResponse>;\n}\n\nexport function createIataNamespace(client: HttpClient): IataNamespace {\n const airline = ((value: string) =>\n client.get<IataAirlineResponse>('/v0/iata/airline', { value })\n ) as IataAirlineNamespace;\n\n airline.list = () => client.get<IataAirlineListItem[]>('/v0/iata/airline/list');\n\n return {\n flight: (value: string) =>\n client.get<IataFlightResponse>('/v0/iata/flight', { value }),\n airline,\n airport: (value: string) =>\n client.get<IataAirportResponse>('/v0/iata/airport', { value }),\n };\n}\n","import type { HttpClient } from '../client.js';\nimport type { IpResponse, MacResponse } from '../types/net.js';\n\nexport interface NetNamespace {\n ip(value: string): Promise<IpResponse>;\n mac(value: string): Promise<MacResponse>;\n}\n\nexport function createNetNamespace(client: HttpClient): NetNamespace {\n return {\n ip: (value: string) => client.get<IpResponse>('/v0/net/ip', { value }),\n mac: (value: string) => client.get<MacResponse>('/v0/net/mac', { value }),\n };\n}\n","import type { HttpClient } from '../client.js';\nimport type { PeselResponse, RegonResponse, KrsResponse } from '../types/pl.js';\n\nexport interface PlNamespace {\n pesel(value: string): Promise<PeselResponse>;\n regon(value: string, opts?: { lookup?: boolean }): Promise<RegonResponse>;\n krs(value: string, opts?: { lookup?: boolean }): Promise<KrsResponse>;\n}\n\nexport function createPlNamespace(client: HttpClient): PlNamespace {\n return {\n pesel: (value: string) =>\n client.get<PeselResponse>('/v0/pl/pesel', { value }),\n regon: (value: string, opts?) =>\n client.get<RegonResponse>('/v0/pl/regon', {\n value,\n lookup: opts?.lookup?.toString(),\n }),\n krs: (value: string, opts?) =>\n client.get<KrsResponse>('/v0/pl/krs', {\n value,\n lookup: opts?.lookup?.toString(),\n }),\n };\n}\n","import type { HttpClient } from '../client.js';\nimport type { CnpjResponse, CpfResponse } from '../types/br.js';\n\nexport interface BrNamespace {\n cnpj(value: string): Promise<CnpjResponse>;\n cpf(value: string): Promise<CpfResponse>;\n}\n\nexport function createBrNamespace(client: HttpClient): BrNamespace {\n return {\n cnpj: (value: string) => client.get<CnpjResponse>('/v0/br/cnpj', { value }),\n cpf: (value: string) => client.get<CpfResponse>('/v0/br/cpf', { value }),\n };\n}\n","import type { HttpClient } from '../client.js';\nimport type { AbnResponse } from '../types/au.js';\n\nexport interface AuNamespace {\n abn(value: string): Promise<AbnResponse>;\n}\n\nexport function createAuNamespace(client: HttpClient): AuNamespace {\n return {\n abn: (value: string) => client.get<AbnResponse>('/v0/au/abn', { value }),\n };\n}\n","import type { HttpClient } from '../client.js';\nimport type { NifResponse } from '../types/es.js';\n\nexport interface EsNamespace {\n nif(value: string): Promise<NifResponse>;\n}\n\nexport function createEsNamespace(client: HttpClient): EsNamespace {\n return {\n nif: (value: string) => client.get<NifResponse>('/v0/es/nif', { value }),\n };\n}\n","import type { HttpClient } from '../client.js';\nimport type { GstinResponse } from '../types/in.js';\n\nexport interface InNamespace {\n gstin(value: string): Promise<GstinResponse>;\n}\n\nexport function createInNamespace(client: HttpClient): InNamespace {\n return {\n gstin: (value: string) => client.get<GstinResponse>('/v0/in/gstin', { value }),\n };\n}\n","import type { HttpClient } from '../client.js';\nimport type { NpiResponse } from '../types/us.js';\n\nexport interface UsNamespace {\n npi(value: string): Promise<NpiResponse>;\n}\n\nexport function createUsNamespace(client: HttpClient): UsNamespace {\n return {\n npi: (value: string) => client.get<NpiResponse>('/v0/us/npi', { value }),\n };\n}\n","import type { HttpClient } from '../client.js';\nimport type { SortCodeResponse } from '../types/gb.js';\n\nexport interface GbNamespace {\n sortCode(value: string): Promise<SortCodeResponse>;\n}\n\nexport function createGbNamespace(client: HttpClient): GbNamespace {\n return {\n sortCode: (value: string) => client.get<SortCodeResponse>('/v0/gb/sort-code', { value }),\n };\n}\n","import { HttpClient } from './client.js';\nimport type { IsValidConfig } from './client.js';\nimport { createLeiNamespace } from './namespaces/lei.js';\nimport type { LeiNamespace } from './namespaces/lei.js';\nimport { createCountryNamespace } from './namespaces/country.js';\nimport type { CountryNamespace } from './namespaces/country.js';\nimport { createCurrencyNamespace } from './namespaces/currency.js';\nimport type { CurrencyNamespace } from './namespaces/currency.js';\nimport { createLanguageNamespace } from './namespaces/language.js';\nimport type { LanguageNamespace } from './namespaces/language.js';\nimport { createIataNamespace } from './namespaces/iata.js';\nimport type { IataNamespace } from './namespaces/iata.js';\nimport { createNetNamespace } from './namespaces/net.js';\nimport type { NetNamespace } from './namespaces/net.js';\nimport { createPlNamespace } from './namespaces/pl.js';\nimport type { PlNamespace } from './namespaces/pl.js';\nimport { createBrNamespace } from './namespaces/br.js';\nimport type { BrNamespace } from './namespaces/br.js';\nimport { createAuNamespace } from './namespaces/au.js';\nimport type { AuNamespace } from './namespaces/au.js';\nimport { createEsNamespace } from './namespaces/es.js';\nimport type { EsNamespace } from './namespaces/es.js';\nimport { createInNamespace } from './namespaces/in.js';\nimport type { InNamespace } from './namespaces/in.js';\nimport { createUsNamespace } from './namespaces/us.js';\nimport type { UsNamespace } from './namespaces/us.js';\nimport { createGbNamespace } from './namespaces/gb.js';\nimport type { GbNamespace } from './namespaces/gb.js';\nimport type {\n EmailResponse, IbanResponse, IsinResponse, DtiResponse, VatResponse,\n GpsResponse, PhoneResponse, UrlResponse, EanResponse, IsbnResponse,\n IssnResponse, BicResponse, CusipResponse, CfiResponse, MicResponse,\n NutsResponse, UuidResponse, JwtResponse, VinResponse, ImeiResponse,\n SemverResponse, ColorResponse, BooleanResponse, DateResponse,\n BtcAddressResponse, PostalCodeResponse, AbaResponse, Iso6346Response,\n SsccResponse, GlnResponse, QrResponse, CreditCardResponse,\n} from './types/simple.js';\n\nexport class IsValid {\n private readonly client: HttpClient;\n\n readonly lei: LeiNamespace;\n readonly country: CountryNamespace;\n readonly currency: CurrencyNamespace;\n readonly language: LanguageNamespace;\n readonly iata: IataNamespace;\n readonly net: NetNamespace;\n readonly pl: PlNamespace;\n readonly br: BrNamespace;\n readonly au: AuNamespace;\n readonly es: EsNamespace;\n readonly in: InNamespace;\n readonly us: UsNamespace;\n readonly gb: GbNamespace;\n\n constructor(config: IsValidConfig) {\n this.client = new HttpClient(config);\n\n this.lei = createLeiNamespace(this.client);\n this.country = createCountryNamespace(this.client);\n this.currency = createCurrencyNamespace(this.client);\n this.language = createLanguageNamespace(this.client);\n this.iata = createIataNamespace(this.client);\n this.net = createNetNamespace(this.client);\n this.pl = createPlNamespace(this.client);\n this.br = createBrNamespace(this.client);\n this.au = createAuNamespace(this.client);\n this.es = createEsNamespace(this.client);\n this.in = createInNamespace(this.client);\n this.us = createUsNamespace(this.client);\n this.gb = createGbNamespace(this.client);\n }\n\n // --- Simple endpoints ---\n\n email(value: string, opts?: { checkMx?: boolean }): Promise<EmailResponse> {\n return this.client.get('/v0/email', { value, checkMx: opts?.checkMx?.toString() });\n }\n\n iban(value: string, opts?: { countryCode?: string }): Promise<IbanResponse> {\n return this.client.get('/v0/iban', { value, countryCode: opts?.countryCode });\n }\n\n isin(value: string): Promise<IsinResponse> {\n return this.client.get('/v0/isin', { value });\n }\n\n dti(value: string): Promise<DtiResponse> {\n return this.client.get('/v0/dti', { value });\n }\n\n vat(value: string, opts?: { countryCode?: string; checkVies?: boolean }): Promise<VatResponse> {\n return this.client.get('/v0/vat', {\n value,\n countryCode: opts?.countryCode,\n checkVies: opts?.checkVies?.toString(),\n });\n }\n\n gps(value: string): Promise<GpsResponse> {\n return this.client.get('/v0/gps', { value });\n }\n\n phone(value: string, opts?: { countryCode?: string }): Promise<PhoneResponse> {\n return this.client.get('/v0/phone', { value, countryCode: opts?.countryCode });\n }\n\n url(value: string): Promise<UrlResponse> {\n return this.client.get('/v0/url', { value });\n }\n\n ean(value: string): Promise<EanResponse> {\n return this.client.get('/v0/ean', { value });\n }\n\n isbn(value: string): Promise<IsbnResponse> {\n return this.client.get('/v0/isbn', { value });\n }\n\n issn(value: string): Promise<IssnResponse> {\n return this.client.get('/v0/issn', { value });\n }\n\n bic(value: string): Promise<BicResponse> {\n return this.client.get('/v0/bic', { value });\n }\n\n cusip(value: string): Promise<CusipResponse> {\n return this.client.get('/v0/cusip', { value });\n }\n\n cfi(value: string): Promise<CfiResponse> {\n return this.client.get('/v0/cfi', { value });\n }\n\n mic(value: string): Promise<MicResponse> {\n return this.client.get('/v0/mic', { value });\n }\n\n nuts(value: string): Promise<NutsResponse> {\n return this.client.get('/v0/nuts', { value });\n }\n\n uuid(value: string, opts?: { version?: number }): Promise<UuidResponse> {\n return this.client.get('/v0/uuid', { value, version: opts?.version?.toString() });\n }\n\n jwt(value: string): Promise<JwtResponse> {\n return this.client.get('/v0/jwt', { value });\n }\n\n vin(value: string): Promise<VinResponse> {\n return this.client.get('/v0/vin', { value });\n }\n\n imei(value: string): Promise<ImeiResponse> {\n return this.client.get('/v0/imei', { value });\n }\n\n semver(value: string): Promise<SemverResponse> {\n return this.client.get('/v0/semver', { value });\n }\n\n color(value: string): Promise<ColorResponse> {\n return this.client.get('/v0/color', { value });\n }\n\n boolean(value: string): Promise<BooleanResponse> {\n return this.client.get('/v0/boolean', { value });\n }\n\n date(value: string, opts?: { format?: string }): Promise<DateResponse> {\n return this.client.get('/v0/date', { value, format: opts?.format });\n }\n\n btcAddress(value: string): Promise<BtcAddressResponse> {\n return this.client.get('/v0/btc-address', { value });\n }\n\n postalCode(value: string, opts?: { countryCode?: string }): Promise<PostalCodeResponse> {\n return this.client.get('/v0/postal-code', { value, countryCode: opts?.countryCode });\n }\n\n aba(value: string): Promise<AbaResponse> {\n return this.client.get('/v0/aba', { value });\n }\n\n iso6346(value: string): Promise<Iso6346Response> {\n return this.client.get('/v0/iso6346', { value });\n }\n\n sscc(value: string): Promise<SsccResponse> {\n return this.client.get('/v0/sscc', { value });\n }\n\n gln(value: string): Promise<GlnResponse> {\n return this.client.get('/v0/gln', { value });\n }\n\n qr(value: string): Promise<QrResponse> {\n return this.client.get('/v0/qr', { value });\n }\n\n creditCard(number: string): Promise<CreditCardResponse> {\n return this.client.post('/v0/credit-card', { number });\n }\n}\n\nexport function createClient(config: IsValidConfig): IsValid {\n return new IsValid(config);\n}\n\nexport { IsValidError, IsValidAuthError, IsValidRateLimitError } from './errors.js';\nexport type { IsValidConfig, RetryConfig } from './client.js';\nexport * from './types/index.js';\n\nexport type { LeiNamespace } from './namespaces/lei.js';\nexport type { CountryNamespace } from './namespaces/country.js';\nexport type { CurrencyNamespace } from './namespaces/currency.js';\nexport type { LanguageNamespace } from './namespaces/language.js';\nexport type { IataNamespace, IataAirlineNamespace } from './namespaces/iata.js';\nexport type { NetNamespace } from './namespaces/net.js';\nexport type { PlNamespace } from './namespaces/pl.js';\nexport type { BrNamespace } from './namespaces/br.js';\nexport type { AuNamespace } from './namespaces/au.js';\nexport type { EsNamespace } from './namespaces/es.js';\nexport type { InNamespace } from './namespaces/in.js';\nexport type { UsNamespace } from './namespaces/us.js';\nexport type { GbNamespace } from './namespaces/gb.js';\n"]}
|