@finalbosstech/idv-sdk 2.4.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.md +31 -0
- package/README.md +296 -0
- package/dist/index.js +7 -0
- package/dist/index.mjs +7 -0
- package/package.json +59 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# License
|
|
2
|
+
|
|
3
|
+
This project is dual-licensed.
|
|
4
|
+
|
|
5
|
+
## Non-Commercial Use
|
|
6
|
+
|
|
7
|
+
Permitted under [PolyForm Noncommercial License 1.0.0](./LICENSES/PolyForm-Noncommercial-1.0.0.txt).
|
|
8
|
+
|
|
9
|
+
You may use, modify, and distribute this software for any non-commercial purpose, including:
|
|
10
|
+
- Personal projects and research
|
|
11
|
+
- Academic and educational use
|
|
12
|
+
- Non-profit organizations
|
|
13
|
+
- Evaluation and testing
|
|
14
|
+
|
|
15
|
+
## Commercial Use
|
|
16
|
+
|
|
17
|
+
Requires a paid commercial license. See [LICENSES/FinalBoss-Commercial.txt](./LICENSES/FinalBoss-Commercial.txt).
|
|
18
|
+
|
|
19
|
+
Commercial use includes:
|
|
20
|
+
- Use in revenue-generating products or services
|
|
21
|
+
- Use by for-profit companies in production
|
|
22
|
+
- Integration into commercial software or SaaS
|
|
23
|
+
|
|
24
|
+
**To obtain a commercial license:**
|
|
25
|
+
|
|
26
|
+
- Email: abraham@finalbosstech.com
|
|
27
|
+
- Web: https://finalbosstech.com
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
Copyright (c) 2025 FinalBoss Technologies. All rights reserved.
|
package/README.md
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
# @finalboss/idv-sdk
|
|
2
|
+
|
|
3
|
+
Official SDK for FinalBoss IDV++ API - Enterprise Identity Verification with Post-Quantum Cryptographic Governance.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🔐 **Identity Verification** - Document, biometric, and liveness verification
|
|
8
|
+
- 🔗 **Hash-Chain Governance** - Tamper-evident audit trail with cryptographic receipts
|
|
9
|
+
- 🛡️ **Post-Quantum Security** - ML-DSA-65 (NIST FIPS 204) signatures
|
|
10
|
+
- ⚡ **Epoch-Based Revocation** - O(1) instant mass invalidation
|
|
11
|
+
- 📋 **Consent Management** - GDPR/CCPA compliant consent tracking
|
|
12
|
+
- 🎯 **Liveness Detection** - 60-second time-bound biometric proofs
|
|
13
|
+
- 📊 **Full TypeScript Support** - Complete type definitions
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @finalboss/idv-sdk
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { IDVClient } from '@finalboss/idv-sdk';
|
|
25
|
+
|
|
26
|
+
const client = new IDVClient({
|
|
27
|
+
clientId: 'your-client-id',
|
|
28
|
+
clientSecret: 'your-client-secret',
|
|
29
|
+
// Optional: custom base URL
|
|
30
|
+
// baseUrl: 'https://your-instance.example.com'
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Create and process a verification
|
|
34
|
+
const verification = await client.createVerification({
|
|
35
|
+
user_id: 'user-123',
|
|
36
|
+
verification_type: 'identity',
|
|
37
|
+
metadata: { document_type: 'passport', country: 'USA' }
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const result = await client.processVerification(verification.verification_id);
|
|
41
|
+
console.log(`Verification ${result.passed ? '✅ PASSED' : '❌ FAILED'}`);
|
|
42
|
+
console.log(`Confidence: ${(result.confidence_score * 100).toFixed(1)}%`);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## API Reference
|
|
46
|
+
|
|
47
|
+
### Verifications
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
// Create a verification
|
|
51
|
+
const verification = await client.createVerification({
|
|
52
|
+
user_id: 'user-123',
|
|
53
|
+
verification_type: 'identity', // 'document' | 'biometric' | 'liveness' | 'age' | 'identity'
|
|
54
|
+
metadata: { /* custom data */ }
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Process through ML pipeline
|
|
58
|
+
const result = await client.processVerification(verification.verification_id);
|
|
59
|
+
|
|
60
|
+
// Get verification details
|
|
61
|
+
const details = await client.getVerification(verification.verification_id);
|
|
62
|
+
|
|
63
|
+
// List all verifications
|
|
64
|
+
const { verifications, total } = await client.listVerifications({
|
|
65
|
+
status: 'verified',
|
|
66
|
+
limit: 100
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Governance Receipts
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
// Get receipt chain for a verification
|
|
74
|
+
const chain = await client.getGovernanceReceipts(verificationId);
|
|
75
|
+
console.log(`Chain integrity: ${chain.chain_integrity}`);
|
|
76
|
+
|
|
77
|
+
// Verify entire receipt chain
|
|
78
|
+
const verification = await client.verifyGovernanceChain();
|
|
79
|
+
console.log(`Total receipts: ${verification.total_receipts}`);
|
|
80
|
+
console.log(`Failures: ${verification.failures.length}`);
|
|
81
|
+
|
|
82
|
+
// Export for independent verification
|
|
83
|
+
const export = await client.exportGovernanceReceipts();
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Post-Quantum Cryptography (ML-DSA-65)
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
// Get PQC public key
|
|
90
|
+
const pqcKey = await client.getPQCPublicKey();
|
|
91
|
+
console.log(`Algorithm: ${pqcKey.algorithm}`);
|
|
92
|
+
console.log(`Key size: ${pqcKey.public_key_bytes} bytes`);
|
|
93
|
+
|
|
94
|
+
// Create PQC receipt
|
|
95
|
+
const receipt = await client.createPQCReceipt({
|
|
96
|
+
event_type: 'verification_completed',
|
|
97
|
+
verification_id: verificationId,
|
|
98
|
+
decision_logic: { confidence: 0.95 }
|
|
99
|
+
});
|
|
100
|
+
console.log(`Signature: ${receipt.signature_bytes} bytes`);
|
|
101
|
+
|
|
102
|
+
// Verify PQC chain
|
|
103
|
+
const pqcVerification = await client.verifyPQCChain();
|
|
104
|
+
console.log(`Chain integrity: ${pqcVerification.chain_integrity}`);
|
|
105
|
+
|
|
106
|
+
// Export with public key for offline verification
|
|
107
|
+
const pqcExport = await client.exportPQCReceipts();
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Consent Management (GDPR/CCPA)
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
// Create consent
|
|
114
|
+
const consent = await client.createConsent({
|
|
115
|
+
subject_id: 'user-123',
|
|
116
|
+
partner_id: 'partner-acme',
|
|
117
|
+
purpose: 'identity_verification',
|
|
118
|
+
scope: {
|
|
119
|
+
data_types: ['name', 'photo', 'date_of_birth'],
|
|
120
|
+
retention_days: 90
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// Verify consent
|
|
125
|
+
const { valid, consent } = await client.verifyConsent({
|
|
126
|
+
subject_id: 'user-123',
|
|
127
|
+
partner_id: 'partner-acme',
|
|
128
|
+
purpose: 'identity_verification'
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// Revoke consent
|
|
132
|
+
await client.revokeConsent(consentId, { reason: 'user_request' });
|
|
133
|
+
|
|
134
|
+
// List all consents for a subject
|
|
135
|
+
const { consents } = await client.listConsentsForSubject('user-123');
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Liveness Detection
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
// Create challenge
|
|
142
|
+
const challenge = await client.createLivenessChallenge({
|
|
143
|
+
subject_id: 'user-123',
|
|
144
|
+
challenge_type: 'blink' // 'blink' | 'smile' | 'turn_head' | 'speak_phrase' | 'nod'
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
console.log(`Challenge: ${challenge.instructions}`);
|
|
148
|
+
console.log(`Expires: ${challenge.expires_at}`);
|
|
149
|
+
|
|
150
|
+
// Submit response (within 60 seconds)
|
|
151
|
+
const result = await client.submitLivenessResponse(challenge.challenge_id, {
|
|
152
|
+
response_data: base64EncodedVideoFrame,
|
|
153
|
+
device_info: {
|
|
154
|
+
user_agent: navigator.userAgent,
|
|
155
|
+
platform: navigator.platform
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
console.log(`Result: ${result.result}`);
|
|
160
|
+
console.log(`Confidence: ${result.confidence_score}`);
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Epoch-Based Revocation
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
// Get current epoch
|
|
167
|
+
const epoch = await client.getEpochStatus();
|
|
168
|
+
console.log(`Current epoch: ${epoch.epoch_id}`);
|
|
169
|
+
|
|
170
|
+
// FLIP EPOCH - Instantly invalidate ALL prior verifications
|
|
171
|
+
const flip = await client.flipEpoch({ reason: 'security_incident' });
|
|
172
|
+
console.log(`New epoch: ${flip.new_epoch}`);
|
|
173
|
+
console.log(flip.message); // "All verifications issued before epoch X are now INVALID"
|
|
174
|
+
|
|
175
|
+
// Revoke single verification
|
|
176
|
+
const revocation = await client.revokeVerification(verificationId, {
|
|
177
|
+
reason: 'fraud_detected'
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Check if verification is still valid
|
|
181
|
+
const validity = await client.checkVerificationValidity(verificationId);
|
|
182
|
+
console.log(`Valid: ${validity.valid}`);
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Policy Management
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
// Get current policy
|
|
189
|
+
const policy = await client.getPolicy();
|
|
190
|
+
|
|
191
|
+
// Set policy
|
|
192
|
+
const newPolicy = await client.setPolicy({
|
|
193
|
+
policy_data: {
|
|
194
|
+
verification_threshold: 0.85,
|
|
195
|
+
consent_required: true,
|
|
196
|
+
liveness_required: true,
|
|
197
|
+
retention_days: 365,
|
|
198
|
+
pqc_receipts_enabled: true
|
|
199
|
+
},
|
|
200
|
+
version: '2.0.0'
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
// Get policy history
|
|
204
|
+
const { policies } = await client.getPolicyHistory();
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Health & Discovery
|
|
208
|
+
|
|
209
|
+
```typescript
|
|
210
|
+
// Check API health
|
|
211
|
+
const health = await client.health();
|
|
212
|
+
console.log(`Version: ${health.version}`);
|
|
213
|
+
console.log(`PQC enabled: ${health.pqc.enabled}`);
|
|
214
|
+
|
|
215
|
+
// Get JWKS for JWT verification
|
|
216
|
+
const jwks = await client.getJWKS();
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Error Handling
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
import {
|
|
223
|
+
IDVClient,
|
|
224
|
+
AuthenticationError,
|
|
225
|
+
ValidationError,
|
|
226
|
+
NotFoundError,
|
|
227
|
+
RateLimitError,
|
|
228
|
+
IDVError
|
|
229
|
+
} from '@finalboss/idv-sdk';
|
|
230
|
+
|
|
231
|
+
try {
|
|
232
|
+
await client.createVerification({ /* ... */ });
|
|
233
|
+
} catch (error) {
|
|
234
|
+
if (error instanceof AuthenticationError) {
|
|
235
|
+
console.error('Authentication failed - check credentials');
|
|
236
|
+
} else if (error instanceof ValidationError) {
|
|
237
|
+
console.error('Validation failed:', error.details);
|
|
238
|
+
} else if (error instanceof NotFoundError) {
|
|
239
|
+
console.error('Resource not found');
|
|
240
|
+
} else if (error instanceof RateLimitError) {
|
|
241
|
+
console.error(`Rate limited - retry after ${error.details?.retry_after}s`);
|
|
242
|
+
} else if (error instanceof IDVError) {
|
|
243
|
+
console.error(`API error ${error.status}: ${error.message}`);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Configuration
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
const client = new IDVClient({
|
|
252
|
+
// Required
|
|
253
|
+
clientId: 'your-client-id',
|
|
254
|
+
clientSecret: 'your-client-secret',
|
|
255
|
+
|
|
256
|
+
// Optional
|
|
257
|
+
baseUrl: 'https://your-instance.example.com',
|
|
258
|
+
timeout: 30000, // Request timeout in ms
|
|
259
|
+
|
|
260
|
+
// Custom fetch (useful for testing/mocking)
|
|
261
|
+
fetch: customFetchImplementation,
|
|
262
|
+
|
|
263
|
+
// Retry configuration
|
|
264
|
+
retry: {
|
|
265
|
+
maxRetries: 3,
|
|
266
|
+
baseDelay: 1000,
|
|
267
|
+
maxDelay: 10000
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## TypeScript Support
|
|
273
|
+
|
|
274
|
+
Full TypeScript support with complete type definitions:
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
import type {
|
|
278
|
+
Verification,
|
|
279
|
+
VerificationResult,
|
|
280
|
+
PQCReceipt,
|
|
281
|
+
Consent,
|
|
282
|
+
LivenessChallenge,
|
|
283
|
+
EpochStatus
|
|
284
|
+
} from '@finalboss/idv-sdk';
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
## License
|
|
288
|
+
|
|
289
|
+
MIT
|
|
290
|
+
|
|
291
|
+
## Support
|
|
292
|
+
|
|
293
|
+
- Documentation: https://finalbosstech.com/docs
|
|
294
|
+
- Issues: https://github.com/805-ai/finalboss-idv-sdk/issues
|
|
295
|
+
- Email: abraham@finalbosstech.com
|
|
296
|
+
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @finalboss/idv-sdk v2.4.0
|
|
3
|
+
* (c) 2025 FinalBoss Technologies
|
|
4
|
+
* Compiled: 2025-12-24T17:24:18.839Z
|
|
5
|
+
* License: MIT
|
|
6
|
+
*/
|
|
7
|
+
"use strict";var l=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var P=(n,e)=>{for(var t in e)l(n,t,{get:e[t],enumerable:!0})},b=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of R(e))!C.call(n,r)&&r!==t&&l(n,r,{get:()=>e[r],enumerable:!(i=m(e,r))||i.enumerable});return n};var x=n=>b(l({},"__esModule",{value:!0}),n);var T={};P(T,{AuthenticationError:()=>a,DEFAULT_API_URL:()=>E,IDVClient:()=>g,IDVError:()=>s,NotFoundError:()=>p,RateLimitError:()=>u,SDK_VERSION:()=>k,ValidationError:()=>c});module.exports=x(T);var s=class extends Error{constructor(t,i,r,h){super(t);this.code=i;this.status=r;this.details=h;this.name="IDVError"}},a=class extends s{constructor(e="Authentication failed"){super(e,"AUTH_FAILED",401),this.name="AuthenticationError"}},c=class extends s{constructor(e,t){super(e,"VALIDATION_FAILED",400,t),this.name="ValidationError"}},p=class extends s{constructor(e,t){super(`${e} not found: ${t}`,"NOT_FOUND",404),this.name="NotFoundError"}},u=class extends s{constructor(e){super("Rate limit exceeded","RATE_LIMITED",429,{retry_after:e}),this.name="RateLimitError"}};var q="https://idv-api-132974110034.us-central1.run.app",S=3e4,g=class{baseUrl;clientId;clientSecret;timeout;accessToken=null;tokenExpiry=0;fetchFn;constructor(e){this.baseUrl=(e.baseUrl||q).replace(/\/$/,""),this.clientId=e.clientId,this.clientSecret=e.clientSecret,this.timeout=e.timeout||S,this.fetchFn=e.fetch||fetch}async request(e,t,i={}){let{body:r,authenticated:h=!0,headers:v={}}=i,y=`${this.baseUrl}${t}`,f={"Content-Type":"application/json",...v};if(h){let o=await this.getAccessToken();f.Authorization=`Bearer ${o}`}let d=new AbortController,_=setTimeout(()=>d.abort(),this.timeout);try{let o=await this.fetchFn(y,{method:e,headers:f,body:r?JSON.stringify(r):void 0,signal:d.signal});return clearTimeout(_),o.ok||await this.handleError(o),o.json()}catch(o){throw clearTimeout(_),o instanceof s?o:new s(o instanceof Error?o.message:"Request failed","REQUEST_FAILED",0)}}async handleError(e){let t={};try{t=await e.json()}catch{}let i=t.message||e.statusText;switch(e.status){case 401:throw this.accessToken=null,new a(i);case 400:throw new c(i,t);case 404:throw new p("Resource","unknown");case 429:let r=parseInt(e.headers.get("Retry-After")||"60");throw new u(r);default:throw new s(i,"API_ERROR",e.status,t)}}async getAccessToken(){if(this.accessToken&&Date.now()<this.tokenExpiry)return this.accessToken;let e=await this.request("POST","/api/v1/auth/token",{body:{client_id:this.clientId,client_secret:this.clientSecret},authenticated:!1});return this.accessToken=e.access_token,this.tokenExpiry=Date.now()+(e.expires_in||3600)*1e3-3e5,this.accessToken}async refreshToken(){this.accessToken=null,this.tokenExpiry=0,await this.getAccessToken()}async health(){return this.request("GET","/health",{authenticated:!1})}async getJWKS(){return this.request("GET","/.well-known/jwks.json",{authenticated:!1})}async getPQCPublicKey(){return this.request("GET","/.well-known/pqc-keys.json",{authenticated:!1})}async createVerification(e){return this.request("POST","/api/v1/verification",{body:e})}async getVerification(e){return this.request("GET",`/api/v1/verification/${e}`)}async processVerification(e){return this.request("POST",`/api/v1/verification/${e}/process`,{body:{}})}async listVerifications(e){let t=new URLSearchParams;e?.status&&t.set("status",e.status),e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset));let i=t.toString(),r=`/api/v1/verification${i?`?${i}`:""}`;return this.request("GET",r)}async getGovernanceReceipts(e){return this.request("GET",`/api/v1/governance/receipts/${e}`)}async verifyGovernanceChain(){return this.request("POST","/api/v1/governance/verify-chain",{body:{}})}async exportGovernanceReceipts(e){let t=new URLSearchParams;e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset));let i=t.toString(),r=`/api/v1/governance/export${i?`?${i}`:""}`;return this.request("GET",r)}async createPQCReceipt(e){return this.request("POST","/api/v1/pqc/receipt",{body:e})}async getPQCReceipts(e){return this.request("GET",`/api/v1/pqc/receipts/${e}`)}async verifyPQCChain(){return this.request("POST","/api/v1/pqc/chain/verify",{body:{}})}async verifyPQCReceipt(e){return this.request("POST","/api/v1/pqc/verify",{body:{receipt:e}})}async exportPQCReceipts(e){let t=new URLSearchParams;e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset));let i=t.toString(),r=`/api/v1/pqc/export${i?`?${i}`:""}`;return this.request("GET",r)}async createConsent(e){return this.request("POST","/api/v1/consent",{body:e})}async getConsent(e){return this.request("GET",`/api/v1/consent/${e}`)}async verifyConsent(e){return this.request("POST","/api/v1/consent/verify",{body:e})}async revokeConsent(e,t){return this.request("POST",`/api/v1/consent/${e}/revoke`,{body:t})}async listConsentsForSubject(e){return this.request("GET",`/api/v1/consent/subject/${e}`)}async createLivenessChallenge(e){return this.request("POST","/api/v1/liveness/challenge",{body:e})}async submitLivenessResponse(e,t){return this.request("POST",`/api/v1/liveness/challenge/${e}/submit`,{body:t})}async getLivenessVerification(e){return this.request("GET",`/api/v1/liveness/verification/${e}`)}async getEpochStatus(){return this.request("GET","/api/v1/revocation/epoch")}async flipEpoch(e){return this.request("POST","/api/v1/revocation/epoch/flip",{body:e})}async revokeVerification(e,t){return this.request("POST",`/api/v1/revocation/${e}`,{body:t})}async checkVerificationValidity(e){return this.request("GET",`/api/v1/revocation/check/${e}`)}async getPolicy(){return this.request("GET","/api/v1/policies")}async setPolicy(e){return this.request("POST","/api/v1/policies",{body:e})}async getPolicyHistory(){return this.request("GET","/api/v1/policies/history")}};var k="2.4.0",E="https://idv-api-132974110034.us-central1.run.app";0&&(module.exports={AuthenticationError,DEFAULT_API_URL,IDVClient,IDVError,NotFoundError,RateLimitError,SDK_VERSION,ValidationError});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @finalboss/idv-sdk v2.4.0
|
|
3
|
+
* (c) 2025 FinalBoss Technologies
|
|
4
|
+
* Compiled: 2025-12-24T17:24:18.839Z
|
|
5
|
+
* License: MIT
|
|
6
|
+
*/
|
|
7
|
+
var n=class extends Error{constructor(t,i,r,l){super(t);this.code=i;this.status=r;this.details=l;this.name="IDVError"}},a=class extends n{constructor(e="Authentication failed"){super(e,"AUTH_FAILED",401),this.name="AuthenticationError"}},c=class extends n{constructor(e,t){super(e,"VALIDATION_FAILED",400,t),this.name="ValidationError"}},p=class extends n{constructor(e,t){super(`${e} not found: ${t}`,"NOT_FOUND",404),this.name="NotFoundError"}},u=class extends n{constructor(e){super("Rate limit exceeded","RATE_LIMITED",429,{retry_after:e}),this.name="RateLimitError"}};var y="https://idv-api-132974110034.us-central1.run.app",m=3e4,g=class{baseUrl;clientId;clientSecret;timeout;accessToken=null;tokenExpiry=0;fetchFn;constructor(e){this.baseUrl=(e.baseUrl||y).replace(/\/$/,""),this.clientId=e.clientId,this.clientSecret=e.clientSecret,this.timeout=e.timeout||m,this.fetchFn=e.fetch||fetch}async request(e,t,i={}){let{body:r,authenticated:l=!0,headers:_={}}=i,v=`${this.baseUrl}${t}`,h={"Content-Type":"application/json",..._};if(l){let s=await this.getAccessToken();h.Authorization=`Bearer ${s}`}let f=new AbortController,d=setTimeout(()=>f.abort(),this.timeout);try{let s=await this.fetchFn(v,{method:e,headers:h,body:r?JSON.stringify(r):void 0,signal:f.signal});return clearTimeout(d),s.ok||await this.handleError(s),s.json()}catch(s){throw clearTimeout(d),s instanceof n?s:new n(s instanceof Error?s.message:"Request failed","REQUEST_FAILED",0)}}async handleError(e){let t={};try{t=await e.json()}catch{}let i=t.message||e.statusText;switch(e.status){case 401:throw this.accessToken=null,new a(i);case 400:throw new c(i,t);case 404:throw new p("Resource","unknown");case 429:let r=parseInt(e.headers.get("Retry-After")||"60");throw new u(r);default:throw new n(i,"API_ERROR",e.status,t)}}async getAccessToken(){if(this.accessToken&&Date.now()<this.tokenExpiry)return this.accessToken;let e=await this.request("POST","/api/v1/auth/token",{body:{client_id:this.clientId,client_secret:this.clientSecret},authenticated:!1});return this.accessToken=e.access_token,this.tokenExpiry=Date.now()+(e.expires_in||3600)*1e3-3e5,this.accessToken}async refreshToken(){this.accessToken=null,this.tokenExpiry=0,await this.getAccessToken()}async health(){return this.request("GET","/health",{authenticated:!1})}async getJWKS(){return this.request("GET","/.well-known/jwks.json",{authenticated:!1})}async getPQCPublicKey(){return this.request("GET","/.well-known/pqc-keys.json",{authenticated:!1})}async createVerification(e){return this.request("POST","/api/v1/verification",{body:e})}async getVerification(e){return this.request("GET",`/api/v1/verification/${e}`)}async processVerification(e){return this.request("POST",`/api/v1/verification/${e}/process`,{body:{}})}async listVerifications(e){let t=new URLSearchParams;e?.status&&t.set("status",e.status),e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset));let i=t.toString(),r=`/api/v1/verification${i?`?${i}`:""}`;return this.request("GET",r)}async getGovernanceReceipts(e){return this.request("GET",`/api/v1/governance/receipts/${e}`)}async verifyGovernanceChain(){return this.request("POST","/api/v1/governance/verify-chain",{body:{}})}async exportGovernanceReceipts(e){let t=new URLSearchParams;e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset));let i=t.toString(),r=`/api/v1/governance/export${i?`?${i}`:""}`;return this.request("GET",r)}async createPQCReceipt(e){return this.request("POST","/api/v1/pqc/receipt",{body:e})}async getPQCReceipts(e){return this.request("GET",`/api/v1/pqc/receipts/${e}`)}async verifyPQCChain(){return this.request("POST","/api/v1/pqc/chain/verify",{body:{}})}async verifyPQCReceipt(e){return this.request("POST","/api/v1/pqc/verify",{body:{receipt:e}})}async exportPQCReceipts(e){let t=new URLSearchParams;e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset));let i=t.toString(),r=`/api/v1/pqc/export${i?`?${i}`:""}`;return this.request("GET",r)}async createConsent(e){return this.request("POST","/api/v1/consent",{body:e})}async getConsent(e){return this.request("GET",`/api/v1/consent/${e}`)}async verifyConsent(e){return this.request("POST","/api/v1/consent/verify",{body:e})}async revokeConsent(e,t){return this.request("POST",`/api/v1/consent/${e}/revoke`,{body:t})}async listConsentsForSubject(e){return this.request("GET",`/api/v1/consent/subject/${e}`)}async createLivenessChallenge(e){return this.request("POST","/api/v1/liveness/challenge",{body:e})}async submitLivenessResponse(e,t){return this.request("POST",`/api/v1/liveness/challenge/${e}/submit`,{body:t})}async getLivenessVerification(e){return this.request("GET",`/api/v1/liveness/verification/${e}`)}async getEpochStatus(){return this.request("GET","/api/v1/revocation/epoch")}async flipEpoch(e){return this.request("POST","/api/v1/revocation/epoch/flip",{body:e})}async revokeVerification(e,t){return this.request("POST",`/api/v1/revocation/${e}`,{body:t})}async checkVerificationValidity(e){return this.request("GET",`/api/v1/revocation/check/${e}`)}async getPolicy(){return this.request("GET","/api/v1/policies")}async setPolicy(e){return this.request("POST","/api/v1/policies",{body:e})}async getPolicyHistory(){return this.request("GET","/api/v1/policies/history")}};var b="2.4.0",x="https://idv-api-132974110034.us-central1.run.app";export{a as AuthenticationError,x as DEFAULT_API_URL,g as IDVClient,n as IDVError,p as NotFoundError,u as RateLimitError,b as SDK_VERSION,c as ValidationError};
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@finalbosstech/idv-sdk",
|
|
3
|
+
"version": "2.4.0",
|
|
4
|
+
"description": "Official SDK for FinalBoss IDV++ API - Post-Quantum Identity Verification",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist/**/*.js",
|
|
17
|
+
"dist/**/*.mjs",
|
|
18
|
+
"dist/**/*.d.ts",
|
|
19
|
+
"dist/**/*.d.mts",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "npm run build:bundle && npm run build:types",
|
|
26
|
+
"build:bundle": "node scripts/build.mjs",
|
|
27
|
+
"build:types": "tsc --emitDeclarationOnly --declaration --outDir dist",
|
|
28
|
+
"build:dev": "tsup src/index.ts --format cjs,esm --dts",
|
|
29
|
+
"clean": "rm -rf dist",
|
|
30
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
31
|
+
"pack:release": "npm run build && npm pack",
|
|
32
|
+
"integrity": "node scripts/integrity.mjs"
|
|
33
|
+
},
|
|
34
|
+
"keywords": [
|
|
35
|
+
"identity-verification",
|
|
36
|
+
"idv",
|
|
37
|
+
"kyc",
|
|
38
|
+
"pqc",
|
|
39
|
+
"post-quantum",
|
|
40
|
+
"ml-dsa",
|
|
41
|
+
"governance"
|
|
42
|
+
],
|
|
43
|
+
"author": "FinalBoss Technologies",
|
|
44
|
+
"license": "PolyForm-Noncommercial-1.0.0 OR LicenseRef-FinalBoss-Commercial",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "https://github.com/805-ai/finalboss-idv-sdk"
|
|
48
|
+
},
|
|
49
|
+
"homepage": "https://finalbosstech.com",
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=18.0.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/node": "^20.10.0",
|
|
55
|
+
"esbuild": "^0.20.2",
|
|
56
|
+
"tsup": "^8.0.1",
|
|
57
|
+
"typescript": "^5.3.0"
|
|
58
|
+
}
|
|
59
|
+
}
|