Repository navigation
Migrating from TOMP
This page is for a site built on the 2022 TOMP bootstrapper (TOMPBoot, a Bare server, boot.html()), or on the StompBoot releases of @sysce/stomp that followed it. It maps each old call to today's StompController API and explains what changed underneath, so you know which parts of your site need more than a rename.
| Name | When | How you got it | Bootstrapper | Network |
|---|---|---|---|---|
| TOMP (toomanyproxies) | early 2022 | the sysce/tomp repository, built with node ./app.mjs build --folder tompbuild
|
TOMPBoot, from bootstrapper.js
|
a Bare server, bare: '/bare/'
|
| stompV1 | April 2022 to 2023 |
@sysce/stomp 1.0.0 to 2.0.0 on npm |
StompBoot, from bootstrapper.js
|
a Bare server, bare_server: '/bare/'
|
| STomp | now |
@sysce/stomp@nightly (4.2.0 nightlies) |
StompController, from controller.mjs or Controller.js
|
a wisp server and a transport in the browser |
The npm latest tag of @sysce/stomp still points at 2.0.0, the stompV1 release. A plain npm install @sysce/stomp or npm update keeps you on the old API. Install @sysce/stomp@nightly and pin the exact version it resolves to (see Install into an existing app).
stompV1 renamed TOMPBoot to StompBoot and bare to bare_server, and kept the rest. Everything below about TOMPBoot applies to StompBoot too.
The 2022 quickstart page, with its four steps from this wiki put together in one file:
<script src="/tomp/bootstrapper.js"></script>
<form class="tomp-form">
<input type="text" class="tomp-input" placeholder="Search or enter web address" />
<input type="submit" />
</form>
<script>
const form = document.querySelector('.tomp-form');
const input = document.querySelector('.tomp-input');
form.addEventListener('submit', tompSubmit);
const boot = new TOMPBoot({
bare: '/bare/',
directory: '/tomp/',
});
const search = new TOMPBoot.SearchBuilder('https://searx.ru/search?q=%s');
async function tompSubmit(event) {
event.preventDefault();
await boot.ready;
const newAddress = boot.html(search.query(input.value));
location.assign(newAddress);
}
</script>The same page on STomp. The form and the search builder stay; the bootstrapper becomes a controller, and the proxied page opens in a frame instead of replacing the tab:
<form class="tomp-form">
<input type="text" class="tomp-input" placeholder="Search or enter web address" />
<input type="submit" />
</form>
<iframe class="tomp-frame" title="Proxied page"></iframe>
<script type="module">
import { StompController, SearchBuilder } from '/tomp/controller.mjs';
const form = document.querySelector('.tomp-form');
const input = document.querySelector('.tomp-input');
const search = new SearchBuilder('https://duckduckgo.com/?q=%s');
const ready = (async () => {
const directory = '/tomp/';
const registration = await StompController.register(directory);
const controller = new StompController({
serviceworker: registration,
transport: {
module: '/epoxy/index.mjs',
options: [{ wisp: location.origin.replace(/^http/, 'ws') + '/wisp/' }],
},
directory,
});
await controller.wait();
return controller.createFrame(document.querySelector('.tomp-frame'));
})();
form.addEventListener('submit', async (event) => {
event.preventDefault();
const frame = await ready;
frame.go(search.query(input.value));
});
</script>This keeps the /tomp/ directory to show that the name is yours to choose: serve STomp's dist/ there and pass the same path. The server side changes too: dist/ comes from the npm package, the epoxy transport is served at /epoxy/, and a wisp server answers on /wisp/ where the Bare server was. Bootstrapper quickstart has the complete server.
| TOMP 2022 | STomp now | Notes |
|---|---|---|
<script src="/tomp/bootstrapper.js">, global TOMPBoot
|
import { StompController } from '<directory>controller.mjs', or <script src="<directory>Controller.js"> (global StompController), or import { StompController } from '@sysce/stomp' in a bundler |
Install into an existing app |
the tompbuild folder from app.mjs build
|
stompPath from @sysce/stomp/path, the package's dist/
|
serve all of it under one directory |
new TOMPBoot(config) |
await StompController.register(directory), then new StompController(init)
|
registering is now a separate, awaited step |
config.directory |
directory, given to both register() and the constructor |
same meaning: where the files are and the service worker's scope. It must end with / and be on the page's origin |
config.bare |
transport: { module: '/epoxy/index.mjs', options: [{ wisp }] } |
see The Bare server is gone |
config.codec: TOMPBoot.CODEC_PLAIN (0, the old default) |
codec: 'generic' |
readable addresses, with characters outside -_~:, digits and letters written as $xx
|
config.codec: TOMPBoot.CODEC_XOR (1) |
codec: 'xor' (the default now) |
a different algorithm under the old name, see docs/codec.md |
| none |
codec: 'aes', codec: 'base64'
|
|
config.loglevel: TOMPBoot.LOG_TRACE to LOG_SILENT
|
none | STomp writes its warnings to the console. For request logs, use onRequest
|
config.noscript |
none | |
boot.ready |
await StompController.register(directory) and await controller.wait()
|
see When the proxy is ready |
location.assign(boot.html(url)) |
frame.go(url) on a frame from controller.createFrame()
|
see Pages open in frames |
boot.html(url) as a string |
await controller.route(url) |
asynchronous now, and the address only works while the controller's page is open |
boot.css(url), boot.js(url), boot.binary(url)
|
none | the service worker routes subresources itself |
TOMPBoot.SearchBuilder |
SearchBuilder, a named export of controller.mjs and @sysce/stomp, or the global from <directory>SearchBuilder.js
|
the rules changed slightly, see SearchBuilder |
<directory>worker.js?config=<JSON> |
<directory>serviceWorker.js |
the configuration no longer travels in the worker's URL |
addresses like /tomp/process:html:https%3A%2F%2Fexample.com
|
<directory><id>/html/<sealed URL> |
old links and bookmarks do not resolve |
TOMP sent every request to a Bare server, usually @tomphttp/bare-server-node mounted at /bare/. The Bare server made the request itself: the TLS connection to the site ended on your server, and sites saw Node's TLS and HTTP/1.1.
STomp runs no proxy code on your server. The transport (the Fracital build of epoxy, or libcurl) runs in the browser, makes the TLS connection to the site there, and sends the encrypted bytes through a wisp server, which relays TCP and UDP streams. For an HTTPS site your server only relays encrypted bytes. Epoxy speaks HTTP/2, and HTTP/3 over wisp's UDP streams (Transports and Wisp).
What to do: remove the Bare server and run a wisp server where it was. In Node that is a few lines with holywisp or @mercuryworkshop/wisp-js on your server's upgrade event (Install into an existing app). On a static host, point the transport at a wisp server elsewhere, such as the public relay wss://holywisp.fracit.al/.
TOMP's service worker had everything it needed in its own configuration, so the tab could navigate to boot.html(url) and leave your page behind. In STomp the transport belongs to the controller, and the controller lives in your page. The service worker asks it for every request. If your page goes away, the proxied page has no one to ask.
So a proxied page is a frame of yours. controller.createFrame() returns a Frame, and frame.go(url) loads a URL in it. In testing, navigating the tab itself to await controller.route(url) showed the page the first time; a reload of it reached the host server, which answered 404. If you liked the full-tab look, make the frame fill the window.
Keeping the controller in your page is also what gives you onNavigate (the address and title of the proxied page as it changes), onOpen (popups you can turn into tabs) and onRequest (a log of every proxied request). Embed STomp in your site shows how to use them.
boot.ready resolved once navigator.serviceWorker.register() and update() had returned, before the worker was necessarily active, so the first navigation could still reach your server instead of the worker. StompController.register() resolves once the worker is activated (after 30 seconds at the most), and controller.wait() resolves once the worker has accepted this controller. After both, frame.go() works.
The old worker read its configuration from its own URL (worker.js?config=...), so a configuration change meant a new worker URL. STomp's worker script has a fixed URL, and each controller sends its configuration when it connects. Several controllers (two tabs of your site) share one worker, each with its own id in its addresses. When a deploy leaves an older worker running, the controller says so with controller.stale and a stale event, and rebinds by itself once the new worker activates.
A routed address is <directory><controller id>/<kind>/<sealed URL>, for example /tomp/kDqSTAdH/html/rffNfPYzd0_xQnlDqhsldqEiVA. The id is 8 characters the controller keeps from visit to visit (or the id you pass). With the default xor codec no character of the real URL appears in the address. Use controller.unroute(address) to read the real URL back; it returns a promise, and null for an address that is not a route.
SearchBuilder keeps its constructor (new SearchBuilder(template), with %s for the query) and its one method, query(input). Its rules changed twice:
| Input | TOMP 2022 | stompV1 | STomp now |
|---|---|---|---|
https://example.com/a |
unchanged | unchanged | unchanged |
example.com |
http://example.com |
http://example.com |
http://example.com |
what is 2.5 |
http://what is 2.5 |
a search | a search |
localhost:3000 |
a search | a search | http://localhost:3000 |
proxy |
a search | a search | a search |
TOMP treated any input with a dot as an address, spaces included. STomp treats input as an address when it starts with http:// or https://, or has no spaces and contains a dot, or is localhost with an optional port. A localhost address only loads if your wisp server allows loopback addresses, which holyWisp and wisp-js refuse by default.
- Remove the TOMP build from your site and install the package:
npm install -E @sysce/stomp@nightly, plus the epoxy build it pins (Install into an existing app). ServestompPathunder the directory you used before, or a new one. - Remove the Bare server and add a wisp server, or use the public relay.
- Serve the epoxy transport's
dist/(for example at/epoxy/). - Replace the bootstrapper script and
new TOMPBoot(...)withStompController.register(),new StompController()andawait controller.wait(). - Add an
<iframe>, pass it tocontroller.createFrame(), and replacelocation.assign(boot.html(...))withframe.go(...). - Replace
TOMPBoot.SearchBuilderwithSearchBuilder. - Clean up the old service worker on returning visitors' browsers (next section).
Browsers keep a registration until it is replaced or removed. If STomp uses the same directory as TOMP did, StompController.register() registers the new script for the same scope and the browser replaces the old worker. If you moved to a new directory, the old worker stays registered at the old scope on every browser that visited before. It does no harm while nothing links there, but you can remove it from your page:
for (const registration of await navigator.serviceWorker.getRegistrations())
if (new URL(registration.scope).pathname === '/tomp/')
await registration.unregister();Old addresses (/tomp/process:html:...) do not resolve under STomp in either case. Bookmarks and history entries from the TOMP days have to be visited again from your address bar.
STomp is licensed under the GPL-3.0. Found a mistake in these pages? Open an issue.