@kalamba/sdk 0.5.0 → 0.6.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.
@@ -0,0 +1,5 @@
1
+ /**
2
+ * BSD 3-Clause License
3
+ * Copyright (c) 2024, Kalamba Games Limited
4
+ */
5
+ "use strict";var R=Object.defineProperty;var _=(N,E,r)=>E in N?R(N,E,{enumerable:!0,configurable:!0,writable:!0,value:r}):N[E]=r;var O=(N,E,r)=>(_(N,typeof E!="symbol"?E+"":E,r),r);const I={CONNECTION_ERROR:"CONNECTION_ERROR",ALREADY_LOGGED_IN:"ALREADY_LOGGED_IN",DENIED:"DENIED",NOT_FOUND:"NOT_FOUND",BONUS_RESTRICTION:"BONUS_RESTRICTION",ERROR:"ERROR",GAME_UNAVAILABLE:"GAME_UNAVAILABLE",RECONNECT_DATA_MISMATCH:"RECONNECT_DATA_MISMATCH",TOO_MANY_OPEN_GAMES:"TOO_MANY_OPEN_GAMES"},A={ERROR:"ERROR",GAMING_LIMITS_REACHED:"GAMING_LIMITS_REACHED",INVALID_CURRENCY:"INVALID_CURRENCY",INVALID_SESSION:"INVALID_SESSION",OUT_OF_MONEY:"OUT_OF_MONEY",UNFINISHED_ROUND_IN_PROGRESS:"UNFINISHED_ROUND_IN_PROGRESS",WALLET_ERROR:"WALLET_ERROR"};class o extends Error{constructor(r){super();O(this,"data");this.name="OpenGameError",this.data=r}}class e extends Error{constructor(r){super();O(this,"data");this.name="PlayError",this.data=r}}class t extends Error{constructor(){super(),this.name="TimeoutError"}}exports.OpenGameError=o;exports.OpenGameErrorCode=I;exports.PlayError=e;exports.PlayErrorCode=A;exports.TimeoutError=t;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * BSD 3-Clause License
3
+ * Copyright (c) 2024, Kalamba Games Limited
4
+ */
5
+ var r = Object.defineProperty;
6
+ var _ = (O, E, N) => E in O ? r(O, E, { enumerable: !0, configurable: !0, writable: !0, value: N }) : O[E] = N;
7
+ var R = (O, E, N) => (_(O, typeof E != "symbol" ? E + "" : E, N), N);
8
+ const A = {
9
+ CONNECTION_ERROR: "CONNECTION_ERROR",
10
+ ALREADY_LOGGED_IN: "ALREADY_LOGGED_IN",
11
+ DENIED: "DENIED",
12
+ NOT_FOUND: "NOT_FOUND",
13
+ BONUS_RESTRICTION: "BONUS_RESTRICTION",
14
+ ERROR: "ERROR",
15
+ GAME_UNAVAILABLE: "GAME_UNAVAILABLE",
16
+ RECONNECT_DATA_MISMATCH: "RECONNECT_DATA_MISMATCH",
17
+ TOO_MANY_OPEN_GAMES: "TOO_MANY_OPEN_GAMES"
18
+ }, s = {
19
+ ERROR: "ERROR",
20
+ GAMING_LIMITS_REACHED: "GAMING_LIMITS_REACHED",
21
+ INVALID_CURRENCY: "INVALID_CURRENCY",
22
+ INVALID_SESSION: "INVALID_SESSION",
23
+ OUT_OF_MONEY: "OUT_OF_MONEY",
24
+ UNFINISHED_ROUND_IN_PROGRESS: "UNFINISHED_ROUND_IN_PROGRESS",
25
+ WALLET_ERROR: "WALLET_ERROR"
26
+ };
27
+ class a extends Error {
28
+ constructor(N) {
29
+ super();
30
+ R(this, "data");
31
+ this.name = "OpenGameError", this.data = N;
32
+ }
33
+ }
34
+ class T extends Error {
35
+ constructor(N) {
36
+ super();
37
+ R(this, "data");
38
+ this.name = "PlayError", this.data = N;
39
+ }
40
+ }
41
+ class o extends Error {
42
+ constructor() {
43
+ super(), this.name = "TimeoutError";
44
+ }
45
+ }
46
+ export {
47
+ a as O,
48
+ T as P,
49
+ o as T,
50
+ A as a,
51
+ s as b
52
+ };
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 G=Object.defineProperty;var L=(r,i,t)=>i in r?G(r,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[i]=t;var S=(r,i,t)=>(L(r,typeof i!="symbol"?i+"":i,t),t),R=(r,i,t)=>{if(!i.has(r))throw TypeError("Cannot "+t)};var m=(r,i,t)=>(R(r,i,"read from private field"),t?t.call(r):i.get(r)),u=(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)},c=(r,i,t,n)=>(R(r,i,"write to private field"),n?n.call(r,t):i.set(r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});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 $(r){const i=I(r);return i.setHours(23,59,59,999),i}function _(){return $(Date.now())}function j(r){const i=I(r);return i.setHours(0,0,0,0),i}function q(){return j(Date.now())}const V=3e4;var D,x;class v{constructor(i){u(this,D,void 0);u(this,x,V);c(this,D,i)}buildHeaders(){const i={};return m(this,D).token&&(i.Authorization=`Bearer ${m(this,D).token}`),i}async request(i,t){const n=new URL(i,m(this,D).apiUrl??window.location.origin);return n.search=new URLSearchParams({...t}).toString(),await(await fetch(n,{signal:AbortSignal.timeout(m(this,x)),headers:this.buildHeaders()})).json()}async getRounds(i){return this.request("/rounds",i)}async getRound(i,t){return this.request(`/rounds/${i}`,t)}}D=new WeakMap,x=new WeakMap;const O={limit:100,page:0};var e,l;class A{constructor({config:i}){u(this,e,void 0);u(this,l,void 0);c(this,e,i),c(this,l,new v({apiUrl:i.api.gameHistoryUrl}))}async getRound(i,{pagination:t=O}={}){return m(this,l).getRound(i,{gameCode:m(this,e).api.game,operatorCode:m(this,e).api.brand,username:m(this,e).api.user,...t})}async getLastRound(){return m(this,e).api.lastRoundId?this.getRound(m(this,e).api.lastRoundId):null}async getRounds({searchPeriod:i={fromDateTime:q(),toDateTime:_()},pagination:t=O}={}){const n=m(this,e).api.user.replace(/^user_/,"").replace(new RegExp(`_${m(this,e).api.integration}$`),"");return m(this,l).getRounds({gameCode:m(this,e).api.game,operatorCode:m(this,e).api.integration,username:n,fromDataTime:i.fromDateTime.toISOString(),toDateTime:i.toDateTime.toISOString(),...t})}}e=new WeakMap,l=new WeakMap;function K(r,i){return r*i/100}function M(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 T="XTS";var F=(r=>(r.Currency="Currency",r.Number="Number",r))(F||{}),y=(r=>(r.Coins="Coins",r.Money="Money",r))(y||{});const E={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 H(r){return r in E}function X(r){return H(r)?{...E[r],currency:T}:{currency:r}}function z(r,i,t){const n=i.format(+r);return H(t)?n.replace(T,E[t].displayAs??t):n}function W(r,i,t){const{maximumFractionDigits:n,minimumFractionDigits:o}=t.resolvedOptions();return M(r,i,{maximumFractionDigits:n,minimumFractionDigits:o})}function J(r,i,{as:t}={as:"Currency"}){const{canShowCurrency:n,currency:o}=r;return t==="Number"||!n?`${i}`:`${i} ${o}`}function Y(r,i,{as:t,from:n}={as:"Currency",from:"Money"},o){if(!["string","number"].includes(typeof i))return"NaN";const{canShowCurrency:s=!0,coinValueInCents:a,currency:C,locales:b}=r;n==="Coins"&&(i=K(+i,a));try{const k=X(C),N=new Intl.NumberFormat(b,{...k,...o,currencyDisplay:"symbol",numberingSystem:"latn",style:"currency"});return t==="Number"||!s?W(r,i,N):z(i,N,C)}catch{return J(r,i,{as:t})}}var g;class P{constructor({config:i}){u(this,g,void 0);c(this,g,i)}formatNumber(i,t){const n={locales:[m(this,g).ui.language]};return M(n,i,t)}formatCurrency(i,t={as:F.Currency,from:y.Money},n){const o=m(this,g).ui.feature.showCurrency,s=m(this,g).api.coinValueInCents,a=m(this,g).api.currency||T,C=[m(this,g).ui.language];return Y({canShowCurrency:o,coinValueInCents:s,currency:a,locales:C},i,t,n)}formatCoins(i,t){return this.formatCurrency(i,{as:F.Number,from:y.Coins},t)}formatCoinsWithCurrency(i,t){return this.formatCurrency(i,{as:F.Currency,from:y.Coins},t)}formatMoney(i,t){return this.formatCurrency(i,{as:F.Number,from:y.Money},t)}formatMoneyWithCurrency(i,t){return this.formatCurrency(i,{as:F.Currency,from:y.Money},t)}}g=new WeakMap;const Q=()=>{};class U extends Error{constructor(t){super("OpenGameError");S(this,"error");this.name="OpenGameError",this.error=t}}class B extends Error{constructor(t){super("PlayError");S(this,"error");this.name="PlayError",this.error=t}}class w extends Error{constructor(){super("TimeoutError"),this.name="TimeoutError"}}var f,h,p,d;class Z{constructor({messagePort:i}){u(this,f,void 0);u(this,h,void 0);u(this,p,void 0);u(this,d,void 0);c(this,d,i),this.on("configured",t=>{c(this,f,t),c(this,p,new P({config:t})),c(this,h,new A({config:t}))}),this.on("playResponse",t=>{this.config.api.lastRoundId=t.contract.roundId})}get config(){if(!m(this,f))throw new Error("config is not initialized, you must open game first");return m(this,f)}get history(){if(!m(this,h))throw new Error("config is not initialized, you must open game first");return m(this,h)}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 s(a){a.data.message===`kalamba:wrapper:${i}`&&(Q("on",a.data.message.replace(/^kalamba:/,""),a.data.payload),t(a.data.payload),n!=null&&n.once&&window.removeEventListener("message",s))};window.addEventListener("message",o)}send(i,...[t]){m(this,d).postMessage({message:`kalamba:sdk:${i}`,payload:t},"*")}async openGame(i){var n;const[,t]=await Promise.all([new Promise(o=>this.on("configured",o,{once:!0})),this.request("openGame",i)]);if(t.type==="response")return t.response;throw((n=t.error)==null?void 0:n.type)==="timeout"?new w:new U(t.error)}async play(i,t,n="SPIN"){var a;const o={contract:i,extra:t,actionType:n},s=await this.request("play",o);if(s.type==="response")return s.response;throw((a=s.error)==null?void 0:a.type)==="timeout"?new w:new B(s.error)}}f=new WeakMap,h=new WeakMap,p=new WeakMap,d=new WeakMap;exports.History=A;exports.I18n=P;exports.KalambaSdk=Z;exports.OpenGameError=U;exports.PlayError=B;exports.TimeoutError=w;
5
+ "use strict";var N=(r,i,t)=>{if(!i.has(r))throw TypeError("Cannot "+t)};var m=(r,i,t)=>(N(r,i,"read from private field"),t?t.call(r):i.get(r)),s=(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)=>(N(r,i,"write to private field"),n?n.call(r,t):i.set(r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./errors-66b5612a.cjs");function O(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 U(r){const i=O(r);return i.setHours(23,59,59,999),i}function B(){return U(Date.now())}function k(r){const i=O(r);return i.setHours(0,0,0,0),i}function G(){return k(Date.now())}const L=3e4;var F,S;class ${constructor(i){s(this,F,void 0);s(this,S,L);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 R={limit:100,page:0};var e,f;class I{constructor({config:i}){s(this,e,void 0);s(this,f,void 0);u(this,e,i),u(this,f,new $({apiUrl:i.api.gameHistoryUrl}))}async getRound(i,{pagination:t=R}={}){return m(this,f).getRound(i,{gameCode:m(this,e).api.game,operatorCode:m(this,e).api.brand,username:m(this,e).api.user,...t})}async getLastRound(){return m(this,e).api.lastRoundId?this.getRound(m(this,e).api.lastRoundId):null}async getRounds({searchPeriod:i={fromDateTime:G(),toDateTime:B()},pagination:t=R}={}){const n=m(this,e).api.user.replace(/^user_/,"").replace(new RegExp(`_${m(this,e).api.integration}$`),"");return m(this,f).getRounds({gameCode:m(this,e).api.game,operatorCode:m(this,e).api.integration,username:n,fromDataTime:i.fromDateTime.toISOString(),toDateTime:i.toDateTime.toISOString(),...t})}}e=new WeakMap,f=new WeakMap;function _(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||{}),l=(r=>(r.Coins="Coins",r.Money="Money",r))(l||{});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:a=!0,coinValueInCents:D,currency:x,locales:E}=r;n==="Coins"&&(i=_(+i,D));try{const H=j(x),b=new Intl.NumberFormat(E,{...H,...o,currencyDisplay:"symbol",numberingSystem:"latn",style:"currency"});return t==="Number"||!a?V(r,i,b):q(i,b,x)}catch{return v(r,i,{as:t})}}var c;class P{constructor({config:i}){s(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:l.Money},n){const o=m(this,c).ui.feature.showCurrency,a=m(this,c).api.coinValueInCents,D=m(this,c).api.currency||w,x=[m(this,c).ui.language];return K({canShowCurrency:o,coinValueInCents:a,currency:D,locales:x},i,t,n)}formatCoins(i,t){return this.formatCurrency(i,{as:y.Number,from:l.Coins},t)}formatCoinsWithCurrency(i,t){return this.formatCurrency(i,{as:y.Currency,from:l.Coins},t)}formatMoney(i,t){return this.formatCurrency(i,{as:y.Number,from:l.Money},t)}formatMoneyWithCurrency(i,t){return this.formatCurrency(i,{as:y.Currency,from:l.Money},t)}}c=new WeakMap;const X=()=>{};var h,d,p,C;class z{constructor({messagePort:i}){s(this,h,void 0);s(this,d,void 0);s(this,p,void 0);s(this,C,void 0);u(this,C,i),this.on("configured",t=>{u(this,h,t),u(this,p,new P({config:t})),u(this,d,new I({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 a(D){D.data.message===`kalamba:wrapper:${i}`&&(X("on",D.data.message.replace(/^kalamba:/,""),D.data.payload),t(D.data.payload),n!=null&&n.once&&window.removeEventListener("message",a))};window.addEventListener("message",o)}send(i,...[t]){m(this,C).postMessage({message:`kalamba:sdk:${i}`,payload:t},"*")}async openGame(i){const[,t]=await Promise.all([new Promise(n=>this.on("configured",n,{once:!0})),this.request("openGame",i)]);if(t.type==="response")return t.response;throw t.error.type==="timeout"?new g.TimeoutError:new g.OpenGameError(t.error.data)}async play(i,t,n="SPIN"){const o={contract:i,extra:t,actionType:n},a=await this.request("play",o);if(a.type==="response")return a.response;throw a.error.type==="timeout"?new g.TimeoutError:new g.PlayError(a.error.data)}}h=new WeakMap,d=new WeakMap,p=new WeakMap,C=new WeakMap;exports.OpenGameError=g.OpenGameError;exports.OpenGameErrorCode=g.OpenGameErrorCode;exports.PlayError=g.PlayError;exports.PlayErrorCode=g.PlayErrorCode;exports.TimeoutError=g.TimeoutError;exports.History=I;exports.I18n=P;exports.KalambaSdk=z;
package/dist/index.d.ts CHANGED
@@ -55,6 +55,7 @@ export declare type CasinoOnlyMessagePayloadMap = {
55
55
  export declare type ContractPlayPayload = {
56
56
  [key: string]: any;
57
57
  bet: Bet | null;
58
+ forcedOutcomes?: unknown;
58
59
  };
59
60
 
60
61
  export { CurrencyFormat }
@@ -169,13 +170,33 @@ export declare type MessageMessageEvent<M extends Message> = MessageEvent<{
169
170
  export declare type MessagePayload<M extends Message> = MessageMap[M];
170
171
 
171
172
  export declare class OpenGameError extends Error {
172
- error: any;
173
- constructor(error: any);
173
+ data: {
174
+ code: keyof typeof OpenGameErrorCode;
175
+ };
176
+ constructor(data: {
177
+ code: keyof typeof OpenGameErrorCode;
178
+ });
174
179
  }
175
180
 
176
181
  declare type OpenGameError_2 = {
177
- data: any;
178
- type?: string;
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";
179
200
  };
180
201
 
181
202
  export declare type OpenGameRequest = {
@@ -232,13 +253,31 @@ export declare interface Pagination {
232
253
  }
233
254
 
234
255
  export declare class PlayError extends Error {
235
- error: any;
236
- constructor(error: any);
256
+ data: {
257
+ code: keyof typeof PlayErrorCode;
258
+ };
259
+ constructor(data: {
260
+ code: keyof typeof PlayErrorCode;
261
+ });
237
262
  }
238
263
 
239
264
  declare type PlayError_2 = {
240
- data: any;
241
- type?: string;
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";
242
281
  };
243
282
 
244
283
  export declare type PlayRequest = {
@@ -317,13 +356,13 @@ export declare type RgsOnlyMessagePayloadMap = {
317
356
  };
318
357
  };
319
358
 
320
- export declare type RgsResponse<M extends DomainMessage<'sdk'>> = `${M}Response` extends DomainMessage<'rgs'> ? {
359
+ export declare type RgsResponse<M extends DomainMessage<'sdk'>> = {
321
360
  type: 'response';
322
- response: DomainMessagePayload<'rgs', `${M}Response`>;
361
+ response: `${M}Response` extends DomainMessage<'rgs'> ? DomainMessagePayload<'rgs', `${M}Response`> : never;
323
362
  } | {
324
363
  type: 'error';
325
- error: DomainMessagePayload<'rgs', `${M}Error`>;
326
- } : never;
364
+ error: `${M}Error` extends DomainMessage<'rgs'> ? DomainMessagePayload<'rgs', `${M}Error`> : never;
365
+ };
327
366
 
328
367
  export declare interface SdkConfig {
329
368
  api: {
package/dist/index.js CHANGED
@@ -2,52 +2,52 @@
2
2
  * BSD 3-Clause License
3
3
  * Copyright (c) 2024, Kalamba Games Limited
4
4
  */
5
- var U = Object.defineProperty;
6
- var B = (r, i, t) => i in r ? U(r, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[i] = t;
7
- var w = (r, i, t) => (B(r, typeof i != "symbol" ? i + "" : i, t), t), R = (r, i, t) => {
8
- if (!i.has(r))
5
+ var b = (n, i, t) => {
6
+ if (!i.has(n))
9
7
  throw TypeError("Cannot " + t);
10
8
  };
11
- var m = (r, i, t) => (R(r, i, "read from private field"), t ? t.call(r) : i.get(r)), u = (r, i, t) => {
12
- if (i.has(r))
9
+ var m = (n, i, t) => (b(n, i, "read from private field"), t ? t.call(n) : i.get(n)), e = (n, i, t) => {
10
+ if (i.has(n))
13
11
  throw TypeError("Cannot add the same private member more than once");
14
- i instanceof WeakSet ? i.add(r) : i.set(r, t);
15
- }, c = (r, i, t, n) => (R(r, i, "write to private field"), n ? n.call(r, t) : i.set(r, t), t);
16
- function I(r) {
17
- const i = Object.prototype.toString.call(r);
18
- 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) : /* @__PURE__ */ new Date(NaN);
12
+ i instanceof WeakSet ? i.add(n) : i.set(n, t);
13
+ }, u = (n, i, t, r) => (b(n, i, "write to private field"), r ? r.call(n, t) : i.set(n, t), t);
14
+ import { T as E, O as H, P as U } from "./errors-96eb18f7.js";
15
+ import { a as ti, b as ni } from "./errors-96eb18f7.js";
16
+ function O(n) {
17
+ const i = Object.prototype.toString.call(n);
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 P(r) {
21
- const i = I(r);
20
+ function B(n) {
21
+ const i = O(n);
22
22
  return i.setHours(23, 59, 59, 999), i;
23
23
  }
24
- function k() {
25
- return P(Date.now());
24
+ function P() {
25
+ return B(Date.now());
26
26
  }
27
- function L(r) {
28
- const i = I(r);
27
+ function k(n) {
28
+ const i = O(n);
29
29
  return i.setHours(0, 0, 0, 0), i;
30
30
  }
31
- function $() {
32
- return L(Date.now());
31
+ function L() {
32
+ return k(Date.now());
33
33
  }
34
- const G = 3e4;
34
+ const $ = 3e4;
35
35
  var D, x;
36
- class _ {
36
+ class G {
37
37
  constructor(i) {
38
- u(this, D, void 0);
39
- u(this, x, G);
40
- c(this, D, i);
38
+ e(this, D, void 0);
39
+ e(this, x, $);
40
+ u(this, D, i);
41
41
  }
42
42
  buildHeaders() {
43
43
  const i = {};
44
44
  return m(this, D).token && (i.Authorization = `Bearer ${m(this, D).token}`), i;
45
45
  }
46
46
  async request(i, t) {
47
- const n = new URL(i, m(this, D).apiUrl ?? window.location.origin);
48
- return n.search = new URLSearchParams({
47
+ const r = new URL(i, m(this, D).apiUrl ?? window.location.origin);
48
+ return r.search = new URLSearchParams({
49
49
  ...t
50
- }).toString(), await (await fetch(n, {
50
+ }).toString(), await (await fetch(r, {
51
51
  signal: AbortSignal.timeout(m(this, x)),
52
52
  headers: this.buildHeaders()
53
53
  })).json();
@@ -60,62 +60,62 @@ class _ {
60
60
  }
61
61
  }
62
62
  D = new WeakMap(), x = new WeakMap();
63
- const b = {
63
+ const R = {
64
64
  limit: 100,
65
65
  page: 0
66
66
  };
67
- var s, f;
68
- class j {
67
+ var a, f;
68
+ class _ {
69
69
  constructor({
70
70
  config: i
71
71
  }) {
72
- u(this, s, void 0);
73
- u(this, f, void 0);
74
- c(this, s, i), c(this, f, new _({
72
+ e(this, a, void 0);
73
+ e(this, f, void 0);
74
+ u(this, a, i), u(this, f, new G({
75
75
  apiUrl: i.api.gameHistoryUrl
76
76
  }));
77
77
  }
78
78
  async getRound(i, {
79
- pagination: t = b
79
+ pagination: t = R
80
80
  } = {}) {
81
81
  return m(this, f).getRound(i, {
82
- gameCode: m(this, s).api.game,
83
- operatorCode: m(this, s).api.brand,
84
- username: m(this, s).api.user,
82
+ gameCode: m(this, a).api.game,
83
+ operatorCode: m(this, a).api.brand,
84
+ username: m(this, a).api.user,
85
85
  ...t
86
86
  });
87
87
  }
88
88
  async getLastRound() {
89
- return m(this, s).api.lastRoundId ? this.getRound(m(this, s).api.lastRoundId) : null;
89
+ return m(this, a).api.lastRoundId ? this.getRound(m(this, a).api.lastRoundId) : null;
90
90
  }
91
91
  async getRounds({
92
92
  searchPeriod: i = {
93
- fromDateTime: $(),
94
- toDateTime: k()
93
+ fromDateTime: L(),
94
+ toDateTime: P()
95
95
  },
96
- pagination: t = b
96
+ pagination: t = R
97
97
  } = {}) {
98
- const n = m(this, s).api.user.replace(/^user_/, "").replace(new RegExp(`_${m(this, s).api.integration}$`), "");
98
+ const r = m(this, a).api.user.replace(/^user_/, "").replace(new RegExp(`_${m(this, a).api.integration}$`), "");
99
99
  return m(this, f).getRounds({
100
- gameCode: m(this, s).api.game,
101
- operatorCode: m(this, s).api.integration,
102
- username: n,
100
+ gameCode: m(this, a).api.game,
101
+ operatorCode: m(this, a).api.integration,
102
+ username: r,
103
103
  fromDataTime: i.fromDateTime.toISOString(),
104
104
  toDateTime: i.toDateTime.toISOString(),
105
105
  ...t
106
106
  });
107
107
  }
108
108
  }
109
- s = new WeakMap(), f = new WeakMap();
110
- function q(r, i) {
111
- return r * i / 100;
109
+ a = new WeakMap(), f = new WeakMap();
110
+ function j(n, i) {
111
+ return n * i / 100;
112
112
  }
113
- function A(r, i, t) {
113
+ function I(n, i, t) {
114
114
  if (!["string", "number"].includes(typeof i))
115
115
  return "NaN";
116
- const { locales: n } = r;
116
+ const { locales: r } = n;
117
117
  try {
118
- return new Intl.NumberFormat(n, {
118
+ return new Intl.NumberFormat(r, {
119
119
  ...t,
120
120
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
121
121
  // @ts-ignore
@@ -126,9 +126,9 @@ function A(r, i, t) {
126
126
  return `${i}`;
127
127
  }
128
128
  }
129
- const S = "XTS";
130
- var F = /* @__PURE__ */ ((r) => (r.Currency = "Currency", r.Number = "Number", r))(F || {}), y = /* @__PURE__ */ ((r) => (r.Coins = "Coins", r.Money = "Money", r))(y || {});
131
- const T = {
129
+ const w = "XTS";
130
+ var F = /* @__PURE__ */ ((n) => (n.Currency = "Currency", n.Number = "Number", n))(F || {}), y = /* @__PURE__ */ ((n) => (n.Coins = "Coins", n.Money = "Money", n))(y || {});
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
134
134
  ARSB: { displayAs: "ARS", maximumFractionDigits: 2, minimumFractionDigits: 2 },
@@ -222,44 +222,44 @@ const T = {
222
222
  FTN: { maximumFractionDigits: 4, minimumFractionDigits: 4 }
223
223
  /* eslint-enable sort-keys-fix/sort-keys-fix */
224
224
  };
225
- function M(r) {
226
- return r in T;
225
+ function A(n) {
226
+ return n in S;
227
227
  }
228
- function V(r) {
229
- return M(r) ? {
230
- ...T[r],
231
- currency: S
228
+ function q(n) {
229
+ return A(n) ? {
230
+ ...S[n],
231
+ currency: w
232
232
  } : {
233
- currency: r
233
+ currency: n
234
234
  };
235
235
  }
236
- function X(r, i, t) {
237
- const n = i.format(+r);
238
- return M(t) ? n.replace(S, T[t].displayAs ?? t) : n;
236
+ function V(n, i, t) {
237
+ const r = i.format(+n);
238
+ return A(t) ? r.replace(w, S[t].displayAs ?? t) : r;
239
239
  }
240
- function v(r, i, t) {
241
- const { maximumFractionDigits: n, minimumFractionDigits: o } = t.resolvedOptions();
242
- return A(r, i, { maximumFractionDigits: n, minimumFractionDigits: o });
240
+ function X(n, i, t) {
241
+ const { maximumFractionDigits: r, minimumFractionDigits: o } = t.resolvedOptions();
242
+ return I(n, i, { maximumFractionDigits: r, minimumFractionDigits: o });
243
243
  }
244
- function z(r, i, { as: t } = {
244
+ function v(n, i, { as: t } = {
245
245
  as: "Currency"
246
246
  /* Currency */
247
247
  }) {
248
- const { canShowCurrency: n, currency: o } = r;
249
- return t === "Number" || !n ? `${i}` : `${i} ${o}`;
248
+ const { canShowCurrency: r, currency: o } = n;
249
+ return t === "Number" || !r ? `${i}` : `${i} ${o}`;
250
250
  }
251
- function K(r, i, { as: t, from: n } = {
251
+ function z(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: e = !0, coinValueInCents: a, currency: C, locales: E } = r;
259
- n === "Coins" && (i = q(+i, a));
258
+ const { canShowCurrency: s = !0, coinValueInCents: g, currency: C, locales: T } = n;
259
+ r === "Coins" && (i = j(+i, g));
260
260
  try {
261
- const H = V(C), N = new Intl.NumberFormat(E, {
262
- ...H,
261
+ const M = q(C), N = new Intl.NumberFormat(T, {
262
+ ...M,
263
263
  ...o,
264
264
  currencyDisplay: "symbol",
265
265
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -267,29 +267,29 @@ function K(r, i, { as: t, from: n } = {
267
267
  numberingSystem: "latn",
268
268
  style: "currency"
269
269
  });
270
- return t === "Number" || !e ? v(r, i, N) : X(i, N, C);
270
+ return t === "Number" || !s ? X(n, i, N) : V(i, N, C);
271
271
  } catch {
272
- return z(r, i, { as: t });
272
+ return v(n, i, { as: t });
273
273
  }
274
274
  }
275
- var g;
276
- class W {
275
+ var c;
276
+ class K {
277
277
  constructor({ config: i }) {
278
- u(this, g, void 0);
279
- c(this, g, i);
278
+ e(this, c, void 0);
279
+ u(this, c, i);
280
280
  }
281
281
  formatNumber(i, t) {
282
- const n = { locales: [m(this, g).ui.language] };
283
- return A(n, i, t);
282
+ const r = { locales: [m(this, c).ui.language] };
283
+ return I(r, i, t);
284
284
  }
285
- formatCurrency(i, t = { as: F.Currency, from: y.Money }, n) {
286
- const o = m(this, g).ui.feature.showCurrency, e = m(this, g).api.coinValueInCents, a = m(this, g).api.currency || S, C = [m(this, g).ui.language];
287
- return K({
285
+ formatCurrency(i, t = { as: F.Currency, from: y.Money }, r) {
286
+ const o = m(this, c).ui.feature.showCurrency, s = m(this, c).api.coinValueInCents, g = m(this, c).api.currency || w, C = [m(this, c).ui.language];
287
+ return z({
288
288
  canShowCurrency: o,
289
- coinValueInCents: e,
290
- currency: a,
289
+ coinValueInCents: s,
290
+ currency: g,
291
291
  locales: C
292
- }, i, t, n);
292
+ }, i, t, r);
293
293
  }
294
294
  formatCoins(i, t) {
295
295
  return this.formatCurrency(i, { as: F.Number, from: y.Coins }, t);
@@ -304,37 +304,18 @@ class W {
304
304
  return this.formatCurrency(i, { as: F.Currency, from: y.Money }, t);
305
305
  }
306
306
  }
307
- g = new WeakMap();
308
- const J = () => {
307
+ c = new WeakMap();
308
+ const W = () => {
309
309
  };
310
- class Y extends Error {
311
- constructor(t) {
312
- super("OpenGameError");
313
- w(this, "error");
314
- this.name = "OpenGameError", this.error = t;
315
- }
316
- }
317
- class Q extends Error {
318
- constructor(t) {
319
- super("PlayError");
320
- w(this, "error");
321
- this.name = "PlayError", this.error = t;
322
- }
323
- }
324
- class O extends Error {
325
- constructor() {
326
- super("TimeoutError"), this.name = "TimeoutError";
327
- }
328
- }
329
310
  var l, h, p, d;
330
- class ii {
311
+ class Q {
331
312
  constructor({ messagePort: i }) {
332
- u(this, l, void 0);
333
- u(this, h, void 0);
334
- u(this, p, void 0);
335
- u(this, d, void 0);
336
- c(this, d, i), this.on("configured", (t) => {
337
- c(this, l, t), c(this, p, new W({ config: t })), c(this, h, new j({ config: t }));
313
+ e(this, l, void 0);
314
+ e(this, h, void 0);
315
+ e(this, p, void 0);
316
+ e(this, d, void 0);
317
+ u(this, d, i), this.on("configured", (t) => {
318
+ u(this, l, t), u(this, p, new K({ config: t })), u(this, h, new _({ config: t }));
338
319
  }), this.on("playResponse", (t) => {
339
320
  this.config.api.lastRoundId = t.contract.roundId;
340
321
  });
@@ -355,15 +336,15 @@ class ii {
355
336
  return m(this, p);
356
337
  }
357
338
  request(i, ...[t]) {
358
- return new Promise((n) => {
359
- this.on(`${i}Response`, (o) => n({ type: "response", response: o }), {
339
+ return new Promise((r) => {
340
+ this.on(`${i}Response`, (o) => r({ type: "response", response: o }), {
360
341
  once: !0
361
- }), this.on(`${i}Error`, (o) => n({ type: "error", error: o }), { once: !0 }), this.send(i, t);
342
+ }), this.on(`${i}Error`, (o) => r({ type: "error", error: o }), { once: !0 }), this.send(i, t);
362
343
  });
363
344
  }
364
- on(i, t, n) {
365
- const o = function e(a) {
366
- a.data.message === `kalamba:wrapper:${i}` && (J("on", a.data.message.replace(/^kalamba:/, ""), a.data.payload), t(a.data.payload), n != null && n.once && window.removeEventListener("message", e));
345
+ on(i, t, r) {
346
+ const o = function s(g) {
347
+ g.data.message === `kalamba:wrapper:${i}` && (W("on", g.data.message.replace(/^kalamba:/, ""), g.data.payload), t(g.data.payload), r != null && r.once && window.removeEventListener("message", s));
367
348
  };
368
349
  window.addEventListener("message", o);
369
350
  }
@@ -378,30 +359,30 @@ class ii {
378
359
  );
379
360
  }
380
361
  async openGame(i) {
381
- var n;
382
362
  const [, t] = await Promise.all([
383
363
  // TODO: return promise from call to this.on if listener is not provided
384
- new Promise((o) => this.on("configured", o, { once: !0 })),
364
+ new Promise((r) => this.on("configured", r, { once: !0 })),
385
365
  this.request("openGame", i)
386
366
  ]);
387
367
  if (t.type === "response")
388
368
  return t.response;
389
- throw ((n = t.error) == null ? void 0 : n.type) === "timeout" ? new O() : new Y(t.error);
369
+ throw t.error.type === "timeout" ? new E() : new H(t.error.data);
390
370
  }
391
- async play(i, t, n = "SPIN") {
392
- var a;
393
- const o = { contract: i, extra: t, actionType: n }, e = await this.request("play", o);
394
- if (e.type === "response")
395
- return e.response;
396
- throw ((a = e.error) == null ? void 0 : a.type) === "timeout" ? new O() : new Q(e.error);
371
+ async play(i, t, r = "SPIN") {
372
+ const o = { contract: i, extra: t, actionType: r }, s = await this.request("play", o);
373
+ if (s.type === "response")
374
+ return s.response;
375
+ throw s.error.type === "timeout" ? new E() : new U(s.error.data);
397
376
  }
398
377
  }
399
378
  l = new WeakMap(), h = new WeakMap(), p = new WeakMap(), d = new WeakMap();
400
379
  export {
401
- j as History,
402
- W as I18n,
403
- ii as KalambaSdk,
404
- Y as OpenGameError,
405
- Q as PlayError,
406
- O as TimeoutError
380
+ _ as History,
381
+ K as I18n,
382
+ Q as KalambaSdk,
383
+ H as OpenGameError,
384
+ ti as OpenGameErrorCode,
385
+ U as PlayError,
386
+ ni as PlayErrorCode,
387
+ E as TimeoutError
407
388
  };