@invonetwork/web-sdk 3.26.1 → 3.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2237,6 +2237,71 @@ function toRewardsPageLink(raw) {
2237
2237
  return { url: str2(raw["url"]), expiresAt: str2(raw["expires_at"]), raw };
2238
2238
  }
2239
2239
 
2240
+ // src/shared/loyalty-events.ts
2241
+ var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
2242
+ var ISO_WITH_ZONE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})$/;
2243
+ function invalid(label, value, why) {
2244
+ return new InvoError({
2245
+ message: `${label} ${why} (got ${JSON.stringify(value)}).`,
2246
+ code: "INVALID_INPUT",
2247
+ status: 0
2248
+ });
2249
+ }
2250
+ function newEventId() {
2251
+ const c = globalThis.crypto;
2252
+ if (c && typeof c.randomUUID === "function") return c.randomUUID();
2253
+ const bytes = new Uint8Array(16);
2254
+ if (c && typeof c.getRandomValues === "function") {
2255
+ c.getRandomValues(bytes);
2256
+ } else {
2257
+ throw new InvoError({
2258
+ message: "No Web Crypto available to generate an eventId; pass `eventId` yourself.",
2259
+ code: "INVALID_INPUT",
2260
+ status: 0
2261
+ });
2262
+ }
2263
+ bytes[6] = bytes[6] & 15 | 64;
2264
+ bytes[8] = bytes[8] & 63 | 128;
2265
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
2266
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
2267
+ }
2268
+ function buildGameEventBody(input) {
2269
+ if (!input || typeof input !== "object") throw invalid("input", input, "must be an object");
2270
+ const { eventType, payload } = input;
2271
+ if (typeof eventType !== "string" || !eventType.startsWith("game.") || eventType.length > 120) {
2272
+ throw invalid("eventType", eventType, "must be a game.* event type");
2273
+ }
2274
+ const eventId = input.eventId === void 0 ? newEventId() : input.eventId;
2275
+ if (typeof eventId !== "string" || !UUID.test(eventId)) {
2276
+ throw invalid("eventId", eventId, "must be a UUID");
2277
+ }
2278
+ const body = { event_type: eventType, event_id: eventId };
2279
+ if (input.occurredAt !== void 0) {
2280
+ const at = input.occurredAt instanceof Date ? input.occurredAt.toISOString() : input.occurredAt;
2281
+ if (typeof at !== "string" || !ISO_WITH_ZONE.test(at) || Number.isNaN(Date.parse(at))) {
2282
+ throw invalid("occurredAt", input.occurredAt, "must be ISO 8601 with a timezone, or a Date");
2283
+ }
2284
+ body["occurred_at"] = at;
2285
+ }
2286
+ if (payload !== void 0) {
2287
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
2288
+ throw invalid("payload", payload, "must be a plain object");
2289
+ }
2290
+ body["payload"] = payload;
2291
+ } else {
2292
+ body["payload"] = {};
2293
+ }
2294
+ return { body, eventId };
2295
+ }
2296
+ function toReportGameEventResult(raw, eventId) {
2297
+ const echoed = raw["event_id"];
2298
+ return {
2299
+ accepted: true,
2300
+ eventId: typeof echoed === "string" && echoed ? echoed : eventId,
2301
+ raw
2302
+ };
2303
+ }
2304
+
2240
2305
  // src/shared/phone-change.ts
2241
2306
  function phoneChangeSignalMessage(changeRequestId, nonce, timestamp, decision = "approve") {
2242
2307
  const action = decision === "deny" ? "phone-change-deny" : "phone-change";
@@ -2999,6 +3064,28 @@ var InvoClient = class {
2999
3064
  return toRewardsPageLink(raw);
3000
3065
  });
3001
3066
  }
3067
+ /**
3068
+ * Report a gameplay event for the signed-in player to INVO's loyalty engine
3069
+ * (`POST /api/sdk/loyalty/events`, player token). Use it for sessions, milestones and
3070
+ * registered custom events (see {@link GameEventType}). Events your SERVER reports with
3071
+ * `InvoServer.reportGameEvent` are the ones trusted for rewards; prefer those when a
3072
+ * reward depends on the event.
3073
+ *
3074
+ * Pass your own `eventId` (a UUID) or reuse the returned one if you retry, so INVO counts
3075
+ * the event once. Not auto-retried from the browser.
3076
+ *
3077
+ * Refusals: `INVALID_INPUT` before the network (non-`game.*` type, malformed `eventId`,
3078
+ * `occurredAt` without a timezone, non-object payload); `400 RESERVED_EVENT_TYPE` /
3079
+ * `EVENT_TYPE_NOT_ALLOWED`; `401 SDK_TOKEN_MISSING` / `SDK_TOKEN_WRONG_SCOPE`;
3080
+ * `422 validation_failed`.
3081
+ */
3082
+ async reportGameEvent(input, opts) {
3083
+ const { body, eventId } = buildGameEventBody(input);
3084
+ return this.withTokenRetry(async () => {
3085
+ const raw = await this.post("/api/sdk/loyalty/events", body, opts?.signal);
3086
+ return toReportGameEventResult(raw ?? {}, eventId);
3087
+ });
3088
+ }
3002
3089
  /**
3003
3090
  * First-enrollment OTP grant (§4.2). When `enrollPasskey()` throws
3004
3091
  * `ENROLLMENT_REQUIRES_AUTHORIZATION` (`err.isEnrollmentAuthorizationRequired`), call
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as ApproveResult, C as ConfirmReceiptResult, P as PurchaseStatusResult, a as PurchaseCredited, b as PurchaseExpired, c as PurchaseRefunded, d as PurchaseRefused, e as CheckoutClientConfig, H as Http, f as PurchaseStatusInput, g as CallOptions, W as WaitForPurchaseInput, M as MountCheckoutOptions, h as CheckoutMountHandle, i as ClientConfig, j as PhoneChangeApprovalsResult, k as ApprovePhoneChangeInput, l as ApprovePhoneChangeResult, L as LinkDeviceResult, m as PendingCollectResult, D as DestinationsQuery, n as DestinationsResult, B as BalanceResult, o as LoyaltyCardsResult, p as LoyaltyVaultResult, R as RedeemRewardResult, q as RewardsPageLink, E as EnrollmentBeginResult, r as EnrollmentVerifyResult, s as RecoveryBeginResult, t as RecoveryCompleteResult } from './types-Cjd4SAR8.cjs';
2
- export { u as BalanceRow, v as CheckoutPurchaseStatus, w as ClaimDelivery, x as DestinationGame, I as InvoError, y as InvoErrorInfo, z as InvoHooks, F as InvoRequestInfo, G as InvoResponseInfo, J as LoyaltyCard, K as LoyaltyCardReward, N as LoyaltyCardStep, O as LoyaltyRewardState, Q as LoyaltyStepProgress, S as LoyaltyStepState, T as LoyaltyVaultEntry, U as PendingCollectItem, V as PhoneChangeApproval, X as PhoneChangeDeviceSignal, Y as PurchaseRefusalReason, Z as Rail, _ as VerificationMethod } from './types-Cjd4SAR8.cjs';
1
+ import { A as ApproveResult, C as ConfirmReceiptResult, P as PurchaseStatusResult, a as PurchaseCredited, b as PurchaseExpired, c as PurchaseRefunded, d as PurchaseRefused, e as CheckoutClientConfig, H as Http, f as PurchaseStatusInput, g as CallOptions, W as WaitForPurchaseInput, M as MountCheckoutOptions, h as CheckoutMountHandle, i as ClientConfig, j as PhoneChangeApprovalsResult, k as ApprovePhoneChangeInput, l as ApprovePhoneChangeResult, L as LinkDeviceResult, m as PendingCollectResult, D as DestinationsQuery, n as DestinationsResult, B as BalanceResult, o as LoyaltyCardsResult, p as LoyaltyVaultResult, R as RedeemRewardResult, q as RewardsPageLink, r as ReportGameEventInput, s as ReportGameEventResult, E as EnrollmentBeginResult, t as EnrollmentVerifyResult, u as RecoveryBeginResult, v as RecoveryCompleteResult } from './types-_lIm74kd.cjs';
2
+ export { w as BalanceRow, x as CheckoutPurchaseStatus, y as ClaimDelivery, z as DestinationGame, G as GameEventType, I as InvoError, F as InvoErrorInfo, J as InvoHooks, K as InvoRequestInfo, N as InvoResponseInfo, O as LoyaltyCard, Q as LoyaltyCardReward, S as LoyaltyCardStep, T as LoyaltyRewardState, U as LoyaltyStepProgress, V as LoyaltyStepState, X as LoyaltyVaultEntry, Y as PendingCollectItem, Z as PhoneChangeApproval, _ as PhoneChangeDeviceSignal, $ as PurchaseRefusalReason, a0 as Rail, a1 as VerificationMethod } from './types-_lIm74kd.cjs';
3
3
 
4
4
  /** The four device-approval flows (`begin.flow`). */
5
5
  type HostedFlow = "transfer" | "send" | "send_receipt" | "transfer_receipt";
@@ -444,6 +444,22 @@ declare class InvoClient {
444
444
  * the page; never share or store it.
445
445
  */
446
446
  getRewardsPageLink(opts?: CallOptions): Promise<RewardsPageLink>;
447
+ /**
448
+ * Report a gameplay event for the signed-in player to INVO's loyalty engine
449
+ * (`POST /api/sdk/loyalty/events`, player token). Use it for sessions, milestones and
450
+ * registered custom events (see {@link GameEventType}). Events your SERVER reports with
451
+ * `InvoServer.reportGameEvent` are the ones trusted for rewards; prefer those when a
452
+ * reward depends on the event.
453
+ *
454
+ * Pass your own `eventId` (a UUID) or reuse the returned one if you retry, so INVO counts
455
+ * the event once. Not auto-retried from the browser.
456
+ *
457
+ * Refusals: `INVALID_INPUT` before the network (non-`game.*` type, malformed `eventId`,
458
+ * `occurredAt` without a timezone, non-object payload); `400 RESERVED_EVENT_TYPE` /
459
+ * `EVENT_TYPE_NOT_ALLOWED`; `401 SDK_TOKEN_MISSING` / `SDK_TOKEN_WRONG_SCOPE`;
460
+ * `422 validation_failed`.
461
+ */
462
+ reportGameEvent(input: ReportGameEventInput, opts?: CallOptions): Promise<ReportGameEventResult>;
447
463
  /**
448
464
  * First-enrollment OTP grant (§4.2). When `enrollPasskey()` throws
449
465
  * `ENROLLMENT_REQUIRES_AUTHORIZATION` (`err.isEnrollmentAuthorizationRequired`), call
@@ -506,4 +522,4 @@ declare class InvoClient {
506
522
  private confirmReceipt;
507
523
  }
508
524
 
509
- export { type ApproveHostedOptions, type ApproveHostedResult, ApprovePhoneChangeInput, ApprovePhoneChangeResult, ApproveResult, BalanceResult, CallOptions, CheckoutClient, CheckoutClientConfig, CheckoutMountHandle, ClientConfig, ConfirmReceiptResult, DestinationsQuery, DestinationsResult, EnrollmentBeginResult, type EnrollmentDecision, type EnrollmentRespond, EnrollmentVerifyResult, type HostedApprovalStatus, type HostedEnrollment, type HostedEnrollmentInput, type HostedFlow, InvoClient, LinkDeviceResult, LoyaltyCardsResult, LoyaltyVaultResult, MountCheckoutOptions, PendingCollectResult, PhoneChangeApprovalsResult, PlatformCommerceClient, PurchaseCredited, PurchaseExpired, PurchaseRefunded, PurchaseRefused, PurchaseStatusInput, PurchaseStatusResult, RecoveryBeginResult, RecoveryCompleteResult, RedeemRewardResult, RewardsPageLink, WaitForPurchaseInput, isPurchaseCredited, isPurchaseExpired, isPurchaseRefunded, isPurchaseRefused, nothingWasCharged, phoneChangeSignalMessage };
525
+ export { type ApproveHostedOptions, type ApproveHostedResult, ApprovePhoneChangeInput, ApprovePhoneChangeResult, ApproveResult, BalanceResult, CallOptions, CheckoutClient, CheckoutClientConfig, CheckoutMountHandle, ClientConfig, ConfirmReceiptResult, DestinationsQuery, DestinationsResult, EnrollmentBeginResult, type EnrollmentDecision, type EnrollmentRespond, EnrollmentVerifyResult, type HostedApprovalStatus, type HostedEnrollment, type HostedEnrollmentInput, type HostedFlow, InvoClient, LinkDeviceResult, LoyaltyCardsResult, LoyaltyVaultResult, MountCheckoutOptions, PendingCollectResult, PhoneChangeApprovalsResult, PlatformCommerceClient, PurchaseCredited, PurchaseExpired, PurchaseRefunded, PurchaseRefused, PurchaseStatusInput, PurchaseStatusResult, RecoveryBeginResult, RecoveryCompleteResult, RedeemRewardResult, ReportGameEventInput, ReportGameEventResult, RewardsPageLink, WaitForPurchaseInput, isPurchaseCredited, isPurchaseExpired, isPurchaseRefunded, isPurchaseRefused, nothingWasCharged, phoneChangeSignalMessage };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as ApproveResult, C as ConfirmReceiptResult, P as PurchaseStatusResult, a as PurchaseCredited, b as PurchaseExpired, c as PurchaseRefunded, d as PurchaseRefused, e as CheckoutClientConfig, H as Http, f as PurchaseStatusInput, g as CallOptions, W as WaitForPurchaseInput, M as MountCheckoutOptions, h as CheckoutMountHandle, i as ClientConfig, j as PhoneChangeApprovalsResult, k as ApprovePhoneChangeInput, l as ApprovePhoneChangeResult, L as LinkDeviceResult, m as PendingCollectResult, D as DestinationsQuery, n as DestinationsResult, B as BalanceResult, o as LoyaltyCardsResult, p as LoyaltyVaultResult, R as RedeemRewardResult, q as RewardsPageLink, E as EnrollmentBeginResult, r as EnrollmentVerifyResult, s as RecoveryBeginResult, t as RecoveryCompleteResult } from './types-Cjd4SAR8.js';
2
- export { u as BalanceRow, v as CheckoutPurchaseStatus, w as ClaimDelivery, x as DestinationGame, I as InvoError, y as InvoErrorInfo, z as InvoHooks, F as InvoRequestInfo, G as InvoResponseInfo, J as LoyaltyCard, K as LoyaltyCardReward, N as LoyaltyCardStep, O as LoyaltyRewardState, Q as LoyaltyStepProgress, S as LoyaltyStepState, T as LoyaltyVaultEntry, U as PendingCollectItem, V as PhoneChangeApproval, X as PhoneChangeDeviceSignal, Y as PurchaseRefusalReason, Z as Rail, _ as VerificationMethod } from './types-Cjd4SAR8.js';
1
+ import { A as ApproveResult, C as ConfirmReceiptResult, P as PurchaseStatusResult, a as PurchaseCredited, b as PurchaseExpired, c as PurchaseRefunded, d as PurchaseRefused, e as CheckoutClientConfig, H as Http, f as PurchaseStatusInput, g as CallOptions, W as WaitForPurchaseInput, M as MountCheckoutOptions, h as CheckoutMountHandle, i as ClientConfig, j as PhoneChangeApprovalsResult, k as ApprovePhoneChangeInput, l as ApprovePhoneChangeResult, L as LinkDeviceResult, m as PendingCollectResult, D as DestinationsQuery, n as DestinationsResult, B as BalanceResult, o as LoyaltyCardsResult, p as LoyaltyVaultResult, R as RedeemRewardResult, q as RewardsPageLink, r as ReportGameEventInput, s as ReportGameEventResult, E as EnrollmentBeginResult, t as EnrollmentVerifyResult, u as RecoveryBeginResult, v as RecoveryCompleteResult } from './types-_lIm74kd.js';
2
+ export { w as BalanceRow, x as CheckoutPurchaseStatus, y as ClaimDelivery, z as DestinationGame, G as GameEventType, I as InvoError, F as InvoErrorInfo, J as InvoHooks, K as InvoRequestInfo, N as InvoResponseInfo, O as LoyaltyCard, Q as LoyaltyCardReward, S as LoyaltyCardStep, T as LoyaltyRewardState, U as LoyaltyStepProgress, V as LoyaltyStepState, X as LoyaltyVaultEntry, Y as PendingCollectItem, Z as PhoneChangeApproval, _ as PhoneChangeDeviceSignal, $ as PurchaseRefusalReason, a0 as Rail, a1 as VerificationMethod } from './types-_lIm74kd.js';
3
3
 
4
4
  /** The four device-approval flows (`begin.flow`). */
5
5
  type HostedFlow = "transfer" | "send" | "send_receipt" | "transfer_receipt";
@@ -444,6 +444,22 @@ declare class InvoClient {
444
444
  * the page; never share or store it.
445
445
  */
446
446
  getRewardsPageLink(opts?: CallOptions): Promise<RewardsPageLink>;
447
+ /**
448
+ * Report a gameplay event for the signed-in player to INVO's loyalty engine
449
+ * (`POST /api/sdk/loyalty/events`, player token). Use it for sessions, milestones and
450
+ * registered custom events (see {@link GameEventType}). Events your SERVER reports with
451
+ * `InvoServer.reportGameEvent` are the ones trusted for rewards; prefer those when a
452
+ * reward depends on the event.
453
+ *
454
+ * Pass your own `eventId` (a UUID) or reuse the returned one if you retry, so INVO counts
455
+ * the event once. Not auto-retried from the browser.
456
+ *
457
+ * Refusals: `INVALID_INPUT` before the network (non-`game.*` type, malformed `eventId`,
458
+ * `occurredAt` without a timezone, non-object payload); `400 RESERVED_EVENT_TYPE` /
459
+ * `EVENT_TYPE_NOT_ALLOWED`; `401 SDK_TOKEN_MISSING` / `SDK_TOKEN_WRONG_SCOPE`;
460
+ * `422 validation_failed`.
461
+ */
462
+ reportGameEvent(input: ReportGameEventInput, opts?: CallOptions): Promise<ReportGameEventResult>;
447
463
  /**
448
464
  * First-enrollment OTP grant (§4.2). When `enrollPasskey()` throws
449
465
  * `ENROLLMENT_REQUIRES_AUTHORIZATION` (`err.isEnrollmentAuthorizationRequired`), call
@@ -506,4 +522,4 @@ declare class InvoClient {
506
522
  private confirmReceipt;
507
523
  }
508
524
 
509
- export { type ApproveHostedOptions, type ApproveHostedResult, ApprovePhoneChangeInput, ApprovePhoneChangeResult, ApproveResult, BalanceResult, CallOptions, CheckoutClient, CheckoutClientConfig, CheckoutMountHandle, ClientConfig, ConfirmReceiptResult, DestinationsQuery, DestinationsResult, EnrollmentBeginResult, type EnrollmentDecision, type EnrollmentRespond, EnrollmentVerifyResult, type HostedApprovalStatus, type HostedEnrollment, type HostedEnrollmentInput, type HostedFlow, InvoClient, LinkDeviceResult, LoyaltyCardsResult, LoyaltyVaultResult, MountCheckoutOptions, PendingCollectResult, PhoneChangeApprovalsResult, PlatformCommerceClient, PurchaseCredited, PurchaseExpired, PurchaseRefunded, PurchaseRefused, PurchaseStatusInput, PurchaseStatusResult, RecoveryBeginResult, RecoveryCompleteResult, RedeemRewardResult, RewardsPageLink, WaitForPurchaseInput, isPurchaseCredited, isPurchaseExpired, isPurchaseRefunded, isPurchaseRefused, nothingWasCharged, phoneChangeSignalMessage };
525
+ export { type ApproveHostedOptions, type ApproveHostedResult, ApprovePhoneChangeInput, ApprovePhoneChangeResult, ApproveResult, BalanceResult, CallOptions, CheckoutClient, CheckoutClientConfig, CheckoutMountHandle, ClientConfig, ConfirmReceiptResult, DestinationsQuery, DestinationsResult, EnrollmentBeginResult, type EnrollmentDecision, type EnrollmentRespond, EnrollmentVerifyResult, type HostedApprovalStatus, type HostedEnrollment, type HostedEnrollmentInput, type HostedFlow, InvoClient, LinkDeviceResult, LoyaltyCardsResult, LoyaltyVaultResult, MountCheckoutOptions, PendingCollectResult, PhoneChangeApprovalsResult, PlatformCommerceClient, PurchaseCredited, PurchaseExpired, PurchaseRefunded, PurchaseRefused, PurchaseStatusInput, PurchaseStatusResult, RecoveryBeginResult, RecoveryCompleteResult, RedeemRewardResult, ReportGameEventInput, ReportGameEventResult, RewardsPageLink, WaitForPurchaseInput, isPurchaseCredited, isPurchaseExpired, isPurchaseRefunded, isPurchaseRefused, nothingWasCharged, phoneChangeSignalMessage };
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
- import { InvoError, assertSecureBaseUrl, Http, toPhoneChangeApprovalsResult, phoneChangeSignalMessage, toApprovePhoneChangeResult, toDestinationsResult, toLoyaltyCardsResult, toLoyaltyVaultResult, toRedeemRewardResult, toRewardsPageLink, receiptFields } from './chunk-7BYAUHTA.js';
2
- export { InvoError, phoneChangeSignalMessage } from './chunk-7BYAUHTA.js';
1
+ import { assertSecureBaseUrl, Http, toPhoneChangeApprovalsResult, phoneChangeSignalMessage, toApprovePhoneChangeResult, toDestinationsResult, toLoyaltyCardsResult, toLoyaltyVaultResult, toRedeemRewardResult, toRewardsPageLink, receiptFields } from './chunk-6CN236QH.js';
2
+ export { phoneChangeSignalMessage } from './chunk-6CN236QH.js';
3
+ import { InvoError, buildGameEventBody, toReportGameEventResult } from './chunk-VP3OK4J4.js';
4
+ export { InvoError } from './chunk-VP3OK4J4.js';
3
5
 
4
6
  // src/shared/webauthn.ts
5
7
  function malformedOptions(field) {
@@ -1429,6 +1431,28 @@ var InvoClient = class {
1429
1431
  return toRewardsPageLink(raw);
1430
1432
  });
1431
1433
  }
1434
+ /**
1435
+ * Report a gameplay event for the signed-in player to INVO's loyalty engine
1436
+ * (`POST /api/sdk/loyalty/events`, player token). Use it for sessions, milestones and
1437
+ * registered custom events (see {@link GameEventType}). Events your SERVER reports with
1438
+ * `InvoServer.reportGameEvent` are the ones trusted for rewards; prefer those when a
1439
+ * reward depends on the event.
1440
+ *
1441
+ * Pass your own `eventId` (a UUID) or reuse the returned one if you retry, so INVO counts
1442
+ * the event once. Not auto-retried from the browser.
1443
+ *
1444
+ * Refusals: `INVALID_INPUT` before the network (non-`game.*` type, malformed `eventId`,
1445
+ * `occurredAt` without a timezone, non-object payload); `400 RESERVED_EVENT_TYPE` /
1446
+ * `EVENT_TYPE_NOT_ALLOWED`; `401 SDK_TOKEN_MISSING` / `SDK_TOKEN_WRONG_SCOPE`;
1447
+ * `422 validation_failed`.
1448
+ */
1449
+ async reportGameEvent(input, opts) {
1450
+ const { body, eventId } = buildGameEventBody(input);
1451
+ return this.withTokenRetry(async () => {
1452
+ const raw = await this.post("/api/sdk/loyalty/events", body, opts?.signal);
1453
+ return toReportGameEventResult(raw ?? {}, eventId);
1454
+ });
1455
+ }
1432
1456
  /**
1433
1457
  * First-enrollment OTP grant (§4.2). When `enrollPasskey()` throws
1434
1458
  * `ENROLLMENT_REQUIRES_AUTHORIZATION` (`err.isEnrollmentAuthorizationRequired`), call
package/dist/server.cjs CHANGED
@@ -1469,6 +1469,71 @@ function toLoyaltyCardsResult(raw) {
1469
1469
  };
1470
1470
  }
1471
1471
 
1472
+ // src/shared/loyalty-events.ts
1473
+ var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
1474
+ var ISO_WITH_ZONE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})$/;
1475
+ function invalid(label, value, why) {
1476
+ return new InvoError({
1477
+ message: `${label} ${why} (got ${JSON.stringify(value)}).`,
1478
+ code: "INVALID_INPUT",
1479
+ status: 0
1480
+ });
1481
+ }
1482
+ function newEventId() {
1483
+ const c = globalThis.crypto;
1484
+ if (c && typeof c.randomUUID === "function") return c.randomUUID();
1485
+ const bytes = new Uint8Array(16);
1486
+ if (c && typeof c.getRandomValues === "function") {
1487
+ c.getRandomValues(bytes);
1488
+ } else {
1489
+ throw new InvoError({
1490
+ message: "No Web Crypto available to generate an eventId; pass `eventId` yourself.",
1491
+ code: "INVALID_INPUT",
1492
+ status: 0
1493
+ });
1494
+ }
1495
+ bytes[6] = bytes[6] & 15 | 64;
1496
+ bytes[8] = bytes[8] & 63 | 128;
1497
+ const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
1498
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
1499
+ }
1500
+ function buildGameEventBody(input) {
1501
+ if (!input || typeof input !== "object") throw invalid("input", input, "must be an object");
1502
+ const { eventType, payload } = input;
1503
+ if (typeof eventType !== "string" || !eventType.startsWith("game.") || eventType.length > 120) {
1504
+ throw invalid("eventType", eventType, "must be a game.* event type");
1505
+ }
1506
+ const eventId = input.eventId === void 0 ? newEventId() : input.eventId;
1507
+ if (typeof eventId !== "string" || !UUID.test(eventId)) {
1508
+ throw invalid("eventId", eventId, "must be a UUID");
1509
+ }
1510
+ const body = { event_type: eventType, event_id: eventId };
1511
+ if (input.occurredAt !== void 0) {
1512
+ const at = input.occurredAt instanceof Date ? input.occurredAt.toISOString() : input.occurredAt;
1513
+ if (typeof at !== "string" || !ISO_WITH_ZONE.test(at) || Number.isNaN(Date.parse(at))) {
1514
+ throw invalid("occurredAt", input.occurredAt, "must be ISO 8601 with a timezone, or a Date");
1515
+ }
1516
+ body["occurred_at"] = at;
1517
+ }
1518
+ if (payload !== void 0) {
1519
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
1520
+ throw invalid("payload", payload, "must be a plain object");
1521
+ }
1522
+ body["payload"] = payload;
1523
+ } else {
1524
+ body["payload"] = {};
1525
+ }
1526
+ return { body, eventId };
1527
+ }
1528
+ function toReportGameEventResult(raw, eventId) {
1529
+ const echoed = raw["event_id"];
1530
+ return {
1531
+ accepted: true,
1532
+ eventId: typeof echoed === "string" && echoed ? echoed : eventId,
1533
+ raw
1534
+ };
1535
+ }
1536
+
1472
1537
  // src/shared/receipt-fields.ts
1473
1538
  function creditFields(raw) {
1474
1539
  const c = raw["credited"];
@@ -1528,7 +1593,7 @@ function toPhoneChangeRequest(raw) {
1528
1593
  }
1529
1594
 
1530
1595
  // src/version.ts
1531
- var SDK_VERSION = "3.26.1";
1596
+ var SDK_VERSION = "3.28.0";
1532
1597
 
1533
1598
  // src/payouts.ts
1534
1599
  var AMOUNT = /^\d+(\.\d{1,2})?$/;
@@ -1890,6 +1955,60 @@ async function hmacHexSubtle(secret, message) {
1890
1955
  return hex;
1891
1956
  }
1892
1957
 
1958
+ // src/environment.ts
1959
+ var PRODUCTION_BASE_URL = "https://invo.network";
1960
+ var SANDBOX_BASE_URL = "https://sandbox.invo.network/sandbox";
1961
+ var DEMO_KEY_PREFIX = "ivsdk_demo_";
1962
+ var KEY_ENVIRONMENT_PATH = "/api/sdk/key-environment";
1963
+ var EnvironmentUnknownError = class extends Error {
1964
+ constructor(message) {
1965
+ super(message);
1966
+ this.name = "EnvironmentUnknownError";
1967
+ }
1968
+ };
1969
+ function isDemoKey(gameSecret) {
1970
+ return typeof gameSecret === "string" && gameSecret.startsWith(DEMO_KEY_PREFIX);
1971
+ }
1972
+ var cache = /* @__PURE__ */ new Map();
1973
+ async function ask(baseUrl, gameSecret, fetchImpl) {
1974
+ let res;
1975
+ try {
1976
+ res = await fetchImpl(baseUrl + KEY_ENVIRONMENT_PATH, {
1977
+ method: "GET",
1978
+ headers: { "X-Game-Secret-Key": gameSecret, Accept: "application/json" },
1979
+ redirect: "error"
1980
+ });
1981
+ } catch {
1982
+ throw new EnvironmentUnknownError("Could not reach INVO to check the key.");
1983
+ }
1984
+ if (res.status === 401 || res.status === 403 || res.status === 404) return null;
1985
+ if (!res.ok) throw new EnvironmentUnknownError(`INVO answered ${res.status} while checking the key.`);
1986
+ const body = await res.json().catch(() => ({}));
1987
+ return body.environment === "production" || body.environment === "sandbox" ? body.environment : null;
1988
+ }
1989
+ function resolveEnvironment(gameSecret, opts = {}) {
1990
+ if (!gameSecret) return Promise.reject(new Error("A game secret is required."));
1991
+ if (isDemoKey(gameSecret)) return Promise.resolve("sandbox");
1992
+ const hit = cache.get(gameSecret);
1993
+ if (hit) return hit;
1994
+ const fetchImpl = opts.fetch ?? ((input, init) => fetch(input, init));
1995
+ const p = (async () => {
1996
+ const env = await ask(PRODUCTION_BASE_URL, gameSecret, fetchImpl) ?? await ask(SANDBOX_BASE_URL, gameSecret, fetchImpl);
1997
+ if (!env) {
1998
+ throw new EnvironmentUnknownError(
1999
+ "Neither INVO production nor the INVO sandbox recognises this key. Check INVO_GAME_SECRET in your secrets."
2000
+ );
2001
+ }
2002
+ return env;
2003
+ })();
2004
+ cache.set(gameSecret, p);
2005
+ p.catch(() => cache.delete(gameSecret));
2006
+ return p;
2007
+ }
2008
+ async function baseUrlForKey(gameSecret, opts = {}) {
2009
+ return await resolveEnvironment(gameSecret, opts) === "production" ? PRODUCTION_BASE_URL : SANDBOX_BASE_URL;
2010
+ }
2011
+
1893
2012
  // src/server.ts
1894
2013
  var DEFAULT_UA = `invonetwork-web-sdk/${SDK_VERSION} (+https://invo.network)`;
1895
2014
  var MAX_USD_AMOUNT = 999999.99;
@@ -4554,6 +4673,37 @@ var InvoServer = class {
4554
4673
  );
4555
4674
  return toLoyaltyCardsResult(raw);
4556
4675
  }
4676
+ /**
4677
+ * Report a gameplay event for one player to INVO's loyalty engine from your SERVER
4678
+ * (`POST /api/sdk/loyalty/server-events`, game secret). Server-reported events are the
4679
+ * ones trusted for rewards. Use it for sessions, level milestones and custom events
4680
+ * registered in the console (see {@link GameEventType}); currency steps are tracked by
4681
+ * INVO itself and are never reported.
4682
+ *
4683
+ * Idempotent on `eventId`: pass your own UUID, or let the SDK generate one, and reuse the
4684
+ * returned `eventId` if you retry. Transient failures (429, 5xx) are retried with it.
4685
+ *
4686
+ * Refusals (all `InvoError`): `INVALID_INPUT` before the network for a non-`game.*` type,
4687
+ * a malformed `eventId`, an `occurredAt` without a timezone or a non-object payload;
4688
+ * `400 RESERVED_EVENT_TYPE` / `EVENT_TYPE_NOT_ALLOWED`; `401 INVALID_GAME_SECRET`;
4689
+ * `404 PLAYER_NOT_FOUND` (`err.isPlayerNotFound`); `422 validation_failed` (for example an
4690
+ * unregistered `event_name`).
4691
+ */
4692
+ async reportGameEvent(input, opts) {
4693
+ if (!input || typeof input.playerEmail !== "string" || !input.playerEmail.trim()) {
4694
+ throw invalidInput2("playerEmail", input?.playerEmail, "is required");
4695
+ }
4696
+ const { body, eventId } = buildGameEventBody(input);
4697
+ body["player_email"] = input.playerEmail.trim();
4698
+ const raw = await this.http.post(
4699
+ "/api/sdk/loyalty/server-events",
4700
+ body,
4701
+ this.auth,
4702
+ // event_id makes this safe to retry: INVO counts one event per id.
4703
+ { idempotent: true, signal: opts?.signal }
4704
+ );
4705
+ return toReportGameEventResult(raw ?? {}, eventId);
4706
+ }
4557
4707
  /**
4558
4708
  * List LIVE, unclaimed inbound sends/transfers addressed to a player at YOUR game —
4559
4709
  * the source of truth for a "you have X to collect" badge. Pass the player's email
@@ -5173,16 +5323,23 @@ var InvoServer = class {
5173
5323
  };
5174
5324
 
5175
5325
  exports.CardsServer = CardsServer;
5326
+ exports.DEMO_KEY_PREFIX = DEMO_KEY_PREFIX;
5327
+ exports.EnvironmentUnknownError = EnvironmentUnknownError;
5176
5328
  exports.InvoError = InvoError;
5177
5329
  exports.InvoServer = InvoServer;
5330
+ exports.PRODUCTION_BASE_URL = PRODUCTION_BASE_URL;
5178
5331
  exports.PayoutsServer = PayoutsServer;
5179
5332
  exports.PlatformCommerceServer = PlatformCommerceServer;
5333
+ exports.SANDBOX_BASE_URL = SANDBOX_BASE_URL;
5180
5334
  exports.SDK_VERSION = SDK_VERSION;
5181
5335
  exports.SandboxServer = SandboxServer;
5182
5336
  exports.SandboxSubscriptionsServer = SandboxSubscriptionsServer;
5183
5337
  exports.SubscriptionsServer = SubscriptionsServer;
5338
+ exports.baseUrlForKey = baseUrlForKey;
5184
5339
  exports.createWebhookHandler = createWebhookHandler;
5340
+ exports.isDemoKey = isDemoKey;
5185
5341
  exports.isRefundPendingApproval = isRefundPendingApproval;
5342
+ exports.resolveEnvironment = resolveEnvironment;
5186
5343
  exports.verifyWebhook = verifyWebhook;
5187
5344
  exports.verifyWebhookAsync = verifyWebhookAsync;
5188
5345
  //# sourceMappingURL=server.cjs.map
package/dist/server.d.cts CHANGED
@@ -1,5 +1,6 @@
1
- import { I as InvoError, H as Http, $ as AuthHeader, g as CallOptions, a0 as CardSetupSessionInput, a1 as CardSetupSessionResult, a2 as CardSetupInput, a3 as CardSetupResult, a4 as CardSetupConfirmInput, a5 as CardSetupConfirmResult, a6 as PlayerCardsResult, a7 as PlatformPurchaseInput, a8 as PlatformPurchaseResult, a9 as PlatformOrderStatusResult, aa as PlatformPurchaseHistoryQuery, ab as PlatformPurchaseHistoryResult, ac as PlatformRefundInput, ad as PlatformRefundResult, ae as CreateSubscriptionInput, af as SubscriptionResult, ag as GetSubscriptionOptions, ah as GetSubscriptionResult, ai as ListSubscriptionsOptions, aj as SubscriptionListResult, ak as CancelSubscriptionOptions, al as CancelResult, am as ChangeAmountResult, an as SetPaymentMethodInput, ao as SetPaymentMethodResult, ap as RefundSubscriptionInput, aq as RefundResult, ar as SteamSubscriptionInitInput, as as SteamInitResult, at as SteamFinalizeSubscriptionResult, au as SandboxClockResult, av as SandboxFailureOutcome, aw as SandboxForceFailureOptions, ax as SandboxForceAuthChallengeOptions, ay as ServerConfig, az as MintPlayerTokenInput, aA as PlayerToken, aB as RegisterPlayerInput, aC as RegisterPlayerResult, aD as UpdatePlayerPhoneInput, aE as UpdatePlayerPhoneResult, aF as RequestPhoneChangeInput, aG as RequestPhoneChangeResult, aH as PhoneChangeRequest, aI as InitiateSendInput, aJ as InitiateResult, aK as InitiateTransferInput, aL as CreateCheckoutInput, aM as CreateCheckoutResult, aN as PurchaseInput, aO as PurchaseResult, aP as CurrencyPurchaseQuoteInput, aQ as CurrencyPurchaseQuote, aR as ConfirmPaymentResult, aS as OrderDetailsResult, aT as SteamPacksQuery, aU as SteamPacksResult, aV as SteamInitPurchaseInput, aW as SteamInitPurchaseResult, aX as SteamFinalizeInput, aY as SteamFinalizeResult, aZ as PurchaseItemInput, a_ as PurchaseItemResult, a$ as ItemHistoryQuery, b0 as ItemHistoryResult, b1 as ItemOrderQuery, b2 as PlayerActivityQuery, b3 as PlayerActivityResult, b4 as PlayerActivityEntry, b5 as PlayerBalanceQuery, b6 as PlayerBalanceResult, o as LoyaltyCardsResult, b7 as InboundPendingQuery, b8 as InboundPendingResult, b9 as LinkedIdentitiesQuery, ba as LinkedIdentitiesResult, bb as SmsVerifyResult, bc as ClaimTransferInput, bd as ClaimResult, be as ClaimCurrencyInput, bf as TransactionStatusResult, bg as GuardianApprovalStatusResult, bh as ServerDestinationsQuery, n as DestinationsResult, bi as PhoneShareContact, bj as PhoneShareInitiateResult, bk as PhoneShareApproveInput, bl as PhoneShareApproveResult, bm as PhoneShareStatusResult, bn as BeginDeviceApprovalInput, bo as DeviceApprovalGrant, bp as PollDeviceApprovalInput, bq as DeviceApprovalPollResult, br as ConfirmDeviceEnrollmentInput, bs as ConfirmDeviceEnrollmentResult, bt as ApproveWithDeviceCodeInput, bu as DeviceApprovalSettleResult, bv as CompleteDeviceApprovalInput, bw as CompleteDeviceApprovalResult } from './types-Cjd4SAR8.cjs';
2
- export { bx as CardSetupStatus, by as CheckoutWarning, w as ClaimDelivery, bz as CurrencyBalance, bA as CurrencyPurchaseQuoteBreakdown, x as DestinationGame, bB as DeviceApprovalChannel, bC as DeviceApprovalEnrollment, bD as DeviceApprovalFlow, bE as DeviceApprovalPollStatus, bF as DeviceEnrollmentDecision, bG as DeviceEnrollmentRespond, bH as ExpiryReason, bI as FeeTakenFrom, bJ as FirstCharge, bK as FirstChargeStatus, bL as FundingSource, bM as InboundPendingItem, y as InvoErrorInfo, z as InvoHooks, F as InvoRequestInfo, G as InvoResponseInfo, bN as LinkedIdentityEmail, J as LoyaltyCard, K as LoyaltyCardReward, N as LoyaltyCardStep, O as LoyaltyRewardState, Q as LoyaltyStepProgress, S as LoyaltyStepState, bO as MinPurchaseWarning, bP as PhoneChangeConfirmation, bQ as PhoneChangeRequestStatus, bR as PlatformPurchaseStatus, bS as PlayerActivityType, Z as Rail, bT as RefundInitiation, bU as RefundPendingApproval, bV as RefundProcessingFeeBasis, bW as RefundReceipt, bX as RefundRevenueShareAttribution, bY as RefundWarning, bZ as SandboxClockState, b_ as SavedCard, b$ as SteamPack, c0 as SteamUserSession, c1 as Subscription, c2 as SubscriptionBaseInput, c3 as SubscriptionConsent, c4 as SubscriptionConsentInput, c5 as SubscriptionFundingRail, c6 as SubscriptionInterval, c7 as SubscriptionRevenueShare, c8 as SubscriptionRevenueShareInput, c9 as SubscriptionStatus, ca as UnacknowledgedPurchaseOutcome, _ as VerificationMethod, cb as isRefundPendingApproval } from './types-Cjd4SAR8.cjs';
1
+ import { I as InvoError, H as Http, a2 as AuthHeader, g as CallOptions, a3 as PlatformPurchaseInput, a4 as PlatformPurchaseResult, a5 as PlatformOrderStatusResult, a6 as PlatformPurchaseHistoryQuery, a7 as PlatformPurchaseHistoryResult, a8 as PlatformRefundInput, a9 as PlatformRefundResult, aa as CreateSubscriptionInput, ab as SubscriptionResult, ac as GetSubscriptionOptions, ad as GetSubscriptionResult, ae as ListSubscriptionsOptions, af as SubscriptionListResult, ag as CancelSubscriptionOptions, ah as CancelResult, ai as ChangeAmountResult, aj as SetPaymentMethodInput, ak as SetPaymentMethodResult, al as RefundSubscriptionInput, am as RefundResult, an as SteamSubscriptionInitInput, ao as SteamInitResult, ap as SteamFinalizeSubscriptionResult, aq as CardSetupSessionInput, ar as CardSetupSessionResult, as as CardSetupInput, at as CardSetupResult, au as CardSetupConfirmInput, av as CardSetupConfirmResult, aw as PlayerCardsResult, ax as SandboxClockResult, ay as SandboxFailureOutcome, az as SandboxForceFailureOptions, aA as SandboxForceAuthChallengeOptions, aB as ServerConfig, aC as MintPlayerTokenInput, aD as PlayerToken, aE as RegisterPlayerInput, aF as RegisterPlayerResult, aG as UpdatePlayerPhoneInput, aH as UpdatePlayerPhoneResult, aI as RequestPhoneChangeInput, aJ as RequestPhoneChangeResult, aK as PhoneChangeRequest, aL as InitiateSendInput, aM as InitiateResult, aN as InitiateTransferInput, aO as CreateCheckoutInput, aP as CreateCheckoutResult, aQ as PurchaseInput, aR as PurchaseResult, aS as CurrencyPurchaseQuoteInput, aT as CurrencyPurchaseQuote, aU as ConfirmPaymentResult, aV as OrderDetailsResult, aW as SteamPacksQuery, aX as SteamPacksResult, aY as SteamInitPurchaseInput, aZ as SteamInitPurchaseResult, a_ as SteamFinalizeInput, a$ as SteamFinalizeResult, b0 as PurchaseItemInput, b1 as PurchaseItemResult, b2 as ItemHistoryQuery, b3 as ItemHistoryResult, b4 as ItemOrderQuery, b5 as PlayerActivityQuery, b6 as PlayerActivityResult, b7 as PlayerActivityEntry, b8 as PlayerBalanceQuery, b9 as PlayerBalanceResult, o as LoyaltyCardsResult, ba as ReportServerGameEventInput, s as ReportGameEventResult, bb as InboundPendingQuery, bc as InboundPendingResult, bd as LinkedIdentitiesQuery, be as LinkedIdentitiesResult, bf as SmsVerifyResult, bg as ClaimTransferInput, bh as ClaimResult, bi as ClaimCurrencyInput, bj as TransactionStatusResult, bk as GuardianApprovalStatusResult, bl as ServerDestinationsQuery, n as DestinationsResult, bm as PhoneShareContact, bn as PhoneShareInitiateResult, bo as PhoneShareApproveInput, bp as PhoneShareApproveResult, bq as PhoneShareStatusResult, br as BeginDeviceApprovalInput, bs as DeviceApprovalGrant, bt as PollDeviceApprovalInput, bu as DeviceApprovalPollResult, bv as ConfirmDeviceEnrollmentInput, bw as ConfirmDeviceEnrollmentResult, bx as ApproveWithDeviceCodeInput, by as DeviceApprovalSettleResult, bz as CompleteDeviceApprovalInput, bA as CompleteDeviceApprovalResult } from './types-_lIm74kd.cjs';
2
+ export { bB as CardSetupStatus, bC as CheckoutWarning, y as ClaimDelivery, bD as CurrencyBalance, bE as CurrencyPurchaseQuoteBreakdown, z as DestinationGame, bF as DeviceApprovalChannel, bG as DeviceApprovalEnrollment, bH as DeviceApprovalFlow, bI as DeviceApprovalPollStatus, bJ as DeviceEnrollmentDecision, bK as DeviceEnrollmentRespond, bL as ExpiryReason, bM as FeeTakenFrom, bN as FirstCharge, bO as FirstChargeStatus, bP as FundingSource, G as GameEventType, bQ as InboundPendingItem, F as InvoErrorInfo, J as InvoHooks, K as InvoRequestInfo, N as InvoResponseInfo, bR as LinkedIdentityEmail, O as LoyaltyCard, Q as LoyaltyCardReward, S as LoyaltyCardStep, T as LoyaltyRewardState, U as LoyaltyStepProgress, V as LoyaltyStepState, bS as MinPurchaseWarning, bT as PhoneChangeConfirmation, bU as PhoneChangeRequestStatus, bV as PlatformPurchaseStatus, bW as PlayerActivityType, a0 as Rail, bX as RefundInitiation, bY as RefundPendingApproval, bZ as RefundProcessingFeeBasis, b_ as RefundReceipt, b$ as RefundRevenueShareAttribution, c0 as RefundWarning, r as ReportGameEventInput, c1 as SandboxClockState, c2 as SavedCard, c3 as SteamPack, c4 as SteamUserSession, c5 as Subscription, c6 as SubscriptionBaseInput, c7 as SubscriptionConsent, c8 as SubscriptionConsentInput, c9 as SubscriptionFundingRail, ca as SubscriptionInterval, cb as SubscriptionRevenueShare, cc as SubscriptionRevenueShareInput, cd as SubscriptionStatus, ce as UnacknowledgedPurchaseOutcome, a1 as VerificationMethod, cf as isRefundPendingApproval } from './types-_lIm74kd.cjs';
3
+ export { S as SDK_VERSION } from './version-iWmcxjYu.cjs';
3
4
 
4
5
  interface VerifyWebhookOptions {
5
6
  /** Max age of the signed timestamp, in seconds. Default 300 (5 min). */
@@ -1109,11 +1110,36 @@ declare class PayoutsServer {
1109
1110
  }
1110
1111
 
1111
1112
  /**
1112
- * The package version, as sent in the server User-Agent. A test pins this to
1113
- * `package.json` so it cannot drift silently (it did: the UA read 3.0.0 through 3.7.0).
1114
- * Bump it with the changeset flow.
1113
+ * Pick the INVO environment from the game secret alone (3.28.0).
1114
+ *
1115
+ * Going live is swapping the key: a sandbox key (including the public demo key baked into
1116
+ * INVO's game templates) talks to the sandbox, a live key to production, and nothing else in
1117
+ * your code changes.
1118
+ *
1119
+ * - The public demo key starts with `ivsdk_demo_`: always the sandbox, no network call.
1120
+ * - Any other key: INVO is asked once (`GET /api/sdk/key-environment`), production first,
1121
+ * then the sandbox. The answer is cached per key for the life of the process.
1122
+ */
1123
+ declare const PRODUCTION_BASE_URL = "https://invo.network";
1124
+ declare const SANDBOX_BASE_URL = "https://sandbox.invo.network/sandbox";
1125
+ declare const DEMO_KEY_PREFIX = "ivsdk_demo_";
1126
+ type InvoEnvironment = "production" | "sandbox";
1127
+ /** Neither environment recognised the key, or INVO could not be reached. */
1128
+ declare class EnvironmentUnknownError extends Error {
1129
+ constructor(message: string);
1130
+ }
1131
+ declare function isDemoKey(gameSecret: string | undefined | null): boolean;
1132
+ /**
1133
+ * `"production"` or `"sandbox"` for this key. Rejects with {@link EnvironmentUnknownError}
1134
+ * when neither environment knows the key (a failed lookup is not cached, so it is retried).
1115
1135
  */
1116
- declare const SDK_VERSION = "3.26.1";
1136
+ declare function resolveEnvironment(gameSecret: string, opts?: {
1137
+ fetch?: typeof fetch;
1138
+ }): Promise<InvoEnvironment>;
1139
+ /** The API base URL for this key (see {@link resolveEnvironment}). */
1140
+ declare function baseUrlForKey(gameSecret: string, opts?: {
1141
+ fetch?: typeof fetch;
1142
+ }): Promise<string>;
1117
1143
 
1118
1144
  /**
1119
1145
  * @invonetwork/web-sdk/server — NODE entry.
@@ -1900,6 +1926,23 @@ declare class InvoServer {
1900
1926
  * timed out): retry later. A GET, so transient failures are retried automatically.
1901
1927
  */
1902
1928
  getPlayerRewards(playerEmail: string, opts?: CallOptions): Promise<LoyaltyCardsResult>;
1929
+ /**
1930
+ * Report a gameplay event for one player to INVO's loyalty engine from your SERVER
1931
+ * (`POST /api/sdk/loyalty/server-events`, game secret). Server-reported events are the
1932
+ * ones trusted for rewards. Use it for sessions, level milestones and custom events
1933
+ * registered in the console (see {@link GameEventType}); currency steps are tracked by
1934
+ * INVO itself and are never reported.
1935
+ *
1936
+ * Idempotent on `eventId`: pass your own UUID, or let the SDK generate one, and reuse the
1937
+ * returned `eventId` if you retry. Transient failures (429, 5xx) are retried with it.
1938
+ *
1939
+ * Refusals (all `InvoError`): `INVALID_INPUT` before the network for a non-`game.*` type,
1940
+ * a malformed `eventId`, an `occurredAt` without a timezone or a non-object payload;
1941
+ * `400 RESERVED_EVENT_TYPE` / `EVENT_TYPE_NOT_ALLOWED`; `401 INVALID_GAME_SECRET`;
1942
+ * `404 PLAYER_NOT_FOUND` (`err.isPlayerNotFound`); `422 validation_failed` (for example an
1943
+ * unregistered `event_name`).
1944
+ */
1945
+ reportGameEvent(input: ReportServerGameEventInput, opts?: CallOptions): Promise<ReportGameEventResult>;
1903
1946
  /**
1904
1947
  * List LIVE, unclaimed inbound sends/transfers addressed to a player at YOUR game —
1905
1948
  * the source of truth for a "you have X to collect" badge. Pass the player's email
@@ -2113,4 +2156,4 @@ declare class InvoServer {
2113
2156
  private toInitiateResult;
2114
2157
  }
2115
2158
 
2116
- export { ApproveWithDeviceCodeInput, BeginDeviceApprovalInput, CallOptions, CancelResult, CancelSubscriptionOptions, CardSetupConfirmInput, CardSetupConfirmResult, CardSetupInput, CardSetupResult, CardSetupSessionInput, CardSetupSessionResult, CardsServer, ChangeAmountResult, ClaimCurrencyInput, ClaimResult, ClaimTransferInput, CompleteDeviceApprovalInput, CompleteDeviceApprovalResult, ConfirmDeviceEnrollmentInput, ConfirmDeviceEnrollmentResult, ConfirmPaymentResult, CreateCheckoutInput, CreateCheckoutResult, CreateSubscriptionInput, CurrencyPurchaseQuote, CurrencyPurchaseQuoteInput, DestinationsResult, DeviceApprovalGrant, DeviceApprovalPollResult, DeviceApprovalSettleResult, GetSubscriptionOptions, GetSubscriptionResult, GuardianApprovalStatusResult, type IdentityPasskeyResetData, InboundPendingQuery, InboundPendingResult, InitiateResult, InitiateSendInput, InitiateTransferInput, InvoError, InvoServer, type InvoWebhookEvent, ItemHistoryQuery, ItemHistoryResult, ItemOrderQuery, type ItemPurchasedData, LinkedIdentitiesQuery, LinkedIdentitiesResult, type ListPayeesQuery, type ListPayeesResult, type ListPayoutsQuery, type ListPayoutsResult, ListSubscriptionsOptions, LoyaltyCardsResult, MintPlayerTokenInput, OrderDetailsResult, type PayableBlocker, type Payee, type PayeeInvite, type PayeeStatus, type PayeeStatusChangedData, type Payout, type PayoutStatus, type PayoutStatusChangedData, PayoutsServer, PhoneChangeRequest, PhoneShareApproveInput, PhoneShareApproveResult, PhoneShareContact, PhoneShareInitiateResult, PhoneShareStatusResult, type PlatformCommercePurchasedData, type PlatformCommerceRefundedData, PlatformCommerceServer, PlatformOrderStatusResult, PlatformPurchaseHistoryQuery, PlatformPurchaseHistoryResult, PlatformPurchaseInput, PlatformPurchaseResult, PlatformRefundInput, PlatformRefundResult, PlayerActivityEntry, PlayerActivityQuery, PlayerActivityResult, PlayerBalanceQuery, PlayerBalanceResult, PlayerCardsResult, type PlayerPhoneChangedData, PlayerToken, PollDeviceApprovalInput, type PurchaseCompletedData, type PurchaseEventData, PurchaseInput, PurchaseItemInput, PurchaseItemResult, PurchaseResult, RefundResult, RefundSubscriptionInput, type RegisterPayeeInput, type RegisterPayeeResult, RegisterPlayerInput, RegisterPlayerResult, type RequestPayoutInput, type RequestPayoutResult, RequestPhoneChangeInput, RequestPhoneChangeResult, type ReturnReasonCode, SDK_VERSION, SandboxClockResult, SandboxFailureOutcome, SandboxForceAuthChallengeOptions, SandboxForceFailureOptions, SandboxServer, SandboxSubscriptionsServer, ServerConfig, ServerDestinationsQuery, SetPaymentMethodInput, SetPaymentMethodResult, SmsVerifyResult, SteamFinalizeInput, SteamFinalizeResult, SteamFinalizeSubscriptionResult, SteamInitPurchaseInput, SteamInitPurchaseResult, SteamInitResult, SteamPacksQuery, SteamPacksResult, SteamSubscriptionInitInput, type SubscriptionAuthenticationRequiredData, type SubscriptionCanceledData, type SubscriptionEventCommon, type SubscriptionExpiredData, SubscriptionListResult, type SubscriptionPastDueData, type SubscriptionPaymentFailedData, type SubscriptionRefundApprovedData, type SubscriptionRefundDetail, type SubscriptionRefundRejectedData, type SubscriptionRefundRequestData, type SubscriptionRefundedData, type SubscriptionRenewalFunding, type SubscriptionRenewalSplit, type SubscriptionRenewedData, SubscriptionResult, type SubscriptionRevenueShareAttribution, type SubscriptionTrialEventFields, SubscriptionsServer, TransactionStatusResult, type TransferEventData, UpdatePlayerPhoneInput, UpdatePlayerPhoneResult, type VerifyWebhookOptions, type WebhookHandlerOptions, createWebhookHandler, verifyWebhook, verifyWebhookAsync };
2159
+ export { ApproveWithDeviceCodeInput, BeginDeviceApprovalInput, CallOptions, CancelResult, CancelSubscriptionOptions, CardSetupConfirmInput, CardSetupConfirmResult, CardSetupInput, CardSetupResult, CardSetupSessionInput, CardSetupSessionResult, CardsServer, ChangeAmountResult, ClaimCurrencyInput, ClaimResult, ClaimTransferInput, CompleteDeviceApprovalInput, CompleteDeviceApprovalResult, ConfirmDeviceEnrollmentInput, ConfirmDeviceEnrollmentResult, ConfirmPaymentResult, CreateCheckoutInput, CreateCheckoutResult, CreateSubscriptionInput, CurrencyPurchaseQuote, CurrencyPurchaseQuoteInput, DEMO_KEY_PREFIX, DestinationsResult, DeviceApprovalGrant, DeviceApprovalPollResult, DeviceApprovalSettleResult, EnvironmentUnknownError, GetSubscriptionOptions, GetSubscriptionResult, GuardianApprovalStatusResult, type IdentityPasskeyResetData, InboundPendingQuery, InboundPendingResult, InitiateResult, InitiateSendInput, InitiateTransferInput, type InvoEnvironment, InvoError, InvoServer, type InvoWebhookEvent, ItemHistoryQuery, ItemHistoryResult, ItemOrderQuery, type ItemPurchasedData, LinkedIdentitiesQuery, LinkedIdentitiesResult, type ListPayeesQuery, type ListPayeesResult, type ListPayoutsQuery, type ListPayoutsResult, ListSubscriptionsOptions, LoyaltyCardsResult, MintPlayerTokenInput, OrderDetailsResult, PRODUCTION_BASE_URL, type PayableBlocker, type Payee, type PayeeInvite, type PayeeStatus, type PayeeStatusChangedData, type Payout, type PayoutStatus, type PayoutStatusChangedData, PayoutsServer, PhoneChangeRequest, PhoneShareApproveInput, PhoneShareApproveResult, PhoneShareContact, PhoneShareInitiateResult, PhoneShareStatusResult, type PlatformCommercePurchasedData, type PlatformCommerceRefundedData, PlatformCommerceServer, PlatformOrderStatusResult, PlatformPurchaseHistoryQuery, PlatformPurchaseHistoryResult, PlatformPurchaseInput, PlatformPurchaseResult, PlatformRefundInput, PlatformRefundResult, PlayerActivityEntry, PlayerActivityQuery, PlayerActivityResult, PlayerBalanceQuery, PlayerBalanceResult, PlayerCardsResult, type PlayerPhoneChangedData, PlayerToken, PollDeviceApprovalInput, type PurchaseCompletedData, type PurchaseEventData, PurchaseInput, PurchaseItemInput, PurchaseItemResult, PurchaseResult, RefundResult, RefundSubscriptionInput, type RegisterPayeeInput, type RegisterPayeeResult, RegisterPlayerInput, RegisterPlayerResult, ReportGameEventResult, ReportServerGameEventInput, type RequestPayoutInput, type RequestPayoutResult, RequestPhoneChangeInput, RequestPhoneChangeResult, type ReturnReasonCode, SANDBOX_BASE_URL, SandboxClockResult, SandboxFailureOutcome, SandboxForceAuthChallengeOptions, SandboxForceFailureOptions, SandboxServer, SandboxSubscriptionsServer, ServerConfig, ServerDestinationsQuery, SetPaymentMethodInput, SetPaymentMethodResult, SmsVerifyResult, SteamFinalizeInput, SteamFinalizeResult, SteamFinalizeSubscriptionResult, SteamInitPurchaseInput, SteamInitPurchaseResult, SteamInitResult, SteamPacksQuery, SteamPacksResult, SteamSubscriptionInitInput, type SubscriptionAuthenticationRequiredData, type SubscriptionCanceledData, type SubscriptionEventCommon, type SubscriptionExpiredData, SubscriptionListResult, type SubscriptionPastDueData, type SubscriptionPaymentFailedData, type SubscriptionRefundApprovedData, type SubscriptionRefundDetail, type SubscriptionRefundRejectedData, type SubscriptionRefundRequestData, type SubscriptionRefundedData, type SubscriptionRenewalFunding, type SubscriptionRenewalSplit, type SubscriptionRenewedData, SubscriptionResult, type SubscriptionRevenueShareAttribution, type SubscriptionTrialEventFields, SubscriptionsServer, TransactionStatusResult, type TransferEventData, UpdatePlayerPhoneInput, UpdatePlayerPhoneResult, type VerifyWebhookOptions, type WebhookHandlerOptions, baseUrlForKey, createWebhookHandler, isDemoKey, resolveEnvironment, verifyWebhook, verifyWebhookAsync };