Async Executor
Run the VM asynchronously so the bytecode decryption key can be fetched at runtime instead of shipping inside the bundle.
Watch
Obfuscator.io Async Executor: Async Bytecode Key Getter and Async-Only VM Virtualization
The vmAsyncExecutor option enables the asynchronous VM executor. Its headline benefit is that vmBytecodeArrayEncodingKeyGetter may now return a Promise - an asynchronous key getter - so the decryption key can come from a network request, IndexedDB, or any async source at load time rather than being available synchronously when the code first runs.
For a complete backend-fetched-key walkthrough, see Externalizing the Bytecode Array Encoding Key.
When to use it
Heavily recommended for fully async codebases. In this mode only async functions are virtualized - a synchronous function cannot be made async without turning its return value into a Promise and breaking its callers - so code that is async throughout gets the most coverage. It still works when the root is synchronous (for example a sync IIFE or UMD wrapper): the outermost async functions inside are protected, and the sync parts are not virtualized (the rest of the obfuscation still applies).
What gets transformed
Every outermost async function, wherever it appears (including nested inside sync wrappers). The outermost async in each chain is the protected unit - everything inside it, sync and async, is compiled in. Synchronous functions and plain generators are not virtualized (the rest of the obfuscation still applies to them).
Skips and warnings
Async generators are also not virtualized when an asynchronous key getter is active - an async generator must return its iterator synchronously and cannot wait for the key. In the default vmTargetFunctionsMode: 'root' skips are silent (selection is automatic), unless nothing at all is virtualized, which reports VMNoFunctionsToVirtualize. In 'comment' mode a warning is reported (in the dashboard, and in the API response's warnings array) whenever a function you explicitly marked cannot be virtualized - it turned out synchronous, or it is an async generator under an async key getter. These warnings (VMSyncFunctionSkippedInAsyncMode, VMAsyncGeneratorSkippedInAsyncMode) can be silenced per type via the warnings option (v7.8.0+).
In root mode, vmAsyncExecutor leaves top-level variable initializers in plain JavaScript even when vmWrapTopLevelInitializers is on, and (v7.8.0+) a VMTopLevelInitializerNotVirtualized warning lists them.
Requirements
- The asynchronous key getter requires
vmBytecodeArrayEncoding, andvmBytecodeArrayEncodingKeyGettermust be paired withvmBytecodeArrayEncodingKey- the obfuscator validates that both are set (or both absent) and that the getter parses as an expression, and rejects the build otherwise. - Obfuscator version 7.3.0 or later.
Enabling the option alone just switches the executor to async mode (only outermost async functions are virtualized). Returning a Promise from the key getter is what unlocks runtime key fetching, and that additionally needs bytecode array encoding with a key getter. Whether the getter returns a Promise cannot be checked at build time, so a Promise-returning getter with vmAsyncExecutor off fails at runtime - the decoder receives the Promise instead of the key.
Example
In a fully synchronous codebase almost nothing is virtualized, since only async functions are eligible. If your entry points are not async, prefer a synchronous key getter and leave vmAsyncExecutor off.
