UNPKG

@ks-opdev/cli

Version:

ksodev: A CLI based on the WPS Open Platform

1 lines 5.42 kB
const a13_0x284872=a13_0x4130;function a13_0x5053(){const _0x271e03=['handleError','1496340CkLvlA','DELETE','8jKNdph','initialized','GET','data','11781007zQbBJv','1052133LSqhoM','cluster_token','getCurrentCluster','toString','axiosInstance','baseURL','delete','request','from','SUCCESS','Cookie','9194298UsfnNS','timeout','code','manageApi','handleBusinessCode','PATCH','801EeWWqv','20933WWtkWL','application/json','utf-8','PUT','base64','Client\x20not\x20initialized','),\x20run\x20login\x20command\x20first','6lMrktj','Agent','put','response','POST','User\x20not\x20login\x20(url=','/c/manage','USER_NOT_LOGIN','skipTLSVerify','patch','initialize','cookieStr','HTTP\x20','baseUrl','67664ctEGAc','Business\x20error:\x20','790220ehACaE','720pzgqNQ','cluster','create','status'];a13_0x5053=function(){return _0x271e03;};return a13_0x5053();}(function(_0x249d53,_0x5aad26){const _0x5a23be=a13_0x4130,_0x5312d9=_0x249d53();while(!![]){try{const _0x5eb1be=parseInt(_0x5a23be(0x118))/0x1+parseInt(_0x5a23be(0x138))/0x2*(-parseInt(_0x5a23be(0x11f))/0x3)+-parseInt(_0x5a23be(0x11a))/0x4*(parseInt(_0x5a23be(0x148))/0x5)+parseInt(_0x5a23be(0x12a))/0x6+-parseInt(_0x5a23be(0x11e))/0x7+parseInt(_0x5a23be(0x146))/0x8*(parseInt(_0x5a23be(0x130))/0x9)+parseInt(_0x5a23be(0x149))/0xa*(parseInt(_0x5a23be(0x131))/0xb);if(_0x5eb1be===_0x5aad26)break;else _0x5312d9['push'](_0x5312d9['shift']());}catch(_0xae6f4e){_0x5312d9['push'](_0x5312d9['shift']());}}}(a13_0x5053,0xd3bcf));import a13_0x4d5ec3 from'axios';function a13_0x4130(_0x43394f,_0x13cc91){const _0x5053a4=a13_0x5053();return a13_0x4130=function(_0x4130c7,_0x39c321){_0x4130c7=_0x4130c7-0x114;let _0x416dc2=_0x5053a4[_0x4130c7];return _0x416dc2;},a13_0x4130(_0x43394f,_0x13cc91);}import a13_0x4a0baf from'node:https';import{ConfigManager}from'../utils/config.js';export class SimpleHttpClient{[a13_0x284872(0x123)]=null;['baseUrl']='';[a13_0x284872(0x143)]='';[a13_0x284872(0x11b)]=![];async[a13_0x284872(0x125)](_0x4697b9,_0x3f8bc1){const _0x79f6b=a13_0x284872;return this['request'](_0x79f6b(0x119),undefined,_0x3f8bc1);}async['get'](_0x23e9c7,_0x3e119c){const _0x4cf8f1=a13_0x284872;return this['request'](_0x4cf8f1(0x11c),_0x23e9c7,undefined,_0x3e119c);}async[a13_0x284872(0x142)](_0x483a49){const _0x4c9560=a13_0x284872;if(_0x483a49?.['baseURL'])this['baseUrl']=_0x483a49[_0x4c9560(0x124)];else{const _0x37b079=ConfigManager[_0x4c9560(0x121)]();_0x37b079?.[_0x4c9560(0x114)]&&(this[_0x4c9560(0x145)]=_0x37b079[_0x4c9560(0x114)]);}if(!this[_0x4c9560(0x145)])throw new Error('BaseURL\x20is\x20required');const _0x44b851=ConfigManager[_0x4c9560(0x121)]();if(_0x44b851?.[_0x4c9560(0x120)]){const _0x4ee532=Buffer[_0x4c9560(0x127)](_0x44b851['cluster_token'],_0x4c9560(0x135))[_0x4c9560(0x122)](_0x4c9560(0x133));this[_0x4c9560(0x143)]='wps_sid='+_0x4ee532;}this[_0x4c9560(0x123)]=a13_0x4d5ec3[_0x4c9560(0x115)]({'baseURL':this['baseUrl'],'headers':{'Content-Type':_0x4c9560(0x132)},'httpsAgent':new a13_0x4a0baf[(_0x4c9560(0x139))]({'rejectUnauthorized':!_0x483a49?.[_0x4c9560(0x140)]}),'timeout':_0x483a49?.[_0x4c9560(0x12b)]||0x7530}),this[_0x4c9560(0x11b)]=!![];}async[a13_0x284872(0x12d)](_0x2a17c3,_0x16b3a8,_0x15385e,_0x512208){const _0x43fc44=a13_0x284872,_0x18d7c9=_0x16b3a8['startsWith'](_0x43fc44(0x13e))?_0x16b3a8:_0x43fc44(0x13e)+_0x16b3a8;return this[_0x43fc44(0x126)](_0x2a17c3,_0x18d7c9,_0x15385e,_0x512208);}async[a13_0x284872(0x141)](_0x25c9a7,_0x1cca12,_0x16db8d){const _0x513393=a13_0x284872;return this['request'](_0x513393(0x12f),_0x25c9a7,_0x1cca12,_0x16db8d);}async['post'](_0x159a59,_0x3aba2a,_0x5f54c2){const _0x216cdb=a13_0x284872;return this['request'](_0x216cdb(0x13c),_0x159a59,_0x3aba2a,_0x5f54c2);}async[a13_0x284872(0x13a)](_0x2215a4,_0x1c944b,_0x3ce7b2){const _0x422332=a13_0x284872;return this[_0x422332(0x126)](_0x422332(0x134),_0x2215a4,_0x1c944b,_0x3ce7b2);}async[a13_0x284872(0x126)](_0x1c19fc,_0x20ef45,_0x4930d3,_0x9651c){const _0x3b56e9=a13_0x284872;if(!this[_0x3b56e9(0x11b)]||!this[_0x3b56e9(0x123)])throw new Error(_0x3b56e9(0x136));const _0x1937eb={'Content-Type':_0x3b56e9(0x132),..._0x9651c};_0x1937eb[_0x3b56e9(0x129)]=this[_0x3b56e9(0x143)];try{const _0x22e507=await this['axiosInstance'][_0x3b56e9(0x126)]({'data':_0x4930d3,'headers':_0x1937eb,'method':_0x1c19fc,'url':_0x20ef45});return await this[_0x3b56e9(0x12e)](_0x22e507[_0x3b56e9(0x11d)]),_0x22e507[_0x3b56e9(0x11d)];}catch(_0x51a7c1){throw this[_0x3b56e9(0x117)](_0x51a7c1);}}async[a13_0x284872(0x12e)](_0x253eff){const _0x5f115a=a13_0x284872;if(_0x253eff[_0x5f115a(0x12c)]===RespCode[_0x5f115a(0x13f)])throw new Error(_0x5f115a(0x13d)+this[_0x5f115a(0x145)]+_0x5f115a(0x137));if(_0x253eff['code']!==RespCode[_0x5f115a(0x128)]&&_0x253eff[_0x5f115a(0x12c)]!==RespCode['SYS_SUCCESS'])throw new Error(_0x5f115a(0x147)+_0x253eff['msg']+'\x20(code:\x20'+_0x253eff['code']+')');}['handleError'](_0x480830){const _0x3107e4=a13_0x284872;if(_0x480830['response']?.['status']===0x191)return new Error('Unauthorized:\x20Please\x20login\x20first');if(_0x480830['response'])return new Error(_0x3107e4(0x144)+_0x480830[_0x3107e4(0x13b)][_0x3107e4(0x116)]+':\x20'+_0x480830[_0x3107e4(0x13b)]['statusText']);return new Error('Request\x20failed:\x20'+_0x480830['message']);}}export const RespCode={'SUCCESS':0x0,'SYS_SUCCESS':0x1312d00,'USER_NOT_LOGIN':0x26407b2};export const simpleHttpClient=new SimpleHttpClient();export const httpClient=simpleHttpClient;export default httpClient;