@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/CHANGELOG.md +1340 -1332
- package/README.md +31 -0
- package/dist/server.cjs +334 -161
- package/dist/server.d.cts +203 -9
- package/dist/server.d.ts +203 -9
- package/dist/server.js +335 -163
- package/package.json +77 -77
package/dist/server.cjs
CHANGED
|
@@ -1528,7 +1528,178 @@ function toPhoneChangeRequest(raw) {
|
|
|
1528
1528
|
}
|
|
1529
1529
|
|
|
1530
1530
|
// src/version.ts
|
|
1531
|
-
var SDK_VERSION = "3.
|
|
1531
|
+
var SDK_VERSION = "3.25.0";
|
|
1532
|
+
|
|
1533
|
+
// src/payouts.ts
|
|
1534
|
+
var AMOUNT = /^\d+(\.\d{1,2})?$/;
|
|
1535
|
+
function invalidInput(label, value, why) {
|
|
1536
|
+
return new InvoError({
|
|
1537
|
+
message: `${label} ${why} (got ${JSON.stringify(value)}).`,
|
|
1538
|
+
code: "INVALID_INPUT",
|
|
1539
|
+
status: 0
|
|
1540
|
+
});
|
|
1541
|
+
}
|
|
1542
|
+
function requireText(label, value) {
|
|
1543
|
+
if (typeof value !== "string" || !value.trim()) throw invalidInput(label, value, "is required");
|
|
1544
|
+
return value.trim();
|
|
1545
|
+
}
|
|
1546
|
+
function amountString(value) {
|
|
1547
|
+
const s = typeof value === "number" ? Number.isFinite(value) ? String(value) : "" : String(value ?? "").trim();
|
|
1548
|
+
if (!AMOUNT.test(s) || Number(s) <= 0) {
|
|
1549
|
+
throw invalidInput("amountUsd", value, "must be a positive amount with at most two decimal places");
|
|
1550
|
+
}
|
|
1551
|
+
return s;
|
|
1552
|
+
}
|
|
1553
|
+
function query(params) {
|
|
1554
|
+
const parts = [];
|
|
1555
|
+
for (const [k, v] of Object.entries(params)) {
|
|
1556
|
+
if (v === void 0 || v === "") continue;
|
|
1557
|
+
parts.push(`${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`);
|
|
1558
|
+
}
|
|
1559
|
+
return parts.length ? `?${parts.join("&")}` : "";
|
|
1560
|
+
}
|
|
1561
|
+
function payeePath(payeeId) {
|
|
1562
|
+
return `/api/partner-payees/${encodeURIComponent(requireText("payeeId", payeeId))}`;
|
|
1563
|
+
}
|
|
1564
|
+
function payoutId(id) {
|
|
1565
|
+
if (!Number.isInteger(id) || id <= 0) throw invalidInput("payoutId", id, "must be a positive integer");
|
|
1566
|
+
return id;
|
|
1567
|
+
}
|
|
1568
|
+
var PayoutsServer = class {
|
|
1569
|
+
constructor(http, auth) {
|
|
1570
|
+
this.http = http;
|
|
1571
|
+
this.auth = auth;
|
|
1572
|
+
}
|
|
1573
|
+
/**
|
|
1574
|
+
* Register a creator (`POST /api/partner-payees`). INVO emails the creator a link to INVO's
|
|
1575
|
+
* own page to give INVO their identity, tax and bank details. `invite.sent` is `false` when
|
|
1576
|
+
* INVO did not email the link (`invite.error_code` says why); the creator is registered
|
|
1577
|
+
* either way. Refusals: `409 PARTNER_REFERENCE_CONFLICT`, `400 INVALID_INPUT`,
|
|
1578
|
+
* `400 COUNTRY_NOT_SUPPORTED`.
|
|
1579
|
+
*/
|
|
1580
|
+
async registerPayee(input, opts) {
|
|
1581
|
+
if (input.payeeType !== "individual" && input.payeeType !== "business") {
|
|
1582
|
+
throw invalidInput("payeeType", input.payeeType, 'must be "individual" or "business"');
|
|
1583
|
+
}
|
|
1584
|
+
const raw = await this.http.post(
|
|
1585
|
+
"/api/partner-payees",
|
|
1586
|
+
{
|
|
1587
|
+
partner_reference: requireText("partnerReference", input.partnerReference),
|
|
1588
|
+
legal_name: requireText("legalName", input.legalName),
|
|
1589
|
+
email: requireText("email", input.email),
|
|
1590
|
+
country: requireText("country", input.country),
|
|
1591
|
+
payee_type: input.payeeType
|
|
1592
|
+
},
|
|
1593
|
+
this.auth,
|
|
1594
|
+
{ idempotent: true, signal: opts?.signal }
|
|
1595
|
+
);
|
|
1596
|
+
return {
|
|
1597
|
+
payee: raw["payee"],
|
|
1598
|
+
invite: raw["invite"],
|
|
1599
|
+
duplicate: raw["duplicate"] === true,
|
|
1600
|
+
raw
|
|
1601
|
+
};
|
|
1602
|
+
}
|
|
1603
|
+
/** This game's creators, newest first (`GET /api/partner-payees`). */
|
|
1604
|
+
async listPayees(q = {}, opts) {
|
|
1605
|
+
const raw = await this.http.get(
|
|
1606
|
+
`/api/partner-payees${query({ limit: q.limit, offset: q.offset, status: q.status })}`,
|
|
1607
|
+
this.auth,
|
|
1608
|
+
{ signal: opts?.signal }
|
|
1609
|
+
);
|
|
1610
|
+
return {
|
|
1611
|
+
total: Number(raw["total"] ?? 0),
|
|
1612
|
+
limit: Number(raw["limit"] ?? 0),
|
|
1613
|
+
offset: Number(raw["offset"] ?? 0),
|
|
1614
|
+
items: raw["items"] ?? [],
|
|
1615
|
+
raw
|
|
1616
|
+
};
|
|
1617
|
+
}
|
|
1618
|
+
/** One creator (`GET /api/partner-payees/{payeeId}`); `404 NOT_FOUND` if not this game's. */
|
|
1619
|
+
async getPayee(payeeId, opts) {
|
|
1620
|
+
const raw = await this.http.get(payeePath(payeeId), this.auth, {
|
|
1621
|
+
signal: opts?.signal
|
|
1622
|
+
});
|
|
1623
|
+
return raw["payee"];
|
|
1624
|
+
}
|
|
1625
|
+
/**
|
|
1626
|
+
* Email the creator a new link (`POST /api/partner-payees/{payeeId}/resend-invite`); the old
|
|
1627
|
+
* link stops working. Allowed while the creator is `invited`, `rejected` or `expired`
|
|
1628
|
+
* (`409 INVITE_NOT_NEEDED` otherwise). Never auto-retried.
|
|
1629
|
+
*/
|
|
1630
|
+
async resendPayeeInvite(payeeId, opts) {
|
|
1631
|
+
const raw = await this.http.post(
|
|
1632
|
+
`${payeePath(payeeId)}/resend-invite`,
|
|
1633
|
+
void 0,
|
|
1634
|
+
this.auth,
|
|
1635
|
+
{ signal: opts?.signal }
|
|
1636
|
+
);
|
|
1637
|
+
return raw["invite"];
|
|
1638
|
+
}
|
|
1639
|
+
/**
|
|
1640
|
+
* Ask INVO to pay out (`POST /api/partner-payouts/request`). With `payeeId`, INVO pays that
|
|
1641
|
+
* verified creator's bank account; otherwise your own verified bank account. The money comes
|
|
1642
|
+
* from the earnings INVO owes your game, and the payout fee is taken from the payout.
|
|
1643
|
+
* Creator refusals: `404 PAYEE_NOT_FOUND`, `409 PAYEE_NOT_VERIFIED`,
|
|
1644
|
+
* `409 PAYEE_VERIFICATION_EXPIRED`, `409 PAYEE_BANK_NOT_VERIFIED`, `409 PAYEE_NOT_PAYABLE`.
|
|
1645
|
+
* Retried safely only when `clientRequestId` is set.
|
|
1646
|
+
*/
|
|
1647
|
+
async requestPayout(input, opts) {
|
|
1648
|
+
if (input.payeeId !== void 0 && input.bankAccountId !== void 0) {
|
|
1649
|
+
throw invalidInput("bankAccountId", input.bankAccountId, "must not be sent with payeeId");
|
|
1650
|
+
}
|
|
1651
|
+
const body = {
|
|
1652
|
+
amount_usd: amountString(input.amountUsd),
|
|
1653
|
+
contact_email: requireText("contactEmail", input.contactEmail)
|
|
1654
|
+
};
|
|
1655
|
+
if (input.payeeId !== void 0) body["payee_id"] = requireText("payeeId", input.payeeId);
|
|
1656
|
+
if (input.bankAccountId !== void 0) body["bank_account_id"] = input.bankAccountId;
|
|
1657
|
+
if (input.clientRequestId !== void 0) body["client_request_id"] = requireText("clientRequestId", input.clientRequestId);
|
|
1658
|
+
if (input.partnerNote !== void 0) body["partner_note"] = input.partnerNote;
|
|
1659
|
+
if (input.additionalEmails !== void 0) body["additional_emails"] = input.additionalEmails;
|
|
1660
|
+
const raw = await this.http.post("/api/partner-payouts/request", body, this.auth, {
|
|
1661
|
+
idempotent: input.clientRequestId !== void 0,
|
|
1662
|
+
signal: opts?.signal
|
|
1663
|
+
});
|
|
1664
|
+
return {
|
|
1665
|
+
payout: raw["payout_request"],
|
|
1666
|
+
duplicate: raw["duplicate"] === true,
|
|
1667
|
+
raw
|
|
1668
|
+
};
|
|
1669
|
+
}
|
|
1670
|
+
/** One payout (`GET /api/partner-payouts/{payoutId}`). */
|
|
1671
|
+
async getPayout(payoutIdValue, opts) {
|
|
1672
|
+
const raw = await this.http.get(
|
|
1673
|
+
`/api/partner-payouts/${payoutId(payoutIdValue)}`,
|
|
1674
|
+
this.auth,
|
|
1675
|
+
{ signal: opts?.signal }
|
|
1676
|
+
);
|
|
1677
|
+
return raw["payout_request"];
|
|
1678
|
+
}
|
|
1679
|
+
/** Your payouts (`GET /api/partner-payouts`), optionally one creator's (`payeeId`). */
|
|
1680
|
+
async listPayouts(q = {}, opts) {
|
|
1681
|
+
const raw = await this.http.get(
|
|
1682
|
+
`/api/partner-payouts${query({ limit: q.limit, offset: q.offset, status: q.status, payee_id: q.payeeId })}`,
|
|
1683
|
+
this.auth,
|
|
1684
|
+
{ signal: opts?.signal }
|
|
1685
|
+
);
|
|
1686
|
+
return { total: Number(raw["total"] ?? 0), items: raw["items"] ?? [], raw };
|
|
1687
|
+
}
|
|
1688
|
+
/**
|
|
1689
|
+
* Cancel a creator payout that is still `requested`
|
|
1690
|
+
* (`POST /api/partner-payouts/{payoutId}/cancel`). Anything past `requested` is
|
|
1691
|
+
* `409 PAYOUT_NOT_CANCELLABLE`.
|
|
1692
|
+
*/
|
|
1693
|
+
async cancelPayout(payoutIdValue, opts) {
|
|
1694
|
+
const raw = await this.http.post(
|
|
1695
|
+
`/api/partner-payouts/${payoutId(payoutIdValue)}/cancel`,
|
|
1696
|
+
void 0,
|
|
1697
|
+
this.auth,
|
|
1698
|
+
{ signal: opts?.signal }
|
|
1699
|
+
);
|
|
1700
|
+
return raw["payout_request"] ?? raw["payout"];
|
|
1701
|
+
}
|
|
1702
|
+
};
|
|
1532
1703
|
|
|
1533
1704
|
// src/shared/types.ts
|
|
1534
1705
|
function isRefundPendingApproval(r) {
|
|
@@ -1796,7 +1967,7 @@ function pricingFields(raw, fallback = {}) {
|
|
|
1796
1967
|
if (warning !== void 0) out.minPurchaseWarning = warning;
|
|
1797
1968
|
return out;
|
|
1798
1969
|
}
|
|
1799
|
-
function
|
|
1970
|
+
function invalidInput2(label, value, why) {
|
|
1800
1971
|
return new InvoError({
|
|
1801
1972
|
message: `${label} ${why} (got ${JSON.stringify(value)}).`,
|
|
1802
1973
|
code: "INVALID_INPUT",
|
|
@@ -1808,17 +1979,17 @@ function parseMoney(value, max, label) {
|
|
|
1808
1979
|
let n;
|
|
1809
1980
|
if (typeof value === "number") {
|
|
1810
1981
|
if (!Number.isFinite(value) || !PLAIN_DECIMAL.test(String(value))) {
|
|
1811
|
-
throw
|
|
1982
|
+
throw invalidInput2(label, value, "must be a positive decimal with at most 2 places");
|
|
1812
1983
|
}
|
|
1813
1984
|
n = value;
|
|
1814
1985
|
} else {
|
|
1815
1986
|
if (!PLAIN_DECIMAL.test(value)) {
|
|
1816
|
-
throw
|
|
1987
|
+
throw invalidInput2(label, value, "must be a plain decimal value with at most 2 places");
|
|
1817
1988
|
}
|
|
1818
1989
|
n = Number(value);
|
|
1819
1990
|
}
|
|
1820
1991
|
if (!Number.isFinite(n) || n <= 0 || n > max) {
|
|
1821
|
-
throw
|
|
1992
|
+
throw invalidInput2(label, value, `must be > 0 and <= ${max}`);
|
|
1822
1993
|
}
|
|
1823
1994
|
return n;
|
|
1824
1995
|
}
|
|
@@ -1828,7 +1999,7 @@ function assertUsdAmount(usdAmount) {
|
|
|
1828
1999
|
var E164 = /^\+[1-9]\d{1,14}$/;
|
|
1829
2000
|
function assertE164(value, label) {
|
|
1830
2001
|
if (typeof value !== "string" || !E164.test(value)) {
|
|
1831
|
-
throw
|
|
2002
|
+
throw invalidInput2(label, value, 'must be an E.164 phone number, e.g. "+15555550100"');
|
|
1832
2003
|
}
|
|
1833
2004
|
}
|
|
1834
2005
|
function sessionTokenFromCreateCheckout(raw, checkoutUrl) {
|
|
@@ -1917,13 +2088,13 @@ function toTransactionStatus(raw) {
|
|
|
1917
2088
|
function assertPageLimit(limit) {
|
|
1918
2089
|
if (limit === void 0) return;
|
|
1919
2090
|
if (typeof limit !== "number" || !Number.isInteger(limit) || limit < 1) {
|
|
1920
|
-
throw
|
|
2091
|
+
throw invalidInput2("limit", limit, "must be a positive integer (INVO caps it at 100)");
|
|
1921
2092
|
}
|
|
1922
2093
|
}
|
|
1923
2094
|
function assertCursor(cursor) {
|
|
1924
2095
|
if (cursor === void 0) return;
|
|
1925
2096
|
if (typeof cursor !== "string" || !cursor.trim()) {
|
|
1926
|
-
throw
|
|
2097
|
+
throw invalidInput2("cursor", cursor, "must be the previous page's nextCursor");
|
|
1927
2098
|
}
|
|
1928
2099
|
}
|
|
1929
2100
|
function strOrNull3(v) {
|
|
@@ -2060,12 +2231,12 @@ function isPastThisStep(flow, currentStatus) {
|
|
|
2060
2231
|
}
|
|
2061
2232
|
function assertPlayerToken(playerToken) {
|
|
2062
2233
|
if (typeof playerToken !== "string" || !playerToken.trim()) {
|
|
2063
|
-
throw
|
|
2234
|
+
throw invalidInput2("playerToken", playerToken, "is required (the player's session token, not the game secret)");
|
|
2064
2235
|
}
|
|
2065
2236
|
}
|
|
2066
2237
|
function assertDeviceApprovalFlow(flow) {
|
|
2067
2238
|
if (typeof flow !== "string" || !DEVICE_APPROVAL_FLOWS.has(flow)) {
|
|
2068
|
-
throw
|
|
2239
|
+
throw invalidInput2("flow", flow, 'must be "transfer" | "send" | "send_receipt" | "transfer_receipt"');
|
|
2069
2240
|
}
|
|
2070
2241
|
}
|
|
2071
2242
|
function toDeviceApprovalGrant(raw) {
|
|
@@ -2205,20 +2376,20 @@ var PlatformCommerceServer = class {
|
|
|
2205
2376
|
["itemName", input.itemName]
|
|
2206
2377
|
];
|
|
2207
2378
|
for (const [k, v] of required) {
|
|
2208
|
-
if (typeof v !== "string" || !v.trim()) throw
|
|
2379
|
+
if (typeof v !== "string" || !v.trim()) throw invalidInput2(k, v, "is required");
|
|
2209
2380
|
}
|
|
2210
2381
|
if (!FUNDING_SOURCES.has(input.fundingSource)) {
|
|
2211
|
-
throw
|
|
2382
|
+
throw invalidInput2("fundingSource", input.fundingSource, 'must be "balance" or "card"');
|
|
2212
2383
|
}
|
|
2213
2384
|
if (!Number.isInteger(input.itemQuantity) || input.itemQuantity < 1 || input.itemQuantity > 1e3) {
|
|
2214
|
-
throw
|
|
2385
|
+
throw invalidInput2("itemQuantity", input.itemQuantity, "must be an integer 1..1000");
|
|
2215
2386
|
}
|
|
2216
2387
|
const unit = parseMoney(input.unitPrice, MAX_ITEM_PRICE, "unitPrice");
|
|
2217
2388
|
const total = parseMoney(input.totalPrice, MAX_ITEM_PRICE, "totalPrice");
|
|
2218
2389
|
const expectedCents = Math.round(unit * input.itemQuantity * 100);
|
|
2219
2390
|
const totalCents = Math.round(total * 100);
|
|
2220
2391
|
if (Math.abs(totalCents - expectedCents) > 1) {
|
|
2221
|
-
throw
|
|
2392
|
+
throw invalidInput2(
|
|
2222
2393
|
"totalPrice",
|
|
2223
2394
|
input.totalPrice,
|
|
2224
2395
|
`must equal unitPrice \xD7 itemQuantity (\xB10.01): ${unit} \xD7 ${input.itemQuantity}`
|
|
@@ -2289,7 +2460,7 @@ var PlatformCommerceServer = class {
|
|
|
2289
2460
|
* `pending_payment` (card awaiting confirmation), or `refunded`. */
|
|
2290
2461
|
async getStatus(orderId, opts) {
|
|
2291
2462
|
if (orderId == null || String(orderId).trim() === "") {
|
|
2292
|
-
throw
|
|
2463
|
+
throw invalidInput2("orderId", orderId, "is required");
|
|
2293
2464
|
}
|
|
2294
2465
|
const raw = await this.http.get(
|
|
2295
2466
|
`/api/platform-commerce/purchase-status/${encodeURIComponent(String(orderId))}`,
|
|
@@ -2312,16 +2483,16 @@ var PlatformCommerceServer = class {
|
|
|
2312
2483
|
* tenant (`err.isNotPlatformTenant`), `429` (back off; `err.retryAfter`). A GET, so
|
|
2313
2484
|
* transient failures are retried automatically.
|
|
2314
2485
|
*/
|
|
2315
|
-
async getPurchaseHistory(
|
|
2316
|
-
if (typeof
|
|
2317
|
-
throw
|
|
2486
|
+
async getPurchaseHistory(query2, opts) {
|
|
2487
|
+
if (typeof query2?.playerEmail !== "string" || !query2.playerEmail.trim()) {
|
|
2488
|
+
throw invalidInput2("playerEmail", query2?.playerEmail, "is required");
|
|
2318
2489
|
}
|
|
2319
|
-
assertPageLimit(
|
|
2320
|
-
assertCursor(
|
|
2490
|
+
assertPageLimit(query2.limit);
|
|
2491
|
+
assertCursor(query2.cursor);
|
|
2321
2492
|
const q = new URLSearchParams();
|
|
2322
|
-
q.set("player_email",
|
|
2323
|
-
if (
|
|
2324
|
-
if (
|
|
2493
|
+
q.set("player_email", query2.playerEmail.trim());
|
|
2494
|
+
if (query2.limit !== void 0) q.set("limit", String(query2.limit));
|
|
2495
|
+
if (query2.cursor !== void 0) q.set("cursor", query2.cursor);
|
|
2325
2496
|
const raw = await this.http.get(
|
|
2326
2497
|
`/api/platform-commerce/purchase-history?${q.toString()}`,
|
|
2327
2498
|
this.auth,
|
|
@@ -2330,7 +2501,7 @@ var PlatformCommerceServer = class {
|
|
|
2330
2501
|
const purchases = Array.isArray(raw["purchases"]) ? raw["purchases"].map((r) => toPlatformOrderStatus(r)) : [];
|
|
2331
2502
|
const nextCursor = nextCursorOf(raw);
|
|
2332
2503
|
return {
|
|
2333
|
-
playerEmail: String(raw["player_email"] ??
|
|
2504
|
+
playerEmail: String(raw["player_email"] ?? query2.playerEmail.trim()),
|
|
2334
2505
|
gameId: String(raw["game_id"] ?? ""),
|
|
2335
2506
|
purchases,
|
|
2336
2507
|
limit: typeof raw["limit"] === "number" ? raw["limit"] : purchases.length,
|
|
@@ -2347,12 +2518,12 @@ var PlatformCommerceServer = class {
|
|
|
2347
2518
|
* for await (const order of invo.platformCommerce.iteratePurchaseHistory({ playerEmail })) { … }
|
|
2348
2519
|
* ```
|
|
2349
2520
|
*/
|
|
2350
|
-
async *iteratePurchaseHistory(
|
|
2521
|
+
async *iteratePurchaseHistory(query2, opts) {
|
|
2351
2522
|
let cursor;
|
|
2352
2523
|
const seen = /* @__PURE__ */ new Set();
|
|
2353
2524
|
for (; ; ) {
|
|
2354
2525
|
const page = await this.getPurchaseHistory(
|
|
2355
|
-
{ playerEmail:
|
|
2526
|
+
{ playerEmail: query2.playerEmail, limit: query2.pageSize, cursor },
|
|
2356
2527
|
opts
|
|
2357
2528
|
);
|
|
2358
2529
|
for (const row of page.purchases) yield row;
|
|
@@ -2429,13 +2600,13 @@ var SANDBOX_FAILURE_OUTCOMES = /* @__PURE__ */ new Set([
|
|
|
2429
2600
|
"error"
|
|
2430
2601
|
]);
|
|
2431
2602
|
function assertClientRequestId(value, label) {
|
|
2432
|
-
if (typeof value !== "string" || !value.trim()) throw
|
|
2433
|
-
if (value.length > 255) throw
|
|
2434
|
-
if (/^sub_/i.test(value)) throw
|
|
2603
|
+
if (typeof value !== "string" || !value.trim()) throw invalidInput2(label, value, "is required");
|
|
2604
|
+
if (value.length > 255) throw invalidInput2(label, value, "must be at most 255 characters");
|
|
2605
|
+
if (/^sub_/i.test(value)) throw invalidInput2(label, value, 'must not begin with "sub_" (reserved)');
|
|
2435
2606
|
}
|
|
2436
2607
|
function assertSubscriptionId(value) {
|
|
2437
2608
|
if (typeof value !== "string" || !value.trim()) {
|
|
2438
|
-
throw
|
|
2609
|
+
throw invalidInput2("subscriptionId", value, "is required");
|
|
2439
2610
|
}
|
|
2440
2611
|
}
|
|
2441
2612
|
function subscriptionMoney(value, label) {
|
|
@@ -2687,10 +2858,10 @@ function subscriptionBaseBody(input) {
|
|
|
2687
2858
|
["playerName", input.playerName],
|
|
2688
2859
|
["itemId", input.itemId]
|
|
2689
2860
|
]) {
|
|
2690
|
-
if (typeof v !== "string" || !v.trim()) throw
|
|
2861
|
+
if (typeof v !== "string" || !v.trim()) throw invalidInput2(k, v, "is required");
|
|
2691
2862
|
}
|
|
2692
2863
|
if (input.interval !== void 0 && !SUBSCRIPTION_INTERVALS.has(input.interval)) {
|
|
2693
|
-
throw
|
|
2864
|
+
throw invalidInput2("interval", input.interval, 'must be "month" or "year"');
|
|
2694
2865
|
}
|
|
2695
2866
|
if (input.playerPhone !== void 0) assertE164(input.playerPhone, "playerPhone");
|
|
2696
2867
|
const body = {
|
|
@@ -2723,7 +2894,7 @@ function subscriptionBaseBody(input) {
|
|
|
2723
2894
|
const hasEmail = typeof s.recipientPlayerEmail === "string" && s.recipientPlayerEmail.trim() !== "";
|
|
2724
2895
|
const hasId = s.recipientPlayerId != null;
|
|
2725
2896
|
if (hasEmail === hasId) {
|
|
2726
|
-
throw
|
|
2897
|
+
throw invalidInput2(
|
|
2727
2898
|
"revenueShare",
|
|
2728
2899
|
s,
|
|
2729
2900
|
"requires EXACTLY ONE of recipientPlayerEmail or recipientPlayerId"
|
|
@@ -2781,19 +2952,19 @@ var SubscriptionsServer = class {
|
|
|
2781
2952
|
const body = subscriptionBaseBody(input);
|
|
2782
2953
|
if (input.intervalCount !== void 0) {
|
|
2783
2954
|
if (!Number.isInteger(input.intervalCount) || input.intervalCount < 1 || input.intervalCount > 36) {
|
|
2784
|
-
throw
|
|
2955
|
+
throw invalidInput2("intervalCount", input.intervalCount, "must be an integer 1..36");
|
|
2785
2956
|
}
|
|
2786
2957
|
body["interval_count"] = input.intervalCount;
|
|
2787
2958
|
}
|
|
2788
2959
|
if (input.trialDays !== void 0) {
|
|
2789
2960
|
if (!Number.isInteger(input.trialDays) || input.trialDays < 1 || input.trialDays > 365) {
|
|
2790
|
-
throw
|
|
2961
|
+
throw invalidInput2("trialDays", input.trialDays, "must be an integer 1..365");
|
|
2791
2962
|
}
|
|
2792
2963
|
body["trial_days"] = input.trialDays;
|
|
2793
2964
|
}
|
|
2794
2965
|
if (input.trialEnd !== void 0) {
|
|
2795
2966
|
if (typeof input.trialEnd !== "string" || Number.isNaN(Date.parse(input.trialEnd))) {
|
|
2796
|
-
throw
|
|
2967
|
+
throw invalidInput2("trialEnd", input.trialEnd, "must be an ISO 8601 timestamp");
|
|
2797
2968
|
}
|
|
2798
2969
|
body["trial_end"] = input.trialEnd;
|
|
2799
2970
|
}
|
|
@@ -2816,16 +2987,16 @@ var SubscriptionsServer = class {
|
|
|
2816
2987
|
}
|
|
2817
2988
|
if (input.walletOnly !== void 0) {
|
|
2818
2989
|
if (typeof input.walletOnly !== "boolean") {
|
|
2819
|
-
throw
|
|
2990
|
+
throw invalidInput2("walletOnly", input.walletOnly, "must be a boolean");
|
|
2820
2991
|
}
|
|
2821
2992
|
body["wallet_only"] = input.walletOnly;
|
|
2822
2993
|
}
|
|
2823
2994
|
if (input.playerCardId !== void 0) {
|
|
2824
2995
|
if (!Number.isInteger(input.playerCardId) || input.playerCardId < 1) {
|
|
2825
|
-
throw
|
|
2996
|
+
throw invalidInput2("playerCardId", input.playerCardId, "must be a positive integer card id (from cards.list)");
|
|
2826
2997
|
}
|
|
2827
2998
|
if (input.walletOnly === true) {
|
|
2828
|
-
throw
|
|
2999
|
+
throw invalidInput2("playerCardId", input.playerCardId, "cannot be combined with walletOnly: true");
|
|
2829
3000
|
}
|
|
2830
3001
|
body["player_card_id"] = input.playerCardId;
|
|
2831
3002
|
}
|
|
@@ -2861,7 +3032,7 @@ var SubscriptionsServer = class {
|
|
|
2861
3032
|
*/
|
|
2862
3033
|
async listForPlayer(playerEmail, options, opts) {
|
|
2863
3034
|
if (typeof playerEmail !== "string" || !playerEmail.trim()) {
|
|
2864
|
-
throw
|
|
3035
|
+
throw invalidInput2("playerEmail", playerEmail, "is required");
|
|
2865
3036
|
}
|
|
2866
3037
|
const q = new URLSearchParams();
|
|
2867
3038
|
q.set("player_email", playerEmail);
|
|
@@ -2872,13 +3043,13 @@ var SubscriptionsServer = class {
|
|
|
2872
3043
|
if (options?.includePlayer) q.set("include_player", "true");
|
|
2873
3044
|
if (options?.limit != null) {
|
|
2874
3045
|
if (!Number.isInteger(options.limit) || options.limit < 1 || options.limit > 100) {
|
|
2875
|
-
throw
|
|
3046
|
+
throw invalidInput2("limit", options.limit, "must be an integer 1..100");
|
|
2876
3047
|
}
|
|
2877
3048
|
q.set("limit", String(options.limit));
|
|
2878
3049
|
}
|
|
2879
3050
|
if (options?.offset != null) {
|
|
2880
3051
|
if (!Number.isInteger(options.offset) || options.offset < 0 || options.offset > 1e5) {
|
|
2881
|
-
throw
|
|
3052
|
+
throw invalidInput2("offset", options.offset, "must be an integer 0..100000");
|
|
2882
3053
|
}
|
|
2883
3054
|
q.set("offset", String(options.offset));
|
|
2884
3055
|
}
|
|
@@ -2918,13 +3089,13 @@ var SubscriptionsServer = class {
|
|
|
2918
3089
|
const body = {};
|
|
2919
3090
|
if (options?.atPeriodEnd !== void 0) {
|
|
2920
3091
|
if (typeof options.atPeriodEnd !== "boolean") {
|
|
2921
|
-
throw
|
|
3092
|
+
throw invalidInput2("atPeriodEnd", options.atPeriodEnd, "must be a boolean");
|
|
2922
3093
|
}
|
|
2923
3094
|
body["at_period_end"] = options.atPeriodEnd;
|
|
2924
3095
|
}
|
|
2925
3096
|
if (options?.reason !== void 0) {
|
|
2926
3097
|
if (typeof options.reason !== "string" || options.reason.length > 500) {
|
|
2927
|
-
throw
|
|
3098
|
+
throw invalidInput2("reason", options.reason, "must be a string of at most 500 characters");
|
|
2928
3099
|
}
|
|
2929
3100
|
body["reason"] = options.reason;
|
|
2930
3101
|
}
|
|
@@ -3003,14 +3174,14 @@ var SubscriptionsServer = class {
|
|
|
3003
3174
|
const body = {};
|
|
3004
3175
|
if ("playerCardId" in input && input.playerCardId !== void 0) {
|
|
3005
3176
|
if (!Number.isInteger(input.playerCardId) || input.playerCardId < 1) {
|
|
3006
|
-
throw
|
|
3177
|
+
throw invalidInput2("playerCardId", input.playerCardId, "must be a positive integer card id (from cards.list)");
|
|
3007
3178
|
}
|
|
3008
3179
|
body["player_card_id"] = input.playerCardId;
|
|
3009
3180
|
if (input.walletOnly !== void 0) body["wallet_only"] = input.walletOnly;
|
|
3010
3181
|
} else if (input.walletOnly === true) {
|
|
3011
3182
|
body["wallet_only"] = true;
|
|
3012
3183
|
} else {
|
|
3013
|
-
throw
|
|
3184
|
+
throw invalidInput2("input", input, "requires { playerCardId } or { walletOnly: true }");
|
|
3014
3185
|
}
|
|
3015
3186
|
const raw = await this.http.post(
|
|
3016
3187
|
`/api/subscriptions/${encodeURIComponent(subscriptionId)}/payment-method`,
|
|
@@ -3071,14 +3242,14 @@ var SubscriptionsServer = class {
|
|
|
3071
3242
|
const body = { client_request_id: input.clientRequestId };
|
|
3072
3243
|
if (input.periodSeq !== void 0) {
|
|
3073
3244
|
if (!Number.isInteger(input.periodSeq) || input.periodSeq < 1) {
|
|
3074
|
-
throw
|
|
3245
|
+
throw invalidInput2("periodSeq", input.periodSeq, "must be an integer >= 1");
|
|
3075
3246
|
}
|
|
3076
3247
|
body["period_seq"] = input.periodSeq;
|
|
3077
3248
|
}
|
|
3078
3249
|
if (input.amountUsd !== void 0) body["amount_usd"] = subscriptionMoney(input.amountUsd, "amountUsd");
|
|
3079
3250
|
if (input.reason !== void 0) {
|
|
3080
3251
|
if (typeof input.reason !== "string" || input.reason.length > 500) {
|
|
3081
|
-
throw
|
|
3252
|
+
throw invalidInput2("reason", input.reason, "must be a string of at most 500 characters");
|
|
3082
3253
|
}
|
|
3083
3254
|
body["reason"] = input.reason;
|
|
3084
3255
|
}
|
|
@@ -3120,10 +3291,10 @@ var SubscriptionsServer = class {
|
|
|
3120
3291
|
async steamInit(input, opts) {
|
|
3121
3292
|
const body = subscriptionBaseBody(input);
|
|
3122
3293
|
if (!/^[0-9]+$/.test(String(input.steamId ?? ""))) {
|
|
3123
|
-
throw
|
|
3294
|
+
throw invalidInput2("steamId", input.steamId, "must be the member's numeric 64-bit Steam id");
|
|
3124
3295
|
}
|
|
3125
3296
|
if (input.userSession !== void 0 && input.userSession !== "client" && input.userSession !== "web") {
|
|
3126
|
-
throw
|
|
3297
|
+
throw invalidInput2("userSession", input.userSession, 'must be "client" or "web"');
|
|
3127
3298
|
}
|
|
3128
3299
|
if (input.userSession === "web" && !input.playerIp) {
|
|
3129
3300
|
throw new InvoError({
|
|
@@ -3133,7 +3304,7 @@ var SubscriptionsServer = class {
|
|
|
3133
3304
|
});
|
|
3134
3305
|
}
|
|
3135
3306
|
if (input.intervalCount !== void 0 && input.intervalCount !== 1) {
|
|
3136
|
-
throw
|
|
3307
|
+
throw invalidInput2("intervalCount", input.intervalCount, "must be 1 on the Steam rail (monthly and yearly only)");
|
|
3137
3308
|
}
|
|
3138
3309
|
const forbidden = input;
|
|
3139
3310
|
if (forbidden["trialAmountUsd"] !== void 0) {
|
|
@@ -3145,7 +3316,7 @@ var SubscriptionsServer = class {
|
|
|
3145
3316
|
}
|
|
3146
3317
|
for (const k of ["trialDays", "trialEnd", "walletOnly", "playerCardId"]) {
|
|
3147
3318
|
if (forbidden[k] !== void 0) {
|
|
3148
|
-
throw
|
|
3319
|
+
throw invalidInput2(k, forbidden[k], "is not available on the Steam rail");
|
|
3149
3320
|
}
|
|
3150
3321
|
}
|
|
3151
3322
|
body["steamid"] = String(input.steamId);
|
|
@@ -3258,24 +3429,24 @@ var CardsServer = class {
|
|
|
3258
3429
|
*/
|
|
3259
3430
|
async createSetupSession(input, opts) {
|
|
3260
3431
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
3261
|
-
throw
|
|
3432
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
3262
3433
|
}
|
|
3263
3434
|
for (const [label, value] of [
|
|
3264
3435
|
["successUrl", input.successUrl],
|
|
3265
3436
|
["cancelUrl", input.cancelUrl]
|
|
3266
3437
|
]) {
|
|
3267
3438
|
if (value === void 0) continue;
|
|
3268
|
-
if (typeof value !== "string" || !value.trim()) throw
|
|
3269
|
-
if (SCRIPT_SCHEME.test(value)) throw
|
|
3439
|
+
if (typeof value !== "string" || !value.trim()) throw invalidInput2(label, value, "must be a non-empty URL");
|
|
3440
|
+
if (SCRIPT_SCHEME.test(value)) throw invalidInput2(label, value, "must not use a script scheme");
|
|
3270
3441
|
}
|
|
3271
3442
|
if (input.metadata !== void 0 && (input.metadata === null || typeof input.metadata !== "object" || Array.isArray(input.metadata))) {
|
|
3272
|
-
throw
|
|
3443
|
+
throw invalidInput2("metadata", input.metadata, "must be a plain object");
|
|
3273
3444
|
}
|
|
3274
3445
|
if (input.playerName !== void 0) {
|
|
3275
3446
|
if (typeof input.playerName !== "string" || !input.playerName.trim()) {
|
|
3276
|
-
throw
|
|
3447
|
+
throw invalidInput2("playerName", input.playerName, "must be a non-empty string");
|
|
3277
3448
|
}
|
|
3278
|
-
if (input.playerName.trim().length > 255) throw
|
|
3449
|
+
if (input.playerName.trim().length > 255) throw invalidInput2("playerName", input.playerName, "must be at most 255 characters");
|
|
3279
3450
|
}
|
|
3280
3451
|
if (input.playerPhone !== void 0) assertE164(input.playerPhone, "playerPhone");
|
|
3281
3452
|
const body = { player_email: input.playerEmail };
|
|
@@ -3320,10 +3491,10 @@ var CardsServer = class {
|
|
|
3320
3491
|
*/
|
|
3321
3492
|
async beginSetup(input, opts) {
|
|
3322
3493
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
3323
|
-
throw
|
|
3494
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
3324
3495
|
}
|
|
3325
3496
|
if (typeof input.setupReference !== "string" || !/^[A-Za-z0-9._:-]{1,200}$/.test(input.setupReference)) {
|
|
3326
|
-
throw
|
|
3497
|
+
throw invalidInput2("setupReference", input.setupReference, "must be 1-200 characters of A-Z a-z 0-9 . _ : -");
|
|
3327
3498
|
}
|
|
3328
3499
|
const body = {
|
|
3329
3500
|
player_email: input.playerEmail,
|
|
@@ -3359,7 +3530,7 @@ var CardsServer = class {
|
|
|
3359
3530
|
*/
|
|
3360
3531
|
async confirmSetup(input, opts) {
|
|
3361
3532
|
if (typeof input.setupIntentId !== "string" || !input.setupIntentId.trim()) {
|
|
3362
|
-
throw
|
|
3533
|
+
throw invalidInput2("setupIntentId", input.setupIntentId, "is required (from beginSetup)");
|
|
3363
3534
|
}
|
|
3364
3535
|
const raw = await this.http.post(
|
|
3365
3536
|
"/api/currency-purchases/setup-intent/confirm",
|
|
@@ -3385,7 +3556,7 @@ var CardsServer = class {
|
|
|
3385
3556
|
*/
|
|
3386
3557
|
async list(playerEmail, opts) {
|
|
3387
3558
|
if (typeof playerEmail !== "string" || !playerEmail.trim()) {
|
|
3388
|
-
throw
|
|
3559
|
+
throw invalidInput2("playerEmail", playerEmail, "is required");
|
|
3389
3560
|
}
|
|
3390
3561
|
const raw = await this.http.get(
|
|
3391
3562
|
`/api/currency-purchases/player-cards?player_email=${encodeURIComponent(playerEmail)}`,
|
|
@@ -3408,7 +3579,7 @@ var SandboxSubscriptionsServer = class {
|
|
|
3408
3579
|
async call(subscriptionId, tool, body, opts) {
|
|
3409
3580
|
assertSubscriptionId(subscriptionId);
|
|
3410
3581
|
if (typeof this.clockKey !== "string" || !this.clockKey.trim()) {
|
|
3411
|
-
throw
|
|
3582
|
+
throw invalidInput2(
|
|
3412
3583
|
"sandboxClockKey",
|
|
3413
3584
|
this.clockKey,
|
|
3414
3585
|
'is required for invo.sandbox.subscriptions.* \u2014 pass it to new InvoServer({ sandboxClockKey }) from the sandbox console (Game Settings, "Sandbox clock key")'
|
|
@@ -3434,7 +3605,7 @@ var SandboxSubscriptionsServer = class {
|
|
|
3434
3605
|
*/
|
|
3435
3606
|
async advanceClock(subscriptionId, intervals = 1, opts) {
|
|
3436
3607
|
if (!Number.isInteger(intervals) || intervals < 0 || intervals > 60) {
|
|
3437
|
-
throw
|
|
3608
|
+
throw invalidInput2("intervals", intervals, "must be an integer 0..60");
|
|
3438
3609
|
}
|
|
3439
3610
|
return this.call(subscriptionId, "advance-clock", { intervals }, opts);
|
|
3440
3611
|
}
|
|
@@ -3457,7 +3628,7 @@ var SandboxSubscriptionsServer = class {
|
|
|
3457
3628
|
*/
|
|
3458
3629
|
async forceFailure(subscriptionId, outcome = "card_declined", options, opts) {
|
|
3459
3630
|
if (!SANDBOX_FAILURE_OUTCOMES.has(outcome)) {
|
|
3460
|
-
throw
|
|
3631
|
+
throw invalidInput2("outcome", outcome, 'must be "card_declined" | "insufficient_funds" | "error"');
|
|
3461
3632
|
}
|
|
3462
3633
|
const body = { outcome };
|
|
3463
3634
|
if (options?.failureCode !== void 0) body["failure_code"] = options.failureCode;
|
|
@@ -3502,6 +3673,7 @@ var InvoServer = class {
|
|
|
3502
3673
|
this.subscriptions = new SubscriptionsServer(this.http, this.auth);
|
|
3503
3674
|
this.cards = new CardsServer(this.http, this.auth);
|
|
3504
3675
|
this.sandbox = new SandboxServer(this.http, this.auth, config.sandboxClockKey);
|
|
3676
|
+
this.payouts = new PayoutsServer(this.http, this.auth);
|
|
3505
3677
|
}
|
|
3506
3678
|
/**
|
|
3507
3679
|
* Mint a short-lived, game-scoped player token to hand to the browser InvoClient.
|
|
@@ -3522,7 +3694,7 @@ var InvoServer = class {
|
|
|
3522
3694
|
*/
|
|
3523
3695
|
async mintPlayerToken(input, opts) {
|
|
3524
3696
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
3525
|
-
throw
|
|
3697
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
3526
3698
|
}
|
|
3527
3699
|
const body = { player_email: input.playerEmail };
|
|
3528
3700
|
if (input.playerPhone !== void 0) {
|
|
@@ -3531,7 +3703,7 @@ var InvoServer = class {
|
|
|
3531
3703
|
}
|
|
3532
3704
|
if (input.playerName !== void 0) {
|
|
3533
3705
|
if (typeof input.playerName !== "string") {
|
|
3534
|
-
throw
|
|
3706
|
+
throw invalidInput2("playerName", input.playerName, "must be a string");
|
|
3535
3707
|
}
|
|
3536
3708
|
body["player_name"] = input.playerName;
|
|
3537
3709
|
}
|
|
@@ -3564,7 +3736,7 @@ var InvoServer = class {
|
|
|
3564
3736
|
*/
|
|
3565
3737
|
async registerPlayer(input, opts) {
|
|
3566
3738
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
3567
|
-
throw
|
|
3739
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
3568
3740
|
}
|
|
3569
3741
|
assertE164(input.playerPhone, "playerPhone");
|
|
3570
3742
|
const body = {
|
|
@@ -3573,7 +3745,7 @@ var InvoServer = class {
|
|
|
3573
3745
|
};
|
|
3574
3746
|
if (input.playerName !== void 0) {
|
|
3575
3747
|
if (typeof input.playerName !== "string") {
|
|
3576
|
-
throw
|
|
3748
|
+
throw invalidInput2("playerName", input.playerName, "must be a string");
|
|
3577
3749
|
}
|
|
3578
3750
|
body["player_name"] = input.playerName;
|
|
3579
3751
|
}
|
|
@@ -3611,7 +3783,7 @@ var InvoServer = class {
|
|
|
3611
3783
|
*/
|
|
3612
3784
|
async updatePlayerPhone(input, opts) {
|
|
3613
3785
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
3614
|
-
throw
|
|
3786
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
3615
3787
|
}
|
|
3616
3788
|
assertE164(input.newPhone, "newPhone");
|
|
3617
3789
|
const raw = await this.http.post(
|
|
@@ -3655,7 +3827,7 @@ var InvoServer = class {
|
|
|
3655
3827
|
*/
|
|
3656
3828
|
async requestPhoneChange(input, opts) {
|
|
3657
3829
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
3658
|
-
throw
|
|
3830
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
3659
3831
|
}
|
|
3660
3832
|
assertE164(input.newPhone, "newPhone");
|
|
3661
3833
|
const raw = await this.http.post(
|
|
@@ -3675,7 +3847,7 @@ var InvoServer = class {
|
|
|
3675
3847
|
*/
|
|
3676
3848
|
async getPhoneChange(changeRequestId, opts) {
|
|
3677
3849
|
if (typeof changeRequestId !== "string" || !changeRequestId.trim()) {
|
|
3678
|
-
throw
|
|
3850
|
+
throw invalidInput2("changeRequestId", changeRequestId, "is required");
|
|
3679
3851
|
}
|
|
3680
3852
|
const raw = await this.http.get(
|
|
3681
3853
|
`/api/sdk/players/phone/change-requests/${encodeURIComponent(changeRequestId)}`,
|
|
@@ -3739,7 +3911,7 @@ var InvoServer = class {
|
|
|
3739
3911
|
* purchase.completed webhook. */
|
|
3740
3912
|
async createCheckout(input, opts) {
|
|
3741
3913
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
3742
|
-
throw
|
|
3914
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
3743
3915
|
}
|
|
3744
3916
|
assertUsdAmount(input.usdAmount);
|
|
3745
3917
|
const body = {
|
|
@@ -3803,7 +3975,7 @@ var InvoServer = class {
|
|
|
3803
3975
|
*/
|
|
3804
3976
|
async purchaseCurrency(input, opts) {
|
|
3805
3977
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
3806
|
-
throw
|
|
3978
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
3807
3979
|
}
|
|
3808
3980
|
assertUsdAmount(input.usdAmount);
|
|
3809
3981
|
if (!input.purchaseReference) {
|
|
@@ -3922,8 +4094,8 @@ var InvoServer = class {
|
|
|
3922
4094
|
};
|
|
3923
4095
|
}
|
|
3924
4096
|
/** Fetch purchase status (order + financial summary + timeline). */
|
|
3925
|
-
async getOrderDetails(
|
|
3926
|
-
if (!
|
|
4097
|
+
async getOrderDetails(query2, opts) {
|
|
4098
|
+
if (!query2.orderId && !query2.transactionId) {
|
|
3927
4099
|
throw new InvoError({
|
|
3928
4100
|
message: "getOrderDetails requires an `orderId` or `transactionId`.",
|
|
3929
4101
|
code: "INVALID_INPUT",
|
|
@@ -3931,8 +4103,8 @@ var InvoServer = class {
|
|
|
3931
4103
|
});
|
|
3932
4104
|
}
|
|
3933
4105
|
const q = new URLSearchParams();
|
|
3934
|
-
if (
|
|
3935
|
-
if (
|
|
4106
|
+
if (query2.orderId) q.set("order_id", query2.orderId);
|
|
4107
|
+
if (query2.transactionId) q.set("transaction_id", query2.transactionId);
|
|
3936
4108
|
const raw = await this.http.get(
|
|
3937
4109
|
`/api/currency-purchases/order-details?${q.toString()}`,
|
|
3938
4110
|
this.auth,
|
|
@@ -3955,8 +4127,8 @@ var InvoServer = class {
|
|
|
3955
4127
|
* no-VAT catalogue and lets the PURCHASE be what refuses; the only 503 is
|
|
3956
4128
|
* the rail being disabled platform-wide, whose body carries no error code.
|
|
3957
4129
|
*/
|
|
3958
|
-
async steamPacks(
|
|
3959
|
-
const qs =
|
|
4130
|
+
async steamPacks(query2, opts) {
|
|
4131
|
+
const qs = query2?.steamid ? `?steamid=${encodeURIComponent(query2.steamid)}` : "";
|
|
3960
4132
|
const raw = await this.http.get(
|
|
3961
4133
|
`/api/currency-purchases/steam/packs${qs}`,
|
|
3962
4134
|
this.auth,
|
|
@@ -4001,12 +4173,12 @@ var InvoServer = class {
|
|
|
4001
4173
|
*/
|
|
4002
4174
|
async steamInitPurchase(input, opts) {
|
|
4003
4175
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
4004
|
-
throw
|
|
4176
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
4005
4177
|
}
|
|
4006
4178
|
if (!/^[0-9]+$/.test(String(input.steamid ?? ""))) {
|
|
4007
|
-
throw
|
|
4179
|
+
throw invalidInput2("steamid", input.steamid, "must be the player's numeric 64-bit Steam id");
|
|
4008
4180
|
}
|
|
4009
|
-
if (!input.packId) throw
|
|
4181
|
+
if (!input.packId) throw invalidInput2("packId", input.packId, "is required \u2014 fetch steamPacks()");
|
|
4010
4182
|
if (!input.purchaseReference) {
|
|
4011
4183
|
throw new InvoError({
|
|
4012
4184
|
message: "purchaseReference is required (idempotency key, unique per intended purchase).",
|
|
@@ -4067,7 +4239,7 @@ var InvoServer = class {
|
|
|
4067
4239
|
* detects the authorized transaction and credits, on a delay.
|
|
4068
4240
|
*/
|
|
4069
4241
|
async steamFinalizePurchase(input, opts) {
|
|
4070
|
-
if (!input.orderId) throw
|
|
4242
|
+
if (!input.orderId) throw invalidInput2("orderId", input.orderId, "is required (from steamInitPurchase)");
|
|
4071
4243
|
const raw = await this.http.post(
|
|
4072
4244
|
"/api/currency-purchases/steam/finalize-purchase",
|
|
4073
4245
|
{ order_id: input.orderId },
|
|
@@ -4102,17 +4274,17 @@ var InvoServer = class {
|
|
|
4102
4274
|
["itemName", input.itemName]
|
|
4103
4275
|
];
|
|
4104
4276
|
for (const [k, v] of required) {
|
|
4105
|
-
if (typeof v !== "string" || !v.trim()) throw
|
|
4277
|
+
if (typeof v !== "string" || !v.trim()) throw invalidInput2(k, v, "is required");
|
|
4106
4278
|
}
|
|
4107
4279
|
if (!Number.isInteger(input.itemQuantity) || input.itemQuantity < 1 || input.itemQuantity > 1e3) {
|
|
4108
|
-
throw
|
|
4280
|
+
throw invalidInput2("itemQuantity", input.itemQuantity, "must be an integer 1..1000");
|
|
4109
4281
|
}
|
|
4110
4282
|
const unit = parseMoney(input.unitPrice, MAX_ITEM_PRICE, "unitPrice");
|
|
4111
4283
|
const total = parseMoney(input.totalPrice, MAX_ITEM_PRICE, "totalPrice");
|
|
4112
4284
|
const expectedCents = Math.round(unit * input.itemQuantity * 100);
|
|
4113
4285
|
const totalCents = Math.round(total * 100);
|
|
4114
4286
|
if (Math.abs(totalCents - expectedCents) > 1) {
|
|
4115
|
-
throw
|
|
4287
|
+
throw invalidInput2(
|
|
4116
4288
|
"totalPrice",
|
|
4117
4289
|
input.totalPrice,
|
|
4118
4290
|
`must equal unitPrice \xD7 itemQuantity (\xB10.01): ${unit} \xD7 ${input.itemQuantity}`
|
|
@@ -4150,14 +4322,14 @@ var InvoServer = class {
|
|
|
4150
4322
|
};
|
|
4151
4323
|
}
|
|
4152
4324
|
/** Paginated item-purchase history for a player (§4.8 companion read). */
|
|
4153
|
-
async getItemPurchaseHistory(
|
|
4154
|
-
if (typeof
|
|
4155
|
-
throw
|
|
4325
|
+
async getItemPurchaseHistory(query2, opts) {
|
|
4326
|
+
if (typeof query2.playerEmail !== "string" || !query2.playerEmail.trim()) {
|
|
4327
|
+
throw invalidInput2("playerEmail", query2.playerEmail, "is required");
|
|
4156
4328
|
}
|
|
4157
4329
|
const q = new URLSearchParams();
|
|
4158
|
-
q.set("player_email",
|
|
4159
|
-
if (
|
|
4160
|
-
if (
|
|
4330
|
+
q.set("player_email", query2.playerEmail);
|
|
4331
|
+
if (query2.limit != null) q.set("limit", String(query2.limit));
|
|
4332
|
+
if (query2.offset != null) q.set("offset", String(query2.offset));
|
|
4161
4333
|
const raw = await this.http.get(
|
|
4162
4334
|
`/api/item-purchases/player-purchase-history?${q.toString()}`,
|
|
4163
4335
|
this.auth,
|
|
@@ -4171,8 +4343,8 @@ var InvoServer = class {
|
|
|
4171
4343
|
}
|
|
4172
4344
|
/** Look up one item order by EXACTLY ONE of orderId | transactionId | clientRequestId
|
|
4173
4345
|
* (§4.8). Use clientRequestId for saga/recovery: "did this purchase actually complete?" */
|
|
4174
|
-
async getItemOrderDetails(
|
|
4175
|
-
const provided = [
|
|
4346
|
+
async getItemOrderDetails(query2, opts) {
|
|
4347
|
+
const provided = [query2.orderId, query2.transactionId, query2.clientRequestId].filter(
|
|
4176
4348
|
(v) => typeof v === "string" && v.trim()
|
|
4177
4349
|
);
|
|
4178
4350
|
if (provided.length !== 1) {
|
|
@@ -4183,9 +4355,9 @@ var InvoServer = class {
|
|
|
4183
4355
|
});
|
|
4184
4356
|
}
|
|
4185
4357
|
const q = new URLSearchParams();
|
|
4186
|
-
if (
|
|
4187
|
-
if (
|
|
4188
|
-
if (
|
|
4358
|
+
if (query2.orderId) q.set("order_id", query2.orderId);
|
|
4359
|
+
if (query2.transactionId) q.set("transaction_id", query2.transactionId);
|
|
4360
|
+
if (query2.clientRequestId) q.set("client_request_id", query2.clientRequestId);
|
|
4189
4361
|
const raw = await this.http.get(
|
|
4190
4362
|
`/api/item-purchases/order-details?${q.toString()}`,
|
|
4191
4363
|
this.auth,
|
|
@@ -4201,15 +4373,15 @@ var InvoServer = class {
|
|
|
4201
4373
|
* for await (const row of invo.iterateItemPurchaseHistory({ playerEmail })) { … }
|
|
4202
4374
|
* ```
|
|
4203
4375
|
*/
|
|
4204
|
-
async *iterateItemPurchaseHistory(
|
|
4205
|
-
if (typeof
|
|
4206
|
-
throw
|
|
4376
|
+
async *iterateItemPurchaseHistory(query2, opts) {
|
|
4377
|
+
if (typeof query2.playerEmail !== "string" || !query2.playerEmail.trim()) {
|
|
4378
|
+
throw invalidInput2("playerEmail", query2.playerEmail, "is required");
|
|
4207
4379
|
}
|
|
4208
|
-
const pageSize = typeof
|
|
4380
|
+
const pageSize = typeof query2.pageSize === "number" && query2.pageSize > 0 ? Math.floor(query2.pageSize) : 50;
|
|
4209
4381
|
let yielded = 0;
|
|
4210
4382
|
for (let offset = 0; ; offset += pageSize) {
|
|
4211
4383
|
const { history, pagination } = await this.getItemPurchaseHistory(
|
|
4212
|
-
{ playerEmail:
|
|
4384
|
+
{ playerEmail: query2.playerEmail, limit: pageSize, offset },
|
|
4213
4385
|
opts
|
|
4214
4386
|
);
|
|
4215
4387
|
if (history.length === 0) return;
|
|
@@ -4243,23 +4415,23 @@ var InvoServer = class {
|
|
|
4243
4415
|
* `500 PLAYER_ACTIVITY_FAILED` (retry later), `429` (back off; `err.retryAfter`). A GET, so
|
|
4244
4416
|
* transient failures are retried automatically.
|
|
4245
4417
|
*/
|
|
4246
|
-
async getPlayerActivity(
|
|
4247
|
-
if (typeof
|
|
4248
|
-
throw
|
|
4418
|
+
async getPlayerActivity(query2, opts) {
|
|
4419
|
+
if (typeof query2?.playerEmail !== "string" || !query2.playerEmail.trim()) {
|
|
4420
|
+
throw invalidInput2("playerEmail", query2?.playerEmail, "is required");
|
|
4249
4421
|
}
|
|
4250
|
-
assertPageLimit(
|
|
4251
|
-
assertCursor(
|
|
4252
|
-
if (
|
|
4253
|
-
if (!Array.isArray(
|
|
4254
|
-
throw
|
|
4422
|
+
assertPageLimit(query2.limit);
|
|
4423
|
+
assertCursor(query2.cursor);
|
|
4424
|
+
if (query2.types !== void 0) {
|
|
4425
|
+
if (!Array.isArray(query2.types) || query2.types.some((t) => typeof t !== "string" || !t.trim() || t.includes(","))) {
|
|
4426
|
+
throw invalidInput2("types", query2.types, "must be an array of activity kinds");
|
|
4255
4427
|
}
|
|
4256
4428
|
}
|
|
4257
4429
|
const q = new URLSearchParams();
|
|
4258
|
-
q.set("player_email",
|
|
4259
|
-
if (
|
|
4260
|
-
if (
|
|
4261
|
-
if (
|
|
4262
|
-
q.set("types",
|
|
4430
|
+
q.set("player_email", query2.playerEmail.trim());
|
|
4431
|
+
if (query2.limit !== void 0) q.set("limit", String(query2.limit));
|
|
4432
|
+
if (query2.cursor !== void 0) q.set("cursor", query2.cursor);
|
|
4433
|
+
if (query2.types && query2.types.length > 0) {
|
|
4434
|
+
q.set("types", query2.types.map((t) => t.trim()).join(","));
|
|
4263
4435
|
}
|
|
4264
4436
|
const raw = await this.http.get(
|
|
4265
4437
|
`/api/sdk/players/activity?${q.toString()}`,
|
|
@@ -4269,7 +4441,7 @@ var InvoServer = class {
|
|
|
4269
4441
|
const activity = Array.isArray(raw["activity"]) ? raw["activity"].map(toPlayerActivityEntry) : [];
|
|
4270
4442
|
const nextCursor = nextCursorOf(raw);
|
|
4271
4443
|
return {
|
|
4272
|
-
playerEmail: String(raw["player_email"] ??
|
|
4444
|
+
playerEmail: String(raw["player_email"] ?? query2.playerEmail.trim()),
|
|
4273
4445
|
gameId: String(raw["game_id"] ?? ""),
|
|
4274
4446
|
types: Array.isArray(raw["types"]) ? raw["types"].map(String) : [],
|
|
4275
4447
|
activity,
|
|
@@ -4287,12 +4459,12 @@ var InvoServer = class {
|
|
|
4287
4459
|
* for await (const row of invo.iteratePlayerActivity({ playerEmail, types: ["send", "transfer"] })) { … }
|
|
4288
4460
|
* ```
|
|
4289
4461
|
*/
|
|
4290
|
-
async *iteratePlayerActivity(
|
|
4462
|
+
async *iteratePlayerActivity(query2, opts) {
|
|
4291
4463
|
let cursor;
|
|
4292
4464
|
const seen = /* @__PURE__ */ new Set();
|
|
4293
4465
|
for (; ; ) {
|
|
4294
4466
|
const page = await this.getPlayerActivity(
|
|
4295
|
-
{ playerEmail:
|
|
4467
|
+
{ playerEmail: query2.playerEmail, types: query2.types, limit: query2.pageSize, cursor },
|
|
4296
4468
|
opts
|
|
4297
4469
|
);
|
|
4298
4470
|
for (const row of page.activity) yield row;
|
|
@@ -4309,11 +4481,11 @@ var InvoServer = class {
|
|
|
4309
4481
|
* browser `InvoClient.getBalance()` (token-authed, identity from the token) for a
|
|
4310
4482
|
* client-side read, or `playerEmail` here server-side.
|
|
4311
4483
|
*/
|
|
4312
|
-
async getPlayerBalance(
|
|
4484
|
+
async getPlayerBalance(query2, opts) {
|
|
4313
4485
|
let path;
|
|
4314
|
-
if (typeof
|
|
4315
|
-
path = `/api/player-balances/player/by-email/${encodeURIComponent(
|
|
4316
|
-
} else if (
|
|
4486
|
+
if (typeof query2.playerEmail === "string" && query2.playerEmail.trim()) {
|
|
4487
|
+
path = `/api/player-balances/player/by-email/${encodeURIComponent(query2.playerEmail)}`;
|
|
4488
|
+
} else if (query2.playerId != null && String(query2.playerId).trim()) {
|
|
4317
4489
|
throw new InvoError({
|
|
4318
4490
|
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.",
|
|
4319
4491
|
code: "INVALID_INPUT",
|
|
@@ -4352,7 +4524,7 @@ var InvoServer = class {
|
|
|
4352
4524
|
*/
|
|
4353
4525
|
async getPlayerRewards(playerEmail, opts) {
|
|
4354
4526
|
if (typeof playerEmail !== "string" || !playerEmail.trim()) {
|
|
4355
|
-
throw
|
|
4527
|
+
throw invalidInput2("playerEmail", playerEmail, "is required");
|
|
4356
4528
|
}
|
|
4357
4529
|
const raw = await this.http.get(
|
|
4358
4530
|
`/api/sdk/loyalty/players/rewards?player_email=${encodeURIComponent(playerEmail.trim())}`,
|
|
@@ -4368,15 +4540,15 @@ var InvoServer = class {
|
|
|
4368
4540
|
* which is null when the phone maps to more than one of your players). Pairs with the
|
|
4369
4541
|
* `transfer.claim_pending` webhook (the webhook is the wake-up; this is the list).
|
|
4370
4542
|
*/
|
|
4371
|
-
async getInboundPending(
|
|
4372
|
-
const hasEmail = typeof
|
|
4373
|
-
const hasPhone = typeof
|
|
4543
|
+
async getInboundPending(query2, opts) {
|
|
4544
|
+
const hasEmail = typeof query2.playerEmail === "string" && query2.playerEmail.trim();
|
|
4545
|
+
const hasPhone = typeof query2.playerPhone === "string" && query2.playerPhone.trim();
|
|
4374
4546
|
if (!hasEmail && !hasPhone) {
|
|
4375
|
-
throw
|
|
4547
|
+
throw invalidInput2("query", query2, "requires a playerEmail or playerPhone");
|
|
4376
4548
|
}
|
|
4377
4549
|
const q = new URLSearchParams();
|
|
4378
|
-
if (hasEmail) q.set("player_email",
|
|
4379
|
-
if (hasPhone) q.set("player_phone",
|
|
4550
|
+
if (hasEmail) q.set("player_email", query2.playerEmail.trim());
|
|
4551
|
+
if (hasPhone) q.set("player_phone", query2.playerPhone.trim());
|
|
4380
4552
|
const raw = await this.http.get(
|
|
4381
4553
|
`/api/transfers/inbound-pending?${q.toString()}`,
|
|
4382
4554
|
this.auth,
|
|
@@ -4393,11 +4565,11 @@ var InvoServer = class {
|
|
|
4393
4565
|
*
|
|
4394
4566
|
* ⚠️ Returns first-party PII (emails/phones) — never expose this to the browser.
|
|
4395
4567
|
*/
|
|
4396
|
-
async getLinkedIdentities(
|
|
4397
|
-
const phone = typeof
|
|
4398
|
-
const email = typeof
|
|
4568
|
+
async getLinkedIdentities(query2, opts) {
|
|
4569
|
+
const phone = typeof query2.playerPhone === "string" && query2.playerPhone.trim() ? query2.playerPhone.trim() : "";
|
|
4570
|
+
const email = typeof query2.playerEmail === "string" && query2.playerEmail.trim() ? query2.playerEmail.trim() : "";
|
|
4399
4571
|
if (!phone && !email) {
|
|
4400
|
-
throw
|
|
4572
|
+
throw invalidInput2("query", query2, "requires a playerEmail or playerPhone");
|
|
4401
4573
|
}
|
|
4402
4574
|
const q = new URLSearchParams();
|
|
4403
4575
|
if (phone) q.set("player_phone", phone);
|
|
@@ -4447,10 +4619,10 @@ var InvoServer = class {
|
|
|
4447
4619
|
*/
|
|
4448
4620
|
async verifySmsTransfer(transactionId, smsPin, opts) {
|
|
4449
4621
|
if (typeof transactionId !== "string" || !transactionId.trim()) {
|
|
4450
|
-
throw
|
|
4622
|
+
throw invalidInput2("transactionId", transactionId, "is required");
|
|
4451
4623
|
}
|
|
4452
4624
|
if (typeof smsPin !== "string" || !smsPin.trim()) {
|
|
4453
|
-
throw
|
|
4625
|
+
throw invalidInput2("smsPin", smsPin, "is required");
|
|
4454
4626
|
}
|
|
4455
4627
|
const raw = await this.http.post(
|
|
4456
4628
|
"/api/transfers/verify-sms",
|
|
@@ -4472,10 +4644,10 @@ var InvoServer = class {
|
|
|
4472
4644
|
*/
|
|
4473
4645
|
async verifySmsSend(transactionId, smsPin, opts) {
|
|
4474
4646
|
if (typeof transactionId !== "string" || !transactionId.trim()) {
|
|
4475
|
-
throw
|
|
4647
|
+
throw invalidInput2("transactionId", transactionId, "is required");
|
|
4476
4648
|
}
|
|
4477
4649
|
if (typeof smsPin !== "string" || !smsPin.trim()) {
|
|
4478
|
-
throw
|
|
4650
|
+
throw invalidInput2("smsPin", smsPin, "is required");
|
|
4479
4651
|
}
|
|
4480
4652
|
const raw = await this.http.post(
|
|
4481
4653
|
"/api/currency-sends/verify-sms",
|
|
@@ -4536,7 +4708,7 @@ var InvoServer = class {
|
|
|
4536
4708
|
/** Read a TRANSFER's status (verification_state + amounts + destination). */
|
|
4537
4709
|
async getTransferStatus(transactionId, opts) {
|
|
4538
4710
|
if (typeof transactionId !== "string" || !transactionId.trim()) {
|
|
4539
|
-
throw
|
|
4711
|
+
throw invalidInput2("transactionId", transactionId, "is required");
|
|
4540
4712
|
}
|
|
4541
4713
|
const raw = await this.http.get(
|
|
4542
4714
|
`/api/transfers/${encodeURIComponent(transactionId)}/status`,
|
|
@@ -4548,7 +4720,7 @@ var InvoServer = class {
|
|
|
4548
4720
|
/** Read a SEND's status (adds fees, game names, claim_info, … on `raw`). */
|
|
4549
4721
|
async getSendStatus(transactionId, opts) {
|
|
4550
4722
|
if (typeof transactionId !== "string" || !transactionId.trim()) {
|
|
4551
|
-
throw
|
|
4723
|
+
throw invalidInput2("transactionId", transactionId, "is required");
|
|
4552
4724
|
}
|
|
4553
4725
|
const raw = await this.http.get(
|
|
4554
4726
|
`/api/currency-sends/${encodeURIComponent(transactionId)}/status`,
|
|
@@ -4564,7 +4736,7 @@ var InvoServer = class {
|
|
|
4564
4736
|
*/
|
|
4565
4737
|
async getGuardianApprovalStatus(transactionId, opts) {
|
|
4566
4738
|
if (typeof transactionId !== "string" || !transactionId.trim()) {
|
|
4567
|
-
throw
|
|
4739
|
+
throw invalidInput2("transactionId", transactionId, "is required");
|
|
4568
4740
|
}
|
|
4569
4741
|
const raw = await this.http.get(
|
|
4570
4742
|
`/api/transactions/${encodeURIComponent(transactionId)}/approval-status`,
|
|
@@ -4580,15 +4752,15 @@ var InvoServer = class {
|
|
|
4580
4752
|
* the source game is passed explicitly rather than inferred from a player token. Rows
|
|
4581
4753
|
* share the browser shape. Idempotent (a POST read — safe to retry).
|
|
4582
4754
|
*/
|
|
4583
|
-
async getDestinations(
|
|
4584
|
-
if (
|
|
4585
|
-
throw
|
|
4755
|
+
async getDestinations(query2, opts) {
|
|
4756
|
+
if (query2.sourceGameId == null || String(query2.sourceGameId).trim() === "") {
|
|
4757
|
+
throw invalidInput2("sourceGameId", query2.sourceGameId, "is required");
|
|
4586
4758
|
}
|
|
4587
|
-
const direction =
|
|
4759
|
+
const direction = query2.direction ?? "transfer";
|
|
4588
4760
|
const path = direction === "send" ? "/api/currency-sends/available-destinations" : "/api/transfers/available-destinations";
|
|
4589
4761
|
const raw = await this.http.post(
|
|
4590
4762
|
path,
|
|
4591
|
-
{ source_game_id:
|
|
4763
|
+
{ source_game_id: query2.sourceGameId },
|
|
4592
4764
|
this.auth,
|
|
4593
4765
|
{ idempotent: true, signal: opts?.signal }
|
|
4594
4766
|
// a POST read — no side effect, safe to retry
|
|
@@ -4607,10 +4779,10 @@ var InvoServer = class {
|
|
|
4607
4779
|
*/
|
|
4608
4780
|
async phoneShareInitiate(input, opts) {
|
|
4609
4781
|
if (typeof input.phone !== "string" || !input.phone.trim()) {
|
|
4610
|
-
throw
|
|
4782
|
+
throw invalidInput2("phone", input.phone, "is required");
|
|
4611
4783
|
}
|
|
4612
4784
|
if (typeof input.email !== "string" || !input.email.trim()) {
|
|
4613
|
-
throw
|
|
4785
|
+
throw invalidInput2("email", input.email, "is required");
|
|
4614
4786
|
}
|
|
4615
4787
|
const raw = await this.http.post(
|
|
4616
4788
|
"/api/wallet/phone-share/initiate",
|
|
@@ -4630,10 +4802,10 @@ var InvoServer = class {
|
|
|
4630
4802
|
*/
|
|
4631
4803
|
async phoneShareApprove(input, opts) {
|
|
4632
4804
|
if (typeof input.approvalId !== "string" || !input.approvalId.trim()) {
|
|
4633
|
-
throw
|
|
4805
|
+
throw invalidInput2("approvalId", input.approvalId, "is required");
|
|
4634
4806
|
}
|
|
4635
4807
|
if (typeof input.otp !== "string" || !input.otp.trim()) {
|
|
4636
|
-
throw
|
|
4808
|
+
throw invalidInput2("otp", input.otp, "is required");
|
|
4637
4809
|
}
|
|
4638
4810
|
const raw = await this.http.post(
|
|
4639
4811
|
"/api/wallet/phone-share/approve",
|
|
@@ -4652,10 +4824,10 @@ var InvoServer = class {
|
|
|
4652
4824
|
*/
|
|
4653
4825
|
async phoneShareStatus(input, opts) {
|
|
4654
4826
|
if (typeof input.phone !== "string" || !input.phone.trim()) {
|
|
4655
|
-
throw
|
|
4827
|
+
throw invalidInput2("phone", input.phone, "is required");
|
|
4656
4828
|
}
|
|
4657
4829
|
if (typeof input.email !== "string" || !input.email.trim()) {
|
|
4658
|
-
throw
|
|
4830
|
+
throw invalidInput2("email", input.email, "is required");
|
|
4659
4831
|
}
|
|
4660
4832
|
const q = new URLSearchParams();
|
|
4661
4833
|
q.set("phone", input.phone);
|
|
@@ -4693,12 +4865,12 @@ var InvoServer = class {
|
|
|
4693
4865
|
async beginDeviceApproval(input, opts) {
|
|
4694
4866
|
assertPlayerToken(input.playerToken);
|
|
4695
4867
|
if (typeof input.transactionId !== "string" || !input.transactionId.trim()) {
|
|
4696
|
-
throw
|
|
4868
|
+
throw invalidInput2("transactionId", input.transactionId, "is required");
|
|
4697
4869
|
}
|
|
4698
4870
|
assertDeviceApprovalFlow(input.flow);
|
|
4699
4871
|
const channel = input.channel ?? "qr";
|
|
4700
4872
|
if (!DEVICE_APPROVAL_CHANNELS.has(channel)) {
|
|
4701
|
-
throw
|
|
4873
|
+
throw invalidInput2("channel", channel, 'must be "qr" | "app_browser" ("popup" is browser-only)');
|
|
4702
4874
|
}
|
|
4703
4875
|
if (channel === "popup") {
|
|
4704
4876
|
throw new InvoError({
|
|
@@ -4736,7 +4908,7 @@ var InvoServer = class {
|
|
|
4736
4908
|
async pollDeviceApproval(input, opts) {
|
|
4737
4909
|
assertPlayerToken(input.playerToken);
|
|
4738
4910
|
if (typeof input.deviceCode !== "string" || !input.deviceCode.trim()) {
|
|
4739
|
-
throw
|
|
4911
|
+
throw invalidInput2("deviceCode", input.deviceCode, "is required (from beginDeviceApproval)");
|
|
4740
4912
|
}
|
|
4741
4913
|
let raw;
|
|
4742
4914
|
try {
|
|
@@ -4774,10 +4946,10 @@ var InvoServer = class {
|
|
|
4774
4946
|
async confirmDeviceEnrollment(input, opts) {
|
|
4775
4947
|
assertPlayerToken(input.playerToken);
|
|
4776
4948
|
if (typeof input.deviceCode !== "string" || !input.deviceCode.trim()) {
|
|
4777
|
-
throw
|
|
4949
|
+
throw invalidInput2("deviceCode", input.deviceCode, "is required (from beginDeviceApproval)");
|
|
4778
4950
|
}
|
|
4779
4951
|
if (input.decision !== "approve" && input.decision !== "deny") {
|
|
4780
|
-
throw
|
|
4952
|
+
throw invalidInput2("decision", input.decision, 'must be "approve" or "deny"');
|
|
4781
4953
|
}
|
|
4782
4954
|
const raw = await this.http.post(
|
|
4783
4955
|
"/api/sdk/approvals/device/confirm-enrollment",
|
|
@@ -4828,11 +5000,11 @@ var InvoServer = class {
|
|
|
4828
5000
|
async approveWithDeviceCode(input, opts) {
|
|
4829
5001
|
assertPlayerToken(input.playerToken);
|
|
4830
5002
|
if (typeof input.transactionId !== "string" || !input.transactionId.trim()) {
|
|
4831
|
-
throw
|
|
5003
|
+
throw invalidInput2("transactionId", input.transactionId, "is required");
|
|
4832
5004
|
}
|
|
4833
5005
|
assertDeviceApprovalFlow(input.flow);
|
|
4834
5006
|
if (typeof input.deviceCode !== "string" || !input.deviceCode.trim()) {
|
|
4835
|
-
throw
|
|
5007
|
+
throw invalidInput2("deviceCode", input.deviceCode, "is required (from beginDeviceApproval)");
|
|
4836
5008
|
}
|
|
4837
5009
|
let raw;
|
|
4838
5010
|
try {
|
|
@@ -4890,11 +5062,11 @@ var InvoServer = class {
|
|
|
4890
5062
|
async completeDeviceApproval(input, opts) {
|
|
4891
5063
|
assertPlayerToken(input.playerToken);
|
|
4892
5064
|
if (typeof input.transactionId !== "string" || !input.transactionId.trim()) {
|
|
4893
|
-
throw
|
|
5065
|
+
throw invalidInput2("transactionId", input.transactionId, "is required");
|
|
4894
5066
|
}
|
|
4895
5067
|
assertDeviceApprovalFlow(input.flow);
|
|
4896
5068
|
if (typeof input.deviceCode !== "string" || !input.deviceCode.trim()) {
|
|
4897
|
-
throw
|
|
5069
|
+
throw invalidInput2("deviceCode", input.deviceCode, "is required (from beginDeviceApproval)");
|
|
4898
5070
|
}
|
|
4899
5071
|
const signal = input.signal ?? opts?.signal;
|
|
4900
5072
|
const { playerToken, deviceCode } = input;
|
|
@@ -4982,6 +5154,7 @@ var InvoServer = class {
|
|
|
4982
5154
|
exports.CardsServer = CardsServer;
|
|
4983
5155
|
exports.InvoError = InvoError;
|
|
4984
5156
|
exports.InvoServer = InvoServer;
|
|
5157
|
+
exports.PayoutsServer = PayoutsServer;
|
|
4985
5158
|
exports.PlatformCommerceServer = PlatformCommerceServer;
|
|
4986
5159
|
exports.SDK_VERSION = SDK_VERSION;
|
|
4987
5160
|
exports.SandboxServer = SandboxServer;
|