Skip to main content

Module serve

Module serve 

Source
Expand description

bynk registry serve and bynk registry token (packaging slice 4c, #2287, decisions A, D and E): a reference server that puts the publish API in front of a static registry directory.

It serves the directory’s files by GET and the API under /api:

  • PUT /api/<org>/<package>/<version> with a bynk-tree-v1 archive body admits the upload by the same rules as bynk registry add, signs its line with the server’s key, and answers 201 with the line (200 with the existing line when the same tree was already published, #2311);
  • POST /api/<org>/<package>/<version>/yank (or /unyank) flips yanked.

A request carries Authorization: Bearer <token>; the tokens file holds only each token’s sha256, the organisations it may act for, and what it can (publish, yank). Requests are handled one at a time, so writes to a registry are serialised. It speaks plain HTTP and binds loopback by default: put a TLS-terminating proxy in front to serve beyond this machine.

Constants§

DEFAULT_LISTEN
The default address: loopback only.

Functions§

mint
bynk registry token: mint a token for organisations that can the given actions, append its hash to tokens_file, and return the token — shown once, never stored.
serve
bynk registry serve: serve dir with the publish API, signing with key_file and authorising with tokens_file, on listen. ready is told the address actually bound, once listening. Runs until the process ends.