js-confuser-vm 0.0.1 → 0.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/dist/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import { compileAndSerialize } from "./compiler.js";
2
+ import { DEFAULT_OPTIONS } from "./options.js";
3
+ async function obfuscate(source, options = DEFAULT_OPTIONS) {
4
+ const result = compileAndSerialize(source, options);
5
+ return result;
6
+ }
7
+ export const JsConfuserVM = {
8
+ obfuscate
9
+ };
10
+ export default JsConfuserVM;
package/dist/minify.js ADDED
@@ -0,0 +1,18 @@
1
+ import ClosureCompiler from "google-closure-compiler";
2
+ export function minify(sourceCode) {
3
+ return new Promise((resolve, reject) => {
4
+ const compiler = new ClosureCompiler({
5
+ compilation_level: "ADVANCED",
6
+ warning_level: "QUIET"
7
+ });
8
+ const compilerProcess = compiler.run((exitCode, stdOut, stdErr) => {
9
+ if (exitCode !== 0) {
10
+ reject(new Error(stdErr || `Closure Compiler exited with code ${exitCode}`));
11
+ } else {
12
+ resolve(stdOut);
13
+ }
14
+ });
15
+ compilerProcess.stdin.write(sourceCode);
16
+ compilerProcess.stdin.end();
17
+ });
18
+ }
@@ -0,0 +1 @@
1
+ export const DEFAULT_OPTIONS = {};
package/dist/random.js ADDED
@@ -0,0 +1,27 @@
1
+ import { ok } from "assert";
2
+ export function getPlaceholder() {
3
+ return Math.random().toString(36).substring(2, 15);
4
+ }
5
+ export function choice(elements) {
6
+ ok(elements.length > 0, "choice() called on empty sequence");
7
+ return elements[Math.floor(Math.random() * elements.length)];
8
+ }
9
+ export function getRandom() {
10
+ return Math.random();
11
+ }
12
+ export function getRandomInt(min, max) {
13
+ ok(min <= max, "min must be <= max");
14
+ return Math.floor(Math.random() * (max - min + 1)) + min;
15
+ }
16
+
17
+ /**
18
+ * Shuffles an array in-place using the Fisher-Yates algorithm.
19
+ * @param array - The array to shuffle (mutated)
20
+ */
21
+ export function shuffle(array) {
22
+ for (let i = array.length - 1; i > 0; i--) {
23
+ const j = Math.floor(Math.random() * (i + 1));
24
+ [array[i], array[j]] = [array[j], array[i]];
25
+ }
26
+ return array;
27
+ }