Local Development
The AppView repository can run a bridge on the same local Snowglobe network as the AppView. The bridge gets its own did:web on the network, so the AppView checks its requests the same way it does in production, and you can install it into a Space you create locally.
Before you start
Section titled “Before you start”Set up the local network with Start a local network with Snowglobe. Keep pnpm dev:snowglobe running in the AppView repository, and the client running, so you can create a Space and add the bridge to it.
The bridge app
Section titled “The bridge app”snowglobe.yml in the AppView repository describes an app named bridge on port 3100. Snowglobe serves it at https://bridge.app.colibri.local.snowglobe.at, which makes the bridge’s DID did:web:bridge.app.colibri.local.snowglobe.at.
snowglobe run --app bridge starts a command with these variables set:
| Variable | Value |
|---|---|
COLIBRI_APPVIEW_URL |
https://appview.app.colibri.local.snowglobe.at |
COLIBRI_APPVIEW_DID |
did:web:appview.app.colibri.local.snowglobe.at |
BRIDGE_DID |
did:web:bridge.app.colibri.local.snowglobe.at |
BRIDGE_HTTP_PORT |
3100 |
NODE_EXTRA_CA_CERTS |
The network’s certificate authority, so Node.js trusts its certificates |
snowglobe run reads snowglobe.yml from the current directory. Run it from the AppView repository, even for a bridge that lives somewhere else.
The bridge serves its own DID document. The AppView fetches it from https://bridge.app.colibri.local.snowglobe.at/.well-known/did.json the first time the bridge calls.
Run your own bridge
Section titled “Run your own bridge”-
Generate a signing key once, in the AppView repository:
Terminal window pnpm --filter @colibri-social/bridge exec tsx --conditions=colibri-source src/index.ts keygenStore the printed
BRIDGE_SIGNING_KEYin your bridge’s environment. The bridge builds its DID document from it. -
Serve the DID document on
BRIDGE_HTTP_PORTwhen the bridge starts:src/index.ts import { createServer } from "node:http";import { bridgeDidDocument, publicDidKeyFor } from "@colibri-social/bridge-core";const did = process.env.BRIDGE_DID!;const document = bridgeDidDocument(did, await publicDidKeyFor(process.env.BRIDGE_SIGNING_KEY!));createServer((req, res) => {if (req.url !== "/.well-known/did.json") return res.writeHead(404).end();res.writeHead(200, { "content-type": "application/json" }).end(JSON.stringify(document));}).listen(Number(process.env.BRIDGE_HTTP_PORT));Then create and start the
Bridgeas in Run the bridge, withCOLIBRI_APPVIEW_URL,COLIBRI_APPVIEW_DIDandBRIDGE_DIDfrom the environment. -
Start the bridge through Snowglobe from the AppView repository. The example below runs the
startscript of a bridge cloned next to it:Terminal window pnpm exec snowglobe run --app bridge -- npm --prefix ../my-bridge start -
Check that the network serves the DID document:
Terminal window curl --cacert ~/.local/share/snowglobe/ca/ca.crt \https://bridge.app.colibri.local.snowglobe.at/.well-known/did.jsonWith a
logoption on theBridge, the bridge logsbridge.stream.openonce it’s connected to the AppView.
Run the Discord bridge
Section titled “Run the Discord bridge”The Discord bridge in apps/bridge reads .env.bridge in the AppView repository. Put BRIDGE_SIGNING_KEY and DISCORD_TOKEN there, then run:
pnpm dev:bridge:snowglobeThe variables from snowglobe.yml win over the ones in .env.bridge. apps/bridge serves the DID document by itself when BRIDGE_HTTP_PORT is set. Connect it to a Space with a pairing code, as described in Pairing a Bridge.
Install the bridge in a Space
Section titled “Install the bridge in a Space”-
Open
http://127.0.0.1:5173/app/, sign in asalice.colibri.local.snowglobe.at, and create a Space. -
Open the menu of the Space and select Manage Space, then Bridges.
-
Select New bridge, then Add manually. Enter
did:web:bridge.app.colibri.local.snowglobe.atunder Code or Address and select Connect twice. -
Set the channels the bridge can use to Let the bridge read and reply and select Save.
The bridge receives the new registration right away. A connector that implements openChannelsChanged() is called with installed, and again with updated once the channels are saved.
Troubleshooting
Section titled “Troubleshooting”- The DID document URL answers
502 Bad Gateway. Nothing listens on port3100. Check that the bridge runs and serves its DID document onBRIDGE_HTTP_PORT. - Adding the bridge fails with “no bridge exists at that address”. The AppView couldn’t fetch the DID document, or the document has no
atprotokey. Fetch it withcurlas in the steps above. - Node.js rejects the network’s certificates. The bridge was started without
snowglobe run, soNODE_EXTRA_CA_CERTSisn’t set.