UNPKG

@northflank/cli

Version:

Provides a command-line interface to the Northflank platform.

1 lines 3.29 kB
function a10m(){const B=['agent','1647087muSXJE','Unexpected\x20response,\x20api\x20token\x20missing','aborted','login-failure','toString','unable\x20to\x20parse\x20message:\x20','exit','browser-opened','data','202458PlFCGt','2105aeTtGk','initPackage','stringify','type','status','49185KLVUta','success','/v1/cli-login','message','replace','end','init','304116yCDAIf','login-success','101876qFDqwW','finally','openBrowser','http:','handleError','ws:','idle','error','duplex','SIGINT','write','Unexpected\x20response','5784jBwnlw','3036HZnXpi','wss:','Login\x20process\x20stopped\x20before\x20completed','baseUrl','init-ack','Failure\x20during\x20login:\x20','12587533Faamis','https:'];a10m=function(){return B;};return a10m();}function a10E(m,E){const h=a10m();return a10E=function(I,T){I=I-0xe0;let e=h[I];return e;},a10E(m,E);}const a10r=a10E;(function(m,E){const H=a10E,h=m();while(!![]){try{const I=-parseInt(H(0x105))/0x1+parseInt(H(0xef))/0x2+parseInt(H(0xed))/0x3+parseInt(H(0xfc))/0x4*(parseInt(H(0xe1))/0x5)+-parseInt(H(0xe0))/0x6+-parseInt(H(0x102))/0x7+-parseInt(H(0xfb))/0x8*(-parseInt(H(0xe6))/0x9);if(I===E)break;else h['push'](h['shift']());}catch(T){h['push'](h['shift']());}}}(a10m,0xe677b));import a10h,{createWebSocketStream}from'ws';import a10I from'open';import{EventEmitter}from'events';export class NorthflankApiBrowserLogin extends EventEmitter{[a10r(0xff)];[a10r(0xf1)];[a10r(0x104)];[a10r(0xf7)];[a10r(0xe5)]=a10r(0xf5);constructor(m,E=!![],h){const F=a10r;super(),this[F(0xff)]=m,this[F(0xf1)]=E,this[F(0x104)]=h;}['startLogin'](){const t=a10r,m=this[t(0xff)]['replace'](t(0x103),t(0xfd))[t(0xea)](t(0xf2),t(0xf4)),E=m+t(0xe8),h=new a10h(E,{'agent':this[t(0x104)]}),I=async()=>{const N=t;await new Promise(e=>{const Y=a10E;this[Y(0xf7)]?.[Y(0xeb)](JSON[Y(0xe3)]({'type':Y(0x107)}),()=>e());}),process[N(0x10b)]();},T=new Promise((o,g)=>{const w=t;try{this[w(0xf7)]=createWebSocketStream(h),process['on']('SIGINT',I);}catch(J){g(new Error('Failed\x20to\x20establish\x20connection\x20to\x20command\x20execution\x20proxy:\x20'+J[w(0xe9)]));}this[w(0xf7)]?.['on'](w(0x10d),L=>{const b=w,P=JSON['parse'](L[b(0x109)]());switch(P?.[b(0xe4)]){case b(0x100):{const {loginPage:X}=P;if(X===undefined){this[b(0xf3)](b(0xfa),g);return;}this[b(0xf1)]&&a10I(X)['catch'](W=>{const n=b,K='Unable\x20to\x20open\x20browser:\x20'+W[n(0xe9)];this[n(0xf3)](K,g);});this['emit'](b(0x10c),{'url':X});break;}case b(0xee):{const {apiToken:W,contextName:K}=P;if(W===undefined){this[b(0xf3)](b(0x106),g);return;}this[b(0xf7)]?.['end'](),o({'token':W,'contextName':K}),this[b(0xe5)]=b(0xe7);break;}case b(0x108):{const z=b(0x101)+P?.[b(0xe9)];this[b(0xf3)](z,g);break;}default:{const S=b(0x10a)+JSON[b(0xe3)](P);this[b(0xf3)](S,g);}}}),this[w(0xf7)]?.['on'](w(0xf6),L=>{this['handleError']('error\x20happened\x20during\x20browser\x20login:\x20'+L['message'],g);}),this[w(0xf7)]?.['on'](w(0xeb),()=>{const Q=w;if(this[Q(0xe5)]===Q(0xe7)){}else this[Q(0xf3)](Q(0xfe),g);});});return this[t(0xf7)]?.[t(0xf9)](this[t(0xe2)]()),this[t(0xe5)]=t(0xec),T[t(0xf0)](()=>{const c=t;process['removeListener'](c(0xf8),I);});}[a10r(0xf3)](m,E){const O=a10r;E?this['duplex']?.[O(0xeb)](()=>E(new Error(m))):this[O(0xf7)]?.[O(0xeb)](),this[O(0xe5)]='error';}[a10r(0xe2)]=()=>JSON[a10r(0xe3)]({'type':'init'});}