@lovrabet/sdk 1.1.4 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a0_0x4cc1d6=a0_0x375a;(function(_0x2d4065,_0x5726e1){const _0x3f9a6e=a0_0x375a,_0x339137=_0x2d4065();while(!![]){try{const _0x1c6389=parseInt(_0x3f9a6e(0xe6))/0x1*(-parseInt(_0x3f9a6e(0xed))/0x2)+-parseInt(_0x3f9a6e(0xf3))/0x3+parseInt(_0x3f9a6e(0x89))/0x4+-parseInt(_0x3f9a6e(0x88))/0x5+parseInt(_0x3f9a6e(0xfd))/0x6*(-parseInt(_0x3f9a6e(0x10e))/0x7)+-parseInt(_0x3f9a6e(0xe2))/0x8+parseInt(_0x3f9a6e(0xb9))/0x9;if(_0x1c6389===_0x5726e1)break;else _0x339137['push'](_0x339137['shift']());}catch(_0x882237){_0x339137['push'](_0x339137['shift']());}}}(a0_0x3289,0x47863));class UserAuth{['config'];constructor(_0xf8e4f){this['config']=_0xf8e4f;}async[a0_0x4cc1d6(0x108)](){const _0x4f55cb=a0_0x4cc1d6;return{'Authorization':'Bearer\x20'+this[_0x4f55cb(0x86)][_0x4f55cb(0xb3)]};}['getToken'](){const _0x2d1290=a0_0x4cc1d6;return this['config'][_0x2d1290(0xb3)];}[a0_0x4cc1d6(0xab)](_0x5d2cc6){const _0x3bc7ee=a0_0x4cc1d6;this[_0x3bc7ee(0x86)][_0x3bc7ee(0xb3)]=_0x5d2cc6;}}class OpenApiAuth{['config'];constructor(_0x40e26a){this['config']=_0x40e26a;}async[a0_0x4cc1d6(0x108)](){const _0x45539e=a0_0x4cc1d6,_0x21b9b6=Date['now']()['toString'](),_0x394235=Math['random']()[_0x45539e(0x7f)](0x24)[_0x45539e(0x111)](0x2),_0x28c343=await this[_0x45539e(0xc3)](_0x21b9b6,_0x394235);return{'X-Access-Key':this[_0x45539e(0x86)][_0x45539e(0xa6)],'X-Timestamp':_0x21b9b6,'X-Nonce':_0x394235,'X-Signature':_0x28c343};}async['generateSignature'](_0x3ea3be,_0x144438){const _0x528352=a0_0x4cc1d6,_0x10edef=''+this[_0x528352(0x86)]['accessKey']+_0x3ea3be+_0x144438;if(typeof crypto!=='undefined'&&crypto[_0x528352(0x91)]){const _0x117d7b=new TextEncoder(),_0x3a17aa=_0x117d7b[_0x528352(0xbb)](this[_0x528352(0x86)][_0x528352(0xeb)]),_0x3976a0=_0x117d7b['encode'](_0x10edef),_0x549946=await crypto[_0x528352(0x91)][_0x528352(0xc9)]('raw',_0x3a17aa,{'name':'HMAC','hash':_0x528352(0x8b)},![],[_0x528352(0xa3)]),_0x1141ed=await crypto['subtle'][_0x528352(0xa3)]('HMAC',_0x549946,_0x3976a0),_0x5f2eaf=Array[_0x528352(0xe9)](new Uint8Array(_0x1141ed));return _0x5f2eaf[_0x528352(0xca)](_0x41883d=>_0x41883d[_0x528352(0x7f)](0x10)['padStart'](0x2,'0'))[_0x528352(0x107)]('');}if(typeof globalThis!=='undefined'&&globalThis[_0x528352(0xc2)]){const _0x17b3d7=globalThis[_0x528352(0xc2)];return _0x17b3d7[_0x528352(0xe9)](_0x10edef+this[_0x528352(0x86)][_0x528352(0xeb)])['toString']('base64');}return btoa(_0x10edef+this[_0x528352(0x86)][_0x528352(0xeb)]);}}class CookieAuth{constructor(){}async['getAuthHeaders'](){return{};}[a0_0x4cc1d6(0x84)](){const _0x496ccb=a0_0x4cc1d6;return typeof window!==_0x496ccb(0x110)&&typeof document!==_0x496ccb(0x110);}}class AuthManager{[a0_0x4cc1d6(0x86)];[a0_0x4cc1d6(0x98)];['openApiAuth'];[a0_0x4cc1d6(0x103)];constructor(_0x21baba){const _0x4f5ab3=a0_0x4cc1d6;this[_0x4f5ab3(0x86)]=_0x21baba,this['initAuthMethods']();}[a0_0x4cc1d6(0x10c)](){const _0x579995=a0_0x4cc1d6;this[_0x579995(0x86)][_0x579995(0xb3)]&&(this[_0x579995(0x98)]=new UserAuth({'token':this[_0x579995(0x86)]['token']})),this[_0x579995(0x86)][_0x579995(0xa6)]&&this[_0x579995(0x86)][_0x579995(0xeb)]&&(this[_0x579995(0x9e)]=new OpenApiAuth({'accessKey':this[_0x579995(0x86)][_0x579995(0xa6)],'secretKey':this[_0x579995(0x86)][_0x579995(0xeb)]})),!this[_0x579995(0x86)][_0x579995(0xb3)]&&!this['config'][_0x579995(0xa6)]&&!this[_0x579995(0x86)][_0x579995(0xeb)]&&(this[_0x579995(0x103)]=new CookieAuth());}async['getAuthHeaders'](){const _0x2f88af=a0_0x4cc1d6,_0x396366={};if(this[_0x2f88af(0x98)]){const _0x5b27f8=await this['userAuth'][_0x2f88af(0x108)]();Object[_0x2f88af(0xaa)](_0x396366,_0x5b27f8);}else{if(this['openApiAuth']){const _0x223157=await this[_0x2f88af(0x9e)]['getAuthHeaders']();Object[_0x2f88af(0xaa)](_0x396366,_0x223157);}else{if(this['cookieAuth']){const _0x501b7c=await this[_0x2f88af(0x103)][_0x2f88af(0x108)]();Object['assign'](_0x396366,_0x501b7c);}}}return _0x396366;}async[a0_0x4cc1d6(0x101)](){const _0x23c78d=a0_0x4cc1d6;try{if(this[_0x23c78d(0x103)]?.[_0x23c78d(0x84)]())return!![];const _0x1264de=await this[_0x23c78d(0x108)]();return Object[_0x23c78d(0xc5)](_0x1264de)[_0x23c78d(0xdc)]>0x0;}catch{return![];}}[a0_0x4cc1d6(0xbe)](){const _0x13360f=a0_0x4cc1d6;return!!this[_0x13360f(0x103)];}[a0_0x4cc1d6(0xab)](_0x568b7c){const _0x43b03a=a0_0x4cc1d6;this[_0x43b03a(0x86)][_0x43b03a(0xb3)]=_0x568b7c,this[_0x43b03a(0x98)]=new UserAuth({'token':_0x568b7c}),this[_0x43b03a(0x103)]=undefined;}}class LovrabetError extends Error{[a0_0x4cc1d6(0xa2)];['code'];[a0_0x4cc1d6(0xa7)];[a0_0x4cc1d6(0xdd)];constructor(_0x58b50d,_0x3f5a75,_0x5d402c,_0x21f229,_0x20af5a){const _0x17c29b=a0_0x4cc1d6;super(_0x58b50d),this[_0x17c29b(0xb8)]='LovrabetError',this[_0x17c29b(0xa2)]=_0x3f5a75,this['code']=_0x5d402c,this[_0x17c29b(0xa7)]=_0x21f229,this['originalError']=_0x20af5a;}[a0_0x4cc1d6(0xb1)](){const _0x177109=a0_0x4cc1d6;return{'name':this[_0x177109(0xb8)],'message':this[_0x177109(0x119)],'status':this[_0x177109(0xa2)],'code':this[_0x177109(0x9a)],'data':this['data']};}}function createErrorHandler(_0x531afd){return _0x4ddb38=>{const _0x336302=a0_0x375a,_0x387c74=_0x4ddb38 instanceof LovrabetError?_0x4ddb38:new LovrabetError(_0x4ddb38[_0x336302(0x119)]||'Unknown\x20error',_0x4ddb38[_0x336302(0xa2)],_0x4ddb38[_0x336302(0x9a)],_0x4ddb38[_0x336302(0xa7)],_0x4ddb38);return typeof globalThis!=='undefined'&&globalThis[_0x336302(0x116)]?.['env']?.[_0x336302(0xf5)]!==_0x336302(0xb2)&&console[_0x336302(0x113)](_0x336302(0xcf),_0x387c74),_0x531afd?.(_0x387c74),Promise[_0x336302(0xbf)](_0x387c74);};}function a0_0x3289(){const _0x2caf55=['online','Model\x20config\x20with\x20name\x20\x22','include','Cookie','AbortError','366oPxACe','set','list','content','validateAuth','makeRequest','cookieAuth','/update','prepareRequestInit','/api/','join','getAuthHeaders','stringify','resolveModelConfig','00-','initAuthMethods','/api/{appCode}/{datasetId}','14728nqfsFL','signal','undefined','substring','executeWithErrorHandling','error','/delete','getOne','process','authManager','errorHandler','message','location','ONLINE','redirected','toString','modelCache','clearCache','ENV','/getOne','isValid','Request\x20timeout','config','getList','1486555SqhIOB','2157504FewiRn','startsWith','SHA-256','getApiPath','number','application/json','/{id}','httpClient','subtle','getModel','clear','append','Invalid\x20environment.\x20Must\x20be\x20\x22online\x22\x20or\x20\x22daily\x22.','string','headers','userAuth','create','code','getBaseUrl','APP_CODE_REQUIRED','http','openApiAuth','searchParams','daily','request','status','sign','\x22\x20not\x20configured.\x20Please\x20provide\x20datasetId\x20in\x20config.models\x20or\x20use\x20registerModels()\x20to\x20configure\x20it.','update','accessKey','data','success','onError','assign','setToken','appCode\x20is\x20required.\x20Please\x20provide\x20it\x20in\x20the\x20config\x20or\x20register\x20models\x20first.','split','url','has','PUT','toJSON','production','token','abort','HTTP\x20','options','requiresAuth','name','9692847uINcxE','modelName','encode','json','href','isCookieAuth','reject','includes','addModel','Buffer','generateSignature','INVALID_METHOD','keys','getModelList','Model\x20\x22','models','importKey','map','CONFIG_NOT_FOUND','DELETE','Unsupported\x20method:\x20','modelManager','[Lovrabet\x20SDK\x20Error]','Unauthorized\x20access','Access\x20forbidden','setEnvironment','POST','\x20is\x20out\x20of\x20range.\x20Available\x20models:\x20','Model\x20\x27','padStart','catch','Internal\x20server\x20error','test','getRandomValues','serverUrl','length','originalError','getFullUrl','statusText','delete','get','1433376GMXtOt','Resource\x20not\x20found','appCode','DAILY','264138wQNAwg','put','TIMEOUT','from','env','secretKey','GET','4VhyIab','\x22\x20not\x20found.\x20Please\x20register\x20it\x20first\x20using\x20registerModels().','post','apiConfigName','object','getConfig','570879etixGO','validateConfig','NODE_ENV','Model\x20index\x20','DEFAULT'];a0_0x3289=function(){return _0x2caf55;};return a0_0x3289();}var CONFIG_NAMES={'DEFAULT':'default','PROD':'prod','DEV':'dev','TEST':a0_0x4cc1d6(0xd9)},ENVIRONMENTS={'ONLINE':a0_0x4cc1d6(0xf8),'DAILY':a0_0x4cc1d6(0xa0)},HTTP_STATUS={'OK':0xc8,'UNAUTHORIZED':0x191,'FORBIDDEN':0x193,'NOT_FOUND':0x194,'INTERNAL_ERROR':0x1f4},DEFAULTS={'ENV':ENVIRONMENTS[a0_0x4cc1d6(0x7d)],'TIMEOUT':0x7530,'RETRY_COUNT':0x3,'PAGE_SIZE':0x14,'CURRENT_PAGE':0x1},ERROR_MESSAGES={'APP_CODE_REQUIRED':a0_0x4cc1d6(0xac),'CONFIG_NOT_FOUND':_0x1cac3e=>a0_0x4cc1d6(0xf9)+_0x1cac3e+a0_0x4cc1d6(0xee),'INVALID_ENV':a0_0x4cc1d6(0x95),'NETWORK_ERROR':'Network\x20request\x20failed','UNAUTHORIZED':a0_0x4cc1d6(0xd0),'FORBIDDEN':a0_0x4cc1d6(0xd1),'NOT_FOUND':a0_0x4cc1d6(0xe3),'SERVER_ERROR':a0_0x4cc1d6(0xd8)},API_PATHS={'BASE':a0_0x4cc1d6(0x10d),'LIST':'','DETAIL':a0_0x4cc1d6(0x8f)},API_ENDPOINTS={[ENVIRONMENTS['ONLINE']]:'https://runtime.lovrabet.com',[ENVIRONMENTS[a0_0x4cc1d6(0xe5)]]:'https://daily-runtime.lovrabet.com'};function a0_0x375a(_0x59008f,_0xbef84){const _0x3289d7=a0_0x3289();return a0_0x375a=function(_0x375aad,_0x11aa10){_0x375aad=_0x375aad-0x7d;let _0x2028b9=_0x3289d7[_0x375aad];return _0x2028b9;},a0_0x375a(_0x59008f,_0xbef84);}function getApiEndpoint(_0x3a8021){return API_ENDPOINTS[_0x3a8021];}function getAvailableEnvironments(){return Object['keys'](API_ENDPOINTS);}var cacheCookie='';function getCookie(){return cacheCookie;}var processResponse=async _0x5a2186=>{const _0x55a7ff=a0_0x4cc1d6,_0x18f0c5=await _0x5a2186['json']();if(!_0x18f0c5[_0x55a7ff(0xa8)]){const _0x504afb=new Error(_0x18f0c5['errorMsg']);_0x504afb['response']=_0x18f0c5;throw _0x504afb;}return _0x18f0c5[_0x55a7ff(0xa7)];};function getTraceparent(){const _0x3d0872=a0_0x4cc1d6;try{return document['querySelector']('meta[name=\x22traceparent\x22]')?.['getAttribute'](_0x3d0872(0x100))||undefined;}catch(_0x4665b6){return;}}function generateTraceparent(){const _0x50471f=a0_0x4cc1d6,_0xdc48d0=getTraceparent(),_0x2796ce=_0xdc48d0?_0xdc48d0[_0x50471f(0xad)]('-')[0x1]:Array[_0x50471f(0xe9)](crypto[_0x50471f(0xda)](new Uint8Array(0x10)))[_0x50471f(0xca)](_0x2374a9=>_0x2374a9[_0x50471f(0x7f)](0x10)[_0x50471f(0xd6)](0x2,'0'))[_0x50471f(0x107)](''),_0x34dd5a=Array[_0x50471f(0xe9)](crypto[_0x50471f(0xda)](new Uint8Array(0x8)))[_0x50471f(0xca)](_0xa76ad2=>_0xa76ad2[_0x50471f(0x7f)](0x10)[_0x50471f(0xd6)](0x2,'0'))[_0x50471f(0x107)](''),_0x24a657='01';return _0x50471f(0x10b)+_0x2796ce+'-'+_0x34dd5a+'-'+_0x24a657;}var get=async(_0x20b485,_0x30a6fc,_0x4d40e1={})=>{const _0x8fcb97=a0_0x4cc1d6,_0x52bf40=new URL(_0x20b485);if(_0x30a6fc)for(const _0x21f195 of Object[_0x8fcb97(0xc5)](_0x30a6fc)){_0x52bf40[_0x8fcb97(0x9f)][_0x8fcb97(0x94)](_0x21f195,String(_0x30a6fc[_0x21f195]));}const _0x1cfb8a={'Content-Type':'application/json',..._0x4d40e1[_0x8fcb97(0x97)],'traceparent':generateTraceparent()};getCookie()&&(_0x1cfb8a['Cookie']=getCookie());const _0x1fb0d9=await fetch(_0x52bf40[_0x8fcb97(0x7f)](),{..._0x4d40e1,'headers':_0x1cfb8a,'credentials':'include'});if(_0x1fb0d9['redirected']){window[_0x8fcb97(0x11a)][_0x8fcb97(0xbd)]=_0x1fb0d9[_0x8fcb97(0xae)];return;}return await processResponse(_0x1fb0d9);},post=async(_0x13aca0,_0x32fae5,_0x31c416={})=>{const _0x52d084=a0_0x4cc1d6,_0x17a284={'Content-Type':_0x52d084(0x8e),..._0x31c416['headers'],'traceparent':generateTraceparent()};getCookie()&&(_0x17a284[_0x52d084(0xfb)]=getCookie());const _0x3aad6e=await fetch(_0x13aca0,{..._0x31c416,'method':'POST','headers':_0x17a284,'body':_0x32fae5&&JSON['stringify'](_0x32fae5),'credentials':_0x52d084(0xfa)});if(_0x3aad6e[_0x52d084(0x7e)]){window['location'][_0x52d084(0xbd)]=_0x3aad6e[_0x52d084(0xae)];return;}return await processResponse(_0x3aad6e);};class HttpClient{[a0_0x4cc1d6(0x86)];[a0_0x4cc1d6(0x117)];[a0_0x4cc1d6(0x118)];constructor(_0x44891e,_0x50289b){const _0xeb81ec=a0_0x4cc1d6;this[_0xeb81ec(0x86)]=_0x44891e,this[_0xeb81ec(0x117)]=_0x50289b,this[_0xeb81ec(0x118)]=createErrorHandler(_0x44891e['options']?.[_0xeb81ec(0xa9)]);}[a0_0x4cc1d6(0x9b)](){const _0x4b0917=a0_0x4cc1d6;if(this['config'][_0x4b0917(0xdb)])return this[_0x4b0917(0x86)][_0x4b0917(0xdb)];const _0x59c8d8=this[_0x4b0917(0x86)][_0x4b0917(0xea)]||_0x4b0917(0xf8);return getApiEndpoint(_0x59c8d8);}['getFullUrl'](_0x371460){const _0x1a58a6=a0_0x4cc1d6;return _0x371460[_0x1a58a6(0x8a)](_0x1a58a6(0x9d))?_0x371460:''+this[_0x1a58a6(0x9b)]()+_0x371460;}async[a0_0x4cc1d6(0x105)](_0xec86eb){const _0x432fc9=a0_0x4cc1d6,_0x3563b8=await this[_0x432fc9(0x117)]['getAuthHeaders'](),_0x36a85d={..._0xec86eb,'headers':{..._0x3563b8,..._0xec86eb?.['headers']}};return this[_0x432fc9(0x117)][_0x432fc9(0xbe)]()&&(_0x36a85d['credentials']=_0x432fc9(0xfa)),_0x36a85d;}async[a0_0x4cc1d6(0x112)](_0x108c63){try{return await _0x108c63();}catch(_0x5ce199){return this['errorHandler'](_0x5ce199);}}async['makeRequest'](_0x3dcc38,_0x3f7f92,_0x1949fc,_0x33a74b){const _0x4aaa6f=a0_0x4cc1d6,_0x1c33b5=this[_0x4aaa6f(0xde)](_0x3f7f92),_0xeaa53f=await this[_0x4aaa6f(0x105)]({..._0x33a74b,'method':_0x3dcc38,'headers':{'Content-Type':'application/json',..._0x33a74b?.['headers']}}),_0x5e9810=new AbortController(),_0x464cd4=setTimeout(()=>{const _0x126198=_0x4aaa6f;_0x5e9810[_0x126198(0xb4)]();},this[_0x4aaa6f(0x86)][_0x4aaa6f(0xb6)]?.['timeout']||0x7530);try{const _0x1ad1b8=await fetch(_0x1c33b5,{..._0xeaa53f,'body':_0x1949fc?JSON[_0x4aaa6f(0x109)](_0x1949fc):undefined,'signal':_0x5e9810[_0x4aaa6f(0x10f)]});clearTimeout(_0x464cd4);if(!_0x1ad1b8['ok']){const _0x32e3a7=await _0x1ad1b8[_0x4aaa6f(0xbc)]()[_0x4aaa6f(0xd7)](()=>({}));throw new LovrabetError(_0x32e3a7[_0x4aaa6f(0x119)]||_0x4aaa6f(0xb5)+_0x1ad1b8['status']+':\x20'+_0x1ad1b8[_0x4aaa6f(0xdf)],_0x1ad1b8['status'],_0x32e3a7[_0x4aaa6f(0x9a)],_0x32e3a7);}return await _0x1ad1b8[_0x4aaa6f(0xbc)]();}catch(_0x4787d3){clearTimeout(_0x464cd4);if(_0x4787d3[_0x4aaa6f(0xb8)]===_0x4aaa6f(0xfc))throw new LovrabetError(_0x4aaa6f(0x85),0x198,_0x4aaa6f(0xe8));throw _0x4787d3;}}async[a0_0x4cc1d6(0xe1)](_0x4dd5ef,_0x3ab7c5,_0x2c7ce4){const _0x41a0f4=a0_0x4cc1d6;return this[_0x41a0f4(0x112)](async()=>{const _0x27885e=_0x41a0f4,_0x2b3457=this[_0x27885e(0xde)](_0x4dd5ef),_0x5d9597=await this[_0x27885e(0x105)](_0x2c7ce4);return await get(_0x2b3457,_0x3ab7c5,_0x5d9597);});}async[a0_0x4cc1d6(0xef)](_0xcfeb87,_0x24e6ef,_0x3e68f6){const _0x5f833d=a0_0x4cc1d6;return this[_0x5f833d(0x112)](async()=>{const _0x4b38a7=_0x5f833d,_0x563a1a=this['getFullUrl'](_0xcfeb87),_0xe992b7=await this[_0x4b38a7(0x105)](_0x3e68f6);return await post(_0x563a1a,_0x24e6ef,_0xe992b7);});}async[a0_0x4cc1d6(0xe7)](_0x12b502,_0x4ecfcd,_0x29cde2){const _0xa23ae0=a0_0x4cc1d6;return this[_0xa23ae0(0x112)](async()=>{const _0x1ad90c=_0xa23ae0;return this[_0x1ad90c(0x102)](_0x1ad90c(0xb0),_0x12b502,_0x4ecfcd,_0x29cde2);});}async['delete'](_0x1b8554,_0x1da98a){const _0x5cd58c=a0_0x4cc1d6;return this[_0x5cd58c(0x112)](async()=>{const _0x3c09a9=_0x5cd58c;return this[_0x3c09a9(0x102)]('DELETE',_0x1b8554,undefined,_0x1da98a);});}async[a0_0x4cc1d6(0xa1)](_0x58a336,_0x4e55a9,_0x548d70,_0x216d6d){const _0x1aac3d=a0_0x4cc1d6;switch(_0x58a336){case _0x1aac3d(0xec):return this[_0x1aac3d(0xe1)](_0x4e55a9,_0x548d70,_0x216d6d);case _0x1aac3d(0xd3):return this['post'](_0x4e55a9,_0x548d70,_0x216d6d);case _0x1aac3d(0xb0):return this[_0x1aac3d(0xe7)](_0x4e55a9,_0x548d70,_0x216d6d);case _0x1aac3d(0xcc):return this[_0x1aac3d(0xe0)](_0x4e55a9,_0x216d6d);default:throw new LovrabetError(_0x1aac3d(0xcd)+_0x58a336,0x190,_0x1aac3d(0xc4));}}}class BaseModel{[a0_0x4cc1d6(0xba)];['httpClient'];[a0_0x4cc1d6(0x86)];[a0_0x4cc1d6(0xe4)];constructor(_0x1d34cb,_0x2e79d4,_0x2a2a7b){const _0x1e77cc=a0_0x4cc1d6;this[_0x1e77cc(0xba)]=_0x1d34cb,this[_0x1e77cc(0x90)]=_0x2e79d4,this[_0x1e77cc(0xe4)]=_0x2a2a7b[_0x1e77cc(0xe4)],this[_0x1e77cc(0x86)]=this[_0x1e77cc(0x10a)](_0x1d34cb,_0x2a2a7b);}['resolveModelConfig'](_0x4f960f,_0x15b41a){const _0x3f48bc=a0_0x4cc1d6;if(_0x15b41a[_0x3f48bc(0xc8)]?.[_0x4f960f])return _0x15b41a[_0x3f48bc(0xc8)][_0x4f960f];throw new Error(_0x3f48bc(0xc7)+_0x4f960f+_0x3f48bc(0xa4));}[a0_0x4cc1d6(0x8c)](){const _0x520156=a0_0x4cc1d6;return _0x520156(0x106)+this[_0x520156(0xe4)]+'/'+this[_0x520156(0x86)]['datasetId'];}async[a0_0x4cc1d6(0x87)](_0x5e79f4){const _0x54770c=a0_0x4cc1d6,_0x1ea995=this['getApiPath']()+'/getList',_0xbbb1f7={'currentPage':0x1,'pageSize':0x14,..._0x5e79f4};return this[_0x54770c(0x90)][_0x54770c(0xef)](_0x1ea995,_0xbbb1f7);}async[a0_0x4cc1d6(0x115)](_0x305df7){const _0xaaae54=a0_0x4cc1d6,_0x20ecad=this[_0xaaae54(0x8c)]()+_0xaaae54(0x83);return this[_0xaaae54(0x90)]['post'](_0x20ecad,{'id':_0x305df7});}async[a0_0x4cc1d6(0x99)](_0x22b778){const _0x23216f=a0_0x4cc1d6,_0x2d019b=this[_0x23216f(0x8c)]()+'/create';return this[_0x23216f(0x90)]['post'](_0x2d019b,_0x22b778);}async[a0_0x4cc1d6(0xa5)](_0x43d53c,_0x42ebf8){const _0x48f305=a0_0x4cc1d6,_0x4cc688=this['getApiPath']()+_0x48f305(0x104);return this[_0x48f305(0x90)][_0x48f305(0xef)](_0x4cc688,{'id':_0x43d53c,..._0x42ebf8});}async[a0_0x4cc1d6(0xe0)](_0x5f1e17){const _0xae9d7a=a0_0x4cc1d6,_0x2553ac=this[_0xae9d7a(0x8c)]()+_0xae9d7a(0x114);await this[_0xae9d7a(0x90)][_0xae9d7a(0xef)](_0x2553ac,{'id':_0x5f1e17});}[a0_0x4cc1d6(0xf2)](){const _0x113e99=a0_0x4cc1d6;return{...this[_0x113e99(0x86)]};}['getModelName'](){return this['modelName'];}}class ModelManager{[a0_0x4cc1d6(0x90)];[a0_0x4cc1d6(0x86)];[a0_0x4cc1d6(0x80)]=new Map();constructor(_0xbc2c0a,_0x56ecfe){const _0xebb268=a0_0x4cc1d6;this['httpClient']=_0xbc2c0a,this[_0xebb268(0x86)]=_0x56ecfe;}[a0_0x4cc1d6(0x92)](_0x171b7e){const _0x221439=a0_0x4cc1d6;if(!this[_0x221439(0x80)][_0x221439(0xaf)](_0x171b7e)){const _0x3aa5ae=new BaseModel(_0x171b7e,this[_0x221439(0x90)],this[_0x221439(0x86)]);this[_0x221439(0x80)][_0x221439(0xfe)](_0x171b7e,_0x3aa5ae);}return this[_0x221439(0x80)][_0x221439(0xe1)](_0x171b7e);}['getCachedModels'](){const _0x59c689=a0_0x4cc1d6;return Array[_0x59c689(0xe9)](this[_0x59c689(0x80)][_0x59c689(0xc5)]());}[a0_0x4cc1d6(0x81)](){const _0x2c174c=a0_0x4cc1d6;this[_0x2c174c(0x80)][_0x2c174c(0x93)]();}[a0_0x4cc1d6(0xc1)](_0x5eb7e7,_0x46e8f4){const _0x467787=a0_0x4cc1d6;!this[_0x467787(0x86)][_0x467787(0xc8)]&&(this[_0x467787(0x86)][_0x467787(0xc8)]={}),this[_0x467787(0x86)][_0x467787(0xc8)][_0x5eb7e7]=_0x46e8f4,this[_0x467787(0x80)]['has'](_0x5eb7e7)&&this[_0x467787(0x80)][_0x467787(0xe0)](_0x5eb7e7);}[a0_0x4cc1d6(0xff)](){const _0x3b0d22=a0_0x4cc1d6;if(!this['config'][_0x3b0d22(0xc8)])return[];return Object['keys'](this[_0x3b0d22(0x86)][_0x3b0d22(0xc8)]);}['get'](_0x952a10){const _0x4eefe0=a0_0x4cc1d6,_0x54d500=this[_0x4eefe0(0xff)]();if(typeof _0x952a10===_0x4eefe0(0x8d)){if(_0x952a10<0x0||_0x952a10>=_0x54d500['length'])throw new Error(_0x4eefe0(0xf6)+_0x952a10+_0x4eefe0(0xd4)+_0x54d500['length']);const _0x10b799=_0x54d500[_0x952a10];return this[_0x4eefe0(0x92)](_0x10b799);}else{if(!_0x54d500[_0x4eefe0(0xc0)](_0x952a10))throw new Error(_0x4eefe0(0xd5)+_0x952a10+'\x27\x20not\x20found.\x20Available\x20models:\x20'+_0x54d500['join'](',\x20'));return this[_0x4eefe0(0x92)](_0x952a10);}}}class LovrabetClient{[a0_0x4cc1d6(0x86)];['authManager'];['httpClient'];[a0_0x4cc1d6(0xce)];[a0_0x4cc1d6(0xc8)];constructor(_0x4e93d3){const _0x1444ed=a0_0x4cc1d6;this['validateConfig'](_0x4e93d3),this[_0x1444ed(0x86)]={..._0x4e93d3},this[_0x1444ed(0x117)]=new AuthManager(this[_0x1444ed(0x86)]),this[_0x1444ed(0x90)]=new HttpClient(this[_0x1444ed(0x86)],this[_0x1444ed(0x117)]),this['modelManager']=new ModelManager(this[_0x1444ed(0x90)],this[_0x1444ed(0x86)]),this[_0x1444ed(0xc8)]=new Proxy({},{'get':(_0x20b59c,_0x56be43)=>{const _0xff49dc=_0x1444ed;return this[_0xff49dc(0x92)](_0x56be43);}});}[a0_0x4cc1d6(0xf4)](_0x43af1b){const _0x3f609e=a0_0x4cc1d6;if(_0x43af1b[_0x3f609e(0xb7)]){const _0x32c02c=!!_0x43af1b[_0x3f609e(0xb3)],_0x27e238=!!(_0x43af1b['accessKey']&&_0x43af1b[_0x3f609e(0xeb)]);if(!_0x32c02c&&!_0x27e238)throw new Error('Authentication\x20is\x20required\x20but\x20no\x20auth\x20method\x20provided.\x20Please\x20provide\x20either\x20\x22token\x22\x20or\x20\x22accessKey\x20+\x20secretKey\x22');}}[a0_0x4cc1d6(0xab)](_0x7afd4){const _0x544f37=a0_0x4cc1d6;this[_0x544f37(0x86)][_0x544f37(0xb3)]=_0x7afd4,this[_0x544f37(0x117)][_0x544f37(0xab)](_0x7afd4);}[a0_0x4cc1d6(0xf2)](){const _0x3616d6=a0_0x4cc1d6;return{...this[_0x3616d6(0x86)]};}[a0_0x4cc1d6(0x9b)](){const _0x354555=a0_0x4cc1d6;if(this[_0x354555(0x86)]['serverUrl'])return this['config']['serverUrl'];const _0xb97846=this['config'][_0x354555(0xea)]||_0x354555(0xf8);return getApiEndpoint(_0xb97846);}[a0_0x4cc1d6(0xd2)](_0x5bd215){const _0x2d4e1d=a0_0x4cc1d6;this[_0x2d4e1d(0x86)][_0x2d4e1d(0xea)]=_0x5bd215;}['getEnvironment'](){const _0x1c1a61=a0_0x4cc1d6;return this[_0x1c1a61(0x86)][_0x1c1a61(0xea)]||_0x1c1a61(0xf8);}[a0_0x4cc1d6(0xc6)](){const _0x566b38=a0_0x4cc1d6;return this[_0x566b38(0xce)]['list']();}['getModel'](_0x298f25){const _0x246530=a0_0x4cc1d6;return this['modelManager'][_0x246530(0xe1)](_0x298f25);}}var modelConfigRegistry=new Map();function registerModels(_0x282ab5,_0x57c6ef=CONFIG_NAMES[a0_0x4cc1d6(0xf7)]){modelConfigRegistry['set'](_0x57c6ef,_0x282ab5);}function getRegisteredModels(_0x5180bc){return modelConfigRegistry['get'](_0x5180bc);}function getRegisteredConfigNames(){return Array['from'](modelConfigRegistry['keys']());}function unregisterModels(_0x5dd447){const _0xadd3a9=a0_0x4cc1d6;return modelConfigRegistry[_0xadd3a9(0xe0)](_0x5dd447);}function clearAllRegistrations(){const _0x1a914b=a0_0x4cc1d6;modelConfigRegistry[_0x1a914b(0x93)]();}function createClient(_0x41c124=CONFIG_NAMES[a0_0x4cc1d6(0xf7)]){const _0x549d41=a0_0x4cc1d6;let _0x28e123;if(typeof _0x41c124===_0x549d41(0x96)){const _0x4b0954=getRegisteredModels(_0x41c124);if(!_0x4b0954)throw new Error(ERROR_MESSAGES[_0x549d41(0xcb)](_0x41c124));_0x28e123={'appCode':_0x4b0954[_0x549d41(0xe4)],'env':DEFAULTS['ENV'],'models':_0x4b0954[_0x549d41(0xc8)]};}else{if(typeof _0x41c124===_0x549d41(0xf1)&&_0x549d41(0xe4)in _0x41c124&&'models'in _0x41c124&&!(_0x549d41(0xea)in _0x41c124))_0x28e123={'appCode':_0x41c124[_0x549d41(0xe4)],'env':DEFAULTS[_0x549d41(0x82)],'models':_0x41c124[_0x549d41(0xc8)]};else{if(typeof _0x41c124==='object'&&_0x549d41(0xf0)in _0x41c124){const {apiConfigName:_0x135aa0,..._0x2d4536}=_0x41c124,_0x50d71b=getRegisteredModels(_0x135aa0);if(!_0x50d71b)throw new Error(ERROR_MESSAGES[_0x549d41(0xcb)](_0x135aa0));_0x28e123={'appCode':_0x50d71b[_0x549d41(0xe4)],'env':DEFAULTS[_0x549d41(0x82)],'models':_0x50d71b[_0x549d41(0xc8)],..._0x2d4536};}else{const _0x842d68={'env':DEFAULTS[_0x549d41(0x82)],'models':{}};_0x28e123={..._0x842d68,..._0x41c124};}}}if(!_0x28e123[_0x549d41(0xe4)])throw new Error(ERROR_MESSAGES[_0x549d41(0x9c)]);return new LovrabetClient(_0x28e123);}export{unregisterModels,registerModels,getRegisteredModels,getRegisteredConfigNames,getAvailableEnvironments,getApiEndpoint,createClient,clearAllRegistrations,LovrabetError,HTTP_STATUS,ERROR_MESSAGES,ENVIRONMENTS,DEFAULTS,CONFIG_NAMES,API_PATHS};
|
|
1
|
+
const a0_0x2c7c38=a0_0x370d;(function(_0xc3cf12,_0x2b7712){const _0x1b3faf=a0_0x370d,_0x32dab6=_0xc3cf12();while(!![]){try{const _0x191f79=-parseInt(_0x1b3faf(0x124))/0x1+-parseInt(_0x1b3faf(0x13a))/0x2*(-parseInt(_0x1b3faf(0x13d))/0x3)+-parseInt(_0x1b3faf(0xe9))/0x4*(parseInt(_0x1b3faf(0xe7))/0x5)+parseInt(_0x1b3faf(0xb8))/0x6*(parseInt(_0x1b3faf(0xff))/0x7)+parseInt(_0x1b3faf(0x14b))/0x8*(-parseInt(_0x1b3faf(0x113))/0x9)+-parseInt(_0x1b3faf(0xf3))/0xa*(-parseInt(_0x1b3faf(0xbc))/0xb)+-parseInt(_0x1b3faf(0x100))/0xc*(-parseInt(_0x1b3faf(0x121))/0xd);if(_0x191f79===_0x2b7712)break;else _0x32dab6['push'](_0x32dab6['shift']());}catch(_0x2236ca){_0x32dab6['push'](_0x32dab6['shift']());}}}(a0_0x128a,0xaf007));class UserAuth{['config'];constructor(_0x932a04){this['config']=_0x932a04;}async[a0_0x2c7c38(0x146)](){const _0x1c6c94=a0_0x2c7c38;return{'Authorization':_0x1c6c94(0xc2)+this['config'][_0x1c6c94(0x141)]};}[a0_0x2c7c38(0xd8)](){const _0x883f55=a0_0x2c7c38;return this[_0x883f55(0xf7)][_0x883f55(0x141)];}[a0_0x2c7c38(0x10a)](_0x1ba5f6){const _0x259d2f=a0_0x2c7c38;this[_0x259d2f(0xf7)]['token']=_0x1ba5f6;}}class OpenApiAuth{[a0_0x2c7c38(0xf7)];constructor(_0x268f43){const _0x1a6a19=a0_0x2c7c38;this[_0x1a6a19(0xf7)]=_0x268f43;}async[a0_0x2c7c38(0x146)](){const _0x327277=a0_0x2c7c38,_0x164b3a=Date[_0x327277(0xe2)]()[_0x327277(0x128)](),_0x29b53e=Math[_0x327277(0xcc)]()['toString'](0x24)[_0x327277(0xe8)](0x2),_0x511168=await this[_0x327277(0xc0)](_0x164b3a,_0x29b53e);return{'X-Access-Key':this[_0x327277(0xf7)][_0x327277(0x11b)],'X-Timestamp':_0x164b3a,'X-Nonce':_0x29b53e,'X-Signature':_0x511168};}async[a0_0x2c7c38(0xc0)](_0x472a29,_0x13ce3d){const _0x4b4da1=a0_0x2c7c38,_0x457c0a=''+this['config'][_0x4b4da1(0x11b)]+_0x472a29+_0x13ce3d;if(typeof crypto!==_0x4b4da1(0x107)&&crypto[_0x4b4da1(0x14c)]){const _0x16e3b8=new TextEncoder(),_0x1066b0=_0x16e3b8[_0x4b4da1(0xe3)](this[_0x4b4da1(0xf7)][_0x4b4da1(0x147)]),_0x41825=_0x16e3b8['encode'](_0x457c0a),_0x477de7=await crypto[_0x4b4da1(0x14c)]['importKey'](_0x4b4da1(0xf6),_0x1066b0,{'name':'HMAC','hash':_0x4b4da1(0x139)},![],[_0x4b4da1(0xbb)]),_0x5232cc=await crypto[_0x4b4da1(0x14c)]['sign']('HMAC',_0x477de7,_0x41825),_0xdb6923=Array[_0x4b4da1(0xca)](new Uint8Array(_0x5232cc));return _0xdb6923['map'](_0x4afbe5=>_0x4afbe5[_0x4b4da1(0x128)](0x10)[_0x4b4da1(0x14a)](0x2,'0'))[_0x4b4da1(0xeb)]('');}if(typeof globalThis!==_0x4b4da1(0x107)&&globalThis[_0x4b4da1(0xbd)]){const _0x2e9d58=globalThis[_0x4b4da1(0xbd)];return _0x2e9d58[_0x4b4da1(0xca)](_0x457c0a+this['config']['secretKey'])[_0x4b4da1(0x128)]('base64');}return btoa(_0x457c0a+this[_0x4b4da1(0xf7)][_0x4b4da1(0x147)]);}}class CookieAuth{constructor(){}async['getAuthHeaders'](){return{};}[a0_0x2c7c38(0xb5)](){const _0x1ca619=a0_0x2c7c38;return typeof window!==_0x1ca619(0x107)&&typeof document!==_0x1ca619(0x107);}}class AuthManager{[a0_0x2c7c38(0xf7)];[a0_0x2c7c38(0xea)];[a0_0x2c7c38(0xf8)];[a0_0x2c7c38(0x131)];constructor(_0x22f708){const _0x419a79=a0_0x2c7c38;this[_0x419a79(0xf7)]=_0x22f708,this[_0x419a79(0xdf)]();}['initAuthMethods'](){const _0x2c1728=a0_0x2c7c38;this[_0x2c1728(0xf7)][_0x2c1728(0x141)]&&(this['userAuth']=new UserAuth({'token':this[_0x2c1728(0xf7)][_0x2c1728(0x141)]})),this['config'][_0x2c1728(0x11b)]&&this[_0x2c1728(0xf7)][_0x2c1728(0x147)]&&(this[_0x2c1728(0xf8)]=new OpenApiAuth({'accessKey':this['config'][_0x2c1728(0x11b)],'secretKey':this['config']['secretKey']})),!this[_0x2c1728(0xf7)][_0x2c1728(0x141)]&&!this[_0x2c1728(0xf7)][_0x2c1728(0x11b)]&&!this[_0x2c1728(0xf7)]['secretKey']&&(this[_0x2c1728(0x131)]=new CookieAuth());}async[a0_0x2c7c38(0x146)](){const _0x9197ac=a0_0x2c7c38,_0x41792d={};if(this['userAuth']){const _0x1eba38=await this[_0x9197ac(0xea)][_0x9197ac(0x146)]();Object[_0x9197ac(0xb0)](_0x41792d,_0x1eba38);}else{if(this[_0x9197ac(0xf8)]){const _0x3f126e=await this[_0x9197ac(0xf8)]['getAuthHeaders']();Object[_0x9197ac(0xb0)](_0x41792d,_0x3f126e);}else{if(this[_0x9197ac(0x131)]){const _0x254f4b=await this[_0x9197ac(0x131)]['getAuthHeaders']();Object[_0x9197ac(0xb0)](_0x41792d,_0x254f4b);}}}return _0x41792d;}async[a0_0x2c7c38(0x11a)](){const _0x53800e=a0_0x2c7c38;try{if(this[_0x53800e(0x131)]?.[_0x53800e(0xb5)]())return!![];const _0x706e63=await this['getAuthHeaders']();return Object[_0x53800e(0xcf)](_0x706e63)[_0x53800e(0x129)]>0x0;}catch{return![];}}[a0_0x2c7c38(0xd4)](){const _0x498ccc=a0_0x2c7c38;return!!this[_0x498ccc(0x131)];}[a0_0x2c7c38(0x10a)](_0x429824){const _0x324e2a=a0_0x2c7c38;this[_0x324e2a(0xf7)][_0x324e2a(0x141)]=_0x429824,this['userAuth']=new UserAuth({'token':_0x429824}),this[_0x324e2a(0x131)]=undefined;}}class LovrabetError extends Error{[a0_0x2c7c38(0xcb)];[a0_0x2c7c38(0xc7)];[a0_0x2c7c38(0xd0)];[a0_0x2c7c38(0x110)];constructor(_0x2f5985,_0x57f6ec,_0x38475c,_0x1be220,_0x1ed873){const _0x1c6c71=a0_0x2c7c38;super(_0x2f5985),this['name']=_0x1c6c71(0xae),this[_0x1c6c71(0xcb)]=_0x57f6ec,this[_0x1c6c71(0xc7)]=_0x38475c,this[_0x1c6c71(0xd0)]=_0x1be220,this[_0x1c6c71(0x110)]=_0x1ed873;}[a0_0x2c7c38(0x12b)](){const _0x21fdd1=a0_0x2c7c38;return{'name':this[_0x21fdd1(0xc4)],'message':this['message'],'status':this[_0x21fdd1(0xcb)],'code':this['code'],'data':this[_0x21fdd1(0xd0)]};}}function createErrorHandler(_0x23ed14){return _0x23b39e=>{const _0x59b627=a0_0x370d,_0x49588a=_0x23b39e instanceof LovrabetError?_0x23b39e:new LovrabetError(_0x23b39e[_0x59b627(0xba)]||_0x59b627(0xfe),_0x23b39e[_0x59b627(0xcb)],_0x23b39e[_0x59b627(0xc7)],_0x23b39e['data'],_0x23b39e);return typeof globalThis!==_0x59b627(0x107)&&globalThis[_0x59b627(0xfb)]?.['env']?.[_0x59b627(0x13c)]!==_0x59b627(0xd5)&&console[_0x59b627(0xdb)](_0x59b627(0x145),_0x49588a),_0x23ed14?.(_0x49588a),Promise['reject'](_0x49588a);};}var CONFIG_NAMES={'DEFAULT':a0_0x2c7c38(0xad),'PROD':a0_0x2c7c38(0xee),'DEV':'dev','TEST':a0_0x2c7c38(0xc1)},ENVIRONMENTS={'ONLINE':a0_0x2c7c38(0x116),'DAILY':a0_0x2c7c38(0xdd)},HTTP_STATUS={'OK':0xc8,'UNAUTHORIZED':0x191,'FORBIDDEN':0x193,'NOT_FOUND':0x194,'INTERNAL_ERROR':0x1f4},DEFAULTS={'ENV':ENVIRONMENTS['ONLINE'],'TIMEOUT':0x7530,'RETRY_COUNT':0x3,'PAGE_SIZE':0x14,'CURRENT_PAGE':0x1},ERROR_MESSAGES={'APP_CODE_REQUIRED':'appCode\x20is\x20required.\x20Please\x20provide\x20it\x20in\x20the\x20config\x20or\x20register\x20models\x20first.','CONFIG_NOT_FOUND':_0x2621af=>a0_0x2c7c38(0xab)+_0x2621af+a0_0x2c7c38(0xf1),'INVALID_ENV':a0_0x2c7c38(0x12e),'NETWORK_ERROR':a0_0x2c7c38(0x103),'UNAUTHORIZED':'Unauthorized\x20access','FORBIDDEN':a0_0x2c7c38(0x115),'NOT_FOUND':a0_0x2c7c38(0x11c),'SERVER_ERROR':a0_0x2c7c38(0xf9)},API_PATHS={'BASE':a0_0x2c7c38(0xc5),'LIST':'','DETAIL':'/{id}'},API_ENDPOINTS={[ENVIRONMENTS[a0_0x2c7c38(0xb2)]]:'https://runtime.lovrabet.com',[ENVIRONMENTS[a0_0x2c7c38(0x112)]]:a0_0x2c7c38(0xa9)};function getApiEndpoint(_0xf10b7b){return API_ENDPOINTS[_0xf10b7b];}function getAvailableEnvironments(){const _0x565ebb=a0_0x2c7c38;return Object[_0x565ebb(0xcf)](API_ENDPOINTS);}var cacheCookie='';function getCookie(){return cacheCookie;}var processResponse=async _0x3536d8=>{const _0x2c87aa=a0_0x2c7c38,_0x23ba17=await _0x3536d8['json']();if(!_0x23ba17[_0x2c87aa(0x125)]){const _0x46a630=new Error(_0x23ba17[_0x2c87aa(0x126)]);_0x46a630[_0x2c87aa(0xa5)]=_0x23ba17;throw _0x46a630;}return _0x23ba17[_0x2c87aa(0xd0)];};function getTraceparent(){const _0x54e47f=a0_0x2c7c38;try{return document[_0x54e47f(0xf5)](_0x54e47f(0x10f))?.[_0x54e47f(0x133)]('content')||undefined;}catch(_0x1f8dc6){return;}}function generateTraceparent(){const _0xddd267=a0_0x2c7c38,_0x51f00e=getTraceparent(),_0x5f0da1=_0x51f00e?_0x51f00e[_0xddd267(0xcd)]('-')[0x1]:Array[_0xddd267(0xca)](crypto[_0xddd267(0x13e)](new Uint8Array(0x10)))['map'](_0x1d3828=>_0x1d3828[_0xddd267(0x128)](0x10)[_0xddd267(0x14a)](0x2,'0'))[_0xddd267(0xeb)](''),_0x53bfce=Array[_0xddd267(0xca)](crypto['getRandomValues'](new Uint8Array(0x8)))[_0xddd267(0x140)](_0x1b2761=>_0x1b2761[_0xddd267(0x128)](0x10)[_0xddd267(0x14a)](0x2,'0'))[_0xddd267(0xeb)](''),_0xb8c5a7='01';return _0xddd267(0x122)+_0x5f0da1+'-'+_0x53bfce+'-'+_0xb8c5a7;}function a0_0x370d(_0x409fa8,_0x49b43c){const _0x128a1e=a0_0x128a();return a0_0x370d=function(_0x370d6a,_0x563841){_0x370d6a=_0x370d6a-0xa5;let _0x45a378=_0x128a1e[_0x370d6a];return _0x45a378;},a0_0x370d(_0x409fa8,_0x49b43c);}var get=async(_0x923ed,_0x19473e,_0x11db79={})=>{const _0x2ecef5=a0_0x2c7c38,_0x2171e7=new URL(_0x923ed);if(_0x19473e)for(const _0x11104c of Object[_0x2ecef5(0xcf)](_0x19473e)){_0x2171e7['searchParams'][_0x2ecef5(0xe6)](_0x11104c,String(_0x19473e[_0x11104c]));}const _0x52e79c={'Content-Type':_0x2ecef5(0xf2),..._0x11db79['headers'],'traceparent':generateTraceparent()};getCookie()&&(_0x52e79c[_0x2ecef5(0x12d)]=getCookie());const _0x2de329=await fetch(_0x2171e7['toString'](),{..._0x11db79,'headers':_0x52e79c,'credentials':_0x2ecef5(0x123)});if(_0x2de329[_0x2ecef5(0x135)]){window[_0x2ecef5(0xd9)][_0x2ecef5(0x111)]=_0x2de329[_0x2ecef5(0x132)];return;}return await processResponse(_0x2de329);},post=async(_0xeb1748,_0x2783b4,_0x4f1073={})=>{const _0x5e5c48=a0_0x2c7c38,_0x18c7ac={'Content-Type':_0x5e5c48(0xf2),..._0x4f1073[_0x5e5c48(0xa7)],'traceparent':generateTraceparent()};getCookie()&&(_0x18c7ac[_0x5e5c48(0x12d)]=getCookie());const _0x532991=await fetch(_0xeb1748,{..._0x4f1073,'method':'POST','headers':_0x18c7ac,'body':_0x2783b4&&JSON[_0x5e5c48(0x118)](_0x2783b4),'credentials':_0x5e5c48(0x123)});if(_0x532991[_0x5e5c48(0x135)]){window['location'][_0x5e5c48(0x111)]=_0x532991[_0x5e5c48(0x132)];return;}return await processResponse(_0x532991);};class HttpClient{['config'];[a0_0x2c7c38(0x148)];[a0_0x2c7c38(0xde)];constructor(_0x4b3420,_0x246111){const _0xadf4d5=a0_0x2c7c38;this[_0xadf4d5(0xf7)]=_0x4b3420,this[_0xadf4d5(0x148)]=_0x246111,this[_0xadf4d5(0xde)]=createErrorHandler(_0x4b3420[_0xadf4d5(0x13f)]?.[_0xadf4d5(0x117)]);}['getBaseUrl'](){const _0x40880f=a0_0x2c7c38;if(this[_0x40880f(0xf7)]['serverUrl'])return this[_0x40880f(0xf7)][_0x40880f(0xb4)];const _0x32fab2=this[_0x40880f(0xf7)][_0x40880f(0x12f)]||'online';return getApiEndpoint(_0x32fab2);}['getFullUrl'](_0x196163){const _0x3fbba8=a0_0x2c7c38;return _0x196163[_0x3fbba8(0x109)](_0x3fbba8(0x106))?_0x196163:''+this[_0x3fbba8(0xac)]()+_0x196163;}async[a0_0x2c7c38(0x13b)](_0x3f5709){const _0x327665=a0_0x2c7c38,_0xcbb4a=await this[_0x327665(0x148)][_0x327665(0x146)](),_0xa52c98={..._0x3f5709,'headers':{..._0xcbb4a,..._0x3f5709?.[_0x327665(0xa7)]}};return this['authManager'][_0x327665(0xd4)]()&&(_0xa52c98[_0x327665(0xbf)]=_0x327665(0x123)),_0xa52c98;}async[a0_0x2c7c38(0xb1)](_0x59eb37){const _0x5c9902=a0_0x2c7c38;try{return await _0x59eb37();}catch(_0x1601cf){return this[_0x5c9902(0xde)](_0x1601cf);}}async[a0_0x2c7c38(0x11f)](_0x57ae85,_0x1ed8c6,_0x4ca35d,_0x13c3ca){const _0x4adc4c=a0_0x2c7c38,_0x491a5b=this[_0x4adc4c(0xef)](_0x1ed8c6),_0x1b323f=await this['prepareRequestInit']({..._0x13c3ca,'method':_0x57ae85,'headers':{'Content-Type':_0x4adc4c(0xf2),..._0x13c3ca?.['headers']}}),_0x5416c3=new AbortController(),_0x886de2=setTimeout(()=>{const _0x54f47c=_0x4adc4c;_0x5416c3[_0x54f47c(0x101)]();},this[_0x4adc4c(0xf7)]['options']?.[_0x4adc4c(0x136)]||0x7530);try{const _0x49c052=await fetch(_0x491a5b,{..._0x1b323f,'body':_0x4ca35d?JSON[_0x4adc4c(0x118)](_0x4ca35d):undefined,'signal':_0x5416c3[_0x4adc4c(0xa8)]});clearTimeout(_0x886de2);if(!_0x49c052['ok']){const _0x1d2421=await _0x49c052[_0x4adc4c(0x144)]()[_0x4adc4c(0xe1)](()=>({}));throw new LovrabetError(_0x1d2421[_0x4adc4c(0xba)]||'HTTP\x20'+_0x49c052['status']+':\x20'+_0x49c052[_0x4adc4c(0x105)],_0x49c052[_0x4adc4c(0xcb)],_0x1d2421[_0x4adc4c(0xc7)],_0x1d2421);}return await _0x49c052[_0x4adc4c(0x144)]();}catch(_0x54973c){clearTimeout(_0x886de2);if(_0x54973c['name']===_0x4adc4c(0x14d))throw new LovrabetError('Request\x20timeout',0x198,_0x4adc4c(0xd6));throw _0x54973c;}}async[a0_0x2c7c38(0xce)](_0x16be76,_0x876063,_0x16fd50){const _0x38f559=a0_0x2c7c38;return this[_0x38f559(0xb1)](async()=>{const _0x3bb741=_0x38f559,_0x59ad26=this[_0x3bb741(0xef)](_0x16be76),_0xdc14a4=await this[_0x3bb741(0x13b)](_0x16fd50);return await get(_0x59ad26,_0x876063,_0xdc14a4);});}async[a0_0x2c7c38(0x138)](_0xd24776,_0x1f0b25,_0x5e3971){return this['executeWithErrorHandling'](async()=>{const _0x332292=this['getFullUrl'](_0xd24776),_0x3baf5c=await this['prepareRequestInit'](_0x5e3971);return await post(_0x332292,_0x1f0b25,_0x3baf5c);});}async[a0_0x2c7c38(0xc6)](_0x2c52a5,_0x99518e,_0x3acbf1){return this['executeWithErrorHandling'](async()=>{const _0x2d2129=a0_0x370d;return this[_0x2d2129(0x11f)]('PUT',_0x2c52a5,_0x99518e,_0x3acbf1);});}async[a0_0x2c7c38(0x104)](_0x7aee48,_0x576285){return this['executeWithErrorHandling'](async()=>{const _0x4550a2=a0_0x370d;return this[_0x4550a2(0x11f)]('DELETE',_0x7aee48,undefined,_0x576285);});}async[a0_0x2c7c38(0xd3)](_0x1e2bc3,_0x53813b,_0x45ed1e,_0x5d3469){const _0x3d3599=a0_0x2c7c38;switch(_0x1e2bc3){case'GET':return this[_0x3d3599(0xce)](_0x53813b,_0x45ed1e,_0x5d3469);case _0x3d3599(0x12a):return this[_0x3d3599(0x138)](_0x53813b,_0x45ed1e,_0x5d3469);case _0x3d3599(0x11e):return this[_0x3d3599(0xc6)](_0x53813b,_0x45ed1e,_0x5d3469);case _0x3d3599(0xc8):return this['delete'](_0x53813b,_0x5d3469);default:throw new LovrabetError(_0x3d3599(0x12c)+_0x1e2bc3,0x190,_0x3d3599(0xd1));}}}class BaseModel{[a0_0x2c7c38(0xfd)];['httpClient'];[a0_0x2c7c38(0xf7)];[a0_0x2c7c38(0xec)];constructor(_0x16c29d,_0x3ce372,_0x425234){const _0x301dfd=a0_0x2c7c38;this['modelName']=_0x16c29d,this[_0x301dfd(0xd7)]=_0x3ce372,this[_0x301dfd(0xec)]=_0x425234[_0x301dfd(0xec)],this['config']=this[_0x301dfd(0xf4)](_0x16c29d,_0x425234);}[a0_0x2c7c38(0xf4)](_0x1a3143,_0x33a65d){const _0x2d7eb1=a0_0x2c7c38;if(_0x33a65d[_0x2d7eb1(0x134)]?.[_0x1a3143])return _0x33a65d['models'][_0x1a3143];throw new Error(_0x2d7eb1(0xaa)+_0x1a3143+'\x22\x20not\x20configured.\x20Please\x20provide\x20datasetId\x20in\x20config.models\x20or\x20use\x20registerModels()\x20to\x20configure\x20it.');}['getApiPath'](){const _0x368b65=a0_0x2c7c38;return'/api/'+this[_0x368b65(0xec)]+'/'+this[_0x368b65(0xf7)]['datasetId'];}async[a0_0x2c7c38(0xb3)](_0x39f32c){const _0x55526c=this['getApiPath']()+'/getList',_0x157eeb={'currentPage':0x1,'pageSize':0x14,..._0x39f32c};return this['httpClient']['post'](_0x55526c,_0x157eeb);}async[a0_0x2c7c38(0x10d)](_0x3b8ddb){const _0x19e5d2=a0_0x2c7c38,_0x4b31c6=this[_0x19e5d2(0x119)]()+_0x19e5d2(0x130);return this['httpClient'][_0x19e5d2(0x138)](_0x4b31c6,{'id':_0x3b8ddb});}async[a0_0x2c7c38(0xe0)](_0x4c05a0){const _0x7e1eec=a0_0x2c7c38,_0x374415=this['getApiPath']()+_0x7e1eec(0xc3);return this[_0x7e1eec(0xd7)]['post'](_0x374415,_0x4c05a0);}async[a0_0x2c7c38(0x108)](_0x257514,_0x1e1f2e){const _0x170a31=a0_0x2c7c38,_0x3e05ba=this[_0x170a31(0x119)]()+_0x170a31(0xaf);return this['httpClient']['post'](_0x3e05ba,{'id':_0x257514,..._0x1e1f2e});}async[a0_0x2c7c38(0x104)](_0x2aa618){const _0x6052e0=a0_0x2c7c38,_0x2b1033=this['getApiPath']()+_0x6052e0(0x10e);await this['httpClient'][_0x6052e0(0x138)](_0x2b1033,{'id':_0x2aa618});}[a0_0x2c7c38(0x149)](){const _0x151c8d=a0_0x2c7c38;return{...this[_0x151c8d(0xf7)]};}[a0_0x2c7c38(0xd2)](){const _0x3342f1=a0_0x2c7c38;return this[_0x3342f1(0xfd)];}}class ModelManager{[a0_0x2c7c38(0xd7)];[a0_0x2c7c38(0xf7)];[a0_0x2c7c38(0x120)]=new Map();constructor(_0x275933,_0x40ae85){const _0x291782=a0_0x2c7c38;this[_0x291782(0xd7)]=_0x275933,this[_0x291782(0xf7)]=_0x40ae85;}[a0_0x2c7c38(0x10b)](_0x35b528){const _0xb8b04f=a0_0x2c7c38;if(!this[_0xb8b04f(0x120)]['has'](_0x35b528)){const _0x636d18=new BaseModel(_0x35b528,this['httpClient'],this[_0xb8b04f(0xf7)]);this[_0xb8b04f(0x120)]['set'](_0x35b528,_0x636d18);}return this[_0xb8b04f(0x120)][_0xb8b04f(0xce)](_0x35b528);}[a0_0x2c7c38(0xbe)](){const _0x3a8077=a0_0x2c7c38;return Array[_0x3a8077(0xca)](this['modelCache']['keys']());}[a0_0x2c7c38(0xdc)](){const _0x432aee=a0_0x2c7c38;this[_0x432aee(0x120)][_0x432aee(0x11d)]();}[a0_0x2c7c38(0xfc)](_0x2b01f8,_0x275823){const _0x5ec554=a0_0x2c7c38;!this[_0x5ec554(0xf7)][_0x5ec554(0x134)]&&(this['config'][_0x5ec554(0x134)]={}),this[_0x5ec554(0xf7)]['models'][_0x2b01f8]=_0x275823,this[_0x5ec554(0x120)][_0x5ec554(0xb6)](_0x2b01f8)&&this[_0x5ec554(0x120)][_0x5ec554(0x104)](_0x2b01f8);}[a0_0x2c7c38(0x127)](){const _0x2d4ffe=a0_0x2c7c38;if(!this[_0x2d4ffe(0xf7)][_0x2d4ffe(0x134)])return[];return Object['keys'](this[_0x2d4ffe(0xf7)][_0x2d4ffe(0x134)]);}['get'](_0x4d87db){const _0x26e162=a0_0x2c7c38,_0x2c6c32=this[_0x26e162(0x127)]();if(typeof _0x4d87db===_0x26e162(0xa6)){if(_0x4d87db<0x0||_0x4d87db>=_0x2c6c32[_0x26e162(0x129)])throw new Error(_0x26e162(0xf0)+_0x4d87db+_0x26e162(0x10c)+_0x2c6c32[_0x26e162(0x129)]);const _0x484691=_0x2c6c32[_0x4d87db];return this[_0x26e162(0x10b)](_0x484691);}else{if(!_0x2c6c32['includes'](_0x4d87db))throw new Error(_0x26e162(0x137)+_0x4d87db+_0x26e162(0x102)+_0x2c6c32[_0x26e162(0xeb)](',\x20'));return this[_0x26e162(0x10b)](_0x4d87db);}}}class LovrabetClient{['config'];['authManager'];[a0_0x2c7c38(0xd7)];[a0_0x2c7c38(0xb9)];['models'];constructor(_0x583771){const _0x4a0f51=a0_0x2c7c38;this[_0x4a0f51(0x143)](_0x583771),this[_0x4a0f51(0xf7)]={..._0x583771},this[_0x4a0f51(0x148)]=new AuthManager(this[_0x4a0f51(0xf7)]),this[_0x4a0f51(0xd7)]=new HttpClient(this[_0x4a0f51(0xf7)],this[_0x4a0f51(0x148)]),this[_0x4a0f51(0xb9)]=new ModelManager(this[_0x4a0f51(0xd7)],this[_0x4a0f51(0xf7)]),this[_0x4a0f51(0x134)]=new Proxy({},{'get':(_0xc561d9,_0x51e57b)=>{const _0x59b874=_0x4a0f51;return this[_0x59b874(0x10b)](_0x51e57b);}});}[a0_0x2c7c38(0x143)](_0x254094){const _0x40adb3=a0_0x2c7c38;if(_0x254094[_0x40adb3(0xe4)]){const _0x32196c=!!_0x254094['token'],_0x568e4b=!!(_0x254094[_0x40adb3(0x11b)]&&_0x254094[_0x40adb3(0x147)]);if(!_0x32196c&&!_0x568e4b)throw new Error(_0x40adb3(0x142));}}[a0_0x2c7c38(0x10a)](_0x5e687c){const _0x45385d=a0_0x2c7c38;this['config'][_0x45385d(0x141)]=_0x5e687c,this['authManager'][_0x45385d(0x10a)](_0x5e687c);}['getConfig'](){const _0x5987db=a0_0x2c7c38;return{...this[_0x5987db(0xf7)]};}['getBaseUrl'](){const _0x22d736=a0_0x2c7c38;if(this['config'][_0x22d736(0xb4)])return this[_0x22d736(0xf7)][_0x22d736(0xb4)];const _0x118244=this[_0x22d736(0xf7)][_0x22d736(0x12f)]||_0x22d736(0x116);return getApiEndpoint(_0x118244);}[a0_0x2c7c38(0xb7)](_0x20aa59){const _0x56f69c=a0_0x2c7c38;this[_0x56f69c(0xf7)][_0x56f69c(0x12f)]=_0x20aa59;}['getEnvironment'](){const _0x367642=a0_0x2c7c38;return this['config']['env']||_0x367642(0x116);}['getModelList'](){const _0x2b3ff3=a0_0x2c7c38;return this[_0x2b3ff3(0xb9)][_0x2b3ff3(0x127)]();}[a0_0x2c7c38(0x10b)](_0x5056c5){const _0x2e0fd0=a0_0x2c7c38;return this['modelManager'][_0x2e0fd0(0xce)](_0x5056c5);}}var modelConfigRegistry=new Map();function registerModels(_0x16276f,_0xb9d47=CONFIG_NAMES[a0_0x2c7c38(0xda)]){const _0x412634=a0_0x2c7c38;modelConfigRegistry[_0x412634(0xe5)](_0xb9d47,_0x16276f);}function getRegisteredModels(_0x429092){const _0x4b99fc=a0_0x2c7c38;return modelConfigRegistry[_0x4b99fc(0xce)](_0x429092);}function getRegisteredConfigNames(){const _0x50de37=a0_0x2c7c38;return Array['from'](modelConfigRegistry[_0x50de37(0xcf)]());}function unregisterModels(_0x132e30){const _0x411c9c=a0_0x2c7c38;return modelConfigRegistry[_0x411c9c(0x104)](_0x132e30);}function clearAllRegistrations(){const _0x158150=a0_0x2c7c38;modelConfigRegistry[_0x158150(0x11d)]();}function createClient(_0x296dfa=CONFIG_NAMES[a0_0x2c7c38(0xda)]){const _0x57ed81=a0_0x2c7c38;let _0x112497;if(typeof _0x296dfa===_0x57ed81(0xc9)){const _0x4b932a=getRegisteredModels(_0x296dfa);if(!_0x4b932a)throw new Error(ERROR_MESSAGES[_0x57ed81(0x114)](_0x296dfa));_0x112497={'appCode':_0x4b932a[_0x57ed81(0xec)],'env':DEFAULTS[_0x57ed81(0xed)],'models':_0x4b932a[_0x57ed81(0x134)]};}else{if(typeof _0x296dfa===_0x57ed81(0xfa)&&'appCode'in _0x296dfa&&_0x57ed81(0x134)in _0x296dfa&&!(_0x57ed81(0x12f)in _0x296dfa))_0x112497={'appCode':_0x296dfa[_0x57ed81(0xec)],'env':DEFAULTS[_0x57ed81(0xed)],'models':_0x296dfa[_0x57ed81(0x134)]};else{if(typeof _0x296dfa==='object'&&'apiConfigName'in _0x296dfa){const {apiConfigName:_0x3652cf,..._0x3c0105}=_0x296dfa,_0x1a65a7=getRegisteredModels(_0x3652cf);if(!_0x1a65a7)throw new Error(ERROR_MESSAGES[_0x57ed81(0x114)](_0x3652cf));_0x112497={'appCode':_0x1a65a7['appCode'],'env':DEFAULTS[_0x57ed81(0xed)],'models':_0x1a65a7['models'],..._0x3c0105};}else{const _0x4ba751={'env':DEFAULTS[_0x57ed81(0xed)],'models':{}};_0x112497={..._0x4ba751,..._0x296dfa};}}}if(!_0x112497['appCode'])throw new Error(ERROR_MESSAGES['APP_CODE_REQUIRED']);return new LovrabetClient(_0x112497);}function a0_0x128a(){const _0x1c5a64=['/create','name','/api/{appCode}/{datasetId}','put','code','DELETE','string','from','status','random','split','get','keys','data','INVALID_METHOD','getModelName','request','isCookieAuth','production','TIMEOUT','httpClient','getToken','location','DEFAULT','error','clearCache','daily','errorHandler','initAuthMethods','create','catch','now','encode','requiresAuth','set','append','75WcHxHv','substring','46560ciZhdp','userAuth','join','appCode','ENV','prod','getFullUrl','Model\x20index\x20','\x22\x20not\x20found.\x20Please\x20register\x20it\x20first\x20using\x20registerModels().','application/json','2000uUBFvi','resolveModelConfig','querySelector','raw','config','openApiAuth','Internal\x20server\x20error','object','process','addModel','modelName','Unknown\x20error','7RJLWrO','536460YSSRLh','abort','\x27\x20not\x20found.\x20Available\x20models:\x20','Network\x20request\x20failed','delete','statusText','http','undefined','update','startsWith','setToken','getModel','\x20is\x20out\x20of\x20range.\x20Available\x20models:\x20','getOne','/delete','meta[name=\x22traceparent\x22]','originalError','href','DAILY','9wzIbfg','CONFIG_NOT_FOUND','Access\x20forbidden','online','onError','stringify','getApiPath','validateAuth','accessKey','Resource\x20not\x20found','clear','PUT','makeRequest','modelCache','533rHWJMd','00-','include','573946mLxWPi','success','errorMsg','list','toString','length','POST','toJSON','Unsupported\x20method:\x20','Cookie','Invalid\x20environment.\x20Must\x20be\x20\x22online\x22\x20or\x20\x22daily\x22.','env','/getOne','cookieAuth','url','getAttribute','models','redirected','timeout','Model\x20\x27','post','SHA-256','8842DKnuJC','prepareRequestInit','NODE_ENV','60PCNsmb','getRandomValues','options','map','token','Authentication\x20is\x20required\x20but\x20no\x20auth\x20method\x20provided.\x20Please\x20provide\x20either\x20\x22token\x22\x20or\x20\x22accessKey\x20+\x20secretKey\x22','validateConfig','json','[Lovrabet\x20SDK\x20Error]','getAuthHeaders','secretKey','authManager','getConfig','padStart','9229552zRHDDS','subtle','AbortError','response','number','headers','signal','https://daily-runtime.lovrabet.com','Model\x20\x22','Model\x20config\x20with\x20name\x20\x22','getBaseUrl','default','LovrabetError','/update','assign','executeWithErrorHandling','ONLINE','getList','serverUrl','isValid','has','setEnvironment','1134732UynvfU','modelManager','message','sign','27973tYNYVh','Buffer','getCachedModels','credentials','generateSignature','test','Bearer\x20'];a0_0x128a=function(){return _0x1c5a64;};return a0_0x128a();}export{unregisterModels,registerModels,getRegisteredModels,getRegisteredConfigNames,getAvailableEnvironments,getApiEndpoint,createClient,clearAllRegistrations,LovrabetError,HTTP_STATUS,ERROR_MESSAGES,ENVIRONMENTS,DEFAULTS,CONFIG_NAMES,API_PATHS};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lovrabet/sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "rm -rf dist && bun build index.ts --outdir=dist --target=browser --format=esm && javascript-obfuscator dist --output dist && npm run types",
|
|
17
17
|
"types": "npx tsc --emitDeclarationOnly --declaration --outDir dist index.ts",
|
|
18
|
+
"beta-release": "bun run build && sh scripts/update-beta-version.sh && git push && git push origin --tag && bun publish",
|
|
18
19
|
"release": "bun run build && bun pm version patch && git push && git push origin --tag && bun publish"
|
|
19
20
|
},
|
|
20
21
|
"files": [
|
|
@@ -27,4 +28,4 @@
|
|
|
27
28
|
"peerDependencies": {
|
|
28
29
|
"typescript": "^5"
|
|
29
30
|
}
|
|
30
|
-
}
|
|
31
|
+
}
|