@proxyrequest/sdk 1.0.0 → 2.0.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/dist/index.cjs CHANGED
@@ -43,6 +43,8 @@ var ApiError = class ApiError extends ProxyRequestError {
43
43
  requestId;
44
44
  retryAfter;
45
45
  contentLanguage;
46
+ currentEtag;
47
+ idempotencyKey;
46
48
  headers;
47
49
  rawBody;
48
50
  cause;
@@ -55,12 +57,14 @@ var ApiError = class ApiError extends ProxyRequestError {
55
57
  this.requestId = options.requestId;
56
58
  this.retryAfter = options.retryAfter;
57
59
  this.contentLanguage = options.contentLanguage;
60
+ this.currentEtag = options.currentEtag;
61
+ this.idempotencyKey = options.idempotencyKey;
58
62
  this.headers = options.headers ?? {};
59
63
  this.rawBody = options.rawBody ?? /* @__PURE__ */ new Uint8Array();
60
64
  this.cause = options.cause;
61
65
  }
62
66
  static async fromResponse(response) {
63
- const headers = headersToRecord(response.headers);
67
+ const headers = headersToRecord$1(response.headers);
64
68
  let rawBody = /* @__PURE__ */ new Uint8Array();
65
69
  try {
66
70
  rawBody = new Uint8Array(await response.clone().arrayBuffer());
@@ -74,6 +78,7 @@ var ApiError = class ApiError extends ProxyRequestError {
74
78
  const requestId = header(headers, "x-request-id", "x-correlation-id");
75
79
  const retryAfter = numberHeader(headers, "retry-after");
76
80
  const contentLanguage = header(headers, "content-language");
81
+ const currentEtag = header(headers, "etag");
77
82
  return new ApiError(detail ?? `ProxyRequest API returned HTTP ${statusCode}.`, {
78
83
  kind,
79
84
  statusCode,
@@ -82,6 +87,7 @@ var ApiError = class ApiError extends ProxyRequestError {
82
87
  ...requestId === void 0 ? {} : { requestId },
83
88
  ...retryAfter === void 0 ? {} : { retryAfter },
84
89
  ...contentLanguage === void 0 ? {} : { contentLanguage },
90
+ ...currentEtag === void 0 ? {} : { currentEtag },
85
91
  headers,
86
92
  rawBody
87
93
  });
@@ -99,6 +105,23 @@ var ApiError = class ApiError extends ProxyRequestError {
99
105
  ...cause === void 0 ? {} : { cause }
100
106
  });
101
107
  }
108
+ withIdempotencyKey(idempotencyKey) {
109
+ if (idempotencyKey === void 0 || this.idempotencyKey === idempotencyKey) return this;
110
+ return new ApiError(this.message, {
111
+ kind: this.kind,
112
+ ...this.statusCode === void 0 ? {} : { statusCode: this.statusCode },
113
+ ...this.detail === void 0 ? {} : { detail: this.detail },
114
+ fieldErrors: { ...this.fieldErrors },
115
+ ...this.requestId === void 0 ? {} : { requestId: this.requestId },
116
+ ...this.retryAfter === void 0 ? {} : { retryAfter: this.retryAfter },
117
+ ...this.contentLanguage === void 0 ? {} : { contentLanguage: this.contentLanguage },
118
+ ...this.currentEtag === void 0 ? {} : { currentEtag: this.currentEtag },
119
+ idempotencyKey,
120
+ headers: { ...this.headers },
121
+ rawBody: this.rawBody,
122
+ ...this.cause === void 0 ? {} : { cause: this.cause }
123
+ });
124
+ }
102
125
  };
103
126
  var PaginationError = class extends ProxyRequestError {
104
127
  name = "PaginationError";
@@ -112,11 +135,12 @@ function kindForStatus(statusCode) {
112
135
  if (statusCode === 403) return "permission";
113
136
  if (statusCode === 404) return "not_found";
114
137
  if (statusCode === 409) return "conflict";
138
+ if (statusCode === 412) return "precondition";
115
139
  if (statusCode === 429) return "rate_limit";
116
140
  if (statusCode >= 500) return "server";
117
141
  return "unexpected";
118
142
  }
119
- function headersToRecord(headers) {
143
+ function headersToRecord$1(headers) {
120
144
  return Object.fromEntries([...headers.entries()].map(([key, value]) => [key.toLowerCase(), value]));
121
145
  }
122
146
  function header(headers, ...names) {
@@ -221,7 +245,11 @@ var APIKeysResource = class {
221
245
  }
222
246
  /** List API keys */
223
247
  async list(options = {}) {
224
- return this.#client._call({
248
+ return (await this.listWithResponse(options)).data;
249
+ }
250
+ /** List API keys; include response metadata. */
251
+ async listWithResponse(options = {}) {
252
+ return this.#client._callWithResponse({
225
253
  operationId: "api_keys_list",
226
254
  method: "GET",
227
255
  path: "/api-keys"
@@ -236,7 +264,11 @@ var APIKeysResource = class {
236
264
  }
237
265
  /** Create an API key */
238
266
  async create(options = {}) {
239
- return this.#client._call({
267
+ return (await this.createWithResponse(options)).data;
268
+ }
269
+ /** Create an API key; include response metadata. */
270
+ async createWithResponse(options = {}) {
271
+ return this.#client._callWithResponse({
240
272
  operationId: "api_keys_create",
241
273
  method: "POST",
242
274
  path: "/api-keys"
@@ -248,13 +280,21 @@ var APIKeysResource = class {
248
280
  }
249
281
  /** Revoke an API key */
250
282
  async delete(options) {
251
- return this.#client._call({
283
+ return (await this.deleteWithResponse(options)).data;
284
+ }
285
+ /** Revoke an API key; include response metadata. */
286
+ async deleteWithResponse(options) {
287
+ return this.#client._callWithResponse({
252
288
  operationId: "api_keys_destroy",
253
289
  method: "DELETE",
254
- path: "/api-keys/{id}"
290
+ path: "/api-keys/{id}",
291
+ idempotent: true
255
292
  }, {
256
293
  path: { id: options.id },
257
- headers: { "Accept-Language": options.acceptLanguage },
294
+ headers: {
295
+ "Idempotency-Key": options.idempotencyKey,
296
+ "Accept-Language": options.acceptLanguage
297
+ },
258
298
  ...options.request === void 0 ? {} : { request: options.request }
259
299
  });
260
300
  }
@@ -266,7 +306,11 @@ var AffiliatesResource = class {
266
306
  }
267
307
  /** List referred customers */
268
308
  async list(options = {}) {
269
- return this.#client._call({
309
+ return (await this.listWithResponse(options)).data;
310
+ }
311
+ /** List referred customers; include response metadata. */
312
+ async listWithResponse(options = {}) {
313
+ return this.#client._callWithResponse({
270
314
  operationId: "affiliates_list",
271
315
  method: "GET",
272
316
  path: "/affiliates"
@@ -281,7 +325,11 @@ var AffiliatesResource = class {
281
325
  }
282
326
  /** List affiliate reward entries */
283
327
  async listRewards(options = {}) {
284
- return this.#client._call({
328
+ return (await this.listRewardsWithResponse(options)).data;
329
+ }
330
+ /** List affiliate reward entries; include response metadata. */
331
+ async listRewardsWithResponse(options = {}) {
332
+ return this.#client._callWithResponse({
285
333
  operationId: "affiliates_rewards_list",
286
334
  method: "GET",
287
335
  path: "/affiliates/rewards"
@@ -296,7 +344,11 @@ var AffiliatesResource = class {
296
344
  }
297
345
  /** Get affiliate earnings over time */
298
346
  async getRewardsOverall(options = {}) {
299
- return this.#client._call({
347
+ return (await this.getRewardsOverallWithResponse(options)).data;
348
+ }
349
+ /** Get affiliate earnings over time; include response metadata. */
350
+ async getRewardsOverallWithResponse(options = {}) {
351
+ return this.#client._callWithResponse({
300
352
  operationId: "affiliates_rewards_overall_retrieve",
301
353
  method: "GET",
302
354
  path: "/affiliates/rewards/overall"
@@ -313,7 +365,11 @@ var AnalyticsResource = class {
313
365
  }
314
366
  /** List data transactions */
315
367
  async getTransactions(options) {
316
- return this.#client._call({
368
+ return (await this.getTransactionsWithResponse(options)).data;
369
+ }
370
+ /** List data transactions; include response metadata. */
371
+ async getTransactionsWithResponse(options) {
372
+ return this.#client._callWithResponse({
317
373
  operationId: "analytics_transactions_retrieve",
318
374
  method: "GET",
319
375
  path: "/analytics/{id}/transactions"
@@ -335,7 +391,11 @@ var AnalyticsResource = class {
335
391
  }
336
392
  /** List active proxy connections */
337
393
  async getConnections(options = {}) {
338
- return this.#client._call({
394
+ return (await this.getConnectionsWithResponse(options)).data;
395
+ }
396
+ /** List active proxy connections; include response metadata. */
397
+ async getConnectionsWithResponse(options = {}) {
398
+ return this.#client._callWithResponse({
339
399
  operationId: "analytics_connections_retrieve",
340
400
  method: "GET",
341
401
  path: "/analytics/connections"
@@ -352,7 +412,11 @@ var AnalyticsResource = class {
352
412
  }
353
413
  /** List top destination domains */
354
414
  async listDomains(options = {}) {
355
- return this.#client._call({
415
+ return (await this.listDomainsWithResponse(options)).data;
416
+ }
417
+ /** List top destination domains; include response metadata. */
418
+ async listDomainsWithResponse(options = {}) {
419
+ return this.#client._callWithResponse({
356
420
  operationId: "analytics_domains_retrieve",
357
421
  method: "GET",
358
422
  path: "/analytics/domains"
@@ -377,7 +441,11 @@ var AnalyticsResource = class {
377
441
  }
378
442
  /** List proxy request activity */
379
443
  async listFeed(options = {}) {
380
- return this.#client._call({
444
+ return (await this.listFeedWithResponse(options)).data;
445
+ }
446
+ /** List proxy request activity; include response metadata. */
447
+ async listFeedWithResponse(options = {}) {
448
+ return this.#client._callWithResponse({
381
449
  operationId: "analytics_feed_retrieve",
382
450
  method: "GET",
383
451
  path: "/analytics/feed"
@@ -404,7 +472,11 @@ var AnalyticsResource = class {
404
472
  }
405
473
  /** List proxy error logs */
406
474
  async listLogs(options = {}) {
407
- return this.#client._call({
475
+ return (await this.listLogsWithResponse(options)).data;
476
+ }
477
+ /** List proxy error logs; include response metadata. */
478
+ async listLogsWithResponse(options = {}) {
479
+ return this.#client._callWithResponse({
408
480
  operationId: "analytics_logs_retrieve",
409
481
  method: "GET",
410
482
  path: "/analytics/logs"
@@ -431,7 +503,11 @@ var AnalyticsResource = class {
431
503
  }
432
504
  /** Get traffic totals over time */
433
505
  async getOverall(options = {}) {
434
- return this.#client._call({
506
+ return (await this.getOverallWithResponse(options)).data;
507
+ }
508
+ /** Get traffic totals over time; include response metadata. */
509
+ async getOverallWithResponse(options = {}) {
510
+ return this.#client._callWithResponse({
435
511
  operationId: "analytics_overall_retrieve",
436
512
  method: "GET",
437
513
  path: "/analytics/overall"
@@ -458,7 +534,11 @@ var AuthorizationResource = class {
458
534
  }
459
535
  /** Sign in with email or username */
460
536
  async login(options) {
461
- return this.#client._call({
537
+ return (await this.loginWithResponse(options)).data;
538
+ }
539
+ /** Sign in with email or username; include response metadata. */
540
+ async loginWithResponse(options) {
541
+ return this.#client._callWithResponse({
462
542
  operationId: "login_create",
463
543
  method: "POST",
464
544
  path: "/login"
@@ -470,7 +550,11 @@ var AuthorizationResource = class {
470
550
  }
471
551
  /** Sign in with Google */
472
552
  async loginWithGoogle(options) {
473
- return this.#client._call({
553
+ return (await this.loginWithGoogleWithResponse(options)).data;
554
+ }
555
+ /** Sign in with Google; include response metadata. */
556
+ async loginWithGoogleWithResponse(options) {
557
+ return this.#client._callWithResponse({
474
558
  operationId: "login_google_create",
475
559
  method: "POST",
476
560
  path: "/login/google"
@@ -480,9 +564,29 @@ var AuthorizationResource = class {
480
564
  ...options.request === void 0 ? {} : { request: options.request }
481
565
  });
482
566
  }
567
+ /** Complete two-factor sign-in */
568
+ async verifyOtp(options) {
569
+ return (await this.verifyOtpWithResponse(options)).data;
570
+ }
571
+ /** Complete two-factor sign-in; include response metadata. */
572
+ async verifyOtpWithResponse(options) {
573
+ return this.#client._callWithResponse({
574
+ operationId: "login_otp_create",
575
+ method: "POST",
576
+ path: "/login/otp"
577
+ }, {
578
+ headers: { "Accept-Language": options.acceptLanguage },
579
+ body: options.body,
580
+ ...options.request === void 0 ? {} : { request: options.request }
581
+ });
582
+ }
483
583
  /** Send a password recovery email */
484
584
  async recoverPassword(options) {
485
- return this.#client._call({
585
+ return (await this.recoverPasswordWithResponse(options)).data;
586
+ }
587
+ /** Send a password recovery email; include response metadata. */
588
+ async recoverPasswordWithResponse(options) {
589
+ return this.#client._callWithResponse({
486
590
  operationId: "recover_password_create",
487
591
  method: "POST",
488
592
  path: "/recover-password"
@@ -494,7 +598,11 @@ var AuthorizationResource = class {
494
598
  }
495
599
  /** Refresh an access token */
496
600
  async refresh(options) {
497
- return this.#client._call({
601
+ return (await this.refreshWithResponse(options)).data;
602
+ }
603
+ /** Refresh an access token; include response metadata. */
604
+ async refreshWithResponse(options) {
605
+ return this.#client._callWithResponse({
498
606
  operationId: "refresh_create",
499
607
  method: "POST",
500
608
  path: "/refresh"
@@ -506,7 +614,11 @@ var AuthorizationResource = class {
506
614
  }
507
615
  /** Create a customer account */
508
616
  async signup(options) {
509
- return this.#client._call({
617
+ return (await this.signupWithResponse(options)).data;
618
+ }
619
+ /** Create a customer account; include response metadata. */
620
+ async signupWithResponse(options) {
621
+ return this.#client._callWithResponse({
510
622
  operationId: "signup_create",
511
623
  method: "POST",
512
624
  path: "/signup"
@@ -524,7 +636,11 @@ var CouponsResource = class {
524
636
  }
525
637
  /** List available coupons */
526
638
  async list(options = {}) {
527
- return this.#client._call({
639
+ return (await this.listWithResponse(options)).data;
640
+ }
641
+ /** List available coupons; include response metadata. */
642
+ async listWithResponse(options = {}) {
643
+ return this.#client._callWithResponse({
528
644
  operationId: "coupons_list",
529
645
  method: "GET",
530
646
  path: "/coupons"
@@ -543,19 +659,31 @@ var CouponsResource = class {
543
659
  }
544
660
  /** Create a coupon */
545
661
  async create(options) {
546
- return this.#client._call({
662
+ return (await this.createWithResponse(options)).data;
663
+ }
664
+ /** Create a coupon; include response metadata. */
665
+ async createWithResponse(options) {
666
+ return this.#client._callWithResponse({
547
667
  operationId: "coupons_create",
548
668
  method: "POST",
549
- path: "/coupons"
669
+ path: "/coupons",
670
+ idempotent: true
550
671
  }, {
551
- headers: { "Accept-Language": options.acceptLanguage },
672
+ headers: {
673
+ "Idempotency-Key": options.idempotencyKey,
674
+ "Accept-Language": options.acceptLanguage
675
+ },
552
676
  body: options.body,
553
677
  ...options.request === void 0 ? {} : { request: options.request }
554
678
  });
555
679
  }
556
680
  /** Get a coupon */
557
681
  async get(options) {
558
- return this.#client._call({
682
+ return (await this.getWithResponse(options)).data;
683
+ }
684
+ /** Get a coupon; include response metadata. */
685
+ async getWithResponse(options) {
686
+ return this.#client._callWithResponse({
559
687
  operationId: "coupons_retrieve",
560
688
  method: "GET",
561
689
  path: "/coupons/{id}"
@@ -567,45 +695,72 @@ var CouponsResource = class {
567
695
  }
568
696
  /** Replace a coupon */
569
697
  async replace(options) {
570
- return this.#client._call({
698
+ return (await this.replaceWithResponse(options)).data;
699
+ }
700
+ /** Replace a coupon; include response metadata. */
701
+ async replaceWithResponse(options) {
702
+ return this.#client._callWithResponse({
571
703
  operationId: "coupons_update",
572
704
  method: "PUT",
573
705
  path: "/coupons/{id}"
574
706
  }, {
575
707
  path: { id: options.id },
576
- headers: { "Accept-Language": options.acceptLanguage },
708
+ headers: {
709
+ "If-Match": options.ifMatch,
710
+ "Accept-Language": options.acceptLanguage
711
+ },
577
712
  body: options.body,
578
713
  ...options.request === void 0 ? {} : { request: options.request }
579
714
  });
580
715
  }
581
716
  /** Update a coupon */
582
717
  async update(options) {
583
- return this.#client._call({
718
+ return (await this.updateWithResponse(options)).data;
719
+ }
720
+ /** Update a coupon; include response metadata. */
721
+ async updateWithResponse(options) {
722
+ return this.#client._callWithResponse({
584
723
  operationId: "coupons_partial_update",
585
724
  method: "PATCH",
586
725
  path: "/coupons/{id}"
587
726
  }, {
588
727
  path: { id: options.id },
589
- headers: { "Accept-Language": options.acceptLanguage },
728
+ headers: {
729
+ "If-Match": options.ifMatch,
730
+ "Accept-Language": options.acceptLanguage
731
+ },
590
732
  ...options.body === void 0 ? {} : { body: options.body },
591
733
  ...options.request === void 0 ? {} : { request: options.request }
592
734
  });
593
735
  }
594
736
  /** Delete a coupon */
595
737
  async delete(options) {
596
- return this.#client._call({
738
+ return (await this.deleteWithResponse(options)).data;
739
+ }
740
+ /** Delete a coupon; include response metadata. */
741
+ async deleteWithResponse(options) {
742
+ return this.#client._callWithResponse({
597
743
  operationId: "coupons_destroy",
598
744
  method: "DELETE",
599
- path: "/coupons/{id}"
745
+ path: "/coupons/{id}",
746
+ idempotent: true
600
747
  }, {
601
748
  path: { id: options.id },
602
- headers: { "Accept-Language": options.acceptLanguage },
749
+ headers: {
750
+ "Idempotency-Key": options.idempotencyKey,
751
+ "If-Match": options.ifMatch,
752
+ "Accept-Language": options.acceptLanguage
753
+ },
603
754
  ...options.request === void 0 ? {} : { request: options.request }
604
755
  });
605
756
  }
606
757
  /** List coupon redemptions */
607
758
  async listRedeems(options) {
608
- return this.#client._call({
759
+ return (await this.listRedeemsWithResponse(options)).data;
760
+ }
761
+ /** List coupon redemptions; include response metadata. */
762
+ async listRedeemsWithResponse(options) {
763
+ return this.#client._callWithResponse({
609
764
  operationId: "coupons_redeems_list",
610
765
  method: "GET",
611
766
  path: "/coupons/{id}/redeems"
@@ -624,7 +779,11 @@ var CouponsResource = class {
624
779
  }
625
780
  /** Calculate a discounted price */
626
781
  async calculatePrice(options) {
627
- return this.#client._call({
782
+ return (await this.calculatePriceWithResponse(options)).data;
783
+ }
784
+ /** Calculate a discounted price; include response metadata. */
785
+ async calculatePriceWithResponse(options) {
786
+ return this.#client._callWithResponse({
628
787
  operationId: "coupons_calculate_price_create",
629
788
  method: "POST",
630
789
  path: "/coupons/calculate-price"
@@ -642,7 +801,11 @@ var InvoicesResource = class {
642
801
  }
643
802
  /** List invoices */
644
803
  async list(options = {}) {
645
- return this.#client._call({
804
+ return (await this.listWithResponse(options)).data;
805
+ }
806
+ /** List invoices; include response metadata. */
807
+ async listWithResponse(options = {}) {
808
+ return this.#client._callWithResponse({
646
809
  operationId: "invoices_list",
647
810
  method: "GET",
648
811
  path: "/invoices"
@@ -666,19 +829,31 @@ var InvoicesResource = class {
666
829
  }
667
830
  /** Create an invoice */
668
831
  async create(options) {
669
- return this.#client._call({
832
+ return (await this.createWithResponse(options)).data;
833
+ }
834
+ /** Create an invoice; include response metadata. */
835
+ async createWithResponse(options) {
836
+ return this.#client._callWithResponse({
670
837
  operationId: "invoices_create",
671
838
  method: "POST",
672
- path: "/invoices"
839
+ path: "/invoices",
840
+ idempotent: true
673
841
  }, {
674
- headers: { "Accept-Language": options.acceptLanguage },
842
+ headers: {
843
+ "Idempotency-Key": options.idempotencyKey,
844
+ "Accept-Language": options.acceptLanguage
845
+ },
675
846
  body: options.body,
676
847
  ...options.request === void 0 ? {} : { request: options.request }
677
848
  });
678
849
  }
679
850
  /** Get an invoice */
680
851
  async get(options) {
681
- return this.#client._call({
852
+ return (await this.getWithResponse(options)).data;
853
+ }
854
+ /** Get an invoice; include response metadata. */
855
+ async getWithResponse(options) {
856
+ return this.#client._callWithResponse({
682
857
  operationId: "invoices_retrieve",
683
858
  method: "GET",
684
859
  path: "/invoices/{id}"
@@ -690,19 +865,32 @@ var InvoicesResource = class {
690
865
  }
691
866
  /** Delete an invoice */
692
867
  async delete(options) {
693
- return this.#client._call({
868
+ return (await this.deleteWithResponse(options)).data;
869
+ }
870
+ /** Delete an invoice; include response metadata. */
871
+ async deleteWithResponse(options) {
872
+ return this.#client._callWithResponse({
694
873
  operationId: "invoices_destroy",
695
874
  method: "DELETE",
696
- path: "/invoices/{id}"
875
+ path: "/invoices/{id}",
876
+ idempotent: true
697
877
  }, {
698
878
  path: { id: options.id },
699
- headers: { "Accept-Language": options.acceptLanguage },
879
+ headers: {
880
+ "Idempotency-Key": options.idempotencyKey,
881
+ "If-Match": options.ifMatch,
882
+ "Accept-Language": options.acceptLanguage
883
+ },
700
884
  ...options.request === void 0 ? {} : { request: options.request }
701
885
  });
702
886
  }
703
887
  /** Download an invoice PDF */
704
888
  async downloadPdf(options) {
705
- return this.#client._call({
889
+ return (await this.downloadPdfWithResponse(options)).data;
890
+ }
891
+ /** Download an invoice PDF; include response metadata. */
892
+ async downloadPdfWithResponse(options) {
893
+ return this.#client._callWithResponse({
706
894
  operationId: "invoices_download_pdf_retrieve",
707
895
  method: "GET",
708
896
  path: "/invoices/{id}/download/pdf",
@@ -715,7 +903,11 @@ var InvoicesResource = class {
715
903
  }
716
904
  /** Get an invoice payment link */
717
905
  async getPaymentLink(options) {
718
- return this.#client._call({
906
+ return (await this.getPaymentLinkWithResponse(options)).data;
907
+ }
908
+ /** Get an invoice payment link; include response metadata. */
909
+ async getPaymentLinkWithResponse(options) {
910
+ return this.#client._callWithResponse({
719
911
  operationId: "invoices_pay_retrieve",
720
912
  method: "GET",
721
913
  path: "/invoices/{id}/pay"
@@ -733,7 +925,11 @@ var LocationsResource = class {
733
925
  }
734
926
  /** List available autonomous systems */
735
927
  async listAsns(options = {}) {
736
- return this.#client._call({
928
+ return (await this.listAsnsWithResponse(options)).data;
929
+ }
930
+ /** List available autonomous systems; include response metadata. */
931
+ async listAsnsWithResponse(options = {}) {
932
+ return this.#client._callWithResponse({
737
933
  operationId: "locations_asn_list",
738
934
  method: "GET",
739
935
  path: "/locations/asn"
@@ -755,7 +951,11 @@ var LocationsResource = class {
755
951
  }
756
952
  /** List available cities */
757
953
  async listCities(options = {}) {
758
- return this.#client._call({
954
+ return (await this.listCitiesWithResponse(options)).data;
955
+ }
956
+ /** List available cities; include response metadata. */
957
+ async listCitiesWithResponse(options = {}) {
958
+ return this.#client._callWithResponse({
759
959
  operationId: "locations_cities_list",
760
960
  method: "GET",
761
961
  path: "/locations/cities"
@@ -777,7 +977,11 @@ var LocationsResource = class {
777
977
  }
778
978
  /** Get a city */
779
979
  async getCity(options) {
780
- return this.#client._call({
980
+ return (await this.getCityWithResponse(options)).data;
981
+ }
982
+ /** Get a city; include response metadata. */
983
+ async getCityWithResponse(options) {
984
+ return this.#client._callWithResponse({
781
985
  operationId: "locations_cities_retrieve",
782
986
  method: "GET",
783
987
  path: "/locations/cities/{id}"
@@ -789,7 +993,11 @@ var LocationsResource = class {
789
993
  }
790
994
  /** List available continents */
791
995
  async listContinents(options = {}) {
792
- return this.#client._call({
996
+ return (await this.listContinentsWithResponse(options)).data;
997
+ }
998
+ /** List available continents; include response metadata. */
999
+ async listContinentsWithResponse(options = {}) {
1000
+ return this.#client._callWithResponse({
793
1001
  operationId: "locations_continents_list",
794
1002
  method: "GET",
795
1003
  path: "/locations/continents"
@@ -809,7 +1017,11 @@ var LocationsResource = class {
809
1017
  }
810
1018
  /** Get a continent */
811
1019
  async getContinent(options) {
812
- return this.#client._call({
1020
+ return (await this.getContinentWithResponse(options)).data;
1021
+ }
1022
+ /** Get a continent; include response metadata. */
1023
+ async getContinentWithResponse(options) {
1024
+ return this.#client._callWithResponse({
813
1025
  operationId: "locations_continents_retrieve",
814
1026
  method: "GET",
815
1027
  path: "/locations/continents/{id}"
@@ -821,7 +1033,11 @@ var LocationsResource = class {
821
1033
  }
822
1034
  /** List available countries */
823
1035
  async listCountries(options = {}) {
824
- return this.#client._call({
1036
+ return (await this.listCountriesWithResponse(options)).data;
1037
+ }
1038
+ /** List available countries; include response metadata. */
1039
+ async listCountriesWithResponse(options = {}) {
1040
+ return this.#client._callWithResponse({
825
1041
  operationId: "locations_countries_list",
826
1042
  method: "GET",
827
1043
  path: "/locations/countries"
@@ -841,7 +1057,11 @@ var LocationsResource = class {
841
1057
  }
842
1058
  /** Get a country */
843
1059
  async getCountry(options) {
844
- return this.#client._call({
1060
+ return (await this.getCountryWithResponse(options)).data;
1061
+ }
1062
+ /** Get a country; include response metadata. */
1063
+ async getCountryWithResponse(options) {
1064
+ return this.#client._callWithResponse({
845
1065
  operationId: "locations_countries_retrieve",
846
1066
  method: "GET",
847
1067
  path: "/locations/countries/{id}"
@@ -853,7 +1073,11 @@ var LocationsResource = class {
853
1073
  }
854
1074
  /** List available internet service providers */
855
1075
  async listIsps(options = {}) {
856
- return this.#client._call({
1076
+ return (await this.listIspsWithResponse(options)).data;
1077
+ }
1078
+ /** List available internet service providers; include response metadata. */
1079
+ async listIspsWithResponse(options = {}) {
1080
+ return this.#client._callWithResponse({
857
1081
  operationId: "locations_isps_list",
858
1082
  method: "GET",
859
1083
  path: "/locations/isps"
@@ -874,7 +1098,11 @@ var LocationsResource = class {
874
1098
  }
875
1099
  /** List available regions */
876
1100
  async listRegions(options = {}) {
877
- return this.#client._call({
1101
+ return (await this.listRegionsWithResponse(options)).data;
1102
+ }
1103
+ /** List available regions; include response metadata. */
1104
+ async listRegionsWithResponse(options = {}) {
1105
+ return this.#client._callWithResponse({
878
1106
  operationId: "locations_regions_list",
879
1107
  method: "GET",
880
1108
  path: "/locations/regions"
@@ -895,7 +1123,11 @@ var LocationsResource = class {
895
1123
  }
896
1124
  /** Get a region */
897
1125
  async getRegion(options) {
898
- return this.#client._call({
1126
+ return (await this.getRegionWithResponse(options)).data;
1127
+ }
1128
+ /** Get a region; include response metadata. */
1129
+ async getRegionWithResponse(options) {
1130
+ return this.#client._callWithResponse({
899
1131
  operationId: "locations_regions_retrieve",
900
1132
  method: "GET",
901
1133
  path: "/locations/regions/{id}"
@@ -913,7 +1145,11 @@ var NewsResource = class {
913
1145
  }
914
1146
  /** List product announcements */
915
1147
  async list(options = {}) {
916
- return this.#client._call({
1148
+ return (await this.listWithResponse(options)).data;
1149
+ }
1150
+ /** List product announcements; include response metadata. */
1151
+ async listWithResponse(options = {}) {
1152
+ return this.#client._callWithResponse({
917
1153
  operationId: "news_list",
918
1154
  method: "GET",
919
1155
  path: "/news"
@@ -936,7 +1172,11 @@ var OrdersResource = class {
936
1172
  }
937
1173
  /** List active orders */
938
1174
  async list(options = {}) {
939
- return this.#client._call({
1175
+ return (await this.listWithResponse(options)).data;
1176
+ }
1177
+ /** List active orders; include response metadata. */
1178
+ async listWithResponse(options = {}) {
1179
+ return this.#client._callWithResponse({
940
1180
  operationId: "orders_list",
941
1181
  method: "GET",
942
1182
  path: "/orders"
@@ -958,7 +1198,11 @@ var OrdersResource = class {
958
1198
  }
959
1199
  /** Get an order */
960
1200
  async get(options) {
961
- return this.#client._call({
1201
+ return (await this.getWithResponse(options)).data;
1202
+ }
1203
+ /** Get an order; include response metadata. */
1204
+ async getWithResponse(options) {
1205
+ return this.#client._callWithResponse({
962
1206
  operationId: "orders_retrieve",
963
1207
  method: "GET",
964
1208
  path: "/orders/{id}"
@@ -970,32 +1214,52 @@ var OrdersResource = class {
970
1214
  }
971
1215
  /** Update order auto-renewal */
972
1216
  async updateAutoRenewal(options) {
973
- return this.#client._call({
1217
+ return (await this.updateAutoRenewalWithResponse(options)).data;
1218
+ }
1219
+ /** Update order auto-renewal; include response metadata. */
1220
+ async updateAutoRenewalWithResponse(options) {
1221
+ return this.#client._callWithResponse({
974
1222
  operationId: "orders_partial_update",
975
1223
  method: "PATCH",
976
1224
  path: "/orders/{id}"
977
1225
  }, {
978
1226
  path: { id: options.id },
979
- headers: { "Accept-Language": options.acceptLanguage },
1227
+ headers: {
1228
+ "If-Match": options.ifMatch,
1229
+ "Accept-Language": options.acceptLanguage
1230
+ },
980
1231
  ...options.body === void 0 ? {} : { body: options.body },
981
1232
  ...options.request === void 0 ? {} : { request: options.request }
982
1233
  });
983
1234
  }
984
1235
  /** Delete a sub-user order */
985
1236
  async delete(options) {
986
- return this.#client._call({
1237
+ return (await this.deleteWithResponse(options)).data;
1238
+ }
1239
+ /** Delete a sub-user order; include response metadata. */
1240
+ async deleteWithResponse(options) {
1241
+ return this.#client._callWithResponse({
987
1242
  operationId: "orders_destroy",
988
1243
  method: "DELETE",
989
- path: "/orders/{id}"
1244
+ path: "/orders/{id}",
1245
+ idempotent: true
990
1246
  }, {
991
1247
  path: { id: options.id },
992
- headers: { "Accept-Language": options.acceptLanguage },
1248
+ headers: {
1249
+ "Idempotency-Key": options.idempotencyKey,
1250
+ "If-Match": options.ifMatch,
1251
+ "Accept-Language": options.acceptLanguage
1252
+ },
993
1253
  ...options.request === void 0 ? {} : { request: options.request }
994
1254
  });
995
1255
  }
996
1256
  /** Reset an order's proxy password */
997
1257
  async resetPassword(options) {
998
- return this.#client._call({
1258
+ return (await this.resetPasswordWithResponse(options)).data;
1259
+ }
1260
+ /** Reset an order's proxy password; include response metadata. */
1261
+ async resetPasswordWithResponse(options) {
1262
+ return this.#client._callWithResponse({
999
1263
  operationId: "reset_password_create",
1000
1264
  method: "POST",
1001
1265
  path: "/reset-password"
@@ -1013,7 +1277,11 @@ var PackagesResource = class {
1013
1277
  }
1014
1278
  /** List available proxy packages */
1015
1279
  async list(options = {}) {
1016
- return this.#client._call({
1280
+ return (await this.listWithResponse(options)).data;
1281
+ }
1282
+ /** List available proxy packages; include response metadata. */
1283
+ async listWithResponse(options = {}) {
1284
+ return this.#client._callWithResponse({
1017
1285
  operationId: "packages_list",
1018
1286
  method: "GET",
1019
1287
  path: "/packages"
@@ -1033,7 +1301,11 @@ var PackagesResource = class {
1033
1301
  }
1034
1302
  /** List affiliate package commissions */
1035
1303
  async listCommissions(options = {}) {
1036
- return this.#client._call({
1304
+ return (await this.listCommissionsWithResponse(options)).data;
1305
+ }
1306
+ /** List affiliate package commissions; include response metadata. */
1307
+ async listCommissionsWithResponse(options = {}) {
1308
+ return this.#client._callWithResponse({
1037
1309
  operationId: "packages_commissions_list",
1038
1310
  method: "GET",
1039
1311
  path: "/packages/commissions"
@@ -1058,7 +1330,11 @@ var ProfileResource = class {
1058
1330
  }
1059
1331
  /** Get the current profile */
1060
1332
  async get(options = {}) {
1061
- return this.#client._call({
1333
+ return (await this.getWithResponse(options)).data;
1334
+ }
1335
+ /** Get the current profile; include response metadata. */
1336
+ async getWithResponse(options = {}) {
1337
+ return this.#client._callWithResponse({
1062
1338
  operationId: "profile_retrieve",
1063
1339
  method: "GET",
1064
1340
  path: "/profile"
@@ -1069,30 +1345,48 @@ var ProfileResource = class {
1069
1345
  }
1070
1346
  /** Update the current profile */
1071
1347
  async update(options = {}) {
1072
- return this.#client._call({
1348
+ return (await this.updateWithResponse(options)).data;
1349
+ }
1350
+ /** Update the current profile; include response metadata. */
1351
+ async updateWithResponse(options = {}) {
1352
+ return this.#client._callWithResponse({
1073
1353
  operationId: "profile_partial_update",
1074
1354
  method: "PATCH",
1075
1355
  path: "/profile"
1076
1356
  }, {
1077
- headers: { "Accept-Language": options.acceptLanguage },
1357
+ headers: {
1358
+ "If-Match": options.ifMatch,
1359
+ "Accept-Language": options.acceptLanguage
1360
+ },
1078
1361
  ...options.body === void 0 ? {} : { body: options.body },
1079
1362
  ...options.request === void 0 ? {} : { request: options.request }
1080
1363
  });
1081
1364
  }
1082
1365
  /** Delete the current account */
1083
1366
  async delete(options = {}) {
1084
- return this.#client._call({
1367
+ return (await this.deleteWithResponse(options)).data;
1368
+ }
1369
+ /** Delete the current account; include response metadata. */
1370
+ async deleteWithResponse(options = {}) {
1371
+ return this.#client._callWithResponse({
1085
1372
  operationId: "profile_destroy",
1086
1373
  method: "DELETE",
1087
1374
  path: "/profile"
1088
1375
  }, {
1089
- headers: { "Accept-Language": options.acceptLanguage },
1376
+ headers: {
1377
+ "If-Match": options.ifMatch,
1378
+ "Accept-Language": options.acceptLanguage
1379
+ },
1090
1380
  ...options.request === void 0 ? {} : { request: options.request }
1091
1381
  });
1092
1382
  }
1093
- /** Confirm two-factor setup */
1383
+ /** Confirm two-factor authentication */
1094
1384
  async confirmTwoFactor(options) {
1095
- return this.#client._call({
1385
+ return (await this.confirmTwoFactorWithResponse(options)).data;
1386
+ }
1387
+ /** Confirm two-factor authentication; include response metadata. */
1388
+ async confirmTwoFactorWithResponse(options) {
1389
+ return this.#client._callWithResponse({
1096
1390
  operationId: "profile_2fa_confirm_create",
1097
1391
  method: "POST",
1098
1392
  path: "/profile/2fa/confirm"
@@ -1104,7 +1398,11 @@ var ProfileResource = class {
1104
1398
  }
1105
1399
  /** Disable two-factor authentication */
1106
1400
  async disableTwoFactor(options) {
1107
- return this.#client._call({
1401
+ return (await this.disableTwoFactorWithResponse(options)).data;
1402
+ }
1403
+ /** Disable two-factor authentication; include response metadata. */
1404
+ async disableTwoFactorWithResponse(options) {
1405
+ return this.#client._callWithResponse({
1108
1406
  operationId: "profile_2fa_disable_create",
1109
1407
  method: "POST",
1110
1408
  path: "/profile/2fa/disable"
@@ -1114,20 +1412,29 @@ var ProfileResource = class {
1114
1412
  ...options.request === void 0 ? {} : { request: options.request }
1115
1413
  });
1116
1414
  }
1117
- /** Start two-factor setup */
1415
+ /** Prepare two-factor authentication */
1118
1416
  async setupTwoFactor(options = {}) {
1119
- return this.#client._call({
1417
+ return (await this.setupTwoFactorWithResponse(options)).data;
1418
+ }
1419
+ /** Prepare two-factor authentication; include response metadata. */
1420
+ async setupTwoFactorWithResponse(options = {}) {
1421
+ return this.#client._callWithResponse({
1120
1422
  operationId: "profile_2fa_setup_create",
1121
1423
  method: "POST",
1122
1424
  path: "/profile/2fa/setup"
1123
1425
  }, {
1124
1426
  headers: { "Accept-Language": options.acceptLanguage },
1427
+ ...options.body === void 0 ? {} : { body: options.body },
1125
1428
  ...options.request === void 0 ? {} : { request: options.request }
1126
1429
  });
1127
1430
  }
1128
1431
  /** Get two-factor status */
1129
1432
  async getTwoFactorStatus(options = {}) {
1130
- return this.#client._call({
1433
+ return (await this.getTwoFactorStatusWithResponse(options)).data;
1434
+ }
1435
+ /** Get two-factor status; include response metadata. */
1436
+ async getTwoFactorStatusWithResponse(options = {}) {
1437
+ return this.#client._callWithResponse({
1131
1438
  operationId: "profile_2fa_status_retrieve",
1132
1439
  method: "GET",
1133
1440
  path: "/profile/2fa/status"
@@ -1138,7 +1445,11 @@ var ProfileResource = class {
1138
1445
  }
1139
1446
  /** Change the account password */
1140
1447
  async changePassword(options) {
1141
- return this.#client._call({
1448
+ return (await this.changePasswordWithResponse(options)).data;
1449
+ }
1450
+ /** Change the account password; include response metadata. */
1451
+ async changePasswordWithResponse(options) {
1452
+ return this.#client._callWithResponse({
1142
1453
  operationId: "profile_change_password_create",
1143
1454
  method: "POST",
1144
1455
  path: "/profile/change-password"
@@ -1156,7 +1467,11 @@ var ProxiesResource = class {
1156
1467
  }
1157
1468
  /** Generate proxy credentials */
1158
1469
  async generate(options) {
1159
- return this.#client._call({
1470
+ return (await this.generateWithResponse(options)).data;
1471
+ }
1472
+ /** Generate proxy credentials; include response metadata. */
1473
+ async generateWithResponse(options) {
1474
+ return this.#client._callWithResponse({
1160
1475
  operationId: "proxies_generate_create",
1161
1476
  method: "POST",
1162
1477
  path: "/proxies/generate"
@@ -1174,7 +1489,11 @@ var RewardsResource = class {
1174
1489
  }
1175
1490
  /** List account rewards */
1176
1491
  async list(options = {}) {
1177
- return this.#client._call({
1492
+ return (await this.listWithResponse(options)).data;
1493
+ }
1494
+ /** List account rewards; include response metadata. */
1495
+ async listWithResponse(options = {}) {
1496
+ return this.#client._callWithResponse({
1178
1497
  operationId: "rewards_list",
1179
1498
  method: "GET",
1180
1499
  path: "/rewards"
@@ -1193,7 +1512,11 @@ var RewardsResource = class {
1193
1512
  }
1194
1513
  /** Claim available rewards */
1195
1514
  async claim(options) {
1196
- return this.#client._call({
1515
+ return (await this.claimWithResponse(options)).data;
1516
+ }
1517
+ /** Claim available rewards; include response metadata. */
1518
+ async claimWithResponse(options) {
1519
+ return this.#client._callWithResponse({
1197
1520
  operationId: "rewards_claim_create",
1198
1521
  method: "POST",
1199
1522
  path: "/rewards/claim"
@@ -1204,35 +1527,6 @@ var RewardsResource = class {
1204
1527
  });
1205
1528
  }
1206
1529
  };
1207
- var SessionsResource = class {
1208
- #client;
1209
- constructor(client) {
1210
- this.#client = client;
1211
- }
1212
- /** List active proxy sessions */
1213
- async list(options = {}) {
1214
- return this.#client._call({
1215
- operationId: "sessions_list",
1216
- method: "GET",
1217
- path: "/sessions"
1218
- }, {
1219
- headers: { "Accept-Language": options.acceptLanguage },
1220
- ...options.request === void 0 ? {} : { request: options.request }
1221
- });
1222
- }
1223
- /** Revoke a proxy session */
1224
- async delete(options) {
1225
- return this.#client._call({
1226
- operationId: "sessions_destroy",
1227
- method: "DELETE",
1228
- path: "/sessions/{id}"
1229
- }, {
1230
- path: { id: options.id },
1231
- headers: { "Accept-Language": options.acceptLanguage },
1232
- ...options.request === void 0 ? {} : { request: options.request }
1233
- });
1234
- }
1235
- };
1236
1530
  var SettingsResource = class {
1237
1531
  #client;
1238
1532
  constructor(client) {
@@ -1240,7 +1534,11 @@ var SettingsResource = class {
1240
1534
  }
1241
1535
  /** Get account settings */
1242
1536
  async get(options = {}) {
1243
- return this.#client._call({
1537
+ return (await this.getWithResponse(options)).data;
1538
+ }
1539
+ /** Get account settings; include response metadata. */
1540
+ async getWithResponse(options = {}) {
1541
+ return this.#client._callWithResponse({
1244
1542
  operationId: "settings_retrieve",
1245
1543
  method: "GET",
1246
1544
  path: "/settings"
@@ -1257,7 +1555,11 @@ var TelegramDashboardResource = class {
1257
1555
  }
1258
1556
  /** Get the Telegram dashboard connection */
1259
1557
  async getConnection(options = {}) {
1260
- return this.#client._call({
1558
+ return (await this.getConnectionWithResponse(options)).data;
1559
+ }
1560
+ /** Get the Telegram dashboard connection; include response metadata. */
1561
+ async getConnectionWithResponse(options = {}) {
1562
+ return this.#client._callWithResponse({
1261
1563
  operationId: "integrations_telegram_connection_retrieve",
1262
1564
  method: "GET",
1263
1565
  path: "/integrations/telegram/connection"
@@ -1268,7 +1570,11 @@ var TelegramDashboardResource = class {
1268
1570
  }
1269
1571
  /** Update Telegram dashboard preferences */
1270
1572
  async updateConnection(options = {}) {
1271
- return this.#client._call({
1573
+ return (await this.updateConnectionWithResponse(options)).data;
1574
+ }
1575
+ /** Update Telegram dashboard preferences; include response metadata. */
1576
+ async updateConnectionWithResponse(options = {}) {
1577
+ return this.#client._callWithResponse({
1272
1578
  operationId: "integrations_telegram_connection_partial_update",
1273
1579
  method: "PATCH",
1274
1580
  path: "/integrations/telegram/connection"
@@ -1280,7 +1586,11 @@ var TelegramDashboardResource = class {
1280
1586
  }
1281
1587
  /** Disconnect the Telegram dashboard */
1282
1588
  async deleteConnection(options = {}) {
1283
- return this.#client._call({
1589
+ return (await this.deleteConnectionWithResponse(options)).data;
1590
+ }
1591
+ /** Disconnect the Telegram dashboard; include response metadata. */
1592
+ async deleteConnectionWithResponse(options = {}) {
1593
+ return this.#client._callWithResponse({
1284
1594
  operationId: "integrations_telegram_connection_destroy",
1285
1595
  method: "DELETE",
1286
1596
  path: "/integrations/telegram/connection"
@@ -1291,7 +1601,11 @@ var TelegramDashboardResource = class {
1291
1601
  }
1292
1602
  /** Create a Telegram account link */
1293
1603
  async createLink(options = {}) {
1294
- return this.#client._call({
1604
+ return (await this.createLinkWithResponse(options)).data;
1605
+ }
1606
+ /** Create a Telegram account link; include response metadata. */
1607
+ async createLinkWithResponse(options = {}) {
1608
+ return this.#client._callWithResponse({
1295
1609
  operationId: "integrations_telegram_link_create",
1296
1610
  method: "POST",
1297
1611
  path: "/integrations/telegram/link"
@@ -1301,42 +1615,6 @@ var TelegramDashboardResource = class {
1301
1615
  });
1302
1616
  }
1303
1617
  };
1304
- var TelegramServiceResource = class {
1305
- #client;
1306
- constructor(client) {
1307
- this.#client = client;
1308
- }
1309
- /** Consume a Telegram account link */
1310
- async consumeLink(options) {
1311
- return this.#client._call({
1312
- operationId: "integrations_telegram_link_consume_create",
1313
- method: "POST",
1314
- path: "/integrations/telegram/link/consume"
1315
- }, {
1316
- headers: {
1317
- "X-ProxyRequest-Telegram-Secret": options.serviceSecret,
1318
- "Accept-Language": options.acceptLanguage
1319
- },
1320
- body: options.body,
1321
- ...options.request === void 0 ? {} : { request: options.request }
1322
- });
1323
- }
1324
- /** Create a Telegram API session */
1325
- async createSession(options) {
1326
- return this.#client._call({
1327
- operationId: "integrations_telegram_session_create",
1328
- method: "POST",
1329
- path: "/integrations/telegram/session"
1330
- }, {
1331
- headers: {
1332
- "X-ProxyRequest-Telegram-Secret": options.serviceSecret,
1333
- "Accept-Language": options.acceptLanguage
1334
- },
1335
- body: options.body,
1336
- ...options.request === void 0 ? {} : { request: options.request }
1337
- });
1338
- }
1339
- };
1340
1618
  var UsersResource = class {
1341
1619
  #client;
1342
1620
  constructor(client) {
@@ -1344,7 +1622,11 @@ var UsersResource = class {
1344
1622
  }
1345
1623
  /** List users in the current account */
1346
1624
  async list(options = {}) {
1347
- return this.#client._call({
1625
+ return (await this.listWithResponse(options)).data;
1626
+ }
1627
+ /** List users in the current account; include response metadata. */
1628
+ async listWithResponse(options = {}) {
1629
+ return this.#client._callWithResponse({
1348
1630
  operationId: "users_list",
1349
1631
  method: "GET",
1350
1632
  path: "/users"
@@ -1365,19 +1647,31 @@ var UsersResource = class {
1365
1647
  }
1366
1648
  /** Create a sub-user */
1367
1649
  async create(options) {
1368
- return this.#client._call({
1650
+ return (await this.createWithResponse(options)).data;
1651
+ }
1652
+ /** Create a sub-user; include response metadata. */
1653
+ async createWithResponse(options) {
1654
+ return this.#client._callWithResponse({
1369
1655
  operationId: "users_create",
1370
1656
  method: "POST",
1371
- path: "/users"
1657
+ path: "/users",
1658
+ idempotent: true
1372
1659
  }, {
1373
- headers: { "Accept-Language": options.acceptLanguage },
1660
+ headers: {
1661
+ "Idempotency-Key": options.idempotencyKey,
1662
+ "Accept-Language": options.acceptLanguage
1663
+ },
1374
1664
  body: options.body,
1375
1665
  ...options.request === void 0 ? {} : { request: options.request }
1376
1666
  });
1377
1667
  }
1378
1668
  /** Get a user */
1379
1669
  async get(options) {
1380
- return this.#client._call({
1670
+ return (await this.getWithResponse(options)).data;
1671
+ }
1672
+ /** Get a user; include response metadata. */
1673
+ async getWithResponse(options) {
1674
+ return this.#client._callWithResponse({
1381
1675
  operationId: "users_retrieve",
1382
1676
  method: "GET",
1383
1677
  path: "/users/{id}"
@@ -1389,58 +1683,94 @@ var UsersResource = class {
1389
1683
  }
1390
1684
  /** Update a user */
1391
1685
  async update(options) {
1392
- return this.#client._call({
1686
+ return (await this.updateWithResponse(options)).data;
1687
+ }
1688
+ /** Update a user; include response metadata. */
1689
+ async updateWithResponse(options) {
1690
+ return this.#client._callWithResponse({
1393
1691
  operationId: "users_partial_update",
1394
1692
  method: "PATCH",
1395
1693
  path: "/users/{id}"
1396
1694
  }, {
1397
1695
  path: { id: options.id },
1398
- headers: { "Accept-Language": options.acceptLanguage },
1696
+ headers: {
1697
+ "If-Match": options.ifMatch,
1698
+ "Accept-Language": options.acceptLanguage
1699
+ },
1399
1700
  ...options.body === void 0 ? {} : { body: options.body },
1400
1701
  ...options.request === void 0 ? {} : { request: options.request }
1401
1702
  });
1402
1703
  }
1403
1704
  /** Delete a user */
1404
1705
  async delete(options) {
1405
- return this.#client._call({
1706
+ return (await this.deleteWithResponse(options)).data;
1707
+ }
1708
+ /** Delete a user; include response metadata. */
1709
+ async deleteWithResponse(options) {
1710
+ return this.#client._callWithResponse({
1406
1711
  operationId: "users_destroy",
1407
1712
  method: "DELETE",
1408
- path: "/users/{id}"
1713
+ path: "/users/{id}",
1714
+ idempotent: true
1409
1715
  }, {
1410
1716
  path: { id: options.id },
1411
- headers: { "Accept-Language": options.acceptLanguage },
1717
+ headers: {
1718
+ "Idempotency-Key": options.idempotencyKey,
1719
+ "If-Match": options.ifMatch,
1720
+ "Accept-Language": options.acceptLanguage
1721
+ },
1412
1722
  ...options.request === void 0 ? {} : { request: options.request }
1413
1723
  });
1414
1724
  }
1415
1725
  /** Add data to a sub-user order */
1416
1726
  async addData(options) {
1417
- return this.#client._call({
1727
+ return (await this.addDataWithResponse(options)).data;
1728
+ }
1729
+ /** Add data to a sub-user order; include response metadata. */
1730
+ async addDataWithResponse(options) {
1731
+ return this.#client._callWithResponse({
1418
1732
  operationId: "users_data_add_create",
1419
1733
  method: "POST",
1420
- path: "/users/{id}/data/add"
1734
+ path: "/users/{id}/data/add",
1735
+ idempotent: true
1421
1736
  }, {
1422
1737
  path: { id: options.id },
1423
- headers: { "Accept-Language": options.acceptLanguage },
1738
+ headers: {
1739
+ "Idempotency-Key": options.idempotencyKey,
1740
+ "Accept-Language": options.acceptLanguage
1741
+ },
1424
1742
  body: options.body,
1425
1743
  ...options.request === void 0 ? {} : { request: options.request }
1426
1744
  });
1427
1745
  }
1428
1746
  /** Subtract data from a sub-user order */
1429
1747
  async subtractData(options) {
1430
- return this.#client._call({
1748
+ return (await this.subtractDataWithResponse(options)).data;
1749
+ }
1750
+ /** Subtract data from a sub-user order; include response metadata. */
1751
+ async subtractDataWithResponse(options) {
1752
+ return this.#client._callWithResponse({
1431
1753
  operationId: "users_data_subtract_create",
1432
1754
  method: "POST",
1433
- path: "/users/{id}/data/subtract"
1755
+ path: "/users/{id}/data/subtract",
1756
+ idempotent: true
1434
1757
  }, {
1435
1758
  path: { id: options.id },
1436
- headers: { "Accept-Language": options.acceptLanguage },
1759
+ headers: {
1760
+ "Idempotency-Key": options.idempotencyKey,
1761
+ "Accept-Language": options.acceptLanguage
1762
+ },
1437
1763
  body: options.body,
1438
1764
  ...options.request === void 0 ? {} : { request: options.request }
1439
1765
  });
1440
1766
  }
1441
1767
  /** List a sub-user's orders */
1442
1768
  async listOrders(options) {
1443
- return this.#client._call({
1769
+ return (await this.listOrdersWithResponse(options)).data;
1770
+ }
1771
+ /** List a sub-user's orders; include response metadata. */
1772
+ async listOrdersWithResponse(options) {
1773
+ return this.#client._callWithResponse({
1444
1774
  operationId: "users_orders_list",
1445
1775
  method: "GET",
1446
1776
  path: "/users/{id}/orders"
@@ -1460,7 +1790,11 @@ var UsersResource = class {
1460
1790
  }
1461
1791
  /** Rotate a sub-user proxy password */
1462
1792
  async resetPassword(options) {
1463
- return this.#client._call({
1793
+ return (await this.resetPasswordWithResponse(options)).data;
1794
+ }
1795
+ /** Rotate a sub-user proxy password; include response metadata. */
1796
+ async resetPasswordWithResponse(options) {
1797
+ return this.#client._callWithResponse({
1464
1798
  operationId: "users_password_create",
1465
1799
  method: "POST",
1466
1800
  path: "/users/{id}/password"
@@ -1479,7 +1813,11 @@ var WebhooksResource = class {
1479
1813
  }
1480
1814
  /** List customer webhooks */
1481
1815
  async list(options = {}) {
1482
- return this.#client._call({
1816
+ return (await this.listWithResponse(options)).data;
1817
+ }
1818
+ /** List customer webhooks; include response metadata. */
1819
+ async listWithResponse(options = {}) {
1820
+ return this.#client._callWithResponse({
1483
1821
  operationId: "webhooks_list",
1484
1822
  method: "GET",
1485
1823
  path: "/webhooks"
@@ -1494,19 +1832,31 @@ var WebhooksResource = class {
1494
1832
  }
1495
1833
  /** Create a customer webhook */
1496
1834
  async create(options) {
1497
- return this.#client._call({
1835
+ return (await this.createWithResponse(options)).data;
1836
+ }
1837
+ /** Create a customer webhook; include response metadata. */
1838
+ async createWithResponse(options) {
1839
+ return this.#client._callWithResponse({
1498
1840
  operationId: "webhooks_create",
1499
1841
  method: "POST",
1500
- path: "/webhooks"
1842
+ path: "/webhooks",
1843
+ idempotent: true
1501
1844
  }, {
1502
- headers: { "Accept-Language": options.acceptLanguage },
1845
+ headers: {
1846
+ "Idempotency-Key": options.idempotencyKey,
1847
+ "Accept-Language": options.acceptLanguage
1848
+ },
1503
1849
  body: options.body,
1504
1850
  ...options.request === void 0 ? {} : { request: options.request }
1505
1851
  });
1506
1852
  }
1507
1853
  /** Get a customer webhook */
1508
1854
  async get(options) {
1509
- return this.#client._call({
1855
+ return (await this.getWithResponse(options)).data;
1856
+ }
1857
+ /** Get a customer webhook; include response metadata. */
1858
+ async getWithResponse(options) {
1859
+ return this.#client._callWithResponse({
1510
1860
  operationId: "webhooks_retrieve",
1511
1861
  method: "GET",
1512
1862
  path: "/webhooks/{id}"
@@ -1518,13 +1868,22 @@ var WebhooksResource = class {
1518
1868
  }
1519
1869
  /** Delete a customer webhook */
1520
1870
  async delete(options) {
1521
- return this.#client._call({
1871
+ return (await this.deleteWithResponse(options)).data;
1872
+ }
1873
+ /** Delete a customer webhook; include response metadata. */
1874
+ async deleteWithResponse(options) {
1875
+ return this.#client._callWithResponse({
1522
1876
  operationId: "webhooks_destroy",
1523
1877
  method: "DELETE",
1524
- path: "/webhooks/{id}"
1878
+ path: "/webhooks/{id}",
1879
+ idempotent: true
1525
1880
  }, {
1526
1881
  path: { id: options.id },
1527
- headers: { "Accept-Language": options.acceptLanguage },
1882
+ headers: {
1883
+ "Idempotency-Key": options.idempotencyKey,
1884
+ "If-Match": options.ifMatch,
1885
+ "Accept-Language": options.acceptLanguage
1886
+ },
1528
1887
  ...options.request === void 0 ? {} : { request: options.request }
1529
1888
  });
1530
1889
  }
@@ -1544,10 +1903,8 @@ function createResourceCollection(client) {
1544
1903
  profile: new ProfileResource(client),
1545
1904
  proxies: new ProxiesResource(client),
1546
1905
  rewards: new RewardsResource(client),
1547
- sessions: new SessionsResource(client),
1548
1906
  settings: new SettingsResource(client),
1549
1907
  telegram: new TelegramDashboardResource(client),
1550
- telegramService: new TelegramServiceResource(client),
1551
1908
  users: new UsersResource(client),
1552
1909
  webhooks: new WebhooksResource(client)
1553
1910
  };
@@ -1606,15 +1963,14 @@ var ProxyRequestClient = class ProxyRequestClient {
1606
1963
  profile;
1607
1964
  proxies;
1608
1965
  rewards;
1609
- sessions;
1610
1966
  settings;
1611
1967
  telegram;
1612
- telegramService;
1613
1968
  users;
1614
1969
  webhooks;
1615
1970
  baseUrl;
1616
1971
  language;
1617
1972
  timeoutMs;
1973
+ idempotency;
1618
1974
  #fetch;
1619
1975
  #headers;
1620
1976
  #openapi;
@@ -1622,6 +1978,7 @@ var ProxyRequestClient = class ProxyRequestClient {
1622
1978
  this.baseUrl = normalizeBaseUrl(options.baseUrl ?? "https://api.proxyrequest.com/api/v1");
1623
1979
  this.language = options.language ?? "en";
1624
1980
  this.timeoutMs = options.timeoutMs ?? 15e3;
1981
+ this.idempotency = options.idempotency ?? true;
1625
1982
  if (!Number.isFinite(this.timeoutMs) || this.timeoutMs < 0) throw new RangeError("timeoutMs must be a non-negative finite number.");
1626
1983
  this.#fetch = options.fetch ?? globalThis.fetch;
1627
1984
  if (typeof this.#fetch !== "function") throw new TypeError("A Fetch API implementation is required.");
@@ -1656,10 +2013,8 @@ var ProxyRequestClient = class ProxyRequestClient {
1656
2013
  this.profile = resources.profile;
1657
2014
  this.proxies = resources.proxies;
1658
2015
  this.rewards = resources.rewards;
1659
- this.sessions = resources.sessions;
1660
2016
  this.settings = resources.settings;
1661
2017
  this.telegram = resources.telegram;
1662
- this.telegramService = resources.telegramService;
1663
2018
  this.users = resources.users;
1664
2019
  this.webhooks = resources.webhooks;
1665
2020
  }
@@ -1679,34 +2034,55 @@ var ProxyRequestClient = class ProxyRequestClient {
1679
2034
  return new ProxyRequestClient(options);
1680
2035
  }
1681
2036
  async _call(spec, data = {}) {
2037
+ return (await this._callWithResponse(spec, data)).data;
2038
+ }
2039
+ async _callWithResponse(spec, data = {}) {
1682
2040
  const controls = data.request ?? {};
1683
- const timeout = requestSignal(controls.signal, controls.timeoutMs ?? this.timeoutMs);
1684
- const options = {
1685
- params: {
1686
- ...data.path === void 0 ? {} : { path: data.path },
1687
- ...data.query === void 0 ? {} : { query: data.query },
1688
- ...data.headers === void 0 ? {} : { header: data.headers }
1689
- },
1690
- ...data.body === void 0 ? {} : { body: data.body },
1691
- ...controls.headers === void 0 ? {} : { headers: controls.headers },
1692
- signal: timeout.signal,
1693
- ...spec.binary ? { parseAs: "arrayBuffer" } : {}
2041
+ const controlHeaders = new Headers(controls.headers);
2042
+ const parameterKey = stringHeader(data.headers?.["Idempotency-Key"]);
2043
+ const controlKey = controlHeaders.get("Idempotency-Key") ?? void 0;
2044
+ const idempotencyKey = spec.idempotent ? parameterKey ?? controlKey ?? (this.idempotency ? newIdempotencyKey() : void 0) : void 0;
2045
+ if (spec.idempotent) controlHeaders.delete("Idempotency-Key");
2046
+ const operationHeaders = {
2047
+ ...data.headers,
2048
+ ...idempotencyKey === void 0 ? {} : { "Idempotency-Key": idempotencyKey }
1694
2049
  };
1695
- try {
1696
- const method = this.#openapi[spec.method];
1697
- const result = await method(spec.path, options);
1698
- if (result.error !== void 0) throw ApiError.unexpected(`ProxyRequest returned an undocumented error for ${spec.operationId}.`, result.error);
1699
- if (spec.binary) {
1700
- if (!(result.data instanceof ArrayBuffer)) throw ApiError.unexpected(`ProxyRequest returned an invalid file for ${spec.operationId}.`);
1701
- return FileDownload.fromResponse(result.data, result.response.headers);
2050
+ const method = this.#openapi[spec.method];
2051
+ for (let attempt = 0; attempt < 3; attempt += 1) {
2052
+ const timeout = requestSignal(controls.signal, controls.timeoutMs ?? this.timeoutMs);
2053
+ try {
2054
+ const result = await method(spec.path, {
2055
+ params: {
2056
+ ...data.path === void 0 ? {} : { path: data.path },
2057
+ ...data.query === void 0 ? {} : { query: data.query },
2058
+ ...Object.keys(operationHeaders).length === 0 ? {} : { header: operationHeaders }
2059
+ },
2060
+ ...data.body === void 0 ? {} : { body: data.body },
2061
+ ...[...controlHeaders].length === 0 ? {} : { headers: controlHeaders },
2062
+ signal: timeout.signal,
2063
+ ...spec.binary ? { parseAs: "arrayBuffer" } : {}
2064
+ });
2065
+ if (result.error !== void 0) throw ApiError.unexpected(`ProxyRequest returned an undocumented error for ${spec.operationId}.`, result.error);
2066
+ const dataValue = spec.binary ? binaryResult(spec, result.data, result.response.headers) : result.data;
2067
+ const headers = headersToRecord(result.response.headers);
2068
+ const etag = headers.etag;
2069
+ return {
2070
+ data: dataValue,
2071
+ statusCode: result.response.status,
2072
+ headers,
2073
+ ...etag === void 0 ? {} : { etag },
2074
+ idempotencyReplayed: headers["idempotency-replayed"]?.toLowerCase() === "true"
2075
+ };
2076
+ } catch (error) {
2077
+ const apiError = (error instanceof ApiError ? error : ApiError.unexpected(`Unable to process the ProxyRequest response for ${spec.operationId}.`, error)).withIdempotencyKey(idempotencyKey);
2078
+ const delay = retryDelay(apiError, attempt);
2079
+ if (attempt >= 2 || idempotencyKey === void 0 || controls.signal?.aborted || delay === void 0) throw apiError;
2080
+ await wait(delay, controls.signal);
2081
+ } finally {
2082
+ timeout.cleanup();
1702
2083
  }
1703
- return result.data;
1704
- } catch (error) {
1705
- if (error instanceof ApiError) throw error;
1706
- throw ApiError.unexpected(`Unable to process the ProxyRequest response for ${spec.operationId}.`, error);
1707
- } finally {
1708
- timeout.cleanup();
1709
2084
  }
2085
+ throw ApiError.unexpected(`Unable to complete ${spec.operationId}.`);
1710
2086
  }
1711
2087
  async request(method, path, options = {}) {
1712
2088
  const url = new URL(path.replace(/^\//u, ""), `${this.baseUrl}/`);
@@ -1781,40 +2157,63 @@ function appendQuery(search, query) {
1781
2157
  function isBodyInit(value) {
1782
2158
  return typeof value === "string" || value instanceof Blob || value instanceof ArrayBuffer || ArrayBuffer.isView(value) || value instanceof FormData || value instanceof URLSearchParams || value instanceof ReadableStream;
1783
2159
  }
2160
+ function stringHeader(value) {
2161
+ return typeof value === "string" && value.length > 0 ? value : void 0;
2162
+ }
2163
+ function newIdempotencyKey() {
2164
+ if (typeof globalThis.crypto?.randomUUID !== "function") throw new Error("crypto.randomUUID() is required for automatic idempotency keys.");
2165
+ return globalThis.crypto.randomUUID();
2166
+ }
2167
+ function binaryResult(spec, data, headers) {
2168
+ if (!(data instanceof ArrayBuffer)) throw ApiError.unexpected(`ProxyRequest returned an invalid file for ${spec.operationId}.`);
2169
+ return FileDownload.fromResponse(data, headers);
2170
+ }
2171
+ function headersToRecord(headers) {
2172
+ return Object.freeze(Object.fromEntries(headers.entries()));
2173
+ }
2174
+ function retryDelay(error, attempt) {
2175
+ if (error.kind === "network") return attempt === 0 ? 100 : 200;
2176
+ if (error.statusCode === 409 && error.retryAfter !== void 0 && error.retryAfter >= 0 && error.retryAfter <= 5) return error.retryAfter * 1e3;
2177
+ }
2178
+ function wait(milliseconds, signal) {
2179
+ if (signal?.aborted) return Promise.reject(ApiError.network(signal.reason));
2180
+ return new Promise((resolvePromise, reject) => {
2181
+ const timer = setTimeout(() => {
2182
+ signal?.removeEventListener("abort", abort);
2183
+ resolvePromise();
2184
+ }, milliseconds);
2185
+ const abort = () => {
2186
+ clearTimeout(timer);
2187
+ reject(ApiError.network(signal?.reason));
2188
+ };
2189
+ signal?.addEventListener("abort", abort, { once: true });
2190
+ });
2191
+ }
1784
2192
 
1785
2193
  //#endregion
1786
2194
  //#region src/webhooks.ts
1787
2195
  const encoder = new TextEncoder();
1788
2196
  var WebhookVerifier = class WebhookVerifier {
1789
- static async verify(rawBody, signature, secret, options = {}) {
1790
- const tolerance = options.tolerance === void 0 ? 300 : options.tolerance;
1791
- if (!signature || !secret || tolerance !== null && tolerance < 0) return false;
1792
- const parsed = parseSignature(signature);
1793
- if (parsed === void 0) return false;
1794
- if (options.timestampHeader !== void 0) {
1795
- const timestampHeader = options.timestampHeader.trim();
1796
- if (!/^\d+$/u.test(timestampHeader) || Number(timestampHeader) !== parsed.timestamp) return false;
1797
- }
1798
- const now = options.now ?? Math.floor(Date.now() / 1e3);
1799
- if (tolerance !== null && Math.abs(now - parsed.timestamp) > tolerance) return false;
1800
- const body = bodyBytes(rawBody);
1801
- const payload = concatBytes(encoder.encode(`${parsed.timestamp}.`), body);
2197
+ /** Verify X-Signature against the exact raw request body. */
2198
+ static async verify(rawBody, signature, secret) {
2199
+ if (!signature || !secret) return false;
2200
+ const candidate = parseBase64Signature(signature);
2201
+ if (candidate === void 0) return false;
1802
2202
  try {
1803
2203
  const key = await globalThis.crypto.subtle.importKey("raw", encoder.encode(secret), {
1804
2204
  name: "HMAC",
1805
2205
  hash: "SHA-256"
1806
- }, false, ["sign"]);
1807
- const expected = new Uint8Array(await globalThis.crypto.subtle.sign("HMAC", key, payload.slice().buffer));
1808
- return parsed.signatures.some((candidate) => constantTimeHexEqual(expected, candidate));
2206
+ }, false, ["verify"]);
2207
+ return globalThis.crypto.subtle.verify("HMAC", key, candidate.slice().buffer, bodyBytes(rawBody).slice().buffer);
1809
2208
  } catch {
1810
2209
  return false;
1811
2210
  }
1812
2211
  }
1813
- static async verifyOrThrow(rawBody, signature, secret, options = {}) {
1814
- if (!await WebhookVerifier.verify(rawBody, signature, secret, options)) throw new InvalidSignatureError("The ProxyRequest webhook signature is invalid or expired.");
2212
+ static async verifyOrThrow(rawBody, signature, secret) {
2213
+ if (!await WebhookVerifier.verify(rawBody, signature, secret)) throw new InvalidSignatureError("The ProxyRequest webhook signature is invalid.");
1815
2214
  }
1816
- static async decodeVerifiedJson(rawBody, signature, secret, options = {}) {
1817
- await WebhookVerifier.verifyOrThrow(rawBody, signature, secret, options);
2215
+ static async decodeVerifiedJson(rawBody, signature, secret) {
2216
+ await WebhookVerifier.verifyOrThrow(rawBody, signature, secret);
1818
2217
  const text = typeof rawBody === "string" ? rawBody : new TextDecoder().decode(bodyBytes(rawBody));
1819
2218
  try {
1820
2219
  const payload = JSON.parse(text);
@@ -1826,38 +2225,15 @@ var WebhookVerifier = class WebhookVerifier {
1826
2225
  }
1827
2226
  }
1828
2227
  };
1829
- function parseSignature(signature) {
1830
- let timestamp;
1831
- const signatures = [];
1832
- for (const part of signature.split(",")) {
1833
- const [key, value] = part.trim().split("=", 2);
1834
- if (key === "t" && value !== void 0 && /^\d+$/u.test(value)) timestamp = Number(value);
1835
- if (key === "v1" && value !== void 0 && /^[a-f\d]{64}$/iu.test(value)) signatures.push(value.toLowerCase());
1836
- }
1837
- if (timestamp === void 0 || !Number.isSafeInteger(timestamp) || signatures.length === 0) return;
1838
- return {
1839
- timestamp,
1840
- signatures
1841
- };
1842
- }
1843
2228
  function bodyBytes(value) {
1844
2229
  if (typeof value === "string") return encoder.encode(value);
1845
2230
  return value instanceof Uint8Array ? value : new Uint8Array(value);
1846
2231
  }
1847
- function concatBytes(left, right) {
1848
- const result = new Uint8Array(left.byteLength + right.byteLength);
1849
- result.set(left, 0);
1850
- result.set(right, left.byteLength);
1851
- return result;
1852
- }
1853
- function constantTimeHexEqual(expected, candidate) {
1854
- if (!/^[a-f\d]+$/iu.test(candidate) || candidate.length !== expected.byteLength * 2) return false;
1855
- let difference = 0;
1856
- for (let index = 0; index < expected.byteLength; index += 1) {
1857
- const byte = Number.parseInt(candidate.slice(index * 2, index * 2 + 2), 16);
1858
- difference |= (expected[index] ?? 0) ^ byte;
1859
- }
1860
- return difference === 0;
2232
+ function parseBase64Signature(signature) {
2233
+ if (!/^[A-Za-z0-9+/]{43}=$/u.test(signature)) return void 0;
2234
+ const decoded = atob(signature);
2235
+ if (decoded.length !== 32 || btoa(decoded) !== signature) return void 0;
2236
+ return Uint8Array.from(decoded, (character) => character.charCodeAt(0));
1861
2237
  }
1862
2238
 
1863
2239
  //#endregion
@@ -1883,10 +2259,8 @@ exports.ProxyRequestClient = ProxyRequestClient;
1883
2259
  exports.ProxyRequestError = ProxyRequestError;
1884
2260
  exports.RewardsResource = RewardsResource;
1885
2261
  exports.SDK_VERSION = SDK_VERSION;
1886
- exports.SessionsResource = SessionsResource;
1887
2262
  exports.SettingsResource = SettingsResource;
1888
2263
  exports.TelegramDashboardResource = TelegramDashboardResource;
1889
- exports.TelegramServiceResource = TelegramServiceResource;
1890
2264
  exports.UsersResource = UsersResource;
1891
2265
  exports.WebhookVerifier = WebhookVerifier;
1892
2266
  exports.WebhooksResource = WebhooksResource;