Artifact 0c2b8e556c21932ac8e754d02008439da3ab7e95da169dca7b96f41de6eec0b9:
- File docs/dev/share.md — part of check-in [96b8c7bfc2] at 2026-11-30 21:34:58 on branch share-origin-fix — Verify share --to matches configured publisher origin and fix network bash doc (user: dmestas, size: 2586) [annotate] [blame] [check-ins using]
/share to the artifact publisher
Status: built 2026-11-29 (ticket 16). Tier: bundled (src/share.c). Clock: vendor (the
publisher's HTTP API). Record: none; a share is a request the person confirmed, not a journal row.
Default: the publisher when a token is stored (or HTML_PUBLISHER_TOKEN is set) and artifactsUrl is set, else the gist.
src/share.c is called by the terminal interface's /share after the yes (share_run in
src/tui/app.c). pic_share_artifacts picks the destination from sessionShareDestination;
pic_share_publish does one POST {artifactsUrl}/api/artifacts over http.c and net.c, the
token in the Authorization: Bearer header and nowhere else, wiped after the call and scrubbed
from errors. The body is {title, message, user, files: {"index.html": base64}}; the reply's
viewerUrl is what the terminal shows.
A text file over 256 KB is a blob in the publisher: the page is first sent with
PUT /api/blobs/SHA256 (Content-Type: text/html) and the artifact's index.html is the pointer
file (artifact-blob 1, sha256, size, type), as the publisher's public/client.js does.
The token is a credential named artifacts, a key that serves no model: pic_model_keyname
(src/model.c) accepts it, as it does brave-search, so pic login artifacts and /login take
it and routing rules and imports refuse it. test/tui/share.sh runs the whole path against
fake_server; it never uses the real publisher or a real token.
pic share (the child /share runs) takes the page on stdin and sends nothing without a yes: a
prompt on /dev/tty, or --yes. The overlay shows the address from pic share --where and hands
that same address to the child as --to URL --yes, so a setting changed while it is open cannot
redirect the page. The child is given 30 seconds (run_piped in src/tui/app.c ends it after
that); the overlay's notice says it is sharing. pic_share_url_ok is the one check for an address
and for the viewer link: https://, or http:// to 127.0.0.1, localhost or [::1], printable ASCII
only. artifactsUrl falls back to HTML_PUBLISHER_URL.
--to URL verifies rather than overrides the configured publisher (artifactsUrl, else
HTML_PUBLISHER_URL): pic_share_publish checks that URL has the same origin (scheme, host,
and port via pic_webpush_origin) as the configured publisher before calling pic_cred_get, and
refuses if it differs or if no publisher is configured. So a model's bash call running pic share
--yes --to ... cannot redirect the stored artifacts token to another host.