@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.d.mts +138 -2
- package/dist/index.d.ts +138 -2
- package/dist/index.js +409 -45
- package/dist/index.mjs +408 -45
- package/dist/react.d.mts +49 -1
- package/dist/react.d.ts +49 -1
- package/dist/react.js +407 -45
- package/dist/react.mjs +407 -45
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -525,6 +525,19 @@ interface HyveClientConfig extends TelemetryConfig {
|
|
|
525
525
|
billing?: BillingConfig;
|
|
526
526
|
/** Storage mode for persistent game data - 'cloud' (default) or 'local' */
|
|
527
527
|
storageMode?: 'cloud' | 'local';
|
|
528
|
+
/**
|
|
529
|
+
* Partner API key for externally-hosted games (e.g. CrazyGames) that cannot
|
|
530
|
+
* carry a hyve JWT. When set, telemetry is sent to the partner analytics
|
|
531
|
+
* endpoint with an `x-api-key` header instead of the JWT path. The key is
|
|
532
|
+
* scoped to the `analytics` domain and bound to a game_id server-side.
|
|
533
|
+
* NOTE: this key ships in client-side game code and is therefore public.
|
|
534
|
+
*/
|
|
535
|
+
partnerApiKey?: string;
|
|
536
|
+
/**
|
|
537
|
+
* Optional base URL for partner analytics requests. Defaults to apiBaseUrl
|
|
538
|
+
* when omitted.
|
|
539
|
+
*/
|
|
540
|
+
partnerApiBaseUrl?: string;
|
|
528
541
|
}
|
|
529
542
|
/**
|
|
530
543
|
* HyveClient provides telemetry and authentication functionality for Hyve games
|
|
@@ -545,6 +558,11 @@ declare class HyveClient {
|
|
|
545
558
|
private storageMode;
|
|
546
559
|
private cloudStorageAdapter;
|
|
547
560
|
private localStorageAdapter;
|
|
561
|
+
private crazyGamesStorageAdapter;
|
|
562
|
+
private partnerApiKey;
|
|
563
|
+
private partnerApiBaseUrl;
|
|
564
|
+
/** Raw (unprefixed) CrazyGames __dangerousUserId, seeded at init and on login. */
|
|
565
|
+
private crazyGamesUserId;
|
|
548
566
|
/**
|
|
549
567
|
* Creates a new HyveClient instance
|
|
550
568
|
* @param config Optional configuration including telemetry and ads
|
|
@@ -568,6 +586,28 @@ declare class HyveClient {
|
|
|
568
586
|
* @returns Promise resolving to boolean indicating success
|
|
569
587
|
*/
|
|
570
588
|
sendTelemetry(eventLocation: string, eventCategory: string, eventAction: string, eventSubCategory?: string | null, eventSubAction?: string | null, eventDetails?: Record<string, any> | string | null, platformId?: string | null): Promise<boolean>;
|
|
589
|
+
/**
|
|
590
|
+
* Validates and enriches user-provided event details with device info,
|
|
591
|
+
* attribution data, and session context — matching the enrichment
|
|
592
|
+
* platform-v2 applies in sendAnalyticsEvent. Shared by the JWT and partner
|
|
593
|
+
* telemetry paths.
|
|
594
|
+
* @returns Enriched details object, or null if eventDetails is not valid JSON.
|
|
595
|
+
*/
|
|
596
|
+
private enrichEventDetails;
|
|
597
|
+
/**
|
|
598
|
+
* Sends a telemetry event via the partner analytics endpoint using a partner
|
|
599
|
+
* API key (x-api-key) instead of a hyve JWT. Used by externally-hosted games
|
|
600
|
+
* such as CrazyGames. game_id is derived from the API key server-side and is
|
|
601
|
+
* therefore not sent. hyve_user_id carries the `cg:`-prefixed CrazyGames id,
|
|
602
|
+
* or a guest sentinel when the player is not logged in.
|
|
603
|
+
*/
|
|
604
|
+
private sendPartnerTelemetry;
|
|
605
|
+
/**
|
|
606
|
+
* Seeds the CrazyGames user id used for telemetry attribution and registers
|
|
607
|
+
* an auth listener so the id updates if a guest logs in mid-session.
|
|
608
|
+
* The id is client-asserted (spoofable) and used only as an attribution label.
|
|
609
|
+
*/
|
|
610
|
+
private seedCrazyGamesUser;
|
|
571
611
|
/**
|
|
572
612
|
* Required lifecycle telemetry — Session start.
|
|
573
613
|
* See https://docs.hyve.gg/docs/telemetry#required-lifecycle-events
|
|
@@ -688,7 +728,15 @@ declare class HyveClient {
|
|
|
688
728
|
*/
|
|
689
729
|
reset(): void;
|
|
690
730
|
/**
|
|
691
|
-
* Get the storage adapter based on mode
|
|
731
|
+
* Get the storage adapter based on mode.
|
|
732
|
+
*
|
|
733
|
+
* Selection order:
|
|
734
|
+
* 1. An explicit `mode` override ('cloud' | 'local') always wins.
|
|
735
|
+
* 2. On the CrazyGames platform, the CrazyGames data store is auto-selected
|
|
736
|
+
* (D3 — public storageMode type is preserved; this is chosen internally).
|
|
737
|
+
* 3. Otherwise the configured storageMode is used.
|
|
738
|
+
*
|
|
739
|
+
* Awaits CrazyGames SDK initialization so the data store is ready before use.
|
|
692
740
|
* @param mode Storage mode override (cloud or local)
|
|
693
741
|
*/
|
|
694
742
|
private getStorageAdapter;
|
|
@@ -925,9 +973,40 @@ interface CrazyGamesGameModule {
|
|
|
925
973
|
gameplayStop(): void;
|
|
926
974
|
happytime(): void;
|
|
927
975
|
}
|
|
976
|
+
/**
|
|
977
|
+
* CrazyGames user, as returned by `SDK.user.getUser()`.
|
|
978
|
+
* `__dangerousUserId` is client-asserted (spoofable) — we use it only as a
|
|
979
|
+
* telemetry attribution label, never for authentication.
|
|
980
|
+
*/
|
|
981
|
+
interface CrazyGamesUser {
|
|
982
|
+
__dangerousUserId: string;
|
|
983
|
+
username: string;
|
|
984
|
+
profilePictureUrl: string;
|
|
985
|
+
}
|
|
986
|
+
type CrazyGamesAuthListener = (user: CrazyGamesUser | null) => void;
|
|
987
|
+
interface CrazyGamesUserModule {
|
|
988
|
+
isUserAccountAvailable: boolean;
|
|
989
|
+
getUser(): Promise<CrazyGamesUser | null>;
|
|
990
|
+
addAuthListener(callback: CrazyGamesAuthListener): void;
|
|
991
|
+
removeAuthListener(callback: CrazyGamesAuthListener): void;
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* CrazyGames key/value data store. Treated as async (promise-based) per the
|
|
995
|
+
* SDK v2 docs; awaiting a synchronous return is harmless, so the wrappers
|
|
996
|
+
* `await` every call regardless.
|
|
997
|
+
*/
|
|
998
|
+
interface CrazyGamesDataModule {
|
|
999
|
+
getItem(key: string): Promise<string | null> | string | null;
|
|
1000
|
+
setItem(key: string, value: string): Promise<void> | void;
|
|
1001
|
+
removeItem(key: string): Promise<void> | void;
|
|
1002
|
+
clear(): Promise<void> | void;
|
|
1003
|
+
getKeys?(): Promise<string[]> | string[];
|
|
1004
|
+
}
|
|
928
1005
|
interface CrazyGamesSDK {
|
|
929
1006
|
ad: CrazyGamesAdModule;
|
|
930
1007
|
game: CrazyGamesGameModule;
|
|
1008
|
+
user: CrazyGamesUserModule;
|
|
1009
|
+
data: CrazyGamesDataModule;
|
|
931
1010
|
getEnvironment(): Promise<CrazyGamesEnvironment>;
|
|
932
1011
|
}
|
|
933
1012
|
declare global {
|
|
@@ -939,6 +1018,7 @@ declare global {
|
|
|
939
1018
|
}
|
|
940
1019
|
declare class CrazyGamesService {
|
|
941
1020
|
private initialized;
|
|
1021
|
+
private environment;
|
|
942
1022
|
/**
|
|
943
1023
|
* Detects if the game is running on the CrazyGames platform.
|
|
944
1024
|
* Games on CrazyGames run inside an iframe, so we check document.referrer
|
|
@@ -982,6 +1062,39 @@ declare class CrazyGamesService {
|
|
|
982
1062
|
* Use sparingly for significant achievements (boss defeat, personal record, etc.)
|
|
983
1063
|
*/
|
|
984
1064
|
happytime(): void;
|
|
1065
|
+
/**
|
|
1066
|
+
* Returns the resolved CrazyGames environment ('crazygames' | 'local' |
|
|
1067
|
+
* 'disabled'), or null if the SDK has not initialized yet. Used to
|
|
1068
|
+
* auto-select the CrazyGames storage adapter.
|
|
1069
|
+
*/
|
|
1070
|
+
getEnvironment(): CrazyGamesEnvironment | null;
|
|
1071
|
+
/**
|
|
1072
|
+
* Whether the CrazyGames account system is present (sync). When false,
|
|
1073
|
+
* there is no logged-in user concept and telemetry falls back to guests.
|
|
1074
|
+
*/
|
|
1075
|
+
isUserAccountAvailable(): boolean;
|
|
1076
|
+
/**
|
|
1077
|
+
* Fetches the current CrazyGames user, or null if the player is not logged
|
|
1078
|
+
* in (guest). The returned `__dangerousUserId` is client-asserted and used
|
|
1079
|
+
* only as a telemetry attribution label.
|
|
1080
|
+
*/
|
|
1081
|
+
getUser(): Promise<CrazyGamesUser | null>;
|
|
1082
|
+
/**
|
|
1083
|
+
* Registers a listener that fires when a guest logs in mid-session.
|
|
1084
|
+
* No-op if the SDK or account system is unavailable.
|
|
1085
|
+
*/
|
|
1086
|
+
addAuthListener(callback: CrazyGamesAuthListener): void;
|
|
1087
|
+
/** Removes a previously registered auth listener. */
|
|
1088
|
+
removeAuthListener(callback: CrazyGamesAuthListener): void;
|
|
1089
|
+
/**
|
|
1090
|
+
* Reads a value from the CrazyGames data store. Returns null when the SDK
|
|
1091
|
+
* is unavailable or the key is absent.
|
|
1092
|
+
*/
|
|
1093
|
+
dataGetItem(key: string): Promise<string | null>;
|
|
1094
|
+
/** Writes a value to the CrazyGames data store. */
|
|
1095
|
+
dataSetItem(key: string, value: string): Promise<void>;
|
|
1096
|
+
/** Removes a value from the CrazyGames data store. */
|
|
1097
|
+
dataRemoveItem(key: string): Promise<void>;
|
|
985
1098
|
private loadScript;
|
|
986
1099
|
}
|
|
987
1100
|
|
|
@@ -1025,6 +1138,29 @@ declare class LocalStorageAdapter implements StorageAdapter {
|
|
|
1025
1138
|
deleteGameData(gameId: string, key: string): Promise<boolean>;
|
|
1026
1139
|
deleteMultipleGameData(gameId: string, keys: string[]): Promise<number>;
|
|
1027
1140
|
}
|
|
1141
|
+
/**
|
|
1142
|
+
* CrazyGames storage adapter — persists game data via the CrazyGames `SDK.data`
|
|
1143
|
+
* key/value store. CrazyGames syncs this to the player's account when logged in
|
|
1144
|
+
* and falls back to device-local storage for guests.
|
|
1145
|
+
*
|
|
1146
|
+
* Keys are namespaced as `${gameId}:${key}` to avoid collisions across games
|
|
1147
|
+
* that share the CrazyGames data store. Each entry stores a full GameDataItem
|
|
1148
|
+
* (value + timestamps) as a JSON string.
|
|
1149
|
+
*
|
|
1150
|
+
* Atomic operations are implemented client-side as read-modify-write since the
|
|
1151
|
+
* underlying store is a plain key/value store.
|
|
1152
|
+
*/
|
|
1153
|
+
declare class CrazyGamesStorageAdapter implements StorageAdapter {
|
|
1154
|
+
private service;
|
|
1155
|
+
constructor(service: CrazyGamesService);
|
|
1156
|
+
private getStorageKey;
|
|
1157
|
+
saveGameData(gameId: string, key: string, value: GameDataValue, operation?: GameDataOperation, path?: string): Promise<SaveGameDataResponse>;
|
|
1158
|
+
batchSaveGameData(gameId: string, items: GameDataBatchItem[]): Promise<BatchSaveGameDataResponse>;
|
|
1159
|
+
getGameData(gameId: string, key: string): Promise<GameDataItem | null>;
|
|
1160
|
+
getMultipleGameData(gameId: string, keys: string[]): Promise<GameDataItem[]>;
|
|
1161
|
+
deleteGameData(gameId: string, key: string): Promise<boolean>;
|
|
1162
|
+
deleteMultipleGameData(gameId: string, keys: string[]): Promise<number>;
|
|
1163
|
+
}
|
|
1028
1164
|
|
|
1029
1165
|
/**
|
|
1030
1166
|
* Logger utility for the Hyve SDK
|
|
@@ -1331,4 +1467,4 @@ declare class NativeBridge {
|
|
|
1331
1467
|
*/
|
|
1332
1468
|
declare function generateUUID(): string;
|
|
1333
1469
|
|
|
1334
|
-
export { type AdConfig, type AdMobFormat, type AdRequestPayload, type AdResult, type AdType, AdsService, type BatchSaveGameDataResponse, type BatchSaveResultItem, type BillingConfig, BillingPlatform, type BillingProduct, BillingService, CloudStorageAdapter, CrazyGamesService, type DeleteGameDataResponse, type GameDataBatchItem, type GameDataItem, type GameDataLeaderboardEntry, type GameDataLeaderboardResponse, type GameDataLeaderboardUserPosition, type GameDataOperation, type GameDataValue, type GetGameDataBatchResponse, type GetGameDataLeaderboardParams, type GetGameDataResponse, HyveClient, type HyveClientConfig, type Inventory, type InventoryItem, LocalStorageAdapter, Logger, type NativeAdResult, NativeBridge, type NativeMessage, type NativeMessageHandler, NativeMessageType, PlaygamaService, type PurchaseResult, type SaveGameDataResponse, type StorageAdapter, type TelemetryAdditionalData, type TelemetryConfig, type TelemetryEvent, generateUUID, isDomainAllowed, logger, parseUrlParams };
|
|
1470
|
+
export { type AdConfig, type AdMobFormat, type AdRequestPayload, type AdResult, type AdType, AdsService, type BatchSaveGameDataResponse, type BatchSaveResultItem, type BillingConfig, BillingPlatform, type BillingProduct, BillingService, CloudStorageAdapter, CrazyGamesService, CrazyGamesStorageAdapter, type DeleteGameDataResponse, type GameDataBatchItem, type GameDataItem, type GameDataLeaderboardEntry, type GameDataLeaderboardResponse, type GameDataLeaderboardUserPosition, type GameDataOperation, type GameDataValue, type GetGameDataBatchResponse, type GetGameDataLeaderboardParams, type GetGameDataResponse, HyveClient, type HyveClientConfig, type Inventory, type InventoryItem, LocalStorageAdapter, Logger, type NativeAdResult, NativeBridge, type NativeMessage, type NativeMessageHandler, NativeMessageType, PlaygamaService, type PurchaseResult, type SaveGameDataResponse, type StorageAdapter, type TelemetryAdditionalData, type TelemetryConfig, type TelemetryEvent, generateUUID, isDomainAllowed, logger, parseUrlParams };
|
package/dist/index.d.ts
CHANGED
|
@@ -525,6 +525,19 @@ interface HyveClientConfig extends TelemetryConfig {
|
|
|
525
525
|
billing?: BillingConfig;
|
|
526
526
|
/** Storage mode for persistent game data - 'cloud' (default) or 'local' */
|
|
527
527
|
storageMode?: 'cloud' | 'local';
|
|
528
|
+
/**
|
|
529
|
+
* Partner API key for externally-hosted games (e.g. CrazyGames) that cannot
|
|
530
|
+
* carry a hyve JWT. When set, telemetry is sent to the partner analytics
|
|
531
|
+
* endpoint with an `x-api-key` header instead of the JWT path. The key is
|
|
532
|
+
* scoped to the `analytics` domain and bound to a game_id server-side.
|
|
533
|
+
* NOTE: this key ships in client-side game code and is therefore public.
|
|
534
|
+
*/
|
|
535
|
+
partnerApiKey?: string;
|
|
536
|
+
/**
|
|
537
|
+
* Optional base URL for partner analytics requests. Defaults to apiBaseUrl
|
|
538
|
+
* when omitted.
|
|
539
|
+
*/
|
|
540
|
+
partnerApiBaseUrl?: string;
|
|
528
541
|
}
|
|
529
542
|
/**
|
|
530
543
|
* HyveClient provides telemetry and authentication functionality for Hyve games
|
|
@@ -545,6 +558,11 @@ declare class HyveClient {
|
|
|
545
558
|
private storageMode;
|
|
546
559
|
private cloudStorageAdapter;
|
|
547
560
|
private localStorageAdapter;
|
|
561
|
+
private crazyGamesStorageAdapter;
|
|
562
|
+
private partnerApiKey;
|
|
563
|
+
private partnerApiBaseUrl;
|
|
564
|
+
/** Raw (unprefixed) CrazyGames __dangerousUserId, seeded at init and on login. */
|
|
565
|
+
private crazyGamesUserId;
|
|
548
566
|
/**
|
|
549
567
|
* Creates a new HyveClient instance
|
|
550
568
|
* @param config Optional configuration including telemetry and ads
|
|
@@ -568,6 +586,28 @@ declare class HyveClient {
|
|
|
568
586
|
* @returns Promise resolving to boolean indicating success
|
|
569
587
|
*/
|
|
570
588
|
sendTelemetry(eventLocation: string, eventCategory: string, eventAction: string, eventSubCategory?: string | null, eventSubAction?: string | null, eventDetails?: Record<string, any> | string | null, platformId?: string | null): Promise<boolean>;
|
|
589
|
+
/**
|
|
590
|
+
* Validates and enriches user-provided event details with device info,
|
|
591
|
+
* attribution data, and session context — matching the enrichment
|
|
592
|
+
* platform-v2 applies in sendAnalyticsEvent. Shared by the JWT and partner
|
|
593
|
+
* telemetry paths.
|
|
594
|
+
* @returns Enriched details object, or null if eventDetails is not valid JSON.
|
|
595
|
+
*/
|
|
596
|
+
private enrichEventDetails;
|
|
597
|
+
/**
|
|
598
|
+
* Sends a telemetry event via the partner analytics endpoint using a partner
|
|
599
|
+
* API key (x-api-key) instead of a hyve JWT. Used by externally-hosted games
|
|
600
|
+
* such as CrazyGames. game_id is derived from the API key server-side and is
|
|
601
|
+
* therefore not sent. hyve_user_id carries the `cg:`-prefixed CrazyGames id,
|
|
602
|
+
* or a guest sentinel when the player is not logged in.
|
|
603
|
+
*/
|
|
604
|
+
private sendPartnerTelemetry;
|
|
605
|
+
/**
|
|
606
|
+
* Seeds the CrazyGames user id used for telemetry attribution and registers
|
|
607
|
+
* an auth listener so the id updates if a guest logs in mid-session.
|
|
608
|
+
* The id is client-asserted (spoofable) and used only as an attribution label.
|
|
609
|
+
*/
|
|
610
|
+
private seedCrazyGamesUser;
|
|
571
611
|
/**
|
|
572
612
|
* Required lifecycle telemetry — Session start.
|
|
573
613
|
* See https://docs.hyve.gg/docs/telemetry#required-lifecycle-events
|
|
@@ -688,7 +728,15 @@ declare class HyveClient {
|
|
|
688
728
|
*/
|
|
689
729
|
reset(): void;
|
|
690
730
|
/**
|
|
691
|
-
* Get the storage adapter based on mode
|
|
731
|
+
* Get the storage adapter based on mode.
|
|
732
|
+
*
|
|
733
|
+
* Selection order:
|
|
734
|
+
* 1. An explicit `mode` override ('cloud' | 'local') always wins.
|
|
735
|
+
* 2. On the CrazyGames platform, the CrazyGames data store is auto-selected
|
|
736
|
+
* (D3 — public storageMode type is preserved; this is chosen internally).
|
|
737
|
+
* 3. Otherwise the configured storageMode is used.
|
|
738
|
+
*
|
|
739
|
+
* Awaits CrazyGames SDK initialization so the data store is ready before use.
|
|
692
740
|
* @param mode Storage mode override (cloud or local)
|
|
693
741
|
*/
|
|
694
742
|
private getStorageAdapter;
|
|
@@ -925,9 +973,40 @@ interface CrazyGamesGameModule {
|
|
|
925
973
|
gameplayStop(): void;
|
|
926
974
|
happytime(): void;
|
|
927
975
|
}
|
|
976
|
+
/**
|
|
977
|
+
* CrazyGames user, as returned by `SDK.user.getUser()`.
|
|
978
|
+
* `__dangerousUserId` is client-asserted (spoofable) — we use it only as a
|
|
979
|
+
* telemetry attribution label, never for authentication.
|
|
980
|
+
*/
|
|
981
|
+
interface CrazyGamesUser {
|
|
982
|
+
__dangerousUserId: string;
|
|
983
|
+
username: string;
|
|
984
|
+
profilePictureUrl: string;
|
|
985
|
+
}
|
|
986
|
+
type CrazyGamesAuthListener = (user: CrazyGamesUser | null) => void;
|
|
987
|
+
interface CrazyGamesUserModule {
|
|
988
|
+
isUserAccountAvailable: boolean;
|
|
989
|
+
getUser(): Promise<CrazyGamesUser | null>;
|
|
990
|
+
addAuthListener(callback: CrazyGamesAuthListener): void;
|
|
991
|
+
removeAuthListener(callback: CrazyGamesAuthListener): void;
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* CrazyGames key/value data store. Treated as async (promise-based) per the
|
|
995
|
+
* SDK v2 docs; awaiting a synchronous return is harmless, so the wrappers
|
|
996
|
+
* `await` every call regardless.
|
|
997
|
+
*/
|
|
998
|
+
interface CrazyGamesDataModule {
|
|
999
|
+
getItem(key: string): Promise<string | null> | string | null;
|
|
1000
|
+
setItem(key: string, value: string): Promise<void> | void;
|
|
1001
|
+
removeItem(key: string): Promise<void> | void;
|
|
1002
|
+
clear(): Promise<void> | void;
|
|
1003
|
+
getKeys?(): Promise<string[]> | string[];
|
|
1004
|
+
}
|
|
928
1005
|
interface CrazyGamesSDK {
|
|
929
1006
|
ad: CrazyGamesAdModule;
|
|
930
1007
|
game: CrazyGamesGameModule;
|
|
1008
|
+
user: CrazyGamesUserModule;
|
|
1009
|
+
data: CrazyGamesDataModule;
|
|
931
1010
|
getEnvironment(): Promise<CrazyGamesEnvironment>;
|
|
932
1011
|
}
|
|
933
1012
|
declare global {
|
|
@@ -939,6 +1018,7 @@ declare global {
|
|
|
939
1018
|
}
|
|
940
1019
|
declare class CrazyGamesService {
|
|
941
1020
|
private initialized;
|
|
1021
|
+
private environment;
|
|
942
1022
|
/**
|
|
943
1023
|
* Detects if the game is running on the CrazyGames platform.
|
|
944
1024
|
* Games on CrazyGames run inside an iframe, so we check document.referrer
|
|
@@ -982,6 +1062,39 @@ declare class CrazyGamesService {
|
|
|
982
1062
|
* Use sparingly for significant achievements (boss defeat, personal record, etc.)
|
|
983
1063
|
*/
|
|
984
1064
|
happytime(): void;
|
|
1065
|
+
/**
|
|
1066
|
+
* Returns the resolved CrazyGames environment ('crazygames' | 'local' |
|
|
1067
|
+
* 'disabled'), or null if the SDK has not initialized yet. Used to
|
|
1068
|
+
* auto-select the CrazyGames storage adapter.
|
|
1069
|
+
*/
|
|
1070
|
+
getEnvironment(): CrazyGamesEnvironment | null;
|
|
1071
|
+
/**
|
|
1072
|
+
* Whether the CrazyGames account system is present (sync). When false,
|
|
1073
|
+
* there is no logged-in user concept and telemetry falls back to guests.
|
|
1074
|
+
*/
|
|
1075
|
+
isUserAccountAvailable(): boolean;
|
|
1076
|
+
/**
|
|
1077
|
+
* Fetches the current CrazyGames user, or null if the player is not logged
|
|
1078
|
+
* in (guest). The returned `__dangerousUserId` is client-asserted and used
|
|
1079
|
+
* only as a telemetry attribution label.
|
|
1080
|
+
*/
|
|
1081
|
+
getUser(): Promise<CrazyGamesUser | null>;
|
|
1082
|
+
/**
|
|
1083
|
+
* Registers a listener that fires when a guest logs in mid-session.
|
|
1084
|
+
* No-op if the SDK or account system is unavailable.
|
|
1085
|
+
*/
|
|
1086
|
+
addAuthListener(callback: CrazyGamesAuthListener): void;
|
|
1087
|
+
/** Removes a previously registered auth listener. */
|
|
1088
|
+
removeAuthListener(callback: CrazyGamesAuthListener): void;
|
|
1089
|
+
/**
|
|
1090
|
+
* Reads a value from the CrazyGames data store. Returns null when the SDK
|
|
1091
|
+
* is unavailable or the key is absent.
|
|
1092
|
+
*/
|
|
1093
|
+
dataGetItem(key: string): Promise<string | null>;
|
|
1094
|
+
/** Writes a value to the CrazyGames data store. */
|
|
1095
|
+
dataSetItem(key: string, value: string): Promise<void>;
|
|
1096
|
+
/** Removes a value from the CrazyGames data store. */
|
|
1097
|
+
dataRemoveItem(key: string): Promise<void>;
|
|
985
1098
|
private loadScript;
|
|
986
1099
|
}
|
|
987
1100
|
|
|
@@ -1025,6 +1138,29 @@ declare class LocalStorageAdapter implements StorageAdapter {
|
|
|
1025
1138
|
deleteGameData(gameId: string, key: string): Promise<boolean>;
|
|
1026
1139
|
deleteMultipleGameData(gameId: string, keys: string[]): Promise<number>;
|
|
1027
1140
|
}
|
|
1141
|
+
/**
|
|
1142
|
+
* CrazyGames storage adapter — persists game data via the CrazyGames `SDK.data`
|
|
1143
|
+
* key/value store. CrazyGames syncs this to the player's account when logged in
|
|
1144
|
+
* and falls back to device-local storage for guests.
|
|
1145
|
+
*
|
|
1146
|
+
* Keys are namespaced as `${gameId}:${key}` to avoid collisions across games
|
|
1147
|
+
* that share the CrazyGames data store. Each entry stores a full GameDataItem
|
|
1148
|
+
* (value + timestamps) as a JSON string.
|
|
1149
|
+
*
|
|
1150
|
+
* Atomic operations are implemented client-side as read-modify-write since the
|
|
1151
|
+
* underlying store is a plain key/value store.
|
|
1152
|
+
*/
|
|
1153
|
+
declare class CrazyGamesStorageAdapter implements StorageAdapter {
|
|
1154
|
+
private service;
|
|
1155
|
+
constructor(service: CrazyGamesService);
|
|
1156
|
+
private getStorageKey;
|
|
1157
|
+
saveGameData(gameId: string, key: string, value: GameDataValue, operation?: GameDataOperation, path?: string): Promise<SaveGameDataResponse>;
|
|
1158
|
+
batchSaveGameData(gameId: string, items: GameDataBatchItem[]): Promise<BatchSaveGameDataResponse>;
|
|
1159
|
+
getGameData(gameId: string, key: string): Promise<GameDataItem | null>;
|
|
1160
|
+
getMultipleGameData(gameId: string, keys: string[]): Promise<GameDataItem[]>;
|
|
1161
|
+
deleteGameData(gameId: string, key: string): Promise<boolean>;
|
|
1162
|
+
deleteMultipleGameData(gameId: string, keys: string[]): Promise<number>;
|
|
1163
|
+
}
|
|
1028
1164
|
|
|
1029
1165
|
/**
|
|
1030
1166
|
* Logger utility for the Hyve SDK
|
|
@@ -1331,4 +1467,4 @@ declare class NativeBridge {
|
|
|
1331
1467
|
*/
|
|
1332
1468
|
declare function generateUUID(): string;
|
|
1333
1469
|
|
|
1334
|
-
export { type AdConfig, type AdMobFormat, type AdRequestPayload, type AdResult, type AdType, AdsService, type BatchSaveGameDataResponse, type BatchSaveResultItem, type BillingConfig, BillingPlatform, type BillingProduct, BillingService, CloudStorageAdapter, CrazyGamesService, type DeleteGameDataResponse, type GameDataBatchItem, type GameDataItem, type GameDataLeaderboardEntry, type GameDataLeaderboardResponse, type GameDataLeaderboardUserPosition, type GameDataOperation, type GameDataValue, type GetGameDataBatchResponse, type GetGameDataLeaderboardParams, type GetGameDataResponse, HyveClient, type HyveClientConfig, type Inventory, type InventoryItem, LocalStorageAdapter, Logger, type NativeAdResult, NativeBridge, type NativeMessage, type NativeMessageHandler, NativeMessageType, PlaygamaService, type PurchaseResult, type SaveGameDataResponse, type StorageAdapter, type TelemetryAdditionalData, type TelemetryConfig, type TelemetryEvent, generateUUID, isDomainAllowed, logger, parseUrlParams };
|
|
1470
|
+
export { type AdConfig, type AdMobFormat, type AdRequestPayload, type AdResult, type AdType, AdsService, type BatchSaveGameDataResponse, type BatchSaveResultItem, type BillingConfig, BillingPlatform, type BillingProduct, BillingService, CloudStorageAdapter, CrazyGamesService, CrazyGamesStorageAdapter, type DeleteGameDataResponse, type GameDataBatchItem, type GameDataItem, type GameDataLeaderboardEntry, type GameDataLeaderboardResponse, type GameDataLeaderboardUserPosition, type GameDataOperation, type GameDataValue, type GetGameDataBatchResponse, type GetGameDataLeaderboardParams, type GetGameDataResponse, HyveClient, type HyveClientConfig, type Inventory, type InventoryItem, LocalStorageAdapter, Logger, type NativeAdResult, NativeBridge, type NativeMessage, type NativeMessageHandler, NativeMessageType, PlaygamaService, type PurchaseResult, type SaveGameDataResponse, type StorageAdapter, type TelemetryAdditionalData, type TelemetryConfig, type TelemetryEvent, generateUUID, isDomainAllowed, logger, parseUrlParams };
|