@invonetwork/web-sdk 3.29.0 → 3.30.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +1432 -1389
  2. package/README.md +2954 -2923
  3. package/dist/{chunk-FJR44FKW.js → chunk-664RAO2T.js} +25 -5
  4. package/dist/chunk-BIK6UXY7.js +6 -0
  5. package/dist/chunk-QDHOPJFL.js +1634 -0
  6. package/dist/{chunk-VP3OK4J4.js → chunk-TSTP2CWA.js} +471 -3
  7. package/dist/game-server.cjs +295 -15
  8. package/dist/game-server.d.cts +49 -9
  9. package/dist/game-server.d.ts +49 -9
  10. package/dist/game-server.js +278 -20
  11. package/dist/game.cjs +2680 -9
  12. package/dist/game.d.cts +78 -4
  13. package/dist/game.d.ts +78 -4
  14. package/dist/game.js +561 -3
  15. package/dist/hosted-approval-DcY4U2RN.d.cts +96 -0
  16. package/dist/hosted-approval-DiKmtjEh.d.ts +96 -0
  17. package/dist/index.d.cts +7 -96
  18. package/dist/index.d.ts +7 -96
  19. package/dist/index.js +2 -1635
  20. package/dist/loyalty-events-CmDw2ZoR.d.cts +40 -0
  21. package/dist/loyalty-events-CmDw2ZoR.d.ts +40 -0
  22. package/dist/{server-Dnx5jxS4.d.ts → server-B0mvlGFY.d.ts} +17 -2
  23. package/dist/{server-UZ38eD2p.d.cts → server-DEh9wjF2.d.cts} +17 -2
  24. package/dist/server.cjs +22 -1
  25. package/dist/server.d.cts +4 -3
  26. package/dist/server.d.ts +4 -3
  27. package/dist/server.js +3 -4
  28. package/dist/{types-_lIm74kd.d.ts → types-BTbZicgj.d.cts} +1 -40
  29. package/dist/{types-_lIm74kd.d.cts → types-BTbZicgj.d.ts} +1 -40
  30. package/dist/{types-CoW9LopI.d.cts → types-jUxfYjiD.d.cts} +76 -1
  31. package/dist/{types-CoW9LopI.d.ts → types-jUxfYjiD.d.ts} +76 -1
  32. package/dist/{version-xyYQO5hp.d.cts → version-DfVkILOj.d.cts} +1 -1
  33. package/dist/{version-xyYQO5hp.d.ts → version-DfVkILOj.d.ts} +1 -1
  34. package/package.json +1 -1
  35. package/dist/chunk-6CN236QH.js +0 -473
  36. package/dist/chunk-KZJABBVT.js +0 -6
@@ -102,6 +102,18 @@ interface GameCatalog {
102
102
  items: GameCatalogItem[];
103
103
  /** True when the server talks to INVO's sandbox (no real money moves). */
104
104
  sandbox: boolean;
105
+ /**
106
+ * True when the server uses INVO's public demo key (3.29.1). Sign-ins are mapped to demo
107
+ * players, so there is no real account and no phone to collect.
108
+ */
109
+ demo?: boolean;
110
+ /**
111
+ * What the sign-in form should ask for (3.29.1). `phone`: `"hidden"` on the demo key (the
112
+ * server never uses it), `"first_sign_in"` otherwise (INVO needs it once to create the player).
113
+ */
114
+ playerFields?: {
115
+ phone: "hidden" | "first_sign_in";
116
+ };
105
117
  }
106
118
  /** Status of a premium-currency purchase, as the game server knows it. */
107
119
  type GamePurchaseStatus = "pending" | "credited" | "failed" | "refunded";
@@ -139,5 +151,68 @@ interface GameErrorBody {
139
151
  requestId?: string;
140
152
  };
141
153
  }
154
+ /**
155
+ * How currency moves to another player. Both are approved with the sender's passkey on INVO's
156
+ * hosted page. A **transfer** can also give the sender a claim code to pass on; a **send** can
157
+ * be collected from a link INVO texts to a phone-only recipient.
158
+ */
159
+ type GameTransferKind = "transfer" | "send";
160
+ /** `GET /transfers/status` answer: whether players can move currency here, and how. */
161
+ interface GameTransferStatus {
162
+ enabled: boolean;
163
+ /**
164
+ * Why transfers are off: `"sandbox"` (your own sandbox key: set `INVO_TRANSFERS=on` to try
165
+ * them), `"off"` (switched off for this game), `"checking"` (the key's environment is still
166
+ * being looked up). `null` when enabled.
167
+ */
168
+ reason: "sandbox" | "off" | "checking" | null;
169
+ /** True on the public demo key. */
170
+ demo: boolean;
171
+ /**
172
+ * Who can receive: `"project"` on the demo key (players of this copy only), `"network"`
173
+ * otherwise (any player of any INVO game the destination list offers).
174
+ */
175
+ scope: "project" | "network";
176
+ /** Which recipient details to ask for. On the demo key only an email; otherwise a phone. */
177
+ recipientFields: {
178
+ email: "required" | "optional";
179
+ phone: "required" | "hidden";
180
+ };
181
+ /** INVO's API base for the player-token calls (destinations, approval, collecting). */
182
+ apiBaseUrl: string | null;
183
+ /**
184
+ * How the sender approves: `"passkey"` on INVO's hosted page, or `"sandbox"` on the public
185
+ * demo key, where the game server approves in INVO's demo sandbox without a passkey and the
186
+ * recipient collects through the game server.
187
+ */
188
+ approval: "passkey" | "sandbox";
189
+ }
190
+ /** `POST /transfers` body. */
191
+ interface GameTransferInput {
192
+ kind?: GameTransferKind;
193
+ /** A destination's `gameId` from `getDestinations`. */
194
+ targetGameId: string | number;
195
+ /** A positive decimal string or number. */
196
+ amount: string | number;
197
+ /** Required on the demo key (the server maps it to the demo player); optional otherwise. */
198
+ recipientEmail?: string;
199
+ /** Required on a real key (E.164); not used on the demo key. */
200
+ recipientPhone?: string;
201
+ /** The sender's phone, when the game never stored one (real keys only). */
202
+ senderPhone?: string;
203
+ /** Idempotency key (8 to 64 of `A-Z a-z 0-9 _ -`). Default: a fresh UUID. */
204
+ clientRequestId?: string;
205
+ }
206
+ /** `POST /transfers` answer: approve it next, from a click, on INVO's hosted page. */
207
+ interface GameTransferStart {
208
+ transactionId: string;
209
+ kind: GameTransferKind;
210
+ /** A minor's transfer waits for a guardian (emailed) instead of the passkey page. */
211
+ guardianPending: boolean;
212
+ /** A fresh player token when the sender's INVO identity changed; the client swaps it in. */
213
+ playerToken: string | null;
214
+ /** How to approve it: see {@link GameTransferStatus.approval}. */
215
+ approval: "passkey" | "sandbox";
216
+ }
142
217
 
143
- export type { GameCurrencyKind as G, GamePurchaseStatus as a, GameEconomyConfig as b, GameCatalog as c, GameCatalogItem as d, GameCheckout as e, GameCurrencyBalance as f, GameErrorBody as g, GameItemPurchase as h, GamePlayer as i, GamePremiumPack as j, GamePurchase as k, GameSession as l, GameWallet as m };
218
+ export type { GameCurrencyKind as G, GamePurchaseStatus as a, GameEconomyConfig as b, GameCatalog as c, GameCatalogItem as d, GameCheckout as e, GameCurrencyBalance as f, GameErrorBody as g, GameItemPurchase as h, GamePlayer as i, GamePremiumPack as j, GamePurchase as k, GameSession as l, GameTransferInput as m, GameTransferKind as n, GameTransferStart as o, GameTransferStatus as p, GameWallet as q };
@@ -3,6 +3,6 @@
3
3
  * `package.json` so it cannot drift silently (it did: the UA read 3.0.0 through 3.7.0).
4
4
  * Bump it with the changeset flow.
5
5
  */
6
- declare const SDK_VERSION = "3.29.0";
6
+ declare const SDK_VERSION = "3.30.0";
7
7
 
8
8
  export { SDK_VERSION as S };
@@ -3,6 +3,6 @@
3
3
  * `package.json` so it cannot drift silently (it did: the UA read 3.0.0 through 3.7.0).
4
4
  * Bump it with the changeset flow.
5
5
  */
6
- declare const SDK_VERSION = "3.29.0";
6
+ declare const SDK_VERSION = "3.30.0";
7
7
 
8
8
  export { SDK_VERSION as S };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@invonetwork/web-sdk",
3
- "version": "3.29.0",
3
+ "version": "3.30.0",
4
4
  "description": "INVO Web SDK — currency purchase, passkey (WebAuthn) verification, loyalty, and a drop-in game economy layer (wallet, shop, hosted checkout) for partner web platforms and browser games.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "private": false,
@@ -1,473 +0,0 @@
1
- import { InvoError, errorFromResponse } from './chunk-VP3OK4J4.js';
2
-
3
- // src/shared/http.ts
4
- var DEFAULT_TIMEOUT = 3e4;
5
- var MAX_RETRY_AFTER_MS = 2e4;
6
- function assertSecureBaseUrl(baseUrl) {
7
- let u;
8
- try {
9
- u = new URL(baseUrl);
10
- } catch {
11
- throw new Error(`Invalid baseUrl: ${baseUrl}`);
12
- }
13
- const isLocal = u.hostname === "localhost" || u.hostname === "127.0.0.1" || u.hostname === "[::1]";
14
- if (u.protocol === "https:" || u.protocol === "http:" && isLocal) return;
15
- throw new Error(
16
- `baseUrl must use https:// (got "${u.protocol}//"). Plaintext would expose the token/secret on the wire.`
17
- );
18
- }
19
- var _Http = class _Http {
20
- constructor(opts) {
21
- this.baseUrl = opts.baseUrl.replace(/\/+$/, "");
22
- this.timeoutMs = opts.timeoutMs ?? DEFAULT_TIMEOUT;
23
- const f = opts.fetchImpl ?? globalThis.fetch;
24
- if (typeof f !== "function") {
25
- throw new Error(
26
- "No fetch implementation available. Use Node >=18, or pass `fetch` in the config."
27
- );
28
- }
29
- this.fetchImpl = f.bind(globalThis);
30
- this.userAgent = opts.userAgent;
31
- this.maxRetries = Math.max(0, opts.maxRetries ?? 2);
32
- this.retryBaseDelayMs = opts.retryBaseDelayMs ?? 250;
33
- this.hooks = opts.hooks;
34
- }
35
- /**
36
- * @param opts.idempotent - mark this POST safe to auto-retry (it carries an
37
- * idempotency key, or has no side effect). Default false: non-idempotent POSTs
38
- * (e.g. single-use WebAuthn assertions) are NEVER auto-retried.
39
- */
40
- async post(path, body, auth, opts) {
41
- return this.request("POST", path, body, auth, opts?.idempotent ?? false, opts?.signal, opts?.headers);
42
- }
43
- // GET is always idempotent → safe to retry.
44
- async get(path, auth, opts) {
45
- return this.request("GET", path, void 0, auth, true, opts?.signal, opts?.headers);
46
- }
47
- authHeaders(auth) {
48
- switch (auth.kind) {
49
- case "game-secret":
50
- return { "X-Game-Secret-Key": auth.secret };
51
- case "bearer":
52
- return { Authorization: `Bearer ${auth.token}` };
53
- case "none":
54
- return {};
55
- }
56
- }
57
- async request(method, path, body, auth, idempotent, signal, extraHeaders) {
58
- const url = `${this.baseUrl}${path}`;
59
- const headers = {
60
- Accept: "application/json",
61
- ...this.authHeaders(auth),
62
- // Per-call extras (e.g. the sandbox clock key) — never able to override the auth header.
63
- ...extraHeaders ?? {},
64
- ...this.authHeaders(auth)
65
- };
66
- if (this.userAgent) headers["User-Agent"] = this.userAgent;
67
- if (body !== void 0) headers["Content-Type"] = "application/json";
68
- const payload = body !== void 0 ? JSON.stringify(body) : void 0;
69
- for (let attempt = 0; ; attempt++) {
70
- if (signal?.aborted) throw abortError(path);
71
- const start = Date.now();
72
- this.fire("onRequest", { method, url, attempt });
73
- const controller = new AbortController();
74
- const timer = setTimeout(() => controller.abort(), this.timeoutMs);
75
- const onAbort = () => controller.abort();
76
- signal?.addEventListener("abort", onAbort, { once: true });
77
- let res;
78
- let networkError;
79
- try {
80
- res = await this.fetchImpl(url, {
81
- method,
82
- headers,
83
- body: payload,
84
- signal: controller.signal,
85
- redirect: "manual"
86
- });
87
- } catch (err) {
88
- networkError = new InvoError({
89
- message: err instanceof Error && err.name === "AbortError" ? `Request to ${path} timed out after ${this.timeoutMs}ms` : `Network error calling ${path}: ${err?.message ?? err}`,
90
- status: 0,
91
- body: null
92
- });
93
- } finally {
94
- clearTimeout(timer);
95
- signal?.removeEventListener("abort", onAbort);
96
- }
97
- if (networkError) {
98
- if (signal?.aborted) throw abortError(path);
99
- const willRetry = idempotent && attempt < this.maxRetries;
100
- this.fire("onError", { method, url, attempt, error: networkError, willRetry });
101
- if (willRetry) {
102
- await sleep(this.backoff(attempt), signal);
103
- continue;
104
- }
105
- throw networkError;
106
- }
107
- if (res.type === "opaqueredirect" || res.status >= 300 && res.status < 400) {
108
- throw new InvoError({
109
- message: `Refused to follow a redirect from ${path} \u2014 credentials are never re-sent to a redirected URL.`,
110
- code: "UNEXPECTED_REDIRECT",
111
- status: res.status || 0,
112
- body: null
113
- });
114
- }
115
- const requestId = pickRequestId(res.headers);
116
- const text = await res.text();
117
- let parsed = null;
118
- if (text) {
119
- try {
120
- parsed = JSON.parse(text);
121
- } catch {
122
- parsed = text;
123
- }
124
- }
125
- this.fire("onResponse", {
126
- method,
127
- url,
128
- attempt,
129
- status: res.status,
130
- durationMs: Date.now() - start,
131
- requestId
132
- });
133
- if (!res.ok) {
134
- const err = errorFromResponse(res.status, parsed, requestId);
135
- let wait;
136
- if (idempotent && attempt < this.maxRetries && _Http.RETRIABLE_STATUS.has(res.status)) {
137
- if (res.status === 429) {
138
- const ra = retryAfterMs(parsed, res.headers);
139
- wait = ra === void 0 ? this.backoff(attempt) : ra <= MAX_RETRY_AFTER_MS ? ra : void 0;
140
- } else {
141
- wait = this.backoff(attempt);
142
- }
143
- }
144
- this.fire("onError", { method, url, attempt, error: err, willRetry: wait !== void 0 });
145
- if (wait !== void 0) {
146
- await sleep(wait, signal);
147
- continue;
148
- }
149
- throw err;
150
- }
151
- return parsed ?? {};
152
- }
153
- }
154
- /** Invoke an observability hook, swallowing any error it throws (best-effort). */
155
- fire(name, info) {
156
- const hook = this.hooks?.[name];
157
- if (!hook) return;
158
- try {
159
- hook(info);
160
- } catch {
161
- }
162
- }
163
- /** Exponential backoff with full jitter: base * 2^attempt, randomized. */
164
- backoff(attempt) {
165
- const ceil = this.retryBaseDelayMs * 2 ** attempt;
166
- return Math.floor(Math.random() * ceil) + this.retryBaseDelayMs;
167
- }
168
- };
169
- /** HTTP statuses worth retrying — rate limit + transient gateway/server errors. */
170
- _Http.RETRIABLE_STATUS = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
171
- var Http = _Http;
172
- function sleep(ms, signal) {
173
- return new Promise((resolve) => {
174
- if (signal?.aborted) return resolve();
175
- const timer = setTimeout(done, ms);
176
- const onAbort = () => done();
177
- function done() {
178
- clearTimeout(timer);
179
- signal?.removeEventListener("abort", onAbort);
180
- resolve();
181
- }
182
- signal?.addEventListener("abort", onAbort, { once: true });
183
- });
184
- }
185
- function abortError(path) {
186
- return new InvoError({ message: `Request to ${path} was aborted`, code: "ABORTED", status: 0 });
187
- }
188
- function pickRequestId(headers) {
189
- if (!headers || typeof headers.get !== "function") return void 0;
190
- return headers.get("x-invo-request-id") ?? headers.get("x-request-id") ?? void 0;
191
- }
192
- function retryAfterMs(parsed, headers) {
193
- if (parsed && typeof parsed === "object") {
194
- const v = parsed["retry_after"];
195
- const n = typeof v === "string" ? v.trim() === "" ? NaN : Number(v) : v;
196
- if (typeof n === "number" && Number.isFinite(n) && n >= 0) return n * 1e3;
197
- }
198
- const header = headers && typeof headers.get === "function" ? headers.get("retry-after") : null;
199
- if (header) {
200
- const n = Number(header);
201
- if (Number.isFinite(n) && n >= 0) return n * 1e3;
202
- }
203
- return void 0;
204
- }
205
-
206
- // src/shared/destinations.ts
207
- function toDestinationGame(row) {
208
- const s = (k) => row[k] === void 0 || row[k] === null ? void 0 : String(row[k]);
209
- return {
210
- gameId: row["game_id"] ?? "",
211
- gameName: String(row["game_name"] ?? ""),
212
- tenantType: s("tenant_type"),
213
- developerName: s("developer_name"),
214
- publisherName: s("publisher_name"),
215
- genre: s("genre"),
216
- platform: s("platform"),
217
- gameStatus: s("game_status"),
218
- gameIcon: s("game_icon"),
219
- gamePoster: s("game_poster"),
220
- gameUrl: s("game_url"),
221
- gameDescription: s("game_description"),
222
- currencyName: String(row["currency_name"] ?? ""),
223
- currencySymbol: String(row["currency_symbol"] ?? ""),
224
- currencySymbolUrl: s("currency_symbol_url"),
225
- minimumTransfer: String(row["minimum_transfer"] ?? ""),
226
- maximumTransfer: String(row["maximum_transfer"] ?? ""),
227
- acceptsSteamOriginValue: row["accepts_steam_origin_value"] === true,
228
- raw: row
229
- };
230
- }
231
- function toDestinationsResult(raw, direction) {
232
- const games = Array.isArray(raw["available_games"]) ? raw["available_games"] : [];
233
- return {
234
- status: String(raw["status"] ?? ""),
235
- sourceGameId: raw["source_game_id"] ?? "",
236
- sourceGameName: String(raw["source_game_name"] ?? ""),
237
- sourceGameIcon: raw["source_game_icon"],
238
- sourceCurrencyName: String(raw["source_currency_name"] ?? ""),
239
- sourceCurrencyIcon: raw["source_currency_icon"],
240
- universalTransfers: raw["universal_transfers"] === true,
241
- transferMode: String(raw["transfer_mode"] ?? ""),
242
- availableGames: games.map(toDestinationGame),
243
- totalDestinations: Number(raw["total_destinations"] ?? games.length),
244
- direction: String(raw["direction"] ?? direction),
245
- linkedGameIds: Array.isArray(raw["linked_game_ids"]) ? raw["linked_game_ids"] : void 0,
246
- raw
247
- };
248
- }
249
-
250
- // src/shared/receipt-fields.ts
251
- function creditFields(raw) {
252
- const c = raw["credited"];
253
- if (c === true) return { credited: true };
254
- if (c === false) {
255
- const r = raw["reason_code"];
256
- return { credited: false, reasonCode: r == null ? null : String(r) };
257
- }
258
- return {};
259
- }
260
- function receiptFields(raw) {
261
- const n = raw["receipt_number"];
262
- if (typeof n !== "string" || n === "") return {};
263
- const u = raw["receipt_url"];
264
- return typeof u === "string" && u !== "" ? { receiptNumber: n, receiptUrl: u } : { receiptNumber: n };
265
- }
266
-
267
- // src/shared/loyalty.ts
268
- var obj = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : {};
269
- var rows = (v) => Array.isArray(v) ? v.filter((r) => r && typeof r === "object" && !Array.isArray(r)) : [];
270
- var str = (v) => v === void 0 || v === null ? "" : String(v);
271
- var strOrNull = (v) => v === void 0 || v === null ? null : String(v);
272
- var numOrNull = (v) => typeof v === "number" && Number.isFinite(v) ? v : null;
273
- var int = (v, fallback = 0) => typeof v === "number" && Number.isFinite(v) ? v : fallback;
274
- var passThrough = (v) => v;
275
- function toLoyaltyStepProgress(value) {
276
- if (!value || typeof value !== "object" || Array.isArray(value)) return null;
277
- const v = value;
278
- const current = v["current"];
279
- const target = v["target"];
280
- if (!Number.isInteger(current) || !Number.isInteger(target)) return null;
281
- return { current, target };
282
- }
283
- function toStep(row) {
284
- return {
285
- stepId: strOrNull(row["step_id"]),
286
- index: int(row["index"]),
287
- action: str(row["action"]),
288
- label: str(row["label"]),
289
- summary: str(row["summary"]),
290
- windowHours: numOrNull(row["window_hours"]),
291
- state: str(row["state"]),
292
- progress: toLoyaltyStepProgress(row["progress"]),
293
- raw: row
294
- };
295
- }
296
- function toCardReward(row) {
297
- return {
298
- vaultEntryId: str(row["vault_entry_id"]),
299
- rewardId: str(row["reward_id"]),
300
- state: str(row["state"]),
301
- unlockedAt: str(row["unlocked_at"]),
302
- expiresAt: str(row["expires_at"]),
303
- redeemedAt: strOrNull(row["redeemed_at"]),
304
- codeMasked: strOrNull(row["code_masked"]),
305
- canRedeem: row["can_redeem"] === true,
306
- canRevealAgain: row["can_reveal_again"] === true,
307
- revealUntil: strOrNull(row["reveal_until"]),
308
- raw: row
309
- };
310
- }
311
- function toLoyaltyCard(row) {
312
- const brand = obj(row["brand"]);
313
- const reward = obj(row["reward"]);
314
- const steps = rows(row["steps"]).map(toStep);
315
- return {
316
- cardVersion: passThrough(row["card_version"]),
317
- mode: str(row["mode"]),
318
- programId: strOrNull(row["program_id"]),
319
- questId: strOrNull(row["quest_id"]),
320
- questVersion: numOrNull(row["quest_version"]),
321
- campaignId: strOrNull(row["campaign_id"]),
322
- title: str(row["title"]),
323
- description: str(row["description"]),
324
- brand: { name: strOrNull(brand["name"]), logoUrl: strOrNull(brand["logo_url"]) },
325
- artUrl: strOrNull(row["art_url"]),
326
- reward: { rewardId: strOrNull(reward["reward_id"]), name: strOrNull(reward["name"]) },
327
- orderMode: str(row["order_mode"]),
328
- status: str(row["status"]),
329
- startsAt: strOrNull(row["starts_at"]),
330
- endsAt: strOrNull(row["ends_at"]),
331
- completionHours: numOrNull(row["completion_hours"]),
332
- completionNote: strOrNull(row["completion_note"]),
333
- windowEndsAt: strOrNull(row["window_ends_at"]),
334
- completedAt: strOrNull(row["completed_at"]),
335
- stepsRequired: passThrough(row["steps_required"]),
336
- stepsComplete: passThrough(row["steps_complete"]),
337
- steps,
338
- rewards: rows(row["rewards"]).map(toCardReward),
339
- raw: row
340
- };
341
- }
342
- function toLoyaltyCardsResult(raw) {
343
- return {
344
- cardVersion: passThrough(raw["card_version"]),
345
- cards: rows(raw["cards"]).map(toLoyaltyCard),
346
- raw
347
- };
348
- }
349
- function toVaultEntry(row) {
350
- return {
351
- vaultEntryId: str(row["vault_entry_id"]),
352
- rewardRef: str(row["reward_ref"]),
353
- programId: str(row["program_id"]),
354
- questId: strOrNull(row["quest_id"]),
355
- units: str(row["units"]),
356
- state: str(row["state"]),
357
- unlockedAt: strOrNull(row["unlocked_at"]),
358
- expiresAt: strOrNull(row["expires_at"]),
359
- redeemedAt: strOrNull(row["redeemed_at"]),
360
- codeMasked: strOrNull(row["code_masked"]),
361
- raw: row
362
- };
363
- }
364
- function toLoyaltyVaultResult(raw) {
365
- return { items: rows(raw["items"]).map(toVaultEntry), raw };
366
- }
367
- function toRedeemRewardResult(raw, vaultEntryId) {
368
- return {
369
- vaultEntryId: str(raw["vault_entry_id"] ?? vaultEntryId),
370
- rewardRef: str(raw["reward_ref"]),
371
- state: str(raw["state"]),
372
- redeemedAt: strOrNull(raw["redeemed_at"]),
373
- code: strOrNull(raw["code"]),
374
- codeMasked: strOrNull(raw["code_masked"]),
375
- revealedAgain: raw["revealed_again"] === true,
376
- revealUntil: strOrNull(raw["reveal_until"]),
377
- raw
378
- };
379
- }
380
- function toRewardsPageLink(raw) {
381
- return { url: str(raw["url"]), expiresAt: str(raw["expires_at"]), raw };
382
- }
383
-
384
- // src/shared/phone-change.ts
385
- function phoneChangeSignalMessage(changeRequestId, nonce, timestamp, decision = "approve") {
386
- const action = decision === "deny" ? "phone-change-deny" : "phone-change";
387
- return `${action}|${changeRequestId}|${nonce}|${Math.trunc(timestamp)}`;
388
- }
389
- function requireField(value, field, raw) {
390
- const s = value == null ? "" : String(value);
391
- if (!s) {
392
- throw new InvoError({
393
- message: `INVO response was missing the required \`${field}\` field.`,
394
- code: "INVALID_RESPONSE",
395
- status: 0,
396
- body: raw
397
- });
398
- }
399
- return s;
400
- }
401
- var str2 = (v) => v == null ? "" : String(v);
402
- var strOrNull2 = (v) => typeof v === "string" ? v : v == null ? null : String(v);
403
- function toRequestPhoneChangeResult(raw) {
404
- return {
405
- changeRequestId: requireField(raw["change_request_id"], "change_request_id", raw),
406
- status: requireField(raw["status"], "status", raw),
407
- expiresAt: str2(raw["expires_at"]),
408
- delivery: str2(raw["delivery"]),
409
- confirmation: str2(raw["confirmation"]),
410
- message: str2(raw["message"]),
411
- raw
412
- };
413
- }
414
- function toPhoneChangeRequest(raw) {
415
- return {
416
- changeRequestId: requireField(raw["change_request_id"], "change_request_id", raw),
417
- status: requireField(raw["status"], "status", raw),
418
- confirmation: str2(raw["confirmation"]),
419
- delivery: str2(raw["delivery"]),
420
- newPhoneMasked: strOrNull2(raw["new_phone_masked"]),
421
- createdAt: strOrNull2(raw["created_at"]),
422
- expiresAt: strOrNull2(raw["expires_at"]),
423
- confirmedAt: strOrNull2(raw["confirmed_at"]),
424
- confirmedVia: strOrNull2(raw["confirmed_via"]),
425
- raw
426
- };
427
- }
428
- function toPhoneChangeApprovalsResult(raw) {
429
- const rows2 = Array.isArray(raw["approvals"]) ? raw["approvals"] : [];
430
- const approvals = rows2.filter((r) => r && typeof r === "object").map((r) => ({
431
- changeRequestId: str2(r["change_request_id"]),
432
- gameName: strOrNull2(r["game_name"]),
433
- oldPhoneMasked: strOrNull2(r["old_phone_masked"]),
434
- newPhoneMasked: strOrNull2(r["new_phone_masked"]),
435
- expiresAt: strOrNull2(r["expires_at"])
436
- }));
437
- return { approvals, raw };
438
- }
439
- function toApprovePhoneChangeResult(raw, changeRequestId) {
440
- const id = str2(raw["change_request_id"] ?? changeRequestId);
441
- const status = requireField(raw["status"], "status", raw);
442
- if (status === "denied") {
443
- return { status: "denied", changeRequestId: id, raw };
444
- }
445
- if (status !== "confirmed") {
446
- throw new InvoError({
447
- message: `INVO answered an unexpected phone change status \`${status}\`.`,
448
- code: "INVALID_RESPONSE",
449
- status: 0,
450
- body: raw
451
- });
452
- }
453
- const out = {
454
- status: "confirmed",
455
- changeRequestId: id,
456
- identityId: str2(raw["identity_id"]),
457
- previousIdentityId: str2(raw["previous_identity_id"]),
458
- playersUpdated: Number(raw["players_updated"] ?? 0) || 0,
459
- verifiedPhone: raw["verified_phone"] === true,
460
- raw
461
- };
462
- if (typeof raw["player_token"] === "string" && raw["player_token"]) {
463
- out.playerToken = raw["player_token"];
464
- if (typeof raw["player_token_expires_at"] === "string") {
465
- out.playerTokenExpiresAt = raw["player_token_expires_at"];
466
- }
467
- }
468
- return out;
469
- }
470
-
471
- export { Http, assertSecureBaseUrl, creditFields, phoneChangeSignalMessage, receiptFields, toApprovePhoneChangeResult, toDestinationsResult, toLoyaltyCardsResult, toLoyaltyVaultResult, toPhoneChangeApprovalsResult, toPhoneChangeRequest, toRedeemRewardResult, toRequestPhoneChangeResult, toRewardsPageLink };
472
- //# sourceMappingURL=chunk-6CN236QH.js.map
473
- //# sourceMappingURL=chunk-6CN236QH.js.map
@@ -1,6 +0,0 @@
1
- // src/version.ts
2
- var SDK_VERSION = "3.29.0";
3
-
4
- export { SDK_VERSION };
5
- //# sourceMappingURL=chunk-KZJABBVT.js.map
6
- //# sourceMappingURL=chunk-KZJABBVT.js.map