@dacely/toildefender 0.1.4 → 0.1.6

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
@@ -99,6 +99,12 @@ the bytecode into encrypted BigInt streams, and executes it through a generated
99
99
  runtime VM. Instead of exposing readable JavaScript logic, your code becomes
100
100
  numeric program data consumed by a randomized virtual machine.
101
101
 
102
+ The compiler also fuses selected hot stack patterns into semantic
103
+ superinstructions, so common operation boundaries such as constant-key property
104
+ reads are not always emitted as separate primitive VM opcodes.
105
+ Constants are wrapped in access-bound cells, so encoded strings and references
106
+ are decoded lazily when bytecode reads them instead of during VM call setup.
107
+
102
108
  Original logic disappears from the output bundle. Attackers no longer reverse
103
109
  plain JavaScript; they must recover the VM, decode the bytecode format,
104
110
  reconstruct the instruction set, and emulate the protected program.
@@ -195,19 +201,20 @@ protections: {
195
201
 
196
202
  The complete beautified generated output is committed at
197
203
  [docs/all-modes-output.demo.js](./docs/all-modes-output.demo.js). It is a real
198
- 961-line artifact from the current generator and executes to:
204
+ 1019-line artifact from the current generator and executes to:
199
205
 
200
206
  Output excerpt:
201
207
 
202
208
  ```js
203
209
  (function () {
204
- function a(f, j) {
205
- var b = new Array(105);
210
+ function a(f, k) {
211
+ var b = new Array(109);
206
212
  ;
207
213
  var c = arguments;
214
+ var i;
208
215
  while (true) try {
209
216
  switch (f) {
210
- case 8455:
217
+ case 24210:
211
218
  b[11] = c[11];
212
219
  b[12] = c[10];
213
220
  b[13] = c[9];
@@ -218,42 +225,43 @@ Output excerpt:
218
225
  b[18] = c[4];
219
226
  b[19] = c[3];
220
227
  b[20] = c[2];
221
- b[21] = e(a, 739, b, c[1]);
222
- b[22] = e(a, 22884, b, c[1]);
223
- b[23] = e(a, 24756, b, c[1]);
224
- b[24] = e(a, 11593, b, c[1]);
225
- b[25] = e(a, 5522, b, c[1]);
226
- b[26] = e(a, 21472, b, c[1]);
227
- b[27] = e(a, 16279, b, c[1]);
228
- b[28] = e(a, 17195, b, c[1]);
229
- b[29] = e(a, 27528, b, c[1]);
230
- b[30] = e(a, 23881, b, c[1]);
231
- b[31] = e(a, 14569, b, c[1]);
232
- b[32] = e(a, 21646, b, c[1]);
233
- b[33] = e(a, 2482, b, c[1]);
234
- b[34] = e(a, 15554, b, c[1]);
235
- b[35] = BigInt(b[19]);
236
- b[36] = [1n];
237
- b[37] = c[1][10][1];
228
+ b[21] = e(a, 16503, b, c[1]);
229
+ b[22] = e(a, 16827, b, c[1]);
230
+ b[23] = e(a, 28881, b, c[1]);
231
+ b[24] = e(a, 27718, b, c[1]);
232
+ b[25] = e(a, 26046, b, c[1]);
233
+ b[26] = e(a, 11984, b, c[1]);
234
+ b[27] = e(a, 10989, b, c[1]);
235
+ b[28] = e(a, 10700, b, c[1]);
236
+ b[29] = e(a, 18606, b, c[1]);
237
+ b[30] = e(a, 22347, b, c[1]);
238
+ b[31] = e(a, 28683, b, c[1]);
239
+ b[32] = e(a, 11069, b, c[1]);
240
+ b[33] = e(a, 8443, b, c[1]);
241
+ b[34] = e(a, 27840, b, c[1]);
242
+ b[35] = e(a, 21656, b, c[1]);
243
+ b[36] = BigInt(b[19]);
244
+ b[37] = [1n];
238
245
  b[38] = c[1][10][1];
246
+ b[39] = c[1][10][1];
239
247
  if (b[11]) {
240
- b[37] = c[1][4](b[11], b[19], b[18], b[17], b[16], b[12]);
241
- b[38] = b[11][c[1][10][24]] >>> c[1][10][1];
248
+ b[38] = c[1][4](b[11], b[19], b[18], b[17], b[16], b[12]);
249
+ b[39] = b[11][c[1][10][24]] >>> c[1][10][1];
242
250
  }
243
- b[39] = c[1][10][1];
244
- b[40] = b[17] >>> c[1][10][1];
245
- while (b[39] < b[18]) {
246
- b[41] = b[32](b[39]);
247
- b[40] = b[33](b[40], b[41], b[39]);
248
- b[39] += c[1][10][5];
251
+ b[40] = c[1][10][1];
252
+ b[41] = b[17] >>> c[1][10][1];
253
+ while (b[40] < b[18]) {
254
+ b[42] = b[33](b[40]);
255
+ b[41] = b[34](b[41], b[42], b[40]);
256
+ b[40] += c[1][10][5];
249
257
  }
250
- if (b[40] >>> c[1][10][1] !== b[16] >>> c[1][10][1]) throw new Error(c[1][10][29]);
251
- b[42] = c[1][10][1];
252
- b[43] = b[17] >>> c[1][10][1];
253
- b[44] = b[17] & c[1][10][5];
254
- b[45] = b[44] ? c[1][10][30] : [];
255
- b[46] = b[44] ? c[1][10][30] : [];
256
- b[47] = b[44] ? h([
258
+ if (b[41] >>> c[1][10][1] !== b[16] >>> c[1][10][1]) throw new Error(c[1][10][29]);
259
+ b[43] = c[1][10][1];
260
+ b[44] = b[17] >>> c[1][10][1];
261
+ b[45] = b[17] & c[1][10][5];
262
+ b[46] = b[45] ? c[1][10][30] : [];
263
+ b[47] = b[45] ? c[1][10][30] : [];
264
+ b[48] = b[45] ? g([
257
265
  /* encoded layout keys */
258
266
  ], [
259
267
  [],
@@ -262,30 +270,31 @@ Output excerpt:
262
270
 
263
271
  /* 900+ more generated lines:
264
272
  dispatcher cases, encoded literals, streaming VM token reads,
265
- seed-selected stack/local storage, BigInt program blobs,
266
- randomized opcode tables, and Hash-Mesh unwrap */
267
-
268
- case 11593:
269
- if (c[1][49] < c[2][10][1] || c[1][49] >= c[1][18]) throw new Error(c[2][10][45]);
270
- b[1] = c[1][30](c[1][49]);
271
- c[1][49] += c[2][10][5];
273
+ lazy constant cells, seed-selected stack/local storage, BigInt program blobs,
274
+ semantic superinstructions, randomized opcode tables,
275
+ and Hash-Mesh unwrap */
276
+
277
+ case 27718:
278
+ if (c[1][50] < c[2][10][1] || c[1][50] >= c[1][18]) throw new Error(c[2][10][46]);
279
+ b[1] = c[1][31](c[1][50]);
280
+ c[1][50] += c[2][10][5];
272
281
  return b[1];
273
- case 5206:
282
+ case 30063:
274
283
  b[1] = '';
275
- b[1] += d(86, 101);
276
- b[1] += d(105, 108, 109);
284
+ b[1] += d(86, 101, 105);
285
+ b[1] += d(108, 109);
277
286
  b[1] += d(97, 114, 107);
278
287
  return b[1];
279
288
  }
280
289
  } catch (a) {
281
- veilmark$tobethrown = null;
290
+ i = null;
282
291
  switch (f) {
283
292
  default:
284
293
  throw a;
285
294
  }
286
295
  }
287
296
  }
288
- a(17701, {});
297
+ a(20498, {});
289
298
  })();
290
299
  ```
291
300
 
@@ -398,12 +407,26 @@ Main options:
398
407
  | `code` | Entry source code. |
399
408
  | `modulesCode` | Map of dependency filename to source code. |
400
409
  | `features` | Feature switches for the classic pipeline. |
410
+ | `babel` | Defaults to `false`; set to `true` only when you want the optional Babel downlevel transform before protection. |
411
+ | `babelPreserveAsync` | Defaults to `true`; when `babel: true`, keeps async/generator syntax native so async-aware flattening can avoid Babel regenerator helper bloat. Set to `false` for legacy async lowering. |
401
412
  | `protections.virtualMachine` | User-facing VM bytecode backend configuration. |
402
413
  | `protections.hashMesh` | User-facing hash-mesh unlock configuration. |
403
414
  | `numericVm` | Lower-level numeric VM configuration retained for internal callers. |
404
415
  | `preprocessorVariables` | Compile-time preprocessor constants. |
405
416
  | `logLevel` | `error`, `warn`, `info`, `debug`, or `log`. |
406
417
 
418
+ The default path parses modern syntax directly and normalizes the constructs
419
+ that older obfuscation passes cannot consume yet. The native AST path supports
420
+ plain classes as native islands, class fields, private fields, arrows, for-of
421
+ loops, async/generator functions, optional chaining, nullish coalescing, object
422
+ rest/spread, and spread calls.
423
+
424
+ When `babel: true` and `babelPreserveAsync` is enabled, optional Babel packages
425
+ installed by the caller can still downlevel syntax for legacy browser targets
426
+ while leaving async and generator functions for ToilDefender's async/generator
427
+ dispatchers. This avoids the large regenerator helper path for modern browser
428
+ and Node bundles.
429
+
407
430
  ## Toil Integration
408
431
 
409
432
  ToilDefender is intended to sit behind Toil build tooling. Framework packages