@hyve-sdk/js 2.13.0 → 2.14.0-canary.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.js CHANGED
@@ -25,6 +25,7 @@ __export(src_exports, {
25
25
  BillingService: () => BillingService,
26
26
  CloudStorageAdapter: () => CloudStorageAdapter,
27
27
  CrazyGamesService: () => CrazyGamesService,
28
+ CrazyGamesStorageAdapter: () => CrazyGamesStorageAdapter,
28
29
  HyveClient: () => HyveClient,
29
30
  LocalStorageAdapter: () => LocalStorageAdapter,
30
31
  Logger: () => Logger,
@@ -1241,6 +1242,7 @@ var PlaygamaService = class {
1241
1242
  var CRAZYGAMES_SDK_CDN = "https://sdk.crazygames.com/crazygames-sdk-v2.js";
1242
1243
  var CrazyGamesService = class {
1243
1244
  initialized = false;
1245
+ environment = null;
1244
1246
  /**
1245
1247
  * Detects if the game is running on the CrazyGames platform.
1246
1248
  * Games on CrazyGames run inside an iframe, so we check document.referrer
@@ -1282,6 +1284,7 @@ var CrazyGamesService = class {
1282
1284
  logger.warn("[CrazyGamesService] Unexpected environment:", env);
1283
1285
  return false;
1284
1286
  }
1287
+ this.environment = env;
1285
1288
  this.initialized = true;
1286
1289
  return true;
1287
1290
  } catch (error) {
@@ -1392,6 +1395,88 @@ var CrazyGamesService = class {
1392
1395
  if (!this.initialized) return;
1393
1396
  window.CrazyGames?.SDK.game.happytime();
1394
1397
  }
1398
+ /**
1399
+ * Returns the resolved CrazyGames environment ('crazygames' | 'local' |
1400
+ * 'disabled'), or null if the SDK has not initialized yet. Used to
1401
+ * auto-select the CrazyGames storage adapter.
1402
+ */
1403
+ getEnvironment() {
1404
+ return this.environment;
1405
+ }
1406
+ /**
1407
+ * Whether the CrazyGames account system is present (sync). When false,
1408
+ * there is no logged-in user concept and telemetry falls back to guests.
1409
+ */
1410
+ isUserAccountAvailable() {
1411
+ if (!this.initialized) return false;
1412
+ return window.CrazyGames?.SDK.user.isUserAccountAvailable ?? false;
1413
+ }
1414
+ /**
1415
+ * Fetches the current CrazyGames user, or null if the player is not logged
1416
+ * in (guest). The returned `__dangerousUserId` is client-asserted and used
1417
+ * only as a telemetry attribution label.
1418
+ */
1419
+ async getUser() {
1420
+ const sdk = window.CrazyGames?.SDK;
1421
+ if (!this.initialized || !sdk || !this.isUserAccountAvailable()) {
1422
+ return null;
1423
+ }
1424
+ try {
1425
+ return await sdk.user.getUser() ?? null;
1426
+ } catch (error) {
1427
+ logger.warn("[CrazyGamesService] getUser failed:", error);
1428
+ return null;
1429
+ }
1430
+ }
1431
+ /**
1432
+ * Registers a listener that fires when a guest logs in mid-session.
1433
+ * No-op if the SDK or account system is unavailable.
1434
+ */
1435
+ addAuthListener(callback) {
1436
+ const sdk = window.CrazyGames?.SDK;
1437
+ if (!this.initialized || !sdk || !this.isUserAccountAvailable()) return;
1438
+ try {
1439
+ sdk.user.addAuthListener(callback);
1440
+ } catch (error) {
1441
+ logger.warn("[CrazyGamesService] addAuthListener failed:", error);
1442
+ }
1443
+ }
1444
+ /** Removes a previously registered auth listener. */
1445
+ removeAuthListener(callback) {
1446
+ const sdk = window.CrazyGames?.SDK;
1447
+ if (!this.initialized || !sdk) return;
1448
+ try {
1449
+ sdk.user.removeAuthListener(callback);
1450
+ } catch (error) {
1451
+ logger.warn("[CrazyGamesService] removeAuthListener failed:", error);
1452
+ }
1453
+ }
1454
+ /**
1455
+ * Reads a value from the CrazyGames data store. Returns null when the SDK
1456
+ * is unavailable or the key is absent.
1457
+ */
1458
+ async dataGetItem(key) {
1459
+ const sdk = window.CrazyGames?.SDK;
1460
+ if (!this.initialized || !sdk) return null;
1461
+ const value = await sdk.data.getItem(key);
1462
+ return value ?? null;
1463
+ }
1464
+ /** Writes a value to the CrazyGames data store. */
1465
+ async dataSetItem(key, value) {
1466
+ const sdk = window.CrazyGames?.SDK;
1467
+ if (!this.initialized || !sdk) {
1468
+ throw new Error("CrazyGames SDK not initialized");
1469
+ }
1470
+ await sdk.data.setItem(key, value);
1471
+ }
1472
+ /** Removes a value from the CrazyGames data store. */
1473
+ async dataRemoveItem(key) {
1474
+ const sdk = window.CrazyGames?.SDK;
1475
+ if (!this.initialized || !sdk) {
1476
+ throw new Error("CrazyGames SDK not initialized");
1477
+ }
1478
+ await sdk.data.removeItem(key);
1479
+ }
1395
1480
  loadScript() {
1396
1481
  return new Promise((resolve, reject) => {
1397
1482
  if (window.CrazyGames?.SDK) {
@@ -2059,6 +2144,162 @@ var LocalStorageAdapter = class {
2059
2144
  return count;
2060
2145
  }
2061
2146
  };
2147
+ function isGameDataObject(value) {
2148
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2149
+ }
2150
+ function toNumber(value) {
2151
+ return typeof value === "number" ? value : 0;
2152
+ }
2153
+ function applyOperation(operation, current, operand) {
2154
+ switch (operation) {
2155
+ case "set":
2156
+ return operand;
2157
+ case "add":
2158
+ return toNumber(current) + toNumber(operand);
2159
+ case "subtract":
2160
+ return toNumber(current) - toNumber(operand);
2161
+ case "multiply":
2162
+ return toNumber(current) * toNumber(operand);
2163
+ case "divide": {
2164
+ const divisor = toNumber(operand);
2165
+ if (divisor === 0) throw new Error("Cannot divide by zero");
2166
+ return toNumber(current) / divisor;
2167
+ }
2168
+ case "modulo": {
2169
+ const divisor = toNumber(operand);
2170
+ if (divisor === 0) throw new Error("Cannot modulo by zero");
2171
+ return toNumber(current) % divisor;
2172
+ }
2173
+ // For min/max, a missing current has nothing to compare against — adopt the operand.
2174
+ case "min":
2175
+ return typeof current === "number" ? Math.min(current, toNumber(operand)) : operand;
2176
+ case "max":
2177
+ return typeof current === "number" ? Math.max(current, toNumber(operand)) : operand;
2178
+ case "append": {
2179
+ const base = Array.isArray(current) ? [...current] : current === void 0 || current === null ? [] : [current];
2180
+ if (Array.isArray(operand)) {
2181
+ base.push(...operand);
2182
+ } else {
2183
+ base.push(operand);
2184
+ }
2185
+ return base;
2186
+ }
2187
+ default:
2188
+ return operand;
2189
+ }
2190
+ }
2191
+ function getAtPath(value, path) {
2192
+ let current = value;
2193
+ for (const segment of path.split(".")) {
2194
+ if (!isGameDataObject(current)) return void 0;
2195
+ current = current[segment];
2196
+ }
2197
+ return current;
2198
+ }
2199
+ function setAtPath(value, path, newValue) {
2200
+ const segments = path.split(".");
2201
+ const root = isGameDataObject(value) ? { ...value } : {};
2202
+ let cursor = root;
2203
+ for (let i = 0; i < segments.length - 1; i++) {
2204
+ const segment = segments[i];
2205
+ const existing = cursor[segment];
2206
+ const next = isGameDataObject(existing) ? { ...existing } : {};
2207
+ cursor[segment] = next;
2208
+ cursor = next;
2209
+ }
2210
+ cursor[segments[segments.length - 1]] = newValue;
2211
+ return root;
2212
+ }
2213
+ var CrazyGamesStorageAdapter = class {
2214
+ constructor(service) {
2215
+ this.service = service;
2216
+ }
2217
+ getStorageKey(gameId, key) {
2218
+ return `${gameId}:${key}`;
2219
+ }
2220
+ async saveGameData(gameId, key, value, operation, path) {
2221
+ const storageKey = this.getStorageKey(gameId, key);
2222
+ const now = (/* @__PURE__ */ new Date()).toISOString();
2223
+ const existingRaw = await this.service.dataGetItem(storageKey);
2224
+ const existing = existingRaw ? JSON.parse(existingRaw) : null;
2225
+ const createdAt = existing?.created_at ?? now;
2226
+ const useOperation = operation !== void 0;
2227
+ let storedValue;
2228
+ let opResult;
2229
+ if (path) {
2230
+ const current = getAtPath(existing?.value, path);
2231
+ const next = useOperation ? applyOperation(operation, current, value) : value;
2232
+ storedValue = setAtPath(existing?.value, path, next);
2233
+ opResult = next;
2234
+ } else {
2235
+ const current = existing?.value;
2236
+ const next = useOperation ? applyOperation(operation, current, value) : value;
2237
+ storedValue = next;
2238
+ opResult = next;
2239
+ }
2240
+ const item = {
2241
+ key,
2242
+ value: storedValue,
2243
+ created_at: createdAt,
2244
+ updated_at: now
2245
+ };
2246
+ await this.service.dataSetItem(storageKey, JSON.stringify(item));
2247
+ const response = { success: true, message: "Data saved successfully" };
2248
+ if (useOperation && operation !== "set") {
2249
+ response.result = opResult;
2250
+ }
2251
+ return response;
2252
+ }
2253
+ async batchSaveGameData(gameId, items) {
2254
+ const results = [];
2255
+ let usedOperation = false;
2256
+ for (const item of items) {
2257
+ if (item.operation !== void 0) usedOperation = true;
2258
+ try {
2259
+ const saved = await this.saveGameData(gameId, item.key, item.value, item.operation, item.path);
2260
+ results.push({ key: item.key, success: true, ...saved.result !== void 0 && { result: saved.result } });
2261
+ } catch (error) {
2262
+ results.push({
2263
+ key: item.key,
2264
+ success: false,
2265
+ error: error instanceof Error ? error.message : "Unknown error"
2266
+ });
2267
+ }
2268
+ }
2269
+ const allSucceeded = results.every((r) => r.success);
2270
+ return {
2271
+ success: allSucceeded,
2272
+ message: `${results.filter((r) => r.success).length}/${items.length} items saved`,
2273
+ ...usedOperation && { results }
2274
+ };
2275
+ }
2276
+ async getGameData(gameId, key) {
2277
+ const raw = await this.service.dataGetItem(this.getStorageKey(gameId, key));
2278
+ return raw ? JSON.parse(raw) : null;
2279
+ }
2280
+ async getMultipleGameData(gameId, keys) {
2281
+ const items = [];
2282
+ for (const key of keys) {
2283
+ const item = await this.getGameData(gameId, key);
2284
+ if (item) items.push(item);
2285
+ }
2286
+ return items;
2287
+ }
2288
+ async deleteGameData(gameId, key) {
2289
+ const storageKey = this.getStorageKey(gameId, key);
2290
+ const existing = await this.service.dataGetItem(storageKey);
2291
+ if (existing === null) return false;
2292
+ await this.service.dataRemoveItem(storageKey);
2293
+ return true;
2294
+ }
2295
+ async deleteMultipleGameData(gameId, keys) {
2296
+ let count = 0;
2297
+ for (const key of keys) {
2298
+ if (await this.deleteGameData(gameId, key)) count++;
2299
+ }
2300
+ return count;
2301
+ }
2302
+ };
2062
2303
 
2063
2304
  // src/core/client.ts
2064
2305
  function determineEnvironmentFromParentUrl() {
@@ -2105,6 +2346,11 @@ var HyveClient = class {
2105
2346
  storageMode;
2106
2347
  cloudStorageAdapter;
2107
2348
  localStorageAdapter;
2349
+ crazyGamesStorageAdapter = null;
2350
+ partnerApiKey = null;
2351
+ partnerApiBaseUrl = null;
2352
+ /** Raw (unprefixed) CrazyGames __dangerousUserId, seeded at init and on login. */
2353
+ crazyGamesUserId = null;
2108
2354
  /**
2109
2355
  * Creates a new HyveClient instance
2110
2356
  * @param config Optional configuration including telemetry and ads
@@ -2132,10 +2378,16 @@ var HyveClient = class {
2132
2378
  return success;
2133
2379
  });
2134
2380
  }
2381
+ this.partnerApiKey = config?.partnerApiKey ?? null;
2382
+ this.partnerApiBaseUrl = config?.partnerApiBaseUrl ?? null;
2135
2383
  if (typeof window !== "undefined" && CrazyGamesService.isCrazyGamesDomain()) {
2136
2384
  this.crazyGamesService = new CrazyGamesService();
2137
- this.crazyGamesInitPromise = this.crazyGamesService.initialize().then((success) => {
2385
+ this.crazyGamesStorageAdapter = new CrazyGamesStorageAdapter(this.crazyGamesService);
2386
+ this.crazyGamesInitPromise = this.crazyGamesService.initialize().then(async (success) => {
2138
2387
  logger.info("CrazyGames SDK initialized:", success);
2388
+ if (success) {
2389
+ await this.seedCrazyGamesUser();
2390
+ }
2139
2391
  return success;
2140
2392
  });
2141
2393
  }
@@ -2231,6 +2483,16 @@ var HyveClient = class {
2231
2483
  * @returns Promise resolving to boolean indicating success
2232
2484
  */
2233
2485
  async sendTelemetry(eventLocation, eventCategory, eventAction, eventSubCategory, eventSubAction, eventDetails, platformId) {
2486
+ if (this.partnerApiKey) {
2487
+ return this.sendPartnerTelemetry(
2488
+ eventLocation,
2489
+ eventCategory,
2490
+ eventAction,
2491
+ eventSubCategory,
2492
+ eventSubAction,
2493
+ eventDetails
2494
+ );
2495
+ }
2234
2496
  if (!this.jwtToken) {
2235
2497
  logger.error("JWT token required. Ensure hyve-access and game-id are present in the URL.");
2236
2498
  return false;
@@ -2240,42 +2502,11 @@ var HyveClient = class {
2240
2502
  return false;
2241
2503
  }
2242
2504
  try {
2243
- if (eventDetails) {
2244
- try {
2245
- if (typeof eventDetails === "string") {
2246
- JSON.parse(eventDetails);
2247
- } else if (typeof eventDetails === "object") {
2248
- JSON.stringify(eventDetails);
2249
- }
2250
- } catch (validationError) {
2251
- logger.error("Invalid JSON in eventDetails:", validationError);
2252
- logger.error("eventDetails value:", eventDetails);
2253
- return false;
2254
- }
2255
- }
2256
- let parsedEventDetails = {};
2257
- if (eventDetails) {
2258
- if (typeof eventDetails === "string") {
2259
- try {
2260
- parsedEventDetails = JSON.parse(eventDetails);
2261
- } catch {
2262
- }
2263
- } else {
2264
- parsedEventDetails = eventDetails;
2265
- }
2505
+ const enrichedEventDetails = this.enrichEventDetails(eventDetails);
2506
+ if (enrichedEventDetails === null) {
2507
+ return false;
2266
2508
  }
2267
2509
  const attribution = getAttributionData();
2268
- const enrichedEventDetails = {
2269
- // Device info
2270
- ...getEssentialDeviceInfo(),
2271
- // Attribution data
2272
- ...attribution,
2273
- // Timestamp and session context
2274
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2275
- session_id: this.sessionId,
2276
- // Event-specific details can override any of the above
2277
- ...parsedEventDetails
2278
- };
2279
2510
  const telemetryEvent = {
2280
2511
  game_id: this.gameId,
2281
2512
  session_id: this.sessionId,
@@ -2314,6 +2545,122 @@ var HyveClient = class {
2314
2545
  return false;
2315
2546
  }
2316
2547
  }
2548
+ /**
2549
+ * Validates and enriches user-provided event details with device info,
2550
+ * attribution data, and session context — matching the enrichment
2551
+ * platform-v2 applies in sendAnalyticsEvent. Shared by the JWT and partner
2552
+ * telemetry paths.
2553
+ * @returns Enriched details object, or null if eventDetails is not valid JSON.
2554
+ */
2555
+ enrichEventDetails(eventDetails) {
2556
+ let parsedEventDetails = {};
2557
+ if (eventDetails) {
2558
+ try {
2559
+ if (typeof eventDetails === "string") {
2560
+ parsedEventDetails = JSON.parse(eventDetails);
2561
+ } else if (typeof eventDetails === "object") {
2562
+ JSON.stringify(eventDetails);
2563
+ parsedEventDetails = eventDetails;
2564
+ }
2565
+ } catch (validationError) {
2566
+ logger.error("Invalid JSON in eventDetails:", validationError);
2567
+ logger.error("eventDetails value:", eventDetails);
2568
+ return null;
2569
+ }
2570
+ }
2571
+ const attribution = getAttributionData();
2572
+ return {
2573
+ // Device info
2574
+ ...getEssentialDeviceInfo(),
2575
+ // Attribution data
2576
+ ...attribution,
2577
+ // Timestamp and session context
2578
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
2579
+ session_id: this.sessionId,
2580
+ // Event-specific details can override any of the above
2581
+ ...parsedEventDetails
2582
+ };
2583
+ }
2584
+ /**
2585
+ * Sends a telemetry event via the partner analytics endpoint using a partner
2586
+ * API key (x-api-key) instead of a hyve JWT. Used by externally-hosted games
2587
+ * such as CrazyGames. game_id is derived from the API key server-side and is
2588
+ * therefore not sent. hyve_user_id carries the `cg:`-prefixed CrazyGames id,
2589
+ * or a guest sentinel when the player is not logged in.
2590
+ */
2591
+ async sendPartnerTelemetry(eventLocation, eventCategory, eventAction, eventSubCategory, eventSubAction, eventDetails) {
2592
+ if (!this.partnerApiKey) {
2593
+ logger.error("Partner API key required for partner telemetry path.");
2594
+ return false;
2595
+ }
2596
+ if (this.crazyGamesService && this.crazyGamesInitPromise) {
2597
+ await this.crazyGamesInitPromise;
2598
+ }
2599
+ try {
2600
+ const enrichedEventDetails = this.enrichEventDetails(eventDetails);
2601
+ if (enrichedEventDetails === null) {
2602
+ return false;
2603
+ }
2604
+ const hyveUserId = this.crazyGamesUserId ? `cg:${this.crazyGamesUserId}` : "cg:guest";
2605
+ const partnerEvent = {
2606
+ session_id: this.sessionId,
2607
+ hyve_user_id: hyveUserId,
2608
+ event_location: eventLocation,
2609
+ event_category: eventCategory,
2610
+ event_sub_category: eventSubCategory || null,
2611
+ event_action: eventAction,
2612
+ event_sub_action: eventSubAction || null,
2613
+ event_details: enrichedEventDetails
2614
+ };
2615
+ logger.debug("Sending partner telemetry event:", partnerEvent);
2616
+ const base = this.partnerApiBaseUrl || this.apiBaseUrl;
2617
+ const telemetryUrl = `${base}/api/v1/partners/analytics/events`;
2618
+ const response = await fetch(telemetryUrl, {
2619
+ method: "POST",
2620
+ headers: {
2621
+ "Content-Type": "application/json",
2622
+ "x-api-key": this.partnerApiKey
2623
+ },
2624
+ body: JSON.stringify(partnerEvent)
2625
+ });
2626
+ if (response.ok) {
2627
+ logger.info("Partner telemetry event sent successfully:", response.status);
2628
+ return true;
2629
+ } else {
2630
+ const errorText = await response.text();
2631
+ logger.error(
2632
+ "Failed to send partner telemetry event:",
2633
+ response.status,
2634
+ errorText
2635
+ );
2636
+ return false;
2637
+ }
2638
+ } catch (error) {
2639
+ logger.error("Error sending partner telemetry event:", error);
2640
+ return false;
2641
+ }
2642
+ }
2643
+ /**
2644
+ * Seeds the CrazyGames user id used for telemetry attribution and registers
2645
+ * an auth listener so the id updates if a guest logs in mid-session.
2646
+ * The id is client-asserted (spoofable) and used only as an attribution label.
2647
+ */
2648
+ async seedCrazyGamesUser() {
2649
+ if (!this.crazyGamesService) return;
2650
+ if (!this.crazyGamesService.isUserAccountAvailable()) {
2651
+ logger.info("CrazyGames account system unavailable \u2014 telemetry attributed by session only");
2652
+ return;
2653
+ }
2654
+ const user = await this.crazyGamesService.getUser();
2655
+ this.crazyGamesUserId = user?.__dangerousUserId ?? null;
2656
+ if (this.crazyGamesUserId) {
2657
+ logger.info("CrazyGames user id seeded for telemetry attribution");
2658
+ }
2659
+ this.crazyGamesService.addAuthListener((updatedUser) => {
2660
+ this.crazyGamesUserId = updatedUser?.__dangerousUserId ?? null;
2661
+ logger.info("CrazyGames auth state changed; telemetry user id updated");
2662
+ });
2663
+ }
2317
2664
  /**
2318
2665
  * Required lifecycle telemetry — Session start.
2319
2666
  * See https://docs.hyve.gg/docs/telemetry#required-lifecycle-events
@@ -2534,12 +2881,28 @@ var HyveClient = class {
2534
2881
  logger.info("Client reset with new sessionId:", this.sessionId);
2535
2882
  }
2536
2883
  /**
2537
- * Get the storage adapter based on mode
2884
+ * Get the storage adapter based on mode.
2885
+ *
2886
+ * Selection order:
2887
+ * 1. An explicit `mode` override ('cloud' | 'local') always wins.
2888
+ * 2. On the CrazyGames platform, the CrazyGames data store is auto-selected
2889
+ * (D3 — public storageMode type is preserved; this is chosen internally).
2890
+ * 3. Otherwise the configured storageMode is used.
2891
+ *
2892
+ * Awaits CrazyGames SDK initialization so the data store is ready before use.
2538
2893
  * @param mode Storage mode override (cloud or local)
2539
2894
  */
2540
- getStorageAdapter(mode) {
2541
- const storageMode = mode || this.storageMode;
2542
- return storageMode === "local" ? this.localStorageAdapter : this.cloudStorageAdapter;
2895
+ async getStorageAdapter(mode) {
2896
+ if (mode) {
2897
+ return mode === "local" ? this.localStorageAdapter : this.cloudStorageAdapter;
2898
+ }
2899
+ if (this.crazyGamesService && this.crazyGamesStorageAdapter) {
2900
+ if (this.crazyGamesInitPromise) await this.crazyGamesInitPromise;
2901
+ if (this.crazyGamesService.getEnvironment() === "crazygames") {
2902
+ return this.crazyGamesStorageAdapter;
2903
+ }
2904
+ }
2905
+ return this.storageMode === "local" ? this.localStorageAdapter : this.cloudStorageAdapter;
2543
2906
  }
2544
2907
  /**
2545
2908
  * Returns the current game ID or throws if not available.
@@ -2563,7 +2926,7 @@ var HyveClient = class {
2563
2926
  const gameId = this.requireGameId();
2564
2927
  const storageMode = storage || this.storageMode;
2565
2928
  logger.debug(`Saving game data to ${storageMode}: ${gameId}/${key}`);
2566
- const adapter = this.getStorageAdapter(storage);
2929
+ const adapter = await this.getStorageAdapter(storage);
2567
2930
  const response = await adapter.saveGameData(gameId, key, value, operation, path);
2568
2931
  logger.info(`Game data saved successfully to ${storageMode}: ${gameId}/${key}`);
2569
2932
  return response;
@@ -2578,7 +2941,7 @@ var HyveClient = class {
2578
2941
  const gameId = this.requireGameId();
2579
2942
  const storageMode = storage || this.storageMode;
2580
2943
  logger.debug(`Batch saving ${items.length} game data entries to ${storageMode} for game: ${gameId}`);
2581
- const adapter = this.getStorageAdapter(storage);
2944
+ const adapter = await this.getStorageAdapter(storage);
2582
2945
  const response = await adapter.batchSaveGameData(gameId, items);
2583
2946
  logger.info(`Batch saved ${items.length} game data entries successfully to ${storageMode}`);
2584
2947
  return response;
@@ -2593,7 +2956,7 @@ var HyveClient = class {
2593
2956
  const gameId = this.requireGameId();
2594
2957
  const storageMode = storage || this.storageMode;
2595
2958
  logger.debug(`Getting game data from ${storageMode}: ${gameId}/${key}`);
2596
- const adapter = this.getStorageAdapter(storage);
2959
+ const adapter = await this.getStorageAdapter(storage);
2597
2960
  const data = await adapter.getGameData(gameId, key);
2598
2961
  if (data) {
2599
2962
  logger.info(`Game data retrieved successfully from ${storageMode}: ${gameId}/${key}`);
@@ -2612,7 +2975,7 @@ var HyveClient = class {
2612
2975
  const gameId = this.requireGameId();
2613
2976
  const storageMode = storage || this.storageMode;
2614
2977
  logger.debug(`Getting ${keys.length} game data entries from ${storageMode} for game: ${gameId}`);
2615
- const adapter = this.getStorageAdapter(storage);
2978
+ const adapter = await this.getStorageAdapter(storage);
2616
2979
  const data = await adapter.getMultipleGameData(gameId, keys);
2617
2980
  logger.info(`Retrieved ${data.length} game data entries from ${storageMode}`);
2618
2981
  return data;
@@ -2627,7 +2990,7 @@ var HyveClient = class {
2627
2990
  const gameId = this.requireGameId();
2628
2991
  const storageMode = storage || this.storageMode;
2629
2992
  logger.debug(`Deleting game data from ${storageMode}: ${gameId}/${key}`);
2630
- const adapter = this.getStorageAdapter(storage);
2993
+ const adapter = await this.getStorageAdapter(storage);
2631
2994
  const deleted = await adapter.deleteGameData(gameId, key);
2632
2995
  if (deleted) {
2633
2996
  logger.info(`Game data deleted successfully from ${storageMode}: ${gameId}/${key}`);
@@ -2646,7 +3009,7 @@ var HyveClient = class {
2646
3009
  const gameId = this.requireGameId();
2647
3010
  const storageMode = storage || this.storageMode;
2648
3011
  logger.debug(`Deleting ${keys.length} game data entries from ${storageMode} for game: ${gameId}`);
2649
- const adapter = this.getStorageAdapter(storage);
3012
+ const adapter = await this.getStorageAdapter(storage);
2650
3013
  const deletedCount = await adapter.deleteMultipleGameData(gameId, keys);
2651
3014
  logger.info(`Deleted ${deletedCount} game data entries from ${storageMode}`);
2652
3015
  return deletedCount;
@@ -2865,6 +3228,7 @@ var HyveClient = class {
2865
3228
  BillingService,
2866
3229
  CloudStorageAdapter,
2867
3230
  CrazyGamesService,
3231
+ CrazyGamesStorageAdapter,
2868
3232
  HyveClient,
2869
3233
  LocalStorageAdapter,
2870
3234
  Logger,