expose-kit 0.11.0 → 0.13.0

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
@@ -358,6 +358,84 @@ Notes:
358
358
 
359
359
  ---
360
360
 
361
+ ### `expose remove-anti-tamper`
362
+
363
+ Drop the self-defending wrapper, debug guards, and console hijacks generated by anti-tamper scripts.
364
+ ```js
365
+ var wrapper = (function () {
366
+ var guard = true;
367
+ return function (ctx, fn) {
368
+ var thunk = guard ? function () {
369
+ if (fn) {
370
+ fn.apply(ctx, arguments);
371
+ fn = null;
372
+ }
373
+ } : function () {};
374
+ guard = false;
375
+ return thunk;
376
+ };
377
+ })();
378
+
379
+ wrapper(this, function () {
380
+ console.log("tamper");
381
+ });
382
+
383
+ console.log("safe");
384
+ ```
385
+ Example is [here](https://github.com/evex-dev/expose-kit/tree/main/commands/remove-anti-tamper/mocks).
386
+
387
+ ```bash
388
+ expose remove-anti-tamper path/to/file.js --output path/to/file.remove-anti-tamper.js
389
+ ```
390
+
391
+ Args:
392
+ - `--o, --output <file>`
393
+ Output file path
394
+
395
+ Notes:
396
+ - Targets wrappers that return guarded helper functions and removes their invocations.
397
+ - Cleans up debug/console helper functions before removing the wrapper.
398
+
399
+ ---
400
+
401
+ ### `expose control-flow-packer`
402
+
403
+ Inline control-flow flattening loops generated by string-based state machines.
404
+ ```js
405
+ const _0x1 = "a|b|c".split("|");
406
+ let _0x2 = 0;
407
+
408
+ while (true) {
409
+ switch (_0x1[_0x2++]) {
410
+ case "a":
411
+ console.log("a");
412
+ continue;
413
+ case "b":
414
+ console.log("b");
415
+ continue;
416
+ case "c":
417
+ console.log("c");
418
+ return;
419
+ }
420
+ break;
421
+ }
422
+ ```
423
+ Example is [here](https://github.com/evex-dev/expose-kit/tree/main/commands/control-flow-packer/mocks).
424
+
425
+ ```bash
426
+ expose control-flow-packer path/to/file.js --output path/to/file.control-flow-packer.js
427
+ ```
428
+
429
+ Args:
430
+ - `--o, --output <file>`
431
+ Output file path
432
+
433
+ Notes:
434
+ - Only flattens loops whose state array comes from a literal `split`.
435
+ - Stops when a branch returns or a state token is missing.
436
+
437
+ ---
438
+
361
439
  ### `expose fn-inliner`
362
440
 
363
441
  Inline proxy function calls into expressions.
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  // index.ts
4
4
  import { Command } from "commander";
5
- import { dirname as dirname12, join as join12 } from "path";
5
+ import { dirname as dirname14, join as join14 } from "path";
6
6
  import { fileURLToPath } from "url";
7
7
  import chalk4 from "chalk";
8
8
 
@@ -1941,9 +1941,9 @@ var remove_deadcode_default = createCommand((program3) => {
1941
1941
  );
1942
1942
  });
1943
1943
 
1944
- // commands/fn-inliner/index.ts
1945
- import { readFileSync as readFileSync11, writeFileSync as writeFileSync10 } from "fs";
1944
+ // commands/remove-anti-tamper/index.ts
1946
1945
  import { basename as basename10, dirname as dirname10, extname as extname10, join as join10 } from "path";
1946
+ import { readFileSync as readFileSync11, writeFileSync as writeFileSync10 } from "fs";
1947
1947
  import { parse as parse11 } from "@babel/parser";
1948
1948
  import traverse10 from "@babel/traverse";
1949
1949
  import generate10 from "@babel/generator";
@@ -1953,24 +1953,413 @@ var walk2 = patchDefault(traverse10);
1953
1953
  var createDefaultOutputPath10 = (inputPath) => {
1954
1954
  const ext = extname10(inputPath);
1955
1955
  if (!ext) {
1956
- return `${inputPath}.fn-inliner.js`;
1956
+ return `${inputPath}.remove-anti-tamper.js`;
1957
1957
  }
1958
1958
  const base = basename10(inputPath, ext);
1959
- return join10(dirname10(inputPath), `${base}.fn-inliner${ext}`);
1959
+ return join10(dirname10(inputPath), `${base}.remove-anti-tamper${ext}`);
1960
+ };
1961
+ var isWrapperDeclaration = (node) => {
1962
+ if (!t9.isIdentifier(node.id)) return false;
1963
+ if (!node.init || !t9.isCallExpression(node.init)) return false;
1964
+ const callee = node.init.callee;
1965
+ if (!t9.isFunctionExpression(callee)) return false;
1966
+ if (callee.params.length !== 0) return false;
1967
+ const bodyStatements = callee.body.body;
1968
+ if (bodyStatements.length < 2) return false;
1969
+ const firstStatement = bodyStatements[0];
1970
+ if (!t9.isVariableDeclaration(firstStatement) || firstStatement.declarations.length !== 1) {
1971
+ return false;
1972
+ }
1973
+ const firstDecl = firstStatement.declarations[0];
1974
+ if (!t9.isIdentifier(firstDecl.id) || !t9.isBooleanLiteral(firstDecl.init, { value: true })) {
1975
+ return false;
1976
+ }
1977
+ const returnStatement = bodyStatements.find(
1978
+ (stmt) => t9.isReturnStatement(stmt)
1979
+ );
1980
+ if (!returnStatement || !t9.isFunctionExpression(returnStatement.argument)) {
1981
+ return false;
1982
+ }
1983
+ const innerFunction = returnStatement.argument;
1984
+ if (innerFunction.params.length < 2) {
1985
+ return false;
1986
+ }
1987
+ return true;
1988
+ };
1989
+ var removeReferencedFunctions = (callPath) => {
1990
+ const args = callPath.get("arguments");
1991
+ if (!args || args.length < 2) {
1992
+ return false;
1993
+ }
1994
+ const handler = args[1];
1995
+ if (!handler.isFunction()) {
1996
+ return false;
1997
+ }
1998
+ let removed = false;
1999
+ handler.traverse({
2000
+ CallExpression(innerPath) {
2001
+ const callee = innerPath.get("callee");
2002
+ if (!callee.isIdentifier()) return;
2003
+ const binding = callee.scope.getBinding(callee.node.name);
2004
+ if (!binding) return;
2005
+ const bindingPath = binding.path;
2006
+ if (bindingPath.isFunctionDeclaration() && !bindingPath.removed) {
2007
+ bindingPath.remove();
2008
+ removed = true;
2009
+ }
2010
+ }
2011
+ });
2012
+ return removed;
2013
+ };
2014
+ var cleanEmptyVariableDeclaration = (path) => {
2015
+ if (path.node.declarations.length === 0) {
2016
+ path.remove();
2017
+ }
2018
+ };
2019
+ var removeAntiTamperPatterns = (code, filename) => {
2020
+ const ast = parse11(code, createParseOptions(filename));
2021
+ let changed = false;
2022
+ walk2(ast, {
2023
+ VariableDeclarator(path) {
2024
+ if (!isWrapperDeclaration(path.node)) return;
2025
+ const wrapperName = path.node.id;
2026
+ if (!t9.isIdentifier(wrapperName)) return;
2027
+ const binding = path.scope.getBinding(wrapperName.name);
2028
+ if (!binding) return;
2029
+ let removedReference = false;
2030
+ const references = [...binding.referencePaths];
2031
+ for (const reference of references) {
2032
+ const callPath = reference.parentPath;
2033
+ if (!callPath?.isCallExpression()) continue;
2034
+ const removedDebug = removeReferencedFunctions(callPath);
2035
+ if (removedDebug) {
2036
+ changed = true;
2037
+ }
2038
+ const declaratorPath = callPath.findParent(
2039
+ (p) => p.isVariableDeclarator()
2040
+ );
2041
+ if (declaratorPath && declaratorPath.isVariableDeclarator()) {
2042
+ const parentDecl = declaratorPath.parentPath;
2043
+ declaratorPath.remove();
2044
+ if (parentDecl?.isVariableDeclaration()) {
2045
+ cleanEmptyVariableDeclaration(parentDecl);
2046
+ }
2047
+ removedReference = true;
2048
+ changed = true;
2049
+ continue;
2050
+ }
2051
+ const statement = callPath.getStatementParent();
2052
+ if (statement) {
2053
+ statement.remove();
2054
+ removedReference = true;
2055
+ changed = true;
2056
+ }
2057
+ }
2058
+ if (removedReference && !path.removed) {
2059
+ path.remove();
2060
+ changed = true;
2061
+ const parentDecl = path.parentPath;
2062
+ if (parentDecl?.isVariableDeclaration()) {
2063
+ cleanEmptyVariableDeclaration(parentDecl);
2064
+ }
2065
+ }
2066
+ }
2067
+ });
2068
+ return {
2069
+ code: patchDefault(generate10)(ast).code,
2070
+ changed
2071
+ };
2072
+ };
2073
+ var remove_anti_tamper_default = createCommand((program3) => {
2074
+ program3.command("remove-anti-tamper").description("Drop anti-tamper wrapper calls and helpers").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(
2075
+ async (fileArgument, options) => {
2076
+ await timeout(
2077
+ async ({ finish }) => {
2078
+ const filename = fileArgument ?? options.file ?? await createPrompt("Enter the file path:");
2079
+ if (!filename) {
2080
+ showError("No file provided");
2081
+ return finish();
2082
+ }
2083
+ try {
2084
+ const fileContent = readFileSync11(filename, "utf8");
2085
+ const defaultOutputPath = createDefaultOutputPath10(filename);
2086
+ let outputPath = options.output;
2087
+ if (!outputPath) {
2088
+ const promptPath = (await createPrompt("Enter the output file path:"))?.trim();
2089
+ outputPath = promptPath || defaultOutputPath;
2090
+ }
2091
+ const loader = loading11("Removing anti-tamper patterns...").start();
2092
+ try {
2093
+ const { code: output, changed } = removeAntiTamperPatterns(
2094
+ fileContent,
2095
+ filename
2096
+ );
2097
+ writeFileSync10(outputPath, output, "utf8");
2098
+ loader.succeed(
2099
+ `Saved remove-anti-tamper file to: ${outputPath} (${diff(fileContent, output).length} lines changed${changed ? ", removed anti-tamper code" : ""})`
2100
+ );
2101
+ return finish();
2102
+ } catch (error) {
2103
+ loader.fail("Failed to apply remove-anti-tamper transform");
2104
+ showError(
2105
+ `Error transforming file '${filename}': ${error instanceof Error ? error.message : "Unknown error"}`
2106
+ );
2107
+ return finish();
2108
+ }
2109
+ } catch (error) {
2110
+ showError(
2111
+ `Error reading file '${filename}': ${error instanceof Error ? error.message : "Unknown error"}`
2112
+ );
2113
+ return finish();
2114
+ }
2115
+ },
2116
+ options.unlimited ? null : 120 * 1e3
2117
+ );
2118
+ }
2119
+ );
2120
+ });
2121
+
2122
+ // commands/control-flow-packer/index.ts
2123
+ import { readFileSync as readFileSync12, writeFileSync as writeFileSync11 } from "fs";
2124
+ import { basename as basename11, dirname as dirname11, extname as extname11, join as join11 } from "path";
2125
+ import { parse as parse12 } from "@babel/parser";
2126
+ import traverse11 from "@babel/traverse";
2127
+ import generate11 from "@babel/generator";
2128
+ import * as t10 from "@babel/types";
2129
+ import loading12 from "loading-cli";
2130
+ var walk3 = patchDefault(traverse11);
2131
+ var createDefaultOutputPath11 = (inputPath) => {
2132
+ const ext = extname11(inputPath);
2133
+ if (!ext) {
2134
+ return `${inputPath}.control-flow-packer.js`;
2135
+ }
2136
+ const base = basename11(inputPath, ext);
2137
+ return join11(dirname11(inputPath), `${base}.control-flow-packer${ext}`);
2138
+ };
2139
+ var isDeclarationOrAssignmentExpression = (node) => {
2140
+ if (t10.isAssignmentExpression(node)) {
2141
+ return t10.isIdentifier(node.left) && t10.isNumericLiteral(node.right);
2142
+ }
2143
+ if (t10.isVariableDeclaration(node) && node.declarations.length === 1 && t10.isIdentifier(node.declarations[0].id) && node.declarations[0].init && t10.isNumericLiteral(node.declarations[0].init)) {
2144
+ return true;
2145
+ }
2146
+ return false;
2147
+ };
2148
+ var extractCounterInfo = (node) => {
2149
+ if (t10.isAssignmentExpression(node)) {
2150
+ return {
2151
+ counterName: node.left.name,
2152
+ initialValue: node.right.value
2153
+ };
2154
+ }
2155
+ const declaration = node.declarations[0];
2156
+ return {
2157
+ counterName: declaration.id.name,
2158
+ initialValue: declaration.init.value
2159
+ };
2160
+ };
2161
+ var isStateArrayExpression = (node) => {
2162
+ return t10.isCallExpression(node) && t10.isMemberExpression(node.callee) && t10.isStringLiteral(node.callee.object) && (t10.isStringLiteral(node.callee.property) && node.callee.property.value === "split" || t10.isIdentifier(node.callee.property) && node.callee.property.name === "split") && node.arguments.length === 1 && t10.isStringLiteral(node.arguments[0]);
2163
+ };
2164
+ var isFlatteningLoopBody = (node, statesName, counterName) => {
2165
+ return t10.isBlockStatement(node) && node.body.length === 2 && t10.isBreakStatement(node.body[1]) && t10.isSwitchStatement(node.body[0]) && t10.isMemberExpression(node.body[0].discriminant) && t10.isIdentifier(node.body[0].discriminant.object) && node.body[0].discriminant.object.name === statesName && t10.isUpdateExpression(node.body[0].discriminant.property) && t10.isIdentifier(node.body[0].discriminant.property.argument) && node.body[0].discriminant.property.argument.name === counterName && node.body[0].cases.every(
2166
+ (c) => c.test && t10.isStringLiteral(c.test)
2167
+ );
2168
+ };
2169
+ var isFlatteningForLoop = (node, statesName) => {
2170
+ return t10.isForStatement(node) && node.init !== null && isDeclarationOrAssignmentExpression(node.init) && isFlatteningLoopBody(
2171
+ node.body,
2172
+ statesName,
2173
+ t10.isAssignmentExpression(node.init) ? node.init.left.name : node.init.declarations[0].id.name
2174
+ );
2175
+ };
2176
+ var isFlatteningWhileLoop = (node, statesName, counterName) => {
2177
+ return t10.isWhileStatement(node) && t10.isBooleanLiteral(node.test) && node.test.value === true && isFlatteningLoopBody(node.body, statesName, counterName);
2178
+ };
2179
+ var getStates = (expression) => {
2180
+ const delimiter = expression.arguments[0].value;
2181
+ return expression.callee.object.value.split(delimiter);
2182
+ };
2183
+ var collectStatements = (cases, states, initialValue) => {
2184
+ const casesMap = new Map(
2185
+ cases.map((c) => [c.test.value, c.consequent])
2186
+ );
2187
+ const statements = [];
2188
+ for (let index = initialValue; index < states.length; index++) {
2189
+ const state = states[index];
2190
+ if (state === void 0 || !casesMap.has(state)) {
2191
+ break;
2192
+ }
2193
+ const blockStatements = casesMap.get(state);
2194
+ for (const statement of blockStatements) {
2195
+ if (t10.isContinueStatement(statement)) {
2196
+ continue;
2197
+ }
2198
+ statements.push(t10.cloneNode(statement, true));
2199
+ }
2200
+ const lastStatement = blockStatements[blockStatements.length - 1];
2201
+ if (lastStatement && t10.isReturnStatement(lastStatement)) {
2202
+ break;
2203
+ }
2204
+ }
2205
+ return statements;
2206
+ };
2207
+ var packControlFlow = (code, filename) => {
2208
+ const ast = parse12(code, createParseOptions(filename));
2209
+ let changedCount = 0;
2210
+ walk3(ast, {
2211
+ VariableDeclarator(path) {
2212
+ if (!path.node.init || !t10.isIdentifier(path.node.id)) {
2213
+ return;
2214
+ }
2215
+ if (!isStateArrayExpression(path.node.init)) {
2216
+ return;
2217
+ }
2218
+ const statementPath = path.getStatementParent();
2219
+ if (!statementPath?.isVariableDeclaration()) {
2220
+ return;
2221
+ }
2222
+ if (statementPath.node.declarations.length !== 1) {
2223
+ return;
2224
+ }
2225
+ const stateVariableName = path.node.id.name;
2226
+ const states = getStates(path.node.init);
2227
+ let nextPath = statementPath.getNextSibling();
2228
+ if (!nextPath) {
2229
+ return;
2230
+ }
2231
+ let loopPath = null;
2232
+ let initialValue = null;
2233
+ let counterName;
2234
+ if (nextPath.isForStatement() && isFlatteningForLoop(nextPath.node, stateVariableName)) {
2235
+ loopPath = nextPath;
2236
+ const initNode = nextPath.node.init;
2237
+ if (!initNode || !isDeclarationOrAssignmentExpression(initNode)) {
2238
+ return;
2239
+ }
2240
+ const counterInfo = extractCounterInfo(initNode);
2241
+ initialValue = counterInfo.initialValue;
2242
+ counterName = counterInfo.counterName;
2243
+ } else if (isDeclarationOrAssignmentExpression(nextPath.node)) {
2244
+ const counterInfo = extractCounterInfo(
2245
+ nextPath.node
2246
+ );
2247
+ counterName = counterInfo.counterName;
2248
+ initialValue = counterInfo.initialValue;
2249
+ nextPath = nextPath.getNextSibling();
2250
+ if (!nextPath || !nextPath.isWhileStatement()) {
2251
+ return;
2252
+ }
2253
+ if (!isFlatteningWhileLoop(
2254
+ nextPath.node,
2255
+ stateVariableName,
2256
+ counterName
2257
+ )) {
2258
+ return;
2259
+ }
2260
+ loopPath = nextPath;
2261
+ } else {
2262
+ return;
2263
+ }
2264
+ if (!loopPath || initialValue === null || counterName === void 0) {
2265
+ return;
2266
+ }
2267
+ const body = loopPath.node.body;
2268
+ const cases = body.body[0].cases;
2269
+ const statements = collectStatements(cases, states, initialValue);
2270
+ if (statements.length === 0) {
2271
+ return;
2272
+ }
2273
+ statementPath.remove();
2274
+ loopPath.replaceWithMultiple(statements);
2275
+ loopPath.skip();
2276
+ changedCount += 1;
2277
+ }
2278
+ });
2279
+ return {
2280
+ code: patchDefault(generate11)(ast).code,
2281
+ changedCount
2282
+ };
2283
+ };
2284
+ var control_flow_packer_default = createCommand((program3) => {
2285
+ program3.command("control-flow-packer").description("Inline control-flow flattening loops").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(
2286
+ async (fileArgument, options) => {
2287
+ await timeout(
2288
+ async ({ finish }) => {
2289
+ const filename = fileArgument ?? options.file ?? await createPrompt("Enter the file path:");
2290
+ if (!filename) {
2291
+ showError("No file provided");
2292
+ return finish();
2293
+ }
2294
+ try {
2295
+ const fileContent = readFileSync12(filename, "utf8");
2296
+ const defaultOutputPath = createDefaultOutputPath11(filename);
2297
+ let outputPath = options.output;
2298
+ if (!outputPath) {
2299
+ const promptPath = (await createPrompt("Enter the output file path:"))?.trim();
2300
+ outputPath = promptPath || defaultOutputPath;
2301
+ }
2302
+ const loader = loading12("Packing control flow...").start();
2303
+ try {
2304
+ const { code: output, changedCount } = packControlFlow(
2305
+ fileContent,
2306
+ filename
2307
+ );
2308
+ writeFileSync11(outputPath, output, "utf8");
2309
+ loader.succeed(
2310
+ `Saved control-flow-packer file to: ${outputPath} (${diff(fileContent, output).length} lines changed, ${changedCount} edits)`
2311
+ );
2312
+ return finish();
2313
+ } catch (error) {
2314
+ loader.fail("Failed to apply control-flow-packer transform");
2315
+ showError(
2316
+ `Error transforming file '${filename}': ${error instanceof Error ? error.message : "Unknown error"}`
2317
+ );
2318
+ return finish();
2319
+ }
2320
+ } catch (error) {
2321
+ showError(
2322
+ `Error reading file '${filename}': ${error instanceof Error ? error.message : "Unknown error"}`
2323
+ );
2324
+ return finish();
2325
+ }
2326
+ },
2327
+ options.unlimited ? null : 120 * 1e3
2328
+ );
2329
+ }
2330
+ );
2331
+ });
2332
+
2333
+ // commands/fn-inliner/index.ts
2334
+ import { readFileSync as readFileSync13, writeFileSync as writeFileSync12 } from "fs";
2335
+ import { basename as basename12, dirname as dirname12, extname as extname12, join as join12 } from "path";
2336
+ import { parse as parse13 } from "@babel/parser";
2337
+ import traverse12 from "@babel/traverse";
2338
+ import generate12 from "@babel/generator";
2339
+ import * as t11 from "@babel/types";
2340
+ import loading13 from "loading-cli";
2341
+ var walk4 = patchDefault(traverse12);
2342
+ var createDefaultOutputPath12 = (inputPath) => {
2343
+ const ext = extname12(inputPath);
2344
+ if (!ext) {
2345
+ return `${inputPath}.fn-inliner.js`;
2346
+ }
2347
+ const base = basename12(inputPath, ext);
2348
+ return join12(dirname12(inputPath), `${base}.fn-inliner${ext}`);
1960
2349
  };
1961
2350
  var isProxyFunctionExpression = (node) => {
1962
- return t9.isFunction(node) && node.params.every((param) => t9.isIdentifier(param)) && (t9.isBlockStatement(node.body) && node.body.body.length === 1 && t9.isReturnStatement(node.body.body[0]) && (node.body.body[0].argument === void 0 || t9.isExpression(node.body.body[0].argument) && isProxyValue(node.body.body[0].argument)) || t9.isArrowFunctionExpression(node) && t9.isExpression(node.body) && isProxyValue(node.body));
2351
+ return t11.isFunction(node) && node.params.every((param) => t11.isIdentifier(param)) && (t11.isBlockStatement(node.body) && node.body.body.length === 1 && t11.isReturnStatement(node.body.body[0]) && (node.body.body[0].argument === void 0 || t11.isExpression(node.body.body[0].argument) && isProxyValue(node.body.body[0].argument)) || t11.isArrowFunctionExpression(node) && t11.isExpression(node.body) && isProxyValue(node.body));
1963
2352
  };
1964
2353
  var isProxyValue = (node) => {
1965
- if (t9.isFunction(node) || t9.isBlockStatement(node) || t9.isSequenceExpression(node) || t9.isAssignmentExpression(node)) {
2354
+ if (t11.isFunction(node) || t11.isBlockStatement(node) || t11.isSequenceExpression(node) || t11.isAssignmentExpression(node)) {
1966
2355
  return false;
1967
2356
  }
1968
2357
  let isValid = true;
1969
- if (!t9.isExpression(node)) {
2358
+ if (!t11.isExpression(node)) {
1970
2359
  return false;
1971
2360
  }
1972
- const wrapper = t9.file(t9.program([t9.expressionStatement(node)]));
1973
- walk2(wrapper, {
2361
+ const wrapper = t11.file(t11.program([t11.expressionStatement(node)]));
2362
+ walk4(wrapper, {
1974
2363
  "SequenceExpression|BlockStatement|Function|AssignmentExpression"(path) {
1975
2364
  isValid = false;
1976
2365
  path.stop();
@@ -1980,7 +2369,7 @@ var isProxyValue = (node) => {
1980
2369
  return isValid;
1981
2370
  };
1982
2371
  var copyExpression = (expression) => {
1983
- return t9.cloneNode(expression, true);
2372
+ return t11.cloneNode(expression, true);
1984
2373
  };
1985
2374
  var ProxyFunction = class {
1986
2375
  expression;
@@ -1988,7 +2377,7 @@ var ProxyFunction = class {
1988
2377
  this.expression = expression;
1989
2378
  }
1990
2379
  getReplacement(args) {
1991
- const expression = t9.isExpression(this.expression.body) ? copyExpression(this.expression.body) : this.expression.body.body[0].argument ? copyExpression(this.expression.body.body[0].argument) : t9.identifier("undefined");
2380
+ const expression = t11.isExpression(this.expression.body) ? copyExpression(this.expression.body) : this.expression.body.body[0].argument ? copyExpression(this.expression.body.body[0].argument) : t11.identifier("undefined");
1992
2381
  this.replaceParameters(expression, args);
1993
2382
  return expression;
1994
2383
  }
@@ -1996,7 +2385,7 @@ var ProxyFunction = class {
1996
2385
  const paramMap = new Map(
1997
2386
  this.expression.params.map((param, index) => [
1998
2387
  param.name,
1999
- args[index] ?? t9.identifier("undefined")
2388
+ args[index] ?? t11.identifier("undefined")
2000
2389
  ])
2001
2390
  );
2002
2391
  const pathsToReplace = [];
@@ -2021,10 +2410,10 @@ var ProxyFunction = class {
2021
2410
  }
2022
2411
  return false;
2023
2412
  };
2024
- const wrapper = t9.file(t9.program([t9.expressionStatement(expression)]));
2025
- walk2(wrapper, {
2413
+ const wrapper = t11.file(t11.program([t11.expressionStatement(expression)]));
2414
+ walk4(wrapper, {
2026
2415
  enter(path) {
2027
- if (t9.isIdentifier(path.node) && !shouldSkipIdentifier(path) && paramMap.has(path.node.name)) {
2416
+ if (t11.isIdentifier(path.node) && !shouldSkipIdentifier(path) && paramMap.has(path.node.name)) {
2028
2417
  const replacement = paramMap.get(path.node.name);
2029
2418
  pathsToReplace.push([path, replacement]);
2030
2419
  }
@@ -2032,7 +2421,7 @@ var ProxyFunction = class {
2032
2421
  noScope: true
2033
2422
  });
2034
2423
  for (const [path, replacement] of pathsToReplace) {
2035
- path.replaceWith(t9.cloneNode(replacement, true));
2424
+ path.replaceWith(t11.cloneNode(replacement, true));
2036
2425
  }
2037
2426
  }
2038
2427
  };
@@ -2052,10 +2441,10 @@ var ProxyFunctionVariable = class extends ProxyFunction {
2052
2441
  const argumentNodes = path.parentPath.node.arguments;
2053
2442
  const args = [];
2054
2443
  for (const argument of argumentNodes) {
2055
- if (!t9.isExpression(argument)) {
2444
+ if (!t11.isExpression(argument)) {
2056
2445
  return false;
2057
2446
  }
2058
- args.push(t9.cloneNode(argument, true));
2447
+ args.push(t11.cloneNode(argument, true));
2059
2448
  }
2060
2449
  const expression = this.getReplacement(args);
2061
2450
  path.parentPath.replaceWith(expression);
@@ -2064,7 +2453,7 @@ var ProxyFunctionVariable = class extends ProxyFunction {
2064
2453
  };
2065
2454
  var collectProxyFunctions = (ast) => {
2066
2455
  const proxies = [];
2067
- walk2(ast, {
2456
+ walk4(ast, {
2068
2457
  FunctionDeclaration(path) {
2069
2458
  if (!path.node.id) return;
2070
2459
  if (!isProxyFunctionExpression(path.node)) return;
@@ -2073,7 +2462,7 @@ var collectProxyFunctions = (ast) => {
2073
2462
  proxies.push(new ProxyFunctionVariable(binding, path.node));
2074
2463
  },
2075
2464
  VariableDeclarator(path) {
2076
- if (!t9.isIdentifier(path.node.id)) return;
2465
+ if (!t11.isIdentifier(path.node.id)) return;
2077
2466
  const init = path.node.init;
2078
2467
  if (!init || !isProxyFunctionExpression(init)) return;
2079
2468
  const binding = path.scope.getBinding(path.node.id.name);
@@ -2084,7 +2473,7 @@ var collectProxyFunctions = (ast) => {
2084
2473
  return proxies;
2085
2474
  };
2086
2475
  var inlineProxyFunctions = (code, filename) => {
2087
- const ast = parse11(code, createParseOptions(filename));
2476
+ const ast = parse13(code, createParseOptions(filename));
2088
2477
  const proxies = collectProxyFunctions(ast);
2089
2478
  let replacedCount = 0;
2090
2479
  for (const proxy of proxies) {
@@ -2096,7 +2485,7 @@ var inlineProxyFunctions = (code, filename) => {
2096
2485
  }
2097
2486
  }
2098
2487
  return {
2099
- code: patchDefault(generate10)(ast).code,
2488
+ code: patchDefault(generate12)(ast).code,
2100
2489
  replacedCount
2101
2490
  };
2102
2491
  };
@@ -2111,20 +2500,20 @@ var fn_inliner_default = createCommand((program3) => {
2111
2500
  return finish();
2112
2501
  }
2113
2502
  try {
2114
- const fileContent = readFileSync11(filename, "utf8");
2115
- const defaultOutputPath = createDefaultOutputPath10(filename);
2503
+ const fileContent = readFileSync13(filename, "utf8");
2504
+ const defaultOutputPath = createDefaultOutputPath12(filename);
2116
2505
  let outputPath = options.output;
2117
2506
  if (!outputPath) {
2118
2507
  const promptPath = (await createPrompt("Enter the output file path:"))?.trim();
2119
2508
  outputPath = promptPath || defaultOutputPath;
2120
2509
  }
2121
- const loader = loading11("Inlining proxy functions...").start();
2510
+ const loader = loading13("Inlining proxy functions...").start();
2122
2511
  try {
2123
2512
  const { code: output, replacedCount } = inlineProxyFunctions(
2124
2513
  fileContent,
2125
2514
  filename
2126
2515
  );
2127
- writeFileSync10(outputPath, output, "utf8");
2516
+ writeFileSync12(outputPath, output, "utf8");
2128
2517
  loader.succeed(
2129
2518
  `Saved fn-inliner file to: ${outputPath} (${diff(fileContent, output).length} lines changed, ${replacedCount} replacements)`
2130
2519
  );
@@ -2150,38 +2539,38 @@ var fn_inliner_default = createCommand((program3) => {
2150
2539
  });
2151
2540
 
2152
2541
  // commands/sequence-split/index.ts
2153
- import { readFileSync as readFileSync12, writeFileSync as writeFileSync11 } from "fs";
2154
- import { basename as basename11, dirname as dirname11, extname as extname11, join as join11 } from "path";
2155
- import { parse as parse12 } from "@babel/parser";
2156
- import traverse11 from "@babel/traverse";
2157
- import generate11 from "@babel/generator";
2158
- import * as t10 from "@babel/types";
2159
- import loading12 from "loading-cli";
2160
- var walk3 = patchDefault(traverse11);
2161
- var createDefaultOutputPath11 = (inputPath) => {
2162
- const ext = extname11(inputPath);
2542
+ import { readFileSync as readFileSync14, writeFileSync as writeFileSync13 } from "fs";
2543
+ import { basename as basename13, dirname as dirname13, extname as extname13, join as join13 } from "path";
2544
+ import { parse as parse14 } from "@babel/parser";
2545
+ import traverse13 from "@babel/traverse";
2546
+ import generate13 from "@babel/generator";
2547
+ import * as t12 from "@babel/types";
2548
+ import loading14 from "loading-cli";
2549
+ var walk5 = patchDefault(traverse13);
2550
+ var createDefaultOutputPath13 = (inputPath) => {
2551
+ const ext = extname13(inputPath);
2163
2552
  if (!ext) {
2164
2553
  return `${inputPath}.sequence-split.js`;
2165
2554
  }
2166
- const base = basename11(inputPath, ext);
2167
- return join11(dirname11(inputPath), `${base}.sequence-split${ext}`);
2555
+ const base = basename13(inputPath, ext);
2556
+ return join13(dirname13(inputPath), `${base}.sequence-split${ext}`);
2168
2557
  };
2169
2558
  var isExcluded = (node) => {
2170
- return t10.isIdentifier(node) && node.name === "eval";
2559
+ return t12.isIdentifier(node) && node.name === "eval";
2171
2560
  };
2172
2561
  var sequenceSplit = (code, filename) => {
2173
- const ast = parse12(code, createParseOptions(filename));
2562
+ const ast = parse14(code, createParseOptions(filename));
2174
2563
  let changedCount = 0;
2175
2564
  const markChanged = () => {
2176
2565
  changedCount += 1;
2177
2566
  };
2178
- walk3(ast, {
2567
+ walk5(ast, {
2179
2568
  ConditionalExpression(path) {
2180
2569
  if (!path.parentPath || !path.parentPath.isExpressionStatement()) return;
2181
- const replacement = t10.ifStatement(
2570
+ const replacement = t12.ifStatement(
2182
2571
  path.node.test,
2183
- t10.expressionStatement(path.node.consequent),
2184
- t10.expressionStatement(path.node.alternate)
2572
+ t12.expressionStatement(path.node.consequent),
2573
+ t12.expressionStatement(path.node.alternate)
2185
2574
  );
2186
2575
  if (path.parentPath.parentPath && path.parentPath.parentPath.key === "alternate" && path.parentPath.parentPath.isBlockStatement() && path.parentPath.parentPath.node.body.length === 1) {
2187
2576
  path.parentPath.parentPath.replaceWith(replacement);
@@ -2194,10 +2583,10 @@ var sequenceSplit = (code, filename) => {
2194
2583
  LogicalExpression(path) {
2195
2584
  if (!path.parentPath || !path.parentPath.isExpressionStatement()) return;
2196
2585
  if (path.node.operator !== "&&" && path.node.operator !== "||") return;
2197
- const test = path.node.operator === "&&" ? path.node.left : t10.unaryExpression("!", path.node.left);
2198
- const replacement = t10.ifStatement(
2586
+ const test = path.node.operator === "&&" ? path.node.left : t12.unaryExpression("!", path.node.left);
2587
+ const replacement = t12.ifStatement(
2199
2588
  test,
2200
- t10.expressionStatement(path.node.right)
2589
+ t12.expressionStatement(path.node.right)
2201
2590
  );
2202
2591
  if (path.parentPath.parentPath && path.parentPath.parentPath.key === "alternate" && path.parentPath.parentPath.isBlockStatement() && path.parentPath.parentPath.node.body.length === 1) {
2203
2592
  path.parentPath.parentPath.replaceWith(replacement);
@@ -2209,24 +2598,24 @@ var sequenceSplit = (code, filename) => {
2209
2598
  },
2210
2599
  "ForStatement|WhileStatement|DoWhileStatement"(path) {
2211
2600
  if (!path.isForStatement() && !path.isWhileStatement() && !path.isDoWhileStatement()) return;
2212
- if (t10.isBlockStatement(path.node.body)) return;
2213
- path.node.body = t10.blockStatement([path.node.body]);
2601
+ if (t12.isBlockStatement(path.node.body)) return;
2602
+ path.node.body = t12.blockStatement([path.node.body]);
2214
2603
  markChanged();
2215
2604
  },
2216
2605
  IfStatement(path) {
2217
- if (!t10.isBlockStatement(path.node.consequent)) {
2218
- path.node.consequent = t10.blockStatement([path.node.consequent]);
2606
+ if (!t12.isBlockStatement(path.node.consequent)) {
2607
+ path.node.consequent = t12.blockStatement([path.node.consequent]);
2219
2608
  markChanged();
2220
2609
  }
2221
- if (path.node.alternate && !t10.isBlockStatement(path.node.alternate) && !t10.isIfStatement(path.node.alternate)) {
2222
- path.node.alternate = t10.blockStatement([path.node.alternate]);
2610
+ if (path.node.alternate && !t12.isBlockStatement(path.node.alternate) && !t12.isIfStatement(path.node.alternate)) {
2611
+ path.node.alternate = t12.blockStatement([path.node.alternate]);
2223
2612
  markChanged();
2224
2613
  }
2225
2614
  },
2226
2615
  VariableDeclaration(path) {
2227
2616
  if (path.node.declarations.length <= 1) return;
2228
2617
  const replacements = path.node.declarations.map(
2229
- (declaration) => t10.variableDeclaration(path.node.kind, [declaration])
2618
+ (declaration) => t12.variableDeclaration(path.node.kind, [declaration])
2230
2619
  );
2231
2620
  if (path.parentPath?.isForStatement() && path.parentKey === "init") {
2232
2621
  const lastDeclaration = replacements.pop();
@@ -2247,7 +2636,7 @@ var sequenceSplit = (code, filename) => {
2247
2636
  return;
2248
2637
  }
2249
2638
  let outerPath = path;
2250
- while (!t10.isStatement(outerPath.node)) {
2639
+ while (!t12.isStatement(outerPath.node)) {
2251
2640
  const parent = outerPath.parentPath;
2252
2641
  if (!parent) return;
2253
2642
  if (parent.isConditionalExpression() && (outerPath.key === "consequent" || outerPath.key === "alternate") || parent.isLogicalExpression() && outerPath.key === "right" || parent.isForStatement() && (outerPath.key === "test" || outerPath.key === "update") || parent.isDoWhileStatement() && outerPath.key === "test" || parent.isArrowFunctionExpression() && outerPath.key === "body") {
@@ -2260,7 +2649,7 @@ var sequenceSplit = (code, filename) => {
2260
2649
  const firstExpressions = expressions.splice(0, expressions.length - 2);
2261
2650
  if (firstExpressions.length > 0) {
2262
2651
  const expressionStatements = firstExpressions.map(
2263
- (expression) => t10.expressionStatement(expression)
2652
+ (expression) => t12.expressionStatement(expression)
2264
2653
  );
2265
2654
  outerPath.insertBefore(expressionStatements);
2266
2655
  markChanged();
@@ -2268,7 +2657,7 @@ var sequenceSplit = (code, filename) => {
2268
2657
  } else {
2269
2658
  const finalExpression = expressions.splice(expressions.length - 1, 1)[0];
2270
2659
  const expressionStatements = expressions.map(
2271
- (expression) => t10.expressionStatement(expression)
2660
+ (expression) => t12.expressionStatement(expression)
2272
2661
  );
2273
2662
  outerPath.insertBefore(expressionStatements);
2274
2663
  if (finalExpression) {
@@ -2279,7 +2668,7 @@ var sequenceSplit = (code, filename) => {
2279
2668
  }
2280
2669
  });
2281
2670
  return {
2282
- code: patchDefault(generate11)(ast).code,
2671
+ code: patchDefault(generate13)(ast).code,
2283
2672
  changedCount
2284
2673
  };
2285
2674
  };
@@ -2294,20 +2683,20 @@ var sequence_split_default = createCommand((program3) => {
2294
2683
  return finish();
2295
2684
  }
2296
2685
  try {
2297
- const fileContent = readFileSync12(filename, "utf8");
2298
- const defaultOutputPath = createDefaultOutputPath11(filename);
2686
+ const fileContent = readFileSync14(filename, "utf8");
2687
+ const defaultOutputPath = createDefaultOutputPath13(filename);
2299
2688
  let outputPath = options.output;
2300
2689
  if (!outputPath) {
2301
2690
  const promptPath = (await createPrompt("Enter the output file path:"))?.trim();
2302
2691
  outputPath = promptPath || defaultOutputPath;
2303
2692
  }
2304
- const loader = loading12("Splitting sequences...").start();
2693
+ const loader = loading14("Splitting sequences...").start();
2305
2694
  try {
2306
2695
  const { code: output, changedCount } = sequenceSplit(
2307
2696
  fileContent,
2308
2697
  filename
2309
2698
  );
2310
- writeFileSync11(outputPath, output, "utf8");
2699
+ writeFileSync13(outputPath, output, "utf8");
2311
2700
  loader.succeed(
2312
2701
  `Saved sequence-split file to: ${outputPath} (${diff(fileContent, output).length} lines changed, ${changedCount} transforms)`
2313
2702
  );
@@ -2356,10 +2745,10 @@ var calmGradienrain = (text) => {
2356
2745
  const endHue = 300;
2357
2746
  const saturation = 0.45;
2358
2747
  const value = 0.8;
2359
- const ease = (t11) => t11 * t11 * (3 - 2 * t11);
2748
+ const ease = (t13) => t13 * t13 * (3 - 2 * t13);
2360
2749
  return text.split("").map((char, i) => {
2361
- const t11 = ease(i / Math.max(text.length - 1, 1));
2362
- const hue = startHue + (endHue - startHue) * t11;
2750
+ const t13 = ease(i / Math.max(text.length - 1, 1));
2751
+ const hue = startHue + (endHue - startHue) * t13;
2363
2752
  const c = value * saturation;
2364
2753
  const h = hue / 60;
2365
2754
  const x = c * (1 - Math.abs(h % 2 - 1));
@@ -2383,11 +2772,11 @@ ${calmGradienrain(`Expose Kit v${VERSION}`)} ${update && update.latest !== VERSI
2383
2772
  `;
2384
2773
 
2385
2774
  // index.ts
2386
- import { readFileSync as readFileSync13 } from "fs";
2775
+ import { readFileSync as readFileSync15 } from "fs";
2387
2776
  import updateNotifier from "update-notifier";
2388
2777
  var __filename = fileURLToPath(import.meta.url);
2389
- var __dirname = dirname12(__filename);
2390
- var pkg = JSON.parse(readFileSync13(join12(__dirname, "package.json"), "utf8"));
2778
+ var __dirname = dirname14(__filename);
2779
+ var pkg = JSON.parse(readFileSync15(join14(__dirname, "package.json"), "utf8"));
2391
2780
  var notifier = updateNotifier({
2392
2781
  pkg,
2393
2782
  updateCheckInterval: 1e3 * 60 * 60 * 24 * 3
@@ -2411,6 +2800,8 @@ var commands = [
2411
2800
  remove_updater_default,
2412
2801
  remove_reassign_default,
2413
2802
  remove_deadcode_default,
2803
+ remove_anti_tamper_default,
2804
+ control_flow_packer_default,
2414
2805
  fn_inliner_default,
2415
2806
  remove_unused_default,
2416
2807
  sequence_split_default
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expose-kit",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
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.11.0",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "author": "EdamAmex <edame8080@gmail.com> (https://github.com/EdamAme-x)",