@afterpack/wasm 0.2.2 → 0.2.4
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/api.js +2 -9
- package/dist/contract.d.ts +2 -0
- package/engine/afterpack_engine_bg.wasm +0 -0
- package/package.json +1 -1
- package/readme.md +3 -3
package/dist/api.js
CHANGED
|
@@ -2,7 +2,6 @@ import { cloudApiBase } from "./cloud-base.js";
|
|
|
2
2
|
import { ObfuscationError } from "./contract.js";
|
|
3
3
|
import { engineVersion, processFile, randomSeed } from "./engine.js";
|
|
4
4
|
export * from "./contract.js";
|
|
5
|
-
const DIAG_OUTPUT_UNPARSEABLE = "DIAG_OUTPUT_UNPARSEABLE";
|
|
6
5
|
function engineCrash(cause) {
|
|
7
6
|
const error = new ObfuscationError("AfterPack engine hit an internal limit while processing this input in this environment " +
|
|
8
7
|
"(the build was not completed)", []);
|
|
@@ -353,15 +352,9 @@ export async function obfuscateAll(files, config) {
|
|
|
353
352
|
const detail = failed.map((file) => `${file.path}: ${file.error}`).join("; ");
|
|
354
353
|
throw new ObfuscationError(`AfterPack refused this build — ${detail}`, everyDiagnostic);
|
|
355
354
|
}
|
|
356
|
-
const cleartext = results
|
|
357
|
-
.map((result, i) => ({
|
|
358
|
-
path: paths[i],
|
|
359
|
-
discarded: result.diagnostics.some((d) => d.code === DIAG_OUTPUT_UNPARSEABLE) ||
|
|
360
|
-
(result.code === "" && sources[i].trim() !== ""),
|
|
361
|
-
}))
|
|
362
|
-
.filter((file) => file.discarded);
|
|
355
|
+
const cleartext = paths.filter((_, i) => results[i].code === "" && sources[i].trim() !== "");
|
|
363
356
|
if (cleartext.length > 0) {
|
|
364
|
-
const named = cleartext.
|
|
357
|
+
const named = cleartext.join(", ");
|
|
365
358
|
throw new ObfuscationError(`AfterPack refused this build — obfuscation was discarded and ${named} would ship as cleartext`, everyDiagnostic);
|
|
366
359
|
}
|
|
367
360
|
return results.map((result, i) => new ObfuscatedFile(files[i].path ?? null, result.code, result.sourceMap, result.diagnostics, result.protectionMap ?? null));
|
package/dist/contract.d.ts
CHANGED
|
@@ -53,6 +53,8 @@ export interface AfterpackConfig {
|
|
|
53
53
|
key?: string;
|
|
54
54
|
/** A named protection level. Defaults to `light`. */
|
|
55
55
|
preset?: Preset;
|
|
56
|
+
/** Whether the input is an ES module or a classic script. `auto` (the default) decides from the source, treating an `.mjs` path as a module. Set `module` for module output that has no `import`/`export`. */
|
|
57
|
+
sourceType?: "auto" | "module" | "script";
|
|
56
58
|
/** How much protection to apply. `0` applies none; higher values apply more and grow the output. */
|
|
57
59
|
complexity?: number;
|
|
58
60
|
/** Runtime reflection your code relies on. A detected pattern that is not listed fails the build. */
|
|
Binary file
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -69,14 +69,14 @@ try {
|
|
|
69
69
|
|
|
70
70
|
## Pro
|
|
71
71
|
|
|
72
|
-
Without a key,
|
|
72
|
+
Without a key, all of Free runs inside your Worker or Node process, with every preset. Add a Pro key (`{ key: env.AFTERPACK_KEY }`) and the same call runs the build in AfterPack's cloud instead. Pro adds per-file and per-region direction through [directives](https://www.afterpack.dev/docs/directives), stores each build's [Protection Map](https://www.afterpack.dev/docs/protection-map), and shows your builds in the [dashboard](https://www.afterpack.dev/docs/dashboard/builds). It also offers two opt-in hardening settings, `transforms.selfIntegrity` and `transforms.comparisonHardening`, both off by default ([details](https://www.afterpack.dev/docs/pro#hardening-for-license-and-payment-paths)). It does not make any transform stronger, and none of it is part of this package. See [deployment modes](https://www.afterpack.dev/docs/deployment-modes), [AfterPack Pro](https://www.afterpack.dev/docs/pro) and [pricing](https://www.afterpack.dev/#pricing).
|
|
73
73
|
|
|
74
74
|
## Size
|
|
75
75
|
|
|
76
76
|
| Measure | Bytes | |
|
|
77
77
|
|---|---:|---|
|
|
78
|
-
| Raw `.wasm` |
|
|
79
|
-
| Gzipped | 1,
|
|
78
|
+
| Raw `.wasm` | 4,570,171 | 4.36 MiB |
|
|
79
|
+
| Gzipped | 1,306,558 | 1.25 MiB |
|
|
80
80
|
|
|
81
81
|
This fits Cloudflare's Worker size limit on both the free and paid plans. CPU time is the tighter limit: the free plan allows 10 ms per request, and obfuscating a 185 KB bundle at `complexity: 8` takes about 263 ms on an Apple M-series laptop. Plan on Workers Paid for real bundles.
|
|
82
82
|
|