@dominusnode/sdk 1.1.2 → 1.3.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 CHANGED
@@ -28,25 +28,27 @@ pnpm add @dominusnode/sdk
28
28
  ## Quick Start
29
29
 
30
30
  ```typescript
31
- import { DominusNodeClient } from '@dominusnode/sdk';
31
+ import { DominusNodeClient } from "@dominusnode/sdk";
32
32
 
33
33
  // Connect with API key
34
- const client = new DominusNodeClient({ baseUrl: 'https://api.dominusnode.com' });
35
- await client.connectWithKey('dn_live_your_api_key');
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('dn_live_your_key', {
43
- protocol: 'http',
44
- country: 'US',
45
- state: 'california',
46
- city: 'losangeles',
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
- // => http://user-country_US-state_california-city_losangeles:dn_live_your_key@proxy.dominusnode.com:8080
51
+ // => http://user-country-US-state-california-city-losangeles:dn_live_your_key@proxy.dominusnode.com:8080
50
52
  ```
51
53
 
52
54
  ## Authentication
@@ -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({ baseUrl: 'https://api.dominusnode.com' });
62
- await client.connectWithKey('dn_live_your_api_key');
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({ baseUrl: 'https://api.dominusnode.com' });
71
- const result = await client.connectWithCredentials('user@example.com', 'SecurePass123!');
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('123456');
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: 'https://api.dominusnode.com',
86
- accessToken: 'existing_jwt',
87
- refreshToken: 'existing_refresh_token',
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(); // Revoke server-side refresh tokens
97
- client.disconnect(); // Clear local token state
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; // Default: 'https://api.dominusnode.com'
105
- accessToken?: string; // Pre-existing access token
106
- refreshToken?: string; // Pre-existing refresh token
107
- proxyHost?: string; // Default: 'proxy.dominusnode.com'
108
- httpProxyPort?: number; // Default: 8080
109
- socks5ProxyPort?: number; // Default: 1080
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('user@example.com', 'SecurePass123!');
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('user@example.com', 'SecurePass123!');
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('123456');
143
+ await client.auth.verifyMfa("123456");
132
144
 
133
145
  // MFA verify with backup code
134
- await client.auth.verifyMfa('12345678', { isBackupCode: true });
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('123456');
153
+ await client.auth.mfaEnable("123456");
142
154
 
143
155
  // MFA disable (requires current password + TOTP code)
144
- await client.auth.mfaDisable('password', '123456');
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('oldpass', 'newpass');
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('my-scraper');
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('key-id');
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, 'btc');
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({ from: '2024-01-01', to: '2024-01-31', limit: 100 });
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({ from: '2024-01-01', to: '2024-01-31' });
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({ from: '2024-01-01', to: '2024-01-31' });
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('vol100');
282
+ const result = await client.plans.changePlan("vol100");
261
283
  // result.message, result.plan
262
284
  ```
263
285
 
@@ -277,25 +299,25 @@ 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('dn_live_key');
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('dn_live_key', { protocol: 'socks5' });
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('dn_live_key', {
289
- country: 'US',
290
- state: 'california',
291
- city: 'losangeles',
292
- sessionId: 'sticky123',
310
+ const geoUrl = client.proxy.buildUrl("dn_live_key", {
311
+ country: "US",
312
+ state: "california",
313
+ city: "losangeles",
314
+ sessionId: "sticky123",
293
315
  });
294
- // => http://user-country_US-state_california-city_losangeles-session_sticky123:dn_live_key@proxy.dominusnode.com:8080
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('dn_live_key', { asn: 7922 });
298
- // => http://user-asn_7922:dn_live_key@proxy.dominusnode.com:8080
319
+ const asnUrl = client.proxy.buildUrl("dn_live_key", { asn: 7922 });
320
+ // => http://user-asn-7922:dn_live_key@proxy.dominusnode.com:8080
299
321
 
300
322
  // Proxy health (no auth required)
301
323
  const health = await client.proxy.getHealth();
@@ -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('user-id');
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('user-id');
352
+ await client.admin.suspendUser("user-id");
331
353
 
332
354
  // Reactivate a suspended user
333
- await client.admin.activateUser('user-id');
355
+ await client.admin.activateUser("user-id");
334
356
 
335
357
  // Soft-delete a user account
336
- await client.admin.deleteUser('user-id');
358
+ await client.admin.deleteUser("user-id");
337
359
 
338
360
  // Revenue statistics (filterable by date range)
339
- const revenue = await client.admin.getRevenue({ since: '2024-01-01', until: '2024-01-31' });
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({ since: '2024-01-01', until: '2024-01-31' });
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 '@dominusnode/sdk';
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('Not authenticated -- login or provide API key');
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('Wallet balance too low -- top up first');
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 | HTTP Status | Description |
392
- |---|---|---|
393
- | `DominusNodeError` | (varies) | Base class for all SDK errors |
394
- | `AuthenticationError` | 401 | Invalid credentials or expired/revoked tokens |
395
- | `AuthorizationError` | 403 | Insufficient permissions (e.g., non-admin accessing admin routes) |
396
- | `InsufficientBalanceError` | 402 | Wallet balance too low for the operation |
397
- | `RateLimitError` | 429 | Too many requests -- has `retryAfterSeconds` property |
398
- | `ValidationError` | 400 | Invalid request parameters |
399
- | `NotFoundError` | 404 | Requested resource does not exist |
400
- | `ConflictError` | 409 | Resource conflict (e.g., duplicate email registration) |
401
- | `ServerError` | 500+ | Server-side error |
402
- | `NetworkError` | -- | Connection failure, DNS resolution error, or timeout |
403
- | `ProxyError` | -- | Proxy-specific error -- has optional `proxyErrorCode` property |
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 '@dominusnode/sdk';
413
- import { ProxyAgent } from 'undici';
440
+ import { DominusNodeClient } from "@dominusnode/sdk";
441
+ import { ProxyAgent } from "undici";
414
442
 
415
- const client = new DominusNodeClient({ baseUrl: 'https://api.dominusnode.com' });
416
- await client.connectWithKey('dn_live_key');
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('dn_live_key', { country: 'US' });
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('http://httpbin.org/ip', { dispatcher: agent });
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 'axios';
437
- import { HttpsProxyAgent } from 'https-proxy-agent';
466
+ import axios from "axios";
467
+ import { HttpsProxyAgent } from "https-proxy-agent";
438
468
 
439
- const proxyUrl = client.proxy.buildUrl('dn_live_key', { country: 'DE' });
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('https://httpbin.org/ip', { httpsAgent: agent });
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 | Type | Description | Example |
451
- |---|---|---|---|
452
- | `protocol` | `"http"` or `"socks5"` | Proxy protocol (default: `"http"`) | `{ protocol: 'socks5' }` |
453
- | `country` | `string` | ISO 3166-1 alpha-2 country code | `{ country: 'US' }` |
454
- | `state` | `string` | State or region name | `{ state: 'california' }` |
455
- | `city` | `string` | City name (no spaces) | `{ city: 'losangeles' }` |
456
- | `asn` | `number` | Autonomous System Number | `{ asn: 7922 }` |
457
- | `sessionId` | `string` | Sticky session identifier | `{ sessionId: 'abc123' }` |
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 '@dominusnode/sdk';
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('@dominusnode/sdk');
570
+ const { DominusNodeClient } = require("@dominusnode/sdk");
539
571
 
540
572
  async function main() {
541
- const client = new DominusNodeClient({ baseUrl: 'https://api.dominusnode.com' });
542
- await client.connectWithKey('dn_live_your_key');
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 { DominusNodeClient, AuthenticationError, InsufficientBalanceError } from '@dominusnode/sdk';
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: 'https://api.dominusnode.com',
560
- proxyHost: 'proxy.dominusnode.com',
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('dn_live_your_api_key');
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(`Balance: $${balance.balanceUsd} (${balance.balanceCents} cents)`);
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, '0')}-01`;
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(`This month: ${usage.summary.totalGB.toFixed(2)} GB, $${usage.summary.totalCostUsd}`);
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('dn_live_your_api_key', {
602
- country: 'US',
603
- state: 'california',
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('Authentication failed:', err.message);
654
+ console.error("Authentication failed:", err.message);
614
655
  } else if (err instanceof InsufficientBalanceError) {
615
- console.error('Insufficient balance:', err.message);
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 | Method | Description |
630
- |---|---|---|
631
- | `auth` | `register(email, password)` | Create a new account |
632
- | `auth` | `login(email, password)` | Login with credentials |
633
- | `auth` | `verifyMfa(code, opts?)` | Complete MFA verification |
634
- | `auth` | `mfaSetup()` | Begin MFA setup (returns secret + backup codes) |
635
- | `auth` | `mfaEnable(code)` | Confirm and enable MFA |
636
- | `auth` | `mfaDisable(password, code)` | Disable MFA |
637
- | `auth` | `mfaStatus()` | Check MFA status |
638
- | `auth` | `changePassword(current, new)` | Change password |
639
- | `auth` | `logout()` | Revoke refresh tokens server-side |
640
- | `auth` | `me()` | Get current user info |
641
- | `auth` | `verifyKey(apiKey)` | Exchange API key for JWT tokens |
642
- | `auth` | `refresh(refreshToken)` | Refresh access token (used internally) |
643
- | `keys` | `create(label?)` | Create a new API key |
644
- | `keys` | `list()` | List all API keys |
645
- | `keys` | `revoke(id)` | Revoke an API key |
646
- | `wallet` | `getBalance()` | Get current balance |
647
- | `wallet` | `getTransactions(opts?)` | Transaction history (paginated) |
648
- | `wallet` | `topUpStripe(amountCents)` | Create Stripe checkout session |
649
- | `wallet` | `topUpCrypto(amountCents, currency)` | Create crypto invoice |
650
- | `wallet` | `getForecast()` | Spending forecast |
651
- | `usage` | `get(opts?)` | Usage records with summary |
652
- | `usage` | `getDaily(opts?)` | Daily usage aggregation |
653
- | `usage` | `getTopHosts(opts?)` | Top target hosts by bandwidth |
654
- | `usage` | `exportCsv(opts?)` | Export usage as CSV |
655
- | `plans` | `list()` | List available plans |
656
- | `plans` | `getUserPlan()` | Get current user's plan |
657
- | `plans` | `changePlan(planId)` | Change plan |
658
- | `sessions` | `getActive()` | Get active proxy sessions |
659
- | `proxy` | `buildUrl(apiKey, opts?)` | Build proxy URL string (no network call) |
660
- | `proxy` | `getHealth()` | Proxy health (no auth) |
661
- | `proxy` | `getStatus()` | Proxy status with provider info |
662
- | `proxy` | `getConfig()` | Proxy configuration |
663
- | `admin` | `listUsers(opts?)` | List all users (paginated) |
664
- | `admin` | `getUser(id)` | Get user details |
665
- | `admin` | `suspendUser(id)` | Suspend a user |
666
- | `admin` | `activateUser(id)` | Reactivate a user |
667
- | `admin` | `deleteUser(id)` | Soft-delete a user |
668
- | `admin` | `getRevenue(opts?)` | Revenue statistics |
669
- | `admin` | `getDailyRevenue(opts?)` | Daily revenue breakdown |
670
- | `admin` | `getStats()` | System-wide statistics |
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
 
@@ -3,6 +3,7 @@ import type { User, LoginResult, MfaStatus, MfaSetup } from "./types.js";
3
3
  export declare class AuthResource {
4
4
  private http;
5
5
  constructor(http: HttpClient);
6
+ private solvePoW;
6
7
  register(email: string, password: string): Promise<{
7
8
  user: User;
8
9
  token?: string;