@invonetwork/web-sdk 3.34.1 → 3.36.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.
Files changed (33) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +115 -4
  3. package/dist/chunk-B75DBT53.js +6 -0
  4. package/dist/{chunk-3BR7URPM.js → chunk-BGCSSWVL.js} +104 -2
  5. package/dist/{chunk-MJXQ3Q7C.js → chunk-J4IQ3ANY.js} +240 -70
  6. package/dist/{chunk-PEYWNML4.js → chunk-SCFK6IVH.js} +3 -3
  7. package/dist/game-server.cjs +302 -73
  8. package/dist/game-server.d.cts +4 -4
  9. package/dist/game-server.d.ts +4 -4
  10. package/dist/game-server.js +5 -5
  11. package/dist/game.cjs +103 -1
  12. package/dist/game.d.cts +3 -3
  13. package/dist/game.d.ts +3 -3
  14. package/dist/game.js +3 -3
  15. package/dist/{hosted-approval-B6yY7ExK.d.cts → hosted-approval-BKI9oHwf.d.cts} +1 -1
  16. package/dist/{hosted-approval-CZ5EYFlM.d.ts → hosted-approval-fgVkugRU.d.ts} +1 -1
  17. package/dist/index.cjs +102 -0
  18. package/dist/index.d.cts +4 -4
  19. package/dist/index.d.ts +4 -4
  20. package/dist/index.js +2 -2
  21. package/dist/{server-A1s7zqzG.d.cts → server-BMY3q2Bn.d.cts} +122 -7
  22. package/dist/{server-JARGQrat.d.ts → server-CSRCWgrK.d.ts} +122 -7
  23. package/dist/server.cjs +341 -66
  24. package/dist/server.d.cts +3 -3
  25. package/dist/server.d.ts +3 -3
  26. package/dist/server.js +3 -3
  27. package/dist/{types-B4J9Ifd2.d.ts → types-BcdXf2S5.d.cts} +173 -1
  28. package/dist/{types-B4J9Ifd2.d.cts → types-BcdXf2S5.d.ts} +173 -1
  29. package/dist/{version-DB2wgiPY.d.cts → version-QIFHOifq.d.cts} +1 -1
  30. package/dist/{version-DB2wgiPY.d.ts → version-QIFHOifq.d.ts} +1 -1
  31. package/docs/apple-in-app-purchases.md +425 -0
  32. package/package.json +2 -1
  33. package/dist/chunk-6763YM7P.js +0 -6
@@ -1,7 +1,93 @@
1
- import { SDK_VERSION } from './chunk-6763YM7P.js';
2
- import { InvoError, assertSecureBaseUrl, Http, toRequestPhoneChangeResult, toPhoneChangeRequest, toPurchaseStatusResult, receiptFields, creditFields, toLoyaltyCardsResult, buildGameEventBody, toReportGameEventResult, toDestinationsResult } from './chunk-3BR7URPM.js';
1
+ import { SDK_VERSION } from './chunk-B75DBT53.js';
2
+ import { InvoError, assertSecureBaseUrl, Http, toRequestPhoneChangeResult, toPhoneChangeRequest, toPurchaseStatusResult, receiptFields, creditFields, toLoyaltyCardsResult, buildGameEventBody, toReportGameEventResult, toDestinationsResult } from './chunk-BGCSSWVL.js';
3
3
  import { createHmac, timingSafeEqual } from 'crypto';
4
4
 
5
+ // src/shared/apple.ts
6
+ var FINISHED_STATUSES = /* @__PURE__ */ new Set(["credited", "already_credited"]);
7
+ var APPLE_FINISH_ERROR_CODES = Object.freeze([
8
+ "APPLE_TRANSACTION_REVOKED",
9
+ "APPLE_TRANSACTION_ALREADY_USED",
10
+ "APPLE_TRANSACTION_TOO_OLD"
11
+ ]);
12
+ function bodyFinish(body) {
13
+ if (body && typeof body === "object") {
14
+ const f = body["finish"];
15
+ if (typeof f === "boolean") return f;
16
+ }
17
+ return void 0;
18
+ }
19
+ function errorView(e) {
20
+ if (e instanceof InvoError) return { isError: true, codes: [e.code, e.rawCode], finish: bodyFinish(e.body) };
21
+ if (e instanceof Error && e.name === "InvoError") {
22
+ const r = e;
23
+ return {
24
+ isError: true,
25
+ codes: [typeof r.code === "string" ? r.code : void 0, typeof r.rawCode === "string" ? r.rawCode : void 0],
26
+ finish: bodyFinish(r.body)
27
+ };
28
+ }
29
+ if (e instanceof Error) return { isError: true, codes: [], finish: void 0 };
30
+ return { isError: false, codes: [], finish: void 0 };
31
+ }
32
+ function shouldFinishAppleTransaction(outcome) {
33
+ const err = errorView(outcome);
34
+ if (err.isError) {
35
+ if (err.finish !== void 0) return err.finish;
36
+ return err.codes.some((c) => c !== void 0 && APPLE_FINISH_ERROR_CODES.includes(c));
37
+ }
38
+ if (outcome && typeof outcome === "object") {
39
+ const o = outcome;
40
+ if (typeof o.finish === "boolean") return o.finish;
41
+ const rawFinish = bodyFinish(o.raw);
42
+ if (rawFinish !== void 0) return rawFinish;
43
+ return typeof o.status === "string" && FINISHED_STATUSES.has(o.status);
44
+ }
45
+ return false;
46
+ }
47
+ function isAppleCreditPending(err) {
48
+ return errorView(err).codes.includes("APPLE_CREDIT_PENDING");
49
+ }
50
+ function nullableString(v) {
51
+ return v === null || v === void 0 ? null : String(v);
52
+ }
53
+ function toNumber(v) {
54
+ const n = typeof v === "number" ? v : Number(v);
55
+ return Number.isFinite(n) ? n : 0;
56
+ }
57
+ function toAppleProductsResult(raw) {
58
+ const rows = Array.isArray(raw["products"]) ? raw["products"] : [];
59
+ return {
60
+ bundleId: String(raw["bundle_id"] ?? ""),
61
+ canSell: raw["can_sell"] === true,
62
+ unavailableReason: nullableString(raw["unavailable_reason"]),
63
+ products: rows.map((p) => ({
64
+ productId: String(p["product_id"] ?? ""),
65
+ coins: toNumber(p["coins"]),
66
+ label: String(p["label"] ?? p["product_id"] ?? ""),
67
+ priceUsd: nullableString(p["price_usd"]),
68
+ active: p["active"] !== false,
69
+ // Fail closed: only an explicit `true` offers the product.
70
+ available: p["available"] === true,
71
+ unavailableReason: nullableString(p["unavailable_reason"])
72
+ })),
73
+ raw
74
+ };
75
+ }
76
+ function toApplePurchaseResult(raw) {
77
+ return {
78
+ status: String(raw["status"] ?? ""),
79
+ orderId: String(raw["order_id"] ?? ""),
80
+ transactionId: String(raw["transaction_id"] ?? ""),
81
+ productId: String(raw["product_id"] ?? ""),
82
+ coins: toNumber(raw["coins"]),
83
+ balance: nullableString(raw["balance"]),
84
+ environment: String(raw["environment"] ?? ""),
85
+ testMode: raw["test_mode"] === true,
86
+ finish: typeof raw["finish"] === "boolean" ? raw["finish"] : FINISHED_STATUSES.has(String(raw["status"] ?? "")),
87
+ raw
88
+ };
89
+ }
90
+
5
91
  // src/payouts.ts
6
92
  var AMOUNT = /^\d+(\.\d{1,2})?$/;
7
93
  function invalidInput(label, value, why) {
@@ -1332,11 +1418,11 @@ function toSavedCard(row) {
1332
1418
  raw: r
1333
1419
  };
1334
1420
  }
1335
- function nullableString(v) {
1421
+ function nullableString2(v) {
1336
1422
  return v == null ? null : String(v);
1337
1423
  }
1338
1424
  function optionalString(r, key) {
1339
- return key in r ? nullableString(r[key]) : void 0;
1425
+ return key in r ? nullableString2(r[key]) : void 0;
1340
1426
  }
1341
1427
  function toCheckoutWarnings(v) {
1342
1428
  if (!Array.isArray(v)) return void 0;
@@ -1356,27 +1442,27 @@ function toRefundResult(raw, subscriptionId, clientRequestId) {
1356
1442
  const base = {
1357
1443
  status: String(raw["status"] ?? ""),
1358
1444
  idempotentReplay: raw["idempotent_replay"] === true,
1359
- refundKey: nullableString(raw["refund_key"]),
1360
- clientRequestId: nullableString(raw["client_request_id"]) ?? clientRequestId,
1445
+ refundKey: nullableString2(raw["refund_key"]),
1446
+ clientRequestId: nullableString2(raw["client_request_id"]) ?? clientRequestId,
1361
1447
  subscriptionId: String(raw["subscription_id"] ?? subscriptionId),
1362
1448
  periodSeq: raw["period_seq"] == null ? null : Number(raw["period_seq"]),
1363
- transactionId: nullableString(raw["transaction_id"]),
1364
- refundedAmountUsd: nullableString(raw["refunded_amount_usd"]),
1365
- totalRefundedAmountUsd: nullableString(raw["total_refunded_amount_usd"]),
1366
- remainingRefundableUsd: nullableString(raw["remaining_refundable_usd"]),
1449
+ transactionId: nullableString2(raw["transaction_id"]),
1450
+ refundedAmountUsd: nullableString2(raw["refunded_amount_usd"]),
1451
+ totalRefundedAmountUsd: nullableString2(raw["total_refunded_amount_usd"]),
1452
+ remainingRefundableUsd: nullableString2(raw["remaining_refundable_usd"]),
1367
1453
  isFullRefund: raw["is_full_refund"] === true,
1368
- fundingShape: nullableString(raw["funding_shape"]),
1369
- balanceDeltaCoins: nullableString(raw["balance_delta_coins"]),
1370
- cardRefundedUsd: nullableString(raw["card_refunded_usd"]),
1454
+ fundingShape: nullableString2(raw["funding_shape"]),
1455
+ balanceDeltaCoins: nullableString2(raw["balance_delta_coins"]),
1456
+ cardRefundedUsd: nullableString2(raw["card_refunded_usd"]),
1371
1457
  // Neutral field only; the vendor-named sibling is deliberately not read.
1372
- processorRefundReference: nullableString(raw["processor_refund_reference"]),
1458
+ processorRefundReference: nullableString2(raw["processor_refund_reference"]),
1373
1459
  processorRefundAdopted: raw["processor_refund_adopted"] === true,
1374
1460
  invoFeeRetained: raw["invo_fee_retained"] === true,
1375
- partnerRevenueReversedUsd: nullableString(raw["partner_revenue_reversed_usd"]),
1376
- partnerRevenueReversalMode: nullableString(raw["partner_revenue_reversal_mode"]),
1377
- reason: nullableString(raw["reason"]),
1378
- refundedAt: nullableString(raw["refunded_at"]),
1379
- newBalance: nullableString(raw["new_balance"]),
1461
+ partnerRevenueReversedUsd: nullableString2(raw["partner_revenue_reversed_usd"]),
1462
+ partnerRevenueReversalMode: nullableString2(raw["partner_revenue_reversal_mode"]),
1463
+ reason: nullableString2(raw["reason"]),
1464
+ refundedAt: nullableString2(raw["refunded_at"]),
1465
+ newBalance: nullableString2(raw["new_balance"]),
1380
1466
  revenueShareAttribution: a ? {
1381
1467
  recipientPlayerId: Number(a["recipient_player_id"] ?? 0),
1382
1468
  percent: String(a["percent"] ?? ""),
@@ -1409,11 +1495,11 @@ function toRefundResult(raw, subscriptionId, clientRequestId) {
1409
1495
  status: "pending_approval",
1410
1496
  requestId: String(raw["request_id"] ?? raw["refund_request_id"] ?? ""),
1411
1497
  requestStatus: String(raw["request_status"] ?? ""),
1412
- requestedAmountUsd: nullableString(raw["requested_amount_usd"]),
1413
- requestedAt: nullableString(raw["requested_at"]),
1414
- dailyCapUsd: nullableString(raw["daily_cap_usd"]),
1415
- executedTodayUsd: nullableString(raw["executed_today_usd"]),
1416
- message: nullableString(raw["message"])
1498
+ requestedAmountUsd: nullableString2(raw["requested_amount_usd"]),
1499
+ requestedAt: nullableString2(raw["requested_at"]),
1500
+ dailyCapUsd: nullableString2(raw["daily_cap_usd"]),
1501
+ executedTodayUsd: nullableString2(raw["executed_today_usd"]),
1502
+ message: nullableString2(raw["message"])
1417
1503
  };
1418
1504
  return pending;
1419
1505
  }
@@ -1430,35 +1516,35 @@ function toSubscription(row) {
1430
1516
  clientRequestId: String(r["client_request_id"] ?? ""),
1431
1517
  status: String(r["status"] ?? ""),
1432
1518
  amountUsd: String(r["amount_usd"] ?? ""),
1433
- pendingAmountUsd: nullableString(r["pending_amount_usd"]),
1519
+ pendingAmountUsd: nullableString2(r["pending_amount_usd"]),
1434
1520
  interval: String(r["interval"] ?? "month"),
1435
1521
  intervalCount: Number(r["interval_count"] ?? 1),
1436
1522
  itemId: String(r["item_id"] ?? ""),
1437
- itemName: nullableString(r["item_name"]),
1523
+ itemName: nullableString2(r["item_name"]),
1438
1524
  currentPeriodStart: String(r["current_period_start"] ?? ""),
1439
1525
  currentPeriodEnd: String(r["current_period_end"] ?? ""),
1440
1526
  periodSeq: Number(r["period_seq"] ?? 0),
1441
- nextChargeAt: nullableString(r["next_charge_at"]),
1527
+ nextChargeAt: nullableString2(r["next_charge_at"]),
1442
1528
  cancelAtPeriodEnd: r["cancel_at_period_end"] === true,
1443
- trialEnd: nullableString(r["trial_end"]),
1444
- trialAmountUsd: nullableString(r["trial_amount_usd"]),
1445
- canceledAt: nullableString(r["canceled_at"]),
1446
- endedAt: nullableString(r["ended_at"]),
1529
+ trialEnd: nullableString2(r["trial_end"]),
1530
+ trialAmountUsd: nullableString2(r["trial_amount_usd"]),
1531
+ canceledAt: nullableString2(r["canceled_at"]),
1532
+ endedAt: nullableString2(r["ended_at"]),
1447
1533
  walletOnly: r["wallet_only"] === true,
1448
1534
  hasPaymentMethod: r["has_payment_method"] === true,
1449
1535
  fundingRail: String(r["funding_rail"] ?? "card"),
1450
- steamAgreementStatus: nullableString(r["steam_agreement_status"]),
1536
+ steamAgreementStatus: nullableString2(r["steam_agreement_status"]),
1451
1537
  metadata: r["metadata"] && typeof r["metadata"] === "object" ? r["metadata"] : null,
1452
1538
  consent: {
1453
- consent_at: nullableString(consent["consent_at"]),
1454
- consent_ip: nullableString(consent["consent_ip"]),
1455
- consent_user_agent: nullableString(consent["consent_user_agent"]),
1456
- disclosed_amount_usd: nullableString(consent["disclosed_amount_usd"]),
1457
- disclosed_interval: nullableString(consent["disclosed_interval"]),
1458
- terms_version: nullableString(consent["terms_version"]),
1459
- disclosed_trial_amount_usd: nullableString(consent["disclosed_trial_amount_usd"]),
1539
+ consent_at: nullableString2(consent["consent_at"]),
1540
+ consent_ip: nullableString2(consent["consent_ip"]),
1541
+ consent_user_agent: nullableString2(consent["consent_user_agent"]),
1542
+ disclosed_amount_usd: nullableString2(consent["disclosed_amount_usd"]),
1543
+ disclosed_interval: nullableString2(consent["disclosed_interval"]),
1544
+ terms_version: nullableString2(consent["terms_version"]),
1545
+ disclosed_trial_amount_usd: nullableString2(consent["disclosed_trial_amount_usd"]),
1460
1546
  disclosed_trial_days: typeof consent["disclosed_trial_days"] === "number" ? consent["disclosed_trial_days"] : null,
1461
- disclosed_trial_end: nullableString(consent["disclosed_trial_end"])
1547
+ disclosed_trial_end: nullableString2(consent["disclosed_trial_end"])
1462
1548
  },
1463
1549
  createdAt: String(r["created_at"] ?? ""),
1464
1550
  updatedAt: String(r["updated_at"] ?? ""),
@@ -1468,13 +1554,13 @@ function toSubscription(row) {
1468
1554
  // Attribution only: INVO never pays the recipient. Read the wire value, never assume.
1469
1555
  settledByInvo: share["settled_by_invo"] === true
1470
1556
  } : null,
1471
- paidThrough: nullableString(r["paid_through"]),
1557
+ paidThrough: nullableString2(r["paid_through"]),
1472
1558
  amountCoinsEstimate: r["amount_coins_estimate"] == null ? void 0 : String(r["amount_coins_estimate"]),
1473
1559
  // Present (possibly null) only on create/finalize bodies from 2026-09-23 on.
1474
- ..."trial_amount_coins_estimate" in r ? { trialAmountCoinsEstimate: nullableString(r["trial_amount_coins_estimate"]) } : {},
1560
+ ..."trial_amount_coins_estimate" in r ? { trialAmountCoinsEstimate: nullableString2(r["trial_amount_coins_estimate"]) } : {},
1475
1561
  // `include_player` puts these two ON the object (there is no separate block).
1476
- ..."player_email" in r ? { playerEmail: nullableString(r["player_email"]) } : {},
1477
- ..."player_name" in r ? { playerName: nullableString(r["player_name"]) } : {},
1562
+ ..."player_email" in r ? { playerEmail: nullableString2(r["player_email"]) } : {},
1563
+ ..."player_name" in r ? { playerName: nullableString2(r["player_name"]) } : {},
1478
1564
  raw: r
1479
1565
  };
1480
1566
  }
@@ -1482,14 +1568,14 @@ function toFirstCharge(row) {
1482
1568
  const r = row && typeof row === "object" ? row : {};
1483
1569
  return {
1484
1570
  status: String(r["status"] ?? "pending"),
1485
- amountUsd: nullableString(r["amount_usd"]),
1571
+ amountUsd: nullableString2(r["amount_usd"]),
1486
1572
  paidPeriodSeq: typeof r["paid_period_seq"] === "number" ? r["paid_period_seq"] : null,
1487
- paidThrough: nullableString(r["paid_through"]),
1488
- failureCode: nullableString(r["failure_code"]),
1489
- nextRetryAt: nullableString(r["next_retry_at"]),
1490
- confirmationUrl: nullableString(r["confirmation_url"]),
1491
- expiresAt: nullableString(r["expires_at"]),
1492
- message: nullableString(r["message"]),
1573
+ paidThrough: nullableString2(r["paid_through"]),
1574
+ failureCode: nullableString2(r["failure_code"]),
1575
+ nextRetryAt: nullableString2(r["next_retry_at"]),
1576
+ confirmationUrl: nullableString2(r["confirmation_url"]),
1577
+ expiresAt: nullableString2(r["expires_at"]),
1578
+ message: nullableString2(r["message"]),
1493
1579
  ...receiptFields(r),
1494
1580
  raw: r
1495
1581
  };
@@ -1511,10 +1597,10 @@ function toSandboxClockState(row) {
1511
1597
  return {
1512
1598
  status: String(r["status"] ?? ""),
1513
1599
  periodSeq: Number(r["period_seq"] ?? 0),
1514
- currentPeriodStart: nullableString(r["current_period_start"]),
1515
- currentPeriodEnd: nullableString(r["current_period_end"]),
1516
- nextChargeAt: nullableString(r["next_charge_at"]),
1517
- trialEnd: nullableString(r["trial_end"]),
1600
+ currentPeriodStart: nullableString2(r["current_period_start"]),
1601
+ currentPeriodEnd: nullableString2(r["current_period_end"]),
1602
+ nextChargeAt: nullableString2(r["next_charge_at"]),
1603
+ trialEnd: nullableString2(r["trial_end"]),
1518
1604
  cancelAtPeriodEnd: r["cancel_at_period_end"] === true,
1519
1605
  walletOnly: r["wallet_only"] === true,
1520
1606
  hasPaymentMethod: r["has_payment_method"] === true,
@@ -1817,14 +1903,14 @@ var SubscriptionsServer = class {
1817
1903
  alreadyCanceled: raw["already_canceled"] === true,
1818
1904
  finalStatus: typeof raw["final_status"] === "string" ? raw["final_status"] : void 0,
1819
1905
  cancelAtPeriodEnd: raw["cancel_at_period_end"] === true,
1820
- effectiveAt: nullableString(raw["effective_at"]),
1821
- currentPeriodEnd: nullableString(raw["current_period_end"]),
1822
- accessUntil: nullableString(raw["access_until"]),
1823
- paidThrough: nullableString(raw["paid_through"]),
1906
+ effectiveAt: nullableString2(raw["effective_at"]),
1907
+ currentPeriodEnd: nullableString2(raw["current_period_end"]),
1908
+ accessUntil: nullableString2(raw["access_until"]),
1909
+ paidThrough: nullableString2(raw["paid_through"]),
1824
1910
  terminatedImmediately: raw["terminated_immediately"] === true,
1825
1911
  downgradeReason: typeof raw["downgrade_reason"] === "string" ? raw["downgrade_reason"] : void 0,
1826
1912
  message: typeof raw["message"] === "string" ? raw["message"] : void 0,
1827
- steamAgreementStatus: "steam_agreement_status" in raw ? nullableString(raw["steam_agreement_status"]) : void 0,
1913
+ steamAgreementStatus: "steam_agreement_status" in raw ? nullableString2(raw["steam_agreement_status"]) : void 0,
1828
1914
  steamAgreementCanceled: typeof raw["steam_agreement_canceled"] === "boolean" ? raw["steam_agreement_canceled"] : void 0,
1829
1915
  subscription: raw["subscription"] ? toSubscription(raw["subscription"]) : null,
1830
1916
  raw
@@ -1855,12 +1941,12 @@ var SubscriptionsServer = class {
1855
1941
  status: String(raw["status"] ?? ""),
1856
1942
  oldAmountUsd: String(raw["old_amount_usd"] ?? ""),
1857
1943
  newAmountUsd: String(raw["new_amount_usd"] ?? amount),
1858
- pendingAmountUsd: nullableString(raw["pending_amount_usd"]),
1944
+ pendingAmountUsd: nullableString2(raw["pending_amount_usd"]),
1859
1945
  changeQueued: raw["change_queued"] === true,
1860
- appliesFrom: nullableString(raw["applies_from"]),
1946
+ appliesFrom: nullableString2(raw["applies_from"]),
1861
1947
  appliesFromPeriodSeq: Number(raw["applies_from_period_seq"] ?? 0),
1862
- paidThrough: nullableString(raw["paid_through"]),
1863
- currentPeriodEnd: nullableString(raw["current_period_end"]),
1948
+ paidThrough: nullableString2(raw["paid_through"]),
1949
+ currentPeriodEnd: nullableString2(raw["current_period_end"]),
1864
1950
  prorated: raw["prorated"] === true,
1865
1951
  subscription: raw["subscription"] ? toSubscription(raw["subscription"]) : null,
1866
1952
  raw
@@ -2046,7 +2132,7 @@ var SubscriptionsServer = class {
2046
2132
  orderId: String(raw["order_id"] ?? ""),
2047
2133
  steamOrderId: String(raw["steam_order_id"] ?? ""),
2048
2134
  steamTransid: String(raw["steam_transid"] ?? ""),
2049
- steamCheckoutUrl: nullableString(raw["steam_checkout_url"]),
2135
+ steamCheckoutUrl: nullableString2(raw["steam_checkout_url"]),
2050
2136
  amountUsd: String(raw["amount_usd"] ?? ""),
2051
2137
  amountCoins: String(raw["amount_coins"] ?? ""),
2052
2138
  steamChargeUsd: String(raw["steam_charge_usd"] ?? ""),
@@ -2084,7 +2170,7 @@ var SubscriptionsServer = class {
2084
2170
  return {
2085
2171
  ...toSubscriptionResult(raw),
2086
2172
  alreadyProcessed: raw["already_processed"] === true,
2087
- steamAgreementStatus: nullableString(raw["steam_agreement_status"]),
2173
+ steamAgreementStatus: nullableString2(raw["steam_agreement_status"]),
2088
2174
  sandboxAutoApproved: raw["sandbox_auto_approved"] === true
2089
2175
  };
2090
2176
  }
@@ -2873,6 +2959,10 @@ var InvoServer = class {
2873
2959
  * answer for all players. Without `steamid` the quote assumes no VAT — the
2874
2960
  * most any pack yields; the purchase itself always re-derives.
2875
2961
  *
2962
+ * Availability (3.36.0): `canSell` / `unavailableReason` for the title, and
2963
+ * per pack `available` / `unavailableReason`. Call this before showing the
2964
+ * store and hide packs with `available: false`; init still decides.
2965
+ *
2876
2966
  * Refusals: `err.isSteamRailNotEntitled` (403). A missing Steam
2877
2967
  * registration does NOT refuse here — packs deliberately answers with the
2878
2968
  * no-VAT catalogue and lets the PURCHASE be what refuses; the only 503 is
@@ -2891,10 +2981,15 @@ var InvoServer = class {
2891
2981
  packId: String(p["pack_id"] ?? ""),
2892
2982
  label: String(p["label"] ?? ""),
2893
2983
  priceUsd: String(p["price_usd"] ?? ""),
2894
- currencyAmount: String(p["currency_amount"] ?? "")
2984
+ currencyAmount: String(p["currency_amount"] ?? ""),
2985
+ // Availability (3.36.0) is additive: set only when the server sent it.
2986
+ ...typeof p["available"] === "boolean" ? { available: p["available"] } : {},
2987
+ ..."unavailable_reason" in p ? { unavailableReason: p["unavailable_reason"] ?? null } : {}
2895
2988
  })),
2896
2989
  country: raw["country"] ?? null,
2897
2990
  vatRatePct: String(raw["vat_rate_pct"] ?? "0"),
2991
+ ...typeof raw["can_sell"] === "boolean" ? { canSell: raw["can_sell"] } : {},
2992
+ ..."unavailable_reason" in raw ? { unavailableReason: raw["unavailable_reason"] ?? null } : {},
2898
2993
  raw
2899
2994
  };
2900
2995
  }
@@ -3008,6 +3103,81 @@ var InvoServer = class {
3008
3103
  raw
3009
3104
  };
3010
3105
  }
3106
+ /**
3107
+ * The App Store products registered for this game, and whether INVO will sell each one
3108
+ * right now. Call it with the game's iOS key **before every purchase** and offer only
3109
+ * products with `available: true`: Apple charges the player before INVO sees the
3110
+ * purchase, so this is the only point where INVO can say no. Ask StoreKit for exactly the
3111
+ * `productId`s listed.
3112
+ *
3113
+ * `unavailableReason` (per product, and for the whole game when `canSell` is `false`):
3114
+ * `APPLE_NOT_VERIFIED`, `PARTNER_BILLING_NOT_SET_UP`, `PARTNER_RAIL_SUSPENDED`,
3115
+ * `PARTNER_CREDIT_UNAVAILABLE`.
3116
+ *
3117
+ * Refusals: `err.isAppleNotConfigured` (409, no Apple configuration or turned off),
3118
+ * `err.isRailChannelMismatch` (409, the key is not an iOS key on the Apple rail).
3119
+ */
3120
+ async appleProducts(opts) {
3121
+ const raw = await this.http.get(
3122
+ "/api/currency-purchases/apple/products",
3123
+ this.auth,
3124
+ { signal: opts?.signal }
3125
+ );
3126
+ return toAppleProductsResult(raw);
3127
+ }
3128
+ /**
3129
+ * Verify a StoreKit 2 transaction and credit its coins, once. Call it from your game
3130
+ * SERVER, never the device, after StoreKit returns a verified transaction, with the
3131
+ * game's iOS key. Send `Transaction.jwsRepresentation` unchanged as `signedTransaction`.
3132
+ *
3133
+ * Then decide `Transaction.finish()` with {@link shouldFinishAppleTransaction}, passing
3134
+ * the result or the thrown error. It reads INVO's `finish` flag, which every answer carries
3135
+ * (`result.finish`, `err.finish`): `true` for `credited`, `already_credited` and the terminal
3136
+ * errors `isAppleTransactionRevoked`, `isAppleTransactionAlreadyUsed` and
3137
+ * `isAppleTransactionTooOld`. On anything else leave the transaction unfinished and
3138
+ * retry: StoreKit redelivers it, and a retry with the same signed transaction never credits
3139
+ * twice (a replay answers `already_credited`, with `balance` `null` unless you name the
3140
+ * same player). Safe to auto-retry for the same reason.
3141
+ *
3142
+ * Refusals: `isAppleSignatureInvalid`, `isAppleBundleMismatch`,
3143
+ * `isAppleEnvironmentNotAllowed`, `isAppleProductTypeUnsupported`, `isAppleProductUnknown`,
3144
+ * `isInvalidMetadata` / `isInvalidInput` (400); `isAppleReviewAccountRequired` (403);
3145
+ * `isAppleTransactionRevoked`, `isAppleTransactionAlreadyUsed`, `isAppleTransactionTooOld`,
3146
+ * `isAppleValueExceedsPrice`, `isAppleAccountTokenMismatch`, `isAppleNotConfigured`,
3147
+ * `isAppleNotVerified`, `isRailChannelMismatch` (409); `isAppleReviewPurchaseLimit` (429);
3148
+ * `isAppleCreditPending` (503, verified and held: retry; also while payments are paused);
3149
+ * and the usual game-key refusals, which carry no `finish` (treated as not finished).
3150
+ */
3151
+ async verifyApplePurchase(input, opts) {
3152
+ if (typeof input?.playerEmail !== "string" || !input.playerEmail.trim()) {
3153
+ throw invalidInput2("playerEmail", input?.playerEmail, "is required");
3154
+ }
3155
+ if (typeof input.signedTransaction !== "string" || !input.signedTransaction.trim()) {
3156
+ throw invalidInput2(
3157
+ "signedTransaction",
3158
+ typeof input.signedTransaction === "string" ? "(empty)" : input.signedTransaction,
3159
+ "is required: StoreKit's Transaction.jwsRepresentation"
3160
+ );
3161
+ }
3162
+ if (input.appAccountToken !== void 0 && (typeof input.appAccountToken !== "string" || !input.appAccountToken || input.appAccountToken.length > 64)) {
3163
+ throw invalidInput2("appAccountToken", input.appAccountToken, "must be the UUID string the game set");
3164
+ }
3165
+ const body = {
3166
+ player_email: input.playerEmail,
3167
+ signed_transaction: input.signedTransaction
3168
+ };
3169
+ if (input.appAccountToken !== void 0) body["app_account_token"] = input.appAccountToken;
3170
+ if (input.playerName) body["player_name"] = input.playerName;
3171
+ if (input.metadata) body["metadata"] = input.metadata;
3172
+ const raw = await this.http.post(
3173
+ "/api/currency-purchases/apple/verify-purchase",
3174
+ body,
3175
+ this.auth,
3176
+ { idempotent: true, signal: opts?.signal }
3177
+ // INVO credits each Apple transaction once
3178
+ );
3179
+ return toApplePurchaseResult(raw);
3180
+ }
3011
3181
  /**
3012
3182
  * Buy an in-game item by SPENDING the player's existing game currency (§4.8).
3013
3183
  * No real money, no payment rail, no passkey — it's a balance debit, authenticated
@@ -3933,6 +4103,6 @@ var InvoServer = class {
3933
4103
  }
3934
4104
  };
3935
4105
 
3936
- export { CardsServer, DEMO_KEY_PREFIX, EnvironmentUnknownError, InvoServer, KeyEnvironmentMismatchError, LIVE_KEY_PREFIX, PRODUCTION_BASE_URL, PayoutsServer, PlatformCommerceServer, SANDBOX_BASE_URL, SandboxServer, SandboxSubscriptionsServer, SubscriptionsServer, TEST_KEY_PREFIX, assertKeyMatchesBaseUrl, assertKeyMatchesEnvironment, baseUrlForKey, createWebhookHandler, environmentForBaseUrl, environmentFromKeyPrefix, isDemoKey, isRefundPendingApproval, resolveEnvironment, verifyInvoSignature, verifyWebhook, verifyWebhookAsync };
3937
- //# sourceMappingURL=chunk-MJXQ3Q7C.js.map
3938
- //# sourceMappingURL=chunk-MJXQ3Q7C.js.map
4106
+ export { APPLE_FINISH_ERROR_CODES, CardsServer, DEMO_KEY_PREFIX, EnvironmentUnknownError, InvoServer, KeyEnvironmentMismatchError, LIVE_KEY_PREFIX, PRODUCTION_BASE_URL, PayoutsServer, PlatformCommerceServer, SANDBOX_BASE_URL, SandboxServer, SandboxSubscriptionsServer, SubscriptionsServer, TEST_KEY_PREFIX, assertKeyMatchesBaseUrl, assertKeyMatchesEnvironment, baseUrlForKey, createWebhookHandler, environmentForBaseUrl, environmentFromKeyPrefix, isAppleCreditPending, isDemoKey, isRefundPendingApproval, resolveEnvironment, shouldFinishAppleTransaction, verifyInvoSignature, verifyWebhook, verifyWebhookAsync };
4107
+ //# sourceMappingURL=chunk-J4IQ3ANY.js.map
4108
+ //# sourceMappingURL=chunk-J4IQ3ANY.js.map
@@ -1,4 +1,4 @@
1
- import { InvoError, assertSecureBaseUrl, Http, toPurchaseStatusResult, toPhoneChangeApprovalsResult, phoneChangeSignalMessage, toApprovePhoneChangeResult, toDestinationsResult, toLoyaltyCardsResult, toLoyaltyVaultResult, toRedeemRewardResult, toRewardsPageLink, buildGameEventBody, toReportGameEventResult } from './chunk-3BR7URPM.js';
1
+ import { InvoError, assertSecureBaseUrl, Http, toPurchaseStatusResult, toPhoneChangeApprovalsResult, phoneChangeSignalMessage, toApprovePhoneChangeResult, toDestinationsResult, toLoyaltyCardsResult, toLoyaltyVaultResult, toRedeemRewardResult, toRewardsPageLink, buildGameEventBody, toReportGameEventResult } from './chunk-BGCSSWVL.js';
2
2
 
3
3
  // src/shared/webauthn.ts
4
4
  function malformedOptions(field) {
@@ -1586,5 +1586,5 @@ var InvoClient = class {
1586
1586
  };
1587
1587
 
1588
1588
  export { CheckoutClient, InvoClient, PlatformCommerceClient };
1589
- //# sourceMappingURL=chunk-PEYWNML4.js.map
1590
- //# sourceMappingURL=chunk-PEYWNML4.js.map
1589
+ //# sourceMappingURL=chunk-SCFK6IVH.js.map
1590
+ //# sourceMappingURL=chunk-SCFK6IVH.js.map