@northflank/cli 0.8.3-beta.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-helpers.js +1 -273
- package/dist/cli.js +1 -630
- package/dist/command-overview.js +1 -93
- package/dist/console-format-helpers.js +1 -113
- package/dist/context/contextCommands.js +1 -522
- package/dist/defaults.js +1 -10238
- package/dist/exec/index.js +1 -262
- package/dist/inquirer-helper.js +1 -1049
- package/dist/login/browser-login.js +1 -204
- package/dist/pagination/inquirer-pagination-prompt.js +1 -156
- package/dist/port-forward/index.js +1 -271
- package/dist/utils.js +1 -201
- package/package.json +4 -3
|
@@ -1,204 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
-
if (k2 === undefined) k2 = k;
|
|
19
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
-
}
|
|
23
|
-
Object.defineProperty(o, k2, desc);
|
|
24
|
-
}) : (function(o, m, k, k2) {
|
|
25
|
-
if (k2 === undefined) k2 = k;
|
|
26
|
-
o[k2] = m[k];
|
|
27
|
-
}));
|
|
28
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
-
}) : function(o, v) {
|
|
31
|
-
o["default"] = v;
|
|
32
|
-
});
|
|
33
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
34
|
-
if (mod && mod.__esModule) return mod;
|
|
35
|
-
var result = {};
|
|
36
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
37
|
-
__setModuleDefault(result, mod);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
40
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
41
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
42
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
43
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
44
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
45
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
46
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
50
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
51
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
52
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
53
|
-
function step(op) {
|
|
54
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
55
|
-
while (_) try {
|
|
56
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
57
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
58
|
-
switch (op[0]) {
|
|
59
|
-
case 0: case 1: t = op; break;
|
|
60
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
61
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
62
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
63
|
-
default:
|
|
64
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
65
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
66
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
67
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
68
|
-
if (t[2]) _.ops.pop();
|
|
69
|
-
_.trys.pop(); continue;
|
|
70
|
-
}
|
|
71
|
-
op = body.call(thisArg, _);
|
|
72
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
73
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
77
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
78
|
-
};
|
|
79
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
80
|
-
exports.NorthflankApiBrowserLogin = void 0;
|
|
81
|
-
/* eslint-disable no-unused-expressions */
|
|
82
|
-
var ws_1 = __importStar(require("ws"));
|
|
83
|
-
var open_1 = __importDefault(require("open"));
|
|
84
|
-
var events_1 = require("events");
|
|
85
|
-
var NorthflankApiBrowserLogin = /** @class */ (function (_super) {
|
|
86
|
-
__extends(NorthflankApiBrowserLogin, _super);
|
|
87
|
-
function NorthflankApiBrowserLogin(baseUrl, openBrowser) {
|
|
88
|
-
if (openBrowser === void 0) { openBrowser = true; }
|
|
89
|
-
var _this = _super.call(this) || this;
|
|
90
|
-
_this.baseUrl = baseUrl;
|
|
91
|
-
_this.openBrowser = openBrowser;
|
|
92
|
-
_this.status = 'idle';
|
|
93
|
-
_this.initPackage = function () { return JSON.stringify({ type: 'init' }); };
|
|
94
|
-
return _this;
|
|
95
|
-
}
|
|
96
|
-
NorthflankApiBrowserLogin.prototype.startLogin = function () {
|
|
97
|
-
var _this = this;
|
|
98
|
-
var _a;
|
|
99
|
-
// Protocol:
|
|
100
|
-
// 1. cli -> api : type: init
|
|
101
|
-
// - public api: creates entry in collection 'session-tokens'
|
|
102
|
-
// 2. api -> cli : type: init-ack, loginPage: https://app.northflank.com/login?type=cli&session_token=<rand-token>
|
|
103
|
-
// - cli opens webpage, user does login, platform adds session-token reference to token
|
|
104
|
-
// 3. api -> cli : type: login-success, token:<api token>
|
|
105
|
-
// 3. api -> cli : type: login-failure, message: timeout
|
|
106
|
-
var wsEndpoint = this.baseUrl.replace('https:', 'wss:').replace('http:', 'ws:');
|
|
107
|
-
var loginWsEndpoint = "".concat(wsEndpoint, "/v1/cli-login");
|
|
108
|
-
var ws = new ws_1.default(loginWsEndpoint);
|
|
109
|
-
var sigintListener = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
110
|
-
var _this = this;
|
|
111
|
-
return __generator(this, function (_a) {
|
|
112
|
-
switch (_a.label) {
|
|
113
|
-
case 0: return [4 /*yield*/, new Promise(function (res) {
|
|
114
|
-
var _a;
|
|
115
|
-
(_a = _this.duplex) === null || _a === void 0 ? void 0 : _a.end(JSON.stringify({ type: 'aborted' }), function () { return res(); });
|
|
116
|
-
})];
|
|
117
|
-
case 1:
|
|
118
|
-
_a.sent();
|
|
119
|
-
process.exit();
|
|
120
|
-
return [2 /*return*/];
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
}); };
|
|
124
|
-
var loginFlow = new Promise(function (res, rej) {
|
|
125
|
-
var _a, _b, _c;
|
|
126
|
-
try {
|
|
127
|
-
_this.duplex = (0, ws_1.createWebSocketStream)(ws);
|
|
128
|
-
process.on('SIGINT', sigintListener);
|
|
129
|
-
}
|
|
130
|
-
catch (e) {
|
|
131
|
-
rej(new Error("Failed to establish connection to command execution proxy: ".concat(e.message)));
|
|
132
|
-
}
|
|
133
|
-
(_a = _this.duplex) === null || _a === void 0 ? void 0 : _a.on('data', function (chunk) {
|
|
134
|
-
var _a;
|
|
135
|
-
var dataObj = JSON.parse(chunk.toString());
|
|
136
|
-
switch (dataObj === null || dataObj === void 0 ? void 0 : dataObj.type) {
|
|
137
|
-
case 'init-ack': {
|
|
138
|
-
var loginPage = dataObj.loginPage;
|
|
139
|
-
if (loginPage === undefined) {
|
|
140
|
-
_this.handleError('Unexpected response', rej);
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
if (_this.openBrowser) {
|
|
144
|
-
(0, open_1.default)(loginPage).catch(function (err) {
|
|
145
|
-
var errorMsg = "Unable to open browser: ".concat(err.message);
|
|
146
|
-
_this.handleError(errorMsg, rej);
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
_this.emit('browser-opened', { url: loginPage });
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
case 'login-success': {
|
|
153
|
-
var apiToken = dataObj.apiToken;
|
|
154
|
-
if (apiToken === undefined) {
|
|
155
|
-
_this.handleError('Unexpected response, api token missing', rej);
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
(_a = _this.duplex) === null || _a === void 0 ? void 0 : _a.end();
|
|
159
|
-
res({ token: apiToken });
|
|
160
|
-
_this.status = 'success';
|
|
161
|
-
break;
|
|
162
|
-
}
|
|
163
|
-
case 'login-failure': {
|
|
164
|
-
var errorMsg = "Failure during login: ".concat(dataObj === null || dataObj === void 0 ? void 0 : dataObj.message);
|
|
165
|
-
_this.handleError(errorMsg, rej);
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
default: {
|
|
169
|
-
var errorMsg = "unable to parse message: ".concat(JSON.stringify(dataObj));
|
|
170
|
-
_this.handleError(errorMsg, rej);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
(_b = _this.duplex) === null || _b === void 0 ? void 0 : _b.on('error', function (err) {
|
|
175
|
-
_this.handleError("error happened during browser login: ".concat(err.message), rej);
|
|
176
|
-
});
|
|
177
|
-
(_c = _this.duplex) === null || _c === void 0 ? void 0 : _c.on('end', function () {
|
|
178
|
-
if (_this.status === 'success') {
|
|
179
|
-
// should have already been handled after login-success packet
|
|
180
|
-
}
|
|
181
|
-
else {
|
|
182
|
-
_this.handleError("Login process stopped before completed", rej);
|
|
183
|
-
}
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
(_a = this.duplex) === null || _a === void 0 ? void 0 : _a.write(this.initPackage());
|
|
187
|
-
this.status = 'init';
|
|
188
|
-
return loginFlow.finally(function () {
|
|
189
|
-
process.removeListener('SIGINT', sigintListener);
|
|
190
|
-
});
|
|
191
|
-
};
|
|
192
|
-
NorthflankApiBrowserLogin.prototype.handleError = function (errorMsg, rej) {
|
|
193
|
-
var _a, _b;
|
|
194
|
-
if (rej) {
|
|
195
|
-
(_a = this.duplex) === null || _a === void 0 ? void 0 : _a.end(function () { return rej(new Error(errorMsg)); });
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
(_b = this.duplex) === null || _b === void 0 ? void 0 : _b.end();
|
|
199
|
-
}
|
|
200
|
-
this.status = 'error';
|
|
201
|
-
};
|
|
202
|
-
return NorthflankApiBrowserLogin;
|
|
203
|
-
}(events_1.EventEmitter));
|
|
204
|
-
exports.NorthflankApiBrowserLogin = NorthflankApiBrowserLogin;
|
|
1
|
+
'use strict';var a8F=a8L;(function(g,L){var X=a8L,S=g();while(!![]){try{var q=parseInt(X(0x163))/0x1*(parseInt(X(0x12d))/0x2)+parseInt(X(0x158))/0x3+-parseInt(X(0x13b))/0x4+-parseInt(X(0x14d))/0x5+-parseInt(X(0x171))/0x6*(-parseInt(X(0x130))/0x7)+-parseInt(X(0x153))/0x8+-parseInt(X(0x13d))/0x9*(-parseInt(X(0x15c))/0xa);if(q===L)break;else S['push'](S['shift']());}catch(e){S['push'](S['shift']());}}}(a8g,0x2c04d));var __extends=this&&this[a8F(0x159)]||(function(){var g=function(L,S){var z=a8L;return g=Object[z(0x15d)]||{'__proto__':[]}instanceof Array&&function(q,e){q['__proto__']=e;}||function(q,e){var W=z;for(var H in e)if(Object['prototype'][W(0x13c)][W(0x124)](e,H))q[H]=e[H];},g(L,S);};return function(L,S){var M=a8L;if(typeof S!==M(0x12b)&&S!==null)throw new TypeError(M(0x16a)+String(S)+M(0x128));g(L,S);function q(){this['constructor']=L;}L[M(0x161)]=S===null?Object[M(0x14c)](S):(q[M(0x161)]=S[M(0x161)],new q());};}()),__createBinding=this&&this[a8F(0x16c)]||(Object[a8F(0x14c)]?function(g,L,S,q){var C=a8F;if(q===undefined)q=S;var e=Object[C(0x16f)](L,S);(!e||(C(0x134)in e?!L[C(0x154)]:e[C(0x162)]||e[C(0x141)]))&&(e={'enumerable':!![],'get':function(){return L[S];}}),Object['defineProperty'](g,q,e);}:function(g,L,S,q){if(q===undefined)q=S;g[q]=L[S];}),__setModuleDefault=this&&this[a8F(0x121)]||(Object['create']?function(g,L){var c=a8F;Object[c(0x12f)](g,c(0x155),{'enumerable':!![],'value':L});}:function(g,L){var j=a8F;g[j(0x155)]=L;}),__importStar=this&&this[a8F(0x146)]||function(g){var G=a8F;if(g&&g['__esModule'])return g;var L={};if(g!=null){for(var S in g)if(S!==G(0x155)&&Object[G(0x161)][G(0x13c)][G(0x124)](g,S))__createBinding(L,g,S);}return __setModuleDefault(L,g),L;},__awaiter=this&&this[a8F(0x145)]||function(g,L,S,q){function e(H){return H instanceof S?H:new S(function(I){I(H);});}return new(S||(S=Promise))(function(H,I){var v=a8L;function y(Y){try{O(q['next'](Y));}catch(B){I(B);}}function k(Y){try{O(q['throw'](Y));}catch(B){I(B);}}function O(Y){var h=a8L;Y[h(0x14a)]?H(Y[h(0x131)]):e(Y['value'])[h(0x14e)](y,k);}O((q=q[v(0x122)](g,L||[]))[v(0x13a)]());});},__generator=this&&this['__generator']||function(L,S){var p=a8F,q={'label':0x0,'sent':function(){if(I[0x0]&0x1)throw I[0x1];return I[0x1];},'trys':[],'ops':[]},e,H,I,k;return k={'next':O(0x0),'throw':O(0x1),'return':O(0x2)},typeof Symbol===p(0x12b)&&(k[Symbol['iterator']]=function(){return this;}),k;function O(B){return function(P){return Y([B,P]);};}function Y(B){var t=p;if(e)throw new TypeError(t(0x137));while(q)try{if(e=0x1,H&&(I=B[0x0]&0x2?H['return']:B[0x0]?H[t(0x167)]||((I=H[t(0x16e)])&&I['call'](H),0x0):H[t(0x13a)])&&!(I=I[t(0x124)](H,B[0x1]))[t(0x14a)])return I;if(H=0x0,I)B=[B[0x0]&0x2,I[t(0x131)]];switch(B[0x0]){case 0x0:case 0x1:I=B;break;case 0x4:q[t(0x132)]++;return{'value':B[0x1],'done':![]};case 0x5:q[t(0x132)]++,H=B[0x1],B=[0x0];continue;case 0x7:B=q[t(0x148)][t(0x140)](),q[t(0x13e)][t(0x140)]();continue;default:if(!(I=q[t(0x13e)],I=I[t(0x126)]>0x0&&I[I[t(0x126)]-0x1])&&(B[0x0]===0x6||B[0x0]===0x2)){q=0x0;continue;}if(B[0x0]===0x3&&(!I||B[0x1]>I[0x0]&&B[0x1]<I[0x3])){q['label']=B[0x1];break;}if(B[0x0]===0x6&&q[t(0x132)]<I[0x1]){q['label']=I[0x1],I=B;break;}if(I&&q[t(0x132)]<I[0x2]){q[t(0x132)]=I[0x2],q[t(0x148)][t(0x12a)](B);break;}if(I[0x2])q[t(0x148)]['pop']();q[t(0x13e)]['pop']();continue;}B=S['call'](L,q);}catch(P){B=[0x6,P],H=0x0;}finally{e=I=0x0;}if(B[0x0]&0x5)throw B[0x1];return{'value':B[0x0]?B[0x1]:void 0x0,'done':!![]};}},__importDefault=this&&this[a8F(0x15a)]||function(g){var s=a8F;return g&&g[s(0x154)]?g:{'default':g};};function a8L(g,L){var S=a8g();return a8L=function(q,e){q=q-0x11e;var H=S[q];return H;},a8L(g,L);}function a8g(){var l=['emit','224500ToGTXN','setPrototypeOf','openBrowser','initPackage','sent','prototype','writable','5rvMBYN','https:','replace','apiToken','throw','message','unable\x20to\x20parse\x20message:\x20','Class\x20extends\x20value\x20','stringify','__createBinding','NorthflankApiBrowserLogin','return','getOwnPropertyDescriptor','error\x20happened\x20during\x20browser\x20login:\x20','7770gdGIBf','createWebSocketStream','removeListener','finally','data','type','__setModuleDefault','apply','SIGINT','call','baseUrl','length','exit','\x20is\x20not\x20a\x20constructor\x20or\x20null','concat','push','function','catch','111742aHujzY','Unexpected\x20response','defineProperty','1113nCWMeH','value','label','browser-opened','get','init','success','Generator\x20is\x20already\x20executing.','loginPage','contextName','next','256956GkeThB','hasOwnProperty','72nKaJZY','trys','aborted','pop','configurable','Failed\x20to\x20establish\x20connection\x20to\x20command\x20execution\x20proxy:\x20','wss:','startLogin','__awaiter','__importStar','/v1/cli-login','ops','toString','done','status','create','1047255smdFkE','then','error','handleError','idle','duplex','2594432WKgvZJ','__esModule','default','http:','end','340305iIdGBc','__extends','__importDefault'];a8g=function(){return l;};return a8g();}Object[a8F(0x12f)](exports,'__esModule',{'value':!![]}),exports[a8F(0x16d)]=void 0x0;var ws_1=__importStar(require('ws')),open_1=__importDefault(require('open')),events_1=require('events'),NorthflankApiBrowserLogin=function(g){var V=a8F;__extends(L,g);function L(S,q){var D=a8L;q===void 0x0&&(q=!![]);var e=g[D(0x124)](this)||this;return e[D(0x125)]=S,e[D(0x15e)]=q,e['status']=D(0x151),e[D(0x15f)]=function(){var T=D;return JSON['stringify']({'type':T(0x135)});},e;}return L[V(0x161)][V(0x144)]=function(){var r=V,S=this,q,e=this[r(0x125)][r(0x165)](r(0x164),r(0x143))[r(0x165)](r(0x156),'ws:'),H=''[r(0x129)](e,r(0x147)),I=new ws_1[(r(0x155))](H),y=function(){return __awaiter(S,void 0x0,void 0x0,function(){var O=this;return __generator(this,function(Y){var b=a8L;switch(Y[b(0x132)]){case 0x0:return[0x4,new Promise(function(B){var w=b,P;(P=O[w(0x152)])===null||P===void 0x0?void 0x0:P['end'](JSON[w(0x16b)]({'type':w(0x13f)}),function(){return B();});})];case 0x1:Y[b(0x160)](),process[b(0x127)]();return[0x2];}});});},k=new Promise(function(O,Y){var m=r,B,P,Z;try{S[m(0x152)]=(0x0,ws_1[m(0x172)])(I),process['on'](m(0x123),y);}catch(a){Y(new Error(m(0x142)[m(0x129)](a[m(0x168)])));}(B=S['duplex'])===null||B===void 0x0?void 0x0:B['on'](m(0x11f),function(A){var K=m,n,U=JSON['parse'](A[K(0x149)]());switch(U===null||U===void 0x0?void 0x0:U[K(0x120)]){case'init-ack':{var f=U[K(0x138)];if(f===undefined){S[K(0x150)](K(0x12e),Y);return;}S[K(0x15e)]&&(0x0,open_1[K(0x155)])(f)[K(0x12c)](function(i){var Q=K,u='Unable\x20to\x20open\x20browser:\x20'[Q(0x129)](i[Q(0x168)]);S[Q(0x150)](u,Y);});S[K(0x15b)](K(0x133),{'url':f});break;}case'login-success':{var J=U[K(0x166)],o=U[K(0x139)];if(J===undefined){S[K(0x150)]('Unexpected\x20response,\x20api\x20token\x20missing',Y);return;}(n=S[K(0x152)])===null||n===void 0x0?void 0x0:n['end'](),O({'token':J,'contextName':o}),S[K(0x14b)]=K(0x136);break;}case'login-failure':{var d='Failure\x20during\x20login:\x20'[K(0x129)](U===null||U===void 0x0?void 0x0:U['message']);S[K(0x150)](d,Y);break;}default:{var d=K(0x169)[K(0x129)](JSON['stringify'](U));S[K(0x150)](d,Y);}}}),(P=S[m(0x152)])===null||P===void 0x0?void 0x0:P['on']('error',function(A){var E=m;S[E(0x150)](E(0x170)[E(0x129)](A['message']),Y);}),(Z=S[m(0x152)])===null||Z===void 0x0?void 0x0:Z['on'](m(0x157),function(){var R=m;if(S[R(0x14b)]===R(0x136)){}else S['handleError']('Login\x20process\x20stopped\x20before\x20completed',Y);});});return(q=this[r(0x152)])===null||q===void 0x0?void 0x0:q['write'](this[r(0x15f)]()),this[r(0x14b)]='init',k[r(0x11e)](function(){var x=r;process[x(0x173)](x(0x123),y);});},L[V(0x161)][V(0x150)]=function(S,q){var N=V,e,H;q?(e=this[N(0x152)])===null||e===void 0x0?void 0x0:e[N(0x157)](function(){return q(new Error(S));}):(H=this[N(0x152)])===null||H===void 0x0?void 0x0:H[N(0x157)](),this['status']=N(0x14f);},L;}(events_1['EventEmitter']);exports['NorthflankApiBrowserLogin']=NorthflankApiBrowserLogin;
|
|
@@ -1,156 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
54
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
55
|
-
};
|
|
56
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
-
exports.DynamicReloadPaginationPrompt = void 0;
|
|
58
|
-
var list_1 = __importDefault(require("inquirer/lib/prompts/list"));
|
|
59
|
-
var choice_1 = __importDefault(require("inquirer/lib/objects/choice"));
|
|
60
|
-
var chalk_1 = __importDefault(require("chalk"));
|
|
61
|
-
function incrementListIndex(current, dir, opt) {
|
|
62
|
-
var len = opt.choices.realLength;
|
|
63
|
-
var shouldLoop = 'loop' in opt ? Boolean(opt.loop) : true;
|
|
64
|
-
if (dir === 'up') {
|
|
65
|
-
if (current > 0) {
|
|
66
|
-
return current - 1;
|
|
67
|
-
}
|
|
68
|
-
return shouldLoop ? len - 1 : current;
|
|
69
|
-
}
|
|
70
|
-
if (dir === 'down') {
|
|
71
|
-
if (current < len - 1) {
|
|
72
|
-
return current + 1;
|
|
73
|
-
}
|
|
74
|
-
return shouldLoop ? 0 : current;
|
|
75
|
-
}
|
|
76
|
-
throw new Error('dir must be up or down');
|
|
77
|
-
}
|
|
78
|
-
var DynamicReloadPaginationPrompt = /** @class */ (function (_super) {
|
|
79
|
-
__extends(DynamicReloadPaginationPrompt, _super);
|
|
80
|
-
function DynamicReloadPaginationPrompt(q, rl, a) {
|
|
81
|
-
var _this = _super.call(this, q, rl, a) || this;
|
|
82
|
-
_this.reloadText = chalk_1.default.italic('.. Load more options ..');
|
|
83
|
-
_this.loading = false;
|
|
84
|
-
_this.pagOpt = _this.opt;
|
|
85
|
-
_this.nextPageCursor = _this.pagOpt.nextPageCursor;
|
|
86
|
-
if (_this.nextPageCursor !== undefined) {
|
|
87
|
-
_this.opt.choices.push(new choice_1.default(_this.reloadText, _this.reloadText));
|
|
88
|
-
}
|
|
89
|
-
return _this;
|
|
90
|
-
}
|
|
91
|
-
DynamicReloadPaginationPrompt.prototype.onUpKey = function () {
|
|
92
|
-
if (this.loading)
|
|
93
|
-
return;
|
|
94
|
-
this.selected = incrementListIndex(this.selected, 'up', this.opt);
|
|
95
|
-
this.render();
|
|
96
|
-
};
|
|
97
|
-
DynamicReloadPaginationPrompt.prototype.onDownKey = function () {
|
|
98
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
99
|
-
return __generator(this, function (_a) {
|
|
100
|
-
switch (_a.label) {
|
|
101
|
-
case 0:
|
|
102
|
-
if (this.loading)
|
|
103
|
-
return [2 /*return*/];
|
|
104
|
-
this.selected = incrementListIndex(this.selected, 'down', this.opt);
|
|
105
|
-
return [4 /*yield*/, this.handleDynamicPageLoad()];
|
|
106
|
-
case 1:
|
|
107
|
-
_a.sent();
|
|
108
|
-
this.render();
|
|
109
|
-
return [2 /*return*/];
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
DynamicReloadPaginationPrompt.prototype.handleDynamicPageLoad = function () {
|
|
115
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
116
|
-
var i_1, interval, _a, elements, nextPageCursor, moreChoices;
|
|
117
|
-
var _b;
|
|
118
|
-
var _this = this;
|
|
119
|
-
return __generator(this, function (_c) {
|
|
120
|
-
switch (_c.label) {
|
|
121
|
-
case 0:
|
|
122
|
-
if (!(this.selected >= this.opt.choices.length - 1)) return [3 /*break*/, 2];
|
|
123
|
-
if (this.nextPageCursor === undefined)
|
|
124
|
-
return [2 /*return*/];
|
|
125
|
-
this.loading = true;
|
|
126
|
-
i_1 = 0;
|
|
127
|
-
interval = setInterval(function () {
|
|
128
|
-
var frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
129
|
-
var loadingNotice = chalk_1.default.italic("".concat(frames[i_1 % frames.length], " Loading more options"));
|
|
130
|
-
_this.opt.choices.choices[_this.selected].name = "".concat(loadingNotice);
|
|
131
|
-
i_1 += 1;
|
|
132
|
-
_this.render();
|
|
133
|
-
}, 80);
|
|
134
|
-
return [4 /*yield*/, this.pagOpt
|
|
135
|
-
.loadMore({ nextPageCursor: this.nextPageCursor })
|
|
136
|
-
.catch(function () { return ({ elements: [], nextPageCursor: undefined }); })];
|
|
137
|
-
case 1:
|
|
138
|
-
_a = _c.sent(), elements = _a.elements, nextPageCursor = _a.nextPageCursor;
|
|
139
|
-
this.nextPageCursor = nextPageCursor;
|
|
140
|
-
moreChoices = elements.map(function (e) { return new choice_1.default(e, e); });
|
|
141
|
-
this.opt.choices.choices.splice(this.selected, 1);
|
|
142
|
-
(_b = this.opt.choices).push.apply(_b, moreChoices);
|
|
143
|
-
if (nextPageCursor !== undefined) {
|
|
144
|
-
this.opt.choices.push(new choice_1.default(this.reloadText, this.reloadText));
|
|
145
|
-
}
|
|
146
|
-
clearInterval(interval);
|
|
147
|
-
this.loading = false;
|
|
148
|
-
_c.label = 2;
|
|
149
|
-
case 2: return [2 /*return*/];
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
};
|
|
154
|
-
return DynamicReloadPaginationPrompt;
|
|
155
|
-
}(list_1.default));
|
|
156
|
-
exports.DynamicReloadPaginationPrompt = DynamicReloadPaginationPrompt;
|
|
1
|
+
'use strict';var a9a=a9L;function a9L(g,L){var S=a9g();return a9L=function(q,e){q=q-0x101;var H=S[q];return H;},a9L(g,L);}(function(g,L){var Z=a9L,S=g();while(!![]){try{var q=parseInt(Z(0x118))/0x1*(parseInt(Z(0x138))/0x2)+-parseInt(Z(0x13c))/0x3+parseInt(Z(0x10b))/0x4+parseInt(Z(0x139))/0x5+-parseInt(Z(0x112))/0x6*(parseInt(Z(0x125))/0x7)+parseInt(Z(0x13a))/0x8*(parseInt(Z(0x13e))/0x9)+-parseInt(Z(0x12f))/0xa;if(q===L)break;else S['push'](S['shift']());}catch(e){S['push'](S['shift']());}}}(a9g,0x1c110));var __extends=this&&this[a9a(0x130)]||(function(){var g=function(L,S){var A=a9L;return g=Object[A(0x103)]||{'__proto__':[]}instanceof Array&&function(q,e){q['__proto__']=e;}||function(q,e){for(var H in e)if(Object['prototype']['hasOwnProperty']['call'](e,H))q[H]=e[H];},g(L,S);};return function(L,S){var n=a9L;if(typeof S!==n(0x131)&&S!==null)throw new TypeError('Class\x20extends\x20value\x20'+String(S)+n(0x104));g(L,S);function q(){this['constructor']=L;}L['prototype']=S===null?Object['create'](S):(q[n(0x12c)]=S['prototype'],new q());};}()),__awaiter=this&&this[a9a(0x127)]||function(g,L,S,q){function e(H){return H instanceof S?H:new S(function(I){I(H);});}return new(S||(S=Promise))(function(H,I){var o=a9L;function y(Y){var U=a9L;try{O(q[U(0x126)](Y));}catch(B){I(B);}}function k(Y){var f=a9L;try{O(q[f(0x119)](Y));}catch(B){I(B);}}function O(Y){var J=a9L;Y['done']?H(Y['value']):e(Y['value'])[J(0x129)](y,k);}O((q=q['apply'](g,L||[]))[o(0x126)]());});},__generator=this&&this[a9a(0x11f)]||function(L,S){var d=a9a,q={'label':0x0,'sent':function(){if(I[0x0]&0x1)throw I[0x1];return I[0x1];},'trys':[],'ops':[]},e,H,I,k;return k={'next':O(0x0),'throw':O(0x1),'return':O(0x2)},typeof Symbol===d(0x131)&&(k[Symbol[d(0x114)]]=function(){return this;}),k;function O(B){return function(P){return Y([B,P]);};}function Y(B){var i=d;if(e)throw new TypeError('Generator\x20is\x20already\x20executing.');while(q)try{if(e=0x1,H&&(I=B[0x0]&0x2?H['return']:B[0x0]?H[i(0x119)]||((I=H[i(0x11c)])&&I['call'](H),0x0):H[i(0x126)])&&!(I=I[i(0x136)](H,B[0x1]))[i(0x13b)])return I;if(H=0x0,I)B=[B[0x0]&0x2,I[i(0x128)]];switch(B[0x0]){case 0x0:case 0x1:I=B;break;case 0x4:q['label']++;return{'value':B[0x1],'done':![]};case 0x5:q['label']++,H=B[0x1],B=[0x0];continue;case 0x7:B=q['ops'][i(0x121)](),q[i(0x133)][i(0x121)]();continue;default:if(!(I=q[i(0x133)],I=I[i(0x12a)]>0x0&&I[I[i(0x12a)]-0x1])&&(B[0x0]===0x6||B[0x0]===0x2)){q=0x0;continue;}if(B[0x0]===0x3&&(!I||B[0x1]>I[0x0]&&B[0x1]<I[0x3])){q[i(0x117)]=B[0x1];break;}if(B[0x0]===0x6&&q[i(0x117)]<I[0x1]){q[i(0x117)]=I[0x1],I=B;break;}if(I&&q['label']<I[0x2]){q[i(0x117)]=I[0x2],q[i(0x105)][i(0x102)](B);break;}if(I[0x2])q['ops'][i(0x121)]();q['trys'][i(0x121)]();continue;}B=S[i(0x136)](L,q);}catch(P){B=[0x6,P],H=0x0;}finally{e=I=0x0;}if(B[0x0]&0x5)throw B[0x1];return{'value':B[0x0]?B[0x1]:void 0x0,'done':!![]};}},__importDefault=this&&this[a9a(0x111)]||function(g){var u=a9a;return g&&g[u(0x108)]?g:{'default':g};};Object['defineProperty'](exports,a9a(0x108),{'value':!![]}),exports[a9a(0x123)]=void 0x0;function a9g(){var G=['value','then','length','default','prototype','catch','render','326600KzcnlH','__extends','function','realLength','trys','concat','..\x20Load\x20more\x20options\x20..','call','selected','2LkdkkF','1070935HZFPXj','32096LOvNgP','done','192252RCpmqS','\x20Loading\x20more\x20options','153XFHjtE','reloadText','push','setPrototypeOf','\x20is\x20not\x20a\x20constructor\x20or\x20null','ops','italic','handleDynamicPageLoad','__esModule','pagOpt','loop','162756USEnDl','loadMore','apply','sent','choices','inquirer/lib/objects/choice','__importDefault','357918FhhutY','nextPageCursor','iterator','down','dir\x20must\x20be\x20up\x20or\x20down','label','7930enQbty','throw','inquirer/lib/prompts/list','splice','return','loading','opt','__generator','name','pop','onUpKey','DynamicReloadPaginationPrompt','onDownKey','14ZYKnRh','next','__awaiter'];a9g=function(){return G;};return a9g();}var list_1=__importDefault(require(a9a(0x11a))),choice_1=__importDefault(require(a9a(0x110))),chalk_1=__importDefault(require('chalk'));function incrementListIndex(g,L,S){var X=a9a,q=S[X(0x10f)][X(0x132)],e=X(0x10a)in S?Boolean(S[X(0x10a)]):!![];if(L==='up'){if(g>0x0)return g-0x1;return e?q-0x1:g;}if(L===X(0x115)){if(g<q-0x1)return g+0x1;return e?0x0:g;}throw new Error(X(0x116));}var DynamicReloadPaginationPrompt=function(g){var z=a9a;__extends(L,g);function L(S,e,H){var F=a9L,I=g[F(0x136)](this,S,e,H)||this;return I['reloadText']=chalk_1[F(0x12b)][F(0x106)](F(0x135)),I['loading']=![],I[F(0x109)]=I['opt'],I[F(0x113)]=I[F(0x109)][F(0x113)],I[F(0x113)]!==undefined&&I[F(0x11e)][F(0x10f)][F(0x102)](new choice_1['default'](I[F(0x101)],I[F(0x101)])),I;}return L['prototype'][z(0x122)]=function(){var W=z;if(this[W(0x11d)])return;this[W(0x137)]=incrementListIndex(this[W(0x137)],'up',this[W(0x11e)]),this[W(0x12e)]();},L[z(0x12c)][z(0x124)]=function(){return __awaiter(this,void 0x0,void 0x0,function(){return __generator(this,function(S){var M=a9L;switch(S['label']){case 0x0:if(this[M(0x11d)])return[0x2];this['selected']=incrementListIndex(this[M(0x137)],M(0x115),this[M(0x11e)]);return[0x4,this[M(0x107)]()];case 0x1:S[M(0x10e)](),this['render']();return[0x2];}});});},L['prototype'][z(0x107)]=function(){return __awaiter(this,void 0x0,void 0x0,function(){var S,q,e,H,I,y,k,O=this;return __generator(this,function(Y){var C=a9L;switch(Y[C(0x117)]){case 0x0:if(!(this['selected']>=this['opt'][C(0x10f)][C(0x12a)]-0x1))return[0x3,0x2];if(this[C(0x113)]===undefined)return[0x2];this[C(0x11d)]=!![],S=0x0,q=setInterval(function(){var c=C,B=['⠋','⠙','⠹','⠸','⠼','⠴','⠦','⠧','⠇','⠏'],P=chalk_1[c(0x12b)][c(0x106)](''['concat'](B[S%B[c(0x12a)]],c(0x13d)));O[c(0x11e)][c(0x10f)][c(0x10f)][O['selected']][c(0x120)]=''[c(0x134)](P),S+=0x1,O[c(0x12e)]();},0x50);return[0x4,this[C(0x109)][C(0x10c)]({'nextPageCursor':this[C(0x113)]})[C(0x12d)](function(){return{'elements':[],'nextPageCursor':undefined};})];case 0x1:e=Y[C(0x10e)](),H=e['elements'],I=e[C(0x113)],this['nextPageCursor']=I,y=H['map'](function(B){var j=C;return new choice_1[(j(0x12b))](B,B);}),this[C(0x11e)]['choices'][C(0x10f)][C(0x11b)](this[C(0x137)],0x1),(k=this[C(0x11e)]['choices'])['push'][C(0x10d)](k,y);I!==undefined&&this[C(0x11e)][C(0x10f)][C(0x102)](new choice_1[(C(0x12b))](this['reloadText'],this[C(0x101)]));clearInterval(q),this['loading']=![],Y[C(0x117)]=0x2;case 0x2:return[0x2];}});});},L;}(list_1['default']);exports['DynamicReloadPaginationPrompt']=DynamicReloadPaginationPrompt;
|