@vigilhq/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/README.md +133 -0
- package/dist/index.d.ts +99 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +165 -0
- package/dist/index.js.map +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# @vigilhq/sdk
|
|
2
|
+
|
|
3
|
+
Official TypeScript/JavaScript SDK for the [Vigil](https://vigilhq.dev) compliance screening API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @vigilhq/sdk
|
|
9
|
+
# or
|
|
10
|
+
pnpm add @vigilhq/sdk
|
|
11
|
+
# or
|
|
12
|
+
yarn add @vigilhq/sdk
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { Vigil } from "@vigilhq/sdk";
|
|
19
|
+
|
|
20
|
+
const client = new Vigil({ apiKey: "vgl_sk_live_..." });
|
|
21
|
+
|
|
22
|
+
// Screen an entity
|
|
23
|
+
const result = await client.screen({ entity: "John Doe" });
|
|
24
|
+
console.log(result.status); // "clear"
|
|
25
|
+
console.log(result.risk_score); // 12
|
|
26
|
+
console.log(result.recommendation); // "approve"
|
|
27
|
+
|
|
28
|
+
// Screen with context to reduce false positives
|
|
29
|
+
const result2 = await client.screen({
|
|
30
|
+
entity: "Jane Smith",
|
|
31
|
+
context: "onboarding",
|
|
32
|
+
date_of_birth: "1990-01-15",
|
|
33
|
+
nationality: "CA",
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Check a sanctioned entity
|
|
37
|
+
const result3 = await client.screen({ entity: "Osama bin Laden" });
|
|
38
|
+
console.log(result3.status); // "match"
|
|
39
|
+
console.log(result3.risk_level); // "critical"
|
|
40
|
+
console.log(result3.recommendation); // "block"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## API Reference
|
|
44
|
+
|
|
45
|
+
### `new Vigil(config)`
|
|
46
|
+
|
|
47
|
+
| Option | Type | Default | Description |
|
|
48
|
+
|-----------|----------|--------------------------|----------------------|
|
|
49
|
+
| `apiKey` | `string` | — | Your Vigil API key |
|
|
50
|
+
| `baseUrl` | `string` | `https://api.vigilhq.dev` | API base URL |
|
|
51
|
+
| `timeout` | `number` | `30000` | Request timeout (ms) |
|
|
52
|
+
|
|
53
|
+
### Screening
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
// Screen an entity
|
|
57
|
+
const result = await client.screen({ entity: "John Doe", context: "onboarding" });
|
|
58
|
+
|
|
59
|
+
// Get a past screening result
|
|
60
|
+
const past = await client.getScreening("scr_abc123");
|
|
61
|
+
|
|
62
|
+
// List screenings (paginated)
|
|
63
|
+
const list = await client.listScreenings({ page: 1, per_page: 25 });
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Batch Screening
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
// Submit batch (up to 1,000 entities)
|
|
70
|
+
const job = await client.batchScreen([
|
|
71
|
+
{ entity: "Entity A" },
|
|
72
|
+
{ entity: "Entity B" },
|
|
73
|
+
]);
|
|
74
|
+
|
|
75
|
+
// Wait for completion
|
|
76
|
+
const completed = await client.waitForBatch(job.job_id);
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Continuous Monitoring
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
// Add entity to monitoring
|
|
83
|
+
await client.addMonitoredEntity({ entity: "Acme Corp", entity_type: "organization" });
|
|
84
|
+
|
|
85
|
+
// List monitored entities
|
|
86
|
+
const monitored = await client.listMonitoredEntities();
|
|
87
|
+
|
|
88
|
+
// Remove from monitoring
|
|
89
|
+
await client.removeMonitoredEntity("mon_abc123");
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### API Keys
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
const newKey = await client.createApiKey({ name: "production" });
|
|
96
|
+
const keys = await client.listApiKeys();
|
|
97
|
+
await client.revokeApiKey("key_abc123");
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Webhooks
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
await client.createWebhook({ url: "https://example.com/webhook", events: ["screening.completed"] });
|
|
104
|
+
const webhooks = await client.listWebhooks();
|
|
105
|
+
await client.deleteWebhook("wh_abc123");
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Organization & Usage
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
const org = await client.getOrg();
|
|
112
|
+
const usage = await client.getUsage("2026-02");
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Error Handling
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { Vigil, VigilError } from "@vigilhq/sdk";
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
await client.screen({ entity: "test" });
|
|
122
|
+
} catch (err) {
|
|
123
|
+
if (err instanceof VigilError) {
|
|
124
|
+
console.log(err.code); // "RATE_LIMIT_EXCEEDED"
|
|
125
|
+
console.log(err.status); // 429
|
|
126
|
+
console.log(err.message); // "Monthly screening limit reached..."
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## License
|
|
132
|
+
|
|
133
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { ScreenRequest, ScreenResponse, BatchScreenResponse, CreateApiKeyRequest, ApiKeyResponse, ApiKeyCreatedResponse, WatchlistSourceResponse, CreateWebhookRequest, WebhookResponse, MonitorEntityRequest, MonitoredEntityResponse, OrgResponse, UsageResponse, PaginatedResponse, ApiError } from "@vigilhq/types";
|
|
2
|
+
/** Configuration options for the Vigil client. */
|
|
3
|
+
export interface VigilConfig {
|
|
4
|
+
/** Your Vigil API key (e.g. `vgl_sk_live_...`). */
|
|
5
|
+
apiKey: string;
|
|
6
|
+
/** API base URL. Defaults to `https://api.vigilhq.dev`. */
|
|
7
|
+
baseUrl?: string;
|
|
8
|
+
/** Request timeout in milliseconds. Defaults to `30000`. */
|
|
9
|
+
timeout?: number;
|
|
10
|
+
}
|
|
11
|
+
/** Error thrown when the Vigil API returns a non-2xx response. */
|
|
12
|
+
export declare class VigilError extends Error {
|
|
13
|
+
/** Machine-readable error code (e.g. `RATE_LIMIT_EXCEEDED`). */
|
|
14
|
+
code: string;
|
|
15
|
+
/** HTTP status code. */
|
|
16
|
+
status: number;
|
|
17
|
+
/** Additional error details, if any. */
|
|
18
|
+
details?: Record<string, unknown>;
|
|
19
|
+
constructor(status: number, error: ApiError["error"]);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Official TypeScript client for the Vigil compliance screening API.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const client = new Vigil({ apiKey: "vgl_sk_live_..." });
|
|
27
|
+
* const result = await client.screen({ entity: "John Doe" });
|
|
28
|
+
* console.log(result.recommendation); // "approve"
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare class Vigil {
|
|
32
|
+
private apiKey;
|
|
33
|
+
private baseUrl;
|
|
34
|
+
private timeout;
|
|
35
|
+
/** Create a new Vigil client. */
|
|
36
|
+
constructor(config: VigilConfig);
|
|
37
|
+
private request;
|
|
38
|
+
/** Screen an entity against all sanctions and PEP lists. */
|
|
39
|
+
screen(input: ScreenRequest): Promise<ScreenResponse>;
|
|
40
|
+
/** Get a past screening result by ID. */
|
|
41
|
+
getScreening(id: string): Promise<ScreenResponse>;
|
|
42
|
+
/** List past screening results (paginated). */
|
|
43
|
+
listScreenings(params?: {
|
|
44
|
+
page?: number;
|
|
45
|
+
per_page?: number;
|
|
46
|
+
}): Promise<PaginatedResponse<ScreenResponse>>;
|
|
47
|
+
/** Submit a batch screening job (up to 1000 entities). */
|
|
48
|
+
batchScreen(entities: ScreenRequest[]): Promise<BatchScreenResponse>;
|
|
49
|
+
/** Poll a batch job's status. */
|
|
50
|
+
getBatchJob(jobId: string): Promise<BatchScreenResponse>;
|
|
51
|
+
/** Wait for a batch job to complete, polling at interval. */
|
|
52
|
+
waitForBatch(jobId: string, intervalMs?: number, maxWaitMs?: number): Promise<BatchScreenResponse>;
|
|
53
|
+
/** Add an entity to continuous monitoring. */
|
|
54
|
+
addMonitoredEntity(input: MonitorEntityRequest): Promise<MonitoredEntityResponse>;
|
|
55
|
+
/** List monitored entities. */
|
|
56
|
+
listMonitoredEntities(): Promise<{
|
|
57
|
+
data: MonitoredEntityResponse[];
|
|
58
|
+
total: number;
|
|
59
|
+
}>;
|
|
60
|
+
/** Remove an entity from monitoring. */
|
|
61
|
+
removeMonitoredEntity(id: string): Promise<{
|
|
62
|
+
success: boolean;
|
|
63
|
+
}>;
|
|
64
|
+
/** List active watchlist sources. */
|
|
65
|
+
listWatchlists(): Promise<{
|
|
66
|
+
data: WatchlistSourceResponse[];
|
|
67
|
+
}>;
|
|
68
|
+
/** Get detailed status of a watchlist. */
|
|
69
|
+
getWatchlistStatus(code: string): Promise<WatchlistSourceResponse & {
|
|
70
|
+
freshness: string;
|
|
71
|
+
}>;
|
|
72
|
+
/** Create a new API key. */
|
|
73
|
+
createApiKey(input: CreateApiKeyRequest): Promise<ApiKeyCreatedResponse>;
|
|
74
|
+
/** List API keys. */
|
|
75
|
+
listApiKeys(): Promise<{
|
|
76
|
+
data: ApiKeyResponse[];
|
|
77
|
+
}>;
|
|
78
|
+
/** Revoke an API key. */
|
|
79
|
+
revokeApiKey(id: string): Promise<{
|
|
80
|
+
success: boolean;
|
|
81
|
+
}>;
|
|
82
|
+
/** Get current organization details. */
|
|
83
|
+
getOrg(): Promise<OrgResponse>;
|
|
84
|
+
/** Get usage stats for the current period. */
|
|
85
|
+
getUsage(period?: string): Promise<UsageResponse>;
|
|
86
|
+
/** Register a webhook. */
|
|
87
|
+
createWebhook(input: CreateWebhookRequest): Promise<WebhookResponse>;
|
|
88
|
+
/** List webhooks. */
|
|
89
|
+
listWebhooks(): Promise<{
|
|
90
|
+
data: WebhookResponse[];
|
|
91
|
+
}>;
|
|
92
|
+
/** Delete a webhook. */
|
|
93
|
+
deleteWebhook(id: string): Promise<{
|
|
94
|
+
success: boolean;
|
|
95
|
+
}>;
|
|
96
|
+
}
|
|
97
|
+
export type { ScreenRequest, ScreenResponse, BatchScreenRequest, BatchScreenResponse, CreateApiKeyRequest, ApiKeyResponse, ApiKeyCreatedResponse, WatchlistSourceResponse, CreateWebhookRequest, WebhookResponse, MonitorEntityRequest, MonitoredEntityResponse, OrgResponse, UsageResponse, PaginatedResponse, ApiError, MatchDetail, SanctionsResult, PepResult, EntityType, ScreeningStatus, RiskLevel, Recommendation, ScreeningContext, } from "@vigilhq/types";
|
|
98
|
+
export default Vigil;
|
|
99
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EAEd,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,uBAAuB,EACvB,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACT,MAAM,gBAAgB,CAAC;AAExB,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC1B,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,kEAAkE;AAClE,qBAAa,UAAW,SAAQ,KAAK;IACnC,gEAAgE;IACzD,IAAI,EAAE,MAAM,CAAC;IACpB,wBAAwB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AAuB,EACvB,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,eAAe,EACf,SAAS,EACT,UAAU,EACV,eAAe,EACf,SAAS,EACT,cAAc,EACd,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AAExB,eAAe,KAAK,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/** Error thrown when the Vigil API returns a non-2xx response. */
|
|
2
|
+
export class VigilError extends Error {
|
|
3
|
+
/** Machine-readable error code (e.g. `RATE_LIMIT_EXCEEDED`). */
|
|
4
|
+
code;
|
|
5
|
+
/** HTTP status code. */
|
|
6
|
+
status;
|
|
7
|
+
/** Additional error details, if any. */
|
|
8
|
+
details;
|
|
9
|
+
constructor(status, error) {
|
|
10
|
+
super(error.message);
|
|
11
|
+
this.name = "VigilError";
|
|
12
|
+
this.code = error.code;
|
|
13
|
+
this.status = status;
|
|
14
|
+
this.details = error.details;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Official TypeScript client for the Vigil compliance screening API.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const client = new Vigil({ apiKey: "vgl_sk_live_..." });
|
|
23
|
+
* const result = await client.screen({ entity: "John Doe" });
|
|
24
|
+
* console.log(result.recommendation); // "approve"
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export class Vigil {
|
|
28
|
+
apiKey;
|
|
29
|
+
baseUrl;
|
|
30
|
+
timeout;
|
|
31
|
+
/** Create a new Vigil client. */
|
|
32
|
+
constructor(config) {
|
|
33
|
+
this.apiKey = config.apiKey;
|
|
34
|
+
this.baseUrl = (config.baseUrl ?? "https://api.vigilhq.dev").replace(/\/$/, "");
|
|
35
|
+
this.timeout = config.timeout ?? 30000;
|
|
36
|
+
}
|
|
37
|
+
async request(method, path, body) {
|
|
38
|
+
const url = `${this.baseUrl}${path}`;
|
|
39
|
+
const controller = new AbortController();
|
|
40
|
+
const timer = setTimeout(() => controller.abort(), this.timeout);
|
|
41
|
+
try {
|
|
42
|
+
const response = await fetch(url, {
|
|
43
|
+
method,
|
|
44
|
+
headers: {
|
|
45
|
+
Authorization: `Bearer ${this.apiKey}`,
|
|
46
|
+
"Content-Type": "application/json",
|
|
47
|
+
"User-Agent": "@vigilhq/sdk/0.1.0",
|
|
48
|
+
},
|
|
49
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
50
|
+
signal: controller.signal,
|
|
51
|
+
});
|
|
52
|
+
const data = await response.json();
|
|
53
|
+
if (!response.ok) {
|
|
54
|
+
const error = data;
|
|
55
|
+
throw new VigilError(response.status, error.error);
|
|
56
|
+
}
|
|
57
|
+
return data;
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// ── Screening ──────────────────────────────────────────────
|
|
64
|
+
/** Screen an entity against all sanctions and PEP lists. */
|
|
65
|
+
async screen(input) {
|
|
66
|
+
return this.request("POST", "/v1/screen", input);
|
|
67
|
+
}
|
|
68
|
+
/** Get a past screening result by ID. */
|
|
69
|
+
async getScreening(id) {
|
|
70
|
+
return this.request("GET", `/v1/screen/${id}`);
|
|
71
|
+
}
|
|
72
|
+
/** List past screening results (paginated). */
|
|
73
|
+
async listScreenings(params) {
|
|
74
|
+
const query = new URLSearchParams();
|
|
75
|
+
if (params?.page)
|
|
76
|
+
query.set("page", String(params.page));
|
|
77
|
+
if (params?.per_page)
|
|
78
|
+
query.set("per_page", String(params.per_page));
|
|
79
|
+
const qs = query.toString();
|
|
80
|
+
return this.request("GET", `/v1/screenings${qs ? `?${qs}` : ""}`);
|
|
81
|
+
}
|
|
82
|
+
// ── Batch ──────────────────────────────────────────────────
|
|
83
|
+
/** Submit a batch screening job (up to 1000 entities). */
|
|
84
|
+
async batchScreen(entities) {
|
|
85
|
+
return this.request("POST", "/v1/screen/batch", {
|
|
86
|
+
entities,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/** Poll a batch job's status. */
|
|
90
|
+
async getBatchJob(jobId) {
|
|
91
|
+
return this.request("GET", `/v1/screen/batch/${jobId}`);
|
|
92
|
+
}
|
|
93
|
+
/** Wait for a batch job to complete, polling at interval. */
|
|
94
|
+
async waitForBatch(jobId, intervalMs = 2000, maxWaitMs = 300000) {
|
|
95
|
+
const deadline = Date.now() + maxWaitMs;
|
|
96
|
+
while (Date.now() < deadline) {
|
|
97
|
+
const job = await this.getBatchJob(jobId);
|
|
98
|
+
if (job.status === "completed" || job.status === "failed") {
|
|
99
|
+
return job;
|
|
100
|
+
}
|
|
101
|
+
await new Promise((r) => setTimeout(r, intervalMs));
|
|
102
|
+
}
|
|
103
|
+
throw new Error(`Batch job ${jobId} timed out after ${maxWaitMs}ms`);
|
|
104
|
+
}
|
|
105
|
+
// ── Monitoring ─────────────────────────────────────────────
|
|
106
|
+
/** Add an entity to continuous monitoring. */
|
|
107
|
+
async addMonitoredEntity(input) {
|
|
108
|
+
return this.request("POST", "/v1/monitor/entities", input);
|
|
109
|
+
}
|
|
110
|
+
/** List monitored entities. */
|
|
111
|
+
async listMonitoredEntities() {
|
|
112
|
+
return this.request("GET", "/v1/monitor/entities");
|
|
113
|
+
}
|
|
114
|
+
/** Remove an entity from monitoring. */
|
|
115
|
+
async removeMonitoredEntity(id) {
|
|
116
|
+
return this.request("DELETE", `/v1/monitor/entities/${id}`);
|
|
117
|
+
}
|
|
118
|
+
// ── Watchlists ─────────────────────────────────────────────
|
|
119
|
+
/** List active watchlist sources. */
|
|
120
|
+
async listWatchlists() {
|
|
121
|
+
return this.request("GET", "/v1/lists");
|
|
122
|
+
}
|
|
123
|
+
/** Get detailed status of a watchlist. */
|
|
124
|
+
async getWatchlistStatus(code) {
|
|
125
|
+
return this.request("GET", `/v1/lists/${code}/status`);
|
|
126
|
+
}
|
|
127
|
+
// ── API Keys ───────────────────────────────────────────────
|
|
128
|
+
/** Create a new API key. */
|
|
129
|
+
async createApiKey(input) {
|
|
130
|
+
return this.request("POST", "/v1/keys", input);
|
|
131
|
+
}
|
|
132
|
+
/** List API keys. */
|
|
133
|
+
async listApiKeys() {
|
|
134
|
+
return this.request("GET", "/v1/keys");
|
|
135
|
+
}
|
|
136
|
+
/** Revoke an API key. */
|
|
137
|
+
async revokeApiKey(id) {
|
|
138
|
+
return this.request("DELETE", `/v1/keys/${id}`);
|
|
139
|
+
}
|
|
140
|
+
// ── Organization ───────────────────────────────────────────
|
|
141
|
+
/** Get current organization details. */
|
|
142
|
+
async getOrg() {
|
|
143
|
+
return this.request("GET", "/v1/org");
|
|
144
|
+
}
|
|
145
|
+
/** Get usage stats for the current period. */
|
|
146
|
+
async getUsage(period) {
|
|
147
|
+
const query = period ? `?period=${period}` : "";
|
|
148
|
+
return this.request("GET", `/v1/org/usage${query}`);
|
|
149
|
+
}
|
|
150
|
+
// ── Webhooks ───────────────────────────────────────────────
|
|
151
|
+
/** Register a webhook. */
|
|
152
|
+
async createWebhook(input) {
|
|
153
|
+
return this.request("POST", "/v1/webhooks", input);
|
|
154
|
+
}
|
|
155
|
+
/** List webhooks. */
|
|
156
|
+
async listWebhooks() {
|
|
157
|
+
return this.request("GET", "/v1/webhooks");
|
|
158
|
+
}
|
|
159
|
+
/** Delete a webhook. */
|
|
160
|
+
async deleteWebhook(id) {
|
|
161
|
+
return this.request("DELETE", `/v1/webhooks/${id}`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
export default Vigil;
|
|
165
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA6BA,kEAAkE;AAClE,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnC,gEAAgE;IACzD,IAAI,CAAS;IACpB,wBAAwB;IACjB,MAAM,CAAS;IACtB,wCAAwC;IACjC,OAAO,CAA2B;IAEzC,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AgB,KAAK,EAAE,gBAAgB,KAAK,EAAE,CAAC,CAAC;IACrE,CAAC;IAED,8DAA8D;IAE9D,0BAA0B;IAC1B,KAAK,CAAC,aAAa,CACjB,KAA2B;QAE3B,OAAO,IAAI,CAAC,OAAO,CAAkB,MAAM,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC;IAED,qBAAqB;IACrB,KAAK,CAAC,YAAY;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC;IAC7C,CAAC;IAED,wBAAwB;IACxB,KAAK,CAAC,aAAa,CAAC,EAAU;QAC5B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;CACF;AA8BD,eAAe,KAAK,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vigilhq/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Official TypeScript/JavaScript SDK for the Vigil compliance screening API",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"typecheck": "tsc --noEmit",
|
|
18
|
+
"clean": "rm -rf dist"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@vigilhq/types": "workspace:^"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"typescript": "^5.7.0"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/ymatagne/vigil",
|
|
35
|
+
"directory": "packages/sdk-ts"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"vigil",
|
|
39
|
+
"sanctions",
|
|
40
|
+
"screening",
|
|
41
|
+
"compliance",
|
|
42
|
+
"aml",
|
|
43
|
+
"kyc",
|
|
44
|
+
"sdk"
|
|
45
|
+
]
|
|
46
|
+
}
|