Relay server API
The relay server's HTTP routes: files, the Marketplace, feedback and the rest.
The relay is mostly two WebSockets, the hub and the pairing relay. Beside them it answers a small set of plain HTTP routes: a circle's sealed files, the plugin Marketplace, feedback, bounties, the pages that link a handle, and, where it is given the folder, the app built for a browser. This page lists every one. Relays that talk to each other, home records and a call's media relay have no HTTP routes of their own: they are spoken over the hub's socket. The public relay is at https://gogho.st. Anyone can run their own from the source: dart run relay/bin/relay.dart --port 8787. The WebSocket protocols are on The hub and pairing protocols, and a Postman collection of these routes is on API overview and Postman.
Conventions
- CORS for one address, on two routes. These routes are for the app and for scripts, not for a page in a browser on another site: the relay sets no
Access-Control-*header, but for the two things the app in a browser sends from an address of its own,POST /feedbackandPOST /market/abuse. A relay set with that address (GHOST_APP_ORIGIN) answers both withVary: Origin, and, to a request whoseOriginis exactly that address, withAccess-Control-Allow-Originnaming it. AnOPTIONSfrom that origin is answered204withAccess-Control-Allow-Methods: POST,Access-Control-Allow-Headers: content-type, x-ghost-key, x-ghost-time, x-ghost-sig, x-ghost-body-sha256, x-ghost-body-lengthandAccess-Control-Max-Age: 600. No other route, and no other origin, is told anything. - No match is not an error. A request that fits no route, whatever its method, answers
200with the plain textGhost Messaging relay. There is no separate health route: this is it. - JSON answers are
application/json; charset=utf-8. Request bodies are read as UTF-8 JSON or raw bytes; noContent-Typeis looked at. - Hex is lowercase. Ids and hashes in paths must match their shape exactly, or the route does not exist.
- Times are whole milliseconds since 1970, as decimal digits.
- Per-address limits on these routes go by the first value of
X-Forwarded-For, or the connection's address where there is none. The hub counts differently: see Signing in to the hub.
Each module says no in its own shape:
| Module | A refusal | Notes |
|---|---|---|
| Files | {"err": "No such space."} | A sentence. A few carry more: have, done, seq. |
| Feedback | {"error": "Feedback is sent with POST."} | A sentence, under error, not err. |
| Marketplace | {"ok": false, "error": "not_found", "message": "There's nothing here by that name."} | error is a fixed code; message is for people. Every success carries "ok": true. |
| Bounties | {"error": "Not here."} | A sentence, under error, as feedback's. |
| The app in a browser | Not found | Plain text with 404. A wrong method is 405 with no body. |
Outside the modules, a path or a query whose percent-escapes are not UTF-8 answers 400 with no body, and an error nothing else caught answers 500 with no body. Both close the connection.
Signing a request
Writes to Files, feedback, and most of the Marketplace are signed with the install's own key, the same one the hub knows it by. No account or password is involved. A bounty is signed the same way, by one key the relay was given.
| Thing | Format |
|---|---|
| Key | P-256 (secp256r1). The public key is 33 bytes compressed: 02 or 03, then x. In a header it is standard base64 with padding, 44 characters. |
| Signature | ECDSA over the SHA-256 of the signed string. 64 bytes: r (32, big-endian) then s (32). Not DER. Standard base64, 88 characters. |
| Id | The first 16 bytes of the SHA-256 of the 33 key bytes, as 32 lowercase hex digits. This is who the relay says wrote something. |
| Body hash | SHA-256 of the body's bytes, 64 lowercase hex digits. For an empty body: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855. |
All three modules take the same three headers and sign five lines joined by a line feed (\n), as UTF-8, with no line feed after the last. Only the first line and a few rules differ.
x-ghost-key: <base64 of the 33-byte public key>
x-ghost-time: <milliseconds since 1970>
x-ghost-sig: <base64 of the 64-byte signature>
The relay remembers what each key signed, so the same request sent twice is refused the second time. To try again, sign again with a new time.
Files
Every Files route but GET /files also carries the space's token: Authorization: Ghost <token>, 64 lowercase hex digits. Reads need only the token. Writes need the token and the signature.
ghost-files v1
<METHOD>
<path and query, as sent>
<time>
<body sha256 hex>
- The third line is the whole request target, query included:
/files/0123456789abcdef0123456789abcdef/log?after=7. - The time may be up to 10 minutes from the relay's clock, either way.
- Where the body is not read (
DELETE /files/{space},POST …/done), sign the empty body's hash. - For a blob's piece sent with
x-ghost-body-sha256, the last line is that header's value, and the signature is checked before the body is read. - Any failure answers
401 {"err": "Bad signature."}.
Feedback
ghost-feedback v1
POST
/feedback
<time>
<body sha256 hex>
- The third line is the path alone, with no query.
- The time may be up to 5 minutes from the relay's clock.
Marketplace
ghost-market v1
<METHOD>
<path>
<time>
<body sha256 hex>
- The third line is the path alone. A signed request with any query string is refused.
- The time may be up to 5 minutes from the relay's clock.
- A
POSTmust say its body up front, in two more headers:x-ghost-body-sha256(64 lowercase hex digits; the last signed line) andx-ghost-body-length(the length in bytes, equal toContent-Length). A chunked body is refused. - A
GETorDELETEmust send neither of those headers and no body, and signs the empty body's hash. - A missing header answers
401 unsigned. A bad key, time or signature, or a repeat, answers401 bad_signature. A broken shape (a query, a header sent twice, a length that does not match) answers400 bad_request.
A signed GET /market/mine looks like this:
GET /market/mine HTTP/1.1
Host: gogho.st
x-ghost-key: AqGyw9Tl9gcYKTpLXG1+j5ChssPU5fYHGCk6S1xtfo+Q
x-ghost-time: 1795000000000
x-ghost-sig: <88 base64 characters>
and its signature is over these bytes:
ghost-market v1
GET
/market/mine
1795000000000
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
Bounties
ghost-bounty v1
POST
/bounty
<time>
<body sha256 hex>
- The same three headers.
x-ghost-keymust be the relay's bounty key (GHOST_BOUNTY_KEY), not an install's. - The third line is always
/bounty. - The time may be up to 5 minutes from the relay's clock. A repeat is refused.
- Any failure answers
401 {"error": "Not signed by the bounty key, or too old."}.
Signatures inside Marketplace bodies
Review's decisions are signed a second time, by the reviewer's key, so that the apps can check them without trusting the relay. Each is the same kind of signature over lines joined by \n, and travels as a JSON object with exactly the fields shown. Here key and sig are strict base64: the standard alphabet, padded, no whitespace.
| What | Signed string | Object |
|---|---|---|
| Approval | ghost-market approve v1\n<plugin>\n<version>\n<sha256> | {"v": 1, "plugin", "version", "sha256", "key", "sig", "at"} |
| Revocation | ghost-market revoke v1\n<plugin>\n<sha256>\n<at>\n<why> | {"v": 1, "plugin", "sha256", "at", "why", "key", "sig"} |
| Retirement | ghost-market retire v1\n<key> (the key's base64 text) | {"v": 1, "key", "at", "sig"} |
General
The relay has one answer for anything it does not recognise. A script can use it to see that a relay is there.
GET /
The answer to any request, of any method and path, that no other route takes. There is no separate health route.
Who Anyone
Answers 200 text/plain: Ghost Messaging relay
Refusals 400 (empty) a path whose percent-escapes are not UTF-8 404 text/plain: Ghost Messaging relay a WebSocket upgrade whose last path segment is neither hub nor 32 hex digits 400 (empty) a WebSocket upgrade to the hub or a channel whose Sec-WebSocket-Key is not 1 to 64 printable ASCII characters
Sign-in links
These are pages for a browser, not an API to call. When someone links a Discord, Telegram or X handle, the app asks the hub for a sign-in address and opens it. The address holds a state made for that install, good for 10 minutes and for one sign-in. The relay checks the sign-in with the network, links the handle, and tells the install over the hub. A network whose keys are not set on the server is off, and its page says the link is no good.
GET /link/{network}
Starts a sign-in the app asked for over the hub. Sends the browser to the network's own sign-in (Discord, X) or shows Telegram's login widget.
Who Anyone holding a state from the hub
| Field | Where | Needed | What |
|---|---|---|---|
network | path | yes | discord, telegram or x. Anything else gets the root answer. |
s | query | yes | The state the hub made for this install: 32 hex digits, good for 10 minutes. |
Answers 302 Location: the network's sign-in (discord, x); 200 text/html (telegram)
Refusals 400 text/html "That didn't work" the state is unknown, expired or for another network, or that sign-in is not set up
GET /link/{network}/callback
Where the network sends the browser back. Checks the sign-in, links the handle, and tells the install over the hub. The state works once.
Who Anyone holding a state from the hub
| Field | Where | Needed | What |
|---|---|---|---|
network | path | yes | discord, telegram or x. |
state | query | yes | The state the sign-in was started with. |
code | query | discord and x: the network's authorization code. | |
id | query | telegram: the widget's id. Required for telegram. | |
auth_date | query | telegram: when the widget signed, in seconds. Required for telegram; at most 86400 seconds old. | |
hash | query | telegram: the widget's HMAC-SHA256 over its fields. Required for telegram. | |
username | query | telegram: the account's username. Also taken: first_name, last_name, photo_url. |
Answers 200 text/html "Linked"
Refusals 400 text/html "That didn't work" the state is unknown or used, the sign-in was cancelled, the account could not be confirmed or has no username
Invite words
A circle can be joined by a word. The relay keeps, under the SHA-256 of the word, a sealed link of at most 1024 characters that the app gave it over the hub. It never sees the word or what the link opens. This one route is how the site's join page looks a word up.
GET /word/{h}
The sealed invite link kept under a word's hash. The word itself is never sent.
Who Anyone
| Field | Where | Needed | What |
|---|---|---|---|
h | path | yes | SHA-256 of the word, as the app works it out: 64 lowercase hex digits. |
Answers 200 {"b": "<sealed link>"}
Refusals 404 {"b": null} no such word, a hash of the wrong shape, or a method other than GET
Files
A space's files live on the relay as sealed blobs, beside an ordered log of sealed operations that says what the files are. The relay can't read either: names, keys and contents are sealed by the apps. It sees the space's id, each blob's size, when things were written, and the id of the install that wrote them.
A space is named by an id (32 hex digits) and guarded by a token (64 hex digits), both made by the apps from the space's secret. The relay keeps only the token's hash, and a wrong token is answered exactly as a space that isn't there. Anyone with the token can read. Writing also takes a signature, so a blob is written and finished only by whoever started it, and removed by them, the space's owner, or a moderator who shows the space's signed roster.
Uploading a file is three steps: reserve a blob with its size, send its pieces in order, then finish it. An upload cut short carries on from have. A blob not finished holds its room in the space until it is finished or dropped, and the space's state lists the newest hundred of them under parts, so an app can show an upload that stopped halfway and carry it on or remove it.
| Limit | Default |
|---|---|
| One file | 50,004,194,304 bytes |
| One space | 100,000,000,000 bytes, 10,000 blobs |
| One piece of a blob | 8 MiB |
| One log operation | 32,768 bytes |
| A space's log | 20,000 entries, 16 MiB |
| Writes by one install | 600 a minute |
| Spaces made by one install | 20 |
| A space nobody opens | Removed after 90 days |
| An unfinished blob | Dropped 24 hours after its last write |
GET /files
Says the relay keeps files, and its limits. Answers any method.
Who Anyone
Answers 200 {"files": 1, "maxFile": 50004194304, "quota": 100000000000}
Refusals
PUT /files/{space}
Makes a space, or opens one that exists. The first PUT sets the space's token. The answer is the space's state, as GET gives it.
Who Holder of the space token, signed
| Field | Where | Needed | What |
|---|---|---|---|
space | path | yes | The space's id: 32 lowercase hex digits. |
owner | body | The owner's public key, 66 hex digits. Taken only when it is the signer's own key. | |
rv | body | A roster announcement: {"v": version, "h": sha256 hex of its signed bytes, "ad": [admins' ids], "g": the owner's grant (128 hex), from a non-owner}. Ignored when not believed. |
Answers 201 (made) or 200 (existed) {"seq": 0, "used": 0, "quota": 100000000000, "maxFile": 50004194304, "files": 0, "owner": "02a1…", "rv": 0, "cas": 1, "parts": []}
Refusals 404 {"err": "No such space."} (also a wrong token) 401 {"err": "No token."} 413 {"err": "Too big."} body over 65536 bytes 401 {"err": "Bad signature."} 429 {"err": "Slow down."} 403 {"err": "Too many Files spaces made by this device."} 429 {"err": "Too many Files spaces made from here today."} 507 {"err": "Full."}
GET /files/{space}
The space's state: its last log number, bytes used, limits, owner and roster version, and in parts the newest 100 uploads not finished yet: each blob's id, who started it (by), its size (z), the bytes here (h) and when it last moved (at).
Who Holder of the space token
| Field | Where | Needed | What |
|---|---|---|---|
space | path | yes | The space's id: 32 lowercase hex digits. |
Answers 200 {"seq": 8, "used": 1048592, "quota": 100000000000, "maxFile": 50004194304, "files": 1, "owner": "02a1…", "rv": 3, "cas": 1, "parts": [{"id": "5d41402abc4b2a76b9719d911017c592", "by": "<id>", "z": 1048592000, "h": 8388608, "at": 1763900000000}]}
Refusals 404 {"err": "No such space."} (also a wrong token) 401 {"err": "No token."} 405 {"err": "No."} any method but PUT, GET, DELETE
DELETE /files/{space}
Removes the space and everything in it. The body is not read: sign the empty body's hash.
Who Signed: the space's owner
| Field | Where | Needed | What |
|---|---|---|---|
space | path | yes | The space's id: 32 lowercase hex digits. |
Answers 200 {"ok": true}
Refusals 404 {"err": "No such space."} (also a wrong token) 401 {"err": "No token."} 401 {"err": "Bad signature."} 403 {"err": "Only the space's owner can remove it."}
GET /files/{space}/log
Reads the log after a number, a page at a time: at most 500 entries or about 1 MiB.
Who Holder of the space token
| Field | Where | Needed | What |
|---|---|---|---|
space | path | yes | The space's id: 32 lowercase hex digits. |
after | query | Return entries numbered above this. Default 0. |
Answers 200 {"ops": [{"s": 1, "by": "<id>", "at": 1763900000000, "rv": 3, "c": 1, "o": "<base64>"}], "seq": 1, "more": false}
Refusals 404 {"err": "No such space."} (also a wrong token) 401 {"err": "No token."} 503 {"err": "Busy. Try again in a moment."} with Retry-After: 2
POST /files/{space}/log
Appends one sealed operation to the log. The body is the operation's raw bytes, 1 to 32768.
Who Holder of the space token, signed
| Field | Where | Needed | What |
|---|---|---|---|
space | path | yes | The space's id: 32 lowercase hex digits. |
after | query | The log number this was written against. The entry lands at after + 1 or not at all. |
Answers 200 {"seq": 8}
Refusals 404 {"err": "No such space."} (also a wrong token) 401 {"err": "No token."} 413 {"err": "An operation is at most 32768 bytes."} also an empty body 401 {"err": "Bad signature."} 429 {"err": "Slow down."} 409 {"err": "The list has moved on. Read it again.", "seq": 8} 507 {"err": "This space's list is full."} 507 {"err": "This space is full."} 507 {"err": "The files server is full."}
POST /files/{space}/blobs
Asks for room for one sealed file and gets its id. The size counts against the space from now.
Who Holder of the space token, signed
| Field | Where | Needed | What |
|---|---|---|---|
space | path | yes | The space's id: 32 lowercase hex digits. |
size | body | yes | The sealed file's length in bytes: 16 to maxFile. |
pre | body | true: every piece will say its hash first (x-ghost-body-sha256); pieces without are refused. |
Answers 201 {"id": "5d41402abc4b2a76b9719d911017c592", "have": 0}
Refusals 404 {"err": "No such space."} (also a wrong token) 401 {"err": "No token."} 413 {"err": "Too big."} body over 1024 bytes 401 {"err": "Bad signature."} 429 {"err": "Slow down."} 400 {"err": "No size."} 400 {"err": "Too small."} 413 {"err": "A file may be at most 50004194304 bytes."} 507 {"err": "This space is full."} 507 {"err": "The files server is full."} 507 {"err": "This space holds as many files as it can."} 429 {"err": "Too many files on their way from here. Finish those first."}
GET /files/{space}/blobs/{blob}
Downloads a finished blob, whole or one byte range of it.
Who Holder of the space token
| Field | Where | Needed | What |
|---|---|---|---|
space | path | yes | The space's id: 32 lowercase hex digits. |
blob | path | yes | The blob's id, as POST /files/{space}/blobs answered it: 32 lowercase hex digits. |
Range | header | One range: bytes=a-b, bytes=a- or bytes=-n. |
Answers 200 or 206 application/octet-stream, with Accept-Ranges: bytes and, for 206, Content-Range
Refusals 404 {"err": "No such space."} (also a wrong token) 401 {"err": "No token."} 404 {"err": "No such file."} 409 {"err": "Not all of it is here yet."} 416 (empty) with Content-Range: bytes */<length>
HEAD /files/{space}/blobs/{blob}
The headers of a download (Content-Length, Accept-Ranges) without the bytes.
Who Holder of the space token
| Field | Where | Needed | What |
|---|---|---|---|
space | path | yes | The space's id: 32 lowercase hex digits. |
blob | path | yes | The blob's id, as POST /files/{space}/blobs answered it: 32 lowercase hex digits. |
Range | header | One range, as for GET. |
Answers 200 or 206, headers only
Refusals 404 no such space or file 401 no token 409 not finished 416 bad range
PUT /files/{space}/blobs/{blob}
Uploads the next piece of a blob, at most 8388608 bytes. Pieces go in order, one at a time.
Who Signed: whoever reserved the blob
| Field | Where | Needed | What |
|---|---|---|---|
space | path | yes | The space's id: 32 lowercase hex digits. |
blob | path | yes | The blob's id, as POST /files/{space}/blobs answered it: 32 lowercase hex digits. |
offset | query | yes | Where this piece starts. Must equal the bytes the relay has (have). |
x-ghost-body-sha256 | header | SHA-256 of this piece, 64 hex digits. Sent, it is the body hash that is signed, and the signature is checked before the body is read. Required when the blob was reserved with pre. | |
x-ghost-body-length | header | With x-ghost-body-sha256: the piece's length. Defaults to Content-Length and must equal it. |
Answers 200 {"have": 8388608}
Refusals 404 {"err": "No such space."} (also a wrong token) 401 {"err": "No token."} 404 {"err": "No such file."} 409 {"err": "Already finished.", "have": 1048592, "done": true} 409 {"err": "Send from where it has got to.", "have": 0} 413 {"err": "A piece is at most 8388608 bytes."} 400 {"err": "The body's hash and length don't match the request."} 413 {"err": "More than the file was said to be."} 401 {"err": "Bad signature."} 403 {"err": "Not yours."} 403 {"err": "Say the piece's hash first."} 429 {"err": "Slow down."} 400 {"err": "The body isn't what its hash said."} 500 {"err": "Something went wrong."} the body stalled for 30 seconds; the piece is dropped
GET /files/{space}/blobs/{blob}/state
How much of a blob has arrived, to carry on an upload.
Who Holder of the space token
| Field | Where | Needed | What |
|---|---|---|---|
space | path | yes | The space's id: 32 lowercase hex digits. |
blob | path | yes | The blob's id, as POST /files/{space}/blobs answered it: 32 lowercase hex digits. |
Answers 200 {"have": 8388608, "size": 1048592000, "done": false}
Refusals 404 {"err": "No such space."} (also a wrong token) 401 {"err": "No token."} 404 {"err": "No such file."}
POST /files/{space}/blobs/{blob}/done
Finishes a blob once every byte is there, so it can be downloaded. The body is ignored: sign the empty body's hash.
Who Signed: whoever reserved the blob
| Field | Where | Needed | What |
|---|---|---|---|
space | path | yes | The space's id: 32 lowercase hex digits. |
blob | path | yes | The blob's id, as POST /files/{space}/blobs answered it: 32 lowercase hex digits. |
Answers 200 {"have": 1048592, "done": true}
Refusals 404 {"err": "No such space."} (also a wrong token) 401 {"err": "No token."} 404 {"err": "No such file."} 401 {"err": "Bad signature."} 403 {"err": "Not yours."} 409 {"err": "Not all of it is here yet."}
DELETE /files/{space}/blobs/{blob}
Removes a blob, finished or not, and frees its room. A moderator or admin sends the space's signed roster as proof.
Who Signed: its uploader, the space's owner, or a moderator with a roster
| Field | Where | Needed | What |
|---|---|---|---|
space | path | yes | The space's id: 32 lowercase hex digits. |
blob | path | yes | The blob's id, as POST /files/{space}/blobs answered it: 32 lowercase hex digits. |
roster | body | {"r": base64 of the bytes the roster's author signed, "s": the signature, 128 hex}. Looked at only when the signer is neither the uploader nor the owner. |
Answers 200 {"ok": true}
Refusals 404 {"err": "No such space."} (also a wrong token) 401 {"err": "No token."} 404 {"err": "No such file."} 413 {"err": "Too big."} body over 65536 bytes 401 {"err": "Bad signature."} 403 {"err": "Only whoever added it, the space's owner, or a moderator can remove it."} 429 {"err": "Slow down."} 403 {"err": "No roster."} or "Not a roster." 403 {"err": "This space's owner hasn't opened it yet, so no roster can be checked."} 403 {"err": "That roster isn't signed by this space's owner or an admin."} 403 {"err": "That roster is older than one this space has seen."} 403 {"err": "This space has seen another roster at that version."} 403 {"err": "That roster skips ahead of what this space has seen."} 403 {"err": "This space's roles don't let you remove that file."}
Feedback
The app's Share feedback sends one signed report. The relay files it on the server's feedback board and answers with the ticket's id. It keeps nothing itself. A username in the report is filed as given when the signing key holds that username, and marked not verified otherwise. On a relay with no board set up the route answers 503.
Limits: 5 reports an hour and 20 a day from one install, 300 a day from everyone, 10 MiB a report, three screenshots of 3 MiB each.
POST /feedback
Files one report, with up to three screenshots. The whole body is at most 10485760 bytes.
Who Signed: any install
| Field | Where | Needed | What |
|---|---|---|---|
type | body | yes | bug, feature, confusing, praise or other. |
text | body | yes | What happened. Cut to 5000 characters. |
title | body | Cut to 120 characters. Left out, the text's first line is used. | |
username | body | The sender's username. Filed as "(not verified)" unless the signing key holds it. | |
platform | body | android, iphone, mac, windows or linux. | |
version | body | The app's version. Cut to 40 characters. | |
Origin | header | From the app in a browser at the address the relay is set to allow (GHOST_APP_ORIGIN), the answer carries Access-Control-Allow-Origin for it. | |
shots | body | Up to 3 of {"name", "mime", "data"}: mime image/png, image/jpeg, image/webp or image/gif; data base64, at most 3145728 bytes decoded. A bad one is skipped. |
Answers 200 {"ok": true, "id": "GMFB-12"}
Refusals 405 {"error": "Feedback is sent with POST."} 503 {"error": "Feedback isn't set up on this server yet."} 413 {"error": "That's too big to send. Try fewer or smaller screenshots."} 400 {"error": "The feedback didn't arrive whole. Try again."} 401 {"error": "The app's signature didn't check out. Make sure your clock is right, then try again."} 429 {"error": "That's a lot of feedback at once. Thank you! Try again in a while."} 400 {"error": "The feedback couldn't be read."} 400 {"error": "Say what happened, in a few words at least."} 502 {"error": "The feedback board didn't take it just now. Try again in a while."} 502 {"error": "The feedback board couldn't be reached. Try again in a while."}
Marketplace
The Marketplace holds plugins from other developers and the queue they wait in for review. A plugin's package is one JSON file in the ghost-plugin/1 format, sent in canonical form (keys sorted, no whitespace) and named by its SHA-256.
Anyone can read the catalog, the withdrawals list, approved packages and listed screenshots. A developer signs with the key that holds the username in the plugin's developer field. Review is an install that holds one of the relay's admin usernames and signed in to the admin page over the hub in the last 8 hours, or the last 30 minutes for approving, revoking, blocking and listing. No password travels over these routes.
The relay is not trusted with a plugin. An approval is the reviewer's own signature over the plugin's id, version and hash, and the app checks it against review keys it already knows before it adds anything. The catalog carries no names or pictures: the app fetches each package and reads them from it.
The relay keeps packages, screenshots, submissions with their notes, reports, and a log of what review did. A report is kept without its sender's key.
The same review takes reports of people and messages (/market/abuse). The app seals each one to the review keys before it sends it, so the relay holds an envelope it can't read, and never who sent it. It keeps the newest 150, letting go first of the oldest one marked done.
| Limit | Default |
|---|---|
| One package | 262,144 bytes |
| Screenshots | 4, PNG, 1 MiB each, 64 to 2,400 pixels a side |
| A signed body | 6 MiB |
| Submissions | 5 a day and 3 waiting, by one developer |
| A new username | Can submit 7 days after it is claimed |
| Public reads | 240 a minute from one address; the catalog and withdrawals 10 a minute |
| Signed requests | 300 an hour by one key, 60 a minute from one address |
| Reports of people | 5 an hour and 15 a day by one key, 20 a day from one address, 15 a day by one verified number or account; 48,000 characters sealed |
GET /market
Whether the Marketplace is open, its limits, and the labels, shelves, hues and permissions a plugin may name. Answers even when it is off.
Who Anyone
Answers 200 {"ok": true, "market": 1, "format": "ghost-plugin/1", "open": true, "limits": {"package": 262144, "icon": 48000, "shot": 1048576, "shotSide": 2400, "shots": 4, "body": 6291456, "notes": 1000}, "labels": [...], "shelves": [...], "hues": [...], "permissions": [...]}
Refusals 429 {"ok": false, "error": "rate_limited"} 405 {"ok": false, "error": "method"}
GET /market/catalog
Every listed plugin's current version: its id, hash, size and the reviewer's signed approval. At most 2000, newest first. Names and pictures are in each package.
Who Anyone
| Field | Where | Needed | What |
|---|---|---|---|
If-None-Match | header | The ETag from an earlier answer. A match answers 304 with no body. |
Answers 200 {"ok": true, "v": 1, "at": 1795000000000, "plugins": [{"id", "version", "sha256", "size", "approval": {...}, "listedAt", "updatedAt"}]} with an ETag
Refusals 429 {"ok": false, "error": "rate_limited"} 503 {"ok": false, "error": "off"} or "busy"
GET /market/revoked
The withdrawals list: signed revocations of approved versions, and review keys no longer to be trusted. Oldest first.
Who Anyone
| Field | Where | Needed | What |
|---|---|---|---|
If-None-Match | header | The ETag from an earlier answer. A match answers 304 with no body. |
Answers 200 {"ok": true, "v": 1, "at": 0, "revoked": [], "retired": []} with an ETag
Refusals 429 {"ok": false, "error": "rate_limited"} 503 {"ok": false, "error": "off"} or "busy"
GET /market/packages/{sha256}
An approved version's package: the plugin's canonical JSON bytes, current or earlier, listed or not.
Who Anyone
| Field | Where | Needed | What |
|---|---|---|---|
sha256 | path | yes | SHA-256 of the package: 64 lowercase hex digits. |
Answers 200 application/octet-stream, filename "<id>-<version>.uplinkplugin"
Refusals 404 {"ok": false, "error": "not_found"} 410 {"ok": false, "error": "revoked"} 429 {"ok": false, "error": "rate_limited"} 503 {"ok": false, "error": "off"} or "busy"
GET /market/shots/{sha256}
A screenshot of a listed plugin's current version.
Who Anyone
| Field | Where | Needed | What |
|---|---|---|---|
sha256 | path | yes | SHA-256 of the picture: 64 lowercase hex digits. |
Answers 200 image/png
Refusals 404 {"ok": false, "error": "not_found"} 429 {"ok": false, "error": "rate_limited"} 503 {"ok": false, "error": "off"} or "busy"
POST /market/report
Reports a plugin to review. The sender's key is not kept with the report.
Who Signed: any install
| Field | Where | Needed | What |
|---|---|---|---|
plugin | body | yes | The plugin's id. It must have an approved version. |
version | body | yes | The version, as 1.0.0. |
reason | body | yes | misleading, harmful, spam, privacy, broken or other. |
text | body | At most 1000 characters. | |
username | body | The sender's username. Marked verified when the signing key holds it. |
Answers 201 {"ok": true, "id": "<16 hex>"}
Refusals 401 {"ok": false, "error": "unsigned"} or "bad_signature" 400 {"ok": false, "error": "bad_json"} or "bad_request" 404 {"ok": false, "error": "not_found"} 429 {"ok": false, "error": "rate_limited"}
POST /market/submissions
Sends a plugin for review, or with check: true only checks it and keeps nothing. A new submission replaces the plugin's open ones.
Who Signed: the developer
| Field | Where | Needed | What |
|---|---|---|---|
package | body | yes | Base64 of the plugin's canonical JSON bytes (keys sorted, no whitespace). At most 262144 bytes decoded. |
shots | body | Up to 4, each {"mime": "image/png", "data": base64} or {"keep": sha256 of an earlier one}. Their hashes, in order, must be the plugin's shots list. | |
notes | body | Notes for the reviewer. At most 1000 characters. | |
list | body | now (the default) or later: approved, it waits for its developer to list it. | |
agree | body | Must be true to submit: agreement to the Marketplace guidelines. Left out with check. | |
check | body | true: check only. The body is then exactly check and package. |
Answers 201 {"ok": true, "submission": {"sid", "plugin", "version", "sha256", "size", "status": "submitted", ...}}; check: 200 {"ok": true, "checked": true}
Refusals 401 {"ok": false, "error": "unsigned"} or "bad_signature" 403 {"ok": false, "error": "blocked"} or "needs_verified", "too_new", "not_owner" 400 {"ok": false, "error": "bad_json"} or "bad_request" 400 {"ok": false, "error": "must_agree"} 400 {"ok": false, "error": "invalid_package", "issues": [{"code", "path", "message", "severity"}]} 400 {"ok": false, "error": "not_canonical"} or "bad_shot" 413 {"ok": false, "error": "too_large"} 409 {"ok": false, "error": "name_used"} or "id_taken", "version_not_newer", "duplicate" 429 {"ok": false, "error": "too_many_plugins"} or "open_limit", "rate_limited" 507 {"ok": false, "error": "developer_full"} or "full"
GET /market/mine
The caller's own submissions (newest first, at most 100) and plugins, and whether they are blocked.
Who Signed: any install
Answers 200 {"ok": true, "blocked": false, "submissions": [...], "plugins": [{"id", "listing", "current", "by", "note", "noteAt"}]}
Refusals 401 {"ok": false, "error": "unsigned"} or "bad_signature" 429 {"ok": false, "error": "rate_limited"}
GET /market/submissions/{sid}
One submission: its status, the plugin's words and the notes between developer and reviewer.
Who Signed: its developer, or review
| Field | Where | Needed | What |
|---|---|---|---|
sid | path | yes | The submission's id: 24 lowercase hex digits. |
Answers 200 {"ok": true, "submission": {...}}
Refusals 401 {"ok": false, "error": "unsigned"} or "bad_signature" 404 {"ok": false, "error": "not_found"} 403 {"ok": false, "error": "not_admin"}
GET /market/submissions/{sid}/package
A submission's package bytes, approved or not.
Who Signed: its developer, or review
| Field | Where | Needed | What |
|---|---|---|---|
sid | path | yes | The submission's id: 24 lowercase hex digits. |
Answers 200 application/octet-stream, filename "<plugin>-<version>.uplinkplugin"
Refusals 401 {"ok": false, "error": "unsigned"} or "bad_signature" 404 {"ok": false, "error": "not_found"} 403 {"ok": false, "error": "not_admin"}
GET /market/submissions/{sid}/shots/{n}
One of a submission's screenshots.
Who Signed: its developer, or review
| Field | Where | Needed | What |
|---|---|---|---|
sid | path | yes | The submission's id: 24 lowercase hex digits. |
n | path | yes | Which screenshot, from 0: one digit. |
Answers 200 image/png
Refusals 401 {"ok": false, "error": "unsigned"} or "bad_signature" 404 {"ok": false, "error": "not_found"} 403 {"ok": false, "error": "not_admin"}
DELETE /market/submissions/{sid}
Withdraws a submission that is still waiting.
Who Signed: its developer
| Field | Where | Needed | What |
|---|---|---|---|
sid | path | yes | The submission's id: 24 lowercase hex digits. |
Answers 200 {"ok": true, "submission": {..., "status": "withdrawn"}}
Refusals 401 {"ok": false, "error": "unsigned"} or "bad_signature" 404 {"ok": false, "error": "not_found"} also another developer's 409 {"ok": false, "error": "wrong_state"}
GET /market/review
The review queue: every open submission, the 50 most recently decided, and counts, with the reports of plugins and of people not yet done.
Who Review
Answers 200 {"ok": true, "open": [...], "recent": [...], "counts": {"submitted": 0, "in_review": 0, "changes_requested": 0, "reports": 0, "abuse": 0}}
Refusals 401 {"ok": false, "error": "unsigned"} or "bad_signature" 403 {"ok": false, "error": "not_admin"}
GET /market/review/{sid}
Everything a reviewer needs for one submission: its package, the listed version it would replace, what was asked for before, and its developer.
Who Review
| Field | Where | Needed | What |
|---|---|---|---|
sid | path | yes | The submission's id: 24 lowercase hex digits. |
Answers 200 {"ok": true, "submission": {...}, "package": "<base64>", "previous": null, "asked": null, "history": [], "developer": {"id", "username", "blocked", "plugins", "submissions", "firstAt"}}
Refusals 401 {"ok": false, "error": "unsigned"} or "bad_signature" 403 {"ok": false, "error": "not_admin"} 404 {"ok": false, "error": "not_found"}
POST /market/review/{sid}
A decision on a submission. An approval carries the reviewer's own signature over the plugin, which the apps check themselves.
Who Review (approve: signed in within 30 minutes)
| Field | Where | Needed | What |
|---|---|---|---|
sid | path | yes | The submission's id: 24 lowercase hex digits. |
decision | body | yes | start, approve, changes or reject. |
note | body | Required for changes and reject. 1 to 2000 characters. | |
approval | body | Required for approve, refused otherwise: {"v": 1, "plugin", "version", "sha256", "key", "sig", "at"}, signed by the request's own key. | |
revokes | body | approve only: up to 5 revocations of earlier versions, each as POST /market/plugins/{id}/revoke takes. |
Answers 200 {"ok": true, "submission": {...}}
Refusals 401 {"ok": false, "error": "unsigned"} or "bad_signature" 403 {"ok": false, "error": "not_admin"} 400 {"ok": false, "error": "bad_json"} or "bad_request" 404 {"ok": false, "error": "not_found"} 409 {"ok": false, "error": "wrong_state"} or "version_not_newer" 400 {"ok": false, "error": "bad_approval"} 507 {"ok": false, "error": "withdrawals_full"}
POST /market/plugins/{id}/listing
Lists an approved plugin in the catalog or takes it off. Its versions stay downloadable either way.
Who Signed: its developer, or review (signed in within 30 minutes)
| Field | Where | Needed | What |
|---|---|---|---|
id | path | yes | The plugin's id: a lowercase letter, then 2 to 23 lowercase letters or digits. |
listed | body | yes | true to list, false to unlist. |
note | body | 1 to 500 characters, kept with the plugin. |
Answers 200 {"ok": true, "plugin": {"id": "tidyup", "listing": "unlisted", "current": "1.0.0", "by": "owner", "note": "...", "noteAt": 1795000000000}}
Refusals 401 {"ok": false, "error": "unsigned"} or "bad_signature" 400 {"ok": false, "error": "bad_json"} or "bad_request" 404 {"ok": false, "error": "not_found"} 403 {"ok": false, "error": "not_admin"} 409 {"ok": false, "error": "wrong_state"} or "admin_unlisted" 403 {"ok": false, "error": "blocked"}
POST /market/plugins/{id}/revoke
Withdraws one approved package. Its download answers 410 from then on, and the signed revocation joins the withdrawals list.
Who Review (signed in within 30 minutes)
| Field | Where | Needed | What |
|---|---|---|---|
id | path | yes | The plugin's id: a lowercase letter, then 2 to 23 lowercase letters or digits. |
v | body | yes | Always 1. |
plugin | body | yes | The plugin's id, the same as in the path. |
sha256 | body | yes | The hash of one of its approved versions. |
at | body | yes | When, in milliseconds. Covered by the signature. |
why | body | yes | 1 to 200 characters, one line. |
key | body | yes | The request's own signing key, base64. |
sig | body | yes | Base64 signature over the revocation's words. |
Answers 200 {"ok": true, "revoked": {...}, "plugin": {...}}
Refusals 401 {"ok": false, "error": "unsigned"} or "bad_signature" 403 {"ok": false, "error": "not_admin"} 400 {"ok": false, "error": "bad_json"} or "bad_approval" 404 {"ok": false, "error": "not_found"} 507 {"ok": false, "error": "withdrawals_full"}
GET /market/reports
The newest 500 reports, newest first.
Who Review
Answers 200 {"ok": true, "reports": [{"rid", "plugin", "version", "reason", "text", "username", "verified", "at", "done", "doneAt"}]}
Refusals 401 {"ok": false, "error": "unsigned"} or "bad_signature" 403 {"ok": false, "error": "not_admin"}
POST /market/reports/{rid}
Marks a report done.
Who Review
| Field | Where | Needed | What |
|---|---|---|---|
rid | path | yes | The report's id: 16 lowercase hex digits. |
done | body | yes | Always true. The body is exactly this. |
Answers 200 {"ok": true}
Refusals 401 {"ok": false, "error": "unsigned"} or "bad_signature" 403 {"ok": false, "error": "not_admin"} 400 {"ok": false, "error": "bad_json"} or "bad_request" 404 {"ok": false, "error": "not_found"}
POST /market/abuse
Reports a person or a message to review. The report is sealed in the app to the review keys: the relay can't read it, and keeps the envelope without its sender's key. The newest 150 are kept.
Who Signed: any install
| Field | Where | Needed | What |
|---|---|---|---|
sealed | body | yes | The sealed report: strict base64, at most 48000 characters, at least 64 bytes decoded. The body is exactly this. |
Origin | header | From the app in a browser at the address the relay is set to allow (GHOST_APP_ORIGIN), the answer carries Access-Control-Allow-Origin for it. |
Answers 201 {"ok": true, "id": "<16 hex>"}
Refusals 401 {"ok": false, "error": "unsigned"} or "bad_signature" 400 {"ok": false, "error": "bad_json"} or "bad_request" 413 {"ok": false, "error": "too_large"} 429 {"ok": false, "error": "rate_limited"} 5 an hour and 15 a day by one key, 20 a day from one address
GET /market/abuse
The reports of people and messages that are kept, newest first, each still sealed. Only a holder of a review key can open one.
Who Review
Answers 200 {"ok": true, "reports": [{"rid", "sealed", "at", "done", "doneAt"}]}
Refusals 401 {"ok": false, "error": "unsigned"} or "bad_signature" 403 {"ok": false, "error": "not_admin"}
POST /market/abuse/{rid}
Marks a report of a person or a message done.
Who Review
| Field | Where | Needed | What |
|---|---|---|---|
rid | path | yes | The report's id: 16 lowercase hex digits. |
done | body | yes | Always true. The body is exactly this. |
Answers 200 {"ok": true}
Refusals 401 {"ok": false, "error": "unsigned"} or "bad_signature" 403 {"ok": false, "error": "not_admin"} 400 {"ok": false, "error": "bad_json"} or "bad_request" 404 {"ok": false, "error": "not_found"}
POST /market/developers/{dev}/block
Blocks a developer from submitting and from listing again, or lifts the block.
Who Review (signed in within 30 minutes)
| Field | Where | Needed | What |
|---|---|---|---|
dev | path | yes | The developer's id: 32 lowercase hex digits. |
blocked | body | yes | true to block, false to unblock. |
note | body | 1 to 500 characters, kept with the developer and their plugins. | |
unlist | body | true: every listed plugin of theirs is unlisted. |
Answers 200 {"ok": true, "developer": {"id": "<32 hex>", "username": "sam.dev", "blocked": true, "plugins": 2, "submissions": 5, "firstAt": 1795000000000}}
Refusals 401 {"ok": false, "error": "unsigned"} or "bad_signature" 403 {"ok": false, "error": "not_admin"} 400 {"ok": false, "error": "bad_json"} or "bad_request"
POST /market/retire
Retires a review key: its approvals are refused from then on, and the retirement joins the withdrawals list. The request is not signed; the body carries the key's own signature.
Who Anyone holding the review key
| Field | Where | Needed | What |
|---|---|---|---|
Content-Length | header | yes | The body's length: at most 4096. |
v | body | yes | Always 1. |
key | body | yes | The review key, base64. One that has approved or revoked something here. |
at | body | yes | When, in milliseconds. Not covered by the signature. |
sig | body | yes | Base64 signature by that key over the retirement's words. |
Answers 200 {"ok": true, "retired": {"v": 1, "key": "...", "at": 1795000000000, "sig": "..."}}
Refusals 429 {"ok": false, "error": "rate_limited"} 10 an hour from one address 400 {"ok": false, "error": "bad_json"} or "bad_request" 413 {"ok": false, "error": "too_large"} 404 {"ok": false, "error": "not_found"} a key that has signed nothing here 401 {"ok": false, "error": "bad_signature"} 507 {"ok": false, "error": "withdrawals_full"}
Bounties
A relay can be given one key that may give souls: the bounty key. Its holder signs a POST /bounty naming an install, a number of souls and a reason. The relay adds the souls, writes the grant in the admin log beside the admin page's own, and tells the install over the hub if it is connected. The key can do nothing else. On a relay with no bounty key the route answers 404.
Limits: 1 to 500 souls at a time, 30 grants a day, a body of 4,096 bytes, a reason of 200 characters.
POST /bounty
Gives souls to one install, with a reason, and records it in the admin log. Signed by the bounty key alone, over ghost-bounty v1. At most 30 a day; the body is at most 4096 bytes.
Who Holder of the bounty key
| Field | Where | Needed | What |
|---|---|---|---|
x-ghost-key | header | yes | The bounty key's public half: base64 of its 33 bytes. It must be the key the relay was given. |
x-ghost-time | header | yes | Milliseconds since 1970, within 5 minutes of the relay's clock. |
x-ghost-sig | header | yes | Base64 of the 64-byte signature over the five lines: ghost-bounty v1, POST, /bounty, the time, the body's SHA-256 in hex. |
to | body | yes | Who gets them: an install's id, 32 lowercase hex digits. |
souls | body | yes | A whole number from 1 to 500. |
why | body | yes | The reason, shown to the person: 1 to 200 characters. |
Answers 200 {"ok": true, "to": "0f1e…", "souls": 50, "n": 150} n is their total after
Refusals 405 {"error": "A bounty is paid with POST."} 404 {"error": "Not here."} no bounty key is set 413 {"error": "Too long to be a bounty."} 400 {"error": "It didn't arrive whole."} the body stalled for 15 seconds 401 {"error": "Not signed by the bounty key, or too old."} also a repeat 400 {"error": "It couldn't be read."} 400 {"error": "to is an Uplink id: 32 hex characters."} 400 {"error": "Between 1 and 500 souls."} 400 {"error": "Say why (the ticket), in at most 200 characters."} 429 {"error": "That's 30 bounties today; more tomorrow."}
Sending souls
A person can send some of their souls to someone else on the same relay. The sender signs a POST /souls/send with their own hub key, so the relay knows whose souls to move: the id of the key that signed. The headers are the three a bounty carries, over the five lines ghost-souls v1, POST, the path, the time and the body's SHA-256 in hex.
Souls only move. The sender's count goes down and the receiver's goes up by the same number in one step, with a receipt, and all three are written to disk together before the relay answers. The receiver must hold a username on this relay, so souls can't be sent to nobody. Both people are told their new count over the hub if they are connected.
Each sending carries an id the sender makes up. The relay moves souls once for an id: a request sent again because its answer was lost gets the first receipt back with "again": true. The app writes that id into the card it puts in the chat, and the other person's app asks POST /souls/receipt before it shows the card as souls sent. A receipt is given only to the two people in it.
Limits: 1 to 100 souls at a time; 300 souls and 10 sendings from one person in 24 hours; 20 askings to send and 300 receipt checks an hour by one key; 600 signed requests an hour from one address; a body of 1,024 bytes. Receipts are kept for a day at least, and the newest 5,000 after that.
Every answer of these two routes is JSON with ok. A relay from before them answers the paths as it answers any it doesn't know, with 200 and a line of text, and the app reads that as "not available yet".
POST /souls/send
Moves souls from the signer to another person on this relay and answers a receipt. Nothing is made or lost: what leaves one count arrives in the other. Asked again with the same id, it answers the first receipt and moves nothing. At most 100 souls at a time, 300 souls and 10 sendings in 24 hours; the body is at most 1024 bytes.
Who Signed: the sender
| Field | Where | Needed | What |
|---|---|---|---|
x-ghost-key | header | yes | The sender's hub key: base64 of its 33 bytes. Its id is whose souls are sent. |
x-ghost-time | header | yes | Milliseconds since 1970, within 5 minutes of the relay's clock. |
x-ghost-sig | header | yes | Base64 of the 64-byte signature over the five lines: ghost-souls v1, POST, /souls/send, the time, the body's SHA-256 in hex. |
to | body | yes | Who gets them: an Uplink id, 32 lowercase hex digits, that holds a username on this relay. |
souls | body | yes | A whole number from 1 to 100. |
id | body | yes | The sender's own name for this sending: 32 lowercase hex digits, made up afresh each time. Souls move once for each id. |
Answers 200 {"ok": true, "receipt": {"id": "6b1f…", "at": 1764000000000, "from": "a4bb…", "to": "0f1e…", "souls": 20}, "n": 80} n is the sender's total after; "again": true for a repeat of the same id
Refusals 405 {"ok": false, "error": "method"} 413 {"ok": false, "error": "too_large"} 401 {"ok": false, "error": "bad_signature"} not signed, too old, or the same signed request again 429 {"ok": false, "error": "rate_limited"} 20 askings an hour by one key, 600 an hour from one address 400 {"ok": false, "error": "bad_request"} a body that can't be read, or a to or id that isn't 32 hex digits 400 {"ok": false, "error": "amount"} not a whole number from 1 to 100 400 {"ok": false, "error": "yourself"} 409 {"ok": false, "error": "no_account"} the sender holds no username here 409 {"ok": false, "error": "no_receiver"} nobody with a username here has that id 409 {"ok": false, "error": "id_used"} that id was another sending's 409 {"ok": false, "error": "not_enough"} 429 {"ok": false, "error": "daily_limit"} 300 souls or 10 sendings in 24 hours
POST /souls/receipt
Reads the receipt of one sending, for one of the two people in it. The app asks before a card in a chat may say souls were sent. Signed as /souls/send is, over its own path.
Who Signed: the sender or the receiver
| Field | Where | Needed | What |
|---|---|---|---|
x-ghost-key | header | yes | The asker's hub key: base64 of its 33 bytes. |
x-ghost-time | header | yes | Milliseconds since 1970, within 5 minutes of the relay's clock. |
x-ghost-sig | header | yes | Base64 of the 64-byte signature over the five lines: ghost-souls v1, POST, /souls/receipt, the time, the body's SHA-256 in hex. |
id | body | yes | The sending's id, as its sender made it: 32 lowercase hex digits. |
Answers 200 {"ok": true, "receipt": {"id": "6b1f…", "at": 1764000000000, "from": "a4bb…", "to": "0f1e…", "souls": 20}} "receipt": null where there is none, or the asker is neither person
Refusals 401 {"ok": false, "error": "bad_signature"} 429 {"ok": false, "error": "rate_limited"} 300 askings an hour by one key 400 {"ok": false, "error": "bad_request"}
The app in a browser
A relay started with --web <folder> serves the app built for a browser under /app/, as plain files. A page in a browser may speak only to where it came from, and the hub sends no CORS headers, so the page and the hub have to be one address: this is how a relay gives its people the app in a browser. Without the folder there is no /app/, and these paths get the root answer.
GETandHEADonly. Nothing is written or kept about who asked.- Only files inside the folder, links followed. A folder is never listed.
index.html, and any file whose name does not hold a hash of its contents, answersCache-Control: no-cachewith anETag. A name with eight or more hex digits between dots before its ending (main.dart.3f9a1c2b.js) answerspublic, max-age=31536000, immutable.- Nothing is compressed as it is asked for. A
.bror.gzcopy beside a file, no older than it, is sent whereAccept-Encodingtakes it. - Every answer carries the page's own
Content-Security-Policy(read from its<meta>, withframe-ancestors 'none'added),X-Frame-Options: DENY,X-Content-Type-Options: nosniff,Referrer-Policy: no-referrer,Cross-Origin-Opener-Policy: same-origin,Cross-Origin-Resource-Policy: same-originandPermissions-Policy: camera=(), microphone=(), geolocation=(), display-capture=(). HSTS is left to the web server in front.
GET /app/
The app's page, index.html. /app without the slash answers 301 to /app/, keeping any query.
Who Anyone
| Field | Where | Needed | What |
|---|---|---|---|
If-None-Match | header | The ETag from an earlier answer. A match answers 304 with no body. |
Answers 200 text/html; charset=utf-8, with an ETag and Cache-Control: no-cache
Refusals 404 text/plain: Not found the folder has no index.html 405 (empty) with Allow: GET, HEAD
GET /app/{path}
One file of the build. Its type goes by its ending. A file with a hash of its contents in its name is kept for a year; any other is asked for again each time. Where name.br or name.gz lies beside it and the browser takes that packing, that is what is sent. A folder is not listed.
Who Anyone
| Field | Where | Needed | What |
|---|---|---|---|
path | path | yes | The file, as the page names it: one or more parts with slashes between. No part may be . or .., start with a dot, or hold a backslash, a colon or a control character. |
If-None-Match | header | The ETag from an earlier answer. A match answers 304 with no body. | |
Accept-Encoding | header | br or gzip: a copy packed beforehand is sent where there is one, with Content-Encoding. |
Answers 200 the file, with Content-Type, ETag, Vary: Accept-Encoding and Cache-Control: no-cache, or public, max-age=31536000, immutable
Refusals 404 text/plain: Not found no such file, a folder, a name that isn't plain, or a link that leads outside the folder 405 (empty) with Allow: GET, HEAD
HEAD /app/{path}
The headers of a file (Content-Type, Content-Length, ETag, Cache-Control) without its bytes.
Who Anyone
| Field | Where | Needed | What |
|---|---|---|---|
path | path | yes | The file, as for GET. Left empty, index.html. |
Answers 200, headers only
Refusals 404 text/plain: Not found 304 (empty) If-None-Match matched
GET /app/clear-site-data
Tells the browser to clear what this address keeps. The app's page asks for it as it signs out or is removed. Answered only to the page itself; anything else gets 404, as a file that isn't there.
Who The app's own page
| Field | Where | Needed | What |
|---|---|---|---|
Sec-Fetch-Site | header | yes | same-origin, as the browser sets it on the page's own fetch. |
Answers 204 (empty) with Clear-Site-Data: "storage" and Cache-Control: no-store
Refusals 404 text/plain: Not found any other Sec-Fetch-Site, or none
Running your own
The relay is one Dart program with no dependencies beyond Dart's own library. It listens over plain HTTP on this machine alone unless told otherwise, so on a server it sits behind a web server that holds the certificate.
dart run relay/bin/relay.dart [--host 127.0.0.1] [--port 8787] [--data relay-data] [--web <folder>] [--verbose]
| Flag | Default | Meaning |
|---|---|---|
--host <address> | 127.0.0.1 | Where to listen. |
--port <number> | $PORT, else 8787 | The port. |
--data <folder> | relay-data | Where everything it keeps is written. |
--web <folder> | $GHOST_WEB_DIR, else none | The folder flutter build web made, served under /app/. |
--verbose | off | Says when an install joins or leaves. Never an address, never a whole id. |
--help, -h | Prints the flags. |
Everything else is set in the environment. Each family is optional: a feature whose values are not set is off, and every limit has a default.
| Family | What it sets | Most useful |
|---|---|---|
GHOST_PUBLIC_URL | The relay's public address, used to build sign-in links and the networks' return addresses. | Default https://ghost-sms.com: set it to your own. |
GHOST_HUB_NAMES | The hosts the hub is reached at, commas between. With them the hub takes a sign-in bound to the host the app dialled. | Unset, the hub takes the older sign-in alone. See Signing in to the hub. |
GHOST_FED, GHOST_FED_*, GHOST_PUBLIC_HUB | Whether this relay links with other relays, with which, and how much it takes from each. | GHOST_FED (off, the default; open; list), GHOST_PUBLIC_HUB (this relay's own hub address, wss://relay.example.com/hub: without it no other relay's hello is taken), GHOST_FED_ALLOW and GHOST_FED_BLOCK (hosts or relay names), GHOST_FED_VIA, GHOST_FED_STANDING, GHOST_FED_PACKETS_A_MINUTE (1200), GHOST_FED_BYTES_A_DAY (512 MiB), GHOST_FED_LOOKUPS_AN_HOUR (600), GHOST_FED_PORTS, GHOST_FED_PLAIN. See Relays that talk to each other. |
GHOST_TURN_* | The media relay a call falls back on: a TURN server's shared secret and addresses. The hub hands a short-lived username and password to whoever joins a room. | GHOST_TURN_SECRET and GHOST_TURN_URLS (commas between; both, or calls are direct only), GHOST_TURN_TTL (seconds; 86400). |
GHOST_LINK_HELPERS | Servers that help two devices link directly, told to each app as it signs in. | Up to 4 https:// addresses, commas between, 200 characters each. |
GHOST_WIRE_* | What all WebSocket connections may hold in memory together, and when one is ended for it. | GHOST_WIRE_MB (64; 8 to 4096), GHOST_WIRE_EACH_MB (8; 1 to 1024), GHOST_WIRE_STALL_S (10; 2 to 600), GHOST_WIRE_IN_STALL_S (20; 2 to 600). |
GHOST_WEB_DIR, GHOST_APP_ORIGIN | The app in a browser: the folder served under /app/, and the one other address whose page may read the answers to feedback and reports. | GHOST_APP_ORIGIN is an origin as a browser names it: https://host, with a port where there is one. Anything else is left off, and said on stderr. |
GHOST_BOUNTY_KEY | The bounty key's public half: 33 bytes as 66 hex digits. | Unset, POST /bounty answers 404. |
GHOST_DISCORD_*, GHOST_X_*, GHOST_TELEGRAM_* | Each network's sign-in. | GHOST_DISCORD_ID and GHOST_DISCORD_SECRET; GHOST_X_ID (GHOST_X_SECRET optional); GHOST_TELEGRAM_BOT and GHOST_TELEGRAM_TOKEN. |
GHOST_TWILIO_*, GHOST_TEXT_TO, GHOST_TEXTS_A_DAY | Verifying a phone number by a texted code. | GHOST_TWILIO_SID, GHOST_TWILIO_TOKEN, GHOST_TWILIO_VERIFY (all three, or it is off); GHOST_TEXT_TO (number prefixes that may be texted, default +1); GHOST_TEXTS_A_DAY (200). |
GHOST_ADMIN_* | The admin page, and so who review is. | GHOST_ADMIN_USER, GHOST_ADMIN_HASH (empty: nobody can sign in), GHOST_ADMIN_NAMES (usernames that may). |
GHOST_APNS_* | Waking a closed iPhone. | GHOST_APNS_KEY_FILE, GHOST_APNS_KEY_ID, GHOST_APNS_TEAM_ID, GHOST_APNS_TOPIC. Without them tokens are kept and nothing is sent. |
GHOST_FILES_* | Files' limits. | GHOST_FILES_MAX_FILE, GHOST_FILES_SPACE_QUOTA, GHOST_FILES_TOTAL (300,000,000,000 bytes for all spaces), GHOST_FILES_IDLE_DAYS (90), GHOST_FILES_WRITES_PER_MINUTE (600), GHOST_FILES_MAX_BODY (8 MiB, at most 10). |
GHOST_NOTION_* | Feedback's board. | GHOST_NOTION_TOKEN and GHOST_NOTION_FEEDBACK. Both, or feedback answers 503. |
GHOST_MARKET_* | The Marketplace's switch, limits and review keys. | GHOST_MARKET_ON (1; 0 turns it off), GHOST_MARKET_REVIEW_KEYS (a comma list of review keys in base64; empty takes the signed-in admin's own key), GHOST_MARKET_NEED_VERIFIED (0), GHOST_MARKET_NAME_AGE_DAYS (7), GHOST_MARKET_MAX_PACKAGE (262144), GHOST_MARKET_TOTAL (1 GiB on disk), GHOST_MARKET_REPORTS_A_DAY (500: what installs with no verified number or linked account may report in a day, all together). |
A relay that links with others makes a key of its own the first time it starts, relay-key.json in the data folder, readable by its own user alone. Its name to other relays is made from that key: keep the file, and keep it private.
The full list of variables, with each one's least and most, is in the source: relay/lib/files.dart, relay/lib/market.dart, relay/lib/handles.dart, relay/lib/feedback.dart, relay/lib/pushes.dart, relay/lib/federation.dart, relay/lib/turn.dart, relay/lib/ws_door.dart and relay/bin/relay.dart.
Developer docs