skystream-cli 1.3.6 → 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 +39 -3
- 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._-]+$/),
|
|
@@ -483,6 +484,41 @@ program.command('test')
|
|
|
483
484
|
},
|
|
484
485
|
btoa: (s) => Buffer.from(s).toString('base64'),
|
|
485
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
|
+
},
|
|
486
522
|
globalThis: {},
|
|
487
523
|
};
|
|
488
524
|
const entityDefs = `
|
|
@@ -537,8 +573,8 @@ program.command('test')
|
|
|
537
573
|
console.error("Critical Runtime Error: " + e.stack);
|
|
538
574
|
}
|
|
539
575
|
`;
|
|
540
|
-
const runtime = new Function('manifest', 'console', 'http_get', 'http_post', '_fetch', 'fetch', 'btoa', 'atob', 'globalThis', combinedScript);
|
|
541
|
-
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);
|
|
542
578
|
const fn = context.globalThis[options.function];
|
|
543
579
|
if (typeof fn !== 'function') {
|
|
544
580
|
console.error('Error: exported function not found');
|