Links and recipients
What a link is made of, what sees which part of it, and when a link can be opened again or is used up.
The link
Its form
For each recipient, the sender's browser creates a link of the form https://fidant.se/r/<link ID>#<secret>. The link ID is 16 random bytes and the secret 32 random bytes, both from the browser's cryptographic random number generator.
What sees which part
The link ID only names the link: our server uses it to pair the sender with the recipient, and the CDN sees it in the address of the recipient's page. The secret is in the fragment, the part after #, which browsers don't send to servers when they open the address. The site also tells browsers not to send the page address on to other sites. The app never sends the secret anywhere, unless you click “Post in #channel” on a page opened from one of our Slack commands, which sends the link to Slack. Otherwise it only derives keys from the secret and keeps the receive page's first address, secret included, in memory. That lets the "Go back to it" bar return you to an unfinished transfer. The link in that bar carries only the path; following it puts the secret back in the address bar.
One per recipient
Every recipient gets their own link ID and secret, so one recipient's link says nothing about another's.
Several recipients and one-time links
Up to 256 people
One send can go to up to 256 people. Each has their own link, key, connection and transfer.
When a link is used up
A link counts as used only once the recipient's RECEIPT matches. After that it is refused. A link that is already connected in one tab is refused in another, and so is a link that has had 10 connection attempts in the current 30-second window. A recipient's page that asks again after a dropped route counts as an attempt, but keeps its connection if it is refused.
Opening it again
Until then the link can be opened again: after a decline, a dropped connection or a failed check. After a dropped connection, Try again in the same tab continues a file's download where it stopped if it can. Every new attempt has a new transfer ID and attempt ID, and so a new file key. A link with the safety number on stops working after 5 attempts that ended before both people confirmed the number. An attempt the sender's page stopped because the two pages run different versions doesn't count.
While the sender's page is open
The file or shared secret isn't stored along the way, so a link works only while the sender's page is open. When it closes, our server forgets its links within a minute.
Asking for a file
The Ask for a file page turns the link around. The recipient's page makes a request link of the form https://fidant.se/a/<link ID>#<public key> and waits on it, and whoever has the link, such as a CI job, sends a file or a secret to it, with fidant --answer or from the send page's Answer a request link field.
The page makes a key pair of its own, whose private key the browser won't let it read out. The part after # is only the public key, so the request link holds no secret. The sender makes its own key pair and sends its public key to the page through our server, unencrypted, before any other setup message. Each side then works out the same secret from its own private key and the other's public key, with ECDH and HKDF-SHA-256, and from there the transfer runs as with any link. Our server passes the sender's public key on, but can't work out the secret from the two public keys.
Our server holds the page's request until a sender connects to the link, with no time limit, while the page's connection is open. Meanwhile it keeps the link ID, a random attempt ID and how many pages wait from that IP address, and it logs one line that a page waits, with the first 6 characters of the link ID. The request lives only in the tab: closing or reloading it ends the request, and so does the browser putting the tab to sleep in the background.
The page answers the first sender that connects without asking you, so that sender learns your IP addresses from the connection setup, and that the page is open, whoever it is. Anyone who can read the request link can connect first and send you a file of their own. Download and Show still need your click.
From then on the page pairs only with that sender's key. Another key gets no answer, and the page says another sender answered. If the job that sends you the file ran again, with a new key, Wait for a new sender lets it in.
A sender shows a fingerprint of its key, 22 characters long: fidant --answer prints it, and the send page shows it on the request's card. Paste it into the page, and the page says whether the sender it is connected to is that job. While it doesn't match, or only part of it is there, Download and Show stay off. Without the fingerprint, a hostile server, or someone who read the request link, could take the job's place unseen. Even then they couldn't read the job's file, because the job's secret depends on both public keys.
The name the sender gives itself isn't verified. Once the file or secret has arrived, the page stops waiting, and the request link no longer works.