@masterunoco/casinowebengine-api 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +190 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +120 -3
- package/dist/index.d.ts +120 -3
- package/dist/index.js +190 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -370,11 +370,29 @@ interface ContentPage {
|
|
|
370
370
|
createdAt: string;
|
|
371
371
|
updatedAt: string;
|
|
372
372
|
}
|
|
373
|
+
interface AnnouncementsResponse {
|
|
374
|
+
message: string;
|
|
375
|
+
announcements: Announcement[] | string;
|
|
376
|
+
gameAnnouncements: Announcement[] | string;
|
|
377
|
+
}
|
|
378
|
+
interface Announcement {
|
|
379
|
+
createdAt: string;
|
|
380
|
+
updatedAt: string;
|
|
381
|
+
id: number;
|
|
382
|
+
state: string;
|
|
383
|
+
title: string;
|
|
384
|
+
text: string;
|
|
385
|
+
category: string;
|
|
386
|
+
startDate: string;
|
|
387
|
+
endDate: string;
|
|
388
|
+
}
|
|
389
|
+
|
|
373
390
|
declare class ContentAPI {
|
|
374
391
|
private http;
|
|
375
392
|
constructor(http: HttpClient);
|
|
376
393
|
list(): Promise<ContentPage[]>;
|
|
377
394
|
get(slug: string): Promise<ContentPage>;
|
|
395
|
+
getAnnouncements(): Promise<AnnouncementsResponse>;
|
|
378
396
|
}
|
|
379
397
|
|
|
380
398
|
interface ChargeData {
|
|
@@ -636,6 +654,12 @@ interface GlobalFavorite {
|
|
|
636
654
|
interface Providers {
|
|
637
655
|
providers: string[];
|
|
638
656
|
}
|
|
657
|
+
interface CategoryProvider {
|
|
658
|
+
id: number;
|
|
659
|
+
name: string;
|
|
660
|
+
parentId?: number;
|
|
661
|
+
providers: string;
|
|
662
|
+
}
|
|
639
663
|
interface Lobby {
|
|
640
664
|
[key: string]: LobbyGame[];
|
|
641
665
|
}
|
|
@@ -685,7 +709,7 @@ declare class GamesAPI {
|
|
|
685
709
|
/** Requires auth: player link */
|
|
686
710
|
getLink(gameId: string): Promise<GameLinkResponse>;
|
|
687
711
|
/** Public: demo link */
|
|
688
|
-
getDemoLink(
|
|
712
|
+
getDemoLink(gameExternalId: string): Promise<GameLinkResponse>;
|
|
689
713
|
setFavorite(gameId: number, isFavorite: boolean): Promise<SetFavoriteGamesResponse>;
|
|
690
714
|
getFavorite(): Promise<FavoriteGamesResponse[]>;
|
|
691
715
|
getRecentBigWins(category: string): Promise<recentBigWinsResponse[]>;
|
|
@@ -695,6 +719,9 @@ declare class GamesAPI {
|
|
|
695
719
|
topRated: TopRated[];
|
|
696
720
|
}>;
|
|
697
721
|
getProviders(): Promise<Providers>;
|
|
722
|
+
getCategoriesProviders(): Promise<{
|
|
723
|
+
categoryProviders: CategoryProvider[];
|
|
724
|
+
}>;
|
|
698
725
|
getLobby(): Promise<Lobby[]>;
|
|
699
726
|
}
|
|
700
727
|
|
|
@@ -973,9 +1000,20 @@ declare class PlayerAPI {
|
|
|
973
1000
|
}): Promise<{
|
|
974
1001
|
message: string;
|
|
975
1002
|
}>;
|
|
1003
|
+
verifyPhoneSignup(data: PhoneVerifyProps): Promise<{
|
|
1004
|
+
message: string;
|
|
1005
|
+
}>;
|
|
1006
|
+
verifyPhoneCodeSignup(data: {
|
|
1007
|
+
verificationCode: string;
|
|
1008
|
+
verificationToken: string;
|
|
1009
|
+
}): Promise<{
|
|
1010
|
+
message: string;
|
|
1011
|
+
}>;
|
|
976
1012
|
getVerificationStatus(): Promise<VerificationStatus[]>;
|
|
977
1013
|
getAvatars(): Promise<Avatar$1[]>;
|
|
978
|
-
changeAvatar(data:
|
|
1014
|
+
changeAvatar(data: {
|
|
1015
|
+
avatarId: number;
|
|
1016
|
+
}): Promise<{
|
|
979
1017
|
message: string;
|
|
980
1018
|
avatar: Avatar$1;
|
|
981
1019
|
}>;
|
|
@@ -1193,6 +1231,16 @@ interface Currency {
|
|
|
1193
1231
|
currencyName: string;
|
|
1194
1232
|
id: number;
|
|
1195
1233
|
}
|
|
1234
|
+
interface CurrencyRates {
|
|
1235
|
+
provider: string;
|
|
1236
|
+
base: string;
|
|
1237
|
+
date: string;
|
|
1238
|
+
updatedAt: string;
|
|
1239
|
+
rates: Rates;
|
|
1240
|
+
}
|
|
1241
|
+
interface Rates {
|
|
1242
|
+
[key: string]: number;
|
|
1243
|
+
}
|
|
1196
1244
|
interface Preferences {
|
|
1197
1245
|
createdAt?: string;
|
|
1198
1246
|
updatedAt?: string;
|
|
@@ -1231,6 +1279,7 @@ declare class SettingsAPI {
|
|
|
1231
1279
|
getPreferences(): Promise<Preferences>;
|
|
1232
1280
|
updatePreferences(data: Partial<Preferences>): Promise<Preferences>;
|
|
1233
1281
|
getCurrencies(): Promise<Currency[]>;
|
|
1282
|
+
getCurrenciesRates(): Promise<CurrencyRates>;
|
|
1234
1283
|
getWebSetting(lang: string): Promise<WebSetting[]>;
|
|
1235
1284
|
getWebSettingProviders(lang: string): Promise<WebSetting[]>;
|
|
1236
1285
|
getWebSettingPin(): Promise<WebSetting[]>;
|
|
@@ -1350,13 +1399,81 @@ declare class WithdrawAPI {
|
|
|
1350
1399
|
getAnindaBankList(methodId: number): Promise<AnindaBank[]>;
|
|
1351
1400
|
}
|
|
1352
1401
|
|
|
1402
|
+
type SocketMessage<TPayload = any> = {
|
|
1403
|
+
type: string;
|
|
1404
|
+
payload?: TPayload;
|
|
1405
|
+
message?: any;
|
|
1406
|
+
};
|
|
1407
|
+
type SocketStatus = 'idle' | 'connecting' | 'connected' | 'disconnected' | 'reconnecting';
|
|
1408
|
+
type SocketEventHandler<T = any> = (data: T, raw: SocketMessage) => void;
|
|
1409
|
+
type SocketClientOptions = {
|
|
1410
|
+
/** Example: wss://socketservice.moneycloud.vip/socket/public-room/join */
|
|
1411
|
+
url: string;
|
|
1412
|
+
/** joinPublic payload name (default: "player1") */
|
|
1413
|
+
publicName?: string;
|
|
1414
|
+
/** Ping interval (ms). Default: 5000 */
|
|
1415
|
+
pingIntervalMs?: number;
|
|
1416
|
+
/** Auto reconnect on close (default: true) */
|
|
1417
|
+
autoReconnect?: boolean;
|
|
1418
|
+
/** Max reconnect delay (ms). Default: 30000 */
|
|
1419
|
+
maxReconnectDelayMs?: number;
|
|
1420
|
+
/** Provide socket token from your storage (localStorage helper, etc.) */
|
|
1421
|
+
getSocketToken?: () => string | null;
|
|
1422
|
+
/** Provide user identity when logged in */
|
|
1423
|
+
getUser?: () => {
|
|
1424
|
+
id: number;
|
|
1425
|
+
name?: string | null;
|
|
1426
|
+
} | null;
|
|
1427
|
+
};
|
|
1428
|
+
|
|
1429
|
+
declare class SocketClient {
|
|
1430
|
+
private opts;
|
|
1431
|
+
private ws;
|
|
1432
|
+
private status;
|
|
1433
|
+
private pingTimer;
|
|
1434
|
+
private reconnectTimer;
|
|
1435
|
+
private reconnectAttempt;
|
|
1436
|
+
private manualClose;
|
|
1437
|
+
private hasJoinedAfterLogin;
|
|
1438
|
+
private handlers;
|
|
1439
|
+
constructor(opts: SocketClientOptions);
|
|
1440
|
+
/** Current status useful for UI */
|
|
1441
|
+
getStatus(): SocketStatus;
|
|
1442
|
+
/** Raw socket access (optional) */
|
|
1443
|
+
getSocket(): WebSocket | null;
|
|
1444
|
+
/** Connect (idempotent) */
|
|
1445
|
+
connect(): void;
|
|
1446
|
+
/** Disconnect gracefully */
|
|
1447
|
+
disconnect(code?: number, reason?: string): void;
|
|
1448
|
+
/** Call after login (or whenever token/user changes) */
|
|
1449
|
+
onLogin(): void;
|
|
1450
|
+
/** Reset join flag (call on logout) */
|
|
1451
|
+
onLogout(): void;
|
|
1452
|
+
/** Subscribe to message type (e.g. 'happyHourStarted', 'latest-bet'). Use '*' to receive everything. */
|
|
1453
|
+
on<T = any>(type: string, handler: SocketEventHandler<T>): () => void;
|
|
1454
|
+
off<T = any>(type: string, handler: SocketEventHandler<T>): void;
|
|
1455
|
+
/** Send a typed message (SDK-side helper) */
|
|
1456
|
+
send(type: string, payload?: any): void;
|
|
1457
|
+
private emit;
|
|
1458
|
+
private sendRaw;
|
|
1459
|
+
private tryJoinAfterLogin;
|
|
1460
|
+
private startPing;
|
|
1461
|
+
private stopPing;
|
|
1462
|
+
private scheduleReconnect;
|
|
1463
|
+
private clearReconnect;
|
|
1464
|
+
private setStatus;
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1353
1467
|
interface SDKConfig {
|
|
1354
1468
|
baseUrl: string;
|
|
1355
1469
|
timeoutMs?: number;
|
|
1470
|
+
socketUrl?: string;
|
|
1471
|
+
getSocketToken?: () => string | null;
|
|
1356
1472
|
}
|
|
1357
1473
|
declare class GameSDK {
|
|
1358
1474
|
readonly http: HttpClient;
|
|
1359
1475
|
readonly auth: JwtAuth;
|
|
1476
|
+
readonly ws: SocketClient;
|
|
1360
1477
|
readonly affiliate: AffiliateAPI;
|
|
1361
1478
|
readonly content: ContentAPI;
|
|
1362
1479
|
readonly deposit: DepositAPI;
|
|
@@ -1376,4 +1493,4 @@ declare class GameSDK {
|
|
|
1376
1493
|
}
|
|
1377
1494
|
declare const createGameSDK: (cfg: SDKConfig) => GameSDK;
|
|
1378
1495
|
|
|
1379
|
-
export { ApiError, type AuthResponse, ContentAPI, type
|
|
1496
|
+
export { ApiError, type AuthResponse, ContentAPI, type CreatePlayerInput, type CreatePlayerV2Input, type CreatePlayerV2Step2Input, type GameLinkResponse, GameSDK, GamesAPI, type GeoInfo, type GoogleLoginRequest, type GoogleProfile, type ISODateString, JwtAuth, PromotionsAPI, type RegisterResponse, type SDKConfig, type SignupResponse, type SignupV2ValidateResponse, USERNAME_REGEX, type User, type Wallet, createGameSDK, isApiError, type pinCodeCheckResponse, type pinCodeResponse };
|
package/dist/index.js
CHANGED
|
@@ -333,6 +333,7 @@ var JwtAuth = class {
|
|
|
333
333
|
const payload = { username, password, recaptchaToken };
|
|
334
334
|
const res = await this.client.post("/auth/login", payload, authPolicy);
|
|
335
335
|
this.setUser(res.user, res.token);
|
|
336
|
+
storage.setSocketToken(res.socketToken);
|
|
336
337
|
return res;
|
|
337
338
|
}
|
|
338
339
|
async GoogleLogin(data) {
|
|
@@ -497,6 +498,9 @@ var ContentAPI = class {
|
|
|
497
498
|
get(slug) {
|
|
498
499
|
return this.http.get(`/content-pages/${slug}`, "none");
|
|
499
500
|
}
|
|
501
|
+
getAnnouncements() {
|
|
502
|
+
return this.http.get("/announcements", "none");
|
|
503
|
+
}
|
|
500
504
|
};
|
|
501
505
|
|
|
502
506
|
// src/apis/deposit.ts
|
|
@@ -522,7 +526,7 @@ var GamesAPI = class {
|
|
|
522
526
|
}
|
|
523
527
|
/** Public: search games */
|
|
524
528
|
search(request) {
|
|
525
|
-
return this.http.
|
|
529
|
+
return this.http.get(`/games/search?${new URLSearchParams(request).toString()}`, "none");
|
|
526
530
|
}
|
|
527
531
|
getCategories() {
|
|
528
532
|
return this.http.get("/games/categories", "none");
|
|
@@ -532,8 +536,8 @@ var GamesAPI = class {
|
|
|
532
536
|
return this.http.post(`/games/getLink`, { gameId }, "required");
|
|
533
537
|
}
|
|
534
538
|
/** Public: demo link */
|
|
535
|
-
getDemoLink(
|
|
536
|
-
return this.http.post("/games/getDemoLink", {
|
|
539
|
+
getDemoLink(gameExternalId) {
|
|
540
|
+
return this.http.post("/games/getDemoLink", { gameExternalId }, "none");
|
|
537
541
|
}
|
|
538
542
|
setFavorite(gameId, isFavorite) {
|
|
539
543
|
return this.http.post("/games/favorites", { gameId, isFavorite }, "required");
|
|
@@ -562,6 +566,9 @@ var GamesAPI = class {
|
|
|
562
566
|
getProviders() {
|
|
563
567
|
return this.http.get("/games/providers", "none");
|
|
564
568
|
}
|
|
569
|
+
getCategoriesProviders() {
|
|
570
|
+
return this.http.get("/games/providers/categories", "none");
|
|
571
|
+
}
|
|
565
572
|
getLobby() {
|
|
566
573
|
const geo = new GeolocationAPI(this.http);
|
|
567
574
|
const countryCode = geo.getCountryCode();
|
|
@@ -650,6 +657,12 @@ var PlayerAPI = class {
|
|
|
650
657
|
verifyPhoneCode(data) {
|
|
651
658
|
return this.http.post("/verify/phone/confirm", data);
|
|
652
659
|
}
|
|
660
|
+
verifyPhoneSignup(data) {
|
|
661
|
+
return this.http.post("/verify/phone/send", data);
|
|
662
|
+
}
|
|
663
|
+
verifyPhoneCodeSignup(data) {
|
|
664
|
+
return this.http.post("/verify/phone/confirm", data);
|
|
665
|
+
}
|
|
653
666
|
getVerificationStatus() {
|
|
654
667
|
return this.http.get("/player/verification-status");
|
|
655
668
|
}
|
|
@@ -771,6 +784,9 @@ var SettingsAPI = class {
|
|
|
771
784
|
getCurrencies() {
|
|
772
785
|
return this.http.get("/currencies/get", "none");
|
|
773
786
|
}
|
|
787
|
+
getCurrenciesRates() {
|
|
788
|
+
return this.http.get("/currencies/rates", "none");
|
|
789
|
+
}
|
|
774
790
|
getWebSetting(lang) {
|
|
775
791
|
return this.http.get(`/website-settings?language=${lang}&key[]=footerCasinoItems&key[]=footerSportsItems&key[]=footerSocialMedia&key[]=footerPromoItems&key[]=footerSupportLegalItems&key[]=footerAboutUsItems&key[]=footerAppLinks`, "none");
|
|
776
792
|
}
|
|
@@ -855,6 +871,171 @@ var WithdrawAPI = class {
|
|
|
855
871
|
}
|
|
856
872
|
};
|
|
857
873
|
|
|
874
|
+
// src/ws/socketClient.ts
|
|
875
|
+
var SocketClient = class {
|
|
876
|
+
constructor(opts) {
|
|
877
|
+
this.opts = opts;
|
|
878
|
+
this.ws = null;
|
|
879
|
+
this.status = "idle";
|
|
880
|
+
this.pingTimer = null;
|
|
881
|
+
this.reconnectTimer = null;
|
|
882
|
+
this.reconnectAttempt = 0;
|
|
883
|
+
this.manualClose = false;
|
|
884
|
+
this.hasJoinedAfterLogin = false;
|
|
885
|
+
this.handlers = /* @__PURE__ */ new Map();
|
|
886
|
+
}
|
|
887
|
+
/** Current status useful for UI */
|
|
888
|
+
getStatus() {
|
|
889
|
+
return this.status;
|
|
890
|
+
}
|
|
891
|
+
/** Raw socket access (optional) */
|
|
892
|
+
getSocket() {
|
|
893
|
+
return this.ws;
|
|
894
|
+
}
|
|
895
|
+
/** Connect (idempotent) */
|
|
896
|
+
connect() {
|
|
897
|
+
if (this.ws && (this.ws.readyState === WebSocket.OPEN || this.ws.readyState === WebSocket.CONNECTING)) {
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
this.manualClose = false;
|
|
901
|
+
this.setStatus(this.reconnectAttempt > 0 ? "reconnecting" : "connecting");
|
|
902
|
+
this.ws = new WebSocket(this.opts.url);
|
|
903
|
+
this.ws.onopen = () => {
|
|
904
|
+
this.reconnectAttempt = 0;
|
|
905
|
+
this.setStatus("connected");
|
|
906
|
+
this.sendRaw({
|
|
907
|
+
type: "joinPublic",
|
|
908
|
+
payload: { name: this.opts.publicName ?? "player1" }
|
|
909
|
+
});
|
|
910
|
+
this.startPing();
|
|
911
|
+
this.tryJoinAfterLogin();
|
|
912
|
+
};
|
|
913
|
+
this.ws.onmessage = (event) => {
|
|
914
|
+
let parsed;
|
|
915
|
+
try {
|
|
916
|
+
parsed = JSON.parse(event.data);
|
|
917
|
+
} catch {
|
|
918
|
+
this.emit("*", event.data, { type: "*", message: event.data });
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
const data = parsed.message ?? parsed.payload ?? parsed;
|
|
922
|
+
this.emit(parsed.type, data, parsed);
|
|
923
|
+
this.emit("*", data, parsed);
|
|
924
|
+
};
|
|
925
|
+
this.ws.onerror = () => {
|
|
926
|
+
this.emit("error", null, { type: "error" });
|
|
927
|
+
};
|
|
928
|
+
this.ws.onclose = () => {
|
|
929
|
+
this.stopPing();
|
|
930
|
+
this.setStatus("disconnected");
|
|
931
|
+
if (!this.manualClose && (this.opts.autoReconnect ?? true)) {
|
|
932
|
+
this.scheduleReconnect();
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
/** Disconnect gracefully */
|
|
937
|
+
disconnect(code = 1e3, reason = "client_disconnect") {
|
|
938
|
+
this.manualClose = true;
|
|
939
|
+
this.stopPing();
|
|
940
|
+
this.clearReconnect();
|
|
941
|
+
if (this.ws) {
|
|
942
|
+
try {
|
|
943
|
+
this.ws.close(code, reason);
|
|
944
|
+
} catch {
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
this.ws = null;
|
|
948
|
+
this.setStatus("disconnected");
|
|
949
|
+
}
|
|
950
|
+
/** Call after login (or whenever token/user changes) */
|
|
951
|
+
onLogin() {
|
|
952
|
+
this.hasJoinedAfterLogin = false;
|
|
953
|
+
this.tryJoinAfterLogin();
|
|
954
|
+
}
|
|
955
|
+
/** Reset join flag (call on logout) */
|
|
956
|
+
onLogout() {
|
|
957
|
+
this.hasJoinedAfterLogin = false;
|
|
958
|
+
}
|
|
959
|
+
/** Subscribe to message type (e.g. 'happyHourStarted', 'latest-bet'). Use '*' to receive everything. */
|
|
960
|
+
on(type, handler) {
|
|
961
|
+
const set = this.handlers.get(type) ?? /* @__PURE__ */ new Set();
|
|
962
|
+
set.add(handler);
|
|
963
|
+
this.handlers.set(type, set);
|
|
964
|
+
return () => this.off(type, handler);
|
|
965
|
+
}
|
|
966
|
+
off(type, handler) {
|
|
967
|
+
const set = this.handlers.get(type);
|
|
968
|
+
if (!set) return;
|
|
969
|
+
set.delete(handler);
|
|
970
|
+
if (set.size === 0) this.handlers.delete(type);
|
|
971
|
+
}
|
|
972
|
+
/** Send a typed message (SDK-side helper) */
|
|
973
|
+
send(type, payload) {
|
|
974
|
+
this.sendRaw({ type, payload });
|
|
975
|
+
}
|
|
976
|
+
// ----------------- internals -----------------
|
|
977
|
+
emit(type, data, raw) {
|
|
978
|
+
const set = this.handlers.get(type);
|
|
979
|
+
if (!set) return;
|
|
980
|
+
for (const fn of set) {
|
|
981
|
+
try {
|
|
982
|
+
fn(data, raw);
|
|
983
|
+
} catch {
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
sendRaw(msg) {
|
|
988
|
+
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) return;
|
|
989
|
+
this.ws.send(JSON.stringify(msg));
|
|
990
|
+
}
|
|
991
|
+
tryJoinAfterLogin() {
|
|
992
|
+
if (this.hasJoinedAfterLogin) return;
|
|
993
|
+
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) return;
|
|
994
|
+
const user = this.opts.getUser?.() ?? null;
|
|
995
|
+
if (!user?.id) return;
|
|
996
|
+
const socketToken = this.opts.getSocketToken?.() ?? "";
|
|
997
|
+
if (!socketToken) return;
|
|
998
|
+
this.sendRaw({
|
|
999
|
+
type: "join",
|
|
1000
|
+
payload: {
|
|
1001
|
+
name: user.name || "player1",
|
|
1002
|
+
playerId: user.id,
|
|
1003
|
+
socketToken
|
|
1004
|
+
}
|
|
1005
|
+
});
|
|
1006
|
+
this.hasJoinedAfterLogin = true;
|
|
1007
|
+
}
|
|
1008
|
+
startPing() {
|
|
1009
|
+
this.stopPing();
|
|
1010
|
+
const every = this.opts.pingIntervalMs ?? 5e3;
|
|
1011
|
+
this.pingTimer = setInterval(() => {
|
|
1012
|
+
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) return;
|
|
1013
|
+
this.sendRaw({ type: "ping", payload: { ping: 1 } });
|
|
1014
|
+
}, every);
|
|
1015
|
+
}
|
|
1016
|
+
stopPing() {
|
|
1017
|
+
if (this.pingTimer) clearInterval(this.pingTimer);
|
|
1018
|
+
this.pingTimer = null;
|
|
1019
|
+
}
|
|
1020
|
+
scheduleReconnect() {
|
|
1021
|
+
this.clearReconnect();
|
|
1022
|
+
this.reconnectAttempt += 1;
|
|
1023
|
+
const base = Math.min(1e3 * 2 ** (this.reconnectAttempt - 1), this.opts.maxReconnectDelayMs ?? 3e4);
|
|
1024
|
+
const jitter = Math.floor(Math.random() * 250);
|
|
1025
|
+
this.reconnectTimer = setTimeout(() => {
|
|
1026
|
+
this.connect();
|
|
1027
|
+
}, base + jitter);
|
|
1028
|
+
}
|
|
1029
|
+
clearReconnect() {
|
|
1030
|
+
if (this.reconnectTimer) clearTimeout(this.reconnectTimer);
|
|
1031
|
+
this.reconnectTimer = null;
|
|
1032
|
+
}
|
|
1033
|
+
setStatus(s) {
|
|
1034
|
+
this.status = s;
|
|
1035
|
+
this.emit("status", s, { type: "status", payload: s });
|
|
1036
|
+
}
|
|
1037
|
+
};
|
|
1038
|
+
|
|
858
1039
|
// src/sdk.ts
|
|
859
1040
|
var GameSDK = class {
|
|
860
1041
|
constructor(cfg) {
|
|
@@ -864,6 +1045,12 @@ var GameSDK = class {
|
|
|
864
1045
|
// <-- uses this.auth (defined below)
|
|
865
1046
|
timeoutMs: cfg.timeoutMs ?? 15e3
|
|
866
1047
|
});
|
|
1048
|
+
this.ws = new SocketClient({
|
|
1049
|
+
url: cfg.socketUrl || "",
|
|
1050
|
+
publicName: "player1",
|
|
1051
|
+
getSocketToken: cfg.getSocketToken ?? (() => storage.getSocketToken()),
|
|
1052
|
+
getUser: () => this.auth.getUser() ? { id: this.auth.getUser().id, name: this.auth.getUser().name } : null
|
|
1053
|
+
});
|
|
867
1054
|
this.auth = new JwtAuth(this.http);
|
|
868
1055
|
this.affiliate = new AffiliateAPI(this.http);
|
|
869
1056
|
this.content = new ContentAPI(this.http);
|