@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.js
CHANGED
|
@@ -3,7 +3,198 @@ export { InvoError } from './chunk-7BYAUHTA.js';
|
|
|
3
3
|
import { createHmac, timingSafeEqual } from 'crypto';
|
|
4
4
|
|
|
5
5
|
// src/version.ts
|
|
6
|
-
var SDK_VERSION = "3.
|
|
6
|
+
var SDK_VERSION = "3.26.0";
|
|
7
|
+
|
|
8
|
+
// src/payouts.ts
|
|
9
|
+
var AMOUNT = /^\d+(\.\d{1,2})?$/;
|
|
10
|
+
function invalidInput(label, value, why) {
|
|
11
|
+
return new InvoError({
|
|
12
|
+
message: `${label} ${why} (got ${JSON.stringify(value)}).`,
|
|
13
|
+
code: "INVALID_INPUT",
|
|
14
|
+
status: 0
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function requireText(label, value) {
|
|
18
|
+
if (typeof value !== "string" || !value.trim()) throw invalidInput(label, value, "is required");
|
|
19
|
+
return value.trim();
|
|
20
|
+
}
|
|
21
|
+
function amountString(value) {
|
|
22
|
+
const s = typeof value === "number" ? Number.isFinite(value) ? String(value) : "" : String(value ?? "").trim();
|
|
23
|
+
if (!AMOUNT.test(s) || Number(s) <= 0) {
|
|
24
|
+
throw invalidInput("amountUsd", value, "must be a positive amount with at most two decimal places");
|
|
25
|
+
}
|
|
26
|
+
return s;
|
|
27
|
+
}
|
|
28
|
+
function query(params) {
|
|
29
|
+
const parts = [];
|
|
30
|
+
for (const [k, v] of Object.entries(params)) {
|
|
31
|
+
if (v === void 0 || v === "") continue;
|
|
32
|
+
parts.push(`${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`);
|
|
33
|
+
}
|
|
34
|
+
return parts.length ? `?${parts.join("&")}` : "";
|
|
35
|
+
}
|
|
36
|
+
function payeePath(payeeId) {
|
|
37
|
+
return `/api/partner-payees/${encodeURIComponent(requireText("payeeId", payeeId))}`;
|
|
38
|
+
}
|
|
39
|
+
function payoutId(id) {
|
|
40
|
+
if (!Number.isInteger(id) || id <= 0) throw invalidInput("payoutId", id, "must be a positive integer");
|
|
41
|
+
return id;
|
|
42
|
+
}
|
|
43
|
+
var PayoutsServer = class {
|
|
44
|
+
constructor(http, auth) {
|
|
45
|
+
this.http = http;
|
|
46
|
+
this.auth = auth;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Register a creator (`POST /api/partner-payees`). INVO emails the creator a link to INVO's
|
|
50
|
+
* own page to give INVO their identity, tax and bank details. `invite.sent` is `false` when
|
|
51
|
+
* INVO did not email the link (`invite.error_code` says why); the creator is registered
|
|
52
|
+
* either way. Refusals: `409 PARTNER_REFERENCE_CONFLICT`, `400 INVALID_INPUT`,
|
|
53
|
+
* `400 COUNTRY_NOT_SUPPORTED`.
|
|
54
|
+
*/
|
|
55
|
+
async registerPayee(input, opts) {
|
|
56
|
+
if (input.payeeType !== "individual" && input.payeeType !== "business") {
|
|
57
|
+
throw invalidInput("payeeType", input.payeeType, 'must be "individual" or "business"');
|
|
58
|
+
}
|
|
59
|
+
const raw = await this.http.post(
|
|
60
|
+
"/api/partner-payees",
|
|
61
|
+
{
|
|
62
|
+
partner_reference: requireText("partnerReference", input.partnerReference),
|
|
63
|
+
legal_name: requireText("legalName", input.legalName),
|
|
64
|
+
email: requireText("email", input.email),
|
|
65
|
+
country: requireText("country", input.country),
|
|
66
|
+
payee_type: input.payeeType
|
|
67
|
+
},
|
|
68
|
+
this.auth,
|
|
69
|
+
{ idempotent: true, signal: opts?.signal }
|
|
70
|
+
);
|
|
71
|
+
return {
|
|
72
|
+
payee: raw["payee"],
|
|
73
|
+
invite: raw["invite"],
|
|
74
|
+
duplicate: raw["duplicate"] === true,
|
|
75
|
+
raw
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** This game's creators, newest first (`GET /api/partner-payees`). */
|
|
79
|
+
async listPayees(q = {}, opts) {
|
|
80
|
+
const raw = await this.http.get(
|
|
81
|
+
`/api/partner-payees${query({ limit: q.limit, offset: q.offset, status: q.status })}`,
|
|
82
|
+
this.auth,
|
|
83
|
+
{ signal: opts?.signal }
|
|
84
|
+
);
|
|
85
|
+
return {
|
|
86
|
+
total: Number(raw["total"] ?? 0),
|
|
87
|
+
limit: Number(raw["limit"] ?? 0),
|
|
88
|
+
offset: Number(raw["offset"] ?? 0),
|
|
89
|
+
items: raw["items"] ?? [],
|
|
90
|
+
raw
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** One creator (`GET /api/partner-payees/{payeeId}`); `404 NOT_FOUND` if not this game's. */
|
|
94
|
+
async getPayee(payeeId, opts) {
|
|
95
|
+
const raw = await this.http.get(payeePath(payeeId), this.auth, {
|
|
96
|
+
signal: opts?.signal
|
|
97
|
+
});
|
|
98
|
+
return raw["payee"];
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Email the creator a new link (`POST /api/partner-payees/{payeeId}/resend-invite`); the old
|
|
102
|
+
* link stops working. Allowed while the creator is `invited`, `rejected` or `expired`
|
|
103
|
+
* (`409 INVITE_NOT_NEEDED` otherwise); `409 PAYEE_ERASED`; `429 INVITE_RATE_LIMITED` with
|
|
104
|
+
* `retry_after_seconds`. If INVO asked the creator to update their details, the resend sends
|
|
105
|
+
* INVO's update notice again. Never auto-retried.
|
|
106
|
+
*/
|
|
107
|
+
async resendPayeeInvite(payeeId, opts) {
|
|
108
|
+
const raw = await this.http.post(
|
|
109
|
+
`${payeePath(payeeId)}/resend-invite`,
|
|
110
|
+
void 0,
|
|
111
|
+
this.auth,
|
|
112
|
+
{ signal: opts?.signal }
|
|
113
|
+
);
|
|
114
|
+
return raw["invite"];
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Remove a creator from your program (`POST /api/partner-payees/{payeeId}/remove`, 3.26.0).
|
|
118
|
+
* The status becomes `closed`. `409 PAYEE_HAS_PAYOUTS_IN_FLIGHT` while a payout to them is in
|
|
119
|
+
* progress, `409 ALREADY_CLOSED`, `409 PAYEE_NOT_CLOSABLE`. Not a block: the same person can
|
|
120
|
+
* be registered again under a new reference. Never auto-retried.
|
|
121
|
+
*/
|
|
122
|
+
async removePayee(payeeId, opts) {
|
|
123
|
+
const raw = await this.http.post(
|
|
124
|
+
`${payeePath(payeeId)}/remove`,
|
|
125
|
+
void 0,
|
|
126
|
+
this.auth,
|
|
127
|
+
{ signal: opts?.signal }
|
|
128
|
+
);
|
|
129
|
+
return raw["payee"];
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Ask INVO to pay out (`POST /api/partner-payouts/request`). Send exactly one of `payeeId`
|
|
133
|
+
* (INVO pays that verified creator's bank account) or `bankAccountId` (your own verified bank
|
|
134
|
+
* account). The money comes from the earnings INVO owes your game, and the payout fee is
|
|
135
|
+
* taken from the payout. Creator refusals: `404 PAYEE_NOT_FOUND`, `409 PAYEE_NOT_VERIFIED`,
|
|
136
|
+
* `409 PAYEE_VERIFICATION_EXPIRED`, `409 PAYEE_BANK_NOT_VERIFIED`, `409 PAYEE_CLOSED`,
|
|
137
|
+
* `409 PAYEE_NOT_PAYABLE` (can't be paid right now; no action needed; try again later),
|
|
138
|
+
* `409 IDEMPOTENCY_KEY_REUSED`. The first payout to a creator registered with the game key
|
|
139
|
+
* carries `owner_confirmation_required: true`. Retried safely only when `clientRequestId` is
|
|
140
|
+
* set.
|
|
141
|
+
*/
|
|
142
|
+
async requestPayout(input, opts) {
|
|
143
|
+
if (input.payeeId !== void 0 && input.bankAccountId !== void 0) {
|
|
144
|
+
throw invalidInput("bankAccountId", input.bankAccountId, "must not be sent with payeeId");
|
|
145
|
+
}
|
|
146
|
+
const body = {
|
|
147
|
+
amount_usd: amountString(input.amountUsd),
|
|
148
|
+
contact_email: requireText("contactEmail", input.contactEmail)
|
|
149
|
+
};
|
|
150
|
+
if (input.payeeId !== void 0) body["payee_id"] = requireText("payeeId", input.payeeId);
|
|
151
|
+
if (input.bankAccountId !== void 0) body["bank_account_id"] = input.bankAccountId;
|
|
152
|
+
if (input.clientRequestId !== void 0) body["client_request_id"] = requireText("clientRequestId", input.clientRequestId);
|
|
153
|
+
if (input.partnerNote !== void 0) body["partner_note"] = input.partnerNote;
|
|
154
|
+
if (input.additionalEmails !== void 0) body["additional_emails"] = input.additionalEmails;
|
|
155
|
+
const raw = await this.http.post("/api/partner-payouts/request", body, this.auth, {
|
|
156
|
+
idempotent: input.clientRequestId !== void 0,
|
|
157
|
+
signal: opts?.signal
|
|
158
|
+
});
|
|
159
|
+
return {
|
|
160
|
+
payout: raw["payout_request"],
|
|
161
|
+
duplicate: raw["duplicate"] === true,
|
|
162
|
+
raw
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
/** One payout (`GET /api/partner-payouts/{payoutId}`). */
|
|
166
|
+
async getPayout(payoutIdValue, opts) {
|
|
167
|
+
const raw = await this.http.get(
|
|
168
|
+
`/api/partner-payouts/${payoutId(payoutIdValue)}`,
|
|
169
|
+
this.auth,
|
|
170
|
+
{ signal: opts?.signal }
|
|
171
|
+
);
|
|
172
|
+
return raw["payout_request"];
|
|
173
|
+
}
|
|
174
|
+
/** Your payouts (`GET /api/partner-payouts`), optionally one creator's (`payeeId`). */
|
|
175
|
+
async listPayouts(q = {}, opts) {
|
|
176
|
+
const raw = await this.http.get(
|
|
177
|
+
`/api/partner-payouts${query({ limit: q.limit, offset: q.offset, status: q.status, payee_id: q.payeeId })}`,
|
|
178
|
+
this.auth,
|
|
179
|
+
{ signal: opts?.signal }
|
|
180
|
+
);
|
|
181
|
+
return { total: Number(raw["total"] ?? 0), items: raw["items"] ?? [], raw };
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Cancel a creator payout that is still `requested`
|
|
185
|
+
* (`POST /api/partner-payouts/{payoutId}/cancel`). Anything past `requested` is
|
|
186
|
+
* `409 PAYOUT_NOT_CANCELLABLE`; a payout to your own bank is `404 NOT_FOUND`.
|
|
187
|
+
*/
|
|
188
|
+
async cancelPayout(payoutIdValue, opts) {
|
|
189
|
+
const raw = await this.http.post(
|
|
190
|
+
`/api/partner-payouts/${payoutId(payoutIdValue)}/cancel`,
|
|
191
|
+
void 0,
|
|
192
|
+
this.auth,
|
|
193
|
+
{ signal: opts?.signal }
|
|
194
|
+
);
|
|
195
|
+
return raw["payout_request"] ?? raw["payout"];
|
|
196
|
+
}
|
|
197
|
+
};
|
|
7
198
|
|
|
8
199
|
// src/shared/types.ts
|
|
9
200
|
function isRefundPendingApproval(r) {
|
|
@@ -271,7 +462,7 @@ function pricingFields(raw, fallback = {}) {
|
|
|
271
462
|
if (warning !== void 0) out.minPurchaseWarning = warning;
|
|
272
463
|
return out;
|
|
273
464
|
}
|
|
274
|
-
function
|
|
465
|
+
function invalidInput2(label, value, why) {
|
|
275
466
|
return new InvoError({
|
|
276
467
|
message: `${label} ${why} (got ${JSON.stringify(value)}).`,
|
|
277
468
|
code: "INVALID_INPUT",
|
|
@@ -283,17 +474,17 @@ function parseMoney(value, max, label) {
|
|
|
283
474
|
let n;
|
|
284
475
|
if (typeof value === "number") {
|
|
285
476
|
if (!Number.isFinite(value) || !PLAIN_DECIMAL.test(String(value))) {
|
|
286
|
-
throw
|
|
477
|
+
throw invalidInput2(label, value, "must be a positive decimal with at most 2 places");
|
|
287
478
|
}
|
|
288
479
|
n = value;
|
|
289
480
|
} else {
|
|
290
481
|
if (!PLAIN_DECIMAL.test(value)) {
|
|
291
|
-
throw
|
|
482
|
+
throw invalidInput2(label, value, "must be a plain decimal value with at most 2 places");
|
|
292
483
|
}
|
|
293
484
|
n = Number(value);
|
|
294
485
|
}
|
|
295
486
|
if (!Number.isFinite(n) || n <= 0 || n > max) {
|
|
296
|
-
throw
|
|
487
|
+
throw invalidInput2(label, value, `must be > 0 and <= ${max}`);
|
|
297
488
|
}
|
|
298
489
|
return n;
|
|
299
490
|
}
|
|
@@ -303,7 +494,7 @@ function assertUsdAmount(usdAmount) {
|
|
|
303
494
|
var E164 = /^\+[1-9]\d{1,14}$/;
|
|
304
495
|
function assertE164(value, label) {
|
|
305
496
|
if (typeof value !== "string" || !E164.test(value)) {
|
|
306
|
-
throw
|
|
497
|
+
throw invalidInput2(label, value, 'must be an E.164 phone number, e.g. "+15555550100"');
|
|
307
498
|
}
|
|
308
499
|
}
|
|
309
500
|
function sessionTokenFromCreateCheckout(raw, checkoutUrl) {
|
|
@@ -392,13 +583,13 @@ function toTransactionStatus(raw) {
|
|
|
392
583
|
function assertPageLimit(limit) {
|
|
393
584
|
if (limit === void 0) return;
|
|
394
585
|
if (typeof limit !== "number" || !Number.isInteger(limit) || limit < 1) {
|
|
395
|
-
throw
|
|
586
|
+
throw invalidInput2("limit", limit, "must be a positive integer (INVO caps it at 100)");
|
|
396
587
|
}
|
|
397
588
|
}
|
|
398
589
|
function assertCursor(cursor) {
|
|
399
590
|
if (cursor === void 0) return;
|
|
400
591
|
if (typeof cursor !== "string" || !cursor.trim()) {
|
|
401
|
-
throw
|
|
592
|
+
throw invalidInput2("cursor", cursor, "must be the previous page's nextCursor");
|
|
402
593
|
}
|
|
403
594
|
}
|
|
404
595
|
function strOrNull(v) {
|
|
@@ -535,12 +726,12 @@ function isPastThisStep(flow, currentStatus) {
|
|
|
535
726
|
}
|
|
536
727
|
function assertPlayerToken(playerToken) {
|
|
537
728
|
if (typeof playerToken !== "string" || !playerToken.trim()) {
|
|
538
|
-
throw
|
|
729
|
+
throw invalidInput2("playerToken", playerToken, "is required (the player's session token, not the game secret)");
|
|
539
730
|
}
|
|
540
731
|
}
|
|
541
732
|
function assertDeviceApprovalFlow(flow) {
|
|
542
733
|
if (typeof flow !== "string" || !DEVICE_APPROVAL_FLOWS.has(flow)) {
|
|
543
|
-
throw
|
|
734
|
+
throw invalidInput2("flow", flow, 'must be "transfer" | "send" | "send_receipt" | "transfer_receipt"');
|
|
544
735
|
}
|
|
545
736
|
}
|
|
546
737
|
function toDeviceApprovalGrant(raw) {
|
|
@@ -680,20 +871,20 @@ var PlatformCommerceServer = class {
|
|
|
680
871
|
["itemName", input.itemName]
|
|
681
872
|
];
|
|
682
873
|
for (const [k, v] of required) {
|
|
683
|
-
if (typeof v !== "string" || !v.trim()) throw
|
|
874
|
+
if (typeof v !== "string" || !v.trim()) throw invalidInput2(k, v, "is required");
|
|
684
875
|
}
|
|
685
876
|
if (!FUNDING_SOURCES.has(input.fundingSource)) {
|
|
686
|
-
throw
|
|
877
|
+
throw invalidInput2("fundingSource", input.fundingSource, 'must be "balance" or "card"');
|
|
687
878
|
}
|
|
688
879
|
if (!Number.isInteger(input.itemQuantity) || input.itemQuantity < 1 || input.itemQuantity > 1e3) {
|
|
689
|
-
throw
|
|
880
|
+
throw invalidInput2("itemQuantity", input.itemQuantity, "must be an integer 1..1000");
|
|
690
881
|
}
|
|
691
882
|
const unit = parseMoney(input.unitPrice, MAX_ITEM_PRICE, "unitPrice");
|
|
692
883
|
const total = parseMoney(input.totalPrice, MAX_ITEM_PRICE, "totalPrice");
|
|
693
884
|
const expectedCents = Math.round(unit * input.itemQuantity * 100);
|
|
694
885
|
const totalCents = Math.round(total * 100);
|
|
695
886
|
if (Math.abs(totalCents - expectedCents) > 1) {
|
|
696
|
-
throw
|
|
887
|
+
throw invalidInput2(
|
|
697
888
|
"totalPrice",
|
|
698
889
|
input.totalPrice,
|
|
699
890
|
`must equal unitPrice \xD7 itemQuantity (\xB10.01): ${unit} \xD7 ${input.itemQuantity}`
|
|
@@ -764,7 +955,7 @@ var PlatformCommerceServer = class {
|
|
|
764
955
|
* `pending_payment` (card awaiting confirmation), or `refunded`. */
|
|
765
956
|
async getStatus(orderId, opts) {
|
|
766
957
|
if (orderId == null || String(orderId).trim() === "") {
|
|
767
|
-
throw
|
|
958
|
+
throw invalidInput2("orderId", orderId, "is required");
|
|
768
959
|
}
|
|
769
960
|
const raw = await this.http.get(
|
|
770
961
|
`/api/platform-commerce/purchase-status/${encodeURIComponent(String(orderId))}`,
|
|
@@ -787,16 +978,16 @@ var PlatformCommerceServer = class {
|
|
|
787
978
|
* tenant (`err.isNotPlatformTenant`), `429` (back off; `err.retryAfter`). A GET, so
|
|
788
979
|
* transient failures are retried automatically.
|
|
789
980
|
*/
|
|
790
|
-
async getPurchaseHistory(
|
|
791
|
-
if (typeof
|
|
792
|
-
throw
|
|
981
|
+
async getPurchaseHistory(query2, opts) {
|
|
982
|
+
if (typeof query2?.playerEmail !== "string" || !query2.playerEmail.trim()) {
|
|
983
|
+
throw invalidInput2("playerEmail", query2?.playerEmail, "is required");
|
|
793
984
|
}
|
|
794
|
-
assertPageLimit(
|
|
795
|
-
assertCursor(
|
|
985
|
+
assertPageLimit(query2.limit);
|
|
986
|
+
assertCursor(query2.cursor);
|
|
796
987
|
const q = new URLSearchParams();
|
|
797
|
-
q.set("player_email",
|
|
798
|
-
if (
|
|
799
|
-
if (
|
|
988
|
+
q.set("player_email", query2.playerEmail.trim());
|
|
989
|
+
if (query2.limit !== void 0) q.set("limit", String(query2.limit));
|
|
990
|
+
if (query2.cursor !== void 0) q.set("cursor", query2.cursor);
|
|
800
991
|
const raw = await this.http.get(
|
|
801
992
|
`/api/platform-commerce/purchase-history?${q.toString()}`,
|
|
802
993
|
this.auth,
|
|
@@ -805,7 +996,7 @@ var PlatformCommerceServer = class {
|
|
|
805
996
|
const purchases = Array.isArray(raw["purchases"]) ? raw["purchases"].map((r) => toPlatformOrderStatus(r)) : [];
|
|
806
997
|
const nextCursor = nextCursorOf(raw);
|
|
807
998
|
return {
|
|
808
|
-
playerEmail: String(raw["player_email"] ??
|
|
999
|
+
playerEmail: String(raw["player_email"] ?? query2.playerEmail.trim()),
|
|
809
1000
|
gameId: String(raw["game_id"] ?? ""),
|
|
810
1001
|
purchases,
|
|
811
1002
|
limit: typeof raw["limit"] === "number" ? raw["limit"] : purchases.length,
|
|
@@ -822,12 +1013,12 @@ var PlatformCommerceServer = class {
|
|
|
822
1013
|
* for await (const order of invo.platformCommerce.iteratePurchaseHistory({ playerEmail })) { … }
|
|
823
1014
|
* ```
|
|
824
1015
|
*/
|
|
825
|
-
async *iteratePurchaseHistory(
|
|
1016
|
+
async *iteratePurchaseHistory(query2, opts) {
|
|
826
1017
|
let cursor;
|
|
827
1018
|
const seen = /* @__PURE__ */ new Set();
|
|
828
1019
|
for (; ; ) {
|
|
829
1020
|
const page = await this.getPurchaseHistory(
|
|
830
|
-
{ playerEmail:
|
|
1021
|
+
{ playerEmail: query2.playerEmail, limit: query2.pageSize, cursor },
|
|
831
1022
|
opts
|
|
832
1023
|
);
|
|
833
1024
|
for (const row of page.purchases) yield row;
|
|
@@ -904,13 +1095,13 @@ var SANDBOX_FAILURE_OUTCOMES = /* @__PURE__ */ new Set([
|
|
|
904
1095
|
"error"
|
|
905
1096
|
]);
|
|
906
1097
|
function assertClientRequestId(value, label) {
|
|
907
|
-
if (typeof value !== "string" || !value.trim()) throw
|
|
908
|
-
if (value.length > 255) throw
|
|
909
|
-
if (/^sub_/i.test(value)) throw
|
|
1098
|
+
if (typeof value !== "string" || !value.trim()) throw invalidInput2(label, value, "is required");
|
|
1099
|
+
if (value.length > 255) throw invalidInput2(label, value, "must be at most 255 characters");
|
|
1100
|
+
if (/^sub_/i.test(value)) throw invalidInput2(label, value, 'must not begin with "sub_" (reserved)');
|
|
910
1101
|
}
|
|
911
1102
|
function assertSubscriptionId(value) {
|
|
912
1103
|
if (typeof value !== "string" || !value.trim()) {
|
|
913
|
-
throw
|
|
1104
|
+
throw invalidInput2("subscriptionId", value, "is required");
|
|
914
1105
|
}
|
|
915
1106
|
}
|
|
916
1107
|
function subscriptionMoney(value, label) {
|
|
@@ -1162,10 +1353,10 @@ function subscriptionBaseBody(input) {
|
|
|
1162
1353
|
["playerName", input.playerName],
|
|
1163
1354
|
["itemId", input.itemId]
|
|
1164
1355
|
]) {
|
|
1165
|
-
if (typeof v !== "string" || !v.trim()) throw
|
|
1356
|
+
if (typeof v !== "string" || !v.trim()) throw invalidInput2(k, v, "is required");
|
|
1166
1357
|
}
|
|
1167
1358
|
if (input.interval !== void 0 && !SUBSCRIPTION_INTERVALS.has(input.interval)) {
|
|
1168
|
-
throw
|
|
1359
|
+
throw invalidInput2("interval", input.interval, 'must be "month" or "year"');
|
|
1169
1360
|
}
|
|
1170
1361
|
if (input.playerPhone !== void 0) assertE164(input.playerPhone, "playerPhone");
|
|
1171
1362
|
const body = {
|
|
@@ -1198,7 +1389,7 @@ function subscriptionBaseBody(input) {
|
|
|
1198
1389
|
const hasEmail = typeof s.recipientPlayerEmail === "string" && s.recipientPlayerEmail.trim() !== "";
|
|
1199
1390
|
const hasId = s.recipientPlayerId != null;
|
|
1200
1391
|
if (hasEmail === hasId) {
|
|
1201
|
-
throw
|
|
1392
|
+
throw invalidInput2(
|
|
1202
1393
|
"revenueShare",
|
|
1203
1394
|
s,
|
|
1204
1395
|
"requires EXACTLY ONE of recipientPlayerEmail or recipientPlayerId"
|
|
@@ -1256,19 +1447,19 @@ var SubscriptionsServer = class {
|
|
|
1256
1447
|
const body = subscriptionBaseBody(input);
|
|
1257
1448
|
if (input.intervalCount !== void 0) {
|
|
1258
1449
|
if (!Number.isInteger(input.intervalCount) || input.intervalCount < 1 || input.intervalCount > 36) {
|
|
1259
|
-
throw
|
|
1450
|
+
throw invalidInput2("intervalCount", input.intervalCount, "must be an integer 1..36");
|
|
1260
1451
|
}
|
|
1261
1452
|
body["interval_count"] = input.intervalCount;
|
|
1262
1453
|
}
|
|
1263
1454
|
if (input.trialDays !== void 0) {
|
|
1264
1455
|
if (!Number.isInteger(input.trialDays) || input.trialDays < 1 || input.trialDays > 365) {
|
|
1265
|
-
throw
|
|
1456
|
+
throw invalidInput2("trialDays", input.trialDays, "must be an integer 1..365");
|
|
1266
1457
|
}
|
|
1267
1458
|
body["trial_days"] = input.trialDays;
|
|
1268
1459
|
}
|
|
1269
1460
|
if (input.trialEnd !== void 0) {
|
|
1270
1461
|
if (typeof input.trialEnd !== "string" || Number.isNaN(Date.parse(input.trialEnd))) {
|
|
1271
|
-
throw
|
|
1462
|
+
throw invalidInput2("trialEnd", input.trialEnd, "must be an ISO 8601 timestamp");
|
|
1272
1463
|
}
|
|
1273
1464
|
body["trial_end"] = input.trialEnd;
|
|
1274
1465
|
}
|
|
@@ -1291,16 +1482,16 @@ var SubscriptionsServer = class {
|
|
|
1291
1482
|
}
|
|
1292
1483
|
if (input.walletOnly !== void 0) {
|
|
1293
1484
|
if (typeof input.walletOnly !== "boolean") {
|
|
1294
|
-
throw
|
|
1485
|
+
throw invalidInput2("walletOnly", input.walletOnly, "must be a boolean");
|
|
1295
1486
|
}
|
|
1296
1487
|
body["wallet_only"] = input.walletOnly;
|
|
1297
1488
|
}
|
|
1298
1489
|
if (input.playerCardId !== void 0) {
|
|
1299
1490
|
if (!Number.isInteger(input.playerCardId) || input.playerCardId < 1) {
|
|
1300
|
-
throw
|
|
1491
|
+
throw invalidInput2("playerCardId", input.playerCardId, "must be a positive integer card id (from cards.list)");
|
|
1301
1492
|
}
|
|
1302
1493
|
if (input.walletOnly === true) {
|
|
1303
|
-
throw
|
|
1494
|
+
throw invalidInput2("playerCardId", input.playerCardId, "cannot be combined with walletOnly: true");
|
|
1304
1495
|
}
|
|
1305
1496
|
body["player_card_id"] = input.playerCardId;
|
|
1306
1497
|
}
|
|
@@ -1336,7 +1527,7 @@ var SubscriptionsServer = class {
|
|
|
1336
1527
|
*/
|
|
1337
1528
|
async listForPlayer(playerEmail, options, opts) {
|
|
1338
1529
|
if (typeof playerEmail !== "string" || !playerEmail.trim()) {
|
|
1339
|
-
throw
|
|
1530
|
+
throw invalidInput2("playerEmail", playerEmail, "is required");
|
|
1340
1531
|
}
|
|
1341
1532
|
const q = new URLSearchParams();
|
|
1342
1533
|
q.set("player_email", playerEmail);
|
|
@@ -1347,13 +1538,13 @@ var SubscriptionsServer = class {
|
|
|
1347
1538
|
if (options?.includePlayer) q.set("include_player", "true");
|
|
1348
1539
|
if (options?.limit != null) {
|
|
1349
1540
|
if (!Number.isInteger(options.limit) || options.limit < 1 || options.limit > 100) {
|
|
1350
|
-
throw
|
|
1541
|
+
throw invalidInput2("limit", options.limit, "must be an integer 1..100");
|
|
1351
1542
|
}
|
|
1352
1543
|
q.set("limit", String(options.limit));
|
|
1353
1544
|
}
|
|
1354
1545
|
if (options?.offset != null) {
|
|
1355
1546
|
if (!Number.isInteger(options.offset) || options.offset < 0 || options.offset > 1e5) {
|
|
1356
|
-
throw
|
|
1547
|
+
throw invalidInput2("offset", options.offset, "must be an integer 0..100000");
|
|
1357
1548
|
}
|
|
1358
1549
|
q.set("offset", String(options.offset));
|
|
1359
1550
|
}
|
|
@@ -1393,13 +1584,13 @@ var SubscriptionsServer = class {
|
|
|
1393
1584
|
const body = {};
|
|
1394
1585
|
if (options?.atPeriodEnd !== void 0) {
|
|
1395
1586
|
if (typeof options.atPeriodEnd !== "boolean") {
|
|
1396
|
-
throw
|
|
1587
|
+
throw invalidInput2("atPeriodEnd", options.atPeriodEnd, "must be a boolean");
|
|
1397
1588
|
}
|
|
1398
1589
|
body["at_period_end"] = options.atPeriodEnd;
|
|
1399
1590
|
}
|
|
1400
1591
|
if (options?.reason !== void 0) {
|
|
1401
1592
|
if (typeof options.reason !== "string" || options.reason.length > 500) {
|
|
1402
|
-
throw
|
|
1593
|
+
throw invalidInput2("reason", options.reason, "must be a string of at most 500 characters");
|
|
1403
1594
|
}
|
|
1404
1595
|
body["reason"] = options.reason;
|
|
1405
1596
|
}
|
|
@@ -1478,14 +1669,14 @@ var SubscriptionsServer = class {
|
|
|
1478
1669
|
const body = {};
|
|
1479
1670
|
if ("playerCardId" in input && input.playerCardId !== void 0) {
|
|
1480
1671
|
if (!Number.isInteger(input.playerCardId) || input.playerCardId < 1) {
|
|
1481
|
-
throw
|
|
1672
|
+
throw invalidInput2("playerCardId", input.playerCardId, "must be a positive integer card id (from cards.list)");
|
|
1482
1673
|
}
|
|
1483
1674
|
body["player_card_id"] = input.playerCardId;
|
|
1484
1675
|
if (input.walletOnly !== void 0) body["wallet_only"] = input.walletOnly;
|
|
1485
1676
|
} else if (input.walletOnly === true) {
|
|
1486
1677
|
body["wallet_only"] = true;
|
|
1487
1678
|
} else {
|
|
1488
|
-
throw
|
|
1679
|
+
throw invalidInput2("input", input, "requires { playerCardId } or { walletOnly: true }");
|
|
1489
1680
|
}
|
|
1490
1681
|
const raw = await this.http.post(
|
|
1491
1682
|
`/api/subscriptions/${encodeURIComponent(subscriptionId)}/payment-method`,
|
|
@@ -1546,14 +1737,14 @@ var SubscriptionsServer = class {
|
|
|
1546
1737
|
const body = { client_request_id: input.clientRequestId };
|
|
1547
1738
|
if (input.periodSeq !== void 0) {
|
|
1548
1739
|
if (!Number.isInteger(input.periodSeq) || input.periodSeq < 1) {
|
|
1549
|
-
throw
|
|
1740
|
+
throw invalidInput2("periodSeq", input.periodSeq, "must be an integer >= 1");
|
|
1550
1741
|
}
|
|
1551
1742
|
body["period_seq"] = input.periodSeq;
|
|
1552
1743
|
}
|
|
1553
1744
|
if (input.amountUsd !== void 0) body["amount_usd"] = subscriptionMoney(input.amountUsd, "amountUsd");
|
|
1554
1745
|
if (input.reason !== void 0) {
|
|
1555
1746
|
if (typeof input.reason !== "string" || input.reason.length > 500) {
|
|
1556
|
-
throw
|
|
1747
|
+
throw invalidInput2("reason", input.reason, "must be a string of at most 500 characters");
|
|
1557
1748
|
}
|
|
1558
1749
|
body["reason"] = input.reason;
|
|
1559
1750
|
}
|
|
@@ -1595,10 +1786,10 @@ var SubscriptionsServer = class {
|
|
|
1595
1786
|
async steamInit(input, opts) {
|
|
1596
1787
|
const body = subscriptionBaseBody(input);
|
|
1597
1788
|
if (!/^[0-9]+$/.test(String(input.steamId ?? ""))) {
|
|
1598
|
-
throw
|
|
1789
|
+
throw invalidInput2("steamId", input.steamId, "must be the member's numeric 64-bit Steam id");
|
|
1599
1790
|
}
|
|
1600
1791
|
if (input.userSession !== void 0 && input.userSession !== "client" && input.userSession !== "web") {
|
|
1601
|
-
throw
|
|
1792
|
+
throw invalidInput2("userSession", input.userSession, 'must be "client" or "web"');
|
|
1602
1793
|
}
|
|
1603
1794
|
if (input.userSession === "web" && !input.playerIp) {
|
|
1604
1795
|
throw new InvoError({
|
|
@@ -1608,7 +1799,7 @@ var SubscriptionsServer = class {
|
|
|
1608
1799
|
});
|
|
1609
1800
|
}
|
|
1610
1801
|
if (input.intervalCount !== void 0 && input.intervalCount !== 1) {
|
|
1611
|
-
throw
|
|
1802
|
+
throw invalidInput2("intervalCount", input.intervalCount, "must be 1 on the Steam rail (monthly and yearly only)");
|
|
1612
1803
|
}
|
|
1613
1804
|
const forbidden = input;
|
|
1614
1805
|
if (forbidden["trialAmountUsd"] !== void 0) {
|
|
@@ -1620,7 +1811,7 @@ var SubscriptionsServer = class {
|
|
|
1620
1811
|
}
|
|
1621
1812
|
for (const k of ["trialDays", "trialEnd", "walletOnly", "playerCardId"]) {
|
|
1622
1813
|
if (forbidden[k] !== void 0) {
|
|
1623
|
-
throw
|
|
1814
|
+
throw invalidInput2(k, forbidden[k], "is not available on the Steam rail");
|
|
1624
1815
|
}
|
|
1625
1816
|
}
|
|
1626
1817
|
body["steamid"] = String(input.steamId);
|
|
@@ -1733,24 +1924,24 @@ var CardsServer = class {
|
|
|
1733
1924
|
*/
|
|
1734
1925
|
async createSetupSession(input, opts) {
|
|
1735
1926
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
1736
|
-
throw
|
|
1927
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
1737
1928
|
}
|
|
1738
1929
|
for (const [label, value] of [
|
|
1739
1930
|
["successUrl", input.successUrl],
|
|
1740
1931
|
["cancelUrl", input.cancelUrl]
|
|
1741
1932
|
]) {
|
|
1742
1933
|
if (value === void 0) continue;
|
|
1743
|
-
if (typeof value !== "string" || !value.trim()) throw
|
|
1744
|
-
if (SCRIPT_SCHEME.test(value)) throw
|
|
1934
|
+
if (typeof value !== "string" || !value.trim()) throw invalidInput2(label, value, "must be a non-empty URL");
|
|
1935
|
+
if (SCRIPT_SCHEME.test(value)) throw invalidInput2(label, value, "must not use a script scheme");
|
|
1745
1936
|
}
|
|
1746
1937
|
if (input.metadata !== void 0 && (input.metadata === null || typeof input.metadata !== "object" || Array.isArray(input.metadata))) {
|
|
1747
|
-
throw
|
|
1938
|
+
throw invalidInput2("metadata", input.metadata, "must be a plain object");
|
|
1748
1939
|
}
|
|
1749
1940
|
if (input.playerName !== void 0) {
|
|
1750
1941
|
if (typeof input.playerName !== "string" || !input.playerName.trim()) {
|
|
1751
|
-
throw
|
|
1942
|
+
throw invalidInput2("playerName", input.playerName, "must be a non-empty string");
|
|
1752
1943
|
}
|
|
1753
|
-
if (input.playerName.trim().length > 255) throw
|
|
1944
|
+
if (input.playerName.trim().length > 255) throw invalidInput2("playerName", input.playerName, "must be at most 255 characters");
|
|
1754
1945
|
}
|
|
1755
1946
|
if (input.playerPhone !== void 0) assertE164(input.playerPhone, "playerPhone");
|
|
1756
1947
|
const body = { player_email: input.playerEmail };
|
|
@@ -1795,10 +1986,10 @@ var CardsServer = class {
|
|
|
1795
1986
|
*/
|
|
1796
1987
|
async beginSetup(input, opts) {
|
|
1797
1988
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
1798
|
-
throw
|
|
1989
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
1799
1990
|
}
|
|
1800
1991
|
if (typeof input.setupReference !== "string" || !/^[A-Za-z0-9._:-]{1,200}$/.test(input.setupReference)) {
|
|
1801
|
-
throw
|
|
1992
|
+
throw invalidInput2("setupReference", input.setupReference, "must be 1-200 characters of A-Z a-z 0-9 . _ : -");
|
|
1802
1993
|
}
|
|
1803
1994
|
const body = {
|
|
1804
1995
|
player_email: input.playerEmail,
|
|
@@ -1834,7 +2025,7 @@ var CardsServer = class {
|
|
|
1834
2025
|
*/
|
|
1835
2026
|
async confirmSetup(input, opts) {
|
|
1836
2027
|
if (typeof input.setupIntentId !== "string" || !input.setupIntentId.trim()) {
|
|
1837
|
-
throw
|
|
2028
|
+
throw invalidInput2("setupIntentId", input.setupIntentId, "is required (from beginSetup)");
|
|
1838
2029
|
}
|
|
1839
2030
|
const raw = await this.http.post(
|
|
1840
2031
|
"/api/currency-purchases/setup-intent/confirm",
|
|
@@ -1860,7 +2051,7 @@ var CardsServer = class {
|
|
|
1860
2051
|
*/
|
|
1861
2052
|
async list(playerEmail, opts) {
|
|
1862
2053
|
if (typeof playerEmail !== "string" || !playerEmail.trim()) {
|
|
1863
|
-
throw
|
|
2054
|
+
throw invalidInput2("playerEmail", playerEmail, "is required");
|
|
1864
2055
|
}
|
|
1865
2056
|
const raw = await this.http.get(
|
|
1866
2057
|
`/api/currency-purchases/player-cards?player_email=${encodeURIComponent(playerEmail)}`,
|
|
@@ -1883,7 +2074,7 @@ var SandboxSubscriptionsServer = class {
|
|
|
1883
2074
|
async call(subscriptionId, tool, body, opts) {
|
|
1884
2075
|
assertSubscriptionId(subscriptionId);
|
|
1885
2076
|
if (typeof this.clockKey !== "string" || !this.clockKey.trim()) {
|
|
1886
|
-
throw
|
|
2077
|
+
throw invalidInput2(
|
|
1887
2078
|
"sandboxClockKey",
|
|
1888
2079
|
this.clockKey,
|
|
1889
2080
|
'is required for invo.sandbox.subscriptions.* \u2014 pass it to new InvoServer({ sandboxClockKey }) from the sandbox console (Game Settings, "Sandbox clock key")'
|
|
@@ -1909,7 +2100,7 @@ var SandboxSubscriptionsServer = class {
|
|
|
1909
2100
|
*/
|
|
1910
2101
|
async advanceClock(subscriptionId, intervals = 1, opts) {
|
|
1911
2102
|
if (!Number.isInteger(intervals) || intervals < 0 || intervals > 60) {
|
|
1912
|
-
throw
|
|
2103
|
+
throw invalidInput2("intervals", intervals, "must be an integer 0..60");
|
|
1913
2104
|
}
|
|
1914
2105
|
return this.call(subscriptionId, "advance-clock", { intervals }, opts);
|
|
1915
2106
|
}
|
|
@@ -1932,7 +2123,7 @@ var SandboxSubscriptionsServer = class {
|
|
|
1932
2123
|
*/
|
|
1933
2124
|
async forceFailure(subscriptionId, outcome = "card_declined", options, opts) {
|
|
1934
2125
|
if (!SANDBOX_FAILURE_OUTCOMES.has(outcome)) {
|
|
1935
|
-
throw
|
|
2126
|
+
throw invalidInput2("outcome", outcome, 'must be "card_declined" | "insufficient_funds" | "error"');
|
|
1936
2127
|
}
|
|
1937
2128
|
const body = { outcome };
|
|
1938
2129
|
if (options?.failureCode !== void 0) body["failure_code"] = options.failureCode;
|
|
@@ -1977,6 +2168,7 @@ var InvoServer = class {
|
|
|
1977
2168
|
this.subscriptions = new SubscriptionsServer(this.http, this.auth);
|
|
1978
2169
|
this.cards = new CardsServer(this.http, this.auth);
|
|
1979
2170
|
this.sandbox = new SandboxServer(this.http, this.auth, config.sandboxClockKey);
|
|
2171
|
+
this.payouts = new PayoutsServer(this.http, this.auth);
|
|
1980
2172
|
}
|
|
1981
2173
|
/**
|
|
1982
2174
|
* Mint a short-lived, game-scoped player token to hand to the browser InvoClient.
|
|
@@ -1997,7 +2189,7 @@ var InvoServer = class {
|
|
|
1997
2189
|
*/
|
|
1998
2190
|
async mintPlayerToken(input, opts) {
|
|
1999
2191
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
2000
|
-
throw
|
|
2192
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
2001
2193
|
}
|
|
2002
2194
|
const body = { player_email: input.playerEmail };
|
|
2003
2195
|
if (input.playerPhone !== void 0) {
|
|
@@ -2006,7 +2198,7 @@ var InvoServer = class {
|
|
|
2006
2198
|
}
|
|
2007
2199
|
if (input.playerName !== void 0) {
|
|
2008
2200
|
if (typeof input.playerName !== "string") {
|
|
2009
|
-
throw
|
|
2201
|
+
throw invalidInput2("playerName", input.playerName, "must be a string");
|
|
2010
2202
|
}
|
|
2011
2203
|
body["player_name"] = input.playerName;
|
|
2012
2204
|
}
|
|
@@ -2039,7 +2231,7 @@ var InvoServer = class {
|
|
|
2039
2231
|
*/
|
|
2040
2232
|
async registerPlayer(input, opts) {
|
|
2041
2233
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
2042
|
-
throw
|
|
2234
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
2043
2235
|
}
|
|
2044
2236
|
assertE164(input.playerPhone, "playerPhone");
|
|
2045
2237
|
const body = {
|
|
@@ -2048,7 +2240,7 @@ var InvoServer = class {
|
|
|
2048
2240
|
};
|
|
2049
2241
|
if (input.playerName !== void 0) {
|
|
2050
2242
|
if (typeof input.playerName !== "string") {
|
|
2051
|
-
throw
|
|
2243
|
+
throw invalidInput2("playerName", input.playerName, "must be a string");
|
|
2052
2244
|
}
|
|
2053
2245
|
body["player_name"] = input.playerName;
|
|
2054
2246
|
}
|
|
@@ -2086,7 +2278,7 @@ var InvoServer = class {
|
|
|
2086
2278
|
*/
|
|
2087
2279
|
async updatePlayerPhone(input, opts) {
|
|
2088
2280
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
2089
|
-
throw
|
|
2281
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
2090
2282
|
}
|
|
2091
2283
|
assertE164(input.newPhone, "newPhone");
|
|
2092
2284
|
const raw = await this.http.post(
|
|
@@ -2130,7 +2322,7 @@ var InvoServer = class {
|
|
|
2130
2322
|
*/
|
|
2131
2323
|
async requestPhoneChange(input, opts) {
|
|
2132
2324
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
2133
|
-
throw
|
|
2325
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
2134
2326
|
}
|
|
2135
2327
|
assertE164(input.newPhone, "newPhone");
|
|
2136
2328
|
const raw = await this.http.post(
|
|
@@ -2150,7 +2342,7 @@ var InvoServer = class {
|
|
|
2150
2342
|
*/
|
|
2151
2343
|
async getPhoneChange(changeRequestId, opts) {
|
|
2152
2344
|
if (typeof changeRequestId !== "string" || !changeRequestId.trim()) {
|
|
2153
|
-
throw
|
|
2345
|
+
throw invalidInput2("changeRequestId", changeRequestId, "is required");
|
|
2154
2346
|
}
|
|
2155
2347
|
const raw = await this.http.get(
|
|
2156
2348
|
`/api/sdk/players/phone/change-requests/${encodeURIComponent(changeRequestId)}`,
|
|
@@ -2214,7 +2406,7 @@ var InvoServer = class {
|
|
|
2214
2406
|
* purchase.completed webhook. */
|
|
2215
2407
|
async createCheckout(input, opts) {
|
|
2216
2408
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
2217
|
-
throw
|
|
2409
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
2218
2410
|
}
|
|
2219
2411
|
assertUsdAmount(input.usdAmount);
|
|
2220
2412
|
const body = {
|
|
@@ -2278,7 +2470,7 @@ var InvoServer = class {
|
|
|
2278
2470
|
*/
|
|
2279
2471
|
async purchaseCurrency(input, opts) {
|
|
2280
2472
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
2281
|
-
throw
|
|
2473
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
2282
2474
|
}
|
|
2283
2475
|
assertUsdAmount(input.usdAmount);
|
|
2284
2476
|
if (!input.purchaseReference) {
|
|
@@ -2397,8 +2589,8 @@ var InvoServer = class {
|
|
|
2397
2589
|
};
|
|
2398
2590
|
}
|
|
2399
2591
|
/** Fetch purchase status (order + financial summary + timeline). */
|
|
2400
|
-
async getOrderDetails(
|
|
2401
|
-
if (!
|
|
2592
|
+
async getOrderDetails(query2, opts) {
|
|
2593
|
+
if (!query2.orderId && !query2.transactionId) {
|
|
2402
2594
|
throw new InvoError({
|
|
2403
2595
|
message: "getOrderDetails requires an `orderId` or `transactionId`.",
|
|
2404
2596
|
code: "INVALID_INPUT",
|
|
@@ -2406,8 +2598,8 @@ var InvoServer = class {
|
|
|
2406
2598
|
});
|
|
2407
2599
|
}
|
|
2408
2600
|
const q = new URLSearchParams();
|
|
2409
|
-
if (
|
|
2410
|
-
if (
|
|
2601
|
+
if (query2.orderId) q.set("order_id", query2.orderId);
|
|
2602
|
+
if (query2.transactionId) q.set("transaction_id", query2.transactionId);
|
|
2411
2603
|
const raw = await this.http.get(
|
|
2412
2604
|
`/api/currency-purchases/order-details?${q.toString()}`,
|
|
2413
2605
|
this.auth,
|
|
@@ -2430,8 +2622,8 @@ var InvoServer = class {
|
|
|
2430
2622
|
* no-VAT catalogue and lets the PURCHASE be what refuses; the only 503 is
|
|
2431
2623
|
* the rail being disabled platform-wide, whose body carries no error code.
|
|
2432
2624
|
*/
|
|
2433
|
-
async steamPacks(
|
|
2434
|
-
const qs =
|
|
2625
|
+
async steamPacks(query2, opts) {
|
|
2626
|
+
const qs = query2?.steamid ? `?steamid=${encodeURIComponent(query2.steamid)}` : "";
|
|
2435
2627
|
const raw = await this.http.get(
|
|
2436
2628
|
`/api/currency-purchases/steam/packs${qs}`,
|
|
2437
2629
|
this.auth,
|
|
@@ -2476,12 +2668,12 @@ var InvoServer = class {
|
|
|
2476
2668
|
*/
|
|
2477
2669
|
async steamInitPurchase(input, opts) {
|
|
2478
2670
|
if (typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
|
|
2479
|
-
throw
|
|
2671
|
+
throw invalidInput2("playerEmail", input.playerEmail, "is required");
|
|
2480
2672
|
}
|
|
2481
2673
|
if (!/^[0-9]+$/.test(String(input.steamid ?? ""))) {
|
|
2482
|
-
throw
|
|
2674
|
+
throw invalidInput2("steamid", input.steamid, "must be the player's numeric 64-bit Steam id");
|
|
2483
2675
|
}
|
|
2484
|
-
if (!input.packId) throw
|
|
2676
|
+
if (!input.packId) throw invalidInput2("packId", input.packId, "is required \u2014 fetch steamPacks()");
|
|
2485
2677
|
if (!input.purchaseReference) {
|
|
2486
2678
|
throw new InvoError({
|
|
2487
2679
|
message: "purchaseReference is required (idempotency key, unique per intended purchase).",
|
|
@@ -2542,7 +2734,7 @@ var InvoServer = class {
|
|
|
2542
2734
|
* detects the authorized transaction and credits, on a delay.
|
|
2543
2735
|
*/
|
|
2544
2736
|
async steamFinalizePurchase(input, opts) {
|
|
2545
|
-
if (!input.orderId) throw
|
|
2737
|
+
if (!input.orderId) throw invalidInput2("orderId", input.orderId, "is required (from steamInitPurchase)");
|
|
2546
2738
|
const raw = await this.http.post(
|
|
2547
2739
|
"/api/currency-purchases/steam/finalize-purchase",
|
|
2548
2740
|
{ order_id: input.orderId },
|
|
@@ -2577,17 +2769,17 @@ var InvoServer = class {
|
|
|
2577
2769
|
["itemName", input.itemName]
|
|
2578
2770
|
];
|
|
2579
2771
|
for (const [k, v] of required) {
|
|
2580
|
-
if (typeof v !== "string" || !v.trim()) throw
|
|
2772
|
+
if (typeof v !== "string" || !v.trim()) throw invalidInput2(k, v, "is required");
|
|
2581
2773
|
}
|
|
2582
2774
|
if (!Number.isInteger(input.itemQuantity) || input.itemQuantity < 1 || input.itemQuantity > 1e3) {
|
|
2583
|
-
throw
|
|
2775
|
+
throw invalidInput2("itemQuantity", input.itemQuantity, "must be an integer 1..1000");
|
|
2584
2776
|
}
|
|
2585
2777
|
const unit = parseMoney(input.unitPrice, MAX_ITEM_PRICE, "unitPrice");
|
|
2586
2778
|
const total = parseMoney(input.totalPrice, MAX_ITEM_PRICE, "totalPrice");
|
|
2587
2779
|
const expectedCents = Math.round(unit * input.itemQuantity * 100);
|
|
2588
2780
|
const totalCents = Math.round(total * 100);
|
|
2589
2781
|
if (Math.abs(totalCents - expectedCents) > 1) {
|
|
2590
|
-
throw
|
|
2782
|
+
throw invalidInput2(
|
|
2591
2783
|
"totalPrice",
|
|
2592
2784
|
input.totalPrice,
|
|
2593
2785
|
`must equal unitPrice \xD7 itemQuantity (\xB10.01): ${unit} \xD7 ${input.itemQuantity}`
|
|
@@ -2625,14 +2817,14 @@ var InvoServer = class {
|
|
|
2625
2817
|
};
|
|
2626
2818
|
}
|
|
2627
2819
|
/** Paginated item-purchase history for a player (§4.8 companion read). */
|
|
2628
|
-
async getItemPurchaseHistory(
|
|
2629
|
-
if (typeof
|
|
2630
|
-
throw
|
|
2820
|
+
async getItemPurchaseHistory(query2, opts) {
|
|
2821
|
+
if (typeof query2.playerEmail !== "string" || !query2.playerEmail.trim()) {
|
|
2822
|
+
throw invalidInput2("playerEmail", query2.playerEmail, "is required");
|
|
2631
2823
|
}
|
|
2632
2824
|
const q = new URLSearchParams();
|
|
2633
|
-
q.set("player_email",
|
|
2634
|
-
if (
|
|
2635
|
-
if (
|
|
2825
|
+
q.set("player_email", query2.playerEmail);
|
|
2826
|
+
if (query2.limit != null) q.set("limit", String(query2.limit));
|
|
2827
|
+
if (query2.offset != null) q.set("offset", String(query2.offset));
|
|
2636
2828
|
const raw = await this.http.get(
|
|
2637
2829
|
`/api/item-purchases/player-purchase-history?${q.toString()}`,
|
|
2638
2830
|
this.auth,
|
|
@@ -2646,8 +2838,8 @@ var InvoServer = class {
|
|
|
2646
2838
|
}
|
|
2647
2839
|
/** Look up one item order by EXACTLY ONE of orderId | transactionId | clientRequestId
|
|
2648
2840
|
* (§4.8). Use clientRequestId for saga/recovery: "did this purchase actually complete?" */
|
|
2649
|
-
async getItemOrderDetails(
|
|
2650
|
-
const provided = [
|
|
2841
|
+
async getItemOrderDetails(query2, opts) {
|
|
2842
|
+
const provided = [query2.orderId, query2.transactionId, query2.clientRequestId].filter(
|
|
2651
2843
|
(v) => typeof v === "string" && v.trim()
|
|
2652
2844
|
);
|
|
2653
2845
|
if (provided.length !== 1) {
|
|
@@ -2658,9 +2850,9 @@ var InvoServer = class {
|
|
|
2658
2850
|
});
|
|
2659
2851
|
}
|
|
2660
2852
|
const q = new URLSearchParams();
|
|
2661
|
-
if (
|
|
2662
|
-
if (
|
|
2663
|
-
if (
|
|
2853
|
+
if (query2.orderId) q.set("order_id", query2.orderId);
|
|
2854
|
+
if (query2.transactionId) q.set("transaction_id", query2.transactionId);
|
|
2855
|
+
if (query2.clientRequestId) q.set("client_request_id", query2.clientRequestId);
|
|
2664
2856
|
const raw = await this.http.get(
|
|
2665
2857
|
`/api/item-purchases/order-details?${q.toString()}`,
|
|
2666
2858
|
this.auth,
|
|
@@ -2676,15 +2868,15 @@ var InvoServer = class {
|
|
|
2676
2868
|
* for await (const row of invo.iterateItemPurchaseHistory({ playerEmail })) { … }
|
|
2677
2869
|
* ```
|
|
2678
2870
|
*/
|
|
2679
|
-
async *iterateItemPurchaseHistory(
|
|
2680
|
-
if (typeof
|
|
2681
|
-
throw
|
|
2871
|
+
async *iterateItemPurchaseHistory(query2, opts) {
|
|
2872
|
+
if (typeof query2.playerEmail !== "string" || !query2.playerEmail.trim()) {
|
|
2873
|
+
throw invalidInput2("playerEmail", query2.playerEmail, "is required");
|
|
2682
2874
|
}
|
|
2683
|
-
const pageSize = typeof
|
|
2875
|
+
const pageSize = typeof query2.pageSize === "number" && query2.pageSize > 0 ? Math.floor(query2.pageSize) : 50;
|
|
2684
2876
|
let yielded = 0;
|
|
2685
2877
|
for (let offset = 0; ; offset += pageSize) {
|
|
2686
2878
|
const { history, pagination } = await this.getItemPurchaseHistory(
|
|
2687
|
-
{ playerEmail:
|
|
2879
|
+
{ playerEmail: query2.playerEmail, limit: pageSize, offset },
|
|
2688
2880
|
opts
|
|
2689
2881
|
);
|
|
2690
2882
|
if (history.length === 0) return;
|
|
@@ -2718,23 +2910,23 @@ var InvoServer = class {
|
|
|
2718
2910
|
* `500 PLAYER_ACTIVITY_FAILED` (retry later), `429` (back off; `err.retryAfter`). A GET, so
|
|
2719
2911
|
* transient failures are retried automatically.
|
|
2720
2912
|
*/
|
|
2721
|
-
async getPlayerActivity(
|
|
2722
|
-
if (typeof
|
|
2723
|
-
throw
|
|
2724
|
-
}
|
|
2725
|
-
assertPageLimit(
|
|
2726
|
-
assertCursor(
|
|
2727
|
-
if (
|
|
2728
|
-
if (!Array.isArray(
|
|
2729
|
-
throw
|
|
2913
|
+
async getPlayerActivity(query2, opts) {
|
|
2914
|
+
if (typeof query2?.playerEmail !== "string" || !query2.playerEmail.trim()) {
|
|
2915
|
+
throw invalidInput2("playerEmail", query2?.playerEmail, "is required");
|
|
2916
|
+
}
|
|
2917
|
+
assertPageLimit(query2.limit);
|
|
2918
|
+
assertCursor(query2.cursor);
|
|
2919
|
+
if (query2.types !== void 0) {
|
|
2920
|
+
if (!Array.isArray(query2.types) || query2.types.some((t) => typeof t !== "string" || !t.trim() || t.includes(","))) {
|
|
2921
|
+
throw invalidInput2("types", query2.types, "must be an array of activity kinds");
|
|
2730
2922
|
}
|
|
2731
2923
|
}
|
|
2732
2924
|
const q = new URLSearchParams();
|
|
2733
|
-
q.set("player_email",
|
|
2734
|
-
if (
|
|
2735
|
-
if (
|
|
2736
|
-
if (
|
|
2737
|
-
q.set("types",
|
|
2925
|
+
q.set("player_email", query2.playerEmail.trim());
|
|
2926
|
+
if (query2.limit !== void 0) q.set("limit", String(query2.limit));
|
|
2927
|
+
if (query2.cursor !== void 0) q.set("cursor", query2.cursor);
|
|
2928
|
+
if (query2.types && query2.types.length > 0) {
|
|
2929
|
+
q.set("types", query2.types.map((t) => t.trim()).join(","));
|
|
2738
2930
|
}
|
|
2739
2931
|
const raw = await this.http.get(
|
|
2740
2932
|
`/api/sdk/players/activity?${q.toString()}`,
|
|
@@ -2744,7 +2936,7 @@ var InvoServer = class {
|
|
|
2744
2936
|
const activity = Array.isArray(raw["activity"]) ? raw["activity"].map(toPlayerActivityEntry) : [];
|
|
2745
2937
|
const nextCursor = nextCursorOf(raw);
|
|
2746
2938
|
return {
|
|
2747
|
-
playerEmail: String(raw["player_email"] ??
|
|
2939
|
+
playerEmail: String(raw["player_email"] ?? query2.playerEmail.trim()),
|
|
2748
2940
|
gameId: String(raw["game_id"] ?? ""),
|
|
2749
2941
|
types: Array.isArray(raw["types"]) ? raw["types"].map(String) : [],
|
|
2750
2942
|
activity,
|
|
@@ -2762,12 +2954,12 @@ var InvoServer = class {
|
|
|
2762
2954
|
* for await (const row of invo.iteratePlayerActivity({ playerEmail, types: ["send", "transfer"] })) { … }
|
|
2763
2955
|
* ```
|
|
2764
2956
|
*/
|
|
2765
|
-
async *iteratePlayerActivity(
|
|
2957
|
+
async *iteratePlayerActivity(query2, opts) {
|
|
2766
2958
|
let cursor;
|
|
2767
2959
|
const seen = /* @__PURE__ */ new Set();
|
|
2768
2960
|
for (; ; ) {
|
|
2769
2961
|
const page = await this.getPlayerActivity(
|
|
2770
|
-
{ playerEmail:
|
|
2962
|
+
{ playerEmail: query2.playerEmail, types: query2.types, limit: query2.pageSize, cursor },
|
|
2771
2963
|
opts
|
|
2772
2964
|
);
|
|
2773
2965
|
for (const row of page.activity) yield row;
|
|
@@ -2784,11 +2976,11 @@ var InvoServer = class {
|
|
|
2784
2976
|
* browser `InvoClient.getBalance()` (token-authed, identity from the token) for a
|
|
2785
2977
|
* client-side read, or `playerEmail` here server-side.
|
|
2786
2978
|
*/
|
|
2787
|
-
async getPlayerBalance(
|
|
2979
|
+
async getPlayerBalance(query2, opts) {
|
|
2788
2980
|
let path;
|
|
2789
|
-
if (typeof
|
|
2790
|
-
path = `/api/player-balances/player/by-email/${encodeURIComponent(
|
|
2791
|
-
} else if (
|
|
2981
|
+
if (typeof query2.playerEmail === "string" && query2.playerEmail.trim()) {
|
|
2982
|
+
path = `/api/player-balances/player/by-email/${encodeURIComponent(query2.playerEmail)}`;
|
|
2983
|
+
} else if (query2.playerId != null && String(query2.playerId).trim()) {
|
|
2792
2984
|
throw new InvoError({
|
|
2793
2985
|
message: "getPlayerBalance is by playerEmail only \u2014 there is no by-id balance route. Use InvoClient.getBalance() client-side (player token), or pass playerEmail here.",
|
|
2794
2986
|
code: "INVALID_INPUT",
|
|
@@ -2827,7 +3019,7 @@ var InvoServer = class {
|
|
|
2827
3019
|
*/
|
|
2828
3020
|
async getPlayerRewards(playerEmail, opts) {
|
|
2829
3021
|
if (typeof playerEmail !== "string" || !playerEmail.trim()) {
|
|
2830
|
-
throw
|
|
3022
|
+
throw invalidInput2("playerEmail", playerEmail, "is required");
|
|
2831
3023
|
}
|
|
2832
3024
|
const raw = await this.http.get(
|
|
2833
3025
|
`/api/sdk/loyalty/players/rewards?player_email=${encodeURIComponent(playerEmail.trim())}`,
|
|
@@ -2843,15 +3035,15 @@ var InvoServer = class {
|
|
|
2843
3035
|
* which is null when the phone maps to more than one of your players). Pairs with the
|
|
2844
3036
|
* `transfer.claim_pending` webhook (the webhook is the wake-up; this is the list).
|
|
2845
3037
|
*/
|
|
2846
|
-
async getInboundPending(
|
|
2847
|
-
const hasEmail = typeof
|
|
2848
|
-
const hasPhone = typeof
|
|
3038
|
+
async getInboundPending(query2, opts) {
|
|
3039
|
+
const hasEmail = typeof query2.playerEmail === "string" && query2.playerEmail.trim();
|
|
3040
|
+
const hasPhone = typeof query2.playerPhone === "string" && query2.playerPhone.trim();
|
|
2849
3041
|
if (!hasEmail && !hasPhone) {
|
|
2850
|
-
throw
|
|
3042
|
+
throw invalidInput2("query", query2, "requires a playerEmail or playerPhone");
|
|
2851
3043
|
}
|
|
2852
3044
|
const q = new URLSearchParams();
|
|
2853
|
-
if (hasEmail) q.set("player_email",
|
|
2854
|
-
if (hasPhone) q.set("player_phone",
|
|
3045
|
+
if (hasEmail) q.set("player_email", query2.playerEmail.trim());
|
|
3046
|
+
if (hasPhone) q.set("player_phone", query2.playerPhone.trim());
|
|
2855
3047
|
const raw = await this.http.get(
|
|
2856
3048
|
`/api/transfers/inbound-pending?${q.toString()}`,
|
|
2857
3049
|
this.auth,
|
|
@@ -2868,11 +3060,11 @@ var InvoServer = class {
|
|
|
2868
3060
|
*
|
|
2869
3061
|
* ⚠️ Returns first-party PII (emails/phones) — never expose this to the browser.
|
|
2870
3062
|
*/
|
|
2871
|
-
async getLinkedIdentities(
|
|
2872
|
-
const phone = typeof
|
|
2873
|
-
const email = typeof
|
|
3063
|
+
async getLinkedIdentities(query2, opts) {
|
|
3064
|
+
const phone = typeof query2.playerPhone === "string" && query2.playerPhone.trim() ? query2.playerPhone.trim() : "";
|
|
3065
|
+
const email = typeof query2.playerEmail === "string" && query2.playerEmail.trim() ? query2.playerEmail.trim() : "";
|
|
2874
3066
|
if (!phone && !email) {
|
|
2875
|
-
throw
|
|
3067
|
+
throw invalidInput2("query", query2, "requires a playerEmail or playerPhone");
|
|
2876
3068
|
}
|
|
2877
3069
|
const q = new URLSearchParams();
|
|
2878
3070
|
if (phone) q.set("player_phone", phone);
|
|
@@ -2922,10 +3114,10 @@ var InvoServer = class {
|
|
|
2922
3114
|
*/
|
|
2923
3115
|
async verifySmsTransfer(transactionId, smsPin, opts) {
|
|
2924
3116
|
if (typeof transactionId !== "string" || !transactionId.trim()) {
|
|
2925
|
-
throw
|
|
3117
|
+
throw invalidInput2("transactionId", transactionId, "is required");
|
|
2926
3118
|
}
|
|
2927
3119
|
if (typeof smsPin !== "string" || !smsPin.trim()) {
|
|
2928
|
-
throw
|
|
3120
|
+
throw invalidInput2("smsPin", smsPin, "is required");
|
|
2929
3121
|
}
|
|
2930
3122
|
const raw = await this.http.post(
|
|
2931
3123
|
"/api/transfers/verify-sms",
|
|
@@ -2947,10 +3139,10 @@ var InvoServer = class {
|
|
|
2947
3139
|
*/
|
|
2948
3140
|
async verifySmsSend(transactionId, smsPin, opts) {
|
|
2949
3141
|
if (typeof transactionId !== "string" || !transactionId.trim()) {
|
|
2950
|
-
throw
|
|
3142
|
+
throw invalidInput2("transactionId", transactionId, "is required");
|
|
2951
3143
|
}
|
|
2952
3144
|
if (typeof smsPin !== "string" || !smsPin.trim()) {
|
|
2953
|
-
throw
|
|
3145
|
+
throw invalidInput2("smsPin", smsPin, "is required");
|
|
2954
3146
|
}
|
|
2955
3147
|
const raw = await this.http.post(
|
|
2956
3148
|
"/api/currency-sends/verify-sms",
|
|
@@ -3011,7 +3203,7 @@ var InvoServer = class {
|
|
|
3011
3203
|
/** Read a TRANSFER's status (verification_state + amounts + destination). */
|
|
3012
3204
|
async getTransferStatus(transactionId, opts) {
|
|
3013
3205
|
if (typeof transactionId !== "string" || !transactionId.trim()) {
|
|
3014
|
-
throw
|
|
3206
|
+
throw invalidInput2("transactionId", transactionId, "is required");
|
|
3015
3207
|
}
|
|
3016
3208
|
const raw = await this.http.get(
|
|
3017
3209
|
`/api/transfers/${encodeURIComponent(transactionId)}/status`,
|
|
@@ -3023,7 +3215,7 @@ var InvoServer = class {
|
|
|
3023
3215
|
/** Read a SEND's status (adds fees, game names, claim_info, … on `raw`). */
|
|
3024
3216
|
async getSendStatus(transactionId, opts) {
|
|
3025
3217
|
if (typeof transactionId !== "string" || !transactionId.trim()) {
|
|
3026
|
-
throw
|
|
3218
|
+
throw invalidInput2("transactionId", transactionId, "is required");
|
|
3027
3219
|
}
|
|
3028
3220
|
const raw = await this.http.get(
|
|
3029
3221
|
`/api/currency-sends/${encodeURIComponent(transactionId)}/status`,
|
|
@@ -3039,7 +3231,7 @@ var InvoServer = class {
|
|
|
3039
3231
|
*/
|
|
3040
3232
|
async getGuardianApprovalStatus(transactionId, opts) {
|
|
3041
3233
|
if (typeof transactionId !== "string" || !transactionId.trim()) {
|
|
3042
|
-
throw
|
|
3234
|
+
throw invalidInput2("transactionId", transactionId, "is required");
|
|
3043
3235
|
}
|
|
3044
3236
|
const raw = await this.http.get(
|
|
3045
3237
|
`/api/transactions/${encodeURIComponent(transactionId)}/approval-status`,
|
|
@@ -3055,15 +3247,15 @@ var InvoServer = class {
|
|
|
3055
3247
|
* the source game is passed explicitly rather than inferred from a player token. Rows
|
|
3056
3248
|
* share the browser shape. Idempotent (a POST read — safe to retry).
|
|
3057
3249
|
*/
|
|
3058
|
-
async getDestinations(
|
|
3059
|
-
if (
|
|
3060
|
-
throw
|
|
3250
|
+
async getDestinations(query2, opts) {
|
|
3251
|
+
if (query2.sourceGameId == null || String(query2.sourceGameId).trim() === "") {
|
|
3252
|
+
throw invalidInput2("sourceGameId", query2.sourceGameId, "is required");
|
|
3061
3253
|
}
|
|
3062
|
-
const direction =
|
|
3254
|
+
const direction = query2.direction ?? "transfer";
|
|
3063
3255
|
const path = direction === "send" ? "/api/currency-sends/available-destinations" : "/api/transfers/available-destinations";
|
|
3064
3256
|
const raw = await this.http.post(
|
|
3065
3257
|
path,
|
|
3066
|
-
{ source_game_id:
|
|
3258
|
+
{ source_game_id: query2.sourceGameId },
|
|
3067
3259
|
this.auth,
|
|
3068
3260
|
{ idempotent: true, signal: opts?.signal }
|
|
3069
3261
|
// a POST read — no side effect, safe to retry
|
|
@@ -3082,10 +3274,10 @@ var InvoServer = class {
|
|
|
3082
3274
|
*/
|
|
3083
3275
|
async phoneShareInitiate(input, opts) {
|
|
3084
3276
|
if (typeof input.phone !== "string" || !input.phone.trim()) {
|
|
3085
|
-
throw
|
|
3277
|
+
throw invalidInput2("phone", input.phone, "is required");
|
|
3086
3278
|
}
|
|
3087
3279
|
if (typeof input.email !== "string" || !input.email.trim()) {
|
|
3088
|
-
throw
|
|
3280
|
+
throw invalidInput2("email", input.email, "is required");
|
|
3089
3281
|
}
|
|
3090
3282
|
const raw = await this.http.post(
|
|
3091
3283
|
"/api/wallet/phone-share/initiate",
|
|
@@ -3105,10 +3297,10 @@ var InvoServer = class {
|
|
|
3105
3297
|
*/
|
|
3106
3298
|
async phoneShareApprove(input, opts) {
|
|
3107
3299
|
if (typeof input.approvalId !== "string" || !input.approvalId.trim()) {
|
|
3108
|
-
throw
|
|
3300
|
+
throw invalidInput2("approvalId", input.approvalId, "is required");
|
|
3109
3301
|
}
|
|
3110
3302
|
if (typeof input.otp !== "string" || !input.otp.trim()) {
|
|
3111
|
-
throw
|
|
3303
|
+
throw invalidInput2("otp", input.otp, "is required");
|
|
3112
3304
|
}
|
|
3113
3305
|
const raw = await this.http.post(
|
|
3114
3306
|
"/api/wallet/phone-share/approve",
|
|
@@ -3127,10 +3319,10 @@ var InvoServer = class {
|
|
|
3127
3319
|
*/
|
|
3128
3320
|
async phoneShareStatus(input, opts) {
|
|
3129
3321
|
if (typeof input.phone !== "string" || !input.phone.trim()) {
|
|
3130
|
-
throw
|
|
3322
|
+
throw invalidInput2("phone", input.phone, "is required");
|
|
3131
3323
|
}
|
|
3132
3324
|
if (typeof input.email !== "string" || !input.email.trim()) {
|
|
3133
|
-
throw
|
|
3325
|
+
throw invalidInput2("email", input.email, "is required");
|
|
3134
3326
|
}
|
|
3135
3327
|
const q = new URLSearchParams();
|
|
3136
3328
|
q.set("phone", input.phone);
|
|
@@ -3168,12 +3360,12 @@ var InvoServer = class {
|
|
|
3168
3360
|
async beginDeviceApproval(input, opts) {
|
|
3169
3361
|
assertPlayerToken(input.playerToken);
|
|
3170
3362
|
if (typeof input.transactionId !== "string" || !input.transactionId.trim()) {
|
|
3171
|
-
throw
|
|
3363
|
+
throw invalidInput2("transactionId", input.transactionId, "is required");
|
|
3172
3364
|
}
|
|
3173
3365
|
assertDeviceApprovalFlow(input.flow);
|
|
3174
3366
|
const channel = input.channel ?? "qr";
|
|
3175
3367
|
if (!DEVICE_APPROVAL_CHANNELS.has(channel)) {
|
|
3176
|
-
throw
|
|
3368
|
+
throw invalidInput2("channel", channel, 'must be "qr" | "app_browser" ("popup" is browser-only)');
|
|
3177
3369
|
}
|
|
3178
3370
|
if (channel === "popup") {
|
|
3179
3371
|
throw new InvoError({
|
|
@@ -3211,7 +3403,7 @@ var InvoServer = class {
|
|
|
3211
3403
|
async pollDeviceApproval(input, opts) {
|
|
3212
3404
|
assertPlayerToken(input.playerToken);
|
|
3213
3405
|
if (typeof input.deviceCode !== "string" || !input.deviceCode.trim()) {
|
|
3214
|
-
throw
|
|
3406
|
+
throw invalidInput2("deviceCode", input.deviceCode, "is required (from beginDeviceApproval)");
|
|
3215
3407
|
}
|
|
3216
3408
|
let raw;
|
|
3217
3409
|
try {
|
|
@@ -3249,10 +3441,10 @@ var InvoServer = class {
|
|
|
3249
3441
|
async confirmDeviceEnrollment(input, opts) {
|
|
3250
3442
|
assertPlayerToken(input.playerToken);
|
|
3251
3443
|
if (typeof input.deviceCode !== "string" || !input.deviceCode.trim()) {
|
|
3252
|
-
throw
|
|
3444
|
+
throw invalidInput2("deviceCode", input.deviceCode, "is required (from beginDeviceApproval)");
|
|
3253
3445
|
}
|
|
3254
3446
|
if (input.decision !== "approve" && input.decision !== "deny") {
|
|
3255
|
-
throw
|
|
3447
|
+
throw invalidInput2("decision", input.decision, 'must be "approve" or "deny"');
|
|
3256
3448
|
}
|
|
3257
3449
|
const raw = await this.http.post(
|
|
3258
3450
|
"/api/sdk/approvals/device/confirm-enrollment",
|
|
@@ -3303,11 +3495,11 @@ var InvoServer = class {
|
|
|
3303
3495
|
async approveWithDeviceCode(input, opts) {
|
|
3304
3496
|
assertPlayerToken(input.playerToken);
|
|
3305
3497
|
if (typeof input.transactionId !== "string" || !input.transactionId.trim()) {
|
|
3306
|
-
throw
|
|
3498
|
+
throw invalidInput2("transactionId", input.transactionId, "is required");
|
|
3307
3499
|
}
|
|
3308
3500
|
assertDeviceApprovalFlow(input.flow);
|
|
3309
3501
|
if (typeof input.deviceCode !== "string" || !input.deviceCode.trim()) {
|
|
3310
|
-
throw
|
|
3502
|
+
throw invalidInput2("deviceCode", input.deviceCode, "is required (from beginDeviceApproval)");
|
|
3311
3503
|
}
|
|
3312
3504
|
let raw;
|
|
3313
3505
|
try {
|
|
@@ -3365,11 +3557,11 @@ var InvoServer = class {
|
|
|
3365
3557
|
async completeDeviceApproval(input, opts) {
|
|
3366
3558
|
assertPlayerToken(input.playerToken);
|
|
3367
3559
|
if (typeof input.transactionId !== "string" || !input.transactionId.trim()) {
|
|
3368
|
-
throw
|
|
3560
|
+
throw invalidInput2("transactionId", input.transactionId, "is required");
|
|
3369
3561
|
}
|
|
3370
3562
|
assertDeviceApprovalFlow(input.flow);
|
|
3371
3563
|
if (typeof input.deviceCode !== "string" || !input.deviceCode.trim()) {
|
|
3372
|
-
throw
|
|
3564
|
+
throw invalidInput2("deviceCode", input.deviceCode, "is required (from beginDeviceApproval)");
|
|
3373
3565
|
}
|
|
3374
3566
|
const signal = input.signal ?? opts?.signal;
|
|
3375
3567
|
const { playerToken, deviceCode } = input;
|
|
@@ -3454,6 +3646,6 @@ var InvoServer = class {
|
|
|
3454
3646
|
}
|
|
3455
3647
|
};
|
|
3456
3648
|
|
|
3457
|
-
export { CardsServer, InvoServer, PlatformCommerceServer, SDK_VERSION, SandboxServer, SandboxSubscriptionsServer, SubscriptionsServer, createWebhookHandler, isRefundPendingApproval, verifyWebhook, verifyWebhookAsync };
|
|
3649
|
+
export { CardsServer, InvoServer, PayoutsServer, PlatformCommerceServer, SDK_VERSION, SandboxServer, SandboxSubscriptionsServer, SubscriptionsServer, createWebhookHandler, isRefundPendingApproval, verifyWebhook, verifyWebhookAsync };
|
|
3458
3650
|
//# sourceMappingURL=server.js.map
|
|
3459
3651
|
//# sourceMappingURL=server.js.map
|