nestjs-web-console 1.0.1 → 1.0.3
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/LICENSE +21 -21
- package/README.md +66 -66
- package/dist/console.types.d.ts +75 -75
- package/dist/console.types.js +15 -15
- package/dist/controllers/web.console.controller.d.ts +1 -1
- package/dist/controllers/web.console.controller.js +690 -675
- package/dist/filters/http-exception.filter.d.ts +4 -4
- package/dist/filters/http-exception.filter.js +50 -50
- package/dist/index.d.ts +8 -8
- package/dist/index.js +24 -24
- package/dist/services/all.commands.d.ts +3 -3
- package/dist/services/all.commands.js +13 -13
- package/dist/services/processors/base/console.command.d.ts +8 -8
- package/dist/services/processors/base/console.command.js +27 -27
- package/dist/services/processors/base/invalid.command.d.ts +5 -5
- package/dist/services/processors/base/invalid.command.js +14 -14
- package/dist/services/processors/base/not-logged.command.d.ts +5 -5
- package/dist/services/processors/base/not-logged.command.js +10 -10
- package/dist/services/processors/bash.command.d.ts +7 -7
- package/dist/services/processors/bash.command.js +102 -102
- package/dist/services/processors/clear-screen.command.d.ts +6 -6
- package/dist/services/processors/clear-screen.command.js +30 -30
- package/dist/services/processors/cmd.command.d.ts +7 -7
- package/dist/services/processors/cmd.command.js +99 -99
- package/dist/services/processors/help.command.d.ts +7 -7
- package/dist/services/processors/help.command.js +41 -41
- package/dist/services/processors/index.d.ts +8 -8
- package/dist/services/processors/index.js +24 -24
- package/dist/services/processors/invite.command.d.ts +9 -9
- package/dist/services/processors/invite.command.js +76 -76
- package/dist/services/processors/join.command.d.ts +8 -8
- package/dist/services/processors/join.command.js +108 -108
- package/dist/services/processors/login.command.d.ts +14 -14
- package/dist/services/processors/login.command.js +69 -69
- package/dist/services/processors/logout.command.d.ts +6 -6
- package/dist/services/processors/logout.command.js +30 -30
- package/dist/services/remote.console.service.d.ts +30 -30
- package/dist/services/remote.console.service.js +107 -107
- package/dist/services/temp.file.service.d.ts +25 -23
- package/dist/services/temp.file.service.js +102 -90
- package/dist/services/web.console.service.d.ts +57 -57
- package/dist/services/web.console.service.js +437 -437
- package/dist/web.console.module.d.ts +6 -6
- package/dist/web.console.module.js +87 -87
- package/dist.zip +0 -0
- package/package.json +5 -5
- package/tsconfig.json +18 -18
|
@@ -1,675 +1,690 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
-
};
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.WebConsoleControllerFactory = void 0;
|
|
19
|
-
const common_1 = require("@nestjs/common");
|
|
20
|
-
const ejs_1 = __importDefault(require("ejs"));
|
|
21
|
-
const express_1 = __importDefault(require("express"));
|
|
22
|
-
const http_exception_filter_1 = require("../filters/http-exception.filter");
|
|
23
|
-
const remote_console_service_1 = require("../services/remote.console.service");
|
|
24
|
-
const temp_file_service_1 = require("../services/temp.file.service");
|
|
25
|
-
const web_console_service_1 = require("../services/web.console.service");
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
input:-webkit-autofill
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
</form>
|
|
268
|
-
|
|
269
|
-
<
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
<
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
if (this.
|
|
296
|
-
this.prevCommand.
|
|
297
|
-
this.commandCount = this.prevCommand.length;
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
this.
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
<%
|
|
331
|
-
|
|
332
|
-
if (key ===
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
} else
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
const
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
$(
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
$('
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
$('#
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
$('#
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
$(
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
});
|
|
435
|
-
|
|
436
|
-
var
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
.
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
session.
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
session.
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
session.
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
__metadata("design:type",
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
(0, common_1.
|
|
630
|
-
__param(
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
(
|
|
640
|
-
|
|
641
|
-
__metadata("design:
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
(0, common_1.
|
|
647
|
-
__param(
|
|
648
|
-
|
|
649
|
-
__metadata("design:
|
|
650
|
-
__metadata("design:
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
__metadata("design:
|
|
657
|
-
__metadata("design:
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
__param(
|
|
663
|
-
__metadata("design:type", Function),
|
|
664
|
-
__metadata("design:paramtypes", [
|
|
665
|
-
__metadata("design:returntype", void 0)
|
|
666
|
-
], WebConsoleController.prototype, "
|
|
667
|
-
|
|
668
|
-
(0, common_1.
|
|
669
|
-
(0, common_1.
|
|
670
|
-
__metadata("design:
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.WebConsoleControllerFactory = void 0;
|
|
19
|
+
const common_1 = require("@nestjs/common");
|
|
20
|
+
const ejs_1 = __importDefault(require("ejs"));
|
|
21
|
+
const express_1 = __importDefault(require("express"));
|
|
22
|
+
const http_exception_filter_1 = require("../filters/http-exception.filter");
|
|
23
|
+
const remote_console_service_1 = require("../services/remote.console.service");
|
|
24
|
+
const temp_file_service_1 = require("../services/temp.file.service");
|
|
25
|
+
const web_console_service_1 = require("../services/web.console.service");
|
|
26
|
+
const core_1 = require("@nestjs/core");
|
|
27
|
+
const boot = new Date();
|
|
28
|
+
function WebConsoleControllerFactory(endpoint) {
|
|
29
|
+
let WebConsoleController = class WebConsoleController {
|
|
30
|
+
constructor(webConsoleService, remoteConsoleService, tempFileService) {
|
|
31
|
+
Object.defineProperty(this, "webConsoleService", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true,
|
|
35
|
+
value: webConsoleService
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(this, "remoteConsoleService", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: true,
|
|
41
|
+
value: remoteConsoleService
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(this, "tempFileService", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
configurable: true,
|
|
46
|
+
writable: true,
|
|
47
|
+
value: tempFileService
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(this, "consoleOptions", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
configurable: true,
|
|
52
|
+
writable: true,
|
|
53
|
+
value: void 0
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(this, "appConfig", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
configurable: true,
|
|
58
|
+
writable: true,
|
|
59
|
+
value: void 0
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(this, "view", {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
configurable: true,
|
|
64
|
+
writable: true,
|
|
65
|
+
value: `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
66
|
+
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
|
|
67
|
+
<head>
|
|
68
|
+
<title>Web Console | <%= model.name %></title>
|
|
69
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
70
|
+
<meta name="robots" content="noindex">
|
|
71
|
+
<style type="text/css">
|
|
72
|
+
* {
|
|
73
|
+
margin: 0;
|
|
74
|
+
padding: 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
html, body {
|
|
78
|
+
height: 100%;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
body {
|
|
82
|
+
background: black;
|
|
83
|
+
color: white;
|
|
84
|
+
font-family: Consolas, Monaco, monospace;
|
|
85
|
+
font-size: 0;
|
|
86
|
+
display: flex;
|
|
87
|
+
flex-direction: column;
|
|
88
|
+
transition: opacity 500ms;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
div#output {
|
|
92
|
+
overflow-y: auto;
|
|
93
|
+
overflow-x: hidden;
|
|
94
|
+
padding: 5px;
|
|
95
|
+
font-size: 14px;
|
|
96
|
+
flex: 1;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
div#bottom, div#bottom-base {
|
|
100
|
+
font-size: 14px;
|
|
101
|
+
display: flex;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
div#bottom-base {
|
|
105
|
+
padding: 10px 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
div#bottom-base > * {
|
|
109
|
+
margin-left: 10px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
span#input {
|
|
113
|
+
flex: 1;
|
|
114
|
+
display: flex;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
input, input:focus, input:active input:focus-visible {
|
|
118
|
+
font-family: Consolas, Monaco, monospace;
|
|
119
|
+
background: transparent;
|
|
120
|
+
border: none;
|
|
121
|
+
outline: none;
|
|
122
|
+
color: white;
|
|
123
|
+
font-size: 14px;
|
|
124
|
+
flex: 1;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
input:-webkit-autofill,
|
|
128
|
+
input:-webkit-autofill:hover,
|
|
129
|
+
input:-webkit-autofill:focus,
|
|
130
|
+
input:-webkit-autofill:active {
|
|
131
|
+
-webkit-box-shadow: 0 0 0 30px black inset !important;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
input:-webkit-autofill {
|
|
135
|
+
-webkit-text-fill-color: white !important;
|
|
136
|
+
font-family: Consolas, Monaco, monospace;
|
|
137
|
+
font-size: 14px;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
div.row {
|
|
141
|
+
display: flex;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
select {
|
|
145
|
+
-webkit-appearance: none;
|
|
146
|
+
-moz-appearance: none;
|
|
147
|
+
appearance: none;
|
|
148
|
+
background-color: black;
|
|
149
|
+
border: none;
|
|
150
|
+
padding: 0 1em 0 0;
|
|
151
|
+
margin: 0;
|
|
152
|
+
width: 100%;
|
|
153
|
+
font-family: inherit;
|
|
154
|
+
font-size: inherit;
|
|
155
|
+
cursor: inherit;
|
|
156
|
+
line-height: inherit;
|
|
157
|
+
color: white;
|
|
158
|
+
z-index: 1;
|
|
159
|
+
outline: none;
|
|
160
|
+
overflow: hidden;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
select::-ms-expand {
|
|
164
|
+
display: none;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.select {
|
|
168
|
+
display: grid;
|
|
169
|
+
grid-template-areas: "select";
|
|
170
|
+
align-items: center;
|
|
171
|
+
position: relative;
|
|
172
|
+
min-width: 15ch;
|
|
173
|
+
max-width: unset;
|
|
174
|
+
border: 0;
|
|
175
|
+
border-radius: 0.25em;
|
|
176
|
+
cursor: pointer;
|
|
177
|
+
background-color: #000;
|
|
178
|
+
background-image: linear-gradient(to top, #000, #000 33%);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.select select, .select::after {
|
|
182
|
+
grid-area: select;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.select:not(.select--multiple)::after {
|
|
186
|
+
content: "";
|
|
187
|
+
justify-self: end;
|
|
188
|
+
width: 0.6em;
|
|
189
|
+
height: 0.35em;
|
|
190
|
+
z-index: 1;
|
|
191
|
+
background-color: white;
|
|
192
|
+
-webkit-clip-path: polygon(100% 0%, 0 0%, 50% 100%);
|
|
193
|
+
clip-path: polygon(100% 0%, 0 0%, 50% 100%);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.select.desktop:not(.select--multiple)::after {
|
|
197
|
+
content: none;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.desktop-hide {
|
|
201
|
+
display: none !important;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.submitting {
|
|
205
|
+
pointer-events: none;
|
|
206
|
+
touch-action: none;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.submitting2 {
|
|
210
|
+
opacity: 0.7;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
select:focus + .focus {
|
|
214
|
+
position: absolute;
|
|
215
|
+
top: -1px;
|
|
216
|
+
left: -1px;
|
|
217
|
+
right: -1px;
|
|
218
|
+
bottom: -1px;
|
|
219
|
+
border: 0;
|
|
220
|
+
border-radius: inherit;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
</style>
|
|
224
|
+
<script src="https://code.jquery.com/jquery-3.6.0.slim.min.js"></script>
|
|
225
|
+
</head>
|
|
226
|
+
<body>
|
|
227
|
+
<div id="output">
|
|
228
|
+
<div>
|
|
229
|
+
Web Console | <%= model.name %><br />
|
|
230
|
+
All rights reserved.<br /><br />
|
|
231
|
+
Server boot: <%= model.boot %><br /><br />
|
|
232
|
+
</div>
|
|
233
|
+
<div id="logs">
|
|
234
|
+
<%- model.result %>
|
|
235
|
+
|
|
236
|
+
<% if (model.running && model.readLine) { %>
|
|
237
|
+
<form method="post" style="display: flex; flex: 1" class="commandFormInline">
|
|
238
|
+
<% if (model.readLineOpts.select) { %>
|
|
239
|
+
<div class="select">
|
|
240
|
+
<select id="command" name="command" size="<%= Math.max(2,model.readLineOpts.select.length) %>"
|
|
241
|
+
autofocus="autofocus">
|
|
242
|
+
<option value="[null]" id="empty">Select...</option>
|
|
243
|
+
<% model.readLineOpts.select.forEach(function(x, i) {
|
|
244
|
+
const isArray = Array.isArray(x);
|
|
245
|
+
%>
|
|
246
|
+
<option value="<%= isArray ? x[0] : x %>"><%= isArray ? x[1] : x %></option>
|
|
247
|
+
<% }) %>
|
|
248
|
+
</select>
|
|
249
|
+
<span class="focus"></span>
|
|
250
|
+
</div>
|
|
251
|
+
<% } else { %>
|
|
252
|
+
<input type="<%= model.readLineOpts.secure ? 'password' : 'text' %>" id="command" name="command" style="flex: 1"
|
|
253
|
+
autofocus="autofocus" autocomplete="off" />
|
|
254
|
+
<% } %>
|
|
255
|
+
</form><%- '</div>' %>
|
|
256
|
+
<% } %>
|
|
257
|
+
</div>
|
|
258
|
+
<div id="running"></div>
|
|
259
|
+
|
|
260
|
+
<form method="post" class="commandForm">
|
|
261
|
+
<div id="bottom">
|
|
262
|
+
<% if (!model.running) { %>
|
|
263
|
+
<span id="path">web:/> </span>
|
|
264
|
+
<span id="input"><input type="text" id="command" name="command" autofocus="autofocus" autocomplete="off" /></span>
|
|
265
|
+
<% } %>
|
|
266
|
+
</div>
|
|
267
|
+
</form>
|
|
268
|
+
|
|
269
|
+
<form method="post" id="cancelForm">
|
|
270
|
+
<input type="hidden" name="command" value="ctrl+c" />
|
|
271
|
+
</form>
|
|
272
|
+
<form method="post" id="cancelShiftForm">
|
|
273
|
+
<input type="hidden" name="command" value="ctrl+shift+c" />
|
|
274
|
+
</form>
|
|
275
|
+
</div>
|
|
276
|
+
<div id="bottom-base">
|
|
277
|
+
<% if (model.running) { %>
|
|
278
|
+
<div id="cancel">[ Terminate ]</div>
|
|
279
|
+
<div id="shiftCancel">[ Cancel Signal ]</div>
|
|
280
|
+
<% } else { %>
|
|
281
|
+
<div id="prev">[ Previous ]</div>
|
|
282
|
+
<div id="next">[ Next ]</div>
|
|
283
|
+
<% } %>
|
|
284
|
+
</div>
|
|
285
|
+
<script type="text/javascript">
|
|
286
|
+
document.getElementById('bottom').scrollIntoView(false);
|
|
287
|
+
const commands = JSON.parse(localStorage.getItem('command-history') || '[]');
|
|
288
|
+
const commandStore = {
|
|
289
|
+
index: commands.length,
|
|
290
|
+
commandCount: commands.length,
|
|
291
|
+
prevCommand: commands,
|
|
292
|
+
put: function (val) {
|
|
293
|
+
if (!val)
|
|
294
|
+
return;
|
|
295
|
+
if (this.prevCommand.indexOf(val) > -1) {
|
|
296
|
+
this.prevCommand = this.prevCommand.filter(x => x != val);
|
|
297
|
+
this.commandCount = this.prevCommand.length;
|
|
298
|
+
}
|
|
299
|
+
this.commandCount++;
|
|
300
|
+
this.index = this.commandCount;
|
|
301
|
+
this.prevCommand.push(val);
|
|
302
|
+
if (this.commandCount > 30) {
|
|
303
|
+
this.prevCommand.shift();
|
|
304
|
+
this.commandCount = this.prevCommand.length;
|
|
305
|
+
this.index = this.commandCount;
|
|
306
|
+
}
|
|
307
|
+
localStorage.setItem('command-history', JSON.stringify(this.prevCommand));
|
|
308
|
+
},
|
|
309
|
+
get: function (isUp) {
|
|
310
|
+
if (isUp && this.index > 0)
|
|
311
|
+
this.index--;
|
|
312
|
+
else if (!isUp && this.index < this.commandCount)
|
|
313
|
+
this.index++;
|
|
314
|
+
if (typeof this.prevCommand[this.index] !== "undefined") {
|
|
315
|
+
return this.prevCommand[this.index];
|
|
316
|
+
}
|
|
317
|
+
return '';
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
}
|
|
321
|
+
</script>
|
|
322
|
+
<script type="text/javascript">
|
|
323
|
+
$(document).on('keydown', function (e) {
|
|
324
|
+
e = e || window.event;
|
|
325
|
+
const key = e.which || e.keyCode;
|
|
326
|
+
const ctrl = e.ctrlKey ? e.ctrlKey : ((key === 17) ? true : false);
|
|
327
|
+
const shift = e.shiftKey ? e.shiftKey : ((key === 16) ? true : false);
|
|
328
|
+
const alt = e.altKey ? e.altKey : ((key === 18) ? true : false);
|
|
329
|
+
|
|
330
|
+
<% if (model.running) { %>
|
|
331
|
+
|
|
332
|
+
if (key === 67 && alt && shift) {
|
|
333
|
+
$('#cancelShiftForm').submit();
|
|
334
|
+
} else if (key === 67 && alt) {
|
|
335
|
+
$('#cancelForm').submit();
|
|
336
|
+
}
|
|
337
|
+
<% } else { %>
|
|
338
|
+
|
|
339
|
+
if (key === 38 && $("input").is(":focus")) {
|
|
340
|
+
const val = commandStore.get(true);
|
|
341
|
+
$("input").val(val);
|
|
342
|
+
const input = $("input")[0];
|
|
343
|
+
setTimeout(function () { input.selectionStart = input.selectionEnd = input.value.length; }, 0);
|
|
344
|
+
} else if (key === 40 && $("input").is(":focus")) {
|
|
345
|
+
const val = commandStore.get(false);
|
|
346
|
+
$("input").val(val);
|
|
347
|
+
const input = $("input")[0];
|
|
348
|
+
setTimeout(function () { input.selectionStart = input.selectionEnd = input.value.length; }, 0);
|
|
349
|
+
}
|
|
350
|
+
<% } %>
|
|
351
|
+
|
|
352
|
+
if (key === 13 && $("select").is(":focus")) {
|
|
353
|
+
$('form.commandFormInline').submit();
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
<% if (!model.readLine) { %>
|
|
358
|
+
$("form.commandForm").on("submit", function (e) {
|
|
359
|
+
commandStore.put($('input').val());
|
|
360
|
+
});
|
|
361
|
+
<% } %>
|
|
362
|
+
|
|
363
|
+
<% if (model.running && !model.readLine) { %>
|
|
364
|
+
let start = +'<%= model.result.length %>';
|
|
365
|
+
setInterval(() => {
|
|
366
|
+
fetch('<%= model.url %>/substring/' + start).then(x => x.json())
|
|
367
|
+
.then(x => {
|
|
368
|
+
if (!x.running || x.readLine)
|
|
369
|
+
window.location.href = '<%= model.url %>';
|
|
370
|
+
else if (x.result.length) {
|
|
371
|
+
$('#logs').append(x.result);
|
|
372
|
+
start += x.result.length;
|
|
373
|
+
document.getElementById('bottom').scrollIntoView(false);
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
}, 1000);
|
|
377
|
+
let ticks = 1;
|
|
378
|
+
setInterval(() => {
|
|
379
|
+
$('#running').html('.'.repeat(ticks++));
|
|
380
|
+
if (ticks > 3)
|
|
381
|
+
ticks = 1;
|
|
382
|
+
}, 300);
|
|
383
|
+
<% } %>
|
|
384
|
+
if (window.history.replaceState) {
|
|
385
|
+
window.history.replaceState(null, null, window.location.href);
|
|
386
|
+
}
|
|
387
|
+
const isMobile = (navigator.maxTouchPoints || 'ontouchstart' in document.documentElement);
|
|
388
|
+
|
|
389
|
+
<% if (model.readLine && model.readLineOpts.select) { %>
|
|
390
|
+
if (isMobile) {
|
|
391
|
+
$('select').on('change', function () {
|
|
392
|
+
if ($(this).val() !== '[null]')
|
|
393
|
+
$('form.commandFormInline').submit();
|
|
394
|
+
});
|
|
395
|
+
$('select').attr('size', 1);
|
|
396
|
+
} else {
|
|
397
|
+
$('select > option').first().remove();
|
|
398
|
+
$('.select').addClass('desktop');
|
|
399
|
+
}
|
|
400
|
+
$('select')[0].selectedIndex = 0;
|
|
401
|
+
<% } %>
|
|
402
|
+
if (!isMobile) {
|
|
403
|
+
$('#bottom-base').addClass('desktop-hide');
|
|
404
|
+
}
|
|
405
|
+
<% if (model.running) { %>
|
|
406
|
+
if (isMobile) {
|
|
407
|
+
$('#cancel').on('click', function () {
|
|
408
|
+
$('#cancelForm').submit();
|
|
409
|
+
});
|
|
410
|
+
$('#shiftCancel').on('click', function () {
|
|
411
|
+
$('#cancelShiftForm').submit();
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
<% } else { %>
|
|
415
|
+
|
|
416
|
+
if (isMobile) {
|
|
417
|
+
$('#prev').on('click', function () {
|
|
418
|
+
const val = commandStore.get(true);
|
|
419
|
+
$("input").val(val);
|
|
420
|
+
const input = $("input")[0];
|
|
421
|
+
setTimeout(function () { input.selectionStart = input.selectionEnd = input.value.length; }, 0);
|
|
422
|
+
});
|
|
423
|
+
$('#next').on('click', function () {
|
|
424
|
+
const val = commandStore.get(false);
|
|
425
|
+
$("input").val(val);
|
|
426
|
+
const input = $("input")[0];
|
|
427
|
+
setTimeout(function () { input.selectionStart = input.selectionEnd = input.value.length; }, 0);
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
<% } %>
|
|
431
|
+
$('form').on('submit', function () {
|
|
432
|
+
document.activeElement?.blur();
|
|
433
|
+
$('body').addClass('submitting submitting2');
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
var longpress = false;
|
|
437
|
+
|
|
438
|
+
$("body").on('click', function () {
|
|
439
|
+
if (!longpress)
|
|
440
|
+
document.getElementById('command')?.focus();
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
var startTime, endTime;
|
|
444
|
+
$("body").on('mousedown', function () {
|
|
445
|
+
startTime = new Date().getTime();
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
$("body").on('mouseup', function () {
|
|
449
|
+
endTime = new Date().getTime();
|
|
450
|
+
longpress = (endTime - startTime < 500) ? false : true;
|
|
451
|
+
});
|
|
452
|
+
</script>
|
|
453
|
+
</body>
|
|
454
|
+
</html>
|
|
455
|
+
`
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
async getSubstring(req, res, start) {
|
|
459
|
+
const session = this.webConsoleService.getSession(req, res);
|
|
460
|
+
let result;
|
|
461
|
+
if (session.logs.length <= +start)
|
|
462
|
+
result = '';
|
|
463
|
+
else
|
|
464
|
+
result = session.logs.substring(+start);
|
|
465
|
+
return res.send({
|
|
466
|
+
result,
|
|
467
|
+
running: session.running,
|
|
468
|
+
readLine: !!session.readLineCallback,
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
async get(req, res) {
|
|
472
|
+
const session = this.webConsoleService.getSession(req, res);
|
|
473
|
+
const globalPrefix = this.appConfig.getGlobalPrefix();
|
|
474
|
+
return res.send(ejs_1.default.render(this.view, {
|
|
475
|
+
model: {
|
|
476
|
+
name: this.consoleOptions.name,
|
|
477
|
+
result: session.logs,
|
|
478
|
+
running: session.running,
|
|
479
|
+
readLine: !!session.readLineCallback,
|
|
480
|
+
readLineOpts: session.readLineOpts,
|
|
481
|
+
boot,
|
|
482
|
+
url: `${globalPrefix || ''}/${endpoint}`
|
|
483
|
+
}
|
|
484
|
+
})
|
|
485
|
+
.replace(/>[\r\n ]+</g, "><")
|
|
486
|
+
.replace(/(<.*?>)|\s+/g, (m, $1) => $1 ? $1 : ' ')
|
|
487
|
+
.trim());
|
|
488
|
+
}
|
|
489
|
+
async post(command, req, res, ip) {
|
|
490
|
+
var _a, _b, _c;
|
|
491
|
+
if (command == null)
|
|
492
|
+
command = '';
|
|
493
|
+
const escaped = command.replace(/\\\|/g, '\r\n');
|
|
494
|
+
const cmds = escaped.split("|").filter(x => x)
|
|
495
|
+
.map(x => x.replace(/\r\n/g, '|'));
|
|
496
|
+
const session = this.webConsoleService.getSession(req, res);
|
|
497
|
+
const globalPrefix = this.appConfig.getGlobalPrefix();
|
|
498
|
+
if (command == 'ctrl+c') {
|
|
499
|
+
session.cancel = true;
|
|
500
|
+
(_a = session.onCancel) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
501
|
+
if (session.readLineCallback) {
|
|
502
|
+
session.readLineCallback(null);
|
|
503
|
+
session.logs += '</div>';
|
|
504
|
+
session.readLineCallback = null;
|
|
505
|
+
}
|
|
506
|
+
session.logs += '<div>Operation canceled</div><br/>';
|
|
507
|
+
session.running = false;
|
|
508
|
+
}
|
|
509
|
+
else if (command == 'ctrl+shift+c') {
|
|
510
|
+
if (session.onCancelSignal)
|
|
511
|
+
(_b = session.onCancelSignal) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
512
|
+
else {
|
|
513
|
+
session.cancel = true;
|
|
514
|
+
(_c = session.onCancel) === null || _c === void 0 ? void 0 : _c.call(this);
|
|
515
|
+
if (session.readLineCallback) {
|
|
516
|
+
session.readLineCallback(null);
|
|
517
|
+
session.logs += '</div>';
|
|
518
|
+
session.readLineCallback = null;
|
|
519
|
+
}
|
|
520
|
+
session.logs += '<div>Operation canceled</div><br/>';
|
|
521
|
+
session.running = false;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
else {
|
|
525
|
+
if (session.readLineCallback) {
|
|
526
|
+
(async () => {
|
|
527
|
+
session.readLineCallback(command);
|
|
528
|
+
})().catch(e => {
|
|
529
|
+
if (session.cancel)
|
|
530
|
+
return;
|
|
531
|
+
session.logs += e + '<br/><br/>';
|
|
532
|
+
session.running = false;
|
|
533
|
+
});
|
|
534
|
+
session.readLineCallback = null;
|
|
535
|
+
}
|
|
536
|
+
else {
|
|
537
|
+
session.cancel = false;
|
|
538
|
+
session.onCancel = null;
|
|
539
|
+
session.running = true;
|
|
540
|
+
(async () => {
|
|
541
|
+
if (!cmds.length) {
|
|
542
|
+
session.logs += `web:/> `;
|
|
543
|
+
}
|
|
544
|
+
for (let i = 0; i < cmds.length; i++) {
|
|
545
|
+
let cmd = cmds[i];
|
|
546
|
+
const { cmd: parsed, arg } = this.webConsoleService.parse(cmd, session);
|
|
547
|
+
await parsed.process({
|
|
548
|
+
session,
|
|
549
|
+
arg,
|
|
550
|
+
req,
|
|
551
|
+
res,
|
|
552
|
+
ip,
|
|
553
|
+
rawCommand: cmd,
|
|
554
|
+
log: (...text) => this.webConsoleService.log(session, this.webConsoleService.escapeHtml(text.map(x => typeof x == "object" ? JSON.stringify(x, null, 2) : x).join(' ')).replace(/\n/g, '<br/>').replace(/\r/g, '').replace(/\s\s/g, ' ')),
|
|
555
|
+
logRaw: (text) => this.webConsoleService.log(session, text),
|
|
556
|
+
logTable: (entities, noColumns) => this.webConsoleService.log(session, this.webConsoleService.toTable(entities, noColumns)),
|
|
557
|
+
readArgs: (mapList, parameters) => this.webConsoleService.readArgs(session, arg, mapList, parameters),
|
|
558
|
+
readLine: (title, opts) => this.webConsoleService.readLine(session, title || '', opts),
|
|
559
|
+
parseArgs: (funcArg) => this.webConsoleService.parseArgs(funcArg || arg),
|
|
560
|
+
toTable: this.webConsoleService.toTable,
|
|
561
|
+
loop: this.webConsoleService.loopFactory(session),
|
|
562
|
+
longWork: this.webConsoleService.longWorkFactory(session),
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
})().catch(e => {
|
|
566
|
+
if (session.cancel)
|
|
567
|
+
return;
|
|
568
|
+
session.logs += e + '<br/>';
|
|
569
|
+
}).finally(() => {
|
|
570
|
+
if (session.cancel)
|
|
571
|
+
return;
|
|
572
|
+
session.logs += '<br/>';
|
|
573
|
+
session.running = false;
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
setImmediate(() => {
|
|
578
|
+
res.send(ejs_1.default.render(this.view, {
|
|
579
|
+
model: {
|
|
580
|
+
name: this.consoleOptions.name,
|
|
581
|
+
result: session.logs,
|
|
582
|
+
running: session.running,
|
|
583
|
+
readLine: !!session.readLineCallback,
|
|
584
|
+
readLineOpts: session.readLineOpts,
|
|
585
|
+
boot,
|
|
586
|
+
url: `${globalPrefix || ''}/${endpoint}`
|
|
587
|
+
}
|
|
588
|
+
})
|
|
589
|
+
.replace(/>[\r\n ]+</g, "><")
|
|
590
|
+
.replace(/(<.*?>)|\s+/g, (m, $1) => $1 ? $1 : ' ')
|
|
591
|
+
.trim());
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
invite(input) {
|
|
595
|
+
return this.remoteConsoleService.inviteThisConsole(input.name, input.v, input.p);
|
|
596
|
+
}
|
|
597
|
+
stream(input) {
|
|
598
|
+
return this.remoteConsoleService.pumpStream(input);
|
|
599
|
+
}
|
|
600
|
+
close(input) {
|
|
601
|
+
return this.remoteConsoleService.closeFromRemote(input.name);
|
|
602
|
+
}
|
|
603
|
+
downloadTemp(name, res) {
|
|
604
|
+
const file = this.tempFileService.read(name);
|
|
605
|
+
switch (file.type) {
|
|
606
|
+
case 'csv':
|
|
607
|
+
if (!res['csv'])
|
|
608
|
+
throw new common_1.BadRequestException('Module csv-express not installed');
|
|
609
|
+
res.charset = 'utf8';
|
|
610
|
+
return res['csv'](file.content, true);
|
|
611
|
+
case 'html':
|
|
612
|
+
res.setHeader('Content-Type', 'text/html');
|
|
613
|
+
return res.send(file.content);
|
|
614
|
+
}
|
|
615
|
+
throw new common_1.BadRequestException(`Invalid file type: ${file.type}`);
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
__decorate([
|
|
619
|
+
(0, common_1.Inject)('CONFIG_ROOT_OPTIONS'),
|
|
620
|
+
__metadata("design:type", Object)
|
|
621
|
+
], WebConsoleController.prototype, "consoleOptions", void 0);
|
|
622
|
+
__decorate([
|
|
623
|
+
(0, common_1.Inject)(core_1.ApplicationConfig),
|
|
624
|
+
__metadata("design:type", core_1.ApplicationConfig)
|
|
625
|
+
], WebConsoleController.prototype, "appConfig", void 0);
|
|
626
|
+
__decorate([
|
|
627
|
+
(0, common_1.Get)('substring/:start'),
|
|
628
|
+
__param(0, (0, common_1.Req)()),
|
|
629
|
+
__param(1, (0, common_1.Res)()),
|
|
630
|
+
__param(2, (0, common_1.Param)('start')),
|
|
631
|
+
__metadata("design:type", Function),
|
|
632
|
+
__metadata("design:paramtypes", [Object, Object, String]),
|
|
633
|
+
__metadata("design:returntype", Promise)
|
|
634
|
+
], WebConsoleController.prototype, "getSubstring", null);
|
|
635
|
+
__decorate([
|
|
636
|
+
(0, common_1.Get)(),
|
|
637
|
+
__param(0, (0, common_1.Req)()),
|
|
638
|
+
__param(1, (0, common_1.Res)()),
|
|
639
|
+
__metadata("design:type", Function),
|
|
640
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
641
|
+
__metadata("design:returntype", Promise)
|
|
642
|
+
], WebConsoleController.prototype, "get", null);
|
|
643
|
+
__decorate([
|
|
644
|
+
(0, common_1.Post)(),
|
|
645
|
+
__param(0, (0, common_1.Body)('command')),
|
|
646
|
+
__param(1, (0, common_1.Req)()),
|
|
647
|
+
__param(2, (0, common_1.Res)()),
|
|
648
|
+
__param(3, (0, common_1.Ip)()),
|
|
649
|
+
__metadata("design:type", Function),
|
|
650
|
+
__metadata("design:paramtypes", [String, Object, Object, String]),
|
|
651
|
+
__metadata("design:returntype", Promise)
|
|
652
|
+
], WebConsoleController.prototype, "post", null);
|
|
653
|
+
__decorate([
|
|
654
|
+
(0, common_1.Get)('remote/invite'),
|
|
655
|
+
__param(0, (0, common_1.Query)()),
|
|
656
|
+
__metadata("design:type", Function),
|
|
657
|
+
__metadata("design:paramtypes", [Object]),
|
|
658
|
+
__metadata("design:returntype", void 0)
|
|
659
|
+
], WebConsoleController.prototype, "invite", null);
|
|
660
|
+
__decorate([
|
|
661
|
+
(0, common_1.Post)('remote/stream'),
|
|
662
|
+
__param(0, (0, common_1.Body)()),
|
|
663
|
+
__metadata("design:type", Function),
|
|
664
|
+
__metadata("design:paramtypes", [Object]),
|
|
665
|
+
__metadata("design:returntype", void 0)
|
|
666
|
+
], WebConsoleController.prototype, "stream", null);
|
|
667
|
+
__decorate([
|
|
668
|
+
(0, common_1.Post)('remote/close'),
|
|
669
|
+
__param(0, (0, common_1.Body)()),
|
|
670
|
+
__metadata("design:type", Function),
|
|
671
|
+
__metadata("design:paramtypes", [Object]),
|
|
672
|
+
__metadata("design:returntype", void 0)
|
|
673
|
+
], WebConsoleController.prototype, "close", null);
|
|
674
|
+
__decorate([
|
|
675
|
+
(0, common_1.Get)('file/:name'),
|
|
676
|
+
__param(0, (0, common_1.Param)('name')),
|
|
677
|
+
__param(1, (0, common_1.Res)()),
|
|
678
|
+
__metadata("design:type", Function),
|
|
679
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
680
|
+
__metadata("design:returntype", void 0)
|
|
681
|
+
], WebConsoleController.prototype, "downloadTemp", null);
|
|
682
|
+
WebConsoleController = __decorate([
|
|
683
|
+
(0, common_1.Controller)(endpoint || 'console'),
|
|
684
|
+
(0, common_1.UseFilters)(http_exception_filter_1.HttpExceptionFilter),
|
|
685
|
+
__metadata("design:paramtypes", [web_console_service_1.WebConsoleService, remote_console_service_1.RemoteConsoleService,
|
|
686
|
+
temp_file_service_1.TempFileService])
|
|
687
|
+
], WebConsoleController);
|
|
688
|
+
return WebConsoleController;
|
|
689
|
+
}
|
|
690
|
+
exports.WebConsoleControllerFactory = WebConsoleControllerFactory;
|