@invonetwork/web-sdk 3.34.1 → 3.35.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.
@@ -1,7 +1,93 @@
1
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';
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
  }
@@ -3008,6 +3094,81 @@ var InvoServer = class {
3008
3094
  raw
3009
3095
  };
3010
3096
  }
3097
+ /**
3098
+ * The App Store products registered for this game, and whether INVO will sell each one
3099
+ * right now. Call it with the game's iOS key **before every purchase** and offer only
3100
+ * products with `available: true`: Apple charges the player before INVO sees the
3101
+ * purchase, so this is the only point where INVO can say no. Ask StoreKit for exactly the
3102
+ * `productId`s listed.
3103
+ *
3104
+ * `unavailableReason` (per product, and for the whole game when `canSell` is `false`):
3105
+ * `APPLE_NOT_VERIFIED`, `PARTNER_BILLING_NOT_SET_UP`, `PARTNER_RAIL_SUSPENDED`,
3106
+ * `PARTNER_CREDIT_UNAVAILABLE`.
3107
+ *
3108
+ * Refusals: `err.isAppleNotConfigured` (409, no Apple configuration or turned off),
3109
+ * `err.isRailChannelMismatch` (409, the key is not an iOS key on the Apple rail).
3110
+ */
3111
+ async appleProducts(opts) {
3112
+ const raw = await this.http.get(
3113
+ "/api/currency-purchases/apple/products",
3114
+ this.auth,
3115
+ { signal: opts?.signal }
3116
+ );
3117
+ return toAppleProductsResult(raw);
3118
+ }
3119
+ /**
3120
+ * Verify a StoreKit 2 transaction and credit its coins, once. Call it from your game
3121
+ * SERVER, never the device, after StoreKit returns a verified transaction, with the
3122
+ * game's iOS key. Send `Transaction.jwsRepresentation` unchanged as `signedTransaction`.
3123
+ *
3124
+ * Then decide `Transaction.finish()` with {@link shouldFinishAppleTransaction}, passing
3125
+ * the result or the thrown error. It reads INVO's `finish` flag, which every answer carries
3126
+ * (`result.finish`, `err.finish`): `true` for `credited`, `already_credited` and the terminal
3127
+ * errors `isAppleTransactionRevoked`, `isAppleTransactionAlreadyUsed` and
3128
+ * `isAppleTransactionTooOld`. On anything else leave the transaction unfinished and
3129
+ * retry: StoreKit redelivers it, and a retry with the same signed transaction never credits
3130
+ * twice (a replay answers `already_credited`, with `balance` `null` unless you name the
3131
+ * same player). Safe to auto-retry for the same reason.
3132
+ *
3133
+ * Refusals: `isAppleSignatureInvalid`, `isAppleBundleMismatch`,
3134
+ * `isAppleEnvironmentNotAllowed`, `isAppleProductTypeUnsupported`, `isAppleProductUnknown`,
3135
+ * `isInvalidMetadata` / `isInvalidInput` (400); `isAppleReviewAccountRequired` (403);
3136
+ * `isAppleTransactionRevoked`, `isAppleTransactionAlreadyUsed`, `isAppleTransactionTooOld`,
3137
+ * `isAppleValueExceedsPrice`, `isAppleAccountTokenMismatch`, `isAppleNotConfigured`,
3138
+ * `isAppleNotVerified`, `isRailChannelMismatch` (409); `isAppleReviewPurchaseLimit` (429);
3139
+ * `isAppleCreditPending` (503, verified and held: retry; also while payments are paused);
3140
+ * and the usual game-key refusals, which carry no `finish` (treated as not finished).
3141
+ */
3142
+ async verifyApplePurchase(input, opts) {
3143
+ if (typeof input?.playerEmail !== "string" || !input.playerEmail.trim()) {
3144
+ throw invalidInput2("playerEmail", input?.playerEmail, "is required");
3145
+ }
3146
+ if (typeof input.signedTransaction !== "string" || !input.signedTransaction.trim()) {
3147
+ throw invalidInput2(
3148
+ "signedTransaction",
3149
+ typeof input.signedTransaction === "string" ? "(empty)" : input.signedTransaction,
3150
+ "is required: StoreKit's Transaction.jwsRepresentation"
3151
+ );
3152
+ }
3153
+ if (input.appAccountToken !== void 0 && (typeof input.appAccountToken !== "string" || !input.appAccountToken || input.appAccountToken.length > 64)) {
3154
+ throw invalidInput2("appAccountToken", input.appAccountToken, "must be the UUID string the game set");
3155
+ }
3156
+ const body = {
3157
+ player_email: input.playerEmail,
3158
+ signed_transaction: input.signedTransaction
3159
+ };
3160
+ if (input.appAccountToken !== void 0) body["app_account_token"] = input.appAccountToken;
3161
+ if (input.playerName) body["player_name"] = input.playerName;
3162
+ if (input.metadata) body["metadata"] = input.metadata;
3163
+ const raw = await this.http.post(
3164
+ "/api/currency-purchases/apple/verify-purchase",
3165
+ body,
3166
+ this.auth,
3167
+ { idempotent: true, signal: opts?.signal }
3168
+ // INVO credits each Apple transaction once
3169
+ );
3170
+ return toApplePurchaseResult(raw);
3171
+ }
3011
3172
  /**
3012
3173
  * Buy an in-game item by SPENDING the player's existing game currency (§4.8).
3013
3174
  * No real money, no payment rail, no passkey — it's a balance debit, authenticated
@@ -3933,6 +4094,6 @@ var InvoServer = class {
3933
4094
  }
3934
4095
  };
3935
4096
 
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
4097
+ 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 };
4098
+ //# sourceMappingURL=chunk-XN6MCLQV.js.map
4099
+ //# sourceMappingURL=chunk-XN6MCLQV.js.map