@kalamba/sdk 0.1.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.
@@ -0,0 +1,550 @@
1
+ declare type AutoplayLimit = {
2
+ enabled: boolean;
3
+ showNoLimit: boolean;
4
+ showCustomLimit: boolean;
5
+ options: number[];
6
+ };
7
+
8
+ export declare class BasicPlugin extends CasinoPlugin {
9
+ constructor(...args: ConstructorParameters<typeof CasinoPlugin>);
10
+ registerToSdkEvents(): void;
11
+ registerFromSdkEvents(): void;
12
+ }
13
+
14
+ declare type Bet = {
15
+ base: number;
16
+ multiplier: number;
17
+ };
18
+
19
+ declare type Cashier = {
20
+ type: 'ON_DEMAND' | 'BALANCE_LOW' | 'BALANCE_INSUFFICIENT';
21
+ };
22
+
23
+ declare type CashierConfig = {
24
+ enabled: boolean;
25
+ balanceThreshold: number[];
26
+ };
27
+
28
+ declare type CasinoOnlyMessagePayloadMap = {
29
+ balance: {
30
+ balance: number;
31
+ };
32
+ bet: Bet;
33
+ cashier: Cashier;
34
+ choice: {
35
+ id: string;
36
+ };
37
+ close: never;
38
+ freeze: never;
39
+ help: {
40
+ show?: boolean;
41
+ };
42
+ history: History_2;
43
+ paytable: {
44
+ show?: boolean;
45
+ };
46
+ play: PlayRequest;
47
+ resume: never;
48
+ settings: Settings;
49
+ suspend: never;
50
+ unfreeze: never;
51
+ };
52
+
53
+ export declare abstract class CasinoPlugin {
54
+ config: SdkConfig;
55
+ constructor(config: SdkConfig);
56
+ protected on<M extends DomainMessage<'wrapper'> | ForwardToPluginsMessage<'casino'>>(message: M, listener: (payload: M extends DomainMessage<'wrapper'> ? DomainMessagePayload<'wrapper', M> : M extends ForwardToPluginsMessage<'casino'> ? ForwardToPluginsMessagePayload<'casino', M> : never) => void, options?: AddEventListenerOptions): void;
57
+ protected send<M extends DomainMessage<'casino'>>(message: M, ...[payload]: DomainMessagePayload<'casino', M> extends never ? [] : [payload: DomainMessagePayload<'casino', M>]): void;
58
+ }
59
+
60
+ export declare class DebuggingPlugin extends CasinoPlugin {
61
+ constructor(...args: ConstructorParameters<typeof CasinoPlugin>);
62
+ registerDebugToSdkEvents(): void;
63
+ registerSdkToDebugEvents(): void;
64
+ _send(...args: Parameters<typeof DebuggingPlugin.prototype.send>): ReturnType<typeof DebuggingPlugin.prototype.send>;
65
+ }
66
+
67
+ declare type DomainAllowedPayloadMap<P extends DomainPrefix> = DomainToMessagePayloadMap[P];
68
+
69
+ declare type DomainMessage<P extends DomainPrefix> = keyof DomainAllowedPayloadMap<P>;
70
+
71
+ declare type DomainMessagePayload<P extends DomainPrefix, M extends DomainMessage<P>> = DomainAllowedPayloadMap<P>[M];
72
+
73
+ declare type DomainPrefix = keyof DomainToMessagePayloadMap & string;
74
+
75
+ declare type DomainToMessagePayloadMap = {
76
+ sdk: SdkOnlyMessagePayloadMap;
77
+ wrapper: WrapperOnlyMessagePayloadMap;
78
+ casino: CasinoOnlyMessagePayloadMap;
79
+ rgs: RgsOnlyMessagePayloadMap;
80
+ telemetry: TelemetryOnlyMessagePayloadMap;
81
+ };
82
+
83
+ declare type Error_2 = {
84
+ message: string;
85
+ messageKey: string;
86
+ type: 'CLOSE' | 'RELOAD' | 'CONTINUE';
87
+ };
88
+
89
+ declare type ForwardToPluginsMessage<P extends PluginDomain> = keyof ForwardToPluginsMessageMap<'sdk'>[P] | keyof ForwardToPluginsMessageMap<'rgs'>[P] | keyof ForwardToPluginsMessageMap<'casino'>[P] | keyof ForwardToPluginsMessageMap<'telemetry'>[P];
90
+
91
+ declare interface ForwardToPluginsMessageMap<SourceDomain extends DomainPrefix> {
92
+ casino: ToCasinoPluginsForwardedMessageMap[SourceDomain];
93
+ rgs: ToRgsPluginsForwardedMessageMap[SourceDomain];
94
+ telemetry: ToTelemetryPluginsForwardedMessageMap[SourceDomain];
95
+ }
96
+
97
+ declare type ForwardToPluginsMessagePayload<P extends PluginDomain, M extends ForwardToPluginsMessage<P>> = ForwardToPluginsMessageMap<'sdk'>[P][M] & ForwardToPluginsMessageMap<'rgs'>[P][M] & ForwardToPluginsMessageMap<'casino'>[P][M] & ForwardToPluginsMessageMap<'telemetry'>[P][M];
98
+
99
+ declare type GameEventName = 'BG_RESULT' | 'OPEN_GAME' | 'SPIN_ERROR' | 'SPIN_RESULT';
100
+
101
+ export declare class GigPlugin extends CasinoPlugin {
102
+ constructor(...args: ConstructorParameters<typeof CasinoPlugin>);
103
+ postMessage(event: unknown): void;
104
+ registerToSdkEvents(): void;
105
+ registerFromSdkEvents(): void;
106
+ }
107
+
108
+ declare type History_2 = {
109
+ source: 'realityCheck' | 'settings' | 'casino';
110
+ };
111
+
112
+ export declare class KalambaBullseyePlugin extends RgsPlygin {
113
+ #private;
114
+ socket: KalambaWebSocketClient;
115
+ constructor(...args: ConstructorParameters<typeof RgsPlygin>);
116
+ initialize(init: KalambaWebSocketClientInit): void;
117
+ reconnect(init: KalambaWebSocketClientInit): Promise<void>;
118
+ openGame(): Promise<{
119
+ balance: number;
120
+ balanceVersion: number;
121
+ correlationSeqId: number;
122
+ data: unknown;
123
+ event: "OPEN_GAME";
124
+ } & {
125
+ correlationSeqId?: number | undefined;
126
+ event: "BG_RESULT" | "OPEN_GAME" | "SPIN_ERROR" | "SPIN_RESULT";
127
+ seqId: number;
128
+ }>;
129
+ play(payload: PlayRequest): any;
130
+ registerFromSdkEvents(): void;
131
+ }
132
+
133
+ export declare class KalambaStargazerPlugin extends TelemetryPlugin {
134
+ #private;
135
+ FPS_SAMPLE_INTERVAL: number;
136
+ constructor(...args: ConstructorParameters<typeof TelemetryPlugin>);
137
+ registerEvents(): Promise<void>;
138
+ reportFpsSample(): void;
139
+ reportFpsRound(): void;
140
+ getExtraUiInteractionData(): {
141
+ orientation: string;
142
+ stateType: string;
143
+ };
144
+ deviceInfo(): Promise<Record<string, unknown>>;
145
+ }
146
+
147
+ export declare class KalambaStargazerTracker extends Tracker {
148
+ #private;
149
+ processQueueForced: OmitFirstParam<typeof KalambaStargazerTracker.processQueue>;
150
+ constructor(...args: ConstructorParameters<typeof Tracker>);
151
+ subscribe(): void;
152
+ schedule(): void;
153
+ send(payload: Record<string, unknown>[]): void;
154
+ addToQueue(payload: Record<string, unknown>): void;
155
+ processQueue(forced?: boolean): void;
156
+ track(eventName: unknown, eventParams: Record<string, unknown>): void;
157
+ }
158
+
159
+ declare class KalambaWebSocketClient extends WebSocketClient {
160
+ #private;
161
+ cId: number;
162
+ mId: number;
163
+ seqId: number;
164
+ gameCode: string;
165
+ eventListeners: KalambaWebSocketClientEventListeners;
166
+ constructor(init: KalambaWebSocketClientInit, options: KalambaWebSocketClientOptions);
167
+ private handleRealityCheck;
168
+ addEventListener<K extends keyof KalambaWebSocketClientEventMap>(type: K, listener: KalambaWebSocketClientEventListener<K>): void;
169
+ removeEventListener<K extends keyof KalambaWebSocketClientEventMap>(type: K, listener: KalambaWebSocketClientEventListener<K>): void;
170
+ onMessage: (event: any) => void;
171
+ private buildHeader;
172
+ private buildPayload;
173
+ private getBodyExtras;
174
+ private request;
175
+ activateFreeRound(body: any): Promise<WebSocketResponse<any, Record<string, unknown>, unknown>>;
176
+ authenticate(reconnect?: boolean): Promise<{
177
+ balance: number;
178
+ balanceVersion: number;
179
+ coinValueInCents: number;
180
+ countryCode: string;
181
+ currencyCode: string;
182
+ jurisdictionCode: string;
183
+ uiMessages: unknown[];
184
+ username: string;
185
+ }>;
186
+ openGame(): Promise<{
187
+ balance: number;
188
+ balanceVersion: number;
189
+ correlationSeqId: number;
190
+ data: unknown;
191
+ event: "OPEN_GAME";
192
+ } & {
193
+ correlationSeqId?: number | undefined;
194
+ event: GameEventName;
195
+ seqId: number;
196
+ }>;
197
+ private sendAcknowledgement;
198
+ private sendAction;
199
+ spin(payload: any): Promise<unknown>;
200
+ bgAction(payload: any): Promise<unknown>;
201
+ setRequestTimeoutMs(ms: number): void;
202
+ }
203
+
204
+ declare type KalambaWebSocketClientEventListener<K extends keyof KalambaWebSocketClientEventMap> = (ev: KalambaWebSocketClientEventMap[K]) => any;
205
+
206
+ declare type KalambaWebSocketClientEventListeners = {
207
+ [K in keyof KalambaWebSocketClientEventMap]: KalambaWebSocketClientEventListener<K>[];
208
+ };
209
+
210
+ declare type KalambaWebSocketClientEventMap = WebSocketClientEventMap & {
211
+ realityCheck: RealityCheck['body'];
212
+ };
213
+
214
+ declare interface KalambaWebSocketClientInit {
215
+ apiUrl: string;
216
+ cageCode: string;
217
+ gameCode: string;
218
+ operatorCode: string;
219
+ playMode: string;
220
+ token: string;
221
+ username: string;
222
+ }
223
+
224
+ declare interface KalambaWebSocketClientOptions {
225
+ gameVersion: string;
226
+ requestTimeoutMs: number;
227
+ }
228
+
229
+ export declare class LoggingTracker extends Tracker {
230
+ track(event: unknown, data: Record<string, unknown>): void;
231
+ }
232
+
233
+ declare type OmitFirstParam<T extends (...args: any[]) => any> = T extends (arg: any, ...rest: infer R) => infer Result ? (...args: R) => Result : never;
234
+
235
+ declare type OpenGameError = {
236
+ data: any;
237
+ type?: string;
238
+ };
239
+
240
+ declare type OpenGameRequest = {
241
+ gameName: string;
242
+ version: string;
243
+ };
244
+
245
+ declare type OpenGameResponse = {
246
+ balance: number;
247
+ data: any;
248
+ };
249
+
250
+ export declare class OryxPlugin extends CasinoPlugin {
251
+ constructor(...args: ConstructorParameters<typeof CasinoPlugin>);
252
+ registerToSdkEvents(): void;
253
+ registerFromSdkEvents(): void;
254
+ }
255
+
256
+ export declare class PariplayPlugin extends CasinoPlugin {
257
+ constructor(...args: ConstructorParameters<typeof CasinoPlugin>);
258
+ postMessage(type: string, data?: unknown): void;
259
+ coinsToCurrency(coins: number): number;
260
+ handleContinueButton(button: any, next: any): void;
261
+ handleLinkButton(button: any, next: any): void;
262
+ handleQuitButton(button: any, next: any): void;
263
+ handleCashierButton(button: any, next: any): void;
264
+ handleHistoryButton(button: any, next: any): void;
265
+ get buttonActions(): any;
266
+ processInfoUiMessages(uiMessages: any[]): any;
267
+ registerToSdkEvents(): void;
268
+ registerFromSdkEvents(): void;
269
+ }
270
+
271
+ declare type PlayError = {
272
+ data: any;
273
+ type?: string;
274
+ };
275
+
276
+ declare type PlayRequest = {
277
+ bet: Bet;
278
+ } | {
279
+ userInput: unknown;
280
+ } | {
281
+ opaqueGameAttributes: unknown;
282
+ };
283
+
284
+ declare type PlayResponse = {
285
+ balance: number;
286
+ data: any;
287
+ };
288
+
289
+ declare type PluginDomain = keyof ForwardToPluginsMessageMap<any>;
290
+
291
+ declare type RealityCheck = WebSocketResponse<'RealityCheck', Record<string, unknown>, {
292
+ duration: number;
293
+ sumBetAmount: number;
294
+ sumWinAmount: number;
295
+ }>;
296
+
297
+ declare type RealityCheckConfig = {
298
+ sessionDurationPeriodFormat: 'seconds' | 'minutes' | 'hours';
299
+ showCloseGame: boolean;
300
+ showHistory: boolean;
301
+ showNetPosition: boolean;
302
+ showSessionDuration: boolean;
303
+ showSumBets: boolean;
304
+ showSumWins: boolean;
305
+ };
306
+
307
+ export declare class RelaxFEIMPlugin extends CasinoPlugin {
308
+ VERSION: string;
309
+ constructor(...args: ConstructorParameters<typeof CasinoPlugin>);
310
+ registerToSdkEvents(): void;
311
+ registerFromSdkEvents(): void;
312
+ }
313
+
314
+ declare type ResponseMessageName = 'Authenticate' | 'GameAction' | 'GameEvent' | 'OpenGame' | 'Ping' | 'RealityCheck';
315
+
316
+ declare type RgsOnlyMessagePayloadMap = {
317
+ openGameError: OpenGameError;
318
+ openGameResponse: OpenGameResponse;
319
+ playError: PlayError;
320
+ playResponse: PlayResponse;
321
+ realityCheck: {
322
+ duration: number;
323
+ sumBetAmount: number;
324
+ sumWinAmount: number;
325
+ };
326
+ };
327
+
328
+ export declare abstract class RgsPlygin {
329
+ config: SdkConfig;
330
+ constructor(config: SdkConfig);
331
+ protected on<M extends DomainMessage<'wrapper'> | ForwardToPluginsMessage<'rgs'>>(message: M, listener: (payload: M extends DomainMessage<'wrapper'> ? DomainMessagePayload<'wrapper', M> : M extends ForwardToPluginsMessage<'rgs'> ? ForwardToPluginsMessagePayload<'rgs', M> : never) => void, options?: AddEventListenerOptions): void;
332
+ protected send<M extends DomainMessage<'rgs'>>(message: M, ...[payload]: DomainMessagePayload<'rgs', M> extends never ? [] : [payload: DomainMessagePayload<'rgs', M>]): void;
333
+ }
334
+
335
+ declare interface SdkConfig {
336
+ api: {
337
+ brand: string;
338
+ cashierUrl?: string;
339
+ coinValueInCents: number;
340
+ country: string;
341
+ currency: string;
342
+ game: string;
343
+ gameHistoryUrl: string;
344
+ homeUrl?: string;
345
+ integration: string;
346
+ integrationData?: unknown;
347
+ jurisdiction: string;
348
+ playMode: 'FUN' | 'REAL';
349
+ user: string;
350
+ };
351
+ ui: {
352
+ autoplay: {
353
+ enabled: boolean;
354
+ rounds: AutoplayLimit;
355
+ lossLimit: AutoplayLimit;
356
+ winLimit: AutoplayLimit;
357
+ simple: boolean;
358
+ stopOnFeature: boolean;
359
+ };
360
+ cashier: CashierConfig;
361
+ feature: {
362
+ allowTelemetry: boolean;
363
+ allowFullscreen: boolean;
364
+ allowQuickStop: boolean;
365
+ showCashier: boolean;
366
+ showClock: boolean;
367
+ showCloseGame: boolean;
368
+ showCurrency: boolean;
369
+ showFastPlay: boolean;
370
+ showFeatureBuy: boolean;
371
+ showFeatureIntro: boolean;
372
+ showFeatureOutro: boolean;
373
+ showFunModeBanner: boolean;
374
+ showHistory: boolean;
375
+ showLowWinCelebration: boolean;
376
+ showMaximumWin: boolean;
377
+ showNetPosition: boolean;
378
+ showPaylineLines: boolean;
379
+ showPaytable: boolean;
380
+ showRoundId: boolean;
381
+ showRtp: boolean;
382
+ showRules: boolean;
383
+ showSessionDuration: boolean;
384
+ showUi: boolean;
385
+ };
386
+ language: string;
387
+ maximumBet?: number;
388
+ minimumSpinDuration: number;
389
+ requestTimeoutMs: number;
390
+ realityCheck: RealityCheckConfig;
391
+ skipInsufficientFundsCheck: boolean;
392
+ skipSplash: boolean;
393
+ };
394
+ }
395
+
396
+ declare type SdkOnlyMessagePayloadMap = {
397
+ autoplay: {
398
+ action: 'start' | 'stop' | 'pause' | 'resume';
399
+ };
400
+ balance: {
401
+ balance: number;
402
+ };
403
+ bet: Bet;
404
+ cashier: Cashier;
405
+ choice: {
406
+ message: string;
407
+ options: {
408
+ id: string;
409
+ label: string;
410
+ }[];
411
+ };
412
+ close: never;
413
+ error: Error_2;
414
+ fullscreen: {
415
+ lock?: OrientationLockType;
416
+ };
417
+ history: History_2;
418
+ loadEnd: never;
419
+ loadProgress: {
420
+ progress: number;
421
+ };
422
+ loadStart: never;
423
+ openGame: OpenGameRequest;
424
+ play: PlayRequest;
425
+ playCycleEnd: PlayResponse;
426
+ playCycleStart: PlayRequest;
427
+ playEnd: PlayResponse;
428
+ playReady: {
429
+ ready: boolean;
430
+ };
431
+ playStart: PlayRequest;
432
+ translations: Record<string, Record<string, string>>;
433
+ settings: Settings;
434
+ 'telemetry.click': {
435
+ location: string;
436
+ name: string;
437
+ };
438
+ 'telemetry.orientationChange': never;
439
+ };
440
+
441
+ declare type Settings = {
442
+ fastPlay?: boolean;
443
+ fastPlaySpeed?: number;
444
+ sounds?: boolean;
445
+ music?: boolean;
446
+ };
447
+
448
+ declare type TelemetryOnlyMessagePayloadMap = {
449
+ [key: string]: unknown;
450
+ };
451
+
452
+ export declare abstract class TelemetryPlugin {
453
+ trackers: Tracker[];
454
+ config: SdkConfig;
455
+ constructor(trackers: Tracker[], config: SdkConfig);
456
+ protected on<M extends DomainMessage<'wrapper'> | ForwardToPluginsMessage<'telemetry'>>(message: M, listener: (payload: M extends DomainMessage<'wrapper'> ? DomainMessagePayload<'wrapper', M> : M extends ForwardToPluginsMessage<'telemetry'> ? ForwardToPluginsMessagePayload<'telemetry', M> : never) => void, options?: AddEventListenerOptions): void;
457
+ protected track(event: unknown, data: Record<string, unknown>): void;
458
+ }
459
+
460
+ declare type ToCasinoPluginsForwardedMessageMap = {
461
+ sdk: Pick<SdkOnlyMessagePayloadMap, 'autoplay' | 'balance' | 'bet' | 'cashier' | 'choice' | 'close' | 'error' | 'history' | 'loadEnd' | 'loadProgress' | 'loadStart' | 'openGame' | 'play' | 'playCycleEnd' | 'playCycleStart' | 'playEnd' | 'playReady' | 'playStart' | 'settings'>;
462
+ casino: undefined;
463
+ rgs: Pick<RgsOnlyMessagePayloadMap, 'playResponse' | 'playError' | 'openGameResponse'>;
464
+ telemetry: undefined;
465
+ wrapper: undefined;
466
+ };
467
+
468
+ declare type ToRgsPluginsForwardedMessageMap = {
469
+ sdk: Pick<SdkOnlyMessagePayloadMap, 'history' | 'openGame' | 'play'>;
470
+ casino: Pick<CasinoOnlyMessagePayloadMap, 'play' | 'cashier' | 'close' | 'history'>;
471
+ rgs: undefined;
472
+ telemetry: undefined;
473
+ wrapper: undefined;
474
+ };
475
+
476
+ declare type ToTelemetryPluginsForwardedMessageMap = {
477
+ sdk: Pick<SdkOnlyMessagePayloadMap, 'autoplay' | 'error' | 'loadStart' | 'loadProgress' | 'loadEnd' | 'playCycleStart' | 'playCycleEnd' | 'settings' | 'telemetry.click' | 'telemetry.orientationChange'>;
478
+ casino: undefined;
479
+ rgs: Pick<RgsOnlyMessagePayloadMap, 'openGameResponse' | 'openGameError' | 'playResponse' | 'playError'>;
480
+ telemetry: undefined;
481
+ wrapper: undefined;
482
+ };
483
+
484
+ export declare abstract class Tracker {
485
+ config: SdkConfig;
486
+ constructor(config: SdkConfig);
487
+ abstract track(event: unknown, data: Record<string, unknown>): void;
488
+ }
489
+
490
+ export declare class TukoPlugin extends CasinoPlugin {
491
+ PING_INTERVAL: number;
492
+ constructor(...args: ConstructorParameters<typeof CasinoPlugin>);
493
+ ping(url: string): void;
494
+ registerToSdkEvents(): void;
495
+ registerFromSdkEvents(): void;
496
+ }
497
+
498
+ declare class WebSocketClient {
499
+ socket: WebSocket | null;
500
+ webSocketUrl: string;
501
+ eventListeners: WebSocketClientEventListeners;
502
+ constructor(webSocketUrl: string);
503
+ connect: () => Promise<unknown>;
504
+ send: (payload: any) => void;
505
+ close: () => void;
506
+ addEventListener<K extends keyof WebSocketClientEventMap>(type: K, listener: WebSocketClientEventListener<K>): void;
507
+ removeEventListener<K extends keyof WebSocketClientEventMap>(type: K, listener: WebSocketClientEventListener<K>): void;
508
+ handleClose: (event: WebSocketEventMap['close']) => void;
509
+ handleError: (event: WebSocketEventMap['error']) => void;
510
+ handleMessage: (event: WebSocketEventMap['message']) => void;
511
+ handleOpen: (event: WebSocketEventMap['open']) => void;
512
+ }
513
+
514
+ declare type WebSocketClientEventListener<K extends keyof WebSocketClientEventMap> = (ev: WebSocketClientEventMap[K]) => any;
515
+
516
+ declare type WebSocketClientEventListeners = {
517
+ [K in keyof WebSocketClientEventMap]: WebSocketClientEventListener<K>[];
518
+ };
519
+
520
+ declare type WebSocketClientEventMap = Pick<WebSocketEventMap, 'close' | 'error' | 'message'>;
521
+
522
+ declare interface WebSocketResponse<Name extends ResponseMessageName, Header = Record<string, unknown>, Body = unknown> {
523
+ body: Body;
524
+ header: Header & {
525
+ cId: number;
526
+ mId: number;
527
+ name: Name;
528
+ };
529
+ }
530
+
531
+ declare type WrapperOnlyMessagePayloadMap = {
532
+ bet: Bet;
533
+ close: never;
534
+ configured: SdkConfig;
535
+ freeze: never;
536
+ history: History_2;
537
+ resume: never;
538
+ state: WrapperState;
539
+ suspend: never;
540
+ unfreeze: never;
541
+ };
542
+
543
+ declare type WrapperState = {
544
+ balance: number;
545
+ bet: Bet;
546
+ gameName: string;
547
+ version: string;
548
+ };
549
+
550
+ export { }