@masterunoco/casinowebengine-api 0.1.5 → 0.1.7
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 +199 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +135 -3
- package/dist/index.d.ts +135 -3
- package/dist/index.js +199 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -335,6 +335,7 @@ var JwtAuth = class {
|
|
|
335
335
|
const payload = { username, password, recaptchaToken };
|
|
336
336
|
const res = await this.client.post("/auth/login", payload, authPolicy);
|
|
337
337
|
this.setUser(res.user, res.token);
|
|
338
|
+
storage.setSocketToken(res.socketToken);
|
|
338
339
|
return res;
|
|
339
340
|
}
|
|
340
341
|
async GoogleLogin(data) {
|
|
@@ -499,6 +500,9 @@ var ContentAPI = class {
|
|
|
499
500
|
get(slug) {
|
|
500
501
|
return this.http.get(`/content-pages/${slug}`, "none");
|
|
501
502
|
}
|
|
503
|
+
getAnnouncements() {
|
|
504
|
+
return this.http.get("/announcements", "none");
|
|
505
|
+
}
|
|
502
506
|
};
|
|
503
507
|
|
|
504
508
|
// src/apis/deposit.ts
|
|
@@ -524,7 +528,7 @@ var GamesAPI = class {
|
|
|
524
528
|
}
|
|
525
529
|
/** Public: search games */
|
|
526
530
|
search(request) {
|
|
527
|
-
return this.http.
|
|
531
|
+
return this.http.get(`/games/search?${new URLSearchParams(request).toString()}`, "none");
|
|
528
532
|
}
|
|
529
533
|
getCategories() {
|
|
530
534
|
return this.http.get("/games/categories", "none");
|
|
@@ -534,8 +538,8 @@ var GamesAPI = class {
|
|
|
534
538
|
return this.http.post(`/games/getLink`, { gameId }, "required");
|
|
535
539
|
}
|
|
536
540
|
/** Public: demo link */
|
|
537
|
-
getDemoLink(
|
|
538
|
-
return this.http.post("/games/getDemoLink", {
|
|
541
|
+
getDemoLink(gameExternalId) {
|
|
542
|
+
return this.http.post("/games/getDemoLink", { gameExternalId }, "none");
|
|
539
543
|
}
|
|
540
544
|
setFavorite(gameId, isFavorite) {
|
|
541
545
|
return this.http.post("/games/favorites", { gameId, isFavorite }, "required");
|
|
@@ -564,6 +568,9 @@ var GamesAPI = class {
|
|
|
564
568
|
getProviders() {
|
|
565
569
|
return this.http.get("/games/providers", "none");
|
|
566
570
|
}
|
|
571
|
+
getCategoriesProviders() {
|
|
572
|
+
return this.http.get("/games/providers/categories", "none");
|
|
573
|
+
}
|
|
567
574
|
getLobby() {
|
|
568
575
|
const geo = new GeolocationAPI(this.http);
|
|
569
576
|
const countryCode = geo.getCountryCode();
|
|
@@ -573,6 +580,9 @@ var GamesAPI = class {
|
|
|
573
580
|
}
|
|
574
581
|
return this.http.get(url, "none");
|
|
575
582
|
}
|
|
583
|
+
getGameOfTheWeek() {
|
|
584
|
+
return this.http.get("/games/game-of-the-week", "none");
|
|
585
|
+
}
|
|
576
586
|
};
|
|
577
587
|
|
|
578
588
|
// src/apis/luckyWheel.ts
|
|
@@ -652,6 +662,12 @@ var PlayerAPI = class {
|
|
|
652
662
|
verifyPhoneCode(data) {
|
|
653
663
|
return this.http.post("/verify/phone/confirm", data);
|
|
654
664
|
}
|
|
665
|
+
verifyPhoneSignup(data) {
|
|
666
|
+
return this.http.post("/verify/phone/send", data);
|
|
667
|
+
}
|
|
668
|
+
verifyPhoneCodeSignup(data) {
|
|
669
|
+
return this.http.post("/verify/phone/confirm", data);
|
|
670
|
+
}
|
|
655
671
|
getVerificationStatus() {
|
|
656
672
|
return this.http.get("/player/verification-status");
|
|
657
673
|
}
|
|
@@ -773,6 +789,9 @@ var SettingsAPI = class {
|
|
|
773
789
|
getCurrencies() {
|
|
774
790
|
return this.http.get("/currencies/get", "none");
|
|
775
791
|
}
|
|
792
|
+
getCurrenciesRates() {
|
|
793
|
+
return this.http.get("/currencies/rates", "none");
|
|
794
|
+
}
|
|
776
795
|
getWebSetting(lang) {
|
|
777
796
|
return this.http.get(`/website-settings?language=${lang}&key[]=footerCasinoItems&key[]=footerSportsItems&key[]=footerSocialMedia&key[]=footerPromoItems&key[]=footerSupportLegalItems&key[]=footerAboutUsItems&key[]=footerAppLinks`, "none");
|
|
778
797
|
}
|
|
@@ -806,6 +825,12 @@ var SettingsAPI = class {
|
|
|
806
825
|
getSupportEmail(lang) {
|
|
807
826
|
return this.http.get(`/website-settings?language=${lang}&key[]=supportEmail`, "none");
|
|
808
827
|
}
|
|
828
|
+
getReferralBannersPack(lang) {
|
|
829
|
+
return this.http.get(`/website-settings?language=${lang}&key[]=referral_banners`, "none");
|
|
830
|
+
}
|
|
831
|
+
getReferralGraphicsPack(lang) {
|
|
832
|
+
return this.http.get(`/website-settings?language=${lang}&key[]=Referral_graphics`, "none");
|
|
833
|
+
}
|
|
809
834
|
};
|
|
810
835
|
|
|
811
836
|
// src/apis/sport.ts
|
|
@@ -857,6 +882,171 @@ var WithdrawAPI = class {
|
|
|
857
882
|
}
|
|
858
883
|
};
|
|
859
884
|
|
|
885
|
+
// src/ws/socketClient.ts
|
|
886
|
+
var SocketClient = class {
|
|
887
|
+
constructor(opts) {
|
|
888
|
+
this.opts = opts;
|
|
889
|
+
this.ws = null;
|
|
890
|
+
this.status = "idle";
|
|
891
|
+
this.pingTimer = null;
|
|
892
|
+
this.reconnectTimer = null;
|
|
893
|
+
this.reconnectAttempt = 0;
|
|
894
|
+
this.manualClose = false;
|
|
895
|
+
this.hasJoinedAfterLogin = false;
|
|
896
|
+
this.handlers = /* @__PURE__ */ new Map();
|
|
897
|
+
}
|
|
898
|
+
/** Current status useful for UI */
|
|
899
|
+
getStatus() {
|
|
900
|
+
return this.status;
|
|
901
|
+
}
|
|
902
|
+
/** Raw socket access (optional) */
|
|
903
|
+
getSocket() {
|
|
904
|
+
return this.ws;
|
|
905
|
+
}
|
|
906
|
+
/** Connect (idempotent) */
|
|
907
|
+
connect() {
|
|
908
|
+
if (this.ws && (this.ws.readyState === WebSocket.OPEN || this.ws.readyState === WebSocket.CONNECTING)) {
|
|
909
|
+
return;
|
|
910
|
+
}
|
|
911
|
+
this.manualClose = false;
|
|
912
|
+
this.setStatus(this.reconnectAttempt > 0 ? "reconnecting" : "connecting");
|
|
913
|
+
this.ws = new WebSocket(this.opts.url);
|
|
914
|
+
this.ws.onopen = () => {
|
|
915
|
+
this.reconnectAttempt = 0;
|
|
916
|
+
this.setStatus("connected");
|
|
917
|
+
this.sendRaw({
|
|
918
|
+
type: "joinPublic",
|
|
919
|
+
payload: { name: this.opts.publicName ?? "player1" }
|
|
920
|
+
});
|
|
921
|
+
this.startPing();
|
|
922
|
+
this.tryJoinAfterLogin();
|
|
923
|
+
};
|
|
924
|
+
this.ws.onmessage = (event) => {
|
|
925
|
+
let parsed;
|
|
926
|
+
try {
|
|
927
|
+
parsed = JSON.parse(event.data);
|
|
928
|
+
} catch {
|
|
929
|
+
this.emit("*", event.data, { type: "*", message: event.data });
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
const data = parsed.message ?? parsed.payload ?? parsed;
|
|
933
|
+
this.emit(parsed.type, data, parsed);
|
|
934
|
+
this.emit("*", data, parsed);
|
|
935
|
+
};
|
|
936
|
+
this.ws.onerror = () => {
|
|
937
|
+
this.emit("error", null, { type: "error" });
|
|
938
|
+
};
|
|
939
|
+
this.ws.onclose = () => {
|
|
940
|
+
this.stopPing();
|
|
941
|
+
this.setStatus("disconnected");
|
|
942
|
+
if (!this.manualClose && (this.opts.autoReconnect ?? true)) {
|
|
943
|
+
this.scheduleReconnect();
|
|
944
|
+
}
|
|
945
|
+
};
|
|
946
|
+
}
|
|
947
|
+
/** Disconnect gracefully */
|
|
948
|
+
disconnect(code = 1e3, reason = "client_disconnect") {
|
|
949
|
+
this.manualClose = true;
|
|
950
|
+
this.stopPing();
|
|
951
|
+
this.clearReconnect();
|
|
952
|
+
if (this.ws) {
|
|
953
|
+
try {
|
|
954
|
+
this.ws.close(code, reason);
|
|
955
|
+
} catch {
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
this.ws = null;
|
|
959
|
+
this.setStatus("disconnected");
|
|
960
|
+
}
|
|
961
|
+
/** Call after login (or whenever token/user changes) */
|
|
962
|
+
onLogin() {
|
|
963
|
+
this.hasJoinedAfterLogin = false;
|
|
964
|
+
this.tryJoinAfterLogin();
|
|
965
|
+
}
|
|
966
|
+
/** Reset join flag (call on logout) */
|
|
967
|
+
onLogout() {
|
|
968
|
+
this.hasJoinedAfterLogin = false;
|
|
969
|
+
}
|
|
970
|
+
/** Subscribe to message type (e.g. 'happyHourStarted', 'latest-bet'). Use '*' to receive everything. */
|
|
971
|
+
on(type, handler) {
|
|
972
|
+
const set = this.handlers.get(type) ?? /* @__PURE__ */ new Set();
|
|
973
|
+
set.add(handler);
|
|
974
|
+
this.handlers.set(type, set);
|
|
975
|
+
return () => this.off(type, handler);
|
|
976
|
+
}
|
|
977
|
+
off(type, handler) {
|
|
978
|
+
const set = this.handlers.get(type);
|
|
979
|
+
if (!set) return;
|
|
980
|
+
set.delete(handler);
|
|
981
|
+
if (set.size === 0) this.handlers.delete(type);
|
|
982
|
+
}
|
|
983
|
+
/** Send a typed message (SDK-side helper) */
|
|
984
|
+
send(type, payload) {
|
|
985
|
+
this.sendRaw({ type, payload });
|
|
986
|
+
}
|
|
987
|
+
// ----------------- internals -----------------
|
|
988
|
+
emit(type, data, raw) {
|
|
989
|
+
const set = this.handlers.get(type);
|
|
990
|
+
if (!set) return;
|
|
991
|
+
for (const fn of set) {
|
|
992
|
+
try {
|
|
993
|
+
fn(data, raw);
|
|
994
|
+
} catch {
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
sendRaw(msg) {
|
|
999
|
+
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) return;
|
|
1000
|
+
this.ws.send(JSON.stringify(msg));
|
|
1001
|
+
}
|
|
1002
|
+
tryJoinAfterLogin() {
|
|
1003
|
+
if (this.hasJoinedAfterLogin) return;
|
|
1004
|
+
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) return;
|
|
1005
|
+
const user = this.opts.getUser?.() ?? null;
|
|
1006
|
+
if (!user?.id) return;
|
|
1007
|
+
const socketToken = this.opts.getSocketToken?.() ?? "";
|
|
1008
|
+
if (!socketToken) return;
|
|
1009
|
+
this.sendRaw({
|
|
1010
|
+
type: "join",
|
|
1011
|
+
payload: {
|
|
1012
|
+
name: user.name || "player1",
|
|
1013
|
+
playerId: user.id,
|
|
1014
|
+
socketToken
|
|
1015
|
+
}
|
|
1016
|
+
});
|
|
1017
|
+
this.hasJoinedAfterLogin = true;
|
|
1018
|
+
}
|
|
1019
|
+
startPing() {
|
|
1020
|
+
this.stopPing();
|
|
1021
|
+
const every = this.opts.pingIntervalMs ?? 5e3;
|
|
1022
|
+
this.pingTimer = setInterval(() => {
|
|
1023
|
+
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) return;
|
|
1024
|
+
this.sendRaw({ type: "ping", payload: { ping: 1 } });
|
|
1025
|
+
}, every);
|
|
1026
|
+
}
|
|
1027
|
+
stopPing() {
|
|
1028
|
+
if (this.pingTimer) clearInterval(this.pingTimer);
|
|
1029
|
+
this.pingTimer = null;
|
|
1030
|
+
}
|
|
1031
|
+
scheduleReconnect() {
|
|
1032
|
+
this.clearReconnect();
|
|
1033
|
+
this.reconnectAttempt += 1;
|
|
1034
|
+
const base = Math.min(1e3 * 2 ** (this.reconnectAttempt - 1), this.opts.maxReconnectDelayMs ?? 3e4);
|
|
1035
|
+
const jitter = Math.floor(Math.random() * 250);
|
|
1036
|
+
this.reconnectTimer = setTimeout(() => {
|
|
1037
|
+
this.connect();
|
|
1038
|
+
}, base + jitter);
|
|
1039
|
+
}
|
|
1040
|
+
clearReconnect() {
|
|
1041
|
+
if (this.reconnectTimer) clearTimeout(this.reconnectTimer);
|
|
1042
|
+
this.reconnectTimer = null;
|
|
1043
|
+
}
|
|
1044
|
+
setStatus(s) {
|
|
1045
|
+
this.status = s;
|
|
1046
|
+
this.emit("status", s, { type: "status", payload: s });
|
|
1047
|
+
}
|
|
1048
|
+
};
|
|
1049
|
+
|
|
860
1050
|
// src/sdk.ts
|
|
861
1051
|
var GameSDK = class {
|
|
862
1052
|
constructor(cfg) {
|
|
@@ -866,6 +1056,12 @@ var GameSDK = class {
|
|
|
866
1056
|
// <-- uses this.auth (defined below)
|
|
867
1057
|
timeoutMs: cfg.timeoutMs ?? 15e3
|
|
868
1058
|
});
|
|
1059
|
+
this.ws = new SocketClient({
|
|
1060
|
+
url: cfg.socketUrl || "",
|
|
1061
|
+
publicName: "player1",
|
|
1062
|
+
getSocketToken: cfg.getSocketToken ?? (() => storage.getSocketToken()),
|
|
1063
|
+
getUser: () => this.auth.getUser() ? { id: this.auth.getUser().id, name: this.auth.getUser().name } : null
|
|
1064
|
+
});
|
|
869
1065
|
this.auth = new JwtAuth(this.http);
|
|
870
1066
|
this.affiliate = new AffiliateAPI(this.http);
|
|
871
1067
|
this.content = new ContentAPI(this.http);
|