expose-kit 0.2.7 → 0.2.8

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/README.md CHANGED
@@ -85,7 +85,7 @@ If you try to write your own deobfuscation logic (e.g. in Python), you’ll quic
85
85
  That’s why you should **always start with**:
86
86
 
87
87
  ```bash
88
- expose scope-safe input.js
88
+ expose safe-scope input.js
89
89
  ```
90
90
 
91
91
  This renames bindings per scope, producing code like:
@@ -104,7 +104,7 @@ With this alone:
104
104
 
105
105
  ### 3. Apply transforms step by step
106
106
 
107
- After `scope-safe`, combine common techniques like:
107
+ After `safe-scope`, combine common techniques like:
108
108
  - `expand-array` and more
109
109
  - legacy obfuscator-specific commands
110
110
 
@@ -136,19 +136,19 @@ Args:
136
136
 
137
137
  ---
138
138
 
139
- ### `expose scope-safe`
139
+ ### `expose safe-scope`
140
140
 
141
141
  Rename bindings per scope for safer transformations.
142
142
 
143
143
  ```bash
144
- expose scope-safe path/to/file.js --output path/to/file.scope-safe.js
144
+ expose safe-scope path/to/file.js --output path/to/file.safe-scope.js
145
145
  ```
146
146
 
147
147
  Args:
148
148
  - `--o, --output <file>`
149
149
  Output file path
150
- - No extension → `file.scope-safe.js`
151
- - With extension → `file.scope-safe.<ext>`
150
+ - No extension → `file.safe-scope.js`
151
+ - With extension → `file.safe-scope.<ext>`
152
152
 
153
153
  ---
154
154
 
package/dist/index.js CHANGED
@@ -59,13 +59,14 @@ var createParseOptions = (filename) => {
59
59
  };
60
60
 
61
61
  // utils/common/timeout.ts
62
+ var MAX_TIMEOUT = 2147483647;
62
63
  var timeout = (fn, ms) => {
63
64
  let aborted = false;
64
65
  const { resolve, reject, promise } = Promise.withResolvers();
65
66
  const timer = setTimeout(() => {
66
67
  aborted = true;
67
68
  reject(new Error("Hang detected, please report to the developer"));
68
- }, ms);
69
+ }, ms ?? MAX_TIMEOUT);
69
70
  const finish = () => {
70
71
  clearTimeout(timer);
71
72
  resolve();
@@ -118,13 +119,13 @@ var parsable_default = createCommand((program2) => {
118
119
  return finish();
119
120
  }
120
121
  },
121
- options.unlimited ? Infinity : 30 * 1e3
122
+ options.unlimited ? null : 30 * 1e3
122
123
  );
123
124
  }
124
125
  );
125
126
  });
126
127
 
127
- // commands/scope-safe/index.ts
128
+ // commands/safe-scope/index.ts
128
129
  import { readFileSync as readFileSync2, writeFileSync } from "fs";
129
130
  import { basename, dirname, extname, join } from "path";
130
131
  import { parse as parse2 } from "@babel/parser";
@@ -134,6 +135,9 @@ import loading2 from "loading-cli";
134
135
 
135
136
  // utils/babel/patchDefault.ts
136
137
  var patchDefault = (babelFn) => {
138
+ if (typeof babelFn === "function") {
139
+ return babelFn;
140
+ }
137
141
  return babelFn.default;
138
142
  };
139
143
 
@@ -151,14 +155,14 @@ function diff(before, after) {
151
155
  return changed;
152
156
  }
153
157
 
154
- // commands/scope-safe/index.ts
158
+ // commands/safe-scope/index.ts
155
159
  var createDefaultOutputPath = (inputPath) => {
156
160
  const ext = extname(inputPath);
157
161
  if (!ext) {
158
- return `${inputPath}.scope-safe.js`;
162
+ return `${inputPath}.safe-scope.js`;
159
163
  }
160
164
  const base = basename(inputPath, ext);
161
- return join(dirname(inputPath), `${base}.scope-safe${ext}`);
165
+ return join(dirname(inputPath), `${base}.safe-scope${ext}`);
162
166
  };
163
167
  var renameBindingsByScope = (code, filename) => {
164
168
  const ast = parse2(code, createParseOptions(filename));
@@ -184,8 +188,8 @@ var renameBindingsByScope = (code, filename) => {
184
188
  });
185
189
  return patchDefault(generate)(ast).code;
186
190
  };
187
- var scope_safe_default = createCommand((program2) => {
188
- program2.command("scope-safe").description("Rename bindings per scope for safer transforms").argument("[file]", "The file to transform").option("--input, --file <file>", "The file to transform").option("--o, --output <file>", "Output file path").option("--unlimited", "Unlimited timeout").action(
191
+ var safe_scope_default = createCommand((program2) => {
192
+ program2.command("safe-scope").description("Rename bindings per scope for safer transforms").argument("[file]", "The file to transform").option("--input, --file <file>", "The file to transform").option("--o, --output <file>", "Output file path").option("--unlimited", "Unlimited timeout").action(
189
193
  async (fileArgument, options) => {
190
194
  await timeout(
191
195
  async ({ finish }) => {
@@ -197,15 +201,21 @@ var scope_safe_default = createCommand((program2) => {
197
201
  try {
198
202
  const fileContent = readFileSync2(filename, "utf8");
199
203
  const defaultOutputPath = createDefaultOutputPath(filename);
200
- const outputPath = options.output ?? (await createPrompt("Enter the output file path:") || "").trim() ?? defaultOutputPath;
204
+ let outputPath = options.output;
205
+ if (!outputPath) {
206
+ const promptPath = (await createPrompt("Enter the output file path:"))?.trim();
207
+ outputPath = promptPath || defaultOutputPath;
208
+ }
201
209
  const loader = loading2("Renaming variables by scope...").start();
202
210
  try {
203
211
  const output = renameBindingsByScope(fileContent, filename);
204
212
  writeFileSync(outputPath, output, "utf8");
205
- loader.succeed(`Saved scope-safe file to: ${outputPath} (${diff(fileContent, output).length} lines changed)`);
213
+ loader.succeed(
214
+ `Saved safe-scope file to: ${outputPath} (${diff(fileContent, output).length} lines changed)`
215
+ );
206
216
  return finish();
207
217
  } catch (error) {
208
- loader.fail("Failed to apply scope-safe transform");
218
+ loader.fail("Failed to apply safe-scope transform");
209
219
  showError(
210
220
  `Error transforming file '${filename}': ${error instanceof Error ? error.message : "Unknown error"}`
211
221
  );
@@ -218,7 +228,7 @@ var scope_safe_default = createCommand((program2) => {
218
228
  return finish();
219
229
  }
220
230
  },
221
- options.unlimited ? Infinity : 120 * 1e3
231
+ options.unlimited ? null : 120 * 1e3
222
232
  );
223
233
  }
224
234
  );
@@ -287,7 +297,7 @@ program.name("expose").description("CLI for Deobfuscating").version(
287
297
  "-v, --version",
288
298
  "display version number"
289
299
  );
290
- var commands = [parsable_default, scope_safe_default];
300
+ var commands = [parsable_default, safe_scope_default];
291
301
  for (const command of commands) {
292
302
  command(program);
293
303
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expose-kit",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "author": "EdamAmex <edame8080@gmail.com> (https://github.com/EdamAme-x)",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expose-kit",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "author": "EdamAmex <edame8080@gmail.com> (https://github.com/EdamAme-x)",