@hyve-sdk/js 2.13.0 → 2.14.0-canary.1
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 +144 -2
- package/dist/index.d.ts +144 -2
- package/dist/index.js +411 -45
- package/dist/index.mjs +410 -45
- package/dist/react.d.mts +55 -1
- package/dist/react.d.ts +55 -1
- package/dist/react.js +409 -45
- package/dist/react.mjs +409 -45
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -525,6 +525,25 @@ 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;
|
|
541
|
+
/**
|
|
542
|
+
* Game ID for externally-hosted builds (e.g. CrazyGames) whose URL carries
|
|
543
|
+
* no `game-id` parameter or hyve JWT. Used for storage key namespacing and
|
|
544
|
+
* telemetry. A `game-id` URL parameter still takes precedence when present.
|
|
545
|
+
*/
|
|
546
|
+
gameId?: string;
|
|
528
547
|
}
|
|
529
548
|
/**
|
|
530
549
|
* HyveClient provides telemetry and authentication functionality for Hyve games
|
|
@@ -545,6 +564,11 @@ declare class HyveClient {
|
|
|
545
564
|
private storageMode;
|
|
546
565
|
private cloudStorageAdapter;
|
|
547
566
|
private localStorageAdapter;
|
|
567
|
+
private crazyGamesStorageAdapter;
|
|
568
|
+
private partnerApiKey;
|
|
569
|
+
private partnerApiBaseUrl;
|
|
570
|
+
/** Raw (unprefixed) CrazyGames __dangerousUserId, seeded at init and on login. */
|
|
571
|
+
private crazyGamesUserId;
|
|
548
572
|
/**
|
|
549
573
|
* Creates a new HyveClient instance
|
|
550
574
|
* @param config Optional configuration including telemetry and ads
|
|
@@ -568,6 +592,28 @@ declare class HyveClient {
|
|
|
568
592
|
* @returns Promise resolving to boolean indicating success
|
|
569
593
|
*/
|
|
570
594
|
sendTelemetry(eventLocation: string, eventCategory: string, eventAction: string, eventSubCategory?: string | null, eventSubAction?: string | null, eventDetails?: Record<string, any> | string | null, platformId?: string | null): Promise<boolean>;
|
|
595
|
+
/**
|
|
596
|
+
* Validates and enriches user-provided event details with device info,
|
|
597
|
+
* attribution data, and session context — matching the enrichment
|
|
598
|
+
* platform-v2 applies in sendAnalyticsEvent. Shared by the JWT and partner
|
|
599
|
+
* telemetry paths.
|
|
600
|
+
* @returns Enriched details object, or null if eventDetails is not valid JSON.
|
|
601
|
+
*/
|
|
602
|
+
private enrichEventDetails;
|
|
603
|
+
/**
|
|
604
|
+
* Sends a telemetry event via the partner analytics endpoint using a partner
|
|
605
|
+
* API key (x-api-key) instead of a hyve JWT. Used by externally-hosted games
|
|
606
|
+
* such as CrazyGames. game_id is derived from the API key server-side and is
|
|
607
|
+
* therefore not sent. hyve_user_id carries the `cg:`-prefixed CrazyGames id,
|
|
608
|
+
* or a guest sentinel when the player is not logged in.
|
|
609
|
+
*/
|
|
610
|
+
private sendPartnerTelemetry;
|
|
611
|
+
/**
|
|
612
|
+
* Seeds the CrazyGames user id used for telemetry attribution and registers
|
|
613
|
+
* an auth listener so the id updates if a guest logs in mid-session.
|
|
614
|
+
* The id is client-asserted (spoofable) and used only as an attribution label.
|
|
615
|
+
*/
|
|
616
|
+
private seedCrazyGamesUser;
|
|
571
617
|
/**
|
|
572
618
|
* Required lifecycle telemetry — Session start.
|
|
573
619
|
* See https://docs.hyve.gg/docs/telemetry#required-lifecycle-events
|
|
@@ -688,7 +734,15 @@ declare class HyveClient {
|
|
|
688
734
|
*/
|
|
689
735
|
reset(): void;
|
|
690
736
|
/**
|
|
691
|
-
* Get the storage adapter based on mode
|
|
737
|
+
* Get the storage adapter based on mode.
|
|
738
|
+
*
|
|
739
|
+
* Selection order:
|
|
740
|
+
* 1. An explicit `mode` override ('cloud' | 'local') always wins.
|
|
741
|
+
* 2. On the CrazyGames platform, the CrazyGames data store is auto-selected
|
|
742
|
+
* (D3 — public storageMode type is preserved; this is chosen internally).
|
|
743
|
+
* 3. Otherwise the configured storageMode is used.
|
|
744
|
+
*
|
|
745
|
+
* Awaits CrazyGames SDK initialization so the data store is ready before use.
|
|
692
746
|
* @param mode Storage mode override (cloud or local)
|
|
693
747
|
*/
|
|
694
748
|
private getStorageAdapter;
|
|
@@ -925,9 +979,40 @@ interface CrazyGamesGameModule {
|
|
|
925
979
|
gameplayStop(): void;
|
|
926
980
|
happytime(): void;
|
|
927
981
|
}
|
|
982
|
+
/**
|
|
983
|
+
* CrazyGames user, as returned by `SDK.user.getUser()`.
|
|
984
|
+
* `__dangerousUserId` is client-asserted (spoofable) — we use it only as a
|
|
985
|
+
* telemetry attribution label, never for authentication.
|
|
986
|
+
*/
|
|
987
|
+
interface CrazyGamesUser {
|
|
988
|
+
__dangerousUserId: string;
|
|
989
|
+
username: string;
|
|
990
|
+
profilePictureUrl: string;
|
|
991
|
+
}
|
|
992
|
+
type CrazyGamesAuthListener = (user: CrazyGamesUser | null) => void;
|
|
993
|
+
interface CrazyGamesUserModule {
|
|
994
|
+
isUserAccountAvailable: boolean;
|
|
995
|
+
getUser(): Promise<CrazyGamesUser | null>;
|
|
996
|
+
addAuthListener(callback: CrazyGamesAuthListener): void;
|
|
997
|
+
removeAuthListener(callback: CrazyGamesAuthListener): void;
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* CrazyGames key/value data store. Treated as async (promise-based) per the
|
|
1001
|
+
* SDK v2 docs; awaiting a synchronous return is harmless, so the wrappers
|
|
1002
|
+
* `await` every call regardless.
|
|
1003
|
+
*/
|
|
1004
|
+
interface CrazyGamesDataModule {
|
|
1005
|
+
getItem(key: string): Promise<string | null> | string | null;
|
|
1006
|
+
setItem(key: string, value: string): Promise<void> | void;
|
|
1007
|
+
removeItem(key: string): Promise<void> | void;
|
|
1008
|
+
clear(): Promise<void> | void;
|
|
1009
|
+
getKeys?(): Promise<string[]> | string[];
|
|
1010
|
+
}
|
|
928
1011
|
interface CrazyGamesSDK {
|
|
929
1012
|
ad: CrazyGamesAdModule;
|
|
930
1013
|
game: CrazyGamesGameModule;
|
|
1014
|
+
user: CrazyGamesUserModule;
|
|
1015
|
+
data: CrazyGamesDataModule;
|
|
931
1016
|
getEnvironment(): Promise<CrazyGamesEnvironment>;
|
|
932
1017
|
}
|
|
933
1018
|
declare global {
|
|
@@ -939,6 +1024,7 @@ declare global {
|
|
|
939
1024
|
}
|
|
940
1025
|
declare class CrazyGamesService {
|
|
941
1026
|
private initialized;
|
|
1027
|
+
private environment;
|
|
942
1028
|
/**
|
|
943
1029
|
* Detects if the game is running on the CrazyGames platform.
|
|
944
1030
|
* Games on CrazyGames run inside an iframe, so we check document.referrer
|
|
@@ -982,6 +1068,39 @@ declare class CrazyGamesService {
|
|
|
982
1068
|
* Use sparingly for significant achievements (boss defeat, personal record, etc.)
|
|
983
1069
|
*/
|
|
984
1070
|
happytime(): void;
|
|
1071
|
+
/**
|
|
1072
|
+
* Returns the resolved CrazyGames environment ('crazygames' | 'local' |
|
|
1073
|
+
* 'disabled'), or null if the SDK has not initialized yet. Used to
|
|
1074
|
+
* auto-select the CrazyGames storage adapter.
|
|
1075
|
+
*/
|
|
1076
|
+
getEnvironment(): CrazyGamesEnvironment | null;
|
|
1077
|
+
/**
|
|
1078
|
+
* Whether the CrazyGames account system is present (sync). When false,
|
|
1079
|
+
* there is no logged-in user concept and telemetry falls back to guests.
|
|
1080
|
+
*/
|
|
1081
|
+
isUserAccountAvailable(): boolean;
|
|
1082
|
+
/**
|
|
1083
|
+
* Fetches the current CrazyGames user, or null if the player is not logged
|
|
1084
|
+
* in (guest). The returned `__dangerousUserId` is client-asserted and used
|
|
1085
|
+
* only as a telemetry attribution label.
|
|
1086
|
+
*/
|
|
1087
|
+
getUser(): Promise<CrazyGamesUser | null>;
|
|
1088
|
+
/**
|
|
1089
|
+
* Registers a listener that fires when a guest logs in mid-session.
|
|
1090
|
+
* No-op if the SDK or account system is unavailable.
|
|
1091
|
+
*/
|
|
1092
|
+
addAuthListener(callback: CrazyGamesAuthListener): void;
|
|
1093
|
+
/** Removes a previously registered auth listener. */
|
|
1094
|
+
removeAuthListener(callback: CrazyGamesAuthListener): void;
|
|
1095
|
+
/**
|
|
1096
|
+
* Reads a value from the CrazyGames data store. Returns null when the SDK
|
|
1097
|
+
* is unavailable or the key is absent.
|
|
1098
|
+
*/
|
|
1099
|
+
dataGetItem(key: string): Promise<string | null>;
|
|
1100
|
+
/** Writes a value to the CrazyGames data store. */
|
|
1101
|
+
dataSetItem(key: string, value: string): Promise<void>;
|
|
1102
|
+
/** Removes a value from the CrazyGames data store. */
|
|
1103
|
+
dataRemoveItem(key: string): Promise<void>;
|
|
985
1104
|
private loadScript;
|
|
986
1105
|
}
|
|
987
1106
|
|
|
@@ -1025,6 +1144,29 @@ declare class LocalStorageAdapter implements StorageAdapter {
|
|
|
1025
1144
|
deleteGameData(gameId: string, key: string): Promise<boolean>;
|
|
1026
1145
|
deleteMultipleGameData(gameId: string, keys: string[]): Promise<number>;
|
|
1027
1146
|
}
|
|
1147
|
+
/**
|
|
1148
|
+
* CrazyGames storage adapter — persists game data via the CrazyGames `SDK.data`
|
|
1149
|
+
* key/value store. CrazyGames syncs this to the player's account when logged in
|
|
1150
|
+
* and falls back to device-local storage for guests.
|
|
1151
|
+
*
|
|
1152
|
+
* Keys are namespaced as `${gameId}:${key}` to avoid collisions across games
|
|
1153
|
+
* that share the CrazyGames data store. Each entry stores a full GameDataItem
|
|
1154
|
+
* (value + timestamps) as a JSON string.
|
|
1155
|
+
*
|
|
1156
|
+
* Atomic operations are implemented client-side as read-modify-write since the
|
|
1157
|
+
* underlying store is a plain key/value store.
|
|
1158
|
+
*/
|
|
1159
|
+
declare class CrazyGamesStorageAdapter implements StorageAdapter {
|
|
1160
|
+
private service;
|
|
1161
|
+
constructor(service: CrazyGamesService);
|
|
1162
|
+
private getStorageKey;
|
|
1163
|
+
saveGameData(gameId: string, key: string, value: GameDataValue, operation?: GameDataOperation, path?: string): Promise<SaveGameDataResponse>;
|
|
1164
|
+
batchSaveGameData(gameId: string, items: GameDataBatchItem[]): Promise<BatchSaveGameDataResponse>;
|
|
1165
|
+
getGameData(gameId: string, key: string): Promise<GameDataItem | null>;
|
|
1166
|
+
getMultipleGameData(gameId: string, keys: string[]): Promise<GameDataItem[]>;
|
|
1167
|
+
deleteGameData(gameId: string, key: string): Promise<boolean>;
|
|
1168
|
+
deleteMultipleGameData(gameId: string, keys: string[]): Promise<number>;
|
|
1169
|
+
}
|
|
1028
1170
|
|
|
1029
1171
|
/**
|
|
1030
1172
|
* Logger utility for the Hyve SDK
|
|
@@ -1331,4 +1473,4 @@ declare class NativeBridge {
|
|
|
1331
1473
|
*/
|
|
1332
1474
|
declare function generateUUID(): string;
|
|
1333
1475
|
|
|
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 };
|
|
1476
|
+
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,25 @@ 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;
|
|
541
|
+
/**
|
|
542
|
+
* Game ID for externally-hosted builds (e.g. CrazyGames) whose URL carries
|
|
543
|
+
* no `game-id` parameter or hyve JWT. Used for storage key namespacing and
|
|
544
|
+
* telemetry. A `game-id` URL parameter still takes precedence when present.
|
|
545
|
+
*/
|
|
546
|
+
gameId?: string;
|
|
528
547
|
}
|
|
529
548
|
/**
|
|
530
549
|
* HyveClient provides telemetry and authentication functionality for Hyve games
|
|
@@ -545,6 +564,11 @@ declare class HyveClient {
|
|
|
545
564
|
private storageMode;
|
|
546
565
|
private cloudStorageAdapter;
|
|
547
566
|
private localStorageAdapter;
|
|
567
|
+
private crazyGamesStorageAdapter;
|
|
568
|
+
private partnerApiKey;
|
|
569
|
+
private partnerApiBaseUrl;
|
|
570
|
+
/** Raw (unprefixed) CrazyGames __dangerousUserId, seeded at init and on login. */
|
|
571
|
+
private crazyGamesUserId;
|
|
548
572
|
/**
|
|
549
573
|
* Creates a new HyveClient instance
|
|
550
574
|
* @param config Optional configuration including telemetry and ads
|
|
@@ -568,6 +592,28 @@ declare class HyveClient {
|
|
|
568
592
|
* @returns Promise resolving to boolean indicating success
|
|
569
593
|
*/
|
|
570
594
|
sendTelemetry(eventLocation: string, eventCategory: string, eventAction: string, eventSubCategory?: string | null, eventSubAction?: string | null, eventDetails?: Record<string, any> | string | null, platformId?: string | null): Promise<boolean>;
|
|
595
|
+
/**
|
|
596
|
+
* Validates and enriches user-provided event details with device info,
|
|
597
|
+
* attribution data, and session context — matching the enrichment
|
|
598
|
+
* platform-v2 applies in sendAnalyticsEvent. Shared by the JWT and partner
|
|
599
|
+
* telemetry paths.
|
|
600
|
+
* @returns Enriched details object, or null if eventDetails is not valid JSON.
|
|
601
|
+
*/
|
|
602
|
+
private enrichEventDetails;
|
|
603
|
+
/**
|
|
604
|
+
* Sends a telemetry event via the partner analytics endpoint using a partner
|
|
605
|
+
* API key (x-api-key) instead of a hyve JWT. Used by externally-hosted games
|
|
606
|
+
* such as CrazyGames. game_id is derived from the API key server-side and is
|
|
607
|
+
* therefore not sent. hyve_user_id carries the `cg:`-prefixed CrazyGames id,
|
|
608
|
+
* or a guest sentinel when the player is not logged in.
|
|
609
|
+
*/
|
|
610
|
+
private sendPartnerTelemetry;
|
|
611
|
+
/**
|
|
612
|
+
* Seeds the CrazyGames user id used for telemetry attribution and registers
|
|
613
|
+
* an auth listener so the id updates if a guest logs in mid-session.
|
|
614
|
+
* The id is client-asserted (spoofable) and used only as an attribution label.
|
|
615
|
+
*/
|
|
616
|
+
private seedCrazyGamesUser;
|
|
571
617
|
/**
|
|
572
618
|
* Required lifecycle telemetry — Session start.
|
|
573
619
|
* See https://docs.hyve.gg/docs/telemetry#required-lifecycle-events
|
|
@@ -688,7 +734,15 @@ declare class HyveClient {
|
|
|
688
734
|
*/
|
|
689
735
|
reset(): void;
|
|
690
736
|
/**
|
|
691
|
-
* Get the storage adapter based on mode
|
|
737
|
+
* Get the storage adapter based on mode.
|
|
738
|
+
*
|
|
739
|
+
* Selection order:
|
|
740
|
+
* 1. An explicit `mode` override ('cloud' | 'local') always wins.
|
|
741
|
+
* 2. On the CrazyGames platform, the CrazyGames data store is auto-selected
|
|
742
|
+
* (D3 — public storageMode type is preserved; this is chosen internally).
|
|
743
|
+
* 3. Otherwise the configured storageMode is used.
|
|
744
|
+
*
|
|
745
|
+
* Awaits CrazyGames SDK initialization so the data store is ready before use.
|
|
692
746
|
* @param mode Storage mode override (cloud or local)
|
|
693
747
|
*/
|
|
694
748
|
private getStorageAdapter;
|
|
@@ -925,9 +979,40 @@ interface CrazyGamesGameModule {
|
|
|
925
979
|
gameplayStop(): void;
|
|
926
980
|
happytime(): void;
|
|
927
981
|
}
|
|
982
|
+
/**
|
|
983
|
+
* CrazyGames user, as returned by `SDK.user.getUser()`.
|
|
984
|
+
* `__dangerousUserId` is client-asserted (spoofable) — we use it only as a
|
|
985
|
+
* telemetry attribution label, never for authentication.
|
|
986
|
+
*/
|
|
987
|
+
interface CrazyGamesUser {
|
|
988
|
+
__dangerousUserId: string;
|
|
989
|
+
username: string;
|
|
990
|
+
profilePictureUrl: string;
|
|
991
|
+
}
|
|
992
|
+
type CrazyGamesAuthListener = (user: CrazyGamesUser | null) => void;
|
|
993
|
+
interface CrazyGamesUserModule {
|
|
994
|
+
isUserAccountAvailable: boolean;
|
|
995
|
+
getUser(): Promise<CrazyGamesUser | null>;
|
|
996
|
+
addAuthListener(callback: CrazyGamesAuthListener): void;
|
|
997
|
+
removeAuthListener(callback: CrazyGamesAuthListener): void;
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* CrazyGames key/value data store. Treated as async (promise-based) per the
|
|
1001
|
+
* SDK v2 docs; awaiting a synchronous return is harmless, so the wrappers
|
|
1002
|
+
* `await` every call regardless.
|
|
1003
|
+
*/
|
|
1004
|
+
interface CrazyGamesDataModule {
|
|
1005
|
+
getItem(key: string): Promise<string | null> | string | null;
|
|
1006
|
+
setItem(key: string, value: string): Promise<void> | void;
|
|
1007
|
+
removeItem(key: string): Promise<void> | void;
|
|
1008
|
+
clear(): Promise<void> | void;
|
|
1009
|
+
getKeys?(): Promise<string[]> | string[];
|
|
1010
|
+
}
|
|
928
1011
|
interface CrazyGamesSDK {
|
|
929
1012
|
ad: CrazyGamesAdModule;
|
|
930
1013
|
game: CrazyGamesGameModule;
|
|
1014
|
+
user: CrazyGamesUserModule;
|
|
1015
|
+
data: CrazyGamesDataModule;
|
|
931
1016
|
getEnvironment(): Promise<CrazyGamesEnvironment>;
|
|
932
1017
|
}
|
|
933
1018
|
declare global {
|
|
@@ -939,6 +1024,7 @@ declare global {
|
|
|
939
1024
|
}
|
|
940
1025
|
declare class CrazyGamesService {
|
|
941
1026
|
private initialized;
|
|
1027
|
+
private environment;
|
|
942
1028
|
/**
|
|
943
1029
|
* Detects if the game is running on the CrazyGames platform.
|
|
944
1030
|
* Games on CrazyGames run inside an iframe, so we check document.referrer
|
|
@@ -982,6 +1068,39 @@ declare class CrazyGamesService {
|
|
|
982
1068
|
* Use sparingly for significant achievements (boss defeat, personal record, etc.)
|
|
983
1069
|
*/
|
|
984
1070
|
happytime(): void;
|
|
1071
|
+
/**
|
|
1072
|
+
* Returns the resolved CrazyGames environment ('crazygames' | 'local' |
|
|
1073
|
+
* 'disabled'), or null if the SDK has not initialized yet. Used to
|
|
1074
|
+
* auto-select the CrazyGames storage adapter.
|
|
1075
|
+
*/
|
|
1076
|
+
getEnvironment(): CrazyGamesEnvironment | null;
|
|
1077
|
+
/**
|
|
1078
|
+
* Whether the CrazyGames account system is present (sync). When false,
|
|
1079
|
+
* there is no logged-in user concept and telemetry falls back to guests.
|
|
1080
|
+
*/
|
|
1081
|
+
isUserAccountAvailable(): boolean;
|
|
1082
|
+
/**
|
|
1083
|
+
* Fetches the current CrazyGames user, or null if the player is not logged
|
|
1084
|
+
* in (guest). The returned `__dangerousUserId` is client-asserted and used
|
|
1085
|
+
* only as a telemetry attribution label.
|
|
1086
|
+
*/
|
|
1087
|
+
getUser(): Promise<CrazyGamesUser | null>;
|
|
1088
|
+
/**
|
|
1089
|
+
* Registers a listener that fires when a guest logs in mid-session.
|
|
1090
|
+
* No-op if the SDK or account system is unavailable.
|
|
1091
|
+
*/
|
|
1092
|
+
addAuthListener(callback: CrazyGamesAuthListener): void;
|
|
1093
|
+
/** Removes a previously registered auth listener. */
|
|
1094
|
+
removeAuthListener(callback: CrazyGamesAuthListener): void;
|
|
1095
|
+
/**
|
|
1096
|
+
* Reads a value from the CrazyGames data store. Returns null when the SDK
|
|
1097
|
+
* is unavailable or the key is absent.
|
|
1098
|
+
*/
|
|
1099
|
+
dataGetItem(key: string): Promise<string | null>;
|
|
1100
|
+
/** Writes a value to the CrazyGames data store. */
|
|
1101
|
+
dataSetItem(key: string, value: string): Promise<void>;
|
|
1102
|
+
/** Removes a value from the CrazyGames data store. */
|
|
1103
|
+
dataRemoveItem(key: string): Promise<void>;
|
|
985
1104
|
private loadScript;
|
|
986
1105
|
}
|
|
987
1106
|
|
|
@@ -1025,6 +1144,29 @@ declare class LocalStorageAdapter implements StorageAdapter {
|
|
|
1025
1144
|
deleteGameData(gameId: string, key: string): Promise<boolean>;
|
|
1026
1145
|
deleteMultipleGameData(gameId: string, keys: string[]): Promise<number>;
|
|
1027
1146
|
}
|
|
1147
|
+
/**
|
|
1148
|
+
* CrazyGames storage adapter — persists game data via the CrazyGames `SDK.data`
|
|
1149
|
+
* key/value store. CrazyGames syncs this to the player's account when logged in
|
|
1150
|
+
* and falls back to device-local storage for guests.
|
|
1151
|
+
*
|
|
1152
|
+
* Keys are namespaced as `${gameId}:${key}` to avoid collisions across games
|
|
1153
|
+
* that share the CrazyGames data store. Each entry stores a full GameDataItem
|
|
1154
|
+
* (value + timestamps) as a JSON string.
|
|
1155
|
+
*
|
|
1156
|
+
* Atomic operations are implemented client-side as read-modify-write since the
|
|
1157
|
+
* underlying store is a plain key/value store.
|
|
1158
|
+
*/
|
|
1159
|
+
declare class CrazyGamesStorageAdapter implements StorageAdapter {
|
|
1160
|
+
private service;
|
|
1161
|
+
constructor(service: CrazyGamesService);
|
|
1162
|
+
private getStorageKey;
|
|
1163
|
+
saveGameData(gameId: string, key: string, value: GameDataValue, operation?: GameDataOperation, path?: string): Promise<SaveGameDataResponse>;
|
|
1164
|
+
batchSaveGameData(gameId: string, items: GameDataBatchItem[]): Promise<BatchSaveGameDataResponse>;
|
|
1165
|
+
getGameData(gameId: string, key: string): Promise<GameDataItem | null>;
|
|
1166
|
+
getMultipleGameData(gameId: string, keys: string[]): Promise<GameDataItem[]>;
|
|
1167
|
+
deleteGameData(gameId: string, key: string): Promise<boolean>;
|
|
1168
|
+
deleteMultipleGameData(gameId: string, keys: string[]): Promise<number>;
|
|
1169
|
+
}
|
|
1028
1170
|
|
|
1029
1171
|
/**
|
|
1030
1172
|
* Logger utility for the Hyve SDK
|
|
@@ -1331,4 +1473,4 @@ declare class NativeBridge {
|
|
|
1331
1473
|
*/
|
|
1332
1474
|
declare function generateUUID(): string;
|
|
1333
1475
|
|
|
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 };
|
|
1476
|
+
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 };
|