downloader | ||
fallback-files | ||
keygen | ||
patcher | ||
.gitignore | ||
README.md | ||
UNLICENSE |
Wokwi for VS Code Offline mode enabler
This projects enables Wokwi Visual Studio Code extension Offline mode.
To do so, the following steps are needed, which are explained later:
- Download the code
- Patch the code
- Block Wokwi Internet access
- Generate a license key
Download the code
Internet access and valid Wokwi license (free license is enough) is required for getting code directory URL. Fallback files are available in the repository.
On each launch, Wokwi attempts to receive or update offline engine version, which is said in documentation. This is performed by sending a HTTP request to https://wokwi.com/api/vscode/update-v2
.
The request is identified by Authorization
. Its value is Wokwi
followed by a license.
If a license is authorized for offline access, the response contains bundle
parameter with a link to non-existent bundle.bin
file in the directory where index.json
file exists, pointing to remaining files needed to be downloaded. However, the link can also be reconstructed from sha256
parameter received when using unauthorized, but still valid, license, like free one.
Launch downloader.py
and provide it a valid license to get the files.
Patch the code
Since Wokwi licenses are cryptographically signed, the only way to force the extension to accept locally generated keys would be to replace the public key present in entry.js
file with own key.
The task can be done with a text editor, however, since the file is big and may cause performance issues when opened, it is advised to launch patcher.py
instead, by first putting entry.js
file in the same directory.
The patched file, as well as other downloaded files, should then be placed in .cache
subdirectory of Wokwi directory in Visual Studio Code extension path.
Block Wokwi Internet access
To prevent Wokwi extension from loading the most recent online version, which would reject the license, wokwi.com
access should be blocked for Visual Studio with firewall or hosts file.
Generate a license key
Now it should be possible to launch Wokwi extension offline, but it will still complain about lack of license.
Wokwi license structure is:
Cleartext part:
u=userid&n=name&e=email&x=expiration&p=plan
followed by NULL character, followed by RSA digital signature.
Userid is only used in telemetry. Name is displayed in license activation message and is exported in a license file. If it doesn't have @ character, it is displayed in the main window. Email is exported in license file. Expiration date should be in YYYYMMDD format and should be exactly 8 digits. 99991231 is the maximum valid date. Plan can be "club", "hobby", "hobbyplus", "pro", "classroom" and "addon-offline". Anything else is treated as Community plan, which lacks Diagram Editor.
Launch keygen.py
and insert this data. Then copy the license to Wokwi extension and now you can use it.