@kalamba/sdk 0.6.0 → 0.7.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/errors-867a013a.js +57 -0
- package/dist/errors-c5948a4a.cjs +5 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +76 -69
- package/dist/index.js +78 -84
- package/dist/plugins.cjs +1 -1
- package/dist/plugins.d.ts +73 -52
- package/dist/plugins.js +978 -1018
- package/dist/wrapper.d.ts +71 -50
- package/package.json +1 -1
- package/dist/errors-66b5612a.cjs +0 -5
- package/dist/errors-96eb18f7.js +0 -52
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BSD 3-Clause License
|
|
3
|
+
* Copyright (c) 2024, Kalamba Games Limited
|
|
4
|
+
*/
|
|
5
|
+
var O = Object.defineProperty;
|
|
6
|
+
var A = (_, E, R) => E in _ ? O(_, E, { enumerable: !0, configurable: !0, writable: !0, value: R }) : _[E] = R;
|
|
7
|
+
var N = (_, E, R) => (A(_, typeof E != "symbol" ? E + "" : E, R), R);
|
|
8
|
+
const I = {
|
|
9
|
+
CONNECTION_ERROR: "CONNECTION_ERROR",
|
|
10
|
+
INVALID_BET_CURRENCY: "INVALID_BET_CURRENCY",
|
|
11
|
+
INVALID_BET: "INVALID_BET",
|
|
12
|
+
INVALID_CAGE_CODE: "INVALID_CAGE_CODE",
|
|
13
|
+
INVALID_CLIENT_TYPE: "INVALID_CLIENT_TYPE",
|
|
14
|
+
INVALID_MESSAGE_FORMAT: "INVALID_MESSAGE_FORMAT",
|
|
15
|
+
INVALID_SESSION: "INVALID_SESSION",
|
|
16
|
+
TOO_HIGH_BET_FREQUENCY: "TOO_HIGH_BET_FREQUENCY",
|
|
17
|
+
TOO_HIGH_ACTION_FREQUENCY: "TOO_HIGH_ACTION_FREQUENCY",
|
|
18
|
+
USER_LOCK_INVALID_PARAMS: "USER_LOCK_INVALID_PARAMS",
|
|
19
|
+
USER_ALREADY_LOCKED: "USER_ALREADY_LOCKED",
|
|
20
|
+
GAME_SERVER_ERROR: "GAME_SERVER_ERROR",
|
|
21
|
+
SESSION_MANAGEMENT_ERROR: "SESSION_MANAGEMENT_ERROR",
|
|
22
|
+
MESSAGE_SENDER_ERROR: "MESSAGE_SENDER_ERROR",
|
|
23
|
+
FREE_ROUNDS_PROCESSING_ERROR: "FREE_ROUNDS_PROCESSING_ERROR",
|
|
24
|
+
WEB_SESSION_NOT_OPEN: "WEB_SESSION_NOT_OPEN",
|
|
25
|
+
GAMING_LIMITS_REACHED: "GAMING_LIMITS_REACHED",
|
|
26
|
+
OUT_OF_MONEY: "OUT_OF_MONEY",
|
|
27
|
+
UNFINISHED_ROUND_IN_PROGRESS: "UNFINISHED_ROUND_IN_PROGRESS",
|
|
28
|
+
ACCESS_DENIED: "ACCESS_DENIED",
|
|
29
|
+
CREDENTIALS_NOT_FOUND: "CREDENTIALS_NOT_FOUND",
|
|
30
|
+
ALREADY_LOGGED_IN: "ALREADY_LOGGED_IN",
|
|
31
|
+
GAME_UNAVAILABLE: "GAME_UNAVAILABLE",
|
|
32
|
+
BONUS_RESTRICTION: "BONUS_RESTRICTION",
|
|
33
|
+
TOO_MANY_OPEN_GAMES: "TOO_MANY_OPEN_GAMES",
|
|
34
|
+
GAME_FROZEN: "GAME_FROZEN",
|
|
35
|
+
WALLET_PROCESSING_ERROR: "WALLET_PROCESSING_ERROR",
|
|
36
|
+
FORCED_OUTCOMES_NOT_ALLOWED: "FORCED_OUTCOMES_NOT_ALLOWED",
|
|
37
|
+
MISSING_GAME_STATE: "MISSING_GAME_STATE",
|
|
38
|
+
DATA_ACCESS_ERROR: "DATA_ACCESS_ERROR",
|
|
39
|
+
UNKNOWN: "UNKNOWN"
|
|
40
|
+
};
|
|
41
|
+
class T extends Error {
|
|
42
|
+
constructor(R) {
|
|
43
|
+
super();
|
|
44
|
+
N(this, "data");
|
|
45
|
+
this.name = "RgsError", this.data = R;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
class D extends Error {
|
|
49
|
+
constructor() {
|
|
50
|
+
super(), this.name = "TimeoutError";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
T as R,
|
|
55
|
+
D as T,
|
|
56
|
+
I as a
|
|
57
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BSD 3-Clause License
|
|
3
|
+
* Copyright (c) 2024, Kalamba Games Limited
|
|
4
|
+
*/
|
|
5
|
+
"use strict";var O=Object.defineProperty;var A=(_,E,R)=>E in _?O(_,E,{enumerable:!0,configurable:!0,writable:!0,value:R}):_[E]=R;var N=(_,E,R)=>(A(_,typeof E!="symbol"?E+"":E,R),R);const S={CONNECTION_ERROR:"CONNECTION_ERROR",INVALID_BET_CURRENCY:"INVALID_BET_CURRENCY",INVALID_BET:"INVALID_BET",INVALID_CAGE_CODE:"INVALID_CAGE_CODE",INVALID_CLIENT_TYPE:"INVALID_CLIENT_TYPE",INVALID_MESSAGE_FORMAT:"INVALID_MESSAGE_FORMAT",INVALID_SESSION:"INVALID_SESSION",TOO_HIGH_BET_FREQUENCY:"TOO_HIGH_BET_FREQUENCY",TOO_HIGH_ACTION_FREQUENCY:"TOO_HIGH_ACTION_FREQUENCY",USER_LOCK_INVALID_PARAMS:"USER_LOCK_INVALID_PARAMS",USER_ALREADY_LOCKED:"USER_ALREADY_LOCKED",GAME_SERVER_ERROR:"GAME_SERVER_ERROR",SESSION_MANAGEMENT_ERROR:"SESSION_MANAGEMENT_ERROR",MESSAGE_SENDER_ERROR:"MESSAGE_SENDER_ERROR",FREE_ROUNDS_PROCESSING_ERROR:"FREE_ROUNDS_PROCESSING_ERROR",WEB_SESSION_NOT_OPEN:"WEB_SESSION_NOT_OPEN",GAMING_LIMITS_REACHED:"GAMING_LIMITS_REACHED",OUT_OF_MONEY:"OUT_OF_MONEY",UNFINISHED_ROUND_IN_PROGRESS:"UNFINISHED_ROUND_IN_PROGRESS",ACCESS_DENIED:"ACCESS_DENIED",CREDENTIALS_NOT_FOUND:"CREDENTIALS_NOT_FOUND",ALREADY_LOGGED_IN:"ALREADY_LOGGED_IN",GAME_UNAVAILABLE:"GAME_UNAVAILABLE",BONUS_RESTRICTION:"BONUS_RESTRICTION",TOO_MANY_OPEN_GAMES:"TOO_MANY_OPEN_GAMES",GAME_FROZEN:"GAME_FROZEN",WALLET_PROCESSING_ERROR:"WALLET_PROCESSING_ERROR",FORCED_OUTCOMES_NOT_ALLOWED:"FORCED_OUTCOMES_NOT_ALLOWED",MISSING_GAME_STATE:"MISSING_GAME_STATE",DATA_ACCESS_ERROR:"DATA_ACCESS_ERROR",UNKNOWN:"UNKNOWN"};class I extends Error{constructor(R){super();N(this,"data");this.name="RgsError",this.data=R}}class T extends Error{constructor(){super(),this.name="TimeoutError"}}exports.RgsError=I;exports.RgsErrorCode=S;exports.TimeoutError=T;
|
package/dist/index.cjs
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* BSD 3-Clause License
|
|
3
3
|
* Copyright (c) 2024, Kalamba Games Limited
|
|
4
4
|
*/
|
|
5
|
-
"use strict";var
|
|
5
|
+
"use strict";var b=(r,i,t)=>{if(!i.has(r))throw TypeError("Cannot "+t)};var m=(r,i,t)=>(b(r,i,"read from private field"),t?t.call(r):i.get(r)),a=(r,i,t)=>{if(i.has(r))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(r):i.set(r,t)},u=(r,i,t,n)=>(b(r,i,"write to private field"),n?n.call(r,t):i.set(r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("./errors-c5948a4a.cjs");function I(r){const i=Object.prototype.toString.call(r);return r instanceof Date||typeof r=="object"&&i==="[object Date]"?new r.constructor(+r):typeof r=="number"||i==="[object Number]"||typeof r=="string"||i==="[object String]"?new Date(r):new Date(NaN)}function B(r){const i=I(r);return i.setHours(23,59,59,999),i}function k(){return B(Date.now())}function P(r){const i=I(r);return i.setHours(0,0,0,0),i}function L(){return P(Date.now())}const $=3e4;var F,S;class _{constructor(i){a(this,F,void 0);a(this,S,$);u(this,F,i)}buildHeaders(){const i={};return m(this,F).token&&(i.Authorization=`Bearer ${m(this,F).token}`),i}async request(i,t){const n=new URL(i,m(this,F).apiUrl??window.location.origin);return n.search=new URLSearchParams({...t}).toString(),await(await fetch(n,{signal:AbortSignal.timeout(m(this,S)),headers:this.buildHeaders()})).json()}async getRounds(i){return this.request("/rounds",i)}async getRound(i,t){return this.request(`/rounds/${i}`,t)}}F=new WeakMap,S=new WeakMap;const N={limit:100,page:0};var s,l;class O{constructor({config:i}){a(this,s,void 0);a(this,l,void 0);u(this,s,i),u(this,l,new _({apiUrl:i.api.gameHistoryUrl}))}async getRound(i,{pagination:t=N}={}){return m(this,l).getRound(i,{gameCode:m(this,s).api.game,operatorCode:m(this,s).api.brand,username:m(this,s).api.user,...t})}async getLastRound(){return m(this,s).api.lastRoundId?this.getRound(m(this,s).api.lastRoundId):null}async getRounds({searchPeriod:i={fromDateTime:L(),toDateTime:k()},pagination:t=N}={}){const n=m(this,s).api.user.replace(/^user_/,"").replace(new RegExp(`_${m(this,s).api.integration}$`),"");return m(this,l).getRounds({gameCode:m(this,s).api.game,operatorCode:m(this,s).api.integration,username:n,fromDataTime:i.fromDateTime.toISOString(),toDateTime:i.toDateTime.toISOString(),...t})}}s=new WeakMap,l=new WeakMap;function G(r,i){return r*i/100}function A(r,i,t){if(!["string","number"].includes(typeof i))return"NaN";const{locales:n}=r;try{return new Intl.NumberFormat(n,{...t,numberingSystem:"latn",style:"decimal"}).format(+i)}catch{return`${i}`}}const w="XTS";var y=(r=>(r.Currency="Currency",r.Number="Number",r))(y||{}),f=(r=>(r.Coins="Coins",r.Money="Money",r))(f||{});const T={ARSB:{displayAs:"ARS",maximumFractionDigits:2,minimumFractionDigits:2},CHIPS:{maximumFractionDigits:0,minimumFractionDigits:0},BNB:{maximumFractionDigits:6,minimumFractionDigits:6},BUSD:{maximumFractionDigits:4,minimumFractionDigits:4},BTC:{maximumFractionDigits:8,minimumFractionDigits:2},mBTC:{maximumFractionDigits:5,minimumFractionDigits:2},uBTC:{maximumFractionDigits:2,minimumFractionDigits:2},BCH:{maximumFractionDigits:8,minimumFractionDigits:2},mBCH:{maximumFractionDigits:2,minimumFractionDigits:2},ETH:{maximumFractionDigits:8,minimumFractionDigits:2},mETH:{maximumFractionDigits:5,minimumFractionDigits:2},uETH:{maximumFractionDigits:2,minimumFractionDigits:2},SOC:{maximumFractionDigits:8,minimumFractionDigits:2},LTC:{maximumFractionDigits:8,minimumFractionDigits:2},mLTC:{maximumFractionDigits:5,minimumFractionDigits:2},uLTC:{maximumFractionDigits:2,minimumFractionDigits:2},DOG:{maximumFractionDigits:4,minimumFractionDigits:2},USDC:{maximumFractionDigits:4,minimumFractionDigits:4},USDT:{maximumFractionDigits:4,minimumFractionDigits:2},TRX:{maximumFractionDigits:2,minimumFractionDigits:2},TUSD:{maximumFractionDigits:2,minimumFractionDigits:2},DAI:{maximumFractionDigits:2,minimumFractionDigits:2},XMR:{maximumFractionDigits:4,minimumFractionDigits:4},CBET:{maximumFractionDigits:0,minimumFractionDigits:0},kCBET:{maximumFractionDigits:2,minimumFractionDigits:2},SHIB:{maximumFractionDigits:0,minimumFractionDigits:0},kSHIB:{maximumFractionDigits:4,minimumFractionDigits:2},NEO:{maximumFractionDigits:4,minimumFractionDigits:4},BSV:{maximumFractionDigits:4,minimumFractionDigits:4},EOS:{maximumFractionDigits:4,minimumFractionDigits:4},DASH:{maximumFractionDigits:4,minimumFractionDigits:4},XLM:{maximumFractionDigits:2,minimumFractionDigits:2},KRW:{maximumFractionDigits:2,minimumFractionDigits:2},kVND:{maximumFractionDigits:4,minimumFractionDigits:2},kIDR:{maximumFractionDigits:4,minimumFractionDigits:2},RSD:{maximumFractionDigits:2,minimumFractionDigits:2},STAKEGC:{displayAs:"GC",maximumFractionDigits:0,minimumFractionDigits:0},STAKESC:{displayAs:"SC",maximumFractionDigits:2,minimumFractionDigits:2},"FC.":{maximumFractionDigits:2,minimumFractionDigits:2},"GC.":{maximumFractionDigits:2,minimumFractionDigits:2},"SC.":{maximumFractionDigits:2,minimumFractionDigits:2},SVC:{maximumFractionDigits:2,minimumFractionDigits:2},DOT:{maximumFractionDigits:4,minimumFractionDigits:4},SOL:{maximumFractionDigits:4,minimumFractionDigits:4},XRP:{maximumFractionDigits:4,minimumFractionDigits:4},ADA:{maximumFractionDigits:4,minimumFractionDigits:4},TON:{maximumFractionDigits:4,minimumFractionDigits:4},FTN:{maximumFractionDigits:4,minimumFractionDigits:4}};function M(r){return r in T}function j(r){return M(r)?{...T[r],currency:w}:{currency:r}}function q(r,i,t){const n=i.format(+r);return M(t)?n.replace(w,T[t].displayAs??t):n}function V(r,i,t){const{maximumFractionDigits:n,minimumFractionDigits:o}=t.resolvedOptions();return A(r,i,{maximumFractionDigits:n,minimumFractionDigits:o})}function v(r,i,{as:t}={as:"Currency"}){const{canShowCurrency:n,currency:o}=r;return t==="Number"||!n?`${i}`:`${i} ${o}`}function K(r,i,{as:t,from:n}={as:"Currency",from:"Money"},o){if(!["string","number"].includes(typeof i))return"NaN";const{canShowCurrency:e=!0,coinValueInCents:g,currency:x,locales:R}=r;n==="Coins"&&(i=G(+i,g));try{const U=j(x),E=new Intl.NumberFormat(R,{...U,...o,currencyDisplay:"symbol",numberingSystem:"latn",style:"currency"});return t==="Number"||!e?V(r,i,E):q(i,E,x)}catch{return v(r,i,{as:t})}}var c;class H{constructor({config:i}){a(this,c,void 0);u(this,c,i)}formatNumber(i,t){const n={locales:[m(this,c).ui.language]};return A(n,i,t)}formatCurrency(i,t={as:y.Currency,from:f.Money},n){const o=m(this,c).ui.feature.showCurrency,e=m(this,c).api.coinValueInCents,g=m(this,c).api.currency||w,x=[m(this,c).ui.language];return K({canShowCurrency:o,coinValueInCents:e,currency:g,locales:x},i,t,n)}formatCoins(i,t){return this.formatCurrency(i,{as:y.Number,from:f.Coins},t)}formatCoinsWithCurrency(i,t){return this.formatCurrency(i,{as:y.Currency,from:f.Coins},t)}formatMoney(i,t){return this.formatCurrency(i,{as:y.Number,from:f.Money},t)}formatMoneyWithCurrency(i,t){return this.formatCurrency(i,{as:y.Currency,from:f.Money},t)}}c=new WeakMap;const X=()=>{};var h,d,p,C;class z{constructor({messagePort:i}){a(this,h,void 0);a(this,d,void 0);a(this,p,void 0);a(this,C,void 0);u(this,C,i),this.on("configured",t=>{u(this,h,t),u(this,p,new H({config:t})),u(this,d,new O({config:t}))}),this.on("playResponse",t=>{this.config.api.lastRoundId=t.contract.roundId})}get config(){if(!m(this,h))throw new Error("config is not initialized, you must open game first");return m(this,h)}get history(){if(!m(this,d))throw new Error("config is not initialized, you must open game first");return m(this,d)}get i18n(){if(!m(this,p))throw new Error("i18n is not initialized, you must open game first");return m(this,p)}request(i,...[t]){return new Promise(n=>{this.on(`${i}Response`,o=>n({type:"response",response:o}),{once:!0}),this.on(`${i}Error`,o=>n({type:"error",error:o}),{once:!0}),this.send(i,t)})}on(i,t,n){const o=function e(g){g.data.message===`kalamba:wrapper:${i}`&&(X("on",g.data.message.replace(/^kalamba:/,""),g.data.payload),t(g.data.payload),n!=null&&n.once&&window.removeEventListener("message",e))};window.addEventListener("message",o)}send(i,...[t]){m(this,C).postMessage({message:`kalamba:sdk:${i}`,payload:t},"*")}async openGame(i){const t=new Promise(o=>this.on("configured",o,{once:!0})),n=await this.request("openGame",i);if(n.type==="response")return await t,n.response;throw n.error.type==="timeout"?new D.TimeoutError:new D.RgsError(n.error.data)}async play(i,t,n="SPIN"){const o={contract:i,extra:t,actionType:n},e=await this.request("play",o);if(e.type==="response")return e.response;throw e.error.type==="timeout"?new D.TimeoutError:new D.RgsError(e.error.data)}}h=new WeakMap,d=new WeakMap,p=new WeakMap,C=new WeakMap;exports.RgsError=D.RgsError;exports.RgsErrorCode=D.RgsErrorCode;exports.TimeoutError=D.TimeoutError;exports.History=O;exports.I18n=H;exports.KalambaSdk=z;
|
package/dist/index.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export declare type CasinoOnlyMessagePayloadMap = {
|
|
|
55
55
|
export declare type ContractPlayPayload = {
|
|
56
56
|
[key: string]: any;
|
|
57
57
|
bet: Bet | null;
|
|
58
|
-
|
|
58
|
+
forcedOutcomes?: unknown;
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
export { CurrencyFormat }
|
|
@@ -83,13 +83,6 @@ export declare type DomainToMessagePayloadMap = {
|
|
|
83
83
|
telemetry: TelemetryOnlyMessagePayloadMap;
|
|
84
84
|
};
|
|
85
85
|
|
|
86
|
-
declare type Error_2 = {
|
|
87
|
-
message: string;
|
|
88
|
-
messageKey: string;
|
|
89
|
-
type: 'CLOSE' | 'RELOAD' | 'CONTINUE';
|
|
90
|
-
};
|
|
91
|
-
export { Error_2 as Error }
|
|
92
|
-
|
|
93
86
|
export { FormatCurrencyOptions }
|
|
94
87
|
|
|
95
88
|
export declare type ForwardToPluginsMessage<P extends PluginDomain> = keyof ForwardToPluginsMessageMap<'sdk'>[P] | keyof ForwardToPluginsMessageMap<'rgs'>[P] | keyof ForwardToPluginsMessageMap<'casino'>[P] | keyof ForwardToPluginsMessageMap<'telemetry'>[P];
|
|
@@ -169,36 +162,6 @@ export declare type MessageMessageEvent<M extends Message> = MessageEvent<{
|
|
|
169
162
|
|
|
170
163
|
export declare type MessagePayload<M extends Message> = MessageMap[M];
|
|
171
164
|
|
|
172
|
-
export declare class OpenGameError extends Error {
|
|
173
|
-
data: {
|
|
174
|
-
code: keyof typeof OpenGameErrorCode;
|
|
175
|
-
};
|
|
176
|
-
constructor(data: {
|
|
177
|
-
code: keyof typeof OpenGameErrorCode;
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
declare type OpenGameError_2 = {
|
|
182
|
-
type: 'timeout';
|
|
183
|
-
} | {
|
|
184
|
-
type: 'error';
|
|
185
|
-
data: {
|
|
186
|
-
code: keyof typeof OpenGameErrorCode;
|
|
187
|
-
};
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
export declare const OpenGameErrorCode: {
|
|
191
|
-
readonly CONNECTION_ERROR: "CONNECTION_ERROR";
|
|
192
|
-
readonly ALREADY_LOGGED_IN: "ALREADY_LOGGED_IN";
|
|
193
|
-
readonly DENIED: "DENIED";
|
|
194
|
-
readonly NOT_FOUND: "NOT_FOUND";
|
|
195
|
-
readonly BONUS_RESTRICTION: "BONUS_RESTRICTION";
|
|
196
|
-
readonly ERROR: "ERROR";
|
|
197
|
-
readonly GAME_UNAVAILABLE: "GAME_UNAVAILABLE";
|
|
198
|
-
readonly RECONNECT_DATA_MISMATCH: "RECONNECT_DATA_MISMATCH";
|
|
199
|
-
readonly TOO_MANY_OPEN_GAMES: "TOO_MANY_OPEN_GAMES";
|
|
200
|
-
};
|
|
201
|
-
|
|
202
165
|
export declare type OpenGameRequest = {
|
|
203
166
|
gameName: string;
|
|
204
167
|
/** version of game client */
|
|
@@ -252,34 +215,6 @@ export declare interface Pagination {
|
|
|
252
215
|
page: number;
|
|
253
216
|
}
|
|
254
217
|
|
|
255
|
-
export declare class PlayError extends Error {
|
|
256
|
-
data: {
|
|
257
|
-
code: keyof typeof PlayErrorCode;
|
|
258
|
-
};
|
|
259
|
-
constructor(data: {
|
|
260
|
-
code: keyof typeof PlayErrorCode;
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
declare type PlayError_2 = {
|
|
265
|
-
type: 'timeout';
|
|
266
|
-
} | {
|
|
267
|
-
type: 'error';
|
|
268
|
-
data: {
|
|
269
|
-
code: keyof typeof PlayErrorCode;
|
|
270
|
-
};
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
export declare const PlayErrorCode: {
|
|
274
|
-
readonly ERROR: "ERROR";
|
|
275
|
-
readonly GAMING_LIMITS_REACHED: "GAMING_LIMITS_REACHED";
|
|
276
|
-
readonly INVALID_CURRENCY: "INVALID_CURRENCY";
|
|
277
|
-
readonly INVALID_SESSION: "INVALID_SESSION";
|
|
278
|
-
readonly OUT_OF_MONEY: "OUT_OF_MONEY";
|
|
279
|
-
readonly UNFINISHED_ROUND_IN_PROGRESS: "UNFINISHED_ROUND_IN_PROGRESS";
|
|
280
|
-
readonly WALLET_ERROR: "WALLET_ERROR";
|
|
281
|
-
};
|
|
282
|
-
|
|
283
218
|
export declare type PlayRequest = {
|
|
284
219
|
contract: ContractPlayPayload;
|
|
285
220
|
extra?: unknown;
|
|
@@ -344,10 +279,61 @@ export declare type RealityCheckConfig = {
|
|
|
344
279
|
showSumWins: boolean;
|
|
345
280
|
};
|
|
346
281
|
|
|
282
|
+
export declare class RgsError extends Error {
|
|
283
|
+
data: RgsErrorData;
|
|
284
|
+
constructor(data: RgsErrorData);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
declare type RgsError_2 = {
|
|
288
|
+
type: 'timeout';
|
|
289
|
+
} | {
|
|
290
|
+
type: 'error';
|
|
291
|
+
data: RgsErrorData;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
export declare const RgsErrorCode: {
|
|
295
|
+
readonly CONNECTION_ERROR: "CONNECTION_ERROR";
|
|
296
|
+
readonly INVALID_BET_CURRENCY: "INVALID_BET_CURRENCY";
|
|
297
|
+
readonly INVALID_BET: "INVALID_BET";
|
|
298
|
+
readonly INVALID_CAGE_CODE: "INVALID_CAGE_CODE";
|
|
299
|
+
readonly INVALID_CLIENT_TYPE: "INVALID_CLIENT_TYPE";
|
|
300
|
+
readonly INVALID_MESSAGE_FORMAT: "INVALID_MESSAGE_FORMAT";
|
|
301
|
+
readonly INVALID_SESSION: "INVALID_SESSION";
|
|
302
|
+
readonly TOO_HIGH_BET_FREQUENCY: "TOO_HIGH_BET_FREQUENCY";
|
|
303
|
+
readonly TOO_HIGH_ACTION_FREQUENCY: "TOO_HIGH_ACTION_FREQUENCY";
|
|
304
|
+
readonly USER_LOCK_INVALID_PARAMS: "USER_LOCK_INVALID_PARAMS";
|
|
305
|
+
readonly USER_ALREADY_LOCKED: "USER_ALREADY_LOCKED";
|
|
306
|
+
readonly GAME_SERVER_ERROR: "GAME_SERVER_ERROR";
|
|
307
|
+
readonly SESSION_MANAGEMENT_ERROR: "SESSION_MANAGEMENT_ERROR";
|
|
308
|
+
readonly MESSAGE_SENDER_ERROR: "MESSAGE_SENDER_ERROR";
|
|
309
|
+
readonly FREE_ROUNDS_PROCESSING_ERROR: "FREE_ROUNDS_PROCESSING_ERROR";
|
|
310
|
+
readonly WEB_SESSION_NOT_OPEN: "WEB_SESSION_NOT_OPEN";
|
|
311
|
+
readonly GAMING_LIMITS_REACHED: "GAMING_LIMITS_REACHED";
|
|
312
|
+
readonly OUT_OF_MONEY: "OUT_OF_MONEY";
|
|
313
|
+
readonly UNFINISHED_ROUND_IN_PROGRESS: "UNFINISHED_ROUND_IN_PROGRESS";
|
|
314
|
+
readonly ACCESS_DENIED: "ACCESS_DENIED";
|
|
315
|
+
readonly CREDENTIALS_NOT_FOUND: "CREDENTIALS_NOT_FOUND";
|
|
316
|
+
readonly ALREADY_LOGGED_IN: "ALREADY_LOGGED_IN";
|
|
317
|
+
readonly GAME_UNAVAILABLE: "GAME_UNAVAILABLE";
|
|
318
|
+
readonly BONUS_RESTRICTION: "BONUS_RESTRICTION";
|
|
319
|
+
readonly TOO_MANY_OPEN_GAMES: "TOO_MANY_OPEN_GAMES";
|
|
320
|
+
readonly GAME_FROZEN: "GAME_FROZEN";
|
|
321
|
+
readonly WALLET_PROCESSING_ERROR: "WALLET_PROCESSING_ERROR";
|
|
322
|
+
readonly FORCED_OUTCOMES_NOT_ALLOWED: "FORCED_OUTCOMES_NOT_ALLOWED";
|
|
323
|
+
readonly MISSING_GAME_STATE: "MISSING_GAME_STATE";
|
|
324
|
+
readonly DATA_ACCESS_ERROR: "DATA_ACCESS_ERROR";
|
|
325
|
+
readonly UNKNOWN: "UNKNOWN";
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
export declare type RgsErrorData = {
|
|
329
|
+
code: keyof typeof RgsErrorCode;
|
|
330
|
+
details?: unknown;
|
|
331
|
+
};
|
|
332
|
+
|
|
347
333
|
export declare type RgsOnlyMessagePayloadMap = {
|
|
348
|
-
openGameError:
|
|
334
|
+
openGameError: RgsError_2;
|
|
349
335
|
openGameResponse: OpenGameResponse;
|
|
350
|
-
playError:
|
|
336
|
+
playError: RgsError_2;
|
|
351
337
|
playResponse: PlayResponse;
|
|
352
338
|
realityCheck: {
|
|
353
339
|
duration: number;
|
|
@@ -427,6 +413,15 @@ export declare interface SdkConfig {
|
|
|
427
413
|
};
|
|
428
414
|
}
|
|
429
415
|
|
|
416
|
+
export declare type SdkError = {
|
|
417
|
+
messageCode: string;
|
|
418
|
+
type: 'CLOSE' | 'RELOAD' | 'CONTINUE';
|
|
419
|
+
} & ({
|
|
420
|
+
message: string;
|
|
421
|
+
} | {
|
|
422
|
+
messageKey: string;
|
|
423
|
+
});
|
|
424
|
+
|
|
430
425
|
export declare type SdkOnlyMessagePayloadMap = {
|
|
431
426
|
autoplay: {
|
|
432
427
|
action: 'start' | 'stop' | 'pause' | 'resume';
|
|
@@ -444,7 +439,7 @@ export declare type SdkOnlyMessagePayloadMap = {
|
|
|
444
439
|
}[];
|
|
445
440
|
};
|
|
446
441
|
close: never;
|
|
447
|
-
error:
|
|
442
|
+
error: SdkError;
|
|
448
443
|
fullscreen: {
|
|
449
444
|
lock?: OrientationLockType;
|
|
450
445
|
};
|
|
@@ -463,6 +458,18 @@ export declare type SdkOnlyMessagePayloadMap = {
|
|
|
463
458
|
ready: boolean;
|
|
464
459
|
};
|
|
465
460
|
playStart: ContractPlayPayload;
|
|
461
|
+
/**
|
|
462
|
+
* ```typescript
|
|
463
|
+
* {
|
|
464
|
+
* en: {
|
|
465
|
+
* 'generic_error': 'Something went wrong',
|
|
466
|
+
* },
|
|
467
|
+
* pl: {
|
|
468
|
+
* 'generic_error': 'Coś poszło nie tak',
|
|
469
|
+
* }
|
|
470
|
+
* }
|
|
471
|
+
* ```
|
|
472
|
+
*/
|
|
466
473
|
translations: Record<string, Record<string, string>>;
|
|
467
474
|
settings: Settings;
|
|
468
475
|
'telemetry.click': {
|
package/dist/index.js
CHANGED
|
@@ -2,41 +2,41 @@
|
|
|
2
2
|
* BSD 3-Clause License
|
|
3
3
|
* Copyright (c) 2024, Kalamba Games Limited
|
|
4
4
|
*/
|
|
5
|
-
var
|
|
5
|
+
var N = (n, i, t) => {
|
|
6
6
|
if (!i.has(n))
|
|
7
7
|
throw TypeError("Cannot " + t);
|
|
8
8
|
};
|
|
9
|
-
var m = (n, i, t) => (
|
|
9
|
+
var m = (n, i, t) => (N(n, i, "read from private field"), t ? t.call(n) : i.get(n)), e = (n, i, t) => {
|
|
10
10
|
if (i.has(n))
|
|
11
11
|
throw TypeError("Cannot add the same private member more than once");
|
|
12
12
|
i instanceof WeakSet ? i.add(n) : i.set(n, t);
|
|
13
|
-
}, u = (n, i, t, r) => (
|
|
14
|
-
import { T as
|
|
15
|
-
import { a as
|
|
16
|
-
function
|
|
13
|
+
}, u = (n, i, t, r) => (N(n, i, "write to private field"), r ? r.call(n, t) : i.set(n, t), t);
|
|
14
|
+
import { T as b, R as E } from "./errors-867a013a.js";
|
|
15
|
+
import { a as ii } from "./errors-867a013a.js";
|
|
16
|
+
function A(n) {
|
|
17
17
|
const i = Object.prototype.toString.call(n);
|
|
18
18
|
return n instanceof Date || typeof n == "object" && i === "[object Date]" ? new n.constructor(+n) : typeof n == "number" || i === "[object Number]" || typeof n == "string" || i === "[object String]" ? new Date(n) : /* @__PURE__ */ new Date(NaN);
|
|
19
19
|
}
|
|
20
|
-
function
|
|
21
|
-
const i =
|
|
20
|
+
function U(n) {
|
|
21
|
+
const i = A(n);
|
|
22
22
|
return i.setHours(23, 59, 59, 999), i;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
return
|
|
24
|
+
function B() {
|
|
25
|
+
return U(Date.now());
|
|
26
26
|
}
|
|
27
27
|
function k(n) {
|
|
28
|
-
const i =
|
|
28
|
+
const i = A(n);
|
|
29
29
|
return i.setHours(0, 0, 0, 0), i;
|
|
30
30
|
}
|
|
31
31
|
function L() {
|
|
32
32
|
return k(Date.now());
|
|
33
33
|
}
|
|
34
|
-
const
|
|
34
|
+
const P = 3e4;
|
|
35
35
|
var D, x;
|
|
36
|
-
class
|
|
36
|
+
class $ {
|
|
37
37
|
constructor(i) {
|
|
38
38
|
e(this, D, void 0);
|
|
39
|
-
e(this, x,
|
|
39
|
+
e(this, x, P);
|
|
40
40
|
u(this, D, i);
|
|
41
41
|
}
|
|
42
42
|
buildHeaders() {
|
|
@@ -60,45 +60,45 @@ class G {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
D = new WeakMap(), x = new WeakMap();
|
|
63
|
-
const
|
|
63
|
+
const I = {
|
|
64
64
|
limit: 100,
|
|
65
65
|
page: 0
|
|
66
66
|
};
|
|
67
|
-
var
|
|
67
|
+
var s, y;
|
|
68
68
|
class _ {
|
|
69
69
|
constructor({
|
|
70
70
|
config: i
|
|
71
71
|
}) {
|
|
72
|
-
e(this,
|
|
73
|
-
e(this,
|
|
74
|
-
u(this,
|
|
72
|
+
e(this, s, void 0);
|
|
73
|
+
e(this, y, void 0);
|
|
74
|
+
u(this, s, i), u(this, y, new $({
|
|
75
75
|
apiUrl: i.api.gameHistoryUrl
|
|
76
76
|
}));
|
|
77
77
|
}
|
|
78
78
|
async getRound(i, {
|
|
79
|
-
pagination: t =
|
|
79
|
+
pagination: t = I
|
|
80
80
|
} = {}) {
|
|
81
|
-
return m(this,
|
|
82
|
-
gameCode: m(this,
|
|
83
|
-
operatorCode: m(this,
|
|
84
|
-
username: m(this,
|
|
81
|
+
return m(this, y).getRound(i, {
|
|
82
|
+
gameCode: m(this, s).api.game,
|
|
83
|
+
operatorCode: m(this, s).api.brand,
|
|
84
|
+
username: m(this, s).api.user,
|
|
85
85
|
...t
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
async getLastRound() {
|
|
89
|
-
return m(this,
|
|
89
|
+
return m(this, s).api.lastRoundId ? this.getRound(m(this, s).api.lastRoundId) : null;
|
|
90
90
|
}
|
|
91
91
|
async getRounds({
|
|
92
92
|
searchPeriod: i = {
|
|
93
93
|
fromDateTime: L(),
|
|
94
|
-
toDateTime:
|
|
94
|
+
toDateTime: B()
|
|
95
95
|
},
|
|
96
|
-
pagination: t =
|
|
96
|
+
pagination: t = I
|
|
97
97
|
} = {}) {
|
|
98
|
-
const r = m(this,
|
|
99
|
-
return m(this,
|
|
100
|
-
gameCode: m(this,
|
|
101
|
-
operatorCode: m(this,
|
|
98
|
+
const r = m(this, s).api.user.replace(/^user_/, "").replace(new RegExp(`_${m(this, s).api.integration}$`), "");
|
|
99
|
+
return m(this, y).getRounds({
|
|
100
|
+
gameCode: m(this, s).api.game,
|
|
101
|
+
operatorCode: m(this, s).api.integration,
|
|
102
102
|
username: r,
|
|
103
103
|
fromDataTime: i.fromDateTime.toISOString(),
|
|
104
104
|
toDateTime: i.toDateTime.toISOString(),
|
|
@@ -106,11 +106,11 @@ class _ {
|
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
|
|
110
|
-
function
|
|
109
|
+
s = new WeakMap(), y = new WeakMap();
|
|
110
|
+
function G(n, i) {
|
|
111
111
|
return n * i / 100;
|
|
112
112
|
}
|
|
113
|
-
function
|
|
113
|
+
function O(n, i, t) {
|
|
114
114
|
if (!["string", "number"].includes(typeof i))
|
|
115
115
|
return "NaN";
|
|
116
116
|
const { locales: r } = n;
|
|
@@ -127,7 +127,7 @@ function I(n, i, t) {
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
const w = "XTS";
|
|
130
|
-
var F = /* @__PURE__ */ ((n) => (n.Currency = "Currency", n.Number = "Number", n))(F || {}),
|
|
130
|
+
var F = /* @__PURE__ */ ((n) => (n.Currency = "Currency", n.Number = "Number", n))(F || {}), f = /* @__PURE__ */ ((n) => (n.Coins = "Coins", n.Money = "Money", n))(f || {});
|
|
131
131
|
const S = {
|
|
132
132
|
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
133
133
|
// ARSB is the internal currency relevant for invoicing purposes, players should see it as ARS
|
|
@@ -222,44 +222,44 @@ const S = {
|
|
|
222
222
|
FTN: { maximumFractionDigits: 4, minimumFractionDigits: 4 }
|
|
223
223
|
/* eslint-enable sort-keys-fix/sort-keys-fix */
|
|
224
224
|
};
|
|
225
|
-
function
|
|
225
|
+
function M(n) {
|
|
226
226
|
return n in S;
|
|
227
227
|
}
|
|
228
|
-
function
|
|
229
|
-
return
|
|
228
|
+
function j(n) {
|
|
229
|
+
return M(n) ? {
|
|
230
230
|
...S[n],
|
|
231
231
|
currency: w
|
|
232
232
|
} : {
|
|
233
233
|
currency: n
|
|
234
234
|
};
|
|
235
235
|
}
|
|
236
|
-
function
|
|
236
|
+
function q(n, i, t) {
|
|
237
237
|
const r = i.format(+n);
|
|
238
|
-
return
|
|
238
|
+
return M(t) ? r.replace(w, S[t].displayAs ?? t) : r;
|
|
239
239
|
}
|
|
240
|
-
function
|
|
240
|
+
function V(n, i, t) {
|
|
241
241
|
const { maximumFractionDigits: r, minimumFractionDigits: o } = t.resolvedOptions();
|
|
242
|
-
return
|
|
242
|
+
return O(n, i, { maximumFractionDigits: r, minimumFractionDigits: o });
|
|
243
243
|
}
|
|
244
|
-
function
|
|
244
|
+
function X(n, i, { as: t } = {
|
|
245
245
|
as: "Currency"
|
|
246
246
|
/* Currency */
|
|
247
247
|
}) {
|
|
248
248
|
const { canShowCurrency: r, currency: o } = n;
|
|
249
249
|
return t === "Number" || !r ? `${i}` : `${i} ${o}`;
|
|
250
250
|
}
|
|
251
|
-
function
|
|
251
|
+
function v(n, i, { as: t, from: r } = {
|
|
252
252
|
as: "Currency",
|
|
253
253
|
from: "Money"
|
|
254
254
|
/* Money */
|
|
255
255
|
}, o) {
|
|
256
256
|
if (!["string", "number"].includes(typeof i))
|
|
257
257
|
return "NaN";
|
|
258
|
-
const { canShowCurrency:
|
|
259
|
-
r === "Coins" && (i =
|
|
258
|
+
const { canShowCurrency: a = !0, coinValueInCents: g, currency: C, locales: T } = n;
|
|
259
|
+
r === "Coins" && (i = G(+i, g));
|
|
260
260
|
try {
|
|
261
|
-
const
|
|
262
|
-
...
|
|
261
|
+
const H = j(C), R = new Intl.NumberFormat(T, {
|
|
262
|
+
...H,
|
|
263
263
|
...o,
|
|
264
264
|
currencyDisplay: "symbol",
|
|
265
265
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -267,55 +267,55 @@ function z(n, i, { as: t, from: r } = {
|
|
|
267
267
|
numberingSystem: "latn",
|
|
268
268
|
style: "currency"
|
|
269
269
|
});
|
|
270
|
-
return t === "Number" || !
|
|
270
|
+
return t === "Number" || !a ? V(n, i, R) : q(i, R, C);
|
|
271
271
|
} catch {
|
|
272
|
-
return
|
|
272
|
+
return X(n, i, { as: t });
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
275
|
var c;
|
|
276
|
-
class
|
|
276
|
+
class z {
|
|
277
277
|
constructor({ config: i }) {
|
|
278
278
|
e(this, c, void 0);
|
|
279
279
|
u(this, c, i);
|
|
280
280
|
}
|
|
281
281
|
formatNumber(i, t) {
|
|
282
282
|
const r = { locales: [m(this, c).ui.language] };
|
|
283
|
-
return
|
|
283
|
+
return O(r, i, t);
|
|
284
284
|
}
|
|
285
|
-
formatCurrency(i, t = { as: F.Currency, from:
|
|
286
|
-
const o = m(this, c).ui.feature.showCurrency,
|
|
287
|
-
return
|
|
285
|
+
formatCurrency(i, t = { as: F.Currency, from: f.Money }, r) {
|
|
286
|
+
const o = m(this, c).ui.feature.showCurrency, a = m(this, c).api.coinValueInCents, g = m(this, c).api.currency || w, C = [m(this, c).ui.language];
|
|
287
|
+
return v({
|
|
288
288
|
canShowCurrency: o,
|
|
289
|
-
coinValueInCents:
|
|
289
|
+
coinValueInCents: a,
|
|
290
290
|
currency: g,
|
|
291
291
|
locales: C
|
|
292
292
|
}, i, t, r);
|
|
293
293
|
}
|
|
294
294
|
formatCoins(i, t) {
|
|
295
|
-
return this.formatCurrency(i, { as: F.Number, from:
|
|
295
|
+
return this.formatCurrency(i, { as: F.Number, from: f.Coins }, t);
|
|
296
296
|
}
|
|
297
297
|
formatCoinsWithCurrency(i, t) {
|
|
298
|
-
return this.formatCurrency(i, { as: F.Currency, from:
|
|
298
|
+
return this.formatCurrency(i, { as: F.Currency, from: f.Coins }, t);
|
|
299
299
|
}
|
|
300
300
|
formatMoney(i, t) {
|
|
301
|
-
return this.formatCurrency(i, { as: F.Number, from:
|
|
301
|
+
return this.formatCurrency(i, { as: F.Number, from: f.Money }, t);
|
|
302
302
|
}
|
|
303
303
|
formatMoneyWithCurrency(i, t) {
|
|
304
|
-
return this.formatCurrency(i, { as: F.Currency, from:
|
|
304
|
+
return this.formatCurrency(i, { as: F.Currency, from: f.Money }, t);
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
c = new WeakMap();
|
|
308
|
-
const
|
|
308
|
+
const K = () => {
|
|
309
309
|
};
|
|
310
310
|
var l, h, p, d;
|
|
311
|
-
class
|
|
311
|
+
class Y {
|
|
312
312
|
constructor({ messagePort: i }) {
|
|
313
313
|
e(this, l, void 0);
|
|
314
314
|
e(this, h, void 0);
|
|
315
315
|
e(this, p, void 0);
|
|
316
316
|
e(this, d, void 0);
|
|
317
317
|
u(this, d, i), this.on("configured", (t) => {
|
|
318
|
-
u(this, l, t), u(this, p, new
|
|
318
|
+
u(this, l, t), u(this, p, new z({ config: t })), u(this, h, new _({ config: t }));
|
|
319
319
|
}), this.on("playResponse", (t) => {
|
|
320
320
|
this.config.api.lastRoundId = t.contract.roundId;
|
|
321
321
|
});
|
|
@@ -343,8 +343,8 @@ class Q {
|
|
|
343
343
|
});
|
|
344
344
|
}
|
|
345
345
|
on(i, t, r) {
|
|
346
|
-
const o = function
|
|
347
|
-
g.data.message === `kalamba:wrapper:${i}` && (
|
|
346
|
+
const o = function a(g) {
|
|
347
|
+
g.data.message === `kalamba:wrapper:${i}` && (K("on", g.data.message.replace(/^kalamba:/, ""), g.data.payload), t(g.data.payload), r != null && r.once && window.removeEventListener("message", a));
|
|
348
348
|
};
|
|
349
349
|
window.addEventListener("message", o);
|
|
350
350
|
}
|
|
@@ -359,30 +359,24 @@ class Q {
|
|
|
359
359
|
);
|
|
360
360
|
}
|
|
361
361
|
async openGame(i) {
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
]);
|
|
367
|
-
if (t.type === "response")
|
|
368
|
-
return t.response;
|
|
369
|
-
throw t.error.type === "timeout" ? new E() : new H(t.error.data);
|
|
362
|
+
const t = new Promise((o) => this.on("configured", o, { once: !0 })), r = await this.request("openGame", i);
|
|
363
|
+
if (r.type === "response")
|
|
364
|
+
return await t, r.response;
|
|
365
|
+
throw r.error.type === "timeout" ? new b() : new E(r.error.data);
|
|
370
366
|
}
|
|
371
367
|
async play(i, t, r = "SPIN") {
|
|
372
|
-
const o = { contract: i, extra: t, actionType: r },
|
|
373
|
-
if (
|
|
374
|
-
return
|
|
375
|
-
throw
|
|
368
|
+
const o = { contract: i, extra: t, actionType: r }, a = await this.request("play", o);
|
|
369
|
+
if (a.type === "response")
|
|
370
|
+
return a.response;
|
|
371
|
+
throw a.error.type === "timeout" ? new b() : new E(a.error.data);
|
|
376
372
|
}
|
|
377
373
|
}
|
|
378
374
|
l = new WeakMap(), h = new WeakMap(), p = new WeakMap(), d = new WeakMap();
|
|
379
375
|
export {
|
|
380
376
|
_ as History,
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
ni as PlayErrorCode,
|
|
387
|
-
E as TimeoutError
|
|
377
|
+
z as I18n,
|
|
378
|
+
Y as KalambaSdk,
|
|
379
|
+
E as RgsError,
|
|
380
|
+
ii as RgsErrorCode,
|
|
381
|
+
b as TimeoutError
|
|
388
382
|
};
|