@invonetwork/web-sdk 2.1.0 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,38 @@ All notable changes to `@invonetwork/web-sdk` are documented here. This project
4
4
  [Semantic Versioning](https://semver.org/). Releases are managed with
5
5
  [changesets](https://github.com/changesets/changesets).
6
6
 
7
+ ## [2.1.2] — 2026-07-07
8
+
9
+ **Hosted-checkout reconciliation** (the create-session API contract is unchanged; the hosted
10
+ page was rebuilt). Additive + docs only.
11
+
12
+ - `createCheckout` now surfaces `expiresInSeconds` (the `checkout_url` token TTL, e.g. 900) as
13
+ a first-class field on `CreateCheckoutResult` — previously only on `.raw`.
14
+ - README: the `platform` rail is described as cards + Apple Pay / Google Pay / Link +
15
+ international billing (no app-store commission), and the checkout note now says reloading the
16
+ URL after a completed payment is idempotent (an already-complete success screen), not an
17
+ error. No API/signature changes.
18
+
19
+ ## [2.1.1] — 2026-07-06
20
+
21
+ **Security & correctness hardening** from a full audit + red-team of both SDKs. No API changes;
22
+ upgrade recommended.
23
+
24
+ - **Fail closed on HTTP redirects (security).** The transport now sends `redirect:"manual"` and
25
+ throws `UNEXPECTED_REDIRECT` on any 3xx instead of following it. Previously a redirect from
26
+ the API host could cause the game-secret header to be re-sent to an unvalidated URL (matches
27
+ the Python SDK fix, where the leak also covered the player token and an `http://` downgrade).
28
+ - **`retryAfter` no longer treats a blank `retry_after` as `0`.** An empty/whitespace
29
+ `retry_after` string used to become `0` (`Number("")===0`) — an immediate, no-backoff retry.
30
+ It's now correctly `undefined`, in both `InvoError.retryAfter` and the retry layer.
31
+ - **Whitespace OTP codes rejected client-side.** `recoveryComplete`/`enrollmentVerify` now
32
+ reject a whitespace-only `code` before the network call, so it can't burn an attempt against
33
+ the attempt-capped endpoints (parity with the Python SDK).
34
+ - **Webhook verify uses `crypto.timingSafeEqual`** on the sync path (parity with Python's
35
+ `hmac.compare_digest`); the runtime-agnostic async/edge path keeps its string compare.
36
+ - **WebAuthn option mappers fail cleanly.** A malformed `register/begin` body now throws
37
+ `WEBAUTHN_OPTIONS_MALFORMED` (an `InvoError`) instead of a raw `TypeError`.
38
+
7
39
  ## [2.1.0] — 2026-07-02
8
40
 
9
41
  **Passkey recovery ("lost or replaced my passkey").** Deleting a passkey on the device never
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  First-party TypeScript SDK for integrating **INVO** into partner **web** platforms (storefronts, web games, dashboards). It wraps INVO's web money flows behind a typed, versioned API — the web analog of the Unity/Unreal plugins.
4
4
 
5
- > **Status:** `v2.1.0` — stable, published on npm. The backend it wraps is **live** on sandbox + production. The API is covered by a [stability commitment](#stability): no breaking changes without a major bump. **Since 2.0.0 (breaking):** `mintPlayerToken` requires `playerPhone` (E.164) — see the [CHANGELOG](CHANGELOG.md) migration note. **2.1.0 adds** self-serve passkey recovery (`recoveryBegin`/`recoveryComplete`).
5
+ > **Status:** `v2.1.1` — stable, published on npm. The backend it wraps is **live** on sandbox + production. The API is covered by a [stability commitment](#stability): no breaking changes without a major bump. **Since 2.0.0 (breaking):** `mintPlayerToken` requires `playerPhone` (E.164) — see the [CHANGELOG](CHANGELOG.md) migration note. **2.1.0 adds** self-serve passkey recovery (`recoveryBegin`/`recoveryComplete`); **2.1.1** is a security/correctness hardening patch; **2.1.2** surfaces `expiresInSeconds` on `createCheckout`.
6
6
  > Canonical partner reference: **https://docs.invo.network/docs/currency-purchase** and **https://docs.invo.network/docs/game-developer-integration**.
7
7
 
8
8
  ## What it does
@@ -200,7 +200,7 @@ Buy game currency with real money. Authenticated by the **payment rail**, not a
200
200
 
201
201
  ```ts
202
202
  // SERVER
203
- const { checkoutUrl, sessionId, expiresAt } = await server.createCheckout({
203
+ const { checkoutUrl, sessionId, expiresAt, expiresInSeconds } = await server.createCheckout({
204
204
  playerEmail: "p@example.com",
205
205
  usdAmount: "20.00", // USD, 0 < x ≤ 999.99
206
206
  rail: "platform", // optional: "platform" (default) | "game" | "steam"
@@ -208,7 +208,9 @@ const { checkoutUrl, sessionId, expiresAt } = await server.createCheckout({
208
208
  cancelUrl: "https://you/buy/cancel",
209
209
  metadata: { yourOrderId: "ord_42" }, // echoed on the purchase.completed webhook (all rails); order_id also reconciles
210
210
  });
211
- // → send the browser to checkoutUrl (single-use, ~15 min)
211
+ // → send the browser to checkoutUrl. Token TTL is expiresInSeconds (~900s / 15 min).
212
+ // Reloading the URL after a completed payment is idempotent — it shows an already-complete
213
+ // success screen (no error), so you don't have to guard against a refresh.
212
214
  ```
213
215
 
214
216
  Open `checkoutUrl` either way:
@@ -237,8 +239,8 @@ The hosted page handles card entry, saved cards, and 3-D Secure (with a top-leve
237
239
  ### Payment rails (neutral names)
238
240
 
239
241
  The `rail` selects the in-page experience — all branded INVO, no visible redirect:
240
- - `"platform"` (default) — card checkout.
241
- - `"game"` — regional / game-store methods.
242
+ - `"platform"` (default) — cards plus **Apple Pay / Google Pay / Link** (rendered automatically on supported devices) and international billing addresses. It's a web checkout, so there's no app-store commission.
243
+ - `"game"` — regional / game-store methods (may redirect to the regional hosted page).
242
244
  - `"steam"` — Steam titles hand off to the in-client Steam flow.
243
245
 
244
246
  Provider/processor names are an internal detail and never appear in the API.
@@ -585,7 +587,7 @@ try {
585
587
  | `mintPlayerToken({ playerEmail, playerPhone })` | `{ token, expiresAt, identityId }` — **both required**; `playerPhone` must be E.164 (see [Player registration](#player-registration-email--phone-required)) |
586
588
  | `initiateSend(input)` | `{ transactionId, verificationMethod, guardianApproval?, raw }` |
587
589
  | `initiateTransfer(input)` | `{ transactionId, verificationMethod, guardianApproval?, raw }` |
588
- | `createCheckout(input)` | `{ sessionId, checkoutUrl, expiresAt, raw }` |
590
+ | `createCheckout(input)` | `{ sessionId, checkoutUrl, expiresAt, expiresInSeconds, raw }` |
589
591
  | `purchaseCurrency(input)` | `{ status, clientSecret?, paymentIntentId?, paymentUrl?, transactionId?, orderId?, newBalance?, raw }` |
590
592
  | `confirmPayment({ paymentIntentId, orderId? })` | `{ status, transactionId?, newBalance?, raw }` |
591
593
  | `getOrderDetails({ orderId? \| transactionId? })` | `{ order, financialSummary, statusTimeline, raw }` |
@@ -636,7 +638,7 @@ npm test # vitest
636
638
 
637
639
  ### Stability
638
640
 
639
- As of **`1.0.0`** the public API is **stable**: it follows [semver](https://semver.org/), and **no breaking change ships without a major version bump + a migration note**. Patch = fixes, minor = additive surface (new methods/fields, backward-compatible), major = breaking changes (rare). The wire contract is the same live INVO API you'd call directly, and it's backward-compatible within a major — so a pinned SDK keeps working. Safe to depend on in production; pin a version and watch [releases](https://github.com/Invo-Technologies/invo-web-sdk/releases) for security updates.
641
+ Since **`1.0.0`** the public API is **stable**: it follows [semver](https://semver.org/), and **no breaking change ships without a major version bump + a migration note** (the `2.0.0` `playerPhone` requirement is the one such change to date). Patch = fixes, minor = additive surface (new methods/fields, backward-compatible — e.g. `2.1.0`'s passkey recovery), major = breaking changes (rare). The wire contract is the same live INVO API you'd call directly, and it's backward-compatible within a major — so a pinned SDK keeps working. Safe to depend on in production; pin a version and watch [releases](https://github.com/Invo-Technologies/invo-web-sdk/releases) for security updates.
640
642
 
641
643
  Full history: [CHANGELOG](https://github.com/Invo-Technologies/invo-web-sdk/blob/main/CHANGELOG.md) · [release notes](https://github.com/Invo-Technologies/invo-web-sdk/blob/main/docs/RELEASES.md) (absolute links to `main`).
642
644
 
@@ -88,7 +88,7 @@ var InvoError = class _InvoError extends Error {
88
88
  /** Seconds to wait before retrying, when the backend throttled the call (429 `retry_after`). */
89
89
  get retryAfter() {
90
90
  const v = this.bodyObject()["retry_after"];
91
- const n = typeof v === "string" ? Number(v) : v;
91
+ const n = typeof v === "string" ? v.trim() === "" ? NaN : Number(v) : v;
92
92
  return typeof n === "number" && Number.isFinite(n) && n >= 0 ? n : void 0;
93
93
  }
94
94
  /** `body` as a plain object, or `{}` if it's a string/number/null (non-JSON responses).
@@ -191,7 +191,13 @@ var _Http = class _Http {
191
191
  let res;
192
192
  let networkError;
193
193
  try {
194
- res = await this.fetchImpl(url, { method, headers, body: payload, signal: controller.signal });
194
+ res = await this.fetchImpl(url, {
195
+ method,
196
+ headers,
197
+ body: payload,
198
+ signal: controller.signal,
199
+ redirect: "manual"
200
+ });
195
201
  } catch (err) {
196
202
  networkError = new InvoError({
197
203
  message: err instanceof Error && err.name === "AbortError" ? `Request to ${path} timed out after ${this.timeoutMs}ms` : `Network error calling ${path}: ${err?.message ?? err}`,
@@ -212,6 +218,14 @@ var _Http = class _Http {
212
218
  }
213
219
  throw networkError;
214
220
  }
221
+ if (res.type === "opaqueredirect" || res.status >= 300 && res.status < 400) {
222
+ throw new InvoError({
223
+ message: `Refused to follow a redirect from ${path} \u2014 credentials are never re-sent to a redirected URL.`,
224
+ code: "UNEXPECTED_REDIRECT",
225
+ status: res.status || 0,
226
+ body: null
227
+ });
228
+ }
215
229
  const requestId = pickRequestId(res.headers);
216
230
  const text = await res.text();
217
231
  let parsed = null;
@@ -292,7 +306,7 @@ function pickRequestId(headers) {
292
306
  function retryAfterMs(parsed, headers) {
293
307
  if (parsed && typeof parsed === "object") {
294
308
  const v = parsed["retry_after"];
295
- const n = typeof v === "string" ? Number(v) : v;
309
+ const n = typeof v === "string" ? v.trim() === "" ? NaN : Number(v) : v;
296
310
  if (typeof n === "number" && Number.isFinite(n) && n >= 0) return n * 1e3;
297
311
  }
298
312
  const header = headers && typeof headers.get === "function" ? headers.get("retry-after") : null;
@@ -347,5 +361,5 @@ function toDestinationsResult(raw, direction) {
347
361
  }
348
362
 
349
363
  export { Http, InvoError, assertSecureBaseUrl, toDestinationsResult };
350
- //# sourceMappingURL=chunk-YCEW7NC3.js.map
351
- //# sourceMappingURL=chunk-YCEW7NC3.js.map
364
+ //# sourceMappingURL=chunk-4GNJIQY2.js.map
365
+ //# sourceMappingURL=chunk-4GNJIQY2.js.map
package/dist/index.cjs CHANGED
@@ -90,7 +90,7 @@ var InvoError = class _InvoError extends Error {
90
90
  /** Seconds to wait before retrying, when the backend throttled the call (429 `retry_after`). */
91
91
  get retryAfter() {
92
92
  const v = this.bodyObject()["retry_after"];
93
- const n = typeof v === "string" ? Number(v) : v;
93
+ const n = typeof v === "string" ? v.trim() === "" ? NaN : Number(v) : v;
94
94
  return typeof n === "number" && Number.isFinite(n) && n >= 0 ? n : void 0;
95
95
  }
96
96
  /** `body` as a plain object, or `{}` if it's a string/number/null (non-JSON responses).
@@ -193,7 +193,13 @@ var _Http = class _Http {
193
193
  let res;
194
194
  let networkError;
195
195
  try {
196
- res = await this.fetchImpl(url, { method, headers, body: payload, signal: controller.signal });
196
+ res = await this.fetchImpl(url, {
197
+ method,
198
+ headers,
199
+ body: payload,
200
+ signal: controller.signal,
201
+ redirect: "manual"
202
+ });
197
203
  } catch (err) {
198
204
  networkError = new InvoError({
199
205
  message: err instanceof Error && err.name === "AbortError" ? `Request to ${path} timed out after ${this.timeoutMs}ms` : `Network error calling ${path}: ${err?.message ?? err}`,
@@ -214,6 +220,14 @@ var _Http = class _Http {
214
220
  }
215
221
  throw networkError;
216
222
  }
223
+ if (res.type === "opaqueredirect" || res.status >= 300 && res.status < 400) {
224
+ throw new InvoError({
225
+ message: `Refused to follow a redirect from ${path} \u2014 credentials are never re-sent to a redirected URL.`,
226
+ code: "UNEXPECTED_REDIRECT",
227
+ status: res.status || 0,
228
+ body: null
229
+ });
230
+ }
217
231
  const requestId = pickRequestId(res.headers);
218
232
  const text = await res.text();
219
233
  let parsed = null;
@@ -294,7 +308,7 @@ function pickRequestId(headers) {
294
308
  function retryAfterMs(parsed, headers) {
295
309
  if (parsed && typeof parsed === "object") {
296
310
  const v = parsed["retry_after"];
297
- const n = typeof v === "string" ? Number(v) : v;
311
+ const n = typeof v === "string" ? v.trim() === "" ? NaN : Number(v) : v;
298
312
  if (typeof n === "number" && Number.isFinite(n) && n >= 0) return n * 1e3;
299
313
  }
300
314
  const header = headers && typeof headers.get === "function" ? headers.get("retry-after") : null;
@@ -306,6 +320,13 @@ function retryAfterMs(parsed, headers) {
306
320
  }
307
321
 
308
322
  // src/shared/webauthn.ts
323
+ function malformedOptions(field) {
324
+ return new InvoError({
325
+ message: `Malformed WebAuthn options from the backend: missing/invalid \`${field}\`.`,
326
+ code: "WEBAUTHN_OPTIONS_MALFORMED",
327
+ status: 0
328
+ });
329
+ }
309
330
  function b64urlToBuffer(value) {
310
331
  const pad = value.length % 4 === 0 ? "" : "=".repeat(4 - value.length % 4);
311
332
  const b64 = value.replace(/-/g, "+").replace(/_/g, "/") + pad;
@@ -331,6 +352,8 @@ function descriptorsToBinary(list) {
331
352
  });
332
353
  }
333
354
  function toCreationOptions(json) {
355
+ if (typeof json?.["challenge"] !== "string") throw malformedOptions("challenge");
356
+ if (typeof json["user"]?.id !== "string") throw malformedOptions("user.id");
334
357
  const opts = {
335
358
  ...json,
336
359
  challenge: b64urlToBuffer(json["challenge"]),
@@ -345,6 +368,7 @@ function toCreationOptions(json) {
345
368
  return opts;
346
369
  }
347
370
  function toRequestOptions(json) {
371
+ if (typeof json?.["challenge"] !== "string") throw malformedOptions("challenge");
348
372
  const opts = {
349
373
  ...json,
350
374
  challenge: b64urlToBuffer(json["challenge"])
@@ -633,7 +657,7 @@ var InvoClient = class {
633
657
  }
634
658
  /** Verify the enrollment OTP (see {@link enrollmentBegin}); on success, retry `enrollPasskey()`. */
635
659
  async enrollmentVerify(code, opts) {
636
- if (!code) throw new Error("enrollmentVerify requires the OTP `code`.");
660
+ if (!code || !code.trim()) throw new Error("enrollmentVerify requires the OTP `code`.");
637
661
  return this.withTokenRetry(async () => {
638
662
  const raw = await this.post(
639
663
  "/api/sdk/device/enrollment/verify",
@@ -687,7 +711,7 @@ var InvoClient = class {
687
711
  }
688
712
  /** Verify the recovery code (see {@link recoveryBegin}); on success, call `enrollPasskey()`. */
689
713
  async recoveryComplete(code, opts) {
690
- if (!code) throw new Error("recoveryComplete requires the one-time `code`.");
714
+ if (!code || !code.trim()) throw new Error("recoveryComplete requires the one-time `code`.");
691
715
  return this.withTokenRetry(async () => {
692
716
  const raw = await this.post(
693
717
  "/api/sdk/device/recover/complete",
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as ClientConfig, a as CallOptions, A as ApproveResult, b as ConfirmReceiptResult, L as LinkDeviceResult, P as PendingCollectResult, D as DestinationsQuery, c as DestinationsResult, B as BalanceResult, E as EnrollmentBeginResult, d as EnrollmentVerifyResult, R as RecoveryBeginResult, e as RecoveryCompleteResult } from './types-DtihCpOj.cjs';
2
- export { f as BalanceRow, g as DestinationGame, I as InvoError, h as InvoErrorInfo, i as InvoHooks, j as InvoRequestInfo, k as InvoResponseInfo, l as PendingCollectItem, m as Rail, V as VerificationMethod } from './types-DtihCpOj.cjs';
1
+ import { C as ClientConfig, a as CallOptions, A as ApproveResult, b as ConfirmReceiptResult, L as LinkDeviceResult, P as PendingCollectResult, D as DestinationsQuery, c as DestinationsResult, B as BalanceResult, E as EnrollmentBeginResult, d as EnrollmentVerifyResult, R as RecoveryBeginResult, e as RecoveryCompleteResult } from './types-CU2BqbHN.cjs';
2
+ export { f as BalanceRow, g as DestinationGame, I as InvoError, h as InvoErrorInfo, i as InvoHooks, j as InvoRequestInfo, k as InvoResponseInfo, l as PendingCollectItem, m as Rail, V as VerificationMethod } from './types-CU2BqbHN.cjs';
3
3
 
4
4
  declare class InvoClient {
5
5
  private readonly http;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as ClientConfig, a as CallOptions, A as ApproveResult, b as ConfirmReceiptResult, L as LinkDeviceResult, P as PendingCollectResult, D as DestinationsQuery, c as DestinationsResult, B as BalanceResult, E as EnrollmentBeginResult, d as EnrollmentVerifyResult, R as RecoveryBeginResult, e as RecoveryCompleteResult } from './types-DtihCpOj.js';
2
- export { f as BalanceRow, g as DestinationGame, I as InvoError, h as InvoErrorInfo, i as InvoHooks, j as InvoRequestInfo, k as InvoResponseInfo, l as PendingCollectItem, m as Rail, V as VerificationMethod } from './types-DtihCpOj.js';
1
+ import { C as ClientConfig, a as CallOptions, A as ApproveResult, b as ConfirmReceiptResult, L as LinkDeviceResult, P as PendingCollectResult, D as DestinationsQuery, c as DestinationsResult, B as BalanceResult, E as EnrollmentBeginResult, d as EnrollmentVerifyResult, R as RecoveryBeginResult, e as RecoveryCompleteResult } from './types-CU2BqbHN.js';
2
+ export { f as BalanceRow, g as DestinationGame, I as InvoError, h as InvoErrorInfo, i as InvoHooks, j as InvoRequestInfo, k as InvoResponseInfo, l as PendingCollectItem, m as Rail, V as VerificationMethod } from './types-CU2BqbHN.js';
3
3
 
4
4
  declare class InvoClient {
5
5
  private readonly http;
package/dist/index.js CHANGED
@@ -1,7 +1,14 @@
1
- import { assertSecureBaseUrl, Http, toDestinationsResult, InvoError } from './chunk-YCEW7NC3.js';
2
- export { InvoError } from './chunk-YCEW7NC3.js';
1
+ import { assertSecureBaseUrl, Http, toDestinationsResult, InvoError } from './chunk-4GNJIQY2.js';
2
+ export { InvoError } from './chunk-4GNJIQY2.js';
3
3
 
4
4
  // src/shared/webauthn.ts
5
+ function malformedOptions(field) {
6
+ return new InvoError({
7
+ message: `Malformed WebAuthn options from the backend: missing/invalid \`${field}\`.`,
8
+ code: "WEBAUTHN_OPTIONS_MALFORMED",
9
+ status: 0
10
+ });
11
+ }
5
12
  function b64urlToBuffer(value) {
6
13
  const pad = value.length % 4 === 0 ? "" : "=".repeat(4 - value.length % 4);
7
14
  const b64 = value.replace(/-/g, "+").replace(/_/g, "/") + pad;
@@ -27,6 +34,8 @@ function descriptorsToBinary(list) {
27
34
  });
28
35
  }
29
36
  function toCreationOptions(json) {
37
+ if (typeof json?.["challenge"] !== "string") throw malformedOptions("challenge");
38
+ if (typeof json["user"]?.id !== "string") throw malformedOptions("user.id");
30
39
  const opts = {
31
40
  ...json,
32
41
  challenge: b64urlToBuffer(json["challenge"]),
@@ -41,6 +50,7 @@ function toCreationOptions(json) {
41
50
  return opts;
42
51
  }
43
52
  function toRequestOptions(json) {
53
+ if (typeof json?.["challenge"] !== "string") throw malformedOptions("challenge");
44
54
  const opts = {
45
55
  ...json,
46
56
  challenge: b64urlToBuffer(json["challenge"])
@@ -286,7 +296,7 @@ var InvoClient = class {
286
296
  }
287
297
  /** Verify the enrollment OTP (see {@link enrollmentBegin}); on success, retry `enrollPasskey()`. */
288
298
  async enrollmentVerify(code, opts) {
289
- if (!code) throw new Error("enrollmentVerify requires the OTP `code`.");
299
+ if (!code || !code.trim()) throw new Error("enrollmentVerify requires the OTP `code`.");
290
300
  return this.withTokenRetry(async () => {
291
301
  const raw = await this.post(
292
302
  "/api/sdk/device/enrollment/verify",
@@ -340,7 +350,7 @@ var InvoClient = class {
340
350
  }
341
351
  /** Verify the recovery code (see {@link recoveryBegin}); on success, call `enrollPasskey()`. */
342
352
  async recoveryComplete(code, opts) {
343
- if (!code) throw new Error("recoveryComplete requires the one-time `code`.");
353
+ if (!code || !code.trim()) throw new Error("recoveryComplete requires the one-time `code`.");
344
354
  return this.withTokenRetry(async () => {
345
355
  const raw = await this.post(
346
356
  "/api/sdk/device/recover/complete",
package/dist/server.cjs CHANGED
@@ -92,7 +92,7 @@ var InvoError = class _InvoError extends Error {
92
92
  /** Seconds to wait before retrying, when the backend throttled the call (429 `retry_after`). */
93
93
  get retryAfter() {
94
94
  const v = this.bodyObject()["retry_after"];
95
- const n = typeof v === "string" ? Number(v) : v;
95
+ const n = typeof v === "string" ? v.trim() === "" ? NaN : Number(v) : v;
96
96
  return typeof n === "number" && Number.isFinite(n) && n >= 0 ? n : void 0;
97
97
  }
98
98
  /** `body` as a plain object, or `{}` if it's a string/number/null (non-JSON responses).
@@ -195,7 +195,13 @@ var _Http = class _Http {
195
195
  let res;
196
196
  let networkError;
197
197
  try {
198
- res = await this.fetchImpl(url, { method, headers, body: payload, signal: controller.signal });
198
+ res = await this.fetchImpl(url, {
199
+ method,
200
+ headers,
201
+ body: payload,
202
+ signal: controller.signal,
203
+ redirect: "manual"
204
+ });
199
205
  } catch (err) {
200
206
  networkError = new InvoError({
201
207
  message: err instanceof Error && err.name === "AbortError" ? `Request to ${path} timed out after ${this.timeoutMs}ms` : `Network error calling ${path}: ${err?.message ?? err}`,
@@ -216,6 +222,14 @@ var _Http = class _Http {
216
222
  }
217
223
  throw networkError;
218
224
  }
225
+ if (res.type === "opaqueredirect" || res.status >= 300 && res.status < 400) {
226
+ throw new InvoError({
227
+ message: `Refused to follow a redirect from ${path} \u2014 credentials are never re-sent to a redirected URL.`,
228
+ code: "UNEXPECTED_REDIRECT",
229
+ status: res.status || 0,
230
+ body: null
231
+ });
232
+ }
219
233
  const requestId = pickRequestId(res.headers);
220
234
  const text = await res.text();
221
235
  let parsed = null;
@@ -296,7 +310,7 @@ function pickRequestId(headers) {
296
310
  function retryAfterMs(parsed, headers) {
297
311
  if (parsed && typeof parsed === "object") {
298
312
  const v = parsed["retry_after"];
299
- const n = typeof v === "string" ? Number(v) : v;
313
+ const n = typeof v === "string" ? v.trim() === "" ? NaN : Number(v) : v;
300
314
  if (typeof n === "number" && Number.isFinite(n) && n >= 0) return n * 1e3;
301
315
  }
302
316
  const header = headers && typeof headers.get === "function" ? headers.get("retry-after") : null;
@@ -379,6 +393,12 @@ function parseSignatureHeader(header) {
379
393
  function hmacHex(secret, message) {
380
394
  return crypto.createHmac("sha256", secret).update(message).digest("hex");
381
395
  }
396
+ function safeEqualHexNode(a, b) {
397
+ const ba = Buffer.from(a, "utf8");
398
+ const bb = Buffer.from(b, "utf8");
399
+ if (ba.length !== bb.length) return false;
400
+ return crypto.timingSafeEqual(ba, bb);
401
+ }
382
402
  function safeEqualHex(a, b) {
383
403
  if (a.length !== b.length) return false;
384
404
  let diff = 0;
@@ -431,7 +451,7 @@ function verifyWebhook(rawBody, signatureHeader, secret, opts = {}) {
431
451
  );
432
452
  const matched = secrets.some((s) => {
433
453
  const expected = hmacHex(s, message);
434
- return sigs.some((sig) => safeEqualHex(sig, expected));
454
+ return sigs.some((sig) => safeEqualHexNode(sig, expected));
435
455
  });
436
456
  if (!matched) {
437
457
  throw webhookError("Webhook signature verification failed.", "WEBHOOK_SIGNATURE_INVALID");
@@ -508,7 +528,7 @@ async function hmacHexSubtle(secret, message) {
508
528
  }
509
529
 
510
530
  // src/server.ts
511
- var DEFAULT_UA = "invonetwork-web-sdk/2.1.0 (+https://invo.network)";
531
+ var DEFAULT_UA = "invonetwork-web-sdk/2.1.2 (+https://invo.network)";
512
532
  var MAX_USD_AMOUNT = 999.99;
513
533
  var MAX_ITEM_PRICE = 999999.99;
514
534
  function invalidInput(label, value, why) {
@@ -789,6 +809,7 @@ var InvoServer = class {
789
809
  sessionId: String(raw["session_id"] ?? ""),
790
810
  checkoutUrl: requireField(raw["checkout_url"], "checkout_url", raw),
791
811
  expiresAt: String(raw["expires_at"] ?? ""),
812
+ expiresInSeconds: Number(raw["expires_in_seconds"] ?? 0),
792
813
  raw
793
814
  };
794
815
  }
package/dist/server.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as InvoError, S as ServerConfig, a as CallOptions, n as PlayerToken, o as InitiateSendInput, p as InitiateResult, q as InitiateTransferInput, r as CreateCheckoutInput, s as CreateCheckoutResult, t as PurchaseInput, u as PurchaseResult, v as ConfirmPaymentResult, O as OrderDetailsResult, w as PurchaseItemInput, x as PurchaseItemResult, y as ItemHistoryQuery, z as ItemHistoryResult, F as ItemOrderQuery, G as PlayerBalanceQuery, H as PlayerBalanceResult, J as InboundPendingQuery, K as InboundPendingResult, M as LinkedIdentitiesQuery, N as LinkedIdentitiesResult, Q as SmsVerifyResult, T as ClaimTransferInput, U as ClaimResult, W as ClaimCurrencyInput, X as TransactionStatusResult, Y as GuardianApprovalStatusResult, Z as ServerDestinationsQuery, c as DestinationsResult, _ as PhoneShareContact, $ as PhoneShareInitiateResult, a0 as PhoneShareApproveInput, a1 as PhoneShareApproveResult, a2 as PhoneShareStatusResult } from './types-DtihCpOj.cjs';
2
- export { a3 as CurrencyBalance, g as DestinationGame, a4 as InboundPendingItem, h as InvoErrorInfo, i as InvoHooks, j as InvoRequestInfo, k as InvoResponseInfo, a5 as LinkedIdentityEmail, m as Rail, V as VerificationMethod } from './types-DtihCpOj.cjs';
1
+ import { I as InvoError, S as ServerConfig, a as CallOptions, n as PlayerToken, o as InitiateSendInput, p as InitiateResult, q as InitiateTransferInput, r as CreateCheckoutInput, s as CreateCheckoutResult, t as PurchaseInput, u as PurchaseResult, v as ConfirmPaymentResult, O as OrderDetailsResult, w as PurchaseItemInput, x as PurchaseItemResult, y as ItemHistoryQuery, z as ItemHistoryResult, F as ItemOrderQuery, G as PlayerBalanceQuery, H as PlayerBalanceResult, J as InboundPendingQuery, K as InboundPendingResult, M as LinkedIdentitiesQuery, N as LinkedIdentitiesResult, Q as SmsVerifyResult, T as ClaimTransferInput, U as ClaimResult, W as ClaimCurrencyInput, X as TransactionStatusResult, Y as GuardianApprovalStatusResult, Z as ServerDestinationsQuery, c as DestinationsResult, _ as PhoneShareContact, $ as PhoneShareInitiateResult, a0 as PhoneShareApproveInput, a1 as PhoneShareApproveResult, a2 as PhoneShareStatusResult } from './types-CU2BqbHN.cjs';
2
+ export { a3 as CurrencyBalance, g as DestinationGame, a4 as InboundPendingItem, h as InvoErrorInfo, i as InvoHooks, j as InvoRequestInfo, k as InvoResponseInfo, a5 as LinkedIdentityEmail, m as Rail, V as VerificationMethod } from './types-CU2BqbHN.cjs';
3
3
 
4
4
  interface VerifyWebhookOptions {
5
5
  /** Max age of the signed timestamp, in seconds. Default 300 (5 min). */
package/dist/server.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { I as InvoError, S as ServerConfig, a as CallOptions, n as PlayerToken, o as InitiateSendInput, p as InitiateResult, q as InitiateTransferInput, r as CreateCheckoutInput, s as CreateCheckoutResult, t as PurchaseInput, u as PurchaseResult, v as ConfirmPaymentResult, O as OrderDetailsResult, w as PurchaseItemInput, x as PurchaseItemResult, y as ItemHistoryQuery, z as ItemHistoryResult, F as ItemOrderQuery, G as PlayerBalanceQuery, H as PlayerBalanceResult, J as InboundPendingQuery, K as InboundPendingResult, M as LinkedIdentitiesQuery, N as LinkedIdentitiesResult, Q as SmsVerifyResult, T as ClaimTransferInput, U as ClaimResult, W as ClaimCurrencyInput, X as TransactionStatusResult, Y as GuardianApprovalStatusResult, Z as ServerDestinationsQuery, c as DestinationsResult, _ as PhoneShareContact, $ as PhoneShareInitiateResult, a0 as PhoneShareApproveInput, a1 as PhoneShareApproveResult, a2 as PhoneShareStatusResult } from './types-DtihCpOj.js';
2
- export { a3 as CurrencyBalance, g as DestinationGame, a4 as InboundPendingItem, h as InvoErrorInfo, i as InvoHooks, j as InvoRequestInfo, k as InvoResponseInfo, a5 as LinkedIdentityEmail, m as Rail, V as VerificationMethod } from './types-DtihCpOj.js';
1
+ import { I as InvoError, S as ServerConfig, a as CallOptions, n as PlayerToken, o as InitiateSendInput, p as InitiateResult, q as InitiateTransferInput, r as CreateCheckoutInput, s as CreateCheckoutResult, t as PurchaseInput, u as PurchaseResult, v as ConfirmPaymentResult, O as OrderDetailsResult, w as PurchaseItemInput, x as PurchaseItemResult, y as ItemHistoryQuery, z as ItemHistoryResult, F as ItemOrderQuery, G as PlayerBalanceQuery, H as PlayerBalanceResult, J as InboundPendingQuery, K as InboundPendingResult, M as LinkedIdentitiesQuery, N as LinkedIdentitiesResult, Q as SmsVerifyResult, T as ClaimTransferInput, U as ClaimResult, W as ClaimCurrencyInput, X as TransactionStatusResult, Y as GuardianApprovalStatusResult, Z as ServerDestinationsQuery, c as DestinationsResult, _ as PhoneShareContact, $ as PhoneShareInitiateResult, a0 as PhoneShareApproveInput, a1 as PhoneShareApproveResult, a2 as PhoneShareStatusResult } from './types-CU2BqbHN.js';
2
+ export { a3 as CurrencyBalance, g as DestinationGame, a4 as InboundPendingItem, h as InvoErrorInfo, i as InvoHooks, j as InvoRequestInfo, k as InvoResponseInfo, a5 as LinkedIdentityEmail, m as Rail, V as VerificationMethod } from './types-CU2BqbHN.js';
3
3
 
4
4
  interface VerifyWebhookOptions {
5
5
  /** Max age of the signed timestamp, in seconds. Default 300 (5 min). */
package/dist/server.js CHANGED
@@ -1,6 +1,6 @@
1
- import { InvoError, assertSecureBaseUrl, Http, toDestinationsResult } from './chunk-YCEW7NC3.js';
2
- export { InvoError } from './chunk-YCEW7NC3.js';
3
- import { createHmac } from 'crypto';
1
+ import { InvoError, assertSecureBaseUrl, Http, toDestinationsResult } from './chunk-4GNJIQY2.js';
2
+ export { InvoError } from './chunk-4GNJIQY2.js';
3
+ import { createHmac, timingSafeEqual } from 'crypto';
4
4
 
5
5
  var DEFAULT_TOLERANCE_SEC = 300;
6
6
  var ENCODER = new TextEncoder();
@@ -32,6 +32,12 @@ function parseSignatureHeader(header) {
32
32
  function hmacHex(secret, message) {
33
33
  return createHmac("sha256", secret).update(message).digest("hex");
34
34
  }
35
+ function safeEqualHexNode(a, b) {
36
+ const ba = Buffer.from(a, "utf8");
37
+ const bb = Buffer.from(b, "utf8");
38
+ if (ba.length !== bb.length) return false;
39
+ return timingSafeEqual(ba, bb);
40
+ }
35
41
  function safeEqualHex(a, b) {
36
42
  if (a.length !== b.length) return false;
37
43
  let diff = 0;
@@ -84,7 +90,7 @@ function verifyWebhook(rawBody, signatureHeader, secret, opts = {}) {
84
90
  );
85
91
  const matched = secrets.some((s) => {
86
92
  const expected = hmacHex(s, message);
87
- return sigs.some((sig) => safeEqualHex(sig, expected));
93
+ return sigs.some((sig) => safeEqualHexNode(sig, expected));
88
94
  });
89
95
  if (!matched) {
90
96
  throw webhookError("Webhook signature verification failed.", "WEBHOOK_SIGNATURE_INVALID");
@@ -161,7 +167,7 @@ async function hmacHexSubtle(secret, message) {
161
167
  }
162
168
 
163
169
  // src/server.ts
164
- var DEFAULT_UA = "invonetwork-web-sdk/2.1.0 (+https://invo.network)";
170
+ var DEFAULT_UA = "invonetwork-web-sdk/2.1.2 (+https://invo.network)";
165
171
  var MAX_USD_AMOUNT = 999.99;
166
172
  var MAX_ITEM_PRICE = 999999.99;
167
173
  function invalidInput(label, value, why) {
@@ -442,6 +448,7 @@ var InvoServer = class {
442
448
  sessionId: String(raw["session_id"] ?? ""),
443
449
  checkoutUrl: requireField(raw["checkout_url"], "checkout_url", raw),
444
450
  expiresAt: String(raw["expires_at"] ?? ""),
451
+ expiresInSeconds: Number(raw["expires_in_seconds"] ?? 0),
445
452
  raw
446
453
  };
447
454
  }
@@ -198,6 +198,8 @@ interface CreateCheckoutResult {
198
198
  /** Send the browser here; INVO's hosted page handles the processor + 3-D Secure. */
199
199
  checkoutUrl: string;
200
200
  expiresAt: string;
201
+ /** The `checkout_url` token TTL in seconds (e.g. 900 = 15 min). 0 if the backend omits it. */
202
+ expiresInSeconds: number;
201
203
  raw: Record<string, unknown>;
202
204
  }
203
205
  interface PurchaseInput {
@@ -198,6 +198,8 @@ interface CreateCheckoutResult {
198
198
  /** Send the browser here; INVO's hosted page handles the processor + 3-D Secure. */
199
199
  checkoutUrl: string;
200
200
  expiresAt: string;
201
+ /** The `checkout_url` token TTL in seconds (e.g. 900 = 15 min). 0 if the backend omits it. */
202
+ expiresInSeconds: number;
201
203
  raw: Record<string, unknown>;
202
204
  }
203
205
  interface PurchaseInput {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@invonetwork/web-sdk",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "INVO Web SDK — currency purchase + passkey (WebAuthn) verification for partner web platforms.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "private": false,