@invonetwork/web-sdk 3.24.1 → 3.26.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 +18 -0
- package/README.md +2782 -2749
- package/dist/server.cjs +354 -161
- package/dist/server.d.cts +238 -11
- package/dist/server.d.ts +238 -11
- package/dist/server.js +355 -163
- package/package.json +1 -1
package/dist/server.cjs
CHANGED
|
@@ -1528,7 +1528,198 @@ function toPhoneChangeRequest(raw) {
|
|
|
1528
1528
|
}
|
|
1529
1529
|
|
|
1530
1530
|
// src/version.ts
|
|
1531
|
-
var SDK_VERSION = "3.
|
|
1531
|
+
var SDK_VERSION = "3.26.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); `409 PAYEE_ERASED`; `429 INVITE_RATE_LIMITED` with
|
|
1629
|
+
* `retry_after_seconds`. If INVO asked the creator to update their details, the resend sends
|
|
1630
|
+
* INVO's update notice again. Never auto-retried.
|
|
1631
|
+
*/
|
|
1632
|
+
async resendPayeeInvite(payeeId, opts) {
|
|
1633
|
+
const raw = await this.http.post(
|
|
1634
|
+
`${payeePath(payeeId)}/resend-invite`,
|
|
1635
|
+
void 0,
|
|
1636
|
+
this.auth,
|
|
1637
|
+
{ signal: opts?.signal }
|
|
1638
|
+
);
|
|
1639
|
+
return raw["invite"];
|
|
1640
|
+
}
|
|
1641
|
+
/**
|
|
1642
|
+
* Remove a creator from your program (`POST /api/partner-payees/{payeeId}/remove`, 3.26.0).
|
|
1643
|
+
* The status becomes `closed`. `409 PAYEE_HAS_PAYOUTS_IN_FLIGHT` while a payout to them is in
|
|
1644
|
+
* progress, `409 ALREADY_CLOSED`, `409 PAYEE_NOT_CLOSABLE`. Not a block: the same person can
|
|
1645
|
+
* be registered again under a new reference. Never auto-retried.
|
|
1646
|
+
*/
|
|
1647
|
+
async removePayee(payeeId, opts) {
|
|
1648
|
+
const raw = await this.http.post(
|
|
1649
|
+
`${payeePath(payeeId)}/remove`,
|
|
1650
|
+
void 0,
|
|
1651
|
+
this.auth,
|
|
1652
|
+
{ signal: opts?.signal }
|
|
1653
|
+
);
|
|
1654
|
+
return raw["payee"];
|
|
1655
|
+
}
|
|
1656
|
+
/**
|
|
1657
|
+
* Ask INVO to pay out (`POST /api/partner-payouts/request`). Send exactly one of `payeeId`
|
|
1658
|
+
* (INVO pays that verified creator's bank account) or `bankAccountId` (your own verified bank
|
|
1659
|
+
* account). The money comes from the earnings INVO owes your game, and the payout fee is
|
|
1660
|
+
* taken from the payout. Creator refusals: `404 PAYEE_NOT_FOUND`, `409 PAYEE_NOT_VERIFIED`,
|
|
1661
|
+
* `409 PAYEE_VERIFICATION_EXPIRED`, `409 PAYEE_BANK_NOT_VERIFIED`, `409 PAYEE_CLOSED`,
|
|
1662
|
+
* `409 PAYEE_NOT_PAYABLE` (can't be paid right now; no action needed; try again later),
|
|
1663
|
+
* `409 IDEMPOTENCY_KEY_REUSED`. The first payout to a creator registered with the game key
|
|
1664
|
+
* carries `owner_confirmation_required: true`. Retried safely only when `clientRequestId` is
|
|
1665
|
+
* set.
|
|
1666
|
+
*/
|
|
1667
|
+
async requestPayout(input, opts) {
|
|
1668
|
+
if (input.payeeId !== void 0 && input.bankAccountId !== void 0) {
|
|
1669
|
+
throw invalidInput("bankAccountId", input.bankAccountId, "must not be sent with payeeId");
|
|
1670
|
+
}
|
|
1671
|
+
const body = {
|
|
1672
|
+
amount_usd: amountString(input.amountUsd),
|
|
1673
|
+
contact_email: requireText("contactEmail", input.contactEmail)
|
|
1674
|
+
};
|
|
1675
|
+
if (input.payeeId !== void 0) body["payee_id"] = requireText("payeeId", input.payeeId);
|
|
1676
|
+
if (input.bankAccountId !== void 0) body["bank_account_id"] = input.bankAccountId;
|
|
1677
|
+
if (input.clientRequestId !== void 0) body["client_request_id"] = requireText("clientRequestId", input.clientRequestId);
|
|
1678
|
+
if (input.partnerNote !== void 0) body["partner_note"] = input.partnerNote;
|
|
1679
|
+
if (input.additionalEmails !== void 0) body["additional_emails"] = input.additionalEmails;
|
|
1680
|
+
const raw = await this.http.post("/api/partner-payouts/request", body, this.auth, {
|
|
1681
|
+
idempotent: input.clientRequestId !== void 0,
|
|
1682
|
+
signal: opts?.signal
|
|
1683
|
+
});
|
|
1684
|
+
return {
|
|
1685
|
+
payout: raw["payout_request"],
|
|
1686
|
+
duplicate: raw["duplicate"] === true,
|
|
1687
|
+
raw
|
|
1688
|
+
};
|
|
1689
|
+
}
|
|
1690
|
+
/** One payout (`GET /api/partner-payouts/{payoutId}`). */
|
|
1691
|
+
async getPayout(payoutIdValue, opts) {
|
|
1692
|
+
const raw = await this.http.get(
|
|
1693
|
+
`/api/partner-payouts/${payoutId(payoutIdValue)}`,
|
|
1694
|
+
this.auth,
|
|
1695
|
+
{ signal: opts?.signal }
|
|
1696
|
+
);
|
|
1697
|
+
return raw["payout_request"];
|
|
1698
|
+
}
|
|
1699
|
+
/** Your payouts (`GET /api/partner-payouts`), optionally one creator's (`payeeId`). */
|
|
1700
|
+
async listPayouts(q = {}, opts) {
|
|
1701
|
+
const raw = await this.http.get(
|
|
1702
|
+
`/api/partner-payouts${query({ limit: q.limit, offset: q.offset, status: q.status, payee_id: q.payeeId })}`,
|
|
1703
|
+
this.auth,
|
|
1704
|
+
{ signal: opts?.signal }
|
|
1705
|
+
);
|
|
1706
|
+
return { total: Number(raw["total"] ?? 0), items: raw["items"] ?? [], raw };
|
|
1707
|
+
}
|
|
1708
|
+
/**
|
|
1709
|
+
* Cancel a creator payout that is still `requested`
|
|
1710
|
+
* (`POST /api/partner-payouts/{payoutId}/cancel`). Anything past `requested` is
|
|
1711
|
+
* `409 PAYOUT_NOT_CANCELLABLE`; a payout to your own bank is `404 NOT_FOUND`.
|
|
1712
|
+
*/
|
|
1713
|
+
async cancelPayout(payoutIdValue, opts) {
|
|
1714
|
+
const raw = await this.http.post(
|
|
1715
|
+
`/api/partner-payouts/${payoutId(payoutIdValue)}/cancel`,
|
|
1716
|
+
void 0,
|
|
1717
|
+
this.auth,
|
|
1718
|
+
{ signal: opts?.signal }
|
|
1719
|
+
);
|
|
1720
|
+
return raw["payout_request"] ?? raw["payout"];
|
|
1721
|
+
}
|
|
1722
|
+
};
|
|
1532
1723
|
|
|
1533
1724
|
// src/shared/types.ts
|
|
1534
1725
|
function isRefundPendingApproval(r) {
|
|
@@ -1796,7 +1987,7 @@ function pricingFields(raw, fallback = {}) {
|
|
|
1796
1987
|
if (warning !== void 0) out.minPurchaseWarning = warning;
|
|
1797
1988
|
return out;
|
|
1798
1989
|
}
|
|
1799
|
-
function
|
|
1990
|
+
function invalidInput2(label, value, why) {
|
|
1800
1991
|
return new InvoError({
|
|
1801
1992
|
message: `${label} ${why} (got ${JSON.stringify(value)}).`,
|
|
1802
1993
|
code: "INVALID_INPUT",
|
|
@@ -1808,17 +1999,17 @@ function parseMoney(value, max, label) {
|
|
|
1808
1999
|
let n;
|
|
1809
2000
|
if (typeof value === "number") {
|
|
1810
2001
|
if (!Number.isFinite(value) || !PLAIN_DECIMAL.test(String(value))) {
|
|
1811
|
-
throw
|
|
2002
|
+
throw invalidInput2(label, value, "must be a positive decimal with at most 2 places");
|
|
1812
2003
|
}
|
|
1813
2004
|
n = value;
|
|
1814
2005
|
} else {
|
|
1815
2006
|
if (!PLAIN_DECIMAL.test(value)) {
|
|
1816
|
-
throw
|
|
2007
|
+
throw invalidInput2(label, value, "must be a plain decimal value with at most 2 places");
|
|
1817
2008
|
}
|
|
1818
2009
|
n = Number(value);
|
|
1819
2010
|
}
|
|
1820
2011
|
if (!Number.isFinite(n) || n <= 0 || n > max) {
|
|
1821
|
-
throw
|
|
2012
|
+
throw invalidInput2(label, value, `must be > 0 and <= ${max}`);
|
|
1822
2013
|
}
|
|
1823
2014
|
return n;
|
|
1824
2015
|
}
|
|
@@ -1828,7 +2019,7 @@ function assertUsdAmount(usdAmount) {
|
|
|
1828
2019
|
var E164 = /^\+[1-9]\d{1,14}$/;
|
|
1829
2020
|
function assertE164(value, label) {
|
|
1830
2021
|
if (typeof value !== "string" || !E164.test(value)) {
|
|
1831
|
-
throw
|
|
2022
|
+
throw invalidInput2(label, value, 'must be an E.164 phone number, e.g. "+15555550100"');
|
|
1832
2023
|
}
|
|
1833
2024
|
}
|
|
1834
2025
|
function sessionTokenFromCreateCheckout(raw, checkoutUrl) {
|
|
@@ -1917,13 +2108,13 @@ function toTransactionStatus(raw) {
|
|
|
1917
2108
|
function assertPageLimit(limit) {
|
|
1918
2109
|
if (limit === void 0) return;
|
|
1919
2110
|
if (typeof limit !== "number" || !Number.isInteger(limit) || limit < 1) {
|
|
1920
|
-
throw
|
|
2111
|
+
throw invalidInput2("limit", limit, "must be a positive integer (INVO caps it at 100)");
|
|
1921
2112
|
}
|
|
1922
2113
|
}
|
|
1923
2114
|
function assertCursor(cursor) {
|
|
1924
2115
|
if (cursor === void 0) return;
|
|
1925
2116
|
if (typeof cursor !== "string" || !cursor.trim()) {
|
|
1926
|
-
throw
|
|
2117
|
+
throw invalidInput2("cursor", cursor, "must be the previous page's nextCursor");
|
|
1927
2118
|
}
|
|
1928
2119
|
}
|
|
1929
2120
|
function strOrNull3(v) {
|
|
@@ -2060,12 +2251,12 @@ function isPastThisStep(flow, currentStatus) {
|
|
|
2060
2251
|
}
|
|
2061
2252
|
function assertPlayerToken(playerToken) {
|
|
2062
2253
|
if (typeof playerToken !== "string" || !playerToken.trim()) {
|
|
2063
|
-
throw
|
|
2254
|
+
throw invalidInput2("playerToken", playerToken, "is required (the player's session token, not the game secret)");
|
|
2064
2255
|
}
|
|
2065
2256
|
}
|
|
2066
2257
|
function assertDeviceApprovalFlow(flow) {
|
|
2067
2258
|
if (typeof flow !== "string" || !DEVICE_APPROVAL_FLOWS.has(flow)) {
|
|
2068
|
-
throw
|
|
2259
|
+
throw invalidInput2("flow", flow, 'must be "transfer" | "send" | "send_receipt" | "transfer_receipt"');
|
|
2069
2260
|
}
|
|
2070
2261
|
}
|
|
2071
2262
|
function toDeviceApprovalGrant(raw) {
|
|
@@ -2205,20 +2396,20 @@ var PlatformCommerceServer = class {
|
|
|
2205
2396
|
["itemName", input.itemName]
|
|
2206
2397
|
];
|
|
2207
2398
|
for (const [k, v] of required) {
|
|
2208
|
-
if (typeof v !== "string" || !v.trim()) throw
|
|
2399
|
+
if (typeof v !== "string" || !v.trim()) throw invalidInput2(k, v, "is required");
|
|
2209
2400
|
}
|
|
2210
2401
|
if (!FUNDING_SOURCES.has(input.fundingSource)) {
|
|
2211
|
-
throw
|
|
2402
|
+
throw invalidInput2("fundingSource", input.fundingSource, 'must be "balance" or "card"');
|
|
2212
2403
|
}
|
|
2213
2404
|
if (!Number.isInteger(input.itemQuantity) || input.itemQuantity < 1 || input.itemQuantity > 1e3) {
|
|
2214
|
-
throw
|
|
2405
|
+
throw invalidInput2("itemQuantity", input.itemQuantity, "must be an integer 1..1000");
|
|
2215
2406
|
}
|
|
2216
2407
|
const unit = parseMoney(input.unitPrice, MAX_ITEM_PRICE, "unitPrice");
|
|
2217
2408
|
const total = parseMoney(input.totalPrice, MAX_ITEM_PRICE, "totalPrice");
|
|
2218
2409
|
const expectedCents = Math.round(unit * input.itemQuantity * 100);
|
|
2219
2410
|
const totalCents = Math.round(total * 100);
|
|
2220
2411
|
if (Math.abs(totalCents - expectedCents) > 1) {
|
|
2221
|
-
throw
|
|
2412
|
+
throw invalidInput2(
|
|
2222
2413
|
"totalPrice",
|
|
2223
2414
|
input.totalPrice,
|
|
2224
2415
|
`must equal unitPrice \xD7 itemQuantity (\xB10.01): ${unit} \xD7 ${input.itemQuantity}`
|
|
@@ -2289,7 +2480,7 @@ var PlatformCommerceServer = class {
|
|
|
2289
2480
|
* `pending_payment` (card awaiting confirmation), or `refunded`. */
|
|
2290
2481
|
async getStatus(orderId, opts) {
|
|
2291
2482
|
if (orderId == null || String(orderId).trim() === "") {
|
|
2292
|
-
throw
|
|
2483
|
+
throw invalidInput2("orderId", orderId, "is required");
|
|
2293
2484
|
}
|
|
2294
2485
|
const raw = await this.http.get(
|
|
2295
2486
|
`/api/platform-commerce/purchase-status/${encodeURIComponent(String(orderId))}`,
|
|
@@ -2312,16 +2503,16 @@ var PlatformCommerceServer = class {
|
|
|
2312
2503
|
* tenant (`err.isNotPlatformTenant`), `429` (back off; `err.retryAfter`). A GET, so
|
|
2313
2504
|
* transient failures are retried automatically.
|
|
2314
2505
|
*/
|
|
2315
|
-
async getPurchaseHistory(
|
|
2316
|
-
if (typeof
|
|
2317
|
-
throw
|
|
2506
|
+
async getPurchaseHistory(query2, opts) {
|
|
2507
|
+
if (typeof query2?.playerEmail !== "string" || !query2.playerEmail.trim()) {
|
|
2508
|
+
throw invalidInput2("playerEmail", query2?.playerEmail, "is required");
|
|
2318
2509
|
}
|
|
2319
|
-
assertPageLimit(
|
|
2320
|
-
assertCursor(
|
|
2510
|
+
assertPageLimit(query2.limit);
|
|
2511
|
+
assertCursor(query2.cursor);
|
|
2321
2512
|
const q = new URLSearchParams();
|
|
2322
|
-
q.set("player_email",
|
|
2323
|
-
if (
|
|
2324
|
-
if (
|
|
2513
|
+
q.set("player_email", query2.playerEmail.trim());
|
|
2514
|
+
if (query2.limit !== void 0) q.set("limit", String(query2.limit));
|
|
2515
|
+
if (query2.cursor !== void 0) q.set("cursor", query2.cursor);
|
|
2325
2516
|
const raw = await this.http.get(
|
|
2326
2517
|
`/api/platform-commerce/purchase-history?${q.toString()}`,
|
|
2327
2518
|
this.auth,
|
|
@@ -2330,7 +2521,7 @@ var PlatformCommerceServer = class {
|
|
|
2330
2521
|
const purchases = Array.isArray(raw["purchases"]) ? raw["purchases"].map((r) => toPlatformOrderStatus(r)) : [];
|
|
2331
2522
|
const nextCursor = nextCursorOf(raw);
|
|
2332
2523
|
return {
|
|
2333
|
-
playerEmail: String(raw["player_email"] ??
|
|
2524
|
+
playerEmail: String(raw["player_email"] ?? query2.playerEmail.trim()),
|
|
2334
2525
|
gameId: String(raw["game_id"] ?? ""),
|
|
2335
2526
|
purchases,
|
|
2336
2527
|
limit: typeof raw["limit"] === "number" ? raw["limit"] : purchases.length,
|
|
@@ -2347,12 +2538,12 @@ var PlatformCommerceServer = class {
|
|
|
2347
2538
|
* for await (const order of invo.platformCommerce.iteratePurchaseHistory({ playerEmail })) { … }
|
|
2348
2539
|
* ```
|
|
2349
2540
|
*/
|
|
2350
|
-
async *iteratePurchaseHistory(
|
|
2541
|
+
async *iteratePurchaseHistory(query2, opts) {
|
|
2351
2542
|
let cursor;
|
|
2352
2543
|
const seen = /* @__PURE__ */ new Set();
|
|
2353
2544
|
for (; ; ) {
|
|
2354
2545
|
const page = await this.getPurchaseHistory(
|
|
2355
|
-
{ playerEmail:
|
|
2546
|
+
{ playerEmail: query2.playerEmail, limit: query2.pageSize, cursor },
|
|
2356
2547
|
opts
|
|
2357
2548
|
);
|
|
2358
2549
|
for (const row of page.purchases) yield row;
|
|
@@ -2429,13 +2620,13 @@ var SANDBOX_FAILURE_OUTCOMES = /* @__PURE__ */ new Set([
|
|
|
2429
2620
|
"error"
|
|
2430
2621
|
]);
|
|
2431
2622
|
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
|
|
2623
|
+
if (typeof value !== "string" || !value.trim()) throw invalidInput2(label, value, "is required");
|
|
2624
|
+
if (value.length > 255) throw invalidInput2(label, value, "must be at most 255 characters");
|
|
2625
|
+
if (/^sub_/i.test(value)) throw invalidInput2(label, value, 'must not begin with "sub_" (reserved)');
|
|
2435
2626
|
}
|
|
2436
2627
|
function assertSubscriptionId(value) {
|
|
2437
2628
|
if (typeof value !== "string" || !value.trim()) {
|
|
2438
|
-
throw
|
|
2629
|
+
throw invalidInput2("subscriptionId", value, "is required");
|
|
2439
2630
|
}
|
|
2440
2631
|
}
|
|
2441
2632
|
function subscriptionMoney(value, label) {
|
|
@@ -2687,10 +2878,10 @@ function subscriptionBaseBody(input) {
|
|
|
2687
2878
|
["playerName", input.playerName],
|
|
2688
2879
|
["itemId", input.itemId]
|
|
2689
2880
|
]) {
|
|
2690
|
-
if (typeof v !== "string" || !v.trim()) throw
|
|
2881
|
+
if (typeof v !== "string" || !v.trim()) throw invalidInput2(k, v, "is required");
|
|
2691
2882
|
}
|
|
2692
2883
|
if (input.interval !== void 0 && !SUBSCRIPTION_INTERVALS.has(input.interval)) {
|
|
2693
|
-
throw
|
|
2884
|
+
throw invalidInput2("interval", input.interval, 'must be "month" or "year"');
|
|
2694
2885
|
}
|
|
2695
2886
|
if (input.playerPhone !== void 0) assertE164(input.playerPhone, "playerPhone");
|
|
2696
2887
|
const body = {
|
|
@@ -2723,7 +2914,7 @@ function subscriptionBaseBody(input) {
|
|
|
2723
2914
|
const hasEmail = typeof s.recipientPlayerEmail === "string" && s.recipientPlayerEmail.trim() !== "";
|
|
2724
2915
|
const hasId = s.recipientPlayerId != null;
|
|
2725
2916
|
if (hasEmail === hasId) {
|
|
2726
|
-
throw
|
|
2917
|
+
throw invalidInput2(
|
|
2727
2918
|
"revenueShare",
|
|
2728
2919
|
s,
|
|
2729
2920
|
"requires EXACTLY ONE of recipientPlayerEmail or recipientPlayerId"
|
|
@@ -2781,19 +2972,19 @@ var SubscriptionsServer = class {
|
|
|
2781
2972
|
const body = subscriptionBaseBody(input);
|
|
2782
2973
|
if (input.intervalCount !== void 0) {
|
|
2783
2974
|
if (!Number.isInteger(input.intervalCount) || input.intervalCount < 1 || input.intervalCount > 36) {
|
|
2784
|
-
throw
|
|
2975
|
+
throw invalidInput2("intervalCount", input.intervalCount, "must be an integer 1..36");
|
|
2785
2976
|
}
|
|
2786
2977
|
body["interval_count"] = input.intervalCount;
|
|
2787
2978
|
}
|
|
2788
2979
|
if (input.trialDays !== void 0) {
|
|
2789
2980
|
if (!Number.isInteger(input.trialDays) || input.trialDays < 1 || input.trialDays > 365) {
|
|
2790
|
-
throw
|
|
2981
|
+
throw invalidInput2("trialDays", input.trialDays, "must be an integer 1..365");
|
|
2791
2982
|
}
|
|
2792
2983
|
body["trial_days"] = input.trialDays;
|
|
2793
2984
|
}
|
|
2794
2985
|
if (input.trialEnd !== void 0) {
|
|
2795
2986
|
if (typeof input.trialEnd !== "string" || Number.isNaN(Date.parse(input.trialEnd))) {
|
|
2796
|
-
throw
|
|
2987
|
+
throw invalidInput2("trialEnd", input.trialEnd, "must be an ISO 8601 timestamp");
|
|
2797
2988
|
}
|
|
2798
2989
|
body["trial_end"] = input.trialEnd;
|
|
2799
2990
|
}
|
|
@@ -2816,16 +3007,16 @@ var SubscriptionsServer = class {
|
|
|
2816
3007
|
}
|
|
2817
3008
|
if (input.walletOnly !== void 0) {
|
|
2818
3009
|
if (typeof input.walletOnly !== "boolean") {
|
|
2819
|
-
throw
|
|
3010
|
+
throw invalidInput2("walletOnly", input.walletOnly, "must be a boolean");
|
|
2820
3011
|
}
|
|
2821
3012
|
body["wallet_only"] = input.walletOnly;
|
|
2822
3013
|
}
|
|
2823
3014
|
if (input.playerCardId !== void 0) {
|
|
2824
3015
|
if (!Number.isInteger(input.playerCardId) || input.playerCardId < 1) {
|
|
2825
|
-
throw
|
|
3016
|
+
throw invalidInput2("playerCardId", input.playerCardId, "must be a positive integer card id (from cards.list)");
|
|
2826
3017
|
}
|
|
2827
3018
|
if (input.walletOnly === true) {
|
|
2828
|
-
throw
|
|
3019
|
+
throw invalidInput2("playerCardId", input.playerCardId, "cannot be combined with walletOnly: true");
|
|
2829
3020
|
}
|
|
2830
3021
|
body["player_card_id"] = input.playerCardId;
|
|
2831
3022
|
}
|
|
@@ -2861,7 +3052,7 @@ var SubscriptionsServer = class {
|
|
|
2861
3052
|
*/
|
|
2862
3053
|
async listForPlayer(playerEmail, options, opts) {
|
|
2863
3054
|
if (typeof playerEmail !== "string" || !playerEmail.trim()) {
|
|
2864
|
-
throw
|
|
3055
|
+
throw invalidInput2("playerEmail", playerEmail, "is required");
|
|
2865
3056
|
}
|
|
2866
3057
|
const q = new URLSearchParams();
|
|
2867
3058
|
q.set("player_email", playerEmail);
|
|
@@ -2872,13 +3063,13 @@ var SubscriptionsServer = class {
|
|
|
2872
3063
|
if (options?.includePlayer) q.set("include_player", "true");
|
|
2873
3064
|
if (options?.limit != null) {
|
|
2874
3065
|
if (!Number.isInteger(options.limit) || options.limit < 1 || options.limit > 100) {
|
|
2875
|
-
throw
|
|
3066
|
+
throw invalidInput2("limit", options.limit, "must be an integer 1..100");
|
|
2876
3067
|
}
|
|
2877
3068
|
q.set("limit", String(options.limit));
|
|
2878
3069
|
}
|
|
2879
3070
|
if (options?.offset != null) {
|
|
2880
3071
|
if (!Number.isInteger(options.offset) || options.offset < 0 || options.offset > 1e5) {
|
|
2881
|
-
throw
|
|
3072
|
+
throw invalidInput2("offset", options.offset, "must be an integer 0..100000");
|
|
2882
3073
|
}
|
|
2883
3074
|
q.set("offset", String(options.offset));
|
|
2884
3075
|
}
|
|
@@ -2918,13 +3109,13 @@ var SubscriptionsServer = class {
|
|
|
2918
3109
|
const body = {};
|
|
2919
3110
|
if (options?.atPeriodEnd !== void 0) {
|
|
2920
3111
|
if (typeof options.atPeriodEnd !== "boolean") {
|
|
2921
|
-
throw
|
|
3112
|
+
throw invalidInput2("atPeriodEnd", options.atPeriodEnd, "must be a boolean");
|
|
2922
3113
|
}
|
|
2923
3114
|
body["at_period_end"] = options.atPeriodEnd;
|
|
2924
3115
|
}
|
|
2925
3116
|
if (options?.reason !== void 0) {
|
|
2926
3117
|
if (typeof options.reason !== "string" || options.reason.length > 500) {
|
|
2927
|
-
throw
|
|
3118
|
+
throw invalidInput2("reason", options.reason, "must be a string of at most 500 characters");
|
|
2928
3119
|
}
|
|
2929
3120
|
body["reason"] = options.reason;
|
|
2930
3121
|
}
|
|
@@ -3003,14 +3194,14 @@ var SubscriptionsServer = class {
|
|
|
3003
3194
|
const body = {};
|
|
3004
3195
|
if ("playerCardId" in input && input.playerCardId !== void 0) {
|
|
3005
3196
|
if (!Number.isInteger(input.playerCardId) || input.playerCardId < 1) {
|
|
3006
|
-
throw
|
|
3197
|
+
throw invalidInput2("playerCardId", input.playerCardId, "must be a positive integer card id (from cards.list)");
|
|
3007
3198
|
}
|
|
3008
3199
|
body["player_card_id"] = input.playerCardId;
|
|
3009
3200
|
if (input.walletOnly !== void 0) body["wallet_only"] = input.walletOnly;
|
|
3010
3201
|
} else if (input.walletOnly === true) {
|
|
3011
3202
|
body["wallet_only"] = true;
|
|
3012
3203
|
} else {
|
|
3013
|
-
throw
|
|
3204
|
+
throw invalidInput2("input", input, "requires { playerCardId } or { walletOnly: true }");
|
|
3014
3205
|
}
|
|
3015
3206
|
const raw = await this.http.post(
|
|
3016
3207
|
`/api/subscriptions/${encodeURIComponent(subscriptionId)}/payment-method`,
|
|
@@ -3071,14 +3262,14 @@ var SubscriptionsServer = class {
|
|
|
3071
3262
|
const body = { client_request_id: input.clientRequestId };
|
|
3072
3263
|
if (input.periodSeq !== void 0) {
|
|
3073
3264
|
if (!Number.isInteger(input.periodSeq) || input.periodSeq < 1) {
|
|
3074
|
-
throw
|
|
3265
|
+
throw invalidInput2("periodSeq", input.periodSeq, "must be an integer >= 1");
|
|
3075
3266
|
}
|
|
3076
3267
|
body["period_seq"] = input.periodSeq;
|
|
3077
3268
|
}
|
|
3078
3269
|
if (input.amountUsd !== void 0) body["amount_usd"] = subscriptionMoney(input.amountUsd, "amountUsd");
|
|
3079
3270
|
if (input.reason !== void 0) {
|
|
3080
3271
|
if (typeof input.reason !== "string" || input.reason.length > 500) {
|
|
3081
|
-
throw
|
|
3272
|
+
throw invalidInput2("reason", input.reason, "must be a string of at most 500 characters");
|
|
3082
3273
|
}
|
|
3083
3274
|
body["reason"] = input.reason;
|
|
3084
3275
|
}
|
|
@@ -3120,10 +3311,10 @@ var SubscriptionsServer = class {
|
|
|
3120
3311
|
async steamInit(input, opts) {
|
|
3121
3312
|
const body = subscriptionBaseBody(input);
|
|
3122
3313
|
if (!/^[0-9]+$/.test(String(input.steamId ?? ""))) {
|
|
3123
|
-
throw
|
|
3314
|
+
throw invalidInput2("steamId", input.steamId, "must be the member's numeric 64-bit Steam id");
|
|
3124
3315
|
}
|
|
3125
3316
|
if (input.userSession !== void 0 && input.userSession !== "client" && input.userSession !== "web") {
|
|
3126
|
-
throw
|
|
3317
|
+
throw invalidInput2("userSession", input.userSession, 'must be "client" or "web"');
|
|
3127
3318
|
}
|
|
3128
3319
|
if (input.userSession === "web" && !input.playerIp) {
|
|
3129
3320
|
throw new InvoError({
|
|
@@ -3133,7 +3324,7 @@ var SubscriptionsServer = class {
|
|
|
3133
3324
|
});
|
|
3134
3325
|
}
|
|
3135
3326
|
if (input.intervalCount !== void 0 && input.intervalCount !== 1) {
|
|
3136
|
-
throw
|
|
3327
|
+
throw invalidInput2("intervalCount", input.intervalCount, "must be 1 on the Steam rail (monthly and yearly only)");
|
|
3137
3328
|
}
|
|
3138
3329
|
const forbidden = input;
|
|
3139
3330
|
if (forbidden["trialAmountUsd"] !== void 0) {
|
|
@@ -3145,7 +3336,7 @@ var SubscriptionsServer = class {
|
|
|
3145
3336
|
}
|
|
3146
3337
|
for (const k of ["trialDays", "trialEnd", "walletOnly", "playerCardId"]) {
|
|
3147
3338
|
if (forbidden[k] !== void 0) {
|
|
3148
|
-
throw
|
|
3339
|
+
throw invalidInput2(k, forbidden[k], "is not available on the Steam rail");
|
|
3149
3340
|
}
|
|
3150
3341
|
}
|
|
3151
3342
|
body["steamid"] = String(input.steamId);
|
|
@@ -3258,24 +3449,24 @@ var CardsServer = class {
|
|
|
3258
3449
|
*/
|
|
3259
3450
|
async createSetupSession(input, opts) {
|
|
3260
3451
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
3261
|
-
throw
|
|
3452
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
3262
3453
|
}
|
|
3263
3454
|
for (const [label, value] of [
|
|
3264
3455
|
["successUrl", input.successUrl],
|
|
3265
3456
|
["cancelUrl", input.cancelUrl]
|
|
3266
3457
|
]) {
|
|
3267
3458
|
if (value === void 0) continue;
|
|
3268
|
-
if (typeof value !== "string" || !value.trim()) throw
|
|
3269
|
-
if (SCRIPT_SCHEME.test(value)) throw
|
|
3459
|
+
if (typeof value !== "string" || !value.trim()) throw invalidInput2(label, value, "must be a non-empty URL");
|
|
3460
|
+
if (SCRIPT_SCHEME.test(value)) throw invalidInput2(label, value, "must not use a script scheme");
|
|
3270
3461
|
}
|
|
3271
3462
|
if (input.metadata !== void 0 && (input.metadata === null || typeof input.metadata !== "object" || Array.isArray(input.metadata))) {
|
|
3272
|
-
throw
|
|
3463
|
+
throw invalidInput2("metadata", input.metadata, "must be a plain object");
|
|
3273
3464
|
}
|
|
3274
3465
|
if (input.playerName !== void 0) {
|
|
3275
3466
|
if (typeof input.playerName !== "string" || !input.playerName.trim()) {
|
|
3276
|
-
throw
|
|
3467
|
+
throw invalidInput2("playerName", input.playerName, "must be a non-empty string");
|
|
3277
3468
|
}
|
|
3278
|
-
if (input.playerName.trim().length > 255) throw
|
|
3469
|
+
if (input.playerName.trim().length > 255) throw invalidInput2("playerName", input.playerName, "must be at most 255 characters");
|
|
3279
3470
|
}
|
|
3280
3471
|
if (input.playerPhone !== void 0) assertE164(input.playerPhone, "playerPhone");
|
|
3281
3472
|
const body = { player_email: input.playerEmail };
|
|
@@ -3320,10 +3511,10 @@ var CardsServer = class {
|
|
|
3320
3511
|
*/
|
|
3321
3512
|
async beginSetup(input, opts) {
|
|
3322
3513
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
3323
|
-
throw
|
|
3514
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
3324
3515
|
}
|
|
3325
3516
|
if (typeof input.setupReference !== "string" || !/^[A-Za-z0-9._:-]{1,200}$/.test(input.setupReference)) {
|
|
3326
|
-
throw
|
|
3517
|
+
throw invalidInput2("setupReference", input.setupReference, "must be 1-200 characters of A-Z a-z 0-9 . _ : -");
|
|
3327
3518
|
}
|
|
3328
3519
|
const body = {
|
|
3329
3520
|
player_email: input.playerEmail,
|
|
@@ -3359,7 +3550,7 @@ var CardsServer = class {
|
|
|
3359
3550
|
*/
|
|
3360
3551
|
async confirmSetup(input, opts) {
|
|
3361
3552
|
if (typeof input.setupIntentId !== "string" || !input.setupIntentId.trim()) {
|
|
3362
|
-
throw
|
|
3553
|
+
throw invalidInput2("setupIntentId", input.setupIntentId, "is required (from beginSetup)");
|
|
3363
3554
|
}
|
|
3364
3555
|
const raw = await this.http.post(
|
|
3365
3556
|
"/api/currency-purchases/setup-intent/confirm",
|
|
@@ -3385,7 +3576,7 @@ var CardsServer = class {
|
|
|
3385
3576
|
*/
|
|
3386
3577
|
async list(playerEmail, opts) {
|
|
3387
3578
|
if (typeof playerEmail !== "string" || !playerEmail.trim()) {
|
|
3388
|
-
throw
|
|
3579
|
+
throw invalidInput2("playerEmail", playerEmail, "is required");
|
|
3389
3580
|
}
|
|
3390
3581
|
const raw = await this.http.get(
|
|
3391
3582
|
`/api/currency-purchases/player-cards?player_email=${encodeURIComponent(playerEmail)}`,
|
|
@@ -3408,7 +3599,7 @@ var SandboxSubscriptionsServer = class {
|
|
|
3408
3599
|
async call(subscriptionId, tool, body, opts) {
|
|
3409
3600
|
assertSubscriptionId(subscriptionId);
|
|
3410
3601
|
if (typeof this.clockKey !== "string" || !this.clockKey.trim()) {
|
|
3411
|
-
throw
|
|
3602
|
+
throw invalidInput2(
|
|
3412
3603
|
"sandboxClockKey",
|
|
3413
3604
|
this.clockKey,
|
|
3414
3605
|
'is required for invo.sandbox.subscriptions.* \u2014 pass it to new InvoServer({ sandboxClockKey }) from the sandbox console (Game Settings, "Sandbox clock key")'
|
|
@@ -3434,7 +3625,7 @@ var SandboxSubscriptionsServer = class {
|
|
|
3434
3625
|
*/
|
|
3435
3626
|
async advanceClock(subscriptionId, intervals = 1, opts) {
|
|
3436
3627
|
if (!Number.isInteger(intervals) || intervals < 0 || intervals > 60) {
|
|
3437
|
-
throw
|
|
3628
|
+
throw invalidInput2("intervals", intervals, "must be an integer 0..60");
|
|
3438
3629
|
}
|
|
3439
3630
|
return this.call(subscriptionId, "advance-clock", { intervals }, opts);
|
|
3440
3631
|
}
|
|
@@ -3457,7 +3648,7 @@ var SandboxSubscriptionsServer = class {
|
|
|
3457
3648
|
*/
|
|
3458
3649
|
async forceFailure(subscriptionId, outcome = "card_declined", options, opts) {
|
|
3459
3650
|
if (!SANDBOX_FAILURE_OUTCOMES.has(outcome)) {
|
|
3460
|
-
throw
|
|
3651
|
+
throw invalidInput2("outcome", outcome, 'must be "card_declined" | "insufficient_funds" | "error"');
|
|
3461
3652
|
}
|
|
3462
3653
|
const body = { outcome };
|
|
3463
3654
|
if (options?.failureCode !== void 0) body["failure_code"] = options.failureCode;
|
|
@@ -3502,6 +3693,7 @@ var InvoServer = class {
|
|
|
3502
3693
|
this.subscriptions = new SubscriptionsServer(this.http, this.auth);
|
|
3503
3694
|
this.cards = new CardsServer(this.http, this.auth);
|
|
3504
3695
|
this.sandbox = new SandboxServer(this.http, this.auth, config.sandboxClockKey);
|
|
3696
|
+
this.payouts = new PayoutsServer(this.http, this.auth);
|
|
3505
3697
|
}
|
|
3506
3698
|
/**
|
|
3507
3699
|
* Mint a short-lived, game-scoped player token to hand to the browser InvoClient.
|
|
@@ -3522,7 +3714,7 @@ var InvoServer = class {
|
|
|
3522
3714
|
*/
|
|
3523
3715
|
async mintPlayerToken(input, opts) {
|
|
3524
3716
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
3525
|
-
throw
|
|
3717
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
3526
3718
|
}
|
|
3527
3719
|
const body = { player_email: input.playerEmail };
|
|
3528
3720
|
if (input.playerPhone !== void 0) {
|
|
@@ -3531,7 +3723,7 @@ var InvoServer = class {
|
|
|
3531
3723
|
}
|
|
3532
3724
|
if (input.playerName !== void 0) {
|
|
3533
3725
|
if (typeof input.playerName !== "string") {
|
|
3534
|
-
throw
|
|
3726
|
+
throw invalidInput2("playerName", input.playerName, "must be a string");
|
|
3535
3727
|
}
|
|
3536
3728
|
body["player_name"] = input.playerName;
|
|
3537
3729
|
}
|
|
@@ -3564,7 +3756,7 @@ var InvoServer = class {
|
|
|
3564
3756
|
*/
|
|
3565
3757
|
async registerPlayer(input, opts) {
|
|
3566
3758
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
3567
|
-
throw
|
|
3759
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
3568
3760
|
}
|
|
3569
3761
|
assertE164(input.playerPhone, "playerPhone");
|
|
3570
3762
|
const body = {
|
|
@@ -3573,7 +3765,7 @@ var InvoServer = class {
|
|
|
3573
3765
|
};
|
|
3574
3766
|
if (input.playerName !== void 0) {
|
|
3575
3767
|
if (typeof input.playerName !== "string") {
|
|
3576
|
-
throw
|
|
3768
|
+
throw invalidInput2("playerName", input.playerName, "must be a string");
|
|
3577
3769
|
}
|
|
3578
3770
|
body["player_name"] = input.playerName;
|
|
3579
3771
|
}
|
|
@@ -3611,7 +3803,7 @@ var InvoServer = class {
|
|
|
3611
3803
|
*/
|
|
3612
3804
|
async updatePlayerPhone(input, opts) {
|
|
3613
3805
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
3614
|
-
throw
|
|
3806
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
3615
3807
|
}
|
|
3616
3808
|
assertE164(input.newPhone, "newPhone");
|
|
3617
3809
|
const raw = await this.http.post(
|
|
@@ -3655,7 +3847,7 @@ var InvoServer = class {
|
|
|
3655
3847
|
*/
|
|
3656
3848
|
async requestPhoneChange(input, opts) {
|
|
3657
3849
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
3658
|
-
throw
|
|
3850
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
3659
3851
|
}
|
|
3660
3852
|
assertE164(input.newPhone, "newPhone");
|
|
3661
3853
|
const raw = await this.http.post(
|
|
@@ -3675,7 +3867,7 @@ var InvoServer = class {
|
|
|
3675
3867
|
*/
|
|
3676
3868
|
async getPhoneChange(changeRequestId, opts) {
|
|
3677
3869
|
if (typeof changeRequestId !== "string" || !changeRequestId.trim()) {
|
|
3678
|
-
throw
|
|
3870
|
+
throw invalidInput2("changeRequestId", changeRequestId, "is required");
|
|
3679
3871
|
}
|
|
3680
3872
|
const raw = await this.http.get(
|
|
3681
3873
|
`/api/sdk/players/phone/change-requests/${encodeURIComponent(changeRequestId)}`,
|
|
@@ -3739,7 +3931,7 @@ var InvoServer = class {
|
|
|
3739
3931
|
* purchase.completed webhook. */
|
|
3740
3932
|
async createCheckout(input, opts) {
|
|
3741
3933
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
3742
|
-
throw
|
|
3934
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
3743
3935
|
}
|
|
3744
3936
|
assertUsdAmount(input.usdAmount);
|
|
3745
3937
|
const body = {
|
|
@@ -3803,7 +3995,7 @@ var InvoServer = class {
|
|
|
3803
3995
|
*/
|
|
3804
3996
|
async purchaseCurrency(input, opts) {
|
|
3805
3997
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
3806
|
-
throw
|
|
3998
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
3807
3999
|
}
|
|
3808
4000
|
assertUsdAmount(input.usdAmount);
|
|
3809
4001
|
if (!input.purchaseReference) {
|
|
@@ -3922,8 +4114,8 @@ var InvoServer = class {
|
|
|
3922
4114
|
};
|
|
3923
4115
|
}
|
|
3924
4116
|
/** Fetch purchase status (order + financial summary + timeline). */
|
|
3925
|
-
async getOrderDetails(
|
|
3926
|
-
if (!
|
|
4117
|
+
async getOrderDetails(query2, opts) {
|
|
4118
|
+
if (!query2.orderId && !query2.transactionId) {
|
|
3927
4119
|
throw new InvoError({
|
|
3928
4120
|
message: "getOrderDetails requires an `orderId` or `transactionId`.",
|
|
3929
4121
|
code: "INVALID_INPUT",
|
|
@@ -3931,8 +4123,8 @@ var InvoServer = class {
|
|
|
3931
4123
|
});
|
|
3932
4124
|
}
|
|
3933
4125
|
const q = new URLSearchParams();
|
|
3934
|
-
if (
|
|
3935
|
-
if (
|
|
4126
|
+
if (query2.orderId) q.set("order_id", query2.orderId);
|
|
4127
|
+
if (query2.transactionId) q.set("transaction_id", query2.transactionId);
|
|
3936
4128
|
const raw = await this.http.get(
|
|
3937
4129
|
`/api/currency-purchases/order-details?${q.toString()}`,
|
|
3938
4130
|
this.auth,
|
|
@@ -3955,8 +4147,8 @@ var InvoServer = class {
|
|
|
3955
4147
|
* no-VAT catalogue and lets the PURCHASE be what refuses; the only 503 is
|
|
3956
4148
|
* the rail being disabled platform-wide, whose body carries no error code.
|
|
3957
4149
|
*/
|
|
3958
|
-
async steamPacks(
|
|
3959
|
-
const qs =
|
|
4150
|
+
async steamPacks(query2, opts) {
|
|
4151
|
+
const qs = query2?.steamid ? `?steamid=${encodeURIComponent(query2.steamid)}` : "";
|
|
3960
4152
|
const raw = await this.http.get(
|
|
3961
4153
|
`/api/currency-purchases/steam/packs${qs}`,
|
|
3962
4154
|
this.auth,
|
|
@@ -4001,12 +4193,12 @@ var InvoServer = class {
|
|
|
4001
4193
|
*/
|
|
4002
4194
|
async steamInitPurchase(input, opts) {
|
|
4003
4195
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
4004
|
-
throw
|
|
4196
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
4005
4197
|
}
|
|
4006
4198
|
if (!/^[0-9]+$/.test(String(input.steamid ?? ""))) {
|
|
4007
|
-
throw
|
|
4199
|
+
throw invalidInput2("steamid", input.steamid, "must be the player's numeric 64-bit Steam id");
|
|
4008
4200
|
}
|
|
4009
|
-
if (!input.packId) throw
|
|
4201
|
+
if (!input.packId) throw invalidInput2("packId", input.packId, "is required \u2014 fetch steamPacks()");
|
|
4010
4202
|
if (!input.purchaseReference) {
|
|
4011
4203
|
throw new InvoError({
|
|
4012
4204
|
message: "purchaseReference is required (idempotency key, unique per intended purchase).",
|
|
@@ -4067,7 +4259,7 @@ var InvoServer = class {
|
|
|
4067
4259
|
* detects the authorized transaction and credits, on a delay.
|
|
4068
4260
|
*/
|
|
4069
4261
|
async steamFinalizePurchase(input, opts) {
|
|
4070
|
-
if (!input.orderId) throw
|
|
4262
|
+
if (!input.orderId) throw invalidInput2("orderId", input.orderId, "is required (from steamInitPurchase)");
|
|
4071
4263
|
const raw = await this.http.post(
|
|
4072
4264
|
"/api/currency-purchases/steam/finalize-purchase",
|
|
4073
4265
|
{ order_id: input.orderId },
|
|
@@ -4102,17 +4294,17 @@ var InvoServer = class {
|
|
|
4102
4294
|
["itemName", input.itemName]
|
|
4103
4295
|
];
|
|
4104
4296
|
for (const [k, v] of required) {
|
|
4105
|
-
if (typeof v !== "string" || !v.trim()) throw
|
|
4297
|
+
if (typeof v !== "string" || !v.trim()) throw invalidInput2(k, v, "is required");
|
|
4106
4298
|
}
|
|
4107
4299
|
if (!Number.isInteger(input.itemQuantity) || input.itemQuantity < 1 || input.itemQuantity > 1e3) {
|
|
4108
|
-
throw
|
|
4300
|
+
throw invalidInput2("itemQuantity", input.itemQuantity, "must be an integer 1..1000");
|
|
4109
4301
|
}
|
|
4110
4302
|
const unit = parseMoney(input.unitPrice, MAX_ITEM_PRICE, "unitPrice");
|
|
4111
4303
|
const total = parseMoney(input.totalPrice, MAX_ITEM_PRICE, "totalPrice");
|
|
4112
4304
|
const expectedCents = Math.round(unit * input.itemQuantity * 100);
|
|
4113
4305
|
const totalCents = Math.round(total * 100);
|
|
4114
4306
|
if (Math.abs(totalCents - expectedCents) > 1) {
|
|
4115
|
-
throw
|
|
4307
|
+
throw invalidInput2(
|
|
4116
4308
|
"totalPrice",
|
|
4117
4309
|
input.totalPrice,
|
|
4118
4310
|
`must equal unitPrice \xD7 itemQuantity (\xB10.01): ${unit} \xD7 ${input.itemQuantity}`
|
|
@@ -4150,14 +4342,14 @@ var InvoServer = class {
|
|
|
4150
4342
|
};
|
|
4151
4343
|
}
|
|
4152
4344
|
/** Paginated item-purchase history for a player (§4.8 companion read). */
|
|
4153
|
-
async getItemPurchaseHistory(
|
|
4154
|
-
if (typeof
|
|
4155
|
-
throw
|
|
4345
|
+
async getItemPurchaseHistory(query2, opts) {
|
|
4346
|
+
if (typeof query2.playerEmail !== "string" || !query2.playerEmail.trim()) {
|
|
4347
|
+
throw invalidInput2("playerEmail", query2.playerEmail, "is required");
|
|
4156
4348
|
}
|
|
4157
4349
|
const q = new URLSearchParams();
|
|
4158
|
-
q.set("player_email",
|
|
4159
|
-
if (
|
|
4160
|
-
if (
|
|
4350
|
+
q.set("player_email", query2.playerEmail);
|
|
4351
|
+
if (query2.limit != null) q.set("limit", String(query2.limit));
|
|
4352
|
+
if (query2.offset != null) q.set("offset", String(query2.offset));
|
|
4161
4353
|
const raw = await this.http.get(
|
|
4162
4354
|
`/api/item-purchases/player-purchase-history?${q.toString()}`,
|
|
4163
4355
|
this.auth,
|
|
@@ -4171,8 +4363,8 @@ var InvoServer = class {
|
|
|
4171
4363
|
}
|
|
4172
4364
|
/** Look up one item order by EXACTLY ONE of orderId | transactionId | clientRequestId
|
|
4173
4365
|
* (§4.8). Use clientRequestId for saga/recovery: "did this purchase actually complete?" */
|
|
4174
|
-
async getItemOrderDetails(
|
|
4175
|
-
const provided = [
|
|
4366
|
+
async getItemOrderDetails(query2, opts) {
|
|
4367
|
+
const provided = [query2.orderId, query2.transactionId, query2.clientRequestId].filter(
|
|
4176
4368
|
(v) => typeof v === "string" && v.trim()
|
|
4177
4369
|
);
|
|
4178
4370
|
if (provided.length !== 1) {
|
|
@@ -4183,9 +4375,9 @@ var InvoServer = class {
|
|
|
4183
4375
|
});
|
|
4184
4376
|
}
|
|
4185
4377
|
const q = new URLSearchParams();
|
|
4186
|
-
if (
|
|
4187
|
-
if (
|
|
4188
|
-
if (
|
|
4378
|
+
if (query2.orderId) q.set("order_id", query2.orderId);
|
|
4379
|
+
if (query2.transactionId) q.set("transaction_id", query2.transactionId);
|
|
4380
|
+
if (query2.clientRequestId) q.set("client_request_id", query2.clientRequestId);
|
|
4189
4381
|
const raw = await this.http.get(
|
|
4190
4382
|
`/api/item-purchases/order-details?${q.toString()}`,
|
|
4191
4383
|
this.auth,
|
|
@@ -4201,15 +4393,15 @@ var InvoServer = class {
|
|
|
4201
4393
|
* for await (const row of invo.iterateItemPurchaseHistory({ playerEmail })) { … }
|
|
4202
4394
|
* ```
|
|
4203
4395
|
*/
|
|
4204
|
-
async *iterateItemPurchaseHistory(
|
|
4205
|
-
if (typeof
|
|
4206
|
-
throw
|
|
4396
|
+
async *iterateItemPurchaseHistory(query2, opts) {
|
|
4397
|
+
if (typeof query2.playerEmail !== "string" || !query2.playerEmail.trim()) {
|
|
4398
|
+
throw invalidInput2("playerEmail", query2.playerEmail, "is required");
|
|
4207
4399
|
}
|
|
4208
|
-
const pageSize = typeof
|
|
4400
|
+
const pageSize = typeof query2.pageSize === "number" && query2.pageSize > 0 ? Math.floor(query2.pageSize) : 50;
|
|
4209
4401
|
let yielded = 0;
|
|
4210
4402
|
for (let offset = 0; ; offset += pageSize) {
|
|
4211
4403
|
const { history, pagination } = await this.getItemPurchaseHistory(
|
|
4212
|
-
{ playerEmail:
|
|
4404
|
+
{ playerEmail: query2.playerEmail, limit: pageSize, offset },
|
|
4213
4405
|
opts
|
|
4214
4406
|
);
|
|
4215
4407
|
if (history.length === 0) return;
|
|
@@ -4243,23 +4435,23 @@ var InvoServer = class {
|
|
|
4243
4435
|
* `500 PLAYER_ACTIVITY_FAILED` (retry later), `429` (back off; `err.retryAfter`). A GET, so
|
|
4244
4436
|
* transient failures are retried automatically.
|
|
4245
4437
|
*/
|
|
4246
|
-
async getPlayerActivity(
|
|
4247
|
-
if (typeof
|
|
4248
|
-
throw
|
|
4438
|
+
async getPlayerActivity(query2, opts) {
|
|
4439
|
+
if (typeof query2?.playerEmail !== "string" || !query2.playerEmail.trim()) {
|
|
4440
|
+
throw invalidInput2("playerEmail", query2?.playerEmail, "is required");
|
|
4249
4441
|
}
|
|
4250
|
-
assertPageLimit(
|
|
4251
|
-
assertCursor(
|
|
4252
|
-
if (
|
|
4253
|
-
if (!Array.isArray(
|
|
4254
|
-
throw
|
|
4442
|
+
assertPageLimit(query2.limit);
|
|
4443
|
+
assertCursor(query2.cursor);
|
|
4444
|
+
if (query2.types !== void 0) {
|
|
4445
|
+
if (!Array.isArray(query2.types) || query2.types.some((t) => typeof t !== "string" || !t.trim() || t.includes(","))) {
|
|
4446
|
+
throw invalidInput2("types", query2.types, "must be an array of activity kinds");
|
|
4255
4447
|
}
|
|
4256
4448
|
}
|
|
4257
4449
|
const q = new URLSearchParams();
|
|
4258
|
-
q.set("player_email",
|
|
4259
|
-
if (
|
|
4260
|
-
if (
|
|
4261
|
-
if (
|
|
4262
|
-
q.set("types",
|
|
4450
|
+
q.set("player_email", query2.playerEmail.trim());
|
|
4451
|
+
if (query2.limit !== void 0) q.set("limit", String(query2.limit));
|
|
4452
|
+
if (query2.cursor !== void 0) q.set("cursor", query2.cursor);
|
|
4453
|
+
if (query2.types && query2.types.length > 0) {
|
|
4454
|
+
q.set("types", query2.types.map((t) => t.trim()).join(","));
|
|
4263
4455
|
}
|
|
4264
4456
|
const raw = await this.http.get(
|
|
4265
4457
|
`/api/sdk/players/activity?${q.toString()}`,
|
|
@@ -4269,7 +4461,7 @@ var InvoServer = class {
|
|
|
4269
4461
|
const activity = Array.isArray(raw["activity"]) ? raw["activity"].map(toPlayerActivityEntry) : [];
|
|
4270
4462
|
const nextCursor = nextCursorOf(raw);
|
|
4271
4463
|
return {
|
|
4272
|
-
playerEmail: String(raw["player_email"] ??
|
|
4464
|
+
playerEmail: String(raw["player_email"] ?? query2.playerEmail.trim()),
|
|
4273
4465
|
gameId: String(raw["game_id"] ?? ""),
|
|
4274
4466
|
types: Array.isArray(raw["types"]) ? raw["types"].map(String) : [],
|
|
4275
4467
|
activity,
|
|
@@ -4287,12 +4479,12 @@ var InvoServer = class {
|
|
|
4287
4479
|
* for await (const row of invo.iteratePlayerActivity({ playerEmail, types: ["send", "transfer"] })) { … }
|
|
4288
4480
|
* ```
|
|
4289
4481
|
*/
|
|
4290
|
-
async *iteratePlayerActivity(
|
|
4482
|
+
async *iteratePlayerActivity(query2, opts) {
|
|
4291
4483
|
let cursor;
|
|
4292
4484
|
const seen = /* @__PURE__ */ new Set();
|
|
4293
4485
|
for (; ; ) {
|
|
4294
4486
|
const page = await this.getPlayerActivity(
|
|
4295
|
-
{ playerEmail:
|
|
4487
|
+
{ playerEmail: query2.playerEmail, types: query2.types, limit: query2.pageSize, cursor },
|
|
4296
4488
|
opts
|
|
4297
4489
|
);
|
|
4298
4490
|
for (const row of page.activity) yield row;
|
|
@@ -4309,11 +4501,11 @@ var InvoServer = class {
|
|
|
4309
4501
|
* browser `InvoClient.getBalance()` (token-authed, identity from the token) for a
|
|
4310
4502
|
* client-side read, or `playerEmail` here server-side.
|
|
4311
4503
|
*/
|
|
4312
|
-
async getPlayerBalance(
|
|
4504
|
+
async getPlayerBalance(query2, opts) {
|
|
4313
4505
|
let path;
|
|
4314
|
-
if (typeof
|
|
4315
|
-
path = `/api/player-balances/player/by-email/${encodeURIComponent(
|
|
4316
|
-
} else if (
|
|
4506
|
+
if (typeof query2.playerEmail === "string" && query2.playerEmail.trim()) {
|
|
4507
|
+
path = `/api/player-balances/player/by-email/${encodeURIComponent(query2.playerEmail)}`;
|
|
4508
|
+
} else if (query2.playerId != null && String(query2.playerId).trim()) {
|
|
4317
4509
|
throw new InvoError({
|
|
4318
4510
|
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
4511
|
code: "INVALID_INPUT",
|
|
@@ -4352,7 +4544,7 @@ var InvoServer = class {
|
|
|
4352
4544
|
*/
|
|
4353
4545
|
async getPlayerRewards(playerEmail, opts) {
|
|
4354
4546
|
if (typeof playerEmail !== "string" || !playerEmail.trim()) {
|
|
4355
|
-
throw
|
|
4547
|
+
throw invalidInput2("playerEmail", playerEmail, "is required");
|
|
4356
4548
|
}
|
|
4357
4549
|
const raw = await this.http.get(
|
|
4358
4550
|
`/api/sdk/loyalty/players/rewards?player_email=${encodeURIComponent(playerEmail.trim())}`,
|
|
@@ -4368,15 +4560,15 @@ var InvoServer = class {
|
|
|
4368
4560
|
* which is null when the phone maps to more than one of your players). Pairs with the
|
|
4369
4561
|
* `transfer.claim_pending` webhook (the webhook is the wake-up; this is the list).
|
|
4370
4562
|
*/
|
|
4371
|
-
async getInboundPending(
|
|
4372
|
-
const hasEmail = typeof
|
|
4373
|
-
const hasPhone = typeof
|
|
4563
|
+
async getInboundPending(query2, opts) {
|
|
4564
|
+
const hasEmail = typeof query2.playerEmail === "string" && query2.playerEmail.trim();
|
|
4565
|
+
const hasPhone = typeof query2.playerPhone === "string" && query2.playerPhone.trim();
|
|
4374
4566
|
if (!hasEmail && !hasPhone) {
|
|
4375
|
-
throw
|
|
4567
|
+
throw invalidInput2("query", query2, "requires a playerEmail or playerPhone");
|
|
4376
4568
|
}
|
|
4377
4569
|
const q = new URLSearchParams();
|
|
4378
|
-
if (hasEmail) q.set("player_email",
|
|
4379
|
-
if (hasPhone) q.set("player_phone",
|
|
4570
|
+
if (hasEmail) q.set("player_email", query2.playerEmail.trim());
|
|
4571
|
+
if (hasPhone) q.set("player_phone", query2.playerPhone.trim());
|
|
4380
4572
|
const raw = await this.http.get(
|
|
4381
4573
|
`/api/transfers/inbound-pending?${q.toString()}`,
|
|
4382
4574
|
this.auth,
|
|
@@ -4393,11 +4585,11 @@ var InvoServer = class {
|
|
|
4393
4585
|
*
|
|
4394
4586
|
* ⚠️ Returns first-party PII (emails/phones) — never expose this to the browser.
|
|
4395
4587
|
*/
|
|
4396
|
-
async getLinkedIdentities(
|
|
4397
|
-
const phone = typeof
|
|
4398
|
-
const email = typeof
|
|
4588
|
+
async getLinkedIdentities(query2, opts) {
|
|
4589
|
+
const phone = typeof query2.playerPhone === "string" && query2.playerPhone.trim() ? query2.playerPhone.trim() : "";
|
|
4590
|
+
const email = typeof query2.playerEmail === "string" && query2.playerEmail.trim() ? query2.playerEmail.trim() : "";
|
|
4399
4591
|
if (!phone && !email) {
|
|
4400
|
-
throw
|
|
4592
|
+
throw invalidInput2("query", query2, "requires a playerEmail or playerPhone");
|
|
4401
4593
|
}
|
|
4402
4594
|
const q = new URLSearchParams();
|
|
4403
4595
|
if (phone) q.set("player_phone", phone);
|
|
@@ -4447,10 +4639,10 @@ var InvoServer = class {
|
|
|
4447
4639
|
*/
|
|
4448
4640
|
async verifySmsTransfer(transactionId, smsPin, opts) {
|
|
4449
4641
|
if (typeof transactionId !== "string" || !transactionId.trim()) {
|
|
4450
|
-
throw
|
|
4642
|
+
throw invalidInput2("transactionId", transactionId, "is required");
|
|
4451
4643
|
}
|
|
4452
4644
|
if (typeof smsPin !== "string" || !smsPin.trim()) {
|
|
4453
|
-
throw
|
|
4645
|
+
throw invalidInput2("smsPin", smsPin, "is required");
|
|
4454
4646
|
}
|
|
4455
4647
|
const raw = await this.http.post(
|
|
4456
4648
|
"/api/transfers/verify-sms",
|
|
@@ -4472,10 +4664,10 @@ var InvoServer = class {
|
|
|
4472
4664
|
*/
|
|
4473
4665
|
async verifySmsSend(transactionId, smsPin, opts) {
|
|
4474
4666
|
if (typeof transactionId !== "string" || !transactionId.trim()) {
|
|
4475
|
-
throw
|
|
4667
|
+
throw invalidInput2("transactionId", transactionId, "is required");
|
|
4476
4668
|
}
|
|
4477
4669
|
if (typeof smsPin !== "string" || !smsPin.trim()) {
|
|
4478
|
-
throw
|
|
4670
|
+
throw invalidInput2("smsPin", smsPin, "is required");
|
|
4479
4671
|
}
|
|
4480
4672
|
const raw = await this.http.post(
|
|
4481
4673
|
"/api/currency-sends/verify-sms",
|
|
@@ -4536,7 +4728,7 @@ var InvoServer = class {
|
|
|
4536
4728
|
/** Read a TRANSFER's status (verification_state + amounts + destination). */
|
|
4537
4729
|
async getTransferStatus(transactionId, opts) {
|
|
4538
4730
|
if (typeof transactionId !== "string" || !transactionId.trim()) {
|
|
4539
|
-
throw
|
|
4731
|
+
throw invalidInput2("transactionId", transactionId, "is required");
|
|
4540
4732
|
}
|
|
4541
4733
|
const raw = await this.http.get(
|
|
4542
4734
|
`/api/transfers/${encodeURIComponent(transactionId)}/status`,
|
|
@@ -4548,7 +4740,7 @@ var InvoServer = class {
|
|
|
4548
4740
|
/** Read a SEND's status (adds fees, game names, claim_info, … on `raw`). */
|
|
4549
4741
|
async getSendStatus(transactionId, opts) {
|
|
4550
4742
|
if (typeof transactionId !== "string" || !transactionId.trim()) {
|
|
4551
|
-
throw
|
|
4743
|
+
throw invalidInput2("transactionId", transactionId, "is required");
|
|
4552
4744
|
}
|
|
4553
4745
|
const raw = await this.http.get(
|
|
4554
4746
|
`/api/currency-sends/${encodeURIComponent(transactionId)}/status`,
|
|
@@ -4564,7 +4756,7 @@ var InvoServer = class {
|
|
|
4564
4756
|
*/
|
|
4565
4757
|
async getGuardianApprovalStatus(transactionId, opts) {
|
|
4566
4758
|
if (typeof transactionId !== "string" || !transactionId.trim()) {
|
|
4567
|
-
throw
|
|
4759
|
+
throw invalidInput2("transactionId", transactionId, "is required");
|
|
4568
4760
|
}
|
|
4569
4761
|
const raw = await this.http.get(
|
|
4570
4762
|
`/api/transactions/${encodeURIComponent(transactionId)}/approval-status`,
|
|
@@ -4580,15 +4772,15 @@ var InvoServer = class {
|
|
|
4580
4772
|
* the source game is passed explicitly rather than inferred from a player token. Rows
|
|
4581
4773
|
* share the browser shape. Idempotent (a POST read — safe to retry).
|
|
4582
4774
|
*/
|
|
4583
|
-
async getDestinations(
|
|
4584
|
-
if (
|
|
4585
|
-
throw
|
|
4775
|
+
async getDestinations(query2, opts) {
|
|
4776
|
+
if (query2.sourceGameId == null || String(query2.sourceGameId).trim() === "") {
|
|
4777
|
+
throw invalidInput2("sourceGameId", query2.sourceGameId, "is required");
|
|
4586
4778
|
}
|
|
4587
|
-
const direction =
|
|
4779
|
+
const direction = query2.direction ?? "transfer";
|
|
4588
4780
|
const path = direction === "send" ? "/api/currency-sends/available-destinations" : "/api/transfers/available-destinations";
|
|
4589
4781
|
const raw = await this.http.post(
|
|
4590
4782
|
path,
|
|
4591
|
-
{ source_game_id:
|
|
4783
|
+
{ source_game_id: query2.sourceGameId },
|
|
4592
4784
|
this.auth,
|
|
4593
4785
|
{ idempotent: true, signal: opts?.signal }
|
|
4594
4786
|
// a POST read — no side effect, safe to retry
|
|
@@ -4607,10 +4799,10 @@ var InvoServer = class {
|
|
|
4607
4799
|
*/
|
|
4608
4800
|
async phoneShareInitiate(input, opts) {
|
|
4609
4801
|
if (typeof input.phone !== "string" || !input.phone.trim()) {
|
|
4610
|
-
throw
|
|
4802
|
+
throw invalidInput2("phone", input.phone, "is required");
|
|
4611
4803
|
}
|
|
4612
4804
|
if (typeof input.email !== "string" || !input.email.trim()) {
|
|
4613
|
-
throw
|
|
4805
|
+
throw invalidInput2("email", input.email, "is required");
|
|
4614
4806
|
}
|
|
4615
4807
|
const raw = await this.http.post(
|
|
4616
4808
|
"/api/wallet/phone-share/initiate",
|
|
@@ -4630,10 +4822,10 @@ var InvoServer = class {
|
|
|
4630
4822
|
*/
|
|
4631
4823
|
async phoneShareApprove(input, opts) {
|
|
4632
4824
|
if (typeof input.approvalId !== "string" || !input.approvalId.trim()) {
|
|
4633
|
-
throw
|
|
4825
|
+
throw invalidInput2("approvalId", input.approvalId, "is required");
|
|
4634
4826
|
}
|
|
4635
4827
|
if (typeof input.otp !== "string" || !input.otp.trim()) {
|
|
4636
|
-
throw
|
|
4828
|
+
throw invalidInput2("otp", input.otp, "is required");
|
|
4637
4829
|
}
|
|
4638
4830
|
const raw = await this.http.post(
|
|
4639
4831
|
"/api/wallet/phone-share/approve",
|
|
@@ -4652,10 +4844,10 @@ var InvoServer = class {
|
|
|
4652
4844
|
*/
|
|
4653
4845
|
async phoneShareStatus(input, opts) {
|
|
4654
4846
|
if (typeof input.phone !== "string" || !input.phone.trim()) {
|
|
4655
|
-
throw
|
|
4847
|
+
throw invalidInput2("phone", input.phone, "is required");
|
|
4656
4848
|
}
|
|
4657
4849
|
if (typeof input.email !== "string" || !input.email.trim()) {
|
|
4658
|
-
throw
|
|
4850
|
+
throw invalidInput2("email", input.email, "is required");
|
|
4659
4851
|
}
|
|
4660
4852
|
const q = new URLSearchParams();
|
|
4661
4853
|
q.set("phone", input.phone);
|
|
@@ -4693,12 +4885,12 @@ var InvoServer = class {
|
|
|
4693
4885
|
async beginDeviceApproval(input, opts) {
|
|
4694
4886
|
assertPlayerToken(input.playerToken);
|
|
4695
4887
|
if (typeof input.transactionId !== "string" || !input.transactionId.trim()) {
|
|
4696
|
-
throw
|
|
4888
|
+
throw invalidInput2("transactionId", input.transactionId, "is required");
|
|
4697
4889
|
}
|
|
4698
4890
|
assertDeviceApprovalFlow(input.flow);
|
|
4699
4891
|
const channel = input.channel ?? "qr";
|
|
4700
4892
|
if (!DEVICE_APPROVAL_CHANNELS.has(channel)) {
|
|
4701
|
-
throw
|
|
4893
|
+
throw invalidInput2("channel", channel, 'must be "qr" | "app_browser" ("popup" is browser-only)');
|
|
4702
4894
|
}
|
|
4703
4895
|
if (channel === "popup") {
|
|
4704
4896
|
throw new InvoError({
|
|
@@ -4736,7 +4928,7 @@ var InvoServer = class {
|
|
|
4736
4928
|
async pollDeviceApproval(input, opts) {
|
|
4737
4929
|
assertPlayerToken(input.playerToken);
|
|
4738
4930
|
if (typeof input.deviceCode !== "string" || !input.deviceCode.trim()) {
|
|
4739
|
-
throw
|
|
4931
|
+
throw invalidInput2("deviceCode", input.deviceCode, "is required (from beginDeviceApproval)");
|
|
4740
4932
|
}
|
|
4741
4933
|
let raw;
|
|
4742
4934
|
try {
|
|
@@ -4774,10 +4966,10 @@ var InvoServer = class {
|
|
|
4774
4966
|
async confirmDeviceEnrollment(input, opts) {
|
|
4775
4967
|
assertPlayerToken(input.playerToken);
|
|
4776
4968
|
if (typeof input.deviceCode !== "string" || !input.deviceCode.trim()) {
|
|
4777
|
-
throw
|
|
4969
|
+
throw invalidInput2("deviceCode", input.deviceCode, "is required (from beginDeviceApproval)");
|
|
4778
4970
|
}
|
|
4779
4971
|
if (input.decision !== "approve" && input.decision !== "deny") {
|
|
4780
|
-
throw
|
|
4972
|
+
throw invalidInput2("decision", input.decision, 'must be "approve" or "deny"');
|
|
4781
4973
|
}
|
|
4782
4974
|
const raw = await this.http.post(
|
|
4783
4975
|
"/api/sdk/approvals/device/confirm-enrollment",
|
|
@@ -4828,11 +5020,11 @@ var InvoServer = class {
|
|
|
4828
5020
|
async approveWithDeviceCode(input, opts) {
|
|
4829
5021
|
assertPlayerToken(input.playerToken);
|
|
4830
5022
|
if (typeof input.transactionId !== "string" || !input.transactionId.trim()) {
|
|
4831
|
-
throw
|
|
5023
|
+
throw invalidInput2("transactionId", input.transactionId, "is required");
|
|
4832
5024
|
}
|
|
4833
5025
|
assertDeviceApprovalFlow(input.flow);
|
|
4834
5026
|
if (typeof input.deviceCode !== "string" || !input.deviceCode.trim()) {
|
|
4835
|
-
throw
|
|
5027
|
+
throw invalidInput2("deviceCode", input.deviceCode, "is required (from beginDeviceApproval)");
|
|
4836
5028
|
}
|
|
4837
5029
|
let raw;
|
|
4838
5030
|
try {
|
|
@@ -4890,11 +5082,11 @@ var InvoServer = class {
|
|
|
4890
5082
|
async completeDeviceApproval(input, opts) {
|
|
4891
5083
|
assertPlayerToken(input.playerToken);
|
|
4892
5084
|
if (typeof input.transactionId !== "string" || !input.transactionId.trim()) {
|
|
4893
|
-
throw
|
|
5085
|
+
throw invalidInput2("transactionId", input.transactionId, "is required");
|
|
4894
5086
|
}
|
|
4895
5087
|
assertDeviceApprovalFlow(input.flow);
|
|
4896
5088
|
if (typeof input.deviceCode !== "string" || !input.deviceCode.trim()) {
|
|
4897
|
-
throw
|
|
5089
|
+
throw invalidInput2("deviceCode", input.deviceCode, "is required (from beginDeviceApproval)");
|
|
4898
5090
|
}
|
|
4899
5091
|
const signal = input.signal ?? opts?.signal;
|
|
4900
5092
|
const { playerToken, deviceCode } = input;
|
|
@@ -4982,6 +5174,7 @@ var InvoServer = class {
|
|
|
4982
5174
|
exports.CardsServer = CardsServer;
|
|
4983
5175
|
exports.InvoError = InvoError;
|
|
4984
5176
|
exports.InvoServer = InvoServer;
|
|
5177
|
+
exports.PayoutsServer = PayoutsServer;
|
|
4985
5178
|
exports.PlatformCommerceServer = PlatformCommerceServer;
|
|
4986
5179
|
exports.SDK_VERSION = SDK_VERSION;
|
|
4987
5180
|
exports.SandboxServer = SandboxServer;
|