@proxyrequest/sdk 1.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,37 @@
2
2
 
3
3
  All notable changes to this project are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses [Semantic Versioning](https://semver.org/).
4
4
 
5
+ ## [Unreleased]
6
+
7
+ ### Fixed
8
+
9
+ - Keep the exported `SDK_VERSION` synchronized with the package version and verify it in the package smoke test.
10
+
11
+ ## [2.1.0] - 2026-09-17
12
+
13
+ - Add atomic per-package data reset with typed requests, response metadata, and idempotent retries.
14
+ - Refresh the public API contract and document root balances versus child allocations.
15
+
16
+ ## [2.0.0] - 2026-09-16
17
+
18
+ ### Changed
19
+
20
+ - Replace the incorrect webhook verifier with the actual `X-Signature`
21
+ Base64 HMAC-SHA256 format over exact raw bytes.
22
+
23
+ - Regenerated from the public backend contract (81 operations, 130 schemas).
24
+ - Added the optional `pending`/`paid` status to invoice creation requests.
25
+ - Removed the disabled sessions-management resource; 79 supported operations remain.
26
+ - Corrected OTP login unions, MFA request bodies, payment fields, nullable invoices,
27
+ and configuration-dependent user/invoice responses.
28
+ - Replaced fixed contract-size gates with operation-ID and coverage validation.
29
+ - Added backend-serializer fixtures and compatibility regression tests.
30
+
31
+ ### Added
32
+
33
+ - Automatic and explicit idempotency keys with bounded ambiguous-outcome retries.
34
+ - Response metadata variants and explicit ETag/`If-Match` optimistic concurrency support.
35
+
5
36
  ## [1.0.0] - 2026-08-21
6
37
 
7
38
  ### Added
@@ -13,4 +44,6 @@ All notable changes to this project are documented here. The format follows [Kee
13
44
  - Normalized errors, lazy pagination, invoice downloads, raw requests, and webhook verification.
14
45
  - Reproducible OpenAPI generation, package validation, Node/browser tests, CI, and npm provenance workflow.
15
46
 
47
+ [Unreleased]: https://github.com/proxyrequest/javascript-sdk/compare/v2.0.0...HEAD
48
+ [2.0.0]: https://github.com/proxyrequest/javascript-sdk/compare/v1.0.0...v2.0.0
16
49
  [1.0.0]: https://github.com/proxyrequest/javascript-sdk/releases/tag/v1.0.0
package/README.md CHANGED
@@ -14,7 +14,7 @@ The official TypeScript SDK for the [ProxyRequest public API](https://proxyreque
14
14
  - customer and sub-user accounts;
15
15
  - packages, traffic allocations, connection limits, and proxy credentials;
16
16
  - invoices, payment links, coupons, rewards, and reseller workflows;
17
- - residential and static ISP proxy inventory, targeting, routing, and sessions;
17
+ - residential and static ISP proxy inventory, targeting, routing, and sticky proxy credentials;
18
18
  - usage accounting, analytics, operational visibility, and webhooks;
19
19
  - dashboard, branding, API automation, and Telegram integration.
20
20
 
@@ -80,11 +80,17 @@ Public login, signup, locations, and similar calls can use an anonymous client:
80
80
  const client = ProxyRequestClient.anonymous();
81
81
  ```
82
82
 
83
- Never embed a Static API key, Telegram service secret, or webhook secret in frontend JavaScript. Browser support is intended for anonymous or appropriately scoped end-user token flows. See the service documentation on [authentication and API fundamentals](https://proxyrequest.com/docs/integration/api-fundamentals/).
83
+ Never embed a Static API key or webhook secret in frontend JavaScript. Browser support is intended for anonymous or appropriately scoped end-user token flows. See the service documentation on [authentication and API fundamentals](https://proxyrequest.com/docs/integration/api-fundamentals/).
84
84
 
85
85
  ## Resource API
86
86
 
87
- The client exposes all 82 operations through 19 resource groups:
87
+ The client exposes 80 supported operations through 17 resource groups. The pinned
88
+ public schema contains 82 operations; the disabled `sessions_list` and
89
+ `sessions_destroy` operations are intentionally excluded from the SDK. Sticky
90
+ session options in proxy generation remain supported.
91
+
92
+ See [backend compatibility and MFA](docs/backend-compatibility.md) for the updated
93
+ login flow, variable response models, and migration notes.
88
94
 
89
95
  ```ts
90
96
  client.apiKeys;
@@ -100,10 +106,8 @@ client.packages;
100
106
  client.profile;
101
107
  client.proxies;
102
108
  client.rewards;
103
- client.sessions;
104
109
  client.settings;
105
110
  client.telegram;
106
- client.telegramService;
107
111
  client.users;
108
112
  client.webhooks;
109
113
  ```
@@ -173,6 +177,36 @@ console.log(generated.proxies);
173
177
 
174
178
  See [catalog and proxies](https://proxyrequest.com/docs/integration/catalog-and-proxies/) and the separate [proxy connection documentation](https://proxyrequest.com/docs/proxy/authentication/).
175
179
 
180
+ ## Automatic retries and optimistic concurrency
181
+
182
+ The SDK automatically protects supported writes during up to three total
183
+ attempts after a network failure, or after `409 Conflict` with a numeric
184
+ `Retry-After` of at most five seconds. Other HTTP errors are returned
185
+ immediately. This protection applies inside one running call. If the process
186
+ stops before saving the result, inspect the affected resource before submitting
187
+ another write:
188
+
189
+ ```ts
190
+ const response = await client.invoices.createWithResponse({
191
+ body: { gateway: "stripe", package_id: packageId },
192
+ });
193
+
194
+ console.log(response.data.id, response.etag);
195
+ ```
196
+
197
+ Every generated method also has a `WithResponse` variant exposing `statusCode`,
198
+ `headers`, and `etag`.
199
+
200
+ Updates and deletes that declare `If-Match` accept the latest strong ETag:
201
+
202
+ ```ts
203
+ await client.users.update({ id: userId, ifMatch: response.etag, body: changes });
204
+ ```
205
+
206
+ A stale value raises `ApiError` with `kind === "precondition"` and the current
207
+ server ETag in `currentEtag`. The SDK deliberately does not cache ETags: callers
208
+ choose which representation is being updated.
209
+
176
210
  ## Pagination
177
211
 
178
212
  List methods return the API page model. Use `client.paginate()` when you want a lazy async stream:
@@ -205,7 +239,7 @@ try {
205
239
  }
206
240
  ```
207
241
 
208
- Kinds include `validation`, `authentication`, `permission`, `not_found`, `conflict`, `rate_limit`, `server`, `network`, and `unexpected`. The SDK does not retry or refresh tokens automatically. See [common integration errors](https://proxyrequest.com/docs/integration/common-errors/).
242
+ Kinds include `validation`, `authentication`, `permission`, `not_found`, `conflict`, `precondition`, `rate_limit`, `server`, `network`, and `unexpected`. Supported writes receive bounded automatic retries for transient failures; tokens are never refreshed automatically. See [common integration errors](https://proxyrequest.com/docs/integration/common-errors/).
209
243
 
210
244
  ## Per-request controls and custom Fetch
211
245
 
@@ -253,12 +287,12 @@ import { WebhookVerifier } from "@proxyrequest/sdk";
253
287
 
254
288
  const event = await WebhookVerifier.decodeVerifiedJson(
255
289
  rawBody,
256
- request.headers.get("ProxyRequest-Signature") ?? "",
290
+ request.headers.get("X-Signature") ?? "",
257
291
  process.env.PROXYREQUEST_WEBHOOK_SECRET!,
258
292
  );
259
293
  ```
260
294
 
261
- Verification supports the `t=...,v1=...` format, multiple `v1` values, Web Crypto HMAC-SHA256, and a default five-minute tolerance. See the [webhook integration guide](https://proxyrequest.com/docs/integration/webhooks/) and [event reference](https://proxyrequest.com/docs/reference/webhook-events/).
295
+ Deliveries use standard padded Base64 HMAC-SHA256 over the raw body, without a signed timestamp. Verification accepts only this current format. It authenticates the body, but does not prevent replay: deduplicate usage events in your application. These helpers require SDK 2.0.0 or newer; version 1.0.0 does not support the current delivery format. See the [webhook integration guide](https://proxyrequest.com/docs/integration/webhooks/) and [event reference](https://proxyrequest.com/docs/reference/webhook-events/).
262
296
 
263
297
  ## Raw requests
264
298
 
@@ -317,3 +351,19 @@ The repository also has a real Chromium smoke test via `npm run test:browser`.
317
351
  ## License
318
352
 
319
353
  [MIT](LICENSE)
354
+
355
+ ## Reset remaining data (SDK 2.1.0+)
356
+
357
+ ```typescript
358
+ const order = await client.users.resetData({
359
+ id: userId,
360
+ body: { package_id: packageId },
361
+ idempotencyKey: resetOperationId,
362
+ });
363
+ ```
364
+
365
+ Send only `package_id`, without `data`. A system administrator can reset any user; other accounts can reset only their direct children. The server atomically clears positive, zero, or negative remaining data for a finite package and returns the updated order. Unlimited packages are rejected. Root orders lose their remaining ledger balances; child orders lose their remaining quota without changing the parent pool. Usage history and invoices are preserved.
366
+
367
+ Persist one operation ID and reuse it when retrying the same reset, including after a process restart. This prevents a repeated request from clearing a later top-up. Use subtraction when an explicit amount should be removed from a child quota. The backend must support the reset endpoint before calling it.
368
+
369
+ Version 2.1 retains legacy user and invoice models from 2.0 for compatibility with older deployments. These compatibility types do not change the current public API contract.
package/SECURITY.md CHANGED
@@ -10,4 +10,4 @@ Do not open a public issue for a vulnerability. Email `support@proxyrequest.com`
10
10
 
11
11
  ## Credential handling
12
12
 
13
- Static API keys, Telegram service secrets, and webhook secrets belong only in trusted server environments. Rotate any credential that may have been exposed and remove it from Git history and build artifacts. Bearer tokens used in browsers should be short-lived and scoped according to the ProxyRequest API documentation.
13
+ Static API keys and webhook secrets belong only in trusted server environments. Rotate any credential that may have been exposed and remove it from Git history and build artifacts. Bearer tokens used in browsers should be short-lived and scoped according to the ProxyRequest API documentation.