@invonetwork/web-sdk 3.24.1 → 3.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -3,7 +3,178 @@ export { InvoError } from './chunk-7BYAUHTA.js';
3
3
  import { createHmac, timingSafeEqual } from 'crypto';
4
4
 
5
5
  // src/version.ts
6
- var SDK_VERSION = "3.24.1";
6
+ var SDK_VERSION = "3.25.0";
7
+
8
+ // src/payouts.ts
9
+ var AMOUNT = /^\d+(\.\d{1,2})?$/;
10
+ function invalidInput(label, value, why) {
11
+ return new InvoError({
12
+ message: `${label} ${why} (got ${JSON.stringify(value)}).`,
13
+ code: "INVALID_INPUT",
14
+ status: 0
15
+ });
16
+ }
17
+ function requireText(label, value) {
18
+ if (typeof value !== "string" || !value.trim()) throw invalidInput(label, value, "is required");
19
+ return value.trim();
20
+ }
21
+ function amountString(value) {
22
+ const s = typeof value === "number" ? Number.isFinite(value) ? String(value) : "" : String(value ?? "").trim();
23
+ if (!AMOUNT.test(s) || Number(s) <= 0) {
24
+ throw invalidInput("amountUsd", value, "must be a positive amount with at most two decimal places");
25
+ }
26
+ return s;
27
+ }
28
+ function query(params) {
29
+ const parts = [];
30
+ for (const [k, v] of Object.entries(params)) {
31
+ if (v === void 0 || v === "") continue;
32
+ parts.push(`${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`);
33
+ }
34
+ return parts.length ? `?${parts.join("&")}` : "";
35
+ }
36
+ function payeePath(payeeId) {
37
+ return `/api/partner-payees/${encodeURIComponent(requireText("payeeId", payeeId))}`;
38
+ }
39
+ function payoutId(id) {
40
+ if (!Number.isInteger(id) || id <= 0) throw invalidInput("payoutId", id, "must be a positive integer");
41
+ return id;
42
+ }
43
+ var PayoutsServer = class {
44
+ constructor(http, auth) {
45
+ this.http = http;
46
+ this.auth = auth;
47
+ }
48
+ /**
49
+ * Register a creator (`POST /api/partner-payees`). INVO emails the creator a link to INVO's
50
+ * own page to give INVO their identity, tax and bank details. `invite.sent` is `false` when
51
+ * INVO did not email the link (`invite.error_code` says why); the creator is registered
52
+ * either way. Refusals: `409 PARTNER_REFERENCE_CONFLICT`, `400 INVALID_INPUT`,
53
+ * `400 COUNTRY_NOT_SUPPORTED`.
54
+ */
55
+ async registerPayee(input, opts) {
56
+ if (input.payeeType !== "individual" && input.payeeType !== "business") {
57
+ throw invalidInput("payeeType", input.payeeType, 'must be "individual" or "business"');
58
+ }
59
+ const raw = await this.http.post(
60
+ "/api/partner-payees",
61
+ {
62
+ partner_reference: requireText("partnerReference", input.partnerReference),
63
+ legal_name: requireText("legalName", input.legalName),
64
+ email: requireText("email", input.email),
65
+ country: requireText("country", input.country),
66
+ payee_type: input.payeeType
67
+ },
68
+ this.auth,
69
+ { idempotent: true, signal: opts?.signal }
70
+ );
71
+ return {
72
+ payee: raw["payee"],
73
+ invite: raw["invite"],
74
+ duplicate: raw["duplicate"] === true,
75
+ raw
76
+ };
77
+ }
78
+ /** This game's creators, newest first (`GET /api/partner-payees`). */
79
+ async listPayees(q = {}, opts) {
80
+ const raw = await this.http.get(
81
+ `/api/partner-payees${query({ limit: q.limit, offset: q.offset, status: q.status })}`,
82
+ this.auth,
83
+ { signal: opts?.signal }
84
+ );
85
+ return {
86
+ total: Number(raw["total"] ?? 0),
87
+ limit: Number(raw["limit"] ?? 0),
88
+ offset: Number(raw["offset"] ?? 0),
89
+ items: raw["items"] ?? [],
90
+ raw
91
+ };
92
+ }
93
+ /** One creator (`GET /api/partner-payees/{payeeId}`); `404 NOT_FOUND` if not this game's. */
94
+ async getPayee(payeeId, opts) {
95
+ const raw = await this.http.get(payeePath(payeeId), this.auth, {
96
+ signal: opts?.signal
97
+ });
98
+ return raw["payee"];
99
+ }
100
+ /**
101
+ * Email the creator a new link (`POST /api/partner-payees/{payeeId}/resend-invite`); the old
102
+ * link stops working. Allowed while the creator is `invited`, `rejected` or `expired`
103
+ * (`409 INVITE_NOT_NEEDED` otherwise). Never auto-retried.
104
+ */
105
+ async resendPayeeInvite(payeeId, opts) {
106
+ const raw = await this.http.post(
107
+ `${payeePath(payeeId)}/resend-invite`,
108
+ void 0,
109
+ this.auth,
110
+ { signal: opts?.signal }
111
+ );
112
+ return raw["invite"];
113
+ }
114
+ /**
115
+ * Ask INVO to pay out (`POST /api/partner-payouts/request`). With `payeeId`, INVO pays that
116
+ * verified creator's bank account; otherwise your own verified bank account. The money comes
117
+ * from the earnings INVO owes your game, and the payout fee is taken from the payout.
118
+ * Creator refusals: `404 PAYEE_NOT_FOUND`, `409 PAYEE_NOT_VERIFIED`,
119
+ * `409 PAYEE_VERIFICATION_EXPIRED`, `409 PAYEE_BANK_NOT_VERIFIED`, `409 PAYEE_NOT_PAYABLE`.
120
+ * Retried safely only when `clientRequestId` is set.
121
+ */
122
+ async requestPayout(input, opts) {
123
+ if (input.payeeId !== void 0 && input.bankAccountId !== void 0) {
124
+ throw invalidInput("bankAccountId", input.bankAccountId, "must not be sent with payeeId");
125
+ }
126
+ const body = {
127
+ amount_usd: amountString(input.amountUsd),
128
+ contact_email: requireText("contactEmail", input.contactEmail)
129
+ };
130
+ if (input.payeeId !== void 0) body["payee_id"] = requireText("payeeId", input.payeeId);
131
+ if (input.bankAccountId !== void 0) body["bank_account_id"] = input.bankAccountId;
132
+ if (input.clientRequestId !== void 0) body["client_request_id"] = requireText("clientRequestId", input.clientRequestId);
133
+ if (input.partnerNote !== void 0) body["partner_note"] = input.partnerNote;
134
+ if (input.additionalEmails !== void 0) body["additional_emails"] = input.additionalEmails;
135
+ const raw = await this.http.post("/api/partner-payouts/request", body, this.auth, {
136
+ idempotent: input.clientRequestId !== void 0,
137
+ signal: opts?.signal
138
+ });
139
+ return {
140
+ payout: raw["payout_request"],
141
+ duplicate: raw["duplicate"] === true,
142
+ raw
143
+ };
144
+ }
145
+ /** One payout (`GET /api/partner-payouts/{payoutId}`). */
146
+ async getPayout(payoutIdValue, opts) {
147
+ const raw = await this.http.get(
148
+ `/api/partner-payouts/${payoutId(payoutIdValue)}`,
149
+ this.auth,
150
+ { signal: opts?.signal }
151
+ );
152
+ return raw["payout_request"];
153
+ }
154
+ /** Your payouts (`GET /api/partner-payouts`), optionally one creator's (`payeeId`). */
155
+ async listPayouts(q = {}, opts) {
156
+ const raw = await this.http.get(
157
+ `/api/partner-payouts${query({ limit: q.limit, offset: q.offset, status: q.status, payee_id: q.payeeId })}`,
158
+ this.auth,
159
+ { signal: opts?.signal }
160
+ );
161
+ return { total: Number(raw["total"] ?? 0), items: raw["items"] ?? [], raw };
162
+ }
163
+ /**
164
+ * Cancel a creator payout that is still `requested`
165
+ * (`POST /api/partner-payouts/{payoutId}/cancel`). Anything past `requested` is
166
+ * `409 PAYOUT_NOT_CANCELLABLE`.
167
+ */
168
+ async cancelPayout(payoutIdValue, opts) {
169
+ const raw = await this.http.post(
170
+ `/api/partner-payouts/${payoutId(payoutIdValue)}/cancel`,
171
+ void 0,
172
+ this.auth,
173
+ { signal: opts?.signal }
174
+ );
175
+ return raw["payout_request"] ?? raw["payout"];
176
+ }
177
+ };
7
178
 
8
179
  // src/shared/types.ts
9
180
  function isRefundPendingApproval(r) {
@@ -271,7 +442,7 @@ function pricingFields(raw, fallback = {}) {
271
442
  if (warning !== void 0) out.minPurchaseWarning = warning;
272
443
  return out;
273
444
  }
274
- function invalidInput(label, value, why) {
445
+ function invalidInput2(label, value, why) {
275
446
  return new InvoError({
276
447
  message: `${label} ${why} (got ${JSON.stringify(value)}).`,
277
448
  code: "INVALID_INPUT",
@@ -283,17 +454,17 @@ function parseMoney(value, max, label) {
283
454
  let n;
284
455
  if (typeof value === "number") {
285
456
  if (!Number.isFinite(value) || !PLAIN_DECIMAL.test(String(value))) {
286
- throw invalidInput(label, value, "must be a positive decimal with at most 2 places");
457
+ throw invalidInput2(label, value, "must be a positive decimal with at most 2 places");
287
458
  }
288
459
  n = value;
289
460
  } else {
290
461
  if (!PLAIN_DECIMAL.test(value)) {
291
- throw invalidInput(label, value, "must be a plain decimal value with at most 2 places");
462
+ throw invalidInput2(label, value, "must be a plain decimal value with at most 2 places");
292
463
  }
293
464
  n = Number(value);
294
465
  }
295
466
  if (!Number.isFinite(n) || n <= 0 || n > max) {
296
- throw invalidInput(label, value, `must be > 0 and <= ${max}`);
467
+ throw invalidInput2(label, value, `must be > 0 and <= ${max}`);
297
468
  }
298
469
  return n;
299
470
  }
@@ -303,7 +474,7 @@ function assertUsdAmount(usdAmount) {
303
474
  var E164 = /^\+[1-9]\d{1,14}$/;
304
475
  function assertE164(value, label) {
305
476
  if (typeof value !== "string" || !E164.test(value)) {
306
- throw invalidInput(label, value, 'must be an E.164 phone number, e.g. "+15555550100"');
477
+ throw invalidInput2(label, value, 'must be an E.164 phone number, e.g. "+15555550100"');
307
478
  }
308
479
  }
309
480
  function sessionTokenFromCreateCheckout(raw, checkoutUrl) {
@@ -392,13 +563,13 @@ function toTransactionStatus(raw) {
392
563
  function assertPageLimit(limit) {
393
564
  if (limit === void 0) return;
394
565
  if (typeof limit !== "number" || !Number.isInteger(limit) || limit < 1) {
395
- throw invalidInput("limit", limit, "must be a positive integer (INVO caps it at 100)");
566
+ throw invalidInput2("limit", limit, "must be a positive integer (INVO caps it at 100)");
396
567
  }
397
568
  }
398
569
  function assertCursor(cursor) {
399
570
  if (cursor === void 0) return;
400
571
  if (typeof cursor !== "string" || !cursor.trim()) {
401
- throw invalidInput("cursor", cursor, "must be the previous page's nextCursor");
572
+ throw invalidInput2("cursor", cursor, "must be the previous page's nextCursor");
402
573
  }
403
574
  }
404
575
  function strOrNull(v) {
@@ -535,12 +706,12 @@ function isPastThisStep(flow, currentStatus) {
535
706
  }
536
707
  function assertPlayerToken(playerToken) {
537
708
  if (typeof playerToken !== "string" || !playerToken.trim()) {
538
- throw invalidInput("playerToken", playerToken, "is required (the player's session token, not the game secret)");
709
+ throw invalidInput2("playerToken", playerToken, "is required (the player's session token, not the game secret)");
539
710
  }
540
711
  }
541
712
  function assertDeviceApprovalFlow(flow) {
542
713
  if (typeof flow !== "string" || !DEVICE_APPROVAL_FLOWS.has(flow)) {
543
- throw invalidInput("flow", flow, 'must be "transfer" | "send" | "send_receipt" | "transfer_receipt"');
714
+ throw invalidInput2("flow", flow, 'must be "transfer" | "send" | "send_receipt" | "transfer_receipt"');
544
715
  }
545
716
  }
546
717
  function toDeviceApprovalGrant(raw) {
@@ -680,20 +851,20 @@ var PlatformCommerceServer = class {
680
851
  ["itemName", input.itemName]
681
852
  ];
682
853
  for (const [k, v] of required) {
683
- if (typeof v !== "string" || !v.trim()) throw invalidInput(k, v, "is required");
854
+ if (typeof v !== "string" || !v.trim()) throw invalidInput2(k, v, "is required");
684
855
  }
685
856
  if (!FUNDING_SOURCES.has(input.fundingSource)) {
686
- throw invalidInput("fundingSource", input.fundingSource, 'must be "balance" or "card"');
857
+ throw invalidInput2("fundingSource", input.fundingSource, 'must be "balance" or "card"');
687
858
  }
688
859
  if (!Number.isInteger(input.itemQuantity) || input.itemQuantity < 1 || input.itemQuantity > 1e3) {
689
- throw invalidInput("itemQuantity", input.itemQuantity, "must be an integer 1..1000");
860
+ throw invalidInput2("itemQuantity", input.itemQuantity, "must be an integer 1..1000");
690
861
  }
691
862
  const unit = parseMoney(input.unitPrice, MAX_ITEM_PRICE, "unitPrice");
692
863
  const total = parseMoney(input.totalPrice, MAX_ITEM_PRICE, "totalPrice");
693
864
  const expectedCents = Math.round(unit * input.itemQuantity * 100);
694
865
  const totalCents = Math.round(total * 100);
695
866
  if (Math.abs(totalCents - expectedCents) > 1) {
696
- throw invalidInput(
867
+ throw invalidInput2(
697
868
  "totalPrice",
698
869
  input.totalPrice,
699
870
  `must equal unitPrice \xD7 itemQuantity (\xB10.01): ${unit} \xD7 ${input.itemQuantity}`
@@ -764,7 +935,7 @@ var PlatformCommerceServer = class {
764
935
  * `pending_payment` (card awaiting confirmation), or `refunded`. */
765
936
  async getStatus(orderId, opts) {
766
937
  if (orderId == null || String(orderId).trim() === "") {
767
- throw invalidInput("orderId", orderId, "is required");
938
+ throw invalidInput2("orderId", orderId, "is required");
768
939
  }
769
940
  const raw = await this.http.get(
770
941
  `/api/platform-commerce/purchase-status/${encodeURIComponent(String(orderId))}`,
@@ -787,16 +958,16 @@ var PlatformCommerceServer = class {
787
958
  * tenant (`err.isNotPlatformTenant`), `429` (back off; `err.retryAfter`). A GET, so
788
959
  * transient failures are retried automatically.
789
960
  */
790
- async getPurchaseHistory(query, opts) {
791
- if (typeof query?.playerEmail !== "string" || !query.playerEmail.trim()) {
792
- throw invalidInput("playerEmail", query?.playerEmail, "is required");
961
+ async getPurchaseHistory(query2, opts) {
962
+ if (typeof query2?.playerEmail !== "string" || !query2.playerEmail.trim()) {
963
+ throw invalidInput2("playerEmail", query2?.playerEmail, "is required");
793
964
  }
794
- assertPageLimit(query.limit);
795
- assertCursor(query.cursor);
965
+ assertPageLimit(query2.limit);
966
+ assertCursor(query2.cursor);
796
967
  const q = new URLSearchParams();
797
- q.set("player_email", query.playerEmail.trim());
798
- if (query.limit !== void 0) q.set("limit", String(query.limit));
799
- if (query.cursor !== void 0) q.set("cursor", query.cursor);
968
+ q.set("player_email", query2.playerEmail.trim());
969
+ if (query2.limit !== void 0) q.set("limit", String(query2.limit));
970
+ if (query2.cursor !== void 0) q.set("cursor", query2.cursor);
800
971
  const raw = await this.http.get(
801
972
  `/api/platform-commerce/purchase-history?${q.toString()}`,
802
973
  this.auth,
@@ -805,7 +976,7 @@ var PlatformCommerceServer = class {
805
976
  const purchases = Array.isArray(raw["purchases"]) ? raw["purchases"].map((r) => toPlatformOrderStatus(r)) : [];
806
977
  const nextCursor = nextCursorOf(raw);
807
978
  return {
808
- playerEmail: String(raw["player_email"] ?? query.playerEmail.trim()),
979
+ playerEmail: String(raw["player_email"] ?? query2.playerEmail.trim()),
809
980
  gameId: String(raw["game_id"] ?? ""),
810
981
  purchases,
811
982
  limit: typeof raw["limit"] === "number" ? raw["limit"] : purchases.length,
@@ -822,12 +993,12 @@ var PlatformCommerceServer = class {
822
993
  * for await (const order of invo.platformCommerce.iteratePurchaseHistory({ playerEmail })) { … }
823
994
  * ```
824
995
  */
825
- async *iteratePurchaseHistory(query, opts) {
996
+ async *iteratePurchaseHistory(query2, opts) {
826
997
  let cursor;
827
998
  const seen = /* @__PURE__ */ new Set();
828
999
  for (; ; ) {
829
1000
  const page = await this.getPurchaseHistory(
830
- { playerEmail: query.playerEmail, limit: query.pageSize, cursor },
1001
+ { playerEmail: query2.playerEmail, limit: query2.pageSize, cursor },
831
1002
  opts
832
1003
  );
833
1004
  for (const row of page.purchases) yield row;
@@ -904,13 +1075,13 @@ var SANDBOX_FAILURE_OUTCOMES = /* @__PURE__ */ new Set([
904
1075
  "error"
905
1076
  ]);
906
1077
  function assertClientRequestId(value, label) {
907
- if (typeof value !== "string" || !value.trim()) throw invalidInput(label, value, "is required");
908
- if (value.length > 255) throw invalidInput(label, value, "must be at most 255 characters");
909
- if (/^sub_/i.test(value)) throw invalidInput(label, value, 'must not begin with "sub_" (reserved)');
1078
+ if (typeof value !== "string" || !value.trim()) throw invalidInput2(label, value, "is required");
1079
+ if (value.length > 255) throw invalidInput2(label, value, "must be at most 255 characters");
1080
+ if (/^sub_/i.test(value)) throw invalidInput2(label, value, 'must not begin with "sub_" (reserved)');
910
1081
  }
911
1082
  function assertSubscriptionId(value) {
912
1083
  if (typeof value !== "string" || !value.trim()) {
913
- throw invalidInput("subscriptionId", value, "is required");
1084
+ throw invalidInput2("subscriptionId", value, "is required");
914
1085
  }
915
1086
  }
916
1087
  function subscriptionMoney(value, label) {
@@ -1162,10 +1333,10 @@ function subscriptionBaseBody(input) {
1162
1333
  ["playerName", input.playerName],
1163
1334
  ["itemId", input.itemId]
1164
1335
  ]) {
1165
- if (typeof v !== "string" || !v.trim()) throw invalidInput(k, v, "is required");
1336
+ if (typeof v !== "string" || !v.trim()) throw invalidInput2(k, v, "is required");
1166
1337
  }
1167
1338
  if (input.interval !== void 0 && !SUBSCRIPTION_INTERVALS.has(input.interval)) {
1168
- throw invalidInput("interval", input.interval, 'must be "month" or "year"');
1339
+ throw invalidInput2("interval", input.interval, 'must be "month" or "year"');
1169
1340
  }
1170
1341
  if (input.playerPhone !== void 0) assertE164(input.playerPhone, "playerPhone");
1171
1342
  const body = {
@@ -1198,7 +1369,7 @@ function subscriptionBaseBody(input) {
1198
1369
  const hasEmail = typeof s.recipientPlayerEmail === "string" && s.recipientPlayerEmail.trim() !== "";
1199
1370
  const hasId = s.recipientPlayerId != null;
1200
1371
  if (hasEmail === hasId) {
1201
- throw invalidInput(
1372
+ throw invalidInput2(
1202
1373
  "revenueShare",
1203
1374
  s,
1204
1375
  "requires EXACTLY ONE of recipientPlayerEmail or recipientPlayerId"
@@ -1256,19 +1427,19 @@ var SubscriptionsServer = class {
1256
1427
  const body = subscriptionBaseBody(input);
1257
1428
  if (input.intervalCount !== void 0) {
1258
1429
  if (!Number.isInteger(input.intervalCount) || input.intervalCount < 1 || input.intervalCount > 36) {
1259
- throw invalidInput("intervalCount", input.intervalCount, "must be an integer 1..36");
1430
+ throw invalidInput2("intervalCount", input.intervalCount, "must be an integer 1..36");
1260
1431
  }
1261
1432
  body["interval_count"] = input.intervalCount;
1262
1433
  }
1263
1434
  if (input.trialDays !== void 0) {
1264
1435
  if (!Number.isInteger(input.trialDays) || input.trialDays < 1 || input.trialDays > 365) {
1265
- throw invalidInput("trialDays", input.trialDays, "must be an integer 1..365");
1436
+ throw invalidInput2("trialDays", input.trialDays, "must be an integer 1..365");
1266
1437
  }
1267
1438
  body["trial_days"] = input.trialDays;
1268
1439
  }
1269
1440
  if (input.trialEnd !== void 0) {
1270
1441
  if (typeof input.trialEnd !== "string" || Number.isNaN(Date.parse(input.trialEnd))) {
1271
- throw invalidInput("trialEnd", input.trialEnd, "must be an ISO 8601 timestamp");
1442
+ throw invalidInput2("trialEnd", input.trialEnd, "must be an ISO 8601 timestamp");
1272
1443
  }
1273
1444
  body["trial_end"] = input.trialEnd;
1274
1445
  }
@@ -1291,16 +1462,16 @@ var SubscriptionsServer = class {
1291
1462
  }
1292
1463
  if (input.walletOnly !== void 0) {
1293
1464
  if (typeof input.walletOnly !== "boolean") {
1294
- throw invalidInput("walletOnly", input.walletOnly, "must be a boolean");
1465
+ throw invalidInput2("walletOnly", input.walletOnly, "must be a boolean");
1295
1466
  }
1296
1467
  body["wallet_only"] = input.walletOnly;
1297
1468
  }
1298
1469
  if (input.playerCardId !== void 0) {
1299
1470
  if (!Number.isInteger(input.playerCardId) || input.playerCardId < 1) {
1300
- throw invalidInput("playerCardId", input.playerCardId, "must be a positive integer card id (from cards.list)");
1471
+ throw invalidInput2("playerCardId", input.playerCardId, "must be a positive integer card id (from cards.list)");
1301
1472
  }
1302
1473
  if (input.walletOnly === true) {
1303
- throw invalidInput("playerCardId", input.playerCardId, "cannot be combined with walletOnly: true");
1474
+ throw invalidInput2("playerCardId", input.playerCardId, "cannot be combined with walletOnly: true");
1304
1475
  }
1305
1476
  body["player_card_id"] = input.playerCardId;
1306
1477
  }
@@ -1336,7 +1507,7 @@ var SubscriptionsServer = class {
1336
1507
  */
1337
1508
  async listForPlayer(playerEmail, options, opts) {
1338
1509
  if (typeof playerEmail !== "string" || !playerEmail.trim()) {
1339
- throw invalidInput("playerEmail", playerEmail, "is required");
1510
+ throw invalidInput2("playerEmail", playerEmail, "is required");
1340
1511
  }
1341
1512
  const q = new URLSearchParams();
1342
1513
  q.set("player_email", playerEmail);
@@ -1347,13 +1518,13 @@ var SubscriptionsServer = class {
1347
1518
  if (options?.includePlayer) q.set("include_player", "true");
1348
1519
  if (options?.limit != null) {
1349
1520
  if (!Number.isInteger(options.limit) || options.limit < 1 || options.limit > 100) {
1350
- throw invalidInput("limit", options.limit, "must be an integer 1..100");
1521
+ throw invalidInput2("limit", options.limit, "must be an integer 1..100");
1351
1522
  }
1352
1523
  q.set("limit", String(options.limit));
1353
1524
  }
1354
1525
  if (options?.offset != null) {
1355
1526
  if (!Number.isInteger(options.offset) || options.offset < 0 || options.offset > 1e5) {
1356
- throw invalidInput("offset", options.offset, "must be an integer 0..100000");
1527
+ throw invalidInput2("offset", options.offset, "must be an integer 0..100000");
1357
1528
  }
1358
1529
  q.set("offset", String(options.offset));
1359
1530
  }
@@ -1393,13 +1564,13 @@ var SubscriptionsServer = class {
1393
1564
  const body = {};
1394
1565
  if (options?.atPeriodEnd !== void 0) {
1395
1566
  if (typeof options.atPeriodEnd !== "boolean") {
1396
- throw invalidInput("atPeriodEnd", options.atPeriodEnd, "must be a boolean");
1567
+ throw invalidInput2("atPeriodEnd", options.atPeriodEnd, "must be a boolean");
1397
1568
  }
1398
1569
  body["at_period_end"] = options.atPeriodEnd;
1399
1570
  }
1400
1571
  if (options?.reason !== void 0) {
1401
1572
  if (typeof options.reason !== "string" || options.reason.length > 500) {
1402
- throw invalidInput("reason", options.reason, "must be a string of at most 500 characters");
1573
+ throw invalidInput2("reason", options.reason, "must be a string of at most 500 characters");
1403
1574
  }
1404
1575
  body["reason"] = options.reason;
1405
1576
  }
@@ -1478,14 +1649,14 @@ var SubscriptionsServer = class {
1478
1649
  const body = {};
1479
1650
  if ("playerCardId" in input && input.playerCardId !== void 0) {
1480
1651
  if (!Number.isInteger(input.playerCardId) || input.playerCardId < 1) {
1481
- throw invalidInput("playerCardId", input.playerCardId, "must be a positive integer card id (from cards.list)");
1652
+ throw invalidInput2("playerCardId", input.playerCardId, "must be a positive integer card id (from cards.list)");
1482
1653
  }
1483
1654
  body["player_card_id"] = input.playerCardId;
1484
1655
  if (input.walletOnly !== void 0) body["wallet_only"] = input.walletOnly;
1485
1656
  } else if (input.walletOnly === true) {
1486
1657
  body["wallet_only"] = true;
1487
1658
  } else {
1488
- throw invalidInput("input", input, "requires { playerCardId } or { walletOnly: true }");
1659
+ throw invalidInput2("input", input, "requires { playerCardId } or { walletOnly: true }");
1489
1660
  }
1490
1661
  const raw = await this.http.post(
1491
1662
  `/api/subscriptions/${encodeURIComponent(subscriptionId)}/payment-method`,
@@ -1546,14 +1717,14 @@ var SubscriptionsServer = class {
1546
1717
  const body = { client_request_id: input.clientRequestId };
1547
1718
  if (input.periodSeq !== void 0) {
1548
1719
  if (!Number.isInteger(input.periodSeq) || input.periodSeq < 1) {
1549
- throw invalidInput("periodSeq", input.periodSeq, "must be an integer >= 1");
1720
+ throw invalidInput2("periodSeq", input.periodSeq, "must be an integer >= 1");
1550
1721
  }
1551
1722
  body["period_seq"] = input.periodSeq;
1552
1723
  }
1553
1724
  if (input.amountUsd !== void 0) body["amount_usd"] = subscriptionMoney(input.amountUsd, "amountUsd");
1554
1725
  if (input.reason !== void 0) {
1555
1726
  if (typeof input.reason !== "string" || input.reason.length > 500) {
1556
- throw invalidInput("reason", input.reason, "must be a string of at most 500 characters");
1727
+ throw invalidInput2("reason", input.reason, "must be a string of at most 500 characters");
1557
1728
  }
1558
1729
  body["reason"] = input.reason;
1559
1730
  }
@@ -1595,10 +1766,10 @@ var SubscriptionsServer = class {
1595
1766
  async steamInit(input, opts) {
1596
1767
  const body = subscriptionBaseBody(input);
1597
1768
  if (!/^[0-9]+$/.test(String(input.steamId ?? ""))) {
1598
- throw invalidInput("steamId", input.steamId, "must be the member's numeric 64-bit Steam id");
1769
+ throw invalidInput2("steamId", input.steamId, "must be the member's numeric 64-bit Steam id");
1599
1770
  }
1600
1771
  if (input.userSession !== void 0 && input.userSession !== "client" && input.userSession !== "web") {
1601
- throw invalidInput("userSession", input.userSession, 'must be "client" or "web"');
1772
+ throw invalidInput2("userSession", input.userSession, 'must be "client" or "web"');
1602
1773
  }
1603
1774
  if (input.userSession === "web" && !input.playerIp) {
1604
1775
  throw new InvoError({
@@ -1608,7 +1779,7 @@ var SubscriptionsServer = class {
1608
1779
  });
1609
1780
  }
1610
1781
  if (input.intervalCount !== void 0 && input.intervalCount !== 1) {
1611
- throw invalidInput("intervalCount", input.intervalCount, "must be 1 on the Steam rail (monthly and yearly only)");
1782
+ throw invalidInput2("intervalCount", input.intervalCount, "must be 1 on the Steam rail (monthly and yearly only)");
1612
1783
  }
1613
1784
  const forbidden = input;
1614
1785
  if (forbidden["trialAmountUsd"] !== void 0) {
@@ -1620,7 +1791,7 @@ var SubscriptionsServer = class {
1620
1791
  }
1621
1792
  for (const k of ["trialDays", "trialEnd", "walletOnly", "playerCardId"]) {
1622
1793
  if (forbidden[k] !== void 0) {
1623
- throw invalidInput(k, forbidden[k], "is not available on the Steam rail");
1794
+ throw invalidInput2(k, forbidden[k], "is not available on the Steam rail");
1624
1795
  }
1625
1796
  }
1626
1797
  body["steamid"] = String(input.steamId);
@@ -1733,24 +1904,24 @@ var CardsServer = class {
1733
1904
  */
1734
1905
  async createSetupSession(input, opts) {
1735
1906
  if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
1736
- throw invalidInput("playerEmail", input.playerEmail, "is required");
1907
+ throw invalidInput2("playerEmail", input.playerEmail, "is required");
1737
1908
  }
1738
1909
  for (const [label, value] of [
1739
1910
  ["successUrl", input.successUrl],
1740
1911
  ["cancelUrl", input.cancelUrl]
1741
1912
  ]) {
1742
1913
  if (value === void 0) continue;
1743
- if (typeof value !== "string" || !value.trim()) throw invalidInput(label, value, "must be a non-empty URL");
1744
- if (SCRIPT_SCHEME.test(value)) throw invalidInput(label, value, "must not use a script scheme");
1914
+ if (typeof value !== "string" || !value.trim()) throw invalidInput2(label, value, "must be a non-empty URL");
1915
+ if (SCRIPT_SCHEME.test(value)) throw invalidInput2(label, value, "must not use a script scheme");
1745
1916
  }
1746
1917
  if (input.metadata !== void 0 && (input.metadata === null || typeof input.metadata !== "object" || Array.isArray(input.metadata))) {
1747
- throw invalidInput("metadata", input.metadata, "must be a plain object");
1918
+ throw invalidInput2("metadata", input.metadata, "must be a plain object");
1748
1919
  }
1749
1920
  if (input.playerName !== void 0) {
1750
1921
  if (typeof input.playerName !== "string" || !input.playerName.trim()) {
1751
- throw invalidInput("playerName", input.playerName, "must be a non-empty string");
1922
+ throw invalidInput2("playerName", input.playerName, "must be a non-empty string");
1752
1923
  }
1753
- if (input.playerName.trim().length > 255) throw invalidInput("playerName", input.playerName, "must be at most 255 characters");
1924
+ if (input.playerName.trim().length > 255) throw invalidInput2("playerName", input.playerName, "must be at most 255 characters");
1754
1925
  }
1755
1926
  if (input.playerPhone !== void 0) assertE164(input.playerPhone, "playerPhone");
1756
1927
  const body = { player_email: input.playerEmail };
@@ -1795,10 +1966,10 @@ var CardsServer = class {
1795
1966
  */
1796
1967
  async beginSetup(input, opts) {
1797
1968
  if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
1798
- throw invalidInput("playerEmail", input.playerEmail, "is required");
1969
+ throw invalidInput2("playerEmail", input.playerEmail, "is required");
1799
1970
  }
1800
1971
  if (typeof input.setupReference !== "string" || !/^[A-Za-z0-9._:-]{1,200}$/.test(input.setupReference)) {
1801
- throw invalidInput("setupReference", input.setupReference, "must be 1-200 characters of A-Z a-z 0-9 . _ : -");
1972
+ throw invalidInput2("setupReference", input.setupReference, "must be 1-200 characters of A-Z a-z 0-9 . _ : -");
1802
1973
  }
1803
1974
  const body = {
1804
1975
  player_email: input.playerEmail,
@@ -1834,7 +2005,7 @@ var CardsServer = class {
1834
2005
  */
1835
2006
  async confirmSetup(input, opts) {
1836
2007
  if (typeof input.setupIntentId !== "string" || !input.setupIntentId.trim()) {
1837
- throw invalidInput("setupIntentId", input.setupIntentId, "is required (from beginSetup)");
2008
+ throw invalidInput2("setupIntentId", input.setupIntentId, "is required (from beginSetup)");
1838
2009
  }
1839
2010
  const raw = await this.http.post(
1840
2011
  "/api/currency-purchases/setup-intent/confirm",
@@ -1860,7 +2031,7 @@ var CardsServer = class {
1860
2031
  */
1861
2032
  async list(playerEmail, opts) {
1862
2033
  if (typeof playerEmail !== "string" || !playerEmail.trim()) {
1863
- throw invalidInput("playerEmail", playerEmail, "is required");
2034
+ throw invalidInput2("playerEmail", playerEmail, "is required");
1864
2035
  }
1865
2036
  const raw = await this.http.get(
1866
2037
  `/api/currency-purchases/player-cards?player_email=${encodeURIComponent(playerEmail)}`,
@@ -1883,7 +2054,7 @@ var SandboxSubscriptionsServer = class {
1883
2054
  async call(subscriptionId, tool, body, opts) {
1884
2055
  assertSubscriptionId(subscriptionId);
1885
2056
  if (typeof this.clockKey !== "string" || !this.clockKey.trim()) {
1886
- throw invalidInput(
2057
+ throw invalidInput2(
1887
2058
  "sandboxClockKey",
1888
2059
  this.clockKey,
1889
2060
  'is required for invo.sandbox.subscriptions.* \u2014 pass it to new InvoServer({ sandboxClockKey }) from the sandbox console (Game Settings, "Sandbox clock key")'
@@ -1909,7 +2080,7 @@ var SandboxSubscriptionsServer = class {
1909
2080
  */
1910
2081
  async advanceClock(subscriptionId, intervals = 1, opts) {
1911
2082
  if (!Number.isInteger(intervals) || intervals < 0 || intervals > 60) {
1912
- throw invalidInput("intervals", intervals, "must be an integer 0..60");
2083
+ throw invalidInput2("intervals", intervals, "must be an integer 0..60");
1913
2084
  }
1914
2085
  return this.call(subscriptionId, "advance-clock", { intervals }, opts);
1915
2086
  }
@@ -1932,7 +2103,7 @@ var SandboxSubscriptionsServer = class {
1932
2103
  */
1933
2104
  async forceFailure(subscriptionId, outcome = "card_declined", options, opts) {
1934
2105
  if (!SANDBOX_FAILURE_OUTCOMES.has(outcome)) {
1935
- throw invalidInput("outcome", outcome, 'must be "card_declined" | "insufficient_funds" | "error"');
2106
+ throw invalidInput2("outcome", outcome, 'must be "card_declined" | "insufficient_funds" | "error"');
1936
2107
  }
1937
2108
  const body = { outcome };
1938
2109
  if (options?.failureCode !== void 0) body["failure_code"] = options.failureCode;
@@ -1977,6 +2148,7 @@ var InvoServer = class {
1977
2148
  this.subscriptions = new SubscriptionsServer(this.http, this.auth);
1978
2149
  this.cards = new CardsServer(this.http, this.auth);
1979
2150
  this.sandbox = new SandboxServer(this.http, this.auth, config.sandboxClockKey);
2151
+ this.payouts = new PayoutsServer(this.http, this.auth);
1980
2152
  }
1981
2153
  /**
1982
2154
  * Mint a short-lived, game-scoped player token to hand to the browser InvoClient.
@@ -1997,7 +2169,7 @@ var InvoServer = class {
1997
2169
  */
1998
2170
  async mintPlayerToken(input, opts) {
1999
2171
  if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
2000
- throw invalidInput("playerEmail", input.playerEmail, "is required");
2172
+ throw invalidInput2("playerEmail", input.playerEmail, "is required");
2001
2173
  }
2002
2174
  const body = { player_email: input.playerEmail };
2003
2175
  if (input.playerPhone !== void 0) {
@@ -2006,7 +2178,7 @@ var InvoServer = class {
2006
2178
  }
2007
2179
  if (input.playerName !== void 0) {
2008
2180
  if (typeof input.playerName !== "string") {
2009
- throw invalidInput("playerName", input.playerName, "must be a string");
2181
+ throw invalidInput2("playerName", input.playerName, "must be a string");
2010
2182
  }
2011
2183
  body["player_name"] = input.playerName;
2012
2184
  }
@@ -2039,7 +2211,7 @@ var InvoServer = class {
2039
2211
  */
2040
2212
  async registerPlayer(input, opts) {
2041
2213
  if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
2042
- throw invalidInput("playerEmail", input.playerEmail, "is required");
2214
+ throw invalidInput2("playerEmail", input.playerEmail, "is required");
2043
2215
  }
2044
2216
  assertE164(input.playerPhone, "playerPhone");
2045
2217
  const body = {
@@ -2048,7 +2220,7 @@ var InvoServer = class {
2048
2220
  };
2049
2221
  if (input.playerName !== void 0) {
2050
2222
  if (typeof input.playerName !== "string") {
2051
- throw invalidInput("playerName", input.playerName, "must be a string");
2223
+ throw invalidInput2("playerName", input.playerName, "must be a string");
2052
2224
  }
2053
2225
  body["player_name"] = input.playerName;
2054
2226
  }
@@ -2086,7 +2258,7 @@ var InvoServer = class {
2086
2258
  */
2087
2259
  async updatePlayerPhone(input, opts) {
2088
2260
  if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
2089
- throw invalidInput("playerEmail", input.playerEmail, "is required");
2261
+ throw invalidInput2("playerEmail", input.playerEmail, "is required");
2090
2262
  }
2091
2263
  assertE164(input.newPhone, "newPhone");
2092
2264
  const raw = await this.http.post(
@@ -2130,7 +2302,7 @@ var InvoServer = class {
2130
2302
  */
2131
2303
  async requestPhoneChange(input, opts) {
2132
2304
  if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
2133
- throw invalidInput("playerEmail", input.playerEmail, "is required");
2305
+ throw invalidInput2("playerEmail", input.playerEmail, "is required");
2134
2306
  }
2135
2307
  assertE164(input.newPhone, "newPhone");
2136
2308
  const raw = await this.http.post(
@@ -2150,7 +2322,7 @@ var InvoServer = class {
2150
2322
  */
2151
2323
  async getPhoneChange(changeRequestId, opts) {
2152
2324
  if (typeof changeRequestId !== "string" || !changeRequestId.trim()) {
2153
- throw invalidInput("changeRequestId", changeRequestId, "is required");
2325
+ throw invalidInput2("changeRequestId", changeRequestId, "is required");
2154
2326
  }
2155
2327
  const raw = await this.http.get(
2156
2328
  `/api/sdk/players/phone/change-requests/${encodeURIComponent(changeRequestId)}`,
@@ -2214,7 +2386,7 @@ var InvoServer = class {
2214
2386
  * purchase.completed webhook. */
2215
2387
  async createCheckout(input, opts) {
2216
2388
  if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
2217
- throw invalidInput("playerEmail", input.playerEmail, "is required");
2389
+ throw invalidInput2("playerEmail", input.playerEmail, "is required");
2218
2390
  }
2219
2391
  assertUsdAmount(input.usdAmount);
2220
2392
  const body = {
@@ -2278,7 +2450,7 @@ var InvoServer = class {
2278
2450
  */
2279
2451
  async purchaseCurrency(input, opts) {
2280
2452
  if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
2281
- throw invalidInput("playerEmail", input.playerEmail, "is required");
2453
+ throw invalidInput2("playerEmail", input.playerEmail, "is required");
2282
2454
  }
2283
2455
  assertUsdAmount(input.usdAmount);
2284
2456
  if (!input.purchaseReference) {
@@ -2397,8 +2569,8 @@ var InvoServer = class {
2397
2569
  };
2398
2570
  }
2399
2571
  /** Fetch purchase status (order + financial summary + timeline). */
2400
- async getOrderDetails(query, opts) {
2401
- if (!query.orderId && !query.transactionId) {
2572
+ async getOrderDetails(query2, opts) {
2573
+ if (!query2.orderId && !query2.transactionId) {
2402
2574
  throw new InvoError({
2403
2575
  message: "getOrderDetails requires an `orderId` or `transactionId`.",
2404
2576
  code: "INVALID_INPUT",
@@ -2406,8 +2578,8 @@ var InvoServer = class {
2406
2578
  });
2407
2579
  }
2408
2580
  const q = new URLSearchParams();
2409
- if (query.orderId) q.set("order_id", query.orderId);
2410
- if (query.transactionId) q.set("transaction_id", query.transactionId);
2581
+ if (query2.orderId) q.set("order_id", query2.orderId);
2582
+ if (query2.transactionId) q.set("transaction_id", query2.transactionId);
2411
2583
  const raw = await this.http.get(
2412
2584
  `/api/currency-purchases/order-details?${q.toString()}`,
2413
2585
  this.auth,
@@ -2430,8 +2602,8 @@ var InvoServer = class {
2430
2602
  * no-VAT catalogue and lets the PURCHASE be what refuses; the only 503 is
2431
2603
  * the rail being disabled platform-wide, whose body carries no error code.
2432
2604
  */
2433
- async steamPacks(query, opts) {
2434
- const qs = query?.steamid ? `?steamid=${encodeURIComponent(query.steamid)}` : "";
2605
+ async steamPacks(query2, opts) {
2606
+ const qs = query2?.steamid ? `?steamid=${encodeURIComponent(query2.steamid)}` : "";
2435
2607
  const raw = await this.http.get(
2436
2608
  `/api/currency-purchases/steam/packs${qs}`,
2437
2609
  this.auth,
@@ -2476,12 +2648,12 @@ var InvoServer = class {
2476
2648
  */
2477
2649
  async steamInitPurchase(input, opts) {
2478
2650
  if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
2479
- throw invalidInput("playerEmail", input.playerEmail, "is required");
2651
+ throw invalidInput2("playerEmail", input.playerEmail, "is required");
2480
2652
  }
2481
2653
  if (!/^[0-9]+$/.test(String(input.steamid ?? ""))) {
2482
- throw invalidInput("steamid", input.steamid, "must be the player's numeric 64-bit Steam id");
2654
+ throw invalidInput2("steamid", input.steamid, "must be the player's numeric 64-bit Steam id");
2483
2655
  }
2484
- if (!input.packId) throw invalidInput("packId", input.packId, "is required \u2014 fetch steamPacks()");
2656
+ if (!input.packId) throw invalidInput2("packId", input.packId, "is required \u2014 fetch steamPacks()");
2485
2657
  if (!input.purchaseReference) {
2486
2658
  throw new InvoError({
2487
2659
  message: "purchaseReference is required (idempotency key, unique per intended purchase).",
@@ -2542,7 +2714,7 @@ var InvoServer = class {
2542
2714
  * detects the authorized transaction and credits, on a delay.
2543
2715
  */
2544
2716
  async steamFinalizePurchase(input, opts) {
2545
- if (!input.orderId) throw invalidInput("orderId", input.orderId, "is required (from steamInitPurchase)");
2717
+ if (!input.orderId) throw invalidInput2("orderId", input.orderId, "is required (from steamInitPurchase)");
2546
2718
  const raw = await this.http.post(
2547
2719
  "/api/currency-purchases/steam/finalize-purchase",
2548
2720
  { order_id: input.orderId },
@@ -2577,17 +2749,17 @@ var InvoServer = class {
2577
2749
  ["itemName", input.itemName]
2578
2750
  ];
2579
2751
  for (const [k, v] of required) {
2580
- if (typeof v !== "string" || !v.trim()) throw invalidInput(k, v, "is required");
2752
+ if (typeof v !== "string" || !v.trim()) throw invalidInput2(k, v, "is required");
2581
2753
  }
2582
2754
  if (!Number.isInteger(input.itemQuantity) || input.itemQuantity < 1 || input.itemQuantity > 1e3) {
2583
- throw invalidInput("itemQuantity", input.itemQuantity, "must be an integer 1..1000");
2755
+ throw invalidInput2("itemQuantity", input.itemQuantity, "must be an integer 1..1000");
2584
2756
  }
2585
2757
  const unit = parseMoney(input.unitPrice, MAX_ITEM_PRICE, "unitPrice");
2586
2758
  const total = parseMoney(input.totalPrice, MAX_ITEM_PRICE, "totalPrice");
2587
2759
  const expectedCents = Math.round(unit * input.itemQuantity * 100);
2588
2760
  const totalCents = Math.round(total * 100);
2589
2761
  if (Math.abs(totalCents - expectedCents) > 1) {
2590
- throw invalidInput(
2762
+ throw invalidInput2(
2591
2763
  "totalPrice",
2592
2764
  input.totalPrice,
2593
2765
  `must equal unitPrice \xD7 itemQuantity (\xB10.01): ${unit} \xD7 ${input.itemQuantity}`
@@ -2625,14 +2797,14 @@ var InvoServer = class {
2625
2797
  };
2626
2798
  }
2627
2799
  /** Paginated item-purchase history for a player (§4.8 companion read). */
2628
- async getItemPurchaseHistory(query, opts) {
2629
- if (typeof query.playerEmail !== "string" || !query.playerEmail.trim()) {
2630
- throw invalidInput("playerEmail", query.playerEmail, "is required");
2800
+ async getItemPurchaseHistory(query2, opts) {
2801
+ if (typeof query2.playerEmail !== "string" || !query2.playerEmail.trim()) {
2802
+ throw invalidInput2("playerEmail", query2.playerEmail, "is required");
2631
2803
  }
2632
2804
  const q = new URLSearchParams();
2633
- q.set("player_email", query.playerEmail);
2634
- if (query.limit != null) q.set("limit", String(query.limit));
2635
- if (query.offset != null) q.set("offset", String(query.offset));
2805
+ q.set("player_email", query2.playerEmail);
2806
+ if (query2.limit != null) q.set("limit", String(query2.limit));
2807
+ if (query2.offset != null) q.set("offset", String(query2.offset));
2636
2808
  const raw = await this.http.get(
2637
2809
  `/api/item-purchases/player-purchase-history?${q.toString()}`,
2638
2810
  this.auth,
@@ -2646,8 +2818,8 @@ var InvoServer = class {
2646
2818
  }
2647
2819
  /** Look up one item order by EXACTLY ONE of orderId | transactionId | clientRequestId
2648
2820
  * (§4.8). Use clientRequestId for saga/recovery: "did this purchase actually complete?" */
2649
- async getItemOrderDetails(query, opts) {
2650
- const provided = [query.orderId, query.transactionId, query.clientRequestId].filter(
2821
+ async getItemOrderDetails(query2, opts) {
2822
+ const provided = [query2.orderId, query2.transactionId, query2.clientRequestId].filter(
2651
2823
  (v) => typeof v === "string" && v.trim()
2652
2824
  );
2653
2825
  if (provided.length !== 1) {
@@ -2658,9 +2830,9 @@ var InvoServer = class {
2658
2830
  });
2659
2831
  }
2660
2832
  const q = new URLSearchParams();
2661
- if (query.orderId) q.set("order_id", query.orderId);
2662
- if (query.transactionId) q.set("transaction_id", query.transactionId);
2663
- if (query.clientRequestId) q.set("client_request_id", query.clientRequestId);
2833
+ if (query2.orderId) q.set("order_id", query2.orderId);
2834
+ if (query2.transactionId) q.set("transaction_id", query2.transactionId);
2835
+ if (query2.clientRequestId) q.set("client_request_id", query2.clientRequestId);
2664
2836
  const raw = await this.http.get(
2665
2837
  `/api/item-purchases/order-details?${q.toString()}`,
2666
2838
  this.auth,
@@ -2676,15 +2848,15 @@ var InvoServer = class {
2676
2848
  * for await (const row of invo.iterateItemPurchaseHistory({ playerEmail })) { … }
2677
2849
  * ```
2678
2850
  */
2679
- async *iterateItemPurchaseHistory(query, opts) {
2680
- if (typeof query.playerEmail !== "string" || !query.playerEmail.trim()) {
2681
- throw invalidInput("playerEmail", query.playerEmail, "is required");
2851
+ async *iterateItemPurchaseHistory(query2, opts) {
2852
+ if (typeof query2.playerEmail !== "string" || !query2.playerEmail.trim()) {
2853
+ throw invalidInput2("playerEmail", query2.playerEmail, "is required");
2682
2854
  }
2683
- const pageSize = typeof query.pageSize === "number" && query.pageSize > 0 ? Math.floor(query.pageSize) : 50;
2855
+ const pageSize = typeof query2.pageSize === "number" && query2.pageSize > 0 ? Math.floor(query2.pageSize) : 50;
2684
2856
  let yielded = 0;
2685
2857
  for (let offset = 0; ; offset += pageSize) {
2686
2858
  const { history, pagination } = await this.getItemPurchaseHistory(
2687
- { playerEmail: query.playerEmail, limit: pageSize, offset },
2859
+ { playerEmail: query2.playerEmail, limit: pageSize, offset },
2688
2860
  opts
2689
2861
  );
2690
2862
  if (history.length === 0) return;
@@ -2718,23 +2890,23 @@ var InvoServer = class {
2718
2890
  * `500 PLAYER_ACTIVITY_FAILED` (retry later), `429` (back off; `err.retryAfter`). A GET, so
2719
2891
  * transient failures are retried automatically.
2720
2892
  */
2721
- async getPlayerActivity(query, opts) {
2722
- if (typeof query?.playerEmail !== "string" || !query.playerEmail.trim()) {
2723
- throw invalidInput("playerEmail", query?.playerEmail, "is required");
2724
- }
2725
- assertPageLimit(query.limit);
2726
- assertCursor(query.cursor);
2727
- if (query.types !== void 0) {
2728
- if (!Array.isArray(query.types) || query.types.some((t) => typeof t !== "string" || !t.trim() || t.includes(","))) {
2729
- throw invalidInput("types", query.types, "must be an array of activity kinds");
2893
+ async getPlayerActivity(query2, opts) {
2894
+ if (typeof query2?.playerEmail !== "string" || !query2.playerEmail.trim()) {
2895
+ throw invalidInput2("playerEmail", query2?.playerEmail, "is required");
2896
+ }
2897
+ assertPageLimit(query2.limit);
2898
+ assertCursor(query2.cursor);
2899
+ if (query2.types !== void 0) {
2900
+ if (!Array.isArray(query2.types) || query2.types.some((t) => typeof t !== "string" || !t.trim() || t.includes(","))) {
2901
+ throw invalidInput2("types", query2.types, "must be an array of activity kinds");
2730
2902
  }
2731
2903
  }
2732
2904
  const q = new URLSearchParams();
2733
- q.set("player_email", query.playerEmail.trim());
2734
- if (query.limit !== void 0) q.set("limit", String(query.limit));
2735
- if (query.cursor !== void 0) q.set("cursor", query.cursor);
2736
- if (query.types && query.types.length > 0) {
2737
- q.set("types", query.types.map((t) => t.trim()).join(","));
2905
+ q.set("player_email", query2.playerEmail.trim());
2906
+ if (query2.limit !== void 0) q.set("limit", String(query2.limit));
2907
+ if (query2.cursor !== void 0) q.set("cursor", query2.cursor);
2908
+ if (query2.types && query2.types.length > 0) {
2909
+ q.set("types", query2.types.map((t) => t.trim()).join(","));
2738
2910
  }
2739
2911
  const raw = await this.http.get(
2740
2912
  `/api/sdk/players/activity?${q.toString()}`,
@@ -2744,7 +2916,7 @@ var InvoServer = class {
2744
2916
  const activity = Array.isArray(raw["activity"]) ? raw["activity"].map(toPlayerActivityEntry) : [];
2745
2917
  const nextCursor = nextCursorOf(raw);
2746
2918
  return {
2747
- playerEmail: String(raw["player_email"] ?? query.playerEmail.trim()),
2919
+ playerEmail: String(raw["player_email"] ?? query2.playerEmail.trim()),
2748
2920
  gameId: String(raw["game_id"] ?? ""),
2749
2921
  types: Array.isArray(raw["types"]) ? raw["types"].map(String) : [],
2750
2922
  activity,
@@ -2762,12 +2934,12 @@ var InvoServer = class {
2762
2934
  * for await (const row of invo.iteratePlayerActivity({ playerEmail, types: ["send", "transfer"] })) { … }
2763
2935
  * ```
2764
2936
  */
2765
- async *iteratePlayerActivity(query, opts) {
2937
+ async *iteratePlayerActivity(query2, opts) {
2766
2938
  let cursor;
2767
2939
  const seen = /* @__PURE__ */ new Set();
2768
2940
  for (; ; ) {
2769
2941
  const page = await this.getPlayerActivity(
2770
- { playerEmail: query.playerEmail, types: query.types, limit: query.pageSize, cursor },
2942
+ { playerEmail: query2.playerEmail, types: query2.types, limit: query2.pageSize, cursor },
2771
2943
  opts
2772
2944
  );
2773
2945
  for (const row of page.activity) yield row;
@@ -2784,11 +2956,11 @@ var InvoServer = class {
2784
2956
  * browser `InvoClient.getBalance()` (token-authed, identity from the token) for a
2785
2957
  * client-side read, or `playerEmail` here server-side.
2786
2958
  */
2787
- async getPlayerBalance(query, opts) {
2959
+ async getPlayerBalance(query2, opts) {
2788
2960
  let path;
2789
- if (typeof query.playerEmail === "string" && query.playerEmail.trim()) {
2790
- path = `/api/player-balances/player/by-email/${encodeURIComponent(query.playerEmail)}`;
2791
- } else if (query.playerId != null && String(query.playerId).trim()) {
2961
+ if (typeof query2.playerEmail === "string" && query2.playerEmail.trim()) {
2962
+ path = `/api/player-balances/player/by-email/${encodeURIComponent(query2.playerEmail)}`;
2963
+ } else if (query2.playerId != null && String(query2.playerId).trim()) {
2792
2964
  throw new InvoError({
2793
2965
  message: "getPlayerBalance is by playerEmail only \u2014 there is no by-id balance route. Use InvoClient.getBalance() client-side (player token), or pass playerEmail here.",
2794
2966
  code: "INVALID_INPUT",
@@ -2827,7 +2999,7 @@ var InvoServer = class {
2827
2999
  */
2828
3000
  async getPlayerRewards(playerEmail, opts) {
2829
3001
  if (typeof playerEmail !== "string" || !playerEmail.trim()) {
2830
- throw invalidInput("playerEmail", playerEmail, "is required");
3002
+ throw invalidInput2("playerEmail", playerEmail, "is required");
2831
3003
  }
2832
3004
  const raw = await this.http.get(
2833
3005
  `/api/sdk/loyalty/players/rewards?player_email=${encodeURIComponent(playerEmail.trim())}`,
@@ -2843,15 +3015,15 @@ var InvoServer = class {
2843
3015
  * which is null when the phone maps to more than one of your players). Pairs with the
2844
3016
  * `transfer.claim_pending` webhook (the webhook is the wake-up; this is the list).
2845
3017
  */
2846
- async getInboundPending(query, opts) {
2847
- const hasEmail = typeof query.playerEmail === "string" && query.playerEmail.trim();
2848
- const hasPhone = typeof query.playerPhone === "string" && query.playerPhone.trim();
3018
+ async getInboundPending(query2, opts) {
3019
+ const hasEmail = typeof query2.playerEmail === "string" && query2.playerEmail.trim();
3020
+ const hasPhone = typeof query2.playerPhone === "string" && query2.playerPhone.trim();
2849
3021
  if (!hasEmail && !hasPhone) {
2850
- throw invalidInput("query", query, "requires a playerEmail or playerPhone");
3022
+ throw invalidInput2("query", query2, "requires a playerEmail or playerPhone");
2851
3023
  }
2852
3024
  const q = new URLSearchParams();
2853
- if (hasEmail) q.set("player_email", query.playerEmail.trim());
2854
- if (hasPhone) q.set("player_phone", query.playerPhone.trim());
3025
+ if (hasEmail) q.set("player_email", query2.playerEmail.trim());
3026
+ if (hasPhone) q.set("player_phone", query2.playerPhone.trim());
2855
3027
  const raw = await this.http.get(
2856
3028
  `/api/transfers/inbound-pending?${q.toString()}`,
2857
3029
  this.auth,
@@ -2868,11 +3040,11 @@ var InvoServer = class {
2868
3040
  *
2869
3041
  * ⚠️ Returns first-party PII (emails/phones) — never expose this to the browser.
2870
3042
  */
2871
- async getLinkedIdentities(query, opts) {
2872
- const phone = typeof query.playerPhone === "string" && query.playerPhone.trim() ? query.playerPhone.trim() : "";
2873
- const email = typeof query.playerEmail === "string" && query.playerEmail.trim() ? query.playerEmail.trim() : "";
3043
+ async getLinkedIdentities(query2, opts) {
3044
+ const phone = typeof query2.playerPhone === "string" && query2.playerPhone.trim() ? query2.playerPhone.trim() : "";
3045
+ const email = typeof query2.playerEmail === "string" && query2.playerEmail.trim() ? query2.playerEmail.trim() : "";
2874
3046
  if (!phone && !email) {
2875
- throw invalidInput("query", query, "requires a playerEmail or playerPhone");
3047
+ throw invalidInput2("query", query2, "requires a playerEmail or playerPhone");
2876
3048
  }
2877
3049
  const q = new URLSearchParams();
2878
3050
  if (phone) q.set("player_phone", phone);
@@ -2922,10 +3094,10 @@ var InvoServer = class {
2922
3094
  */
2923
3095
  async verifySmsTransfer(transactionId, smsPin, opts) {
2924
3096
  if (typeof transactionId !== "string" || !transactionId.trim()) {
2925
- throw invalidInput("transactionId", transactionId, "is required");
3097
+ throw invalidInput2("transactionId", transactionId, "is required");
2926
3098
  }
2927
3099
  if (typeof smsPin !== "string" || !smsPin.trim()) {
2928
- throw invalidInput("smsPin", smsPin, "is required");
3100
+ throw invalidInput2("smsPin", smsPin, "is required");
2929
3101
  }
2930
3102
  const raw = await this.http.post(
2931
3103
  "/api/transfers/verify-sms",
@@ -2947,10 +3119,10 @@ var InvoServer = class {
2947
3119
  */
2948
3120
  async verifySmsSend(transactionId, smsPin, opts) {
2949
3121
  if (typeof transactionId !== "string" || !transactionId.trim()) {
2950
- throw invalidInput("transactionId", transactionId, "is required");
3122
+ throw invalidInput2("transactionId", transactionId, "is required");
2951
3123
  }
2952
3124
  if (typeof smsPin !== "string" || !smsPin.trim()) {
2953
- throw invalidInput("smsPin", smsPin, "is required");
3125
+ throw invalidInput2("smsPin", smsPin, "is required");
2954
3126
  }
2955
3127
  const raw = await this.http.post(
2956
3128
  "/api/currency-sends/verify-sms",
@@ -3011,7 +3183,7 @@ var InvoServer = class {
3011
3183
  /** Read a TRANSFER's status (verification_state + amounts + destination). */
3012
3184
  async getTransferStatus(transactionId, opts) {
3013
3185
  if (typeof transactionId !== "string" || !transactionId.trim()) {
3014
- throw invalidInput("transactionId", transactionId, "is required");
3186
+ throw invalidInput2("transactionId", transactionId, "is required");
3015
3187
  }
3016
3188
  const raw = await this.http.get(
3017
3189
  `/api/transfers/${encodeURIComponent(transactionId)}/status`,
@@ -3023,7 +3195,7 @@ var InvoServer = class {
3023
3195
  /** Read a SEND's status (adds fees, game names, claim_info, … on `raw`). */
3024
3196
  async getSendStatus(transactionId, opts) {
3025
3197
  if (typeof transactionId !== "string" || !transactionId.trim()) {
3026
- throw invalidInput("transactionId", transactionId, "is required");
3198
+ throw invalidInput2("transactionId", transactionId, "is required");
3027
3199
  }
3028
3200
  const raw = await this.http.get(
3029
3201
  `/api/currency-sends/${encodeURIComponent(transactionId)}/status`,
@@ -3039,7 +3211,7 @@ var InvoServer = class {
3039
3211
  */
3040
3212
  async getGuardianApprovalStatus(transactionId, opts) {
3041
3213
  if (typeof transactionId !== "string" || !transactionId.trim()) {
3042
- throw invalidInput("transactionId", transactionId, "is required");
3214
+ throw invalidInput2("transactionId", transactionId, "is required");
3043
3215
  }
3044
3216
  const raw = await this.http.get(
3045
3217
  `/api/transactions/${encodeURIComponent(transactionId)}/approval-status`,
@@ -3055,15 +3227,15 @@ var InvoServer = class {
3055
3227
  * the source game is passed explicitly rather than inferred from a player token. Rows
3056
3228
  * share the browser shape. Idempotent (a POST read — safe to retry).
3057
3229
  */
3058
- async getDestinations(query, opts) {
3059
- if (query.sourceGameId == null || String(query.sourceGameId).trim() === "") {
3060
- throw invalidInput("sourceGameId", query.sourceGameId, "is required");
3230
+ async getDestinations(query2, opts) {
3231
+ if (query2.sourceGameId == null || String(query2.sourceGameId).trim() === "") {
3232
+ throw invalidInput2("sourceGameId", query2.sourceGameId, "is required");
3061
3233
  }
3062
- const direction = query.direction ?? "transfer";
3234
+ const direction = query2.direction ?? "transfer";
3063
3235
  const path = direction === "send" ? "/api/currency-sends/available-destinations" : "/api/transfers/available-destinations";
3064
3236
  const raw = await this.http.post(
3065
3237
  path,
3066
- { source_game_id: query.sourceGameId },
3238
+ { source_game_id: query2.sourceGameId },
3067
3239
  this.auth,
3068
3240
  { idempotent: true, signal: opts?.signal }
3069
3241
  // a POST read — no side effect, safe to retry
@@ -3082,10 +3254,10 @@ var InvoServer = class {
3082
3254
  */
3083
3255
  async phoneShareInitiate(input, opts) {
3084
3256
  if (typeof input.phone !== "string" || !input.phone.trim()) {
3085
- throw invalidInput("phone", input.phone, "is required");
3257
+ throw invalidInput2("phone", input.phone, "is required");
3086
3258
  }
3087
3259
  if (typeof input.email !== "string" || !input.email.trim()) {
3088
- throw invalidInput("email", input.email, "is required");
3260
+ throw invalidInput2("email", input.email, "is required");
3089
3261
  }
3090
3262
  const raw = await this.http.post(
3091
3263
  "/api/wallet/phone-share/initiate",
@@ -3105,10 +3277,10 @@ var InvoServer = class {
3105
3277
  */
3106
3278
  async phoneShareApprove(input, opts) {
3107
3279
  if (typeof input.approvalId !== "string" || !input.approvalId.trim()) {
3108
- throw invalidInput("approvalId", input.approvalId, "is required");
3280
+ throw invalidInput2("approvalId", input.approvalId, "is required");
3109
3281
  }
3110
3282
  if (typeof input.otp !== "string" || !input.otp.trim()) {
3111
- throw invalidInput("otp", input.otp, "is required");
3283
+ throw invalidInput2("otp", input.otp, "is required");
3112
3284
  }
3113
3285
  const raw = await this.http.post(
3114
3286
  "/api/wallet/phone-share/approve",
@@ -3127,10 +3299,10 @@ var InvoServer = class {
3127
3299
  */
3128
3300
  async phoneShareStatus(input, opts) {
3129
3301
  if (typeof input.phone !== "string" || !input.phone.trim()) {
3130
- throw invalidInput("phone", input.phone, "is required");
3302
+ throw invalidInput2("phone", input.phone, "is required");
3131
3303
  }
3132
3304
  if (typeof input.email !== "string" || !input.email.trim()) {
3133
- throw invalidInput("email", input.email, "is required");
3305
+ throw invalidInput2("email", input.email, "is required");
3134
3306
  }
3135
3307
  const q = new URLSearchParams();
3136
3308
  q.set("phone", input.phone);
@@ -3168,12 +3340,12 @@ var InvoServer = class {
3168
3340
  async beginDeviceApproval(input, opts) {
3169
3341
  assertPlayerToken(input.playerToken);
3170
3342
  if (typeof input.transactionId !== "string" || !input.transactionId.trim()) {
3171
- throw invalidInput("transactionId", input.transactionId, "is required");
3343
+ throw invalidInput2("transactionId", input.transactionId, "is required");
3172
3344
  }
3173
3345
  assertDeviceApprovalFlow(input.flow);
3174
3346
  const channel = input.channel ?? "qr";
3175
3347
  if (!DEVICE_APPROVAL_CHANNELS.has(channel)) {
3176
- throw invalidInput("channel", channel, 'must be "qr" | "app_browser" ("popup" is browser-only)');
3348
+ throw invalidInput2("channel", channel, 'must be "qr" | "app_browser" ("popup" is browser-only)');
3177
3349
  }
3178
3350
  if (channel === "popup") {
3179
3351
  throw new InvoError({
@@ -3211,7 +3383,7 @@ var InvoServer = class {
3211
3383
  async pollDeviceApproval(input, opts) {
3212
3384
  assertPlayerToken(input.playerToken);
3213
3385
  if (typeof input.deviceCode !== "string" || !input.deviceCode.trim()) {
3214
- throw invalidInput("deviceCode", input.deviceCode, "is required (from beginDeviceApproval)");
3386
+ throw invalidInput2("deviceCode", input.deviceCode, "is required (from beginDeviceApproval)");
3215
3387
  }
3216
3388
  let raw;
3217
3389
  try {
@@ -3249,10 +3421,10 @@ var InvoServer = class {
3249
3421
  async confirmDeviceEnrollment(input, opts) {
3250
3422
  assertPlayerToken(input.playerToken);
3251
3423
  if (typeof input.deviceCode !== "string" || !input.deviceCode.trim()) {
3252
- throw invalidInput("deviceCode", input.deviceCode, "is required (from beginDeviceApproval)");
3424
+ throw invalidInput2("deviceCode", input.deviceCode, "is required (from beginDeviceApproval)");
3253
3425
  }
3254
3426
  if (input.decision !== "approve" && input.decision !== "deny") {
3255
- throw invalidInput("decision", input.decision, 'must be "approve" or "deny"');
3427
+ throw invalidInput2("decision", input.decision, 'must be "approve" or "deny"');
3256
3428
  }
3257
3429
  const raw = await this.http.post(
3258
3430
  "/api/sdk/approvals/device/confirm-enrollment",
@@ -3303,11 +3475,11 @@ var InvoServer = class {
3303
3475
  async approveWithDeviceCode(input, opts) {
3304
3476
  assertPlayerToken(input.playerToken);
3305
3477
  if (typeof input.transactionId !== "string" || !input.transactionId.trim()) {
3306
- throw invalidInput("transactionId", input.transactionId, "is required");
3478
+ throw invalidInput2("transactionId", input.transactionId, "is required");
3307
3479
  }
3308
3480
  assertDeviceApprovalFlow(input.flow);
3309
3481
  if (typeof input.deviceCode !== "string" || !input.deviceCode.trim()) {
3310
- throw invalidInput("deviceCode", input.deviceCode, "is required (from beginDeviceApproval)");
3482
+ throw invalidInput2("deviceCode", input.deviceCode, "is required (from beginDeviceApproval)");
3311
3483
  }
3312
3484
  let raw;
3313
3485
  try {
@@ -3365,11 +3537,11 @@ var InvoServer = class {
3365
3537
  async completeDeviceApproval(input, opts) {
3366
3538
  assertPlayerToken(input.playerToken);
3367
3539
  if (typeof input.transactionId !== "string" || !input.transactionId.trim()) {
3368
- throw invalidInput("transactionId", input.transactionId, "is required");
3540
+ throw invalidInput2("transactionId", input.transactionId, "is required");
3369
3541
  }
3370
3542
  assertDeviceApprovalFlow(input.flow);
3371
3543
  if (typeof input.deviceCode !== "string" || !input.deviceCode.trim()) {
3372
- throw invalidInput("deviceCode", input.deviceCode, "is required (from beginDeviceApproval)");
3544
+ throw invalidInput2("deviceCode", input.deviceCode, "is required (from beginDeviceApproval)");
3373
3545
  }
3374
3546
  const signal = input.signal ?? opts?.signal;
3375
3547
  const { playerToken, deviceCode } = input;
@@ -3454,6 +3626,6 @@ var InvoServer = class {
3454
3626
  }
3455
3627
  };
3456
3628
 
3457
- export { CardsServer, InvoServer, PlatformCommerceServer, SDK_VERSION, SandboxServer, SandboxSubscriptionsServer, SubscriptionsServer, createWebhookHandler, isRefundPendingApproval, verifyWebhook, verifyWebhookAsync };
3629
+ export { CardsServer, InvoServer, PayoutsServer, PlatformCommerceServer, SDK_VERSION, SandboxServer, SandboxSubscriptionsServer, SubscriptionsServer, createWebhookHandler, isRefundPendingApproval, verifyWebhook, verifyWebhookAsync };
3458
3630
  //# sourceMappingURL=server.js.map
3459
3631
  //# sourceMappingURL=server.js.map