@invonetwork/web-sdk 3.32.0 → 3.34.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 +16 -0
- package/README.md +3006 -2963
- package/dist/chunk-73ZVDQZV.js +6 -0
- package/dist/{chunk-RPGRRZFY.js → chunk-D2AUZRYS.js} +206 -74
- package/dist/{chunk-2XOKKKFR.js → chunk-DMTNU5PM.js} +3 -3
- package/dist/{chunk-QEJB6HC7.js → chunk-R65CANFG.js} +32 -2
- package/dist/game-server.cjs +176 -5
- package/dist/game-server.d.cts +12 -8
- package/dist/game-server.d.ts +12 -8
- package/dist/game-server.js +11 -7
- package/dist/game.cjs +31 -1
- package/dist/game.d.cts +3 -3
- package/dist/game.d.ts +3 -3
- package/dist/game.js +3 -3
- package/dist/{hosted-approval-li0XZFz-.d.cts → hosted-approval-C1hQvbu6.d.cts} +1 -1
- package/dist/{hosted-approval-ICho9KsV.d.ts → hosted-approval-CFlj4UQE.d.ts} +1 -1
- package/dist/index.cjs +30 -0
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/{server-B-KKg5P0.d.ts → server-CtXpytKt.d.ts} +49 -5
- package/dist/{server-jAn9dNM3.d.cts → server-ZnCyLWA2.d.cts} +49 -5
- package/dist/server.cjs +225 -70
- package/dist/server.d.cts +3 -3
- package/dist/server.d.ts +3 -3
- package/dist/server.js +3 -3
- package/dist/{types-CaPHNjOU.d.cts → types-Ctn8N2_l.d.cts} +60 -4
- package/dist/{types-CaPHNjOU.d.ts → types-Ctn8N2_l.d.ts} +60 -4
- package/dist/{version-CqwGhQXV.d.cts → version-Ce_pLpJf.d.cts} +1 -1
- package/dist/{version-CqwGhQXV.d.ts → version-Ce_pLpJf.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-LVVPRVPU.js +0 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SDK_VERSION } from './chunk-
|
|
2
|
-
import { InvoError, assertSecureBaseUrl, Http, toRequestPhoneChangeResult, toPhoneChangeRequest, toPurchaseStatusResult, receiptFields, creditFields, toLoyaltyCardsResult, buildGameEventBody, toReportGameEventResult, toDestinationsResult } from './chunk-
|
|
1
|
+
import { SDK_VERSION } from './chunk-73ZVDQZV.js';
|
|
2
|
+
import { InvoError, assertSecureBaseUrl, Http, toRequestPhoneChangeResult, toPhoneChangeRequest, toPurchaseStatusResult, receiptFields, creditFields, toLoyaltyCardsResult, buildGameEventBody, toReportGameEventResult, toDestinationsResult } from './chunk-R65CANFG.js';
|
|
3
3
|
import { createHmac, timingSafeEqual } from 'crypto';
|
|
4
4
|
|
|
5
5
|
// src/payouts.ts
|
|
@@ -194,6 +194,152 @@ var PayoutsServer = class {
|
|
|
194
194
|
}
|
|
195
195
|
};
|
|
196
196
|
|
|
197
|
+
// src/environment.ts
|
|
198
|
+
var PRODUCTION_BASE_URL = "https://invo.network";
|
|
199
|
+
var SANDBOX_BASE_URL = "https://sandbox.invo.network/sandbox";
|
|
200
|
+
var DEMO_KEY_PREFIX = "ivsdk_demo_";
|
|
201
|
+
var TEST_KEY_PREFIX = "ivsdk_test_";
|
|
202
|
+
var LIVE_KEY_PREFIX = "ivsdk_live_";
|
|
203
|
+
var KEY_ENVIRONMENT_PATH = "/api/sdk/key-environment";
|
|
204
|
+
function environmentFromKeyPrefix(gameSecret) {
|
|
205
|
+
if (typeof gameSecret !== "string") return null;
|
|
206
|
+
if (gameSecret.startsWith(LIVE_KEY_PREFIX)) return "production";
|
|
207
|
+
if (gameSecret.startsWith(TEST_KEY_PREFIX) || gameSecret.startsWith(DEMO_KEY_PREFIX)) return "sandbox";
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
function environmentForBaseUrl(baseUrl) {
|
|
211
|
+
if (typeof baseUrl !== "string" || !baseUrl.trim()) return null;
|
|
212
|
+
let url;
|
|
213
|
+
try {
|
|
214
|
+
url = new URL(baseUrl.trim());
|
|
215
|
+
} catch {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
const host = url.hostname.toLowerCase().replace(/\.$/, "");
|
|
219
|
+
if (host === "sandbox.invo.network") return "sandbox";
|
|
220
|
+
if (host === "invo.network" || host === "www.invo.network") {
|
|
221
|
+
const first = url.pathname.split("/").filter(Boolean)[0]?.toLowerCase();
|
|
222
|
+
return first === "sandbox" ? "sandbox" : "production";
|
|
223
|
+
}
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
var KeyEnvironmentMismatchError = class extends Error {
|
|
227
|
+
constructor(message, keyEnvironment, configuredEnvironment) {
|
|
228
|
+
super(message);
|
|
229
|
+
this.name = "KeyEnvironmentMismatchError";
|
|
230
|
+
this.keyEnvironment = keyEnvironment;
|
|
231
|
+
this.configuredEnvironment = configuredEnvironment;
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
function strictKeyEnvironment(gameSecret) {
|
|
235
|
+
if (typeof gameSecret !== "string") return null;
|
|
236
|
+
if (gameSecret.startsWith(LIVE_KEY_PREFIX)) return "production";
|
|
237
|
+
if (gameSecret.startsWith(TEST_KEY_PREFIX)) return "sandbox";
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
function describeKey(env) {
|
|
241
|
+
return env === "production" ? `a live key (${LIVE_KEY_PREFIX})` : `a test key (${TEST_KEY_PREFIX})`;
|
|
242
|
+
}
|
|
243
|
+
function fixFor(keyEnv) {
|
|
244
|
+
return keyEnv === "production" ? `Use ${PRODUCTION_BASE_URL}, or a test key.` : `Use ${SANDBOX_BASE_URL}, or a live key.`;
|
|
245
|
+
}
|
|
246
|
+
function displayUrl(baseUrl) {
|
|
247
|
+
try {
|
|
248
|
+
const u = new URL(baseUrl.trim());
|
|
249
|
+
return `${u.protocol}//${u.host}${u.pathname}`.replace(/\/+$/, "");
|
|
250
|
+
} catch {
|
|
251
|
+
return "(the configured URL)";
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
function assertKeyMatchesBaseUrl(gameSecret, baseUrl, setting = "baseUrl") {
|
|
255
|
+
const keyEnv = strictKeyEnvironment(gameSecret);
|
|
256
|
+
if (!keyEnv) return;
|
|
257
|
+
const urlEnv = environmentForBaseUrl(baseUrl);
|
|
258
|
+
if (!urlEnv || urlEnv === keyEnv) return;
|
|
259
|
+
const where = urlEnv === "production" ? "production" : "the sandbox";
|
|
260
|
+
const shown = displayUrl(String(baseUrl));
|
|
261
|
+
throw new KeyEnvironmentMismatchError(
|
|
262
|
+
`This is ${describeKey(keyEnv)} but ${setting} points at ${where} ${shown}. ${fixFor(keyEnv)}`,
|
|
263
|
+
keyEnv,
|
|
264
|
+
urlEnv
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
function assertKeyMatchesEnvironment(gameSecret, environment, setting = "INVO_ENV", rawValue) {
|
|
268
|
+
const keyEnv = strictKeyEnvironment(gameSecret);
|
|
269
|
+
if (!keyEnv || keyEnv === environment) return;
|
|
270
|
+
const other = keyEnv === "production" ? "a test key" : "a live key";
|
|
271
|
+
const raw = rawValue?.trim();
|
|
272
|
+
const shown = raw && raw.toLowerCase() !== environment ? `"${raw}" (read as ${environment})` : environment;
|
|
273
|
+
throw new KeyEnvironmentMismatchError(
|
|
274
|
+
`This is ${describeKey(keyEnv)} but ${setting} is ${shown}. Remove ${setting} (the key picks the environment), or use ${other}.`,
|
|
275
|
+
keyEnv,
|
|
276
|
+
environment
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
var EnvironmentUnknownError = class extends Error {
|
|
280
|
+
constructor(message) {
|
|
281
|
+
super(message);
|
|
282
|
+
this.name = "EnvironmentUnknownError";
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
function isDemoKey(gameSecret) {
|
|
286
|
+
return typeof gameSecret === "string" && gameSecret.startsWith(DEMO_KEY_PREFIX);
|
|
287
|
+
}
|
|
288
|
+
var cache = /* @__PURE__ */ new Map();
|
|
289
|
+
async function ask(baseUrl, gameSecret, fetchImpl) {
|
|
290
|
+
let res;
|
|
291
|
+
try {
|
|
292
|
+
res = await fetchImpl(baseUrl + KEY_ENVIRONMENT_PATH, {
|
|
293
|
+
method: "GET",
|
|
294
|
+
headers: { "X-Game-Secret-Key": gameSecret, Accept: "application/json" },
|
|
295
|
+
redirect: "error"
|
|
296
|
+
});
|
|
297
|
+
} catch {
|
|
298
|
+
throw new EnvironmentUnknownError("Could not reach INVO to check the key.");
|
|
299
|
+
}
|
|
300
|
+
if (res.status === 401 || res.status === 403 || res.status === 404) return null;
|
|
301
|
+
if (!res.ok) throw new EnvironmentUnknownError(`INVO answered ${res.status} while checking the key.`);
|
|
302
|
+
const body = await res.json().catch(() => ({}));
|
|
303
|
+
return body.environment === "production" || body.environment === "sandbox" ? body.environment : null;
|
|
304
|
+
}
|
|
305
|
+
function resolveEnvironment(gameSecret, opts = {}) {
|
|
306
|
+
if (!gameSecret) return Promise.reject(new Error("A game secret is required."));
|
|
307
|
+
const byPrefix = environmentFromKeyPrefix(gameSecret);
|
|
308
|
+
if (byPrefix) return Promise.resolve(byPrefix);
|
|
309
|
+
const hit = cache.get(gameSecret);
|
|
310
|
+
if (hit) return hit;
|
|
311
|
+
const fetchImpl = opts.fetch ?? ((input, init) => fetch(input, init));
|
|
312
|
+
const p = (async () => {
|
|
313
|
+
let prodError = null;
|
|
314
|
+
let env = null;
|
|
315
|
+
try {
|
|
316
|
+
env = await ask(PRODUCTION_BASE_URL, gameSecret, fetchImpl);
|
|
317
|
+
} catch (err) {
|
|
318
|
+
prodError = err;
|
|
319
|
+
}
|
|
320
|
+
if (!env) {
|
|
321
|
+
try {
|
|
322
|
+
env = await ask(SANDBOX_BASE_URL, gameSecret, fetchImpl);
|
|
323
|
+
} catch (err) {
|
|
324
|
+
throw prodError ?? err;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
if (!env && prodError) throw prodError;
|
|
328
|
+
if (!env) {
|
|
329
|
+
throw new EnvironmentUnknownError(
|
|
330
|
+
"Neither INVO production nor the INVO sandbox recognises this key. Check INVO_GAME_SECRET in your secrets."
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
return env;
|
|
334
|
+
})();
|
|
335
|
+
cache.set(gameSecret, p);
|
|
336
|
+
p.catch(() => cache.delete(gameSecret));
|
|
337
|
+
return p;
|
|
338
|
+
}
|
|
339
|
+
async function baseUrlForKey(gameSecret, opts = {}) {
|
|
340
|
+
return await resolveEnvironment(gameSecret, opts) === "production" ? PRODUCTION_BASE_URL : SANDBOX_BASE_URL;
|
|
341
|
+
}
|
|
342
|
+
|
|
197
343
|
// src/shared/types.ts
|
|
198
344
|
function isRefundPendingApproval(r) {
|
|
199
345
|
return r.status === "pending_approval";
|
|
@@ -365,74 +511,6 @@ async function hmacHexSubtle(secret, message) {
|
|
|
365
511
|
return hex;
|
|
366
512
|
}
|
|
367
513
|
|
|
368
|
-
// src/environment.ts
|
|
369
|
-
var PRODUCTION_BASE_URL = "https://invo.network";
|
|
370
|
-
var SANDBOX_BASE_URL = "https://sandbox.invo.network/sandbox";
|
|
371
|
-
var DEMO_KEY_PREFIX = "ivsdk_demo_";
|
|
372
|
-
var KEY_ENVIRONMENT_PATH = "/api/sdk/key-environment";
|
|
373
|
-
var EnvironmentUnknownError = class extends Error {
|
|
374
|
-
constructor(message) {
|
|
375
|
-
super(message);
|
|
376
|
-
this.name = "EnvironmentUnknownError";
|
|
377
|
-
}
|
|
378
|
-
};
|
|
379
|
-
function isDemoKey(gameSecret) {
|
|
380
|
-
return typeof gameSecret === "string" && gameSecret.startsWith(DEMO_KEY_PREFIX);
|
|
381
|
-
}
|
|
382
|
-
var cache = /* @__PURE__ */ new Map();
|
|
383
|
-
async function ask(baseUrl, gameSecret, fetchImpl) {
|
|
384
|
-
let res;
|
|
385
|
-
try {
|
|
386
|
-
res = await fetchImpl(baseUrl + KEY_ENVIRONMENT_PATH, {
|
|
387
|
-
method: "GET",
|
|
388
|
-
headers: { "X-Game-Secret-Key": gameSecret, Accept: "application/json" },
|
|
389
|
-
redirect: "error"
|
|
390
|
-
});
|
|
391
|
-
} catch {
|
|
392
|
-
throw new EnvironmentUnknownError("Could not reach INVO to check the key.");
|
|
393
|
-
}
|
|
394
|
-
if (res.status === 401 || res.status === 403 || res.status === 404) return null;
|
|
395
|
-
if (!res.ok) throw new EnvironmentUnknownError(`INVO answered ${res.status} while checking the key.`);
|
|
396
|
-
const body = await res.json().catch(() => ({}));
|
|
397
|
-
return body.environment === "production" || body.environment === "sandbox" ? body.environment : null;
|
|
398
|
-
}
|
|
399
|
-
function resolveEnvironment(gameSecret, opts = {}) {
|
|
400
|
-
if (!gameSecret) return Promise.reject(new Error("A game secret is required."));
|
|
401
|
-
if (isDemoKey(gameSecret)) return Promise.resolve("sandbox");
|
|
402
|
-
const hit = cache.get(gameSecret);
|
|
403
|
-
if (hit) return hit;
|
|
404
|
-
const fetchImpl = opts.fetch ?? ((input, init) => fetch(input, init));
|
|
405
|
-
const p = (async () => {
|
|
406
|
-
let prodError = null;
|
|
407
|
-
let env = null;
|
|
408
|
-
try {
|
|
409
|
-
env = await ask(PRODUCTION_BASE_URL, gameSecret, fetchImpl);
|
|
410
|
-
} catch (err) {
|
|
411
|
-
prodError = err;
|
|
412
|
-
}
|
|
413
|
-
if (!env) {
|
|
414
|
-
try {
|
|
415
|
-
env = await ask(SANDBOX_BASE_URL, gameSecret, fetchImpl);
|
|
416
|
-
} catch (err) {
|
|
417
|
-
throw prodError ?? err;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
if (!env && prodError) throw prodError;
|
|
421
|
-
if (!env) {
|
|
422
|
-
throw new EnvironmentUnknownError(
|
|
423
|
-
"Neither INVO production nor the INVO sandbox recognises this key. Check INVO_GAME_SECRET in your secrets."
|
|
424
|
-
);
|
|
425
|
-
}
|
|
426
|
-
return env;
|
|
427
|
-
})();
|
|
428
|
-
cache.set(gameSecret, p);
|
|
429
|
-
p.catch(() => cache.delete(gameSecret));
|
|
430
|
-
return p;
|
|
431
|
-
}
|
|
432
|
-
async function baseUrlForKey(gameSecret, opts = {}) {
|
|
433
|
-
return await resolveEnvironment(gameSecret, opts) === "production" ? PRODUCTION_BASE_URL : SANDBOX_BASE_URL;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
514
|
// src/server.ts
|
|
437
515
|
var DEFAULT_UA = `invonetwork-web-sdk/${SDK_VERSION} (+https://invo.network)`;
|
|
438
516
|
var MAX_USD_AMOUNT = 999999.99;
|
|
@@ -692,6 +770,23 @@ function toPlayerActivityEntry(raw) {
|
|
|
692
770
|
raw
|
|
693
771
|
};
|
|
694
772
|
}
|
|
773
|
+
function toPlatformApproval(raw) {
|
|
774
|
+
const s = (k) => raw[k] == null ? null : String(raw[k]);
|
|
775
|
+
const meta = raw["metadata"];
|
|
776
|
+
return {
|
|
777
|
+
approvalId: String(raw["approval_id"] ?? ""),
|
|
778
|
+
clientRequestId: String(raw["client_request_id"] ?? ""),
|
|
779
|
+
status: String(raw["status"] ?? ""),
|
|
780
|
+
reason: s("reason"),
|
|
781
|
+
totalPrice: s("total_price"),
|
|
782
|
+
orderId: raw["order_id"] ?? null,
|
|
783
|
+
transactionId: s("transaction_id"),
|
|
784
|
+
expiresAt: s("expires_at"),
|
|
785
|
+
decidedAt: s("decided_at"),
|
|
786
|
+
metadata: meta && typeof meta === "object" && !Array.isArray(meta) ? meta : {},
|
|
787
|
+
raw
|
|
788
|
+
};
|
|
789
|
+
}
|
|
695
790
|
function toPlatformOrderStatus(raw, fallbackOrderId) {
|
|
696
791
|
return {
|
|
697
792
|
orderId: raw["order_id"] ?? fallbackOrderId ?? "",
|
|
@@ -998,6 +1093,10 @@ var PlatformCommerceServer = class {
|
|
|
998
1093
|
if (input.successUrl) body["success_url"] = input.successUrl;
|
|
999
1094
|
if (input.cancelUrl) body["cancel_url"] = input.cancelUrl;
|
|
1000
1095
|
if (input.metadata) body["metadata"] = input.metadata;
|
|
1096
|
+
if (input.requirePlayerApproval === true) {
|
|
1097
|
+
body["require_player_approval"] = true;
|
|
1098
|
+
if (input.returnUrl) body["return_url"] = input.returnUrl;
|
|
1099
|
+
}
|
|
1001
1100
|
const raw = await this.http.post(
|
|
1002
1101
|
"/api/platform-commerce/purchase",
|
|
1003
1102
|
body,
|
|
@@ -1006,7 +1105,9 @@ var PlatformCommerceServer = class {
|
|
|
1006
1105
|
{ idempotent: true, signal: opts?.signal }
|
|
1007
1106
|
);
|
|
1008
1107
|
const status = String(raw["status"] ?? "");
|
|
1009
|
-
if (status === "
|
|
1108
|
+
if (status === "pending_approval") {
|
|
1109
|
+
requireField(raw["approval_id"], "approval_id", raw);
|
|
1110
|
+
} else if (status === "requires_payment") {
|
|
1010
1111
|
requireField(raw["checkout_url"], "checkout_url", raw);
|
|
1011
1112
|
} else {
|
|
1012
1113
|
requireField(raw["order_id"], "order_id", raw);
|
|
@@ -1027,9 +1128,39 @@ var PlatformCommerceServer = class {
|
|
|
1027
1128
|
amountUsd: raw["amount_usd"] ?? null,
|
|
1028
1129
|
idempotentReplay: raw["idempotent_replay"] === true,
|
|
1029
1130
|
...minPurchaseWarningField(raw),
|
|
1131
|
+
...raw["approval_id"] != null ? { approvalId: String(raw["approval_id"]) } : {},
|
|
1132
|
+
..."approval_url" in raw ? { approvalUrl: raw["approval_url"] ?? null } : {},
|
|
1030
1133
|
raw
|
|
1031
1134
|
};
|
|
1032
1135
|
}
|
|
1136
|
+
/** Read a buyer-approved purchase (3.33.0) by `approvalId` or by your `clientRequestId`
|
|
1137
|
+
* (exactly one). A fallback to the webhooks: `completed` carries `orderId`; an ending
|
|
1138
|
+
* without a sale carries `reason`. Throws `err.isApprovalNotFound` (404). */
|
|
1139
|
+
async getApproval(key, opts) {
|
|
1140
|
+
const id = key?.approvalId;
|
|
1141
|
+
const crid = key?.clientRequestId;
|
|
1142
|
+
if (Boolean(id) === Boolean(crid)) {
|
|
1143
|
+
throw invalidInput2("approvalId", id, "provide exactly one of approvalId or clientRequestId");
|
|
1144
|
+
}
|
|
1145
|
+
const path = id ? `/api/platform-commerce/approvals/${encodeURIComponent(String(id))}` : `/api/platform-commerce/approvals?${new URLSearchParams({ client_request_id: String(crid) }).toString()}`;
|
|
1146
|
+
const raw = await this.http.get(path, this.auth, { signal: opts?.signal });
|
|
1147
|
+
return toPlatformApproval(raw);
|
|
1148
|
+
}
|
|
1149
|
+
/** Withdraw a buyer-approved purchase that is still waiting (3.33.0).
|
|
1150
|
+
* `platform_commerce.declined` follows with reason `cancelled`. Throws
|
|
1151
|
+
* `err.isApprovalAlreadyEnded` (409) when it had already ended. */
|
|
1152
|
+
async cancelApproval(approvalId, opts) {
|
|
1153
|
+
if (typeof approvalId !== "string" || !approvalId.trim()) {
|
|
1154
|
+
throw invalidInput2("approvalId", approvalId, "is required");
|
|
1155
|
+
}
|
|
1156
|
+
const raw = await this.http.post(
|
|
1157
|
+
`/api/platform-commerce/approvals/${encodeURIComponent(approvalId)}/cancel`,
|
|
1158
|
+
{},
|
|
1159
|
+
this.auth,
|
|
1160
|
+
{ idempotent: true, signal: opts?.signal }
|
|
1161
|
+
);
|
|
1162
|
+
return toPlatformApproval(raw);
|
|
1163
|
+
}
|
|
1033
1164
|
/** Poll an order's status: `completed` (balance immediately; card after the webhook),
|
|
1034
1165
|
* `pending_payment` (card awaiting confirmation), or `refunded`. Once the sale has settled,
|
|
1035
1166
|
* `invoFeeUsd` / `partnerShareUsd` say what INVO kept and what you earned (additive). */
|
|
@@ -2256,6 +2387,7 @@ var InvoServer = class {
|
|
|
2256
2387
|
if (!config.gameSecret) throw new Error("InvoServer requires a `gameSecret`.");
|
|
2257
2388
|
if (!config.baseUrl) throw new Error("InvoServer requires a `baseUrl`.");
|
|
2258
2389
|
assertSecureBaseUrl(config.baseUrl);
|
|
2390
|
+
assertKeyMatchesBaseUrl(config.gameSecret.trim(), config.baseUrl);
|
|
2259
2391
|
this.http = new Http({
|
|
2260
2392
|
baseUrl: config.baseUrl,
|
|
2261
2393
|
timeoutMs: config.timeoutMs,
|
|
@@ -3801,6 +3933,6 @@ var InvoServer = class {
|
|
|
3801
3933
|
}
|
|
3802
3934
|
};
|
|
3803
3935
|
|
|
3804
|
-
export { CardsServer, DEMO_KEY_PREFIX, EnvironmentUnknownError, InvoServer, PRODUCTION_BASE_URL, PayoutsServer, PlatformCommerceServer, SANDBOX_BASE_URL, SandboxServer, SandboxSubscriptionsServer, SubscriptionsServer, baseUrlForKey, createWebhookHandler, isDemoKey, isRefundPendingApproval, resolveEnvironment, verifyInvoSignature, verifyWebhook, verifyWebhookAsync };
|
|
3805
|
-
//# sourceMappingURL=chunk-
|
|
3806
|
-
//# sourceMappingURL=chunk-
|
|
3936
|
+
export { CardsServer, DEMO_KEY_PREFIX, EnvironmentUnknownError, InvoServer, KeyEnvironmentMismatchError, LIVE_KEY_PREFIX, PRODUCTION_BASE_URL, PayoutsServer, PlatformCommerceServer, SANDBOX_BASE_URL, SandboxServer, SandboxSubscriptionsServer, SubscriptionsServer, TEST_KEY_PREFIX, assertKeyMatchesBaseUrl, assertKeyMatchesEnvironment, baseUrlForKey, createWebhookHandler, environmentForBaseUrl, environmentFromKeyPrefix, isDemoKey, isRefundPendingApproval, resolveEnvironment, verifyInvoSignature, verifyWebhook, verifyWebhookAsync };
|
|
3937
|
+
//# sourceMappingURL=chunk-D2AUZRYS.js.map
|
|
3938
|
+
//# sourceMappingURL=chunk-D2AUZRYS.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InvoError, assertSecureBaseUrl, Http, toPurchaseStatusResult, toPhoneChangeApprovalsResult, phoneChangeSignalMessage, toApprovePhoneChangeResult, toDestinationsResult, toLoyaltyCardsResult, toLoyaltyVaultResult, toRedeemRewardResult, toRewardsPageLink, buildGameEventBody, toReportGameEventResult } from './chunk-
|
|
1
|
+
import { InvoError, assertSecureBaseUrl, Http, toPurchaseStatusResult, toPhoneChangeApprovalsResult, phoneChangeSignalMessage, toApprovePhoneChangeResult, toDestinationsResult, toLoyaltyCardsResult, toLoyaltyVaultResult, toRedeemRewardResult, toRewardsPageLink, buildGameEventBody, toReportGameEventResult } from './chunk-R65CANFG.js';
|
|
2
2
|
|
|
3
3
|
// src/shared/webauthn.ts
|
|
4
4
|
function malformedOptions(field) {
|
|
@@ -1586,5 +1586,5 @@ var InvoClient = class {
|
|
|
1586
1586
|
};
|
|
1587
1587
|
|
|
1588
1588
|
export { CheckoutClient, InvoClient, PlatformCommerceClient };
|
|
1589
|
-
//# sourceMappingURL=chunk-
|
|
1590
|
-
//# sourceMappingURL=chunk-
|
|
1589
|
+
//# sourceMappingURL=chunk-DMTNU5PM.js.map
|
|
1590
|
+
//# sourceMappingURL=chunk-DMTNU5PM.js.map
|
|
@@ -345,6 +345,36 @@ var InvoError = class _InvoError extends Error {
|
|
|
345
345
|
get isPaymentsPaused() {
|
|
346
346
|
return this.code === "PAYMENTS_PAUSED";
|
|
347
347
|
}
|
|
348
|
+
/** The key belongs to the other INVO environment (`KEY_FOR_OTHER_ENVIRONMENT`, 401;
|
|
349
|
+
* additive, 3.34.0): a test key (`ivsdk_test_`) sent to production, or a live key
|
|
350
|
+
* (`ivsdk_live_`) sent to the sandbox. Never retried. Use the key for the environment
|
|
351
|
+
* you are calling, or point the SDK at the environment the key is for. The code is
|
|
352
|
+
* matched on any code field (`code`, `rawCode`, `publicCode`, or the body's
|
|
353
|
+
* `error_code` / `code`), since the 401 may carry a different `code`. */
|
|
354
|
+
get isKeyForOtherEnvironment() {
|
|
355
|
+
const C = "KEY_FOR_OTHER_ENVIRONMENT";
|
|
356
|
+
const b = this.bodyObject();
|
|
357
|
+
return this.code === C || this.rawCode === C || this.publicCode === C || b["error_code"] === C || b["code"] === C;
|
|
358
|
+
}
|
|
359
|
+
/** A buyer-approved balance purchase cannot start (`BALANCE_UNAVAILABLE`, 400; 3.33.0):
|
|
360
|
+
* the buyer is unknown here or their balance is short. One answer on purpose; the
|
|
361
|
+
* balance is never disclosed. Offer another way to pay. */
|
|
362
|
+
get isBalanceUnavailable() {
|
|
363
|
+
return this.code === "BALANCE_UNAVAILABLE";
|
|
364
|
+
}
|
|
365
|
+
/** Buyer approval is not available (`APPROVAL_NOT_AVAILABLE`, 503 or 409; 3.33.0). */
|
|
366
|
+
get isApprovalNotAvailable() {
|
|
367
|
+
return this.code === "APPROVAL_NOT_AVAILABLE";
|
|
368
|
+
}
|
|
369
|
+
/** No buyer-approved purchase with that id in your store (`APPROVAL_NOT_FOUND`, 404). */
|
|
370
|
+
get isApprovalNotFound() {
|
|
371
|
+
return this.code === "APPROVAL_NOT_FOUND";
|
|
372
|
+
}
|
|
373
|
+
/** `cancelApproval` on an approval that already ended (`APPROVAL_ALREADY_ENDED`, 409).
|
|
374
|
+
* Read it with `getApproval`: it may have completed. */
|
|
375
|
+
get isApprovalAlreadyEnded() {
|
|
376
|
+
return this.code === "APPROVAL_ALREADY_ENDED";
|
|
377
|
+
}
|
|
348
378
|
/** True when init-purchase was given a `packId` that is not in INVO's Steam
|
|
349
379
|
* catalogue (`UNKNOWN_STEAM_PACK`, 400). The error body's
|
|
350
380
|
* `valid_pack_ids` lists what exists; re-fetch `steamPacks()` — the
|
|
@@ -1744,5 +1774,5 @@ function toApprovePhoneChangeResult(raw, changeRequestId) {
|
|
|
1744
1774
|
}
|
|
1745
1775
|
|
|
1746
1776
|
export { Http, InvoError, assertSecureBaseUrl, buildGameEventBody, creditFields, isPurchaseCredited, isPurchaseExpired, isPurchaseRefunded, isPurchaseRefused, newEventId, nothingWasCharged, phoneChangeSignalMessage, receiptFields, toApprovePhoneChangeResult, toDestinationsResult, toLoyaltyCardsResult, toLoyaltyVaultResult, toPhoneChangeApprovalsResult, toPhoneChangeRequest, toPurchaseStatusResult, toRedeemRewardResult, toReportGameEventResult, toRequestPhoneChangeResult, toRewardsPageLink };
|
|
1747
|
-
//# sourceMappingURL=chunk-
|
|
1748
|
-
//# sourceMappingURL=chunk-
|
|
1777
|
+
//# sourceMappingURL=chunk-R65CANFG.js.map
|
|
1778
|
+
//# sourceMappingURL=chunk-R65CANFG.js.map
|