skystream-cli 1.3.5 → 1.3.7
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 +44 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import * as path from 'path';
|
|
4
|
+
import * as crypto from 'crypto';
|
|
4
5
|
import fs from 'fs-extra';
|
|
5
6
|
import { z } from 'zod';
|
|
6
7
|
import archiver from 'archiver';
|
|
@@ -9,7 +10,7 @@ const program = new Command();
|
|
|
9
10
|
program
|
|
10
11
|
.name('skystream')
|
|
11
12
|
.description('SkyStream Plugin Development Kit CLI (Sky Gen 2)')
|
|
12
|
-
.version('1.3.
|
|
13
|
+
.version('1.3.7');
|
|
13
14
|
// Schemas
|
|
14
15
|
const pluginSchema = z.object({
|
|
15
16
|
packageName: z.string().min(5).regex(/^[a-z0-9._-]+$/),
|
|
@@ -436,13 +437,13 @@ program.command('test')
|
|
|
436
437
|
http_get: async (url, headers, cb) => {
|
|
437
438
|
try {
|
|
438
439
|
const res = await axios.get(url, { headers: headers || {} });
|
|
439
|
-
const result = { statusCode: res.status, body: typeof res.data === 'string' ? res.data : JSON.stringify(res.data), headers: res.headers };
|
|
440
|
+
const result = { status: res.status, statusCode: res.status, body: typeof res.data === 'string' ? res.data : JSON.stringify(res.data), headers: res.headers };
|
|
440
441
|
if (cb)
|
|
441
442
|
cb(result);
|
|
442
443
|
return result;
|
|
443
444
|
}
|
|
444
445
|
catch (e) {
|
|
445
|
-
const res = { statusCode: e.response?.status || 500, body: e.response?.data || e.message, headers: e.response?.headers || {} };
|
|
446
|
+
const res = { status: e.response?.status || 500, statusCode: e.response?.status || 500, body: e.response?.data || e.message, headers: e.response?.headers || {} };
|
|
446
447
|
if (cb)
|
|
447
448
|
cb(res);
|
|
448
449
|
return res;
|
|
@@ -451,13 +452,13 @@ program.command('test')
|
|
|
451
452
|
http_post: async (url, headers, body, cb) => {
|
|
452
453
|
try {
|
|
453
454
|
const res = await axios.post(url, body, { headers: headers || {} });
|
|
454
|
-
const result = { statusCode: res.status, body: typeof res.data === 'string' ? res.data : JSON.stringify(res.data), headers: res.headers };
|
|
455
|
+
const result = { status: res.status, statusCode: res.status, body: typeof res.data === 'string' ? res.data : JSON.stringify(res.data), headers: res.headers };
|
|
455
456
|
if (cb)
|
|
456
457
|
cb(result);
|
|
457
458
|
return result;
|
|
458
459
|
}
|
|
459
460
|
catch (e) {
|
|
460
|
-
const res = { statusCode: e.response?.status || 500, body: e.response?.data || e.message, headers: e.response?.headers || {} };
|
|
461
|
+
const res = { status: e.response?.status || 500, statusCode: e.response?.status || 500, body: e.response?.data || e.message, headers: e.response?.headers || {} };
|
|
461
462
|
if (cb)
|
|
462
463
|
cb(res);
|
|
463
464
|
return res;
|
|
@@ -475,6 +476,7 @@ program.command('test')
|
|
|
475
476
|
fetch: async (url) => {
|
|
476
477
|
const res = await axios.get(url);
|
|
477
478
|
return {
|
|
479
|
+
status: res.status,
|
|
478
480
|
statusCode: res.status,
|
|
479
481
|
body: typeof res.data === 'string' ? res.data : JSON.stringify(res.data),
|
|
480
482
|
headers: res.headers
|
|
@@ -482,6 +484,41 @@ program.command('test')
|
|
|
482
484
|
},
|
|
483
485
|
btoa: (s) => Buffer.from(s).toString('base64'),
|
|
484
486
|
atob: (s) => Buffer.from(s, 'base64').toString('utf8'),
|
|
487
|
+
sendMessage: async (id, arg) => {
|
|
488
|
+
if (id === 'crypto_decrypt_aes') {
|
|
489
|
+
const { data, key, iv } = JSON.parse(arg);
|
|
490
|
+
try {
|
|
491
|
+
// Standardize key and iv to correct lengths
|
|
492
|
+
// They are often passed as base64 strings
|
|
493
|
+
const decodeBuffer = (s) => {
|
|
494
|
+
return s.length % 4 === 0 && /^[A-Za-z0-9+/=]+$/.test(s) ? Buffer.from(s, 'base64') : Buffer.from(s, 'utf8');
|
|
495
|
+
};
|
|
496
|
+
const k = decodeBuffer(key);
|
|
497
|
+
const ivBuf = Buffer.alloc(16, 0);
|
|
498
|
+
decodeBuffer(iv).copy(ivBuf);
|
|
499
|
+
let algo = 'aes-256-cbc';
|
|
500
|
+
let finalKey = Buffer.alloc(32, 0);
|
|
501
|
+
if (k.length <= 16) {
|
|
502
|
+
algo = 'aes-128-cbc';
|
|
503
|
+
finalKey = Buffer.alloc(16, 0);
|
|
504
|
+
}
|
|
505
|
+
else if (k.length <= 24) {
|
|
506
|
+
algo = 'aes-192-cbc';
|
|
507
|
+
finalKey = Buffer.alloc(24, 0);
|
|
508
|
+
}
|
|
509
|
+
k.copy(finalKey);
|
|
510
|
+
const decipher = crypto.createDecipheriv(algo, finalKey, ivBuf);
|
|
511
|
+
let decrypted = decipher.update(data, 'base64', 'utf8');
|
|
512
|
+
decrypted += decipher.final('utf8');
|
|
513
|
+
return decrypted;
|
|
514
|
+
}
|
|
515
|
+
catch (e) {
|
|
516
|
+
console.error(' [Mock ERR]: AES Decryption failed:', e.message);
|
|
517
|
+
return data;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
return '';
|
|
521
|
+
},
|
|
485
522
|
globalThis: {},
|
|
486
523
|
};
|
|
487
524
|
const entityDefs = `
|
|
@@ -536,8 +573,8 @@ program.command('test')
|
|
|
536
573
|
console.error("Critical Runtime Error: " + e.stack);
|
|
537
574
|
}
|
|
538
575
|
`;
|
|
539
|
-
const runtime = new Function('manifest', 'console', 'http_get', 'http_post', '_fetch', 'fetch', 'btoa', 'atob', 'globalThis', combinedScript);
|
|
540
|
-
runtime(context.manifest, context.console, context.http_get, context.http_post, context._fetch, context.fetch, context.btoa, context.atob, context.globalThis);
|
|
576
|
+
const runtime = new Function('manifest', 'console', 'http_get', 'http_post', '_fetch', 'fetch', 'btoa', 'atob', 'sendMessage', 'globalThis', combinedScript);
|
|
577
|
+
runtime(context.manifest, context.console, context.http_get, context.http_post, context._fetch, context.fetch, context.btoa, context.atob, context.sendMessage, context.globalThis);
|
|
541
578
|
const fn = context.globalThis[options.function];
|
|
542
579
|
if (typeof fn !== 'function') {
|
|
543
580
|
console.error('Error: exported function not found');
|