@dominusnode/sdk 1.2.0 → 1.5.2
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 +186 -145
- package/dist/cjs/auth.js +8 -2
- package/dist/cjs/constants.d.ts +2 -2
- package/dist/cjs/constants.js +1 -1
- package/dist/cjs/http.js +12 -6
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/resources/agent-wallet.js +16 -6
- package/dist/cjs/resources/mpp.d.ts +4 -0
- package/dist/cjs/resources/mpp.js +12 -4
- package/dist/cjs/resources/teams.js +6 -2
- package/dist/cjs/wallet.js +9 -3
- package/dist/esm/auth.js +8 -2
- package/dist/esm/constants.d.ts +2 -2
- package/dist/esm/constants.js +1 -1
- package/dist/esm/http.js +12 -6
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/resources/agent-wallet.js +16 -6
- package/dist/esm/resources/mpp.d.ts +4 -0
- package/dist/esm/resources/mpp.js +11 -3
- package/dist/esm/resources/teams.js +6 -2
- package/dist/esm/wallet.js +9 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,22 +28,24 @@ pnpm add @dominusnode/sdk
|
|
|
28
28
|
## Quick Start
|
|
29
29
|
|
|
30
30
|
```typescript
|
|
31
|
-
import { DominusNodeClient } from
|
|
31
|
+
import { DominusNodeClient } from "@dominusnode/sdk";
|
|
32
32
|
|
|
33
33
|
// Connect with API key
|
|
34
|
-
const client = new DominusNodeClient({
|
|
35
|
-
|
|
34
|
+
const client = new DominusNodeClient({
|
|
35
|
+
baseUrl: "https://api.dominusnode.com",
|
|
36
|
+
});
|
|
37
|
+
await client.connectWithKey("dn_live_your_api_key");
|
|
36
38
|
|
|
37
39
|
// Check balance
|
|
38
40
|
const balance = await client.wallet.getBalance();
|
|
39
41
|
console.log(`Balance: $${balance.balanceUsd}`);
|
|
40
42
|
|
|
41
43
|
// Build proxy URL
|
|
42
|
-
const proxyUrl = client.proxy.buildUrl(
|
|
43
|
-
protocol:
|
|
44
|
-
country:
|
|
45
|
-
state:
|
|
46
|
-
city:
|
|
44
|
+
const proxyUrl = client.proxy.buildUrl("dn_live_your_key", {
|
|
45
|
+
protocol: "http",
|
|
46
|
+
country: "US",
|
|
47
|
+
state: "california",
|
|
48
|
+
city: "losangeles",
|
|
47
49
|
});
|
|
48
50
|
console.log(proxyUrl);
|
|
49
51
|
// => http://user-country-US-state-california-city-losangeles:dn_live_your_key@proxy.dominusnode.com:8080
|
|
@@ -58,8 +60,10 @@ The SDK supports three authentication modes. All authenticated requests automati
|
|
|
58
60
|
Best for server-side scripts and backend integrations. The key is exchanged for a JWT token pair on the first call.
|
|
59
61
|
|
|
60
62
|
```typescript
|
|
61
|
-
const client = new DominusNodeClient({
|
|
62
|
-
|
|
63
|
+
const client = new DominusNodeClient({
|
|
64
|
+
baseUrl: "https://api.dominusnode.com",
|
|
65
|
+
});
|
|
66
|
+
await client.connectWithKey("dn_live_your_api_key");
|
|
63
67
|
```
|
|
64
68
|
|
|
65
69
|
### Email + Password
|
|
@@ -67,12 +71,17 @@ await client.connectWithKey('dn_live_your_api_key');
|
|
|
67
71
|
Best for interactive applications where the user logs in with credentials. Supports MFA (TOTP or backup codes).
|
|
68
72
|
|
|
69
73
|
```typescript
|
|
70
|
-
const client = new DominusNodeClient({
|
|
71
|
-
|
|
74
|
+
const client = new DominusNodeClient({
|
|
75
|
+
baseUrl: "https://api.dominusnode.com",
|
|
76
|
+
});
|
|
77
|
+
const result = await client.connectWithCredentials(
|
|
78
|
+
"user@example.com",
|
|
79
|
+
"SecurePass123!",
|
|
80
|
+
);
|
|
72
81
|
|
|
73
82
|
if (result.mfaRequired) {
|
|
74
83
|
// User has 2FA enabled -- need TOTP code
|
|
75
|
-
await client.completeMfa(
|
|
84
|
+
await client.completeMfa("123456");
|
|
76
85
|
}
|
|
77
86
|
```
|
|
78
87
|
|
|
@@ -82,9 +91,9 @@ Use when you already have valid JWT tokens (e.g., stored from a previous session
|
|
|
82
91
|
|
|
83
92
|
```typescript
|
|
84
93
|
const client = new DominusNodeClient({
|
|
85
|
-
baseUrl:
|
|
86
|
-
accessToken:
|
|
87
|
-
refreshToken:
|
|
94
|
+
baseUrl: "https://api.dominusnode.com",
|
|
95
|
+
accessToken: "existing_jwt",
|
|
96
|
+
refreshToken: "existing_refresh_token",
|
|
88
97
|
});
|
|
89
98
|
```
|
|
90
99
|
|
|
@@ -93,20 +102,20 @@ const client = new DominusNodeClient({
|
|
|
93
102
|
Clear all stored tokens locally. Call `client.auth.logout()` first if you also want to revoke refresh tokens server-side.
|
|
94
103
|
|
|
95
104
|
```typescript
|
|
96
|
-
await client.auth.logout();
|
|
97
|
-
client.disconnect();
|
|
105
|
+
await client.auth.logout(); // Revoke server-side refresh tokens
|
|
106
|
+
client.disconnect(); // Clear local token state
|
|
98
107
|
```
|
|
99
108
|
|
|
100
109
|
## Configuration
|
|
101
110
|
|
|
102
111
|
```typescript
|
|
103
112
|
interface DominusNodeConfig {
|
|
104
|
-
baseUrl?: string;
|
|
105
|
-
accessToken?: string;
|
|
106
|
-
refreshToken?: string;
|
|
107
|
-
proxyHost?: string;
|
|
108
|
-
httpProxyPort?: number;
|
|
109
|
-
socks5ProxyPort?: number;
|
|
113
|
+
baseUrl?: string; // Default: 'https://api.dominusnode.com'
|
|
114
|
+
accessToken?: string; // Pre-existing access token
|
|
115
|
+
refreshToken?: string; // Pre-existing refresh token
|
|
116
|
+
proxyHost?: string; // Default: 'proxy.dominusnode.com'
|
|
117
|
+
httpProxyPort?: number; // Default: 8080
|
|
118
|
+
socks5ProxyPort?: number; // Default: 1080
|
|
110
119
|
}
|
|
111
120
|
```
|
|
112
121
|
|
|
@@ -122,33 +131,36 @@ Registration, login, MFA management, password changes, and session introspection
|
|
|
122
131
|
|
|
123
132
|
```typescript
|
|
124
133
|
// Register a new account
|
|
125
|
-
const { user } = await client.auth.register(
|
|
134
|
+
const { user } = await client.auth.register(
|
|
135
|
+
"user@example.com",
|
|
136
|
+
"SecurePass123!",
|
|
137
|
+
);
|
|
126
138
|
|
|
127
139
|
// Login (returns token + user, or mfaRequired flag)
|
|
128
|
-
const result = await client.auth.login(
|
|
140
|
+
const result = await client.auth.login("user@example.com", "SecurePass123!");
|
|
129
141
|
|
|
130
142
|
// MFA verify with TOTP code
|
|
131
|
-
await client.auth.verifyMfa(
|
|
143
|
+
await client.auth.verifyMfa("123456");
|
|
132
144
|
|
|
133
145
|
// MFA verify with backup code
|
|
134
|
-
await client.auth.verifyMfa(
|
|
146
|
+
await client.auth.verifyMfa("12345678", { isBackupCode: true });
|
|
135
147
|
|
|
136
148
|
// MFA setup -- returns secret, otpauthUri, and backup codes
|
|
137
149
|
const setup = await client.auth.mfaSetup();
|
|
138
150
|
// setup.secret, setup.otpauthUri, setup.backupCodes
|
|
139
151
|
|
|
140
152
|
// MFA enable (confirm with a valid TOTP code)
|
|
141
|
-
await client.auth.mfaEnable(
|
|
153
|
+
await client.auth.mfaEnable("123456");
|
|
142
154
|
|
|
143
155
|
// MFA disable (requires current password + TOTP code)
|
|
144
|
-
await client.auth.mfaDisable(
|
|
156
|
+
await client.auth.mfaDisable("password", "123456");
|
|
145
157
|
|
|
146
158
|
// MFA status
|
|
147
159
|
const status = await client.auth.mfaStatus();
|
|
148
160
|
// status.enabled, status.backupCodesRemaining
|
|
149
161
|
|
|
150
162
|
// Change password
|
|
151
|
-
await client.auth.changePassword(
|
|
163
|
+
await client.auth.changePassword("oldpass", "newpass");
|
|
152
164
|
|
|
153
165
|
// Logout (revokes refresh tokens server-side)
|
|
154
166
|
await client.auth.logout();
|
|
@@ -164,7 +176,7 @@ Create, list, and revoke API keys. API keys use the `dn_live_` prefix and are au
|
|
|
164
176
|
|
|
165
177
|
```typescript
|
|
166
178
|
// Create a new API key
|
|
167
|
-
const key = await client.keys.create(
|
|
179
|
+
const key = await client.keys.create("my-scraper");
|
|
168
180
|
// key.key is the full API key (dn_live_xxx) -- shown only once, save it!
|
|
169
181
|
// key.id, key.prefix, key.label, key.created_at
|
|
170
182
|
|
|
@@ -173,7 +185,7 @@ const keys = await client.keys.list();
|
|
|
173
185
|
// keys.keys[0].id, .prefix, .label, .created_at, .revoked_at
|
|
174
186
|
|
|
175
187
|
// Revoke an API key by ID
|
|
176
|
-
await client.keys.revoke(
|
|
188
|
+
await client.keys.revoke("key-id");
|
|
177
189
|
```
|
|
178
190
|
|
|
179
191
|
### Wallet
|
|
@@ -202,7 +214,7 @@ const checkout = await client.wallet.topUpStripe(1000); // $10.00
|
|
|
202
214
|
// checkout.sessionId -- Stripe session ID
|
|
203
215
|
|
|
204
216
|
// Top up with crypto (amount in cents, currency code)
|
|
205
|
-
const invoice = await client.wallet.topUpCrypto(1000,
|
|
217
|
+
const invoice = await client.wallet.topUpCrypto(1000, "btc");
|
|
206
218
|
// invoice.invoiceId -- NOWPayments invoice ID
|
|
207
219
|
// invoice.invoiceUrl -- redirect user to pay
|
|
208
220
|
// invoice.payCurrency -- e.g., "btc"
|
|
@@ -222,14 +234,21 @@ Query usage records, daily breakdowns, top hosts, and export data as CSV.
|
|
|
222
234
|
|
|
223
235
|
```typescript
|
|
224
236
|
// Usage records with summary (paginated, filterable by date)
|
|
225
|
-
const usage = await client.usage.get({
|
|
237
|
+
const usage = await client.usage.get({
|
|
238
|
+
from: "2024-01-01",
|
|
239
|
+
to: "2024-01-31",
|
|
240
|
+
limit: 100,
|
|
241
|
+
});
|
|
226
242
|
// usage.summary.totalBytes, .totalCostCents, .requestCount, .totalGB, .totalCostUsd
|
|
227
243
|
// usage.records[0].bytesIn, .bytesOut, .totalBytes, .costCents, .targetHost, .createdAt
|
|
228
244
|
// usage.pagination.limit, .offset, .total
|
|
229
245
|
// usage.period.since, .until
|
|
230
246
|
|
|
231
247
|
// Daily breakdown (for charts)
|
|
232
|
-
const daily = await client.usage.getDaily({
|
|
248
|
+
const daily = await client.usage.getDaily({
|
|
249
|
+
from: "2024-01-01",
|
|
250
|
+
to: "2024-01-31",
|
|
251
|
+
});
|
|
233
252
|
// daily.days[0].date, .totalBytes, .totalGB, .totalCostCents, .totalCostUsd, .requestCount
|
|
234
253
|
|
|
235
254
|
// Top target hosts by bandwidth
|
|
@@ -237,7 +256,10 @@ const hosts = await client.usage.getTopHosts({ limit: 10 });
|
|
|
237
256
|
// hosts.hosts[0].targetHost, .totalBytes, .totalGB, .requestCount
|
|
238
257
|
|
|
239
258
|
// CSV export
|
|
240
|
-
const csv = await client.usage.exportCsv({
|
|
259
|
+
const csv = await client.usage.exportCsv({
|
|
260
|
+
from: "2024-01-01",
|
|
261
|
+
to: "2024-01-31",
|
|
262
|
+
});
|
|
241
263
|
// csv is a raw CSV string
|
|
242
264
|
```
|
|
243
265
|
|
|
@@ -257,7 +279,7 @@ const plan = await client.plans.getUserPlan();
|
|
|
257
279
|
// plan.usage.monthlyUsageBytes, .monthlyUsageGB, .limitBytes, .limitGB, .percentUsed
|
|
258
280
|
|
|
259
281
|
// Change plan
|
|
260
|
-
const result = await client.plans.changePlan(
|
|
282
|
+
const result = await client.plans.changePlan("vol100");
|
|
261
283
|
// result.message, result.plan
|
|
262
284
|
```
|
|
263
285
|
|
|
@@ -277,24 +299,24 @@ Build proxy URLs for direct use with HTTP clients, and query proxy health/status
|
|
|
277
299
|
|
|
278
300
|
```typescript
|
|
279
301
|
// Build a basic HTTP proxy URL (no network call -- pure string construction)
|
|
280
|
-
const httpUrl = client.proxy.buildUrl(
|
|
302
|
+
const httpUrl = client.proxy.buildUrl("dn_live_key");
|
|
281
303
|
// => http://user:dn_live_key@proxy.dominusnode.com:8080
|
|
282
304
|
|
|
283
305
|
// Build a SOCKS5 proxy URL
|
|
284
|
-
const socksUrl = client.proxy.buildUrl(
|
|
306
|
+
const socksUrl = client.proxy.buildUrl("dn_live_key", { protocol: "socks5" });
|
|
285
307
|
// => socks5://user:dn_live_key@proxy.dominusnode.com:1080
|
|
286
308
|
|
|
287
309
|
// Geo-targeted with sticky session
|
|
288
|
-
const geoUrl = client.proxy.buildUrl(
|
|
289
|
-
country:
|
|
290
|
-
state:
|
|
291
|
-
city:
|
|
292
|
-
sessionId:
|
|
310
|
+
const geoUrl = client.proxy.buildUrl("dn_live_key", {
|
|
311
|
+
country: "US",
|
|
312
|
+
state: "california",
|
|
313
|
+
city: "losangeles",
|
|
314
|
+
sessionId: "sticky123",
|
|
293
315
|
});
|
|
294
316
|
// => http://user-country-US-state-california-city-losangeles-session-sticky123:dn_live_key@proxy.dominusnode.com:8080
|
|
295
317
|
|
|
296
318
|
// ASN targeting
|
|
297
|
-
const asnUrl = client.proxy.buildUrl(
|
|
319
|
+
const asnUrl = client.proxy.buildUrl("dn_live_key", { asn: 7922 });
|
|
298
320
|
// => http://user-asn-7922:dn_live_key@proxy.dominusnode.com:8080
|
|
299
321
|
|
|
300
322
|
// Proxy health (no auth required)
|
|
@@ -323,24 +345,30 @@ const users = await client.admin.listUsers({ page: 1, limit: 25 });
|
|
|
323
345
|
// users.pagination.page, .limit, .total, .totalPages
|
|
324
346
|
|
|
325
347
|
// Get a specific user
|
|
326
|
-
const user = await client.admin.getUser(
|
|
348
|
+
const user = await client.admin.getUser("user-id");
|
|
327
349
|
// user.user.id, .email, .status, ...
|
|
328
350
|
|
|
329
351
|
// Suspend a user account
|
|
330
|
-
await client.admin.suspendUser(
|
|
352
|
+
await client.admin.suspendUser("user-id");
|
|
331
353
|
|
|
332
354
|
// Reactivate a suspended user
|
|
333
|
-
await client.admin.activateUser(
|
|
355
|
+
await client.admin.activateUser("user-id");
|
|
334
356
|
|
|
335
357
|
// Soft-delete a user account
|
|
336
|
-
await client.admin.deleteUser(
|
|
358
|
+
await client.admin.deleteUser("user-id");
|
|
337
359
|
|
|
338
360
|
// Revenue statistics (filterable by date range)
|
|
339
|
-
const revenue = await client.admin.getRevenue({
|
|
361
|
+
const revenue = await client.admin.getRevenue({
|
|
362
|
+
since: "2024-01-01",
|
|
363
|
+
until: "2024-01-31",
|
|
364
|
+
});
|
|
340
365
|
// revenue.totalRevenueCents, .totalRevenueUsd, .avgTransactionCents, .transactionCount
|
|
341
366
|
|
|
342
367
|
// Daily revenue breakdown
|
|
343
|
-
const daily = await client.admin.getDailyRevenue({
|
|
368
|
+
const daily = await client.admin.getDailyRevenue({
|
|
369
|
+
since: "2024-01-01",
|
|
370
|
+
until: "2024-01-31",
|
|
371
|
+
});
|
|
344
372
|
// daily.days[0].date, .revenueCents, .revenueUsd
|
|
345
373
|
|
|
346
374
|
// System-wide statistics
|
|
@@ -360,17 +388,17 @@ import {
|
|
|
360
388
|
RateLimitError,
|
|
361
389
|
ValidationError,
|
|
362
390
|
NotFoundError,
|
|
363
|
-
} from
|
|
391
|
+
} from "@dominusnode/sdk";
|
|
364
392
|
|
|
365
393
|
try {
|
|
366
394
|
await client.wallet.getBalance();
|
|
367
395
|
} catch (err) {
|
|
368
396
|
if (err instanceof AuthenticationError) {
|
|
369
397
|
// 401 -- not authenticated or token refresh failed
|
|
370
|
-
console.error(
|
|
398
|
+
console.error("Not authenticated -- login or provide API key");
|
|
371
399
|
} else if (err instanceof InsufficientBalanceError) {
|
|
372
400
|
// 402 -- wallet balance too low
|
|
373
|
-
console.error(
|
|
401
|
+
console.error("Wallet balance too low -- top up first");
|
|
374
402
|
} else if (err instanceof RateLimitError) {
|
|
375
403
|
// 429 -- rate limited (SDK already retried once automatically)
|
|
376
404
|
console.error(`Rate limited -- retry after ${err.retryAfterSeconds}s`);
|
|
@@ -388,19 +416,19 @@ try {
|
|
|
388
416
|
|
|
389
417
|
All errors include a `statusCode` property (when applicable) and a descriptive `message`.
|
|
390
418
|
|
|
391
|
-
| Error Class
|
|
392
|
-
|
|
393
|
-
| `DominusNodeError`
|
|
394
|
-
| `AuthenticationError`
|
|
395
|
-
| `AuthorizationError`
|
|
396
|
-
| `InsufficientBalanceError` | 402
|
|
397
|
-
| `RateLimitError`
|
|
398
|
-
| `ValidationError`
|
|
399
|
-
| `NotFoundError`
|
|
400
|
-
| `ConflictError`
|
|
401
|
-
| `ServerError`
|
|
402
|
-
| `NetworkError`
|
|
403
|
-
| `ProxyError`
|
|
419
|
+
| Error Class | HTTP Status | Description |
|
|
420
|
+
| -------------------------- | ----------- | ----------------------------------------------------------------- |
|
|
421
|
+
| `DominusNodeError` | (varies) | Base class for all SDK errors |
|
|
422
|
+
| `AuthenticationError` | 401 | Invalid credentials or expired/revoked tokens |
|
|
423
|
+
| `AuthorizationError` | 403 | Insufficient permissions (e.g., non-admin accessing admin routes) |
|
|
424
|
+
| `InsufficientBalanceError` | 402 | Wallet balance too low for the operation |
|
|
425
|
+
| `RateLimitError` | 429 | Too many requests -- has `retryAfterSeconds` property |
|
|
426
|
+
| `ValidationError` | 400 | Invalid request parameters |
|
|
427
|
+
| `NotFoundError` | 404 | Requested resource does not exist |
|
|
428
|
+
| `ConflictError` | 409 | Resource conflict (e.g., duplicate email registration) |
|
|
429
|
+
| `ServerError` | 500+ | Server-side error |
|
|
430
|
+
| `NetworkError` | -- | Connection failure, DNS resolution error, or timeout |
|
|
431
|
+
| `ProxyError` | -- | Proxy-specific error -- has optional `proxyErrorCode` property |
|
|
404
432
|
|
|
405
433
|
## Using the Proxy URL
|
|
406
434
|
|
|
@@ -409,16 +437,18 @@ The `proxy.buildUrl()` method returns a standard proxy URL string that works wit
|
|
|
409
437
|
### With undici (ProxyAgent)
|
|
410
438
|
|
|
411
439
|
```typescript
|
|
412
|
-
import { DominusNodeClient } from
|
|
413
|
-
import { ProxyAgent } from
|
|
440
|
+
import { DominusNodeClient } from "@dominusnode/sdk";
|
|
441
|
+
import { ProxyAgent } from "undici";
|
|
414
442
|
|
|
415
|
-
const client = new DominusNodeClient({
|
|
416
|
-
|
|
443
|
+
const client = new DominusNodeClient({
|
|
444
|
+
baseUrl: "https://api.dominusnode.com",
|
|
445
|
+
});
|
|
446
|
+
await client.connectWithKey("dn_live_key");
|
|
417
447
|
|
|
418
|
-
const proxyUrl = client.proxy.buildUrl(
|
|
448
|
+
const proxyUrl = client.proxy.buildUrl("dn_live_key", { country: "US" });
|
|
419
449
|
const agent = new ProxyAgent(proxyUrl);
|
|
420
450
|
|
|
421
|
-
const response = await fetch(
|
|
451
|
+
const response = await fetch("http://httpbin.org/ip", { dispatcher: agent });
|
|
422
452
|
const data = await response.json();
|
|
423
453
|
console.log(data.origin); // US IP address
|
|
424
454
|
```
|
|
@@ -433,13 +463,15 @@ curl -x http://user:dn_live_your_key@proxy.dominusnode.com:8080 https://httpbin.
|
|
|
433
463
|
### With axios
|
|
434
464
|
|
|
435
465
|
```typescript
|
|
436
|
-
import axios from
|
|
437
|
-
import { HttpsProxyAgent } from
|
|
466
|
+
import axios from "axios";
|
|
467
|
+
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
438
468
|
|
|
439
|
-
const proxyUrl = client.proxy.buildUrl(
|
|
469
|
+
const proxyUrl = client.proxy.buildUrl("dn_live_key", { country: "DE" });
|
|
440
470
|
const agent = new HttpsProxyAgent(proxyUrl);
|
|
441
471
|
|
|
442
|
-
const { data } = await axios.get(
|
|
472
|
+
const { data } = await axios.get("https://httpbin.org/ip", {
|
|
473
|
+
httpsAgent: agent,
|
|
474
|
+
});
|
|
443
475
|
console.log(data.origin); // German IP address
|
|
444
476
|
```
|
|
445
477
|
|
|
@@ -447,14 +479,14 @@ console.log(data.origin); // German IP address
|
|
|
447
479
|
|
|
448
480
|
The proxy URL username field encodes geo-targeting and session parameters using the format `user-param_value-param_value`:
|
|
449
481
|
|
|
450
|
-
| Option
|
|
451
|
-
|
|
452
|
-
| `protocol`
|
|
453
|
-
| `country`
|
|
454
|
-
| `state`
|
|
455
|
-
| `city`
|
|
456
|
-
| `asn`
|
|
457
|
-
| `sessionId` | `string`
|
|
482
|
+
| Option | Type | Description | Example |
|
|
483
|
+
| ----------- | ---------------------- | ---------------------------------- | ------------------------- |
|
|
484
|
+
| `protocol` | `"http"` or `"socks5"` | Proxy protocol (default: `"http"`) | `{ protocol: 'socks5' }` |
|
|
485
|
+
| `country` | `string` | ISO 3166-1 alpha-2 country code | `{ country: 'US' }` |
|
|
486
|
+
| `state` | `string` | State or region name | `{ state: 'california' }` |
|
|
487
|
+
| `city` | `string` | City name (no spaces) | `{ city: 'losangeles' }` |
|
|
488
|
+
| `asn` | `number` | Autonomous System Number | `{ asn: 7922 }` |
|
|
489
|
+
| `sessionId` | `string` | Sticky session identifier | `{ sessionId: 'abc123' }` |
|
|
458
490
|
|
|
459
491
|
## Auto Token Refresh
|
|
460
492
|
|
|
@@ -527,7 +559,7 @@ import type {
|
|
|
527
559
|
RevenueResponse,
|
|
528
560
|
DailyRevenueEntry,
|
|
529
561
|
DailyRevenueResponse,
|
|
530
|
-
} from
|
|
562
|
+
} from "@dominusnode/sdk";
|
|
531
563
|
```
|
|
532
564
|
|
|
533
565
|
## CommonJS Usage
|
|
@@ -535,11 +567,13 @@ import type {
|
|
|
535
567
|
The SDK ships dual CJS + ESM builds. CommonJS usage works with `require()`:
|
|
536
568
|
|
|
537
569
|
```javascript
|
|
538
|
-
const { DominusNodeClient } = require(
|
|
570
|
+
const { DominusNodeClient } = require("@dominusnode/sdk");
|
|
539
571
|
|
|
540
572
|
async function main() {
|
|
541
|
-
const client = new DominusNodeClient({
|
|
542
|
-
|
|
573
|
+
const client = new DominusNodeClient({
|
|
574
|
+
baseUrl: "https://api.dominusnode.com",
|
|
575
|
+
});
|
|
576
|
+
await client.connectWithKey("dn_live_your_key");
|
|
543
577
|
|
|
544
578
|
const balance = await client.wallet.getBalance();
|
|
545
579
|
console.log(`Balance: $${balance.balanceUsd}`);
|
|
@@ -551,20 +585,24 @@ main().catch(console.error);
|
|
|
551
585
|
## Complete Example
|
|
552
586
|
|
|
553
587
|
```typescript
|
|
554
|
-
import {
|
|
588
|
+
import {
|
|
589
|
+
DominusNodeClient,
|
|
590
|
+
AuthenticationError,
|
|
591
|
+
InsufficientBalanceError,
|
|
592
|
+
} from "@dominusnode/sdk";
|
|
555
593
|
|
|
556
594
|
async function main() {
|
|
557
595
|
// Initialize client
|
|
558
596
|
const client = new DominusNodeClient({
|
|
559
|
-
baseUrl:
|
|
560
|
-
proxyHost:
|
|
597
|
+
baseUrl: "https://api.dominusnode.com",
|
|
598
|
+
proxyHost: "proxy.dominusnode.com",
|
|
561
599
|
httpProxyPort: 8080,
|
|
562
600
|
socks5ProxyPort: 1080,
|
|
563
601
|
});
|
|
564
602
|
|
|
565
603
|
try {
|
|
566
604
|
// Authenticate
|
|
567
|
-
await client.connectWithKey(
|
|
605
|
+
await client.connectWithKey("dn_live_your_api_key");
|
|
568
606
|
|
|
569
607
|
// Check who we are
|
|
570
608
|
const { user } = await client.auth.me();
|
|
@@ -572,7 +610,9 @@ async function main() {
|
|
|
572
610
|
|
|
573
611
|
// Check balance
|
|
574
612
|
const balance = await client.wallet.getBalance();
|
|
575
|
-
console.log(
|
|
613
|
+
console.log(
|
|
614
|
+
`Balance: $${balance.balanceUsd} (${balance.balanceCents} cents)`,
|
|
615
|
+
);
|
|
576
616
|
|
|
577
617
|
// If balance is low, create a Stripe checkout
|
|
578
618
|
if (balance.balanceCents < 500) {
|
|
@@ -593,26 +633,27 @@ async function main() {
|
|
|
593
633
|
|
|
594
634
|
// Get usage stats for this month
|
|
595
635
|
const now = new Date();
|
|
596
|
-
const firstOfMonth = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2,
|
|
636
|
+
const firstOfMonth = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-01`;
|
|
597
637
|
const usage = await client.usage.get({ from: firstOfMonth });
|
|
598
|
-
console.log(
|
|
638
|
+
console.log(
|
|
639
|
+
`This month: ${usage.summary.totalGB.toFixed(2)} GB, $${usage.summary.totalCostUsd}`,
|
|
640
|
+
);
|
|
599
641
|
|
|
600
642
|
// Build a geo-targeted proxy URL
|
|
601
|
-
const proxyUrl = client.proxy.buildUrl(
|
|
602
|
-
country:
|
|
603
|
-
state:
|
|
643
|
+
const proxyUrl = client.proxy.buildUrl("dn_live_your_api_key", {
|
|
644
|
+
country: "US",
|
|
645
|
+
state: "california",
|
|
604
646
|
});
|
|
605
647
|
console.log(`Proxy URL: ${proxyUrl}`);
|
|
606
648
|
|
|
607
649
|
// Check active sessions
|
|
608
650
|
const sessions = await client.sessions.getActive();
|
|
609
651
|
console.log(`Active sessions: ${sessions.sessions.length}`);
|
|
610
|
-
|
|
611
652
|
} catch (err) {
|
|
612
653
|
if (err instanceof AuthenticationError) {
|
|
613
|
-
console.error(
|
|
654
|
+
console.error("Authentication failed:", err.message);
|
|
614
655
|
} else if (err instanceof InsufficientBalanceError) {
|
|
615
|
-
console.error(
|
|
656
|
+
console.error("Insufficient balance:", err.message);
|
|
616
657
|
} else {
|
|
617
658
|
throw err;
|
|
618
659
|
}
|
|
@@ -626,48 +667,48 @@ main();
|
|
|
626
667
|
|
|
627
668
|
## API Reference Summary
|
|
628
669
|
|
|
629
|
-
| Resource
|
|
630
|
-
|
|
631
|
-
| `auth`
|
|
632
|
-
| `auth`
|
|
633
|
-
| `auth`
|
|
634
|
-
| `auth`
|
|
635
|
-
| `auth`
|
|
636
|
-
| `auth`
|
|
637
|
-
| `auth`
|
|
638
|
-
| `auth`
|
|
639
|
-
| `auth`
|
|
640
|
-
| `auth`
|
|
641
|
-
| `auth`
|
|
642
|
-
| `auth`
|
|
643
|
-
| `keys`
|
|
644
|
-
| `keys`
|
|
645
|
-
| `keys`
|
|
646
|
-
| `wallet`
|
|
647
|
-
| `wallet`
|
|
648
|
-
| `wallet`
|
|
649
|
-
| `wallet`
|
|
650
|
-
| `wallet`
|
|
651
|
-
| `usage`
|
|
652
|
-
| `usage`
|
|
653
|
-
| `usage`
|
|
654
|
-
| `usage`
|
|
655
|
-
| `plans`
|
|
656
|
-
| `plans`
|
|
657
|
-
| `plans`
|
|
658
|
-
| `sessions` | `getActive()`
|
|
659
|
-
| `proxy`
|
|
660
|
-
| `proxy`
|
|
661
|
-
| `proxy`
|
|
662
|
-
| `proxy`
|
|
663
|
-
| `admin`
|
|
664
|
-
| `admin`
|
|
665
|
-
| `admin`
|
|
666
|
-
| `admin`
|
|
667
|
-
| `admin`
|
|
668
|
-
| `admin`
|
|
669
|
-
| `admin`
|
|
670
|
-
| `admin`
|
|
670
|
+
| Resource | Method | Description |
|
|
671
|
+
| ---------- | ------------------------------------ | ----------------------------------------------- |
|
|
672
|
+
| `auth` | `register(email, password)` | Create a new account |
|
|
673
|
+
| `auth` | `login(email, password)` | Login with credentials |
|
|
674
|
+
| `auth` | `verifyMfa(code, opts?)` | Complete MFA verification |
|
|
675
|
+
| `auth` | `mfaSetup()` | Begin MFA setup (returns secret + backup codes) |
|
|
676
|
+
| `auth` | `mfaEnable(code)` | Confirm and enable MFA |
|
|
677
|
+
| `auth` | `mfaDisable(password, code)` | Disable MFA |
|
|
678
|
+
| `auth` | `mfaStatus()` | Check MFA status |
|
|
679
|
+
| `auth` | `changePassword(current, new)` | Change password |
|
|
680
|
+
| `auth` | `logout()` | Revoke refresh tokens server-side |
|
|
681
|
+
| `auth` | `me()` | Get current user info |
|
|
682
|
+
| `auth` | `verifyKey(apiKey)` | Exchange API key for JWT tokens |
|
|
683
|
+
| `auth` | `refresh(refreshToken)` | Refresh access token (used internally) |
|
|
684
|
+
| `keys` | `create(label?)` | Create a new API key |
|
|
685
|
+
| `keys` | `list()` | List all API keys |
|
|
686
|
+
| `keys` | `revoke(id)` | Revoke an API key |
|
|
687
|
+
| `wallet` | `getBalance()` | Get current balance |
|
|
688
|
+
| `wallet` | `getTransactions(opts?)` | Transaction history (paginated) |
|
|
689
|
+
| `wallet` | `topUpStripe(amountCents)` | Create Stripe checkout session |
|
|
690
|
+
| `wallet` | `topUpCrypto(amountCents, currency)` | Create crypto invoice |
|
|
691
|
+
| `wallet` | `getForecast()` | Spending forecast |
|
|
692
|
+
| `usage` | `get(opts?)` | Usage records with summary |
|
|
693
|
+
| `usage` | `getDaily(opts?)` | Daily usage aggregation |
|
|
694
|
+
| `usage` | `getTopHosts(opts?)` | Top target hosts by bandwidth |
|
|
695
|
+
| `usage` | `exportCsv(opts?)` | Export usage as CSV |
|
|
696
|
+
| `plans` | `list()` | List available plans |
|
|
697
|
+
| `plans` | `getUserPlan()` | Get current user's plan |
|
|
698
|
+
| `plans` | `changePlan(planId)` | Change plan |
|
|
699
|
+
| `sessions` | `getActive()` | Get active proxy sessions |
|
|
700
|
+
| `proxy` | `buildUrl(apiKey, opts?)` | Build proxy URL string (no network call) |
|
|
701
|
+
| `proxy` | `getHealth()` | Proxy health (no auth) |
|
|
702
|
+
| `proxy` | `getStatus()` | Proxy status with provider info |
|
|
703
|
+
| `proxy` | `getConfig()` | Proxy configuration |
|
|
704
|
+
| `admin` | `listUsers(opts?)` | List all users (paginated) |
|
|
705
|
+
| `admin` | `getUser(id)` | Get user details |
|
|
706
|
+
| `admin` | `suspendUser(id)` | Suspend a user |
|
|
707
|
+
| `admin` | `activateUser(id)` | Reactivate a user |
|
|
708
|
+
| `admin` | `deleteUser(id)` | Soft-delete a user |
|
|
709
|
+
| `admin` | `getRevenue(opts?)` | Revenue statistics |
|
|
710
|
+
| `admin` | `getDailyRevenue(opts?)` | Daily revenue breakdown |
|
|
711
|
+
| `admin` | `getStats()` | System-wide statistics |
|
|
671
712
|
|
|
672
713
|
## Requirements
|
|
673
714
|
|
package/dist/cjs/auth.js
CHANGED
|
@@ -64,7 +64,10 @@ class AuthResource {
|
|
|
64
64
|
const { challengeId, prefix } = challenge;
|
|
65
65
|
const difficulty = Math.min(challenge.difficulty, 32);
|
|
66
66
|
for (let nonce = 0; nonce < POW_MAX_NONCE; nonce++) {
|
|
67
|
-
const hash = crypto
|
|
67
|
+
const hash = crypto
|
|
68
|
+
.createHash("sha256")
|
|
69
|
+
.update(prefix + nonce)
|
|
70
|
+
.digest();
|
|
68
71
|
if (countLeadingZeroBits(hash) >= difficulty) {
|
|
69
72
|
return { challengeId, nonce };
|
|
70
73
|
}
|
|
@@ -99,7 +102,10 @@ class AuthResource {
|
|
|
99
102
|
return this.http.get("/api/auth/me");
|
|
100
103
|
}
|
|
101
104
|
async changePassword(currentPassword, newPassword) {
|
|
102
|
-
await this.http.post("/api/auth/change-password", {
|
|
105
|
+
await this.http.post("/api/auth/change-password", {
|
|
106
|
+
currentPassword,
|
|
107
|
+
newPassword,
|
|
108
|
+
});
|
|
103
109
|
}
|
|
104
110
|
async verifyKey(apiKey) {
|
|
105
111
|
return this.http.post("/api/auth/verify-key", { apiKey }, false);
|
package/dist/cjs/constants.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.
|
|
2
|
-
export declare const USER_AGENT = "dominusnode-sdk-node/1.
|
|
1
|
+
export declare const SDK_VERSION = "1.5.2";
|
|
2
|
+
export declare const USER_AGENT = "dominusnode-sdk-node/1.5.2";
|
|
3
3
|
export declare const DEFAULT_BASE_URL = "https://api.dominusnode.com";
|
|
4
4
|
export declare const DEFAULT_PROXY_HOST = "proxy.dominusnode.com";
|
|
5
5
|
export declare const DEFAULT_HTTP_PROXY_PORT = 8080;
|
package/dist/cjs/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MAX_RATE_LIMIT_RETRIES = exports.TOKEN_REFRESH_BUFFER_MS = exports.DEFAULT_SOCKS5_PROXY_PORT = exports.DEFAULT_HTTP_PROXY_PORT = exports.DEFAULT_PROXY_HOST = exports.DEFAULT_BASE_URL = exports.USER_AGENT = exports.SDK_VERSION = void 0;
|
|
4
|
-
exports.SDK_VERSION = "1.
|
|
4
|
+
exports.SDK_VERSION = "1.5.2";
|
|
5
5
|
exports.USER_AGENT = `dominusnode-sdk-node/${exports.SDK_VERSION}`;
|
|
6
6
|
exports.DEFAULT_BASE_URL = "https://api.dominusnode.com";
|
|
7
7
|
exports.DEFAULT_PROXY_HOST = "proxy.dominusnode.com";
|
package/dist/cjs/http.js
CHANGED
|
@@ -48,12 +48,18 @@ function throwForStatus(status, body, headers) {
|
|
|
48
48
|
if (message.length > 500)
|
|
49
49
|
message = message.slice(0, 500) + "... [truncated]";
|
|
50
50
|
switch (status) {
|
|
51
|
-
case 400:
|
|
52
|
-
|
|
53
|
-
case
|
|
54
|
-
|
|
55
|
-
case
|
|
56
|
-
|
|
51
|
+
case 400:
|
|
52
|
+
throw new errors_js_1.ValidationError(message);
|
|
53
|
+
case 401:
|
|
54
|
+
throw new errors_js_1.AuthenticationError(message);
|
|
55
|
+
case 402:
|
|
56
|
+
throw new errors_js_1.InsufficientBalanceError(message);
|
|
57
|
+
case 403:
|
|
58
|
+
throw new errors_js_1.AuthorizationError(message);
|
|
59
|
+
case 404:
|
|
60
|
+
throw new errors_js_1.NotFoundError(message);
|
|
61
|
+
case 409:
|
|
62
|
+
throw new errors_js_1.ConflictError(message);
|
|
57
63
|
case 429: {
|
|
58
64
|
const parsed = parseInt(headers.get("retry-after") ?? "60", 10);
|
|
59
65
|
const retryAfter = Number.isFinite(parsed) ? parsed : 60; // NaN guard
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export { AgenticWalletResource } from "./resources/agent-wallet.js";
|
|
|
18
18
|
export type { AgenticWallet, AgenticWalletTransaction, AgenticWalletListResponse, AgenticWalletFundResponse, AgenticWalletTransactionsResponse, AgenticWalletDeleteResponse, } from "./resources/agent-wallet.js";
|
|
19
19
|
export { TeamsResource } from "./resources/teams.js";
|
|
20
20
|
export type { Team, TeamMember, TeamInvite, TeamListResponse, TeamMembersResponse, TeamInvitesResponse, TeamKeysResponse, TeamKeyCreateResponse, TeamDeleteResponse, TeamFundResponse, TeamTransactionsResponse, } from "./resources/teams.js";
|
|
21
|
-
export { X402Resource, X402_PROTOCOL_VERSION, X402_HEADERS } from "./resources/x402.js";
|
|
21
|
+
export { X402Resource, X402_PROTOCOL_VERSION, X402_HEADERS, } from "./resources/x402.js";
|
|
22
22
|
export type { X402Info, X402Facilitator, X402PaymentHeaders, X402Pricing, X402Scheme, X402Token, } from "./resources/x402.js";
|
|
23
23
|
export { WalletAuthResource } from "./resources/wallet-auth.js";
|
|
24
24
|
export type { WalletChallenge, WalletVerifyResult, WalletLinkResult, } from "./resources/wallet-auth.js";
|
|
@@ -7,11 +7,16 @@ class AgenticWalletResource {
|
|
|
7
7
|
this.http = http;
|
|
8
8
|
}
|
|
9
9
|
async create(label, spendingLimitCents = 10000, options) {
|
|
10
|
-
if (!Number.isInteger(spendingLimitCents) ||
|
|
10
|
+
if (!Number.isInteger(spendingLimitCents) ||
|
|
11
|
+
spendingLimitCents < 0 ||
|
|
12
|
+
spendingLimitCents > 2_147_483_647) {
|
|
11
13
|
throw new Error("spendingLimitCents must be a non-negative integer <= 2,147,483,647");
|
|
12
14
|
}
|
|
13
|
-
if (options?.dailyLimitCents !== undefined &&
|
|
14
|
-
|
|
15
|
+
if (options?.dailyLimitCents !== undefined &&
|
|
16
|
+
options.dailyLimitCents !== null) {
|
|
17
|
+
if (!Number.isInteger(options.dailyLimitCents) ||
|
|
18
|
+
options.dailyLimitCents < 0 ||
|
|
19
|
+
options.dailyLimitCents > 2_147_483_647) {
|
|
15
20
|
throw new Error("dailyLimitCents must be a non-negative integer <= 2,147,483,647");
|
|
16
21
|
}
|
|
17
22
|
}
|
|
@@ -29,14 +34,19 @@ class AgenticWalletResource {
|
|
|
29
34
|
return this.http.get(`/api/agent-wallet/${encodeURIComponent(walletId)}`);
|
|
30
35
|
}
|
|
31
36
|
async fund(walletId, amountCents) {
|
|
32
|
-
if (!Number.isInteger(amountCents) ||
|
|
37
|
+
if (!Number.isInteger(amountCents) ||
|
|
38
|
+
amountCents <= 0 ||
|
|
39
|
+
amountCents > 2_147_483_647) {
|
|
33
40
|
throw new Error("amountCents must be a positive integer <= 2,147,483,647");
|
|
34
41
|
}
|
|
35
42
|
return this.http.post(`/api/agent-wallet/${encodeURIComponent(walletId)}/fund`, { amountCents });
|
|
36
43
|
}
|
|
37
44
|
async updateWalletPolicy(walletId, policy) {
|
|
38
|
-
if (policy.dailyLimitCents !== undefined &&
|
|
39
|
-
|
|
45
|
+
if (policy.dailyLimitCents !== undefined &&
|
|
46
|
+
policy.dailyLimitCents !== null) {
|
|
47
|
+
if (!Number.isInteger(policy.dailyLimitCents) ||
|
|
48
|
+
policy.dailyLimitCents < 0 ||
|
|
49
|
+
policy.dailyLimitCents > 2_147_483_647) {
|
|
40
50
|
throw new Error("dailyLimitCents must be a non-negative integer <= 2,147,483,647");
|
|
41
51
|
}
|
|
42
52
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { HttpClient } from "../http.js";
|
|
2
|
+
/** IETF MPP auth scheme name (official spec) */
|
|
3
|
+
export declare const MPP_AUTH_SCHEME = "Payment";
|
|
4
|
+
/** Legacy auth scheme name (backward compat) */
|
|
5
|
+
export declare const MPP_AUTH_SCHEME_LEGACY = "MPP";
|
|
2
6
|
export interface MppInfo {
|
|
3
7
|
supported: boolean;
|
|
4
8
|
enabled: boolean;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MppResource = void 0;
|
|
3
|
+
exports.MppResource = exports.MPP_AUTH_SCHEME_LEGACY = exports.MPP_AUTH_SCHEME = void 0;
|
|
4
|
+
/** IETF MPP auth scheme name (official spec) */
|
|
5
|
+
exports.MPP_AUTH_SCHEME = "Payment";
|
|
6
|
+
/** Legacy auth scheme name (backward compat) */
|
|
7
|
+
exports.MPP_AUTH_SCHEME_LEGACY = "MPP";
|
|
4
8
|
/**
|
|
5
9
|
* Micropayment Payment Protocol (MPP) resource.
|
|
6
10
|
*
|
|
@@ -49,7 +53,7 @@ class MppResource {
|
|
|
49
53
|
*/
|
|
50
54
|
buildProxyHeaders(credential) {
|
|
51
55
|
return {
|
|
52
|
-
Authorization: "
|
|
56
|
+
Authorization: exports.MPP_AUTH_SCHEME + " " + JSON.stringify(credential),
|
|
53
57
|
};
|
|
54
58
|
}
|
|
55
59
|
/**
|
|
@@ -78,7 +82,9 @@ class MppResource {
|
|
|
78
82
|
* @param method - Payment method: "tempo", "stripe_spt", or "lightning"
|
|
79
83
|
*/
|
|
80
84
|
async topUp(amountCents, method) {
|
|
81
|
-
if (!Number.isInteger(amountCents) ||
|
|
85
|
+
if (!Number.isInteger(amountCents) ||
|
|
86
|
+
amountCents <= 0 ||
|
|
87
|
+
amountCents > 2_147_483_647) {
|
|
82
88
|
throw new Error("amountCents must be a positive integer <= 2,147,483,647");
|
|
83
89
|
}
|
|
84
90
|
return this.http.post("/api/mpp/topup", { amountCents, method });
|
|
@@ -94,7 +100,9 @@ class MppResource {
|
|
|
94
100
|
* @param opts.poolType - Proxy pool type (e.g. "dc", "residential")
|
|
95
101
|
*/
|
|
96
102
|
async openSession(opts) {
|
|
97
|
-
if (!Number.isInteger(opts.maxDepositCents) ||
|
|
103
|
+
if (!Number.isInteger(opts.maxDepositCents) ||
|
|
104
|
+
opts.maxDepositCents <= 0 ||
|
|
105
|
+
opts.maxDepositCents > 2_147_483_647) {
|
|
98
106
|
throw new Error("maxDepositCents must be a positive integer <= 2,147,483,647");
|
|
99
107
|
}
|
|
100
108
|
return this.http.post("/api/mpp/session/open", {
|
|
@@ -25,7 +25,9 @@ class TeamsResource {
|
|
|
25
25
|
return this.http.delete(`/api/teams/${encodeURIComponent(teamId)}`);
|
|
26
26
|
}
|
|
27
27
|
async fundWallet(teamId, amountCents) {
|
|
28
|
-
if (!Number.isInteger(amountCents) ||
|
|
28
|
+
if (!Number.isInteger(amountCents) ||
|
|
29
|
+
amountCents <= 0 ||
|
|
30
|
+
amountCents > 2_147_483_647) {
|
|
29
31
|
throw new Error("amountCents must be a positive integer <= 2,147,483,647");
|
|
30
32
|
}
|
|
31
33
|
return this.http.post(`/api/teams/${encodeURIComponent(teamId)}/wallet/fund`, { amountCents });
|
|
@@ -70,7 +72,9 @@ class TeamsResource {
|
|
|
70
72
|
return this.http.post(`/api/teams/invites/${encodeURIComponent(token)}/accept`, {});
|
|
71
73
|
}
|
|
72
74
|
async createKey(teamId, label) {
|
|
73
|
-
return this.http.post(`/api/teams/${encodeURIComponent(teamId)}/keys`, {
|
|
75
|
+
return this.http.post(`/api/teams/${encodeURIComponent(teamId)}/keys`, {
|
|
76
|
+
label,
|
|
77
|
+
});
|
|
74
78
|
}
|
|
75
79
|
async listKeys(teamId) {
|
|
76
80
|
return this.http.get(`/api/teams/${encodeURIComponent(teamId)}/keys`);
|
package/dist/cjs/wallet.js
CHANGED
|
@@ -22,14 +22,18 @@ class WalletResource {
|
|
|
22
22
|
}
|
|
23
23
|
/** Create a Stripe checkout session for wallet top-up. */
|
|
24
24
|
async topUpStripe(amountCents) {
|
|
25
|
-
if (!Number.isInteger(amountCents) ||
|
|
25
|
+
if (!Number.isInteger(amountCents) ||
|
|
26
|
+
amountCents <= 0 ||
|
|
27
|
+
amountCents > 2_147_483_647) {
|
|
26
28
|
throw new Error("amountCents must be a positive integer <= 2,147,483,647");
|
|
27
29
|
}
|
|
28
30
|
return this.http.post("/api/wallet/topup/stripe", { amountCents });
|
|
29
31
|
}
|
|
30
32
|
/** Create a crypto invoice for wallet top-up. Minimum $10 (1000 cents). */
|
|
31
33
|
async topUpCrypto(amountCents, currency) {
|
|
32
|
-
if (!Number.isInteger(amountCents) ||
|
|
34
|
+
if (!Number.isInteger(amountCents) ||
|
|
35
|
+
amountCents <= 0 ||
|
|
36
|
+
amountCents > 2_147_483_647) {
|
|
33
37
|
throw new Error("amountCents must be a positive integer <= 2,147,483,647");
|
|
34
38
|
}
|
|
35
39
|
if (amountCents < 1000) {
|
|
@@ -40,7 +44,9 @@ class WalletResource {
|
|
|
40
44
|
}
|
|
41
45
|
/** Create a PayPal order for wallet top-up. Minimum $5 (500 cents). */
|
|
42
46
|
async topUpPaypal(amountCents) {
|
|
43
|
-
if (!Number.isInteger(amountCents) ||
|
|
47
|
+
if (!Number.isInteger(amountCents) ||
|
|
48
|
+
amountCents <= 0 ||
|
|
49
|
+
amountCents > 2_147_483_647) {
|
|
44
50
|
throw new Error("amountCents must be a positive integer <= 2,147,483,647");
|
|
45
51
|
}
|
|
46
52
|
if (amountCents < 500) {
|
package/dist/esm/auth.js
CHANGED
|
@@ -28,7 +28,10 @@ export class AuthResource {
|
|
|
28
28
|
const { challengeId, prefix } = challenge;
|
|
29
29
|
const difficulty = Math.min(challenge.difficulty, 32);
|
|
30
30
|
for (let nonce = 0; nonce < POW_MAX_NONCE; nonce++) {
|
|
31
|
-
const hash = crypto
|
|
31
|
+
const hash = crypto
|
|
32
|
+
.createHash("sha256")
|
|
33
|
+
.update(prefix + nonce)
|
|
34
|
+
.digest();
|
|
32
35
|
if (countLeadingZeroBits(hash) >= difficulty) {
|
|
33
36
|
return { challengeId, nonce };
|
|
34
37
|
}
|
|
@@ -63,7 +66,10 @@ export class AuthResource {
|
|
|
63
66
|
return this.http.get("/api/auth/me");
|
|
64
67
|
}
|
|
65
68
|
async changePassword(currentPassword, newPassword) {
|
|
66
|
-
await this.http.post("/api/auth/change-password", {
|
|
69
|
+
await this.http.post("/api/auth/change-password", {
|
|
70
|
+
currentPassword,
|
|
71
|
+
newPassword,
|
|
72
|
+
});
|
|
67
73
|
}
|
|
68
74
|
async verifyKey(apiKey) {
|
|
69
75
|
return this.http.post("/api/auth/verify-key", { apiKey }, false);
|
package/dist/esm/constants.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.
|
|
2
|
-
export declare const USER_AGENT = "dominusnode-sdk-node/1.
|
|
1
|
+
export declare const SDK_VERSION = "1.5.2";
|
|
2
|
+
export declare const USER_AGENT = "dominusnode-sdk-node/1.5.2";
|
|
3
3
|
export declare const DEFAULT_BASE_URL = "https://api.dominusnode.com";
|
|
4
4
|
export declare const DEFAULT_PROXY_HOST = "proxy.dominusnode.com";
|
|
5
5
|
export declare const DEFAULT_HTTP_PROXY_PORT = 8080;
|
package/dist/esm/constants.js
CHANGED
package/dist/esm/http.js
CHANGED
|
@@ -45,12 +45,18 @@ function throwForStatus(status, body, headers) {
|
|
|
45
45
|
if (message.length > 500)
|
|
46
46
|
message = message.slice(0, 500) + "... [truncated]";
|
|
47
47
|
switch (status) {
|
|
48
|
-
case 400:
|
|
49
|
-
|
|
50
|
-
case
|
|
51
|
-
|
|
52
|
-
case
|
|
53
|
-
|
|
48
|
+
case 400:
|
|
49
|
+
throw new ValidationError(message);
|
|
50
|
+
case 401:
|
|
51
|
+
throw new AuthenticationError(message);
|
|
52
|
+
case 402:
|
|
53
|
+
throw new InsufficientBalanceError(message);
|
|
54
|
+
case 403:
|
|
55
|
+
throw new AuthorizationError(message);
|
|
56
|
+
case 404:
|
|
57
|
+
throw new NotFoundError(message);
|
|
58
|
+
case 409:
|
|
59
|
+
throw new ConflictError(message);
|
|
54
60
|
case 429: {
|
|
55
61
|
const parsed = parseInt(headers.get("retry-after") ?? "60", 10);
|
|
56
62
|
const retryAfter = Number.isFinite(parsed) ? parsed : 60; // NaN guard
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export { AgenticWalletResource } from "./resources/agent-wallet.js";
|
|
|
18
18
|
export type { AgenticWallet, AgenticWalletTransaction, AgenticWalletListResponse, AgenticWalletFundResponse, AgenticWalletTransactionsResponse, AgenticWalletDeleteResponse, } from "./resources/agent-wallet.js";
|
|
19
19
|
export { TeamsResource } from "./resources/teams.js";
|
|
20
20
|
export type { Team, TeamMember, TeamInvite, TeamListResponse, TeamMembersResponse, TeamInvitesResponse, TeamKeysResponse, TeamKeyCreateResponse, TeamDeleteResponse, TeamFundResponse, TeamTransactionsResponse, } from "./resources/teams.js";
|
|
21
|
-
export { X402Resource, X402_PROTOCOL_VERSION, X402_HEADERS } from "./resources/x402.js";
|
|
21
|
+
export { X402Resource, X402_PROTOCOL_VERSION, X402_HEADERS, } from "./resources/x402.js";
|
|
22
22
|
export type { X402Info, X402Facilitator, X402PaymentHeaders, X402Pricing, X402Scheme, X402Token, } from "./resources/x402.js";
|
|
23
23
|
export { WalletAuthResource } from "./resources/wallet-auth.js";
|
|
24
24
|
export type { WalletChallenge, WalletVerifyResult, WalletLinkResult, } from "./resources/wallet-auth.js";
|
package/dist/esm/index.js
CHANGED
|
@@ -12,7 +12,7 @@ export { AdminResource } from "./admin.js";
|
|
|
12
12
|
export { SlotsResource } from "./slots.js";
|
|
13
13
|
export { AgenticWalletResource } from "./resources/agent-wallet.js";
|
|
14
14
|
export { TeamsResource } from "./resources/teams.js";
|
|
15
|
-
export { X402Resource, X402_PROTOCOL_VERSION, X402_HEADERS } from "./resources/x402.js";
|
|
15
|
+
export { X402Resource, X402_PROTOCOL_VERSION, X402_HEADERS, } from "./resources/x402.js";
|
|
16
16
|
export { WalletAuthResource } from "./resources/wallet-auth.js";
|
|
17
17
|
export { MppResource } from "./resources/mpp.js";
|
|
18
18
|
// Infrastructure (HttpClient for advanced custom integrations)
|
|
@@ -4,11 +4,16 @@ export class AgenticWalletResource {
|
|
|
4
4
|
this.http = http;
|
|
5
5
|
}
|
|
6
6
|
async create(label, spendingLimitCents = 10000, options) {
|
|
7
|
-
if (!Number.isInteger(spendingLimitCents) ||
|
|
7
|
+
if (!Number.isInteger(spendingLimitCents) ||
|
|
8
|
+
spendingLimitCents < 0 ||
|
|
9
|
+
spendingLimitCents > 2_147_483_647) {
|
|
8
10
|
throw new Error("spendingLimitCents must be a non-negative integer <= 2,147,483,647");
|
|
9
11
|
}
|
|
10
|
-
if (options?.dailyLimitCents !== undefined &&
|
|
11
|
-
|
|
12
|
+
if (options?.dailyLimitCents !== undefined &&
|
|
13
|
+
options.dailyLimitCents !== null) {
|
|
14
|
+
if (!Number.isInteger(options.dailyLimitCents) ||
|
|
15
|
+
options.dailyLimitCents < 0 ||
|
|
16
|
+
options.dailyLimitCents > 2_147_483_647) {
|
|
12
17
|
throw new Error("dailyLimitCents must be a non-negative integer <= 2,147,483,647");
|
|
13
18
|
}
|
|
14
19
|
}
|
|
@@ -26,14 +31,19 @@ export class AgenticWalletResource {
|
|
|
26
31
|
return this.http.get(`/api/agent-wallet/${encodeURIComponent(walletId)}`);
|
|
27
32
|
}
|
|
28
33
|
async fund(walletId, amountCents) {
|
|
29
|
-
if (!Number.isInteger(amountCents) ||
|
|
34
|
+
if (!Number.isInteger(amountCents) ||
|
|
35
|
+
amountCents <= 0 ||
|
|
36
|
+
amountCents > 2_147_483_647) {
|
|
30
37
|
throw new Error("amountCents must be a positive integer <= 2,147,483,647");
|
|
31
38
|
}
|
|
32
39
|
return this.http.post(`/api/agent-wallet/${encodeURIComponent(walletId)}/fund`, { amountCents });
|
|
33
40
|
}
|
|
34
41
|
async updateWalletPolicy(walletId, policy) {
|
|
35
|
-
if (policy.dailyLimitCents !== undefined &&
|
|
36
|
-
|
|
42
|
+
if (policy.dailyLimitCents !== undefined &&
|
|
43
|
+
policy.dailyLimitCents !== null) {
|
|
44
|
+
if (!Number.isInteger(policy.dailyLimitCents) ||
|
|
45
|
+
policy.dailyLimitCents < 0 ||
|
|
46
|
+
policy.dailyLimitCents > 2_147_483_647) {
|
|
37
47
|
throw new Error("dailyLimitCents must be a non-negative integer <= 2,147,483,647");
|
|
38
48
|
}
|
|
39
49
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { HttpClient } from "../http.js";
|
|
2
|
+
/** IETF MPP auth scheme name (official spec) */
|
|
3
|
+
export declare const MPP_AUTH_SCHEME = "Payment";
|
|
4
|
+
/** Legacy auth scheme name (backward compat) */
|
|
5
|
+
export declare const MPP_AUTH_SCHEME_LEGACY = "MPP";
|
|
2
6
|
export interface MppInfo {
|
|
3
7
|
supported: boolean;
|
|
4
8
|
enabled: boolean;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/** IETF MPP auth scheme name (official spec) */
|
|
2
|
+
export const MPP_AUTH_SCHEME = "Payment";
|
|
3
|
+
/** Legacy auth scheme name (backward compat) */
|
|
4
|
+
export const MPP_AUTH_SCHEME_LEGACY = "MPP";
|
|
1
5
|
/**
|
|
2
6
|
* Micropayment Payment Protocol (MPP) resource.
|
|
3
7
|
*
|
|
@@ -46,7 +50,7 @@ export class MppResource {
|
|
|
46
50
|
*/
|
|
47
51
|
buildProxyHeaders(credential) {
|
|
48
52
|
return {
|
|
49
|
-
Authorization: "
|
|
53
|
+
Authorization: MPP_AUTH_SCHEME + " " + JSON.stringify(credential),
|
|
50
54
|
};
|
|
51
55
|
}
|
|
52
56
|
/**
|
|
@@ -75,7 +79,9 @@ export class MppResource {
|
|
|
75
79
|
* @param method - Payment method: "tempo", "stripe_spt", or "lightning"
|
|
76
80
|
*/
|
|
77
81
|
async topUp(amountCents, method) {
|
|
78
|
-
if (!Number.isInteger(amountCents) ||
|
|
82
|
+
if (!Number.isInteger(amountCents) ||
|
|
83
|
+
amountCents <= 0 ||
|
|
84
|
+
amountCents > 2_147_483_647) {
|
|
79
85
|
throw new Error("amountCents must be a positive integer <= 2,147,483,647");
|
|
80
86
|
}
|
|
81
87
|
return this.http.post("/api/mpp/topup", { amountCents, method });
|
|
@@ -91,7 +97,9 @@ export class MppResource {
|
|
|
91
97
|
* @param opts.poolType - Proxy pool type (e.g. "dc", "residential")
|
|
92
98
|
*/
|
|
93
99
|
async openSession(opts) {
|
|
94
|
-
if (!Number.isInteger(opts.maxDepositCents) ||
|
|
100
|
+
if (!Number.isInteger(opts.maxDepositCents) ||
|
|
101
|
+
opts.maxDepositCents <= 0 ||
|
|
102
|
+
opts.maxDepositCents > 2_147_483_647) {
|
|
95
103
|
throw new Error("maxDepositCents must be a positive integer <= 2,147,483,647");
|
|
96
104
|
}
|
|
97
105
|
return this.http.post("/api/mpp/session/open", {
|
|
@@ -22,7 +22,9 @@ export class TeamsResource {
|
|
|
22
22
|
return this.http.delete(`/api/teams/${encodeURIComponent(teamId)}`);
|
|
23
23
|
}
|
|
24
24
|
async fundWallet(teamId, amountCents) {
|
|
25
|
-
if (!Number.isInteger(amountCents) ||
|
|
25
|
+
if (!Number.isInteger(amountCents) ||
|
|
26
|
+
amountCents <= 0 ||
|
|
27
|
+
amountCents > 2_147_483_647) {
|
|
26
28
|
throw new Error("amountCents must be a positive integer <= 2,147,483,647");
|
|
27
29
|
}
|
|
28
30
|
return this.http.post(`/api/teams/${encodeURIComponent(teamId)}/wallet/fund`, { amountCents });
|
|
@@ -67,7 +69,9 @@ export class TeamsResource {
|
|
|
67
69
|
return this.http.post(`/api/teams/invites/${encodeURIComponent(token)}/accept`, {});
|
|
68
70
|
}
|
|
69
71
|
async createKey(teamId, label) {
|
|
70
|
-
return this.http.post(`/api/teams/${encodeURIComponent(teamId)}/keys`, {
|
|
72
|
+
return this.http.post(`/api/teams/${encodeURIComponent(teamId)}/keys`, {
|
|
73
|
+
label,
|
|
74
|
+
});
|
|
71
75
|
}
|
|
72
76
|
async listKeys(teamId) {
|
|
73
77
|
return this.http.get(`/api/teams/${encodeURIComponent(teamId)}/keys`);
|
package/dist/esm/wallet.js
CHANGED
|
@@ -19,14 +19,18 @@ export class WalletResource {
|
|
|
19
19
|
}
|
|
20
20
|
/** Create a Stripe checkout session for wallet top-up. */
|
|
21
21
|
async topUpStripe(amountCents) {
|
|
22
|
-
if (!Number.isInteger(amountCents) ||
|
|
22
|
+
if (!Number.isInteger(amountCents) ||
|
|
23
|
+
amountCents <= 0 ||
|
|
24
|
+
amountCents > 2_147_483_647) {
|
|
23
25
|
throw new Error("amountCents must be a positive integer <= 2,147,483,647");
|
|
24
26
|
}
|
|
25
27
|
return this.http.post("/api/wallet/topup/stripe", { amountCents });
|
|
26
28
|
}
|
|
27
29
|
/** Create a crypto invoice for wallet top-up. Minimum $10 (1000 cents). */
|
|
28
30
|
async topUpCrypto(amountCents, currency) {
|
|
29
|
-
if (!Number.isInteger(amountCents) ||
|
|
31
|
+
if (!Number.isInteger(amountCents) ||
|
|
32
|
+
amountCents <= 0 ||
|
|
33
|
+
amountCents > 2_147_483_647) {
|
|
30
34
|
throw new Error("amountCents must be a positive integer <= 2,147,483,647");
|
|
31
35
|
}
|
|
32
36
|
if (amountCents < 1000) {
|
|
@@ -37,7 +41,9 @@ export class WalletResource {
|
|
|
37
41
|
}
|
|
38
42
|
/** Create a PayPal order for wallet top-up. Minimum $5 (500 cents). */
|
|
39
43
|
async topUpPaypal(amountCents) {
|
|
40
|
-
if (!Number.isInteger(amountCents) ||
|
|
44
|
+
if (!Number.isInteger(amountCents) ||
|
|
45
|
+
amountCents <= 0 ||
|
|
46
|
+
amountCents > 2_147_483_647) {
|
|
41
47
|
throw new Error("amountCents must be a positive integer <= 2,147,483,647");
|
|
42
48
|
}
|
|
43
49
|
if (amountCents < 500) {
|