Postern for developers

Let people send passwords and files from their phone to your page

Add one button. Your users scan a QR code, type or paste on their phone, and the field fills, end-to-end encrypted. No app to install and no accounts. Works on websites, smart-TV web apps and anything that runs JavaScript, and through a plain REST API everywhere else.

Try it

Click From phone next to a field and scan the QR code with your phone.

Nothing received yet.

Using the public relay at postern.dahp.io, including through the npm package, is subject to the Terms of Use. If you add Postern to your product, section 5 of the Terms explains your responsibilities.

Install

npm install @dahp/postern

Or without a build step, from a CDN:

<script src="https://cdn.jsdelivr.net/npm/@dahp/postern@1/dist/postern.global.js"></script>

Add the button

Mark the fields, then attach. The button fills the field after the user checks the 4-digit code.

<input type="password" id="password" data-postern>

<script type="module">
  import { attachAll } from "@dahp/postern/ui";
  attachAll();
</script>

Or place the button yourself with the web component, which works in React, Vue, Svelte and plain HTML:

<input type="password" id="password">
<postern-button for="password"></postern-button>

To handle what arrives yourself (a file, for example), listen for the event and cancel the default fill:

button.addEventListener("postern-receive", (event) => {
  event.preventDefault();
  const { item, code } = event.detail; // item: { type, text } or { type: "file", name, mime, bytes }
});

Your own interface

open() shows the dialog and returns what the user confirmed. receive() has no interface at all, for TV apps, kiosks and custom designs: show session.link as a QR code and wait.

import { receive, drawQr } from "@dahp/postern";

const session = await receive({ types: ["password", "text"] });
drawQr(canvas, session.link);
const { item, code } = await session.result; // show code; use item once the user confirms
OptionWhat it doesDefault
serverRelay address, or your self-hosted relayhttps://postern.dahp.io
typesWhat the phone may send: password, text, url, fileAll; a password field asks for passwords and text
transportwebsocket, poll (plain HTTP) or autoauto
scannerOffline mode: pass startScanner from @dahp/postern/scannerOff
signalAn AbortSignal that cancels the sessionNone

Content-Security-Policy

If your site sets one, allow the relay:

connect-src https://postern.dahp.io wss://postern.dahp.io

The dialog needs no inline styles or scripts.

Other platforms: the REST API

Anything that can make HTTPS requests and do HPKE can receive: Android and Google TV (Tink), iOS and Apple TV (CryptoKit), servers, set-top boxes.

RequestWhoWhat it does
GET /api/s/{id} (WebSocket)ReceiverWaits for the message. Send ping every 20 s; the relay answers pong.
GET /api/s/{id}/waitReceiverLong polling: 200 with the message, 204 after 25 s (ask again), 410 expired or used
DELETE /api/s/{id}ReceiverCancels the session
POST /api/s/{id}PhoneBody {"v":1,"enc":"…","ct":"…"}. 200 delivered, 202 queued for a reconnecting receiver, 404 nobody waiting, 410 closed

The QR code holds https://postern.dahp.io/#v=1&id={session id}&k={public key}, optionally &t=password,text. Encryption is HPKE base mode with DHKEM(X25519, HKDF-SHA256), HKDF-SHA256 and AES-256-GCM, info dahp postern v1, associated data v1:{session id}. The full specification and test vectors are in the project's docs/PROTOCOL.md.

Self-host the relay

The relay only passes on ciphertext, but you can run your own. It's the same API and phone page:

docker build -t postern-relay .
docker run -p 8790:8790 postern-relay

Put it behind HTTPS and pass server: "https://postern.example.com".

The Dockerfile, the relay and everything else on this page are in the source repository (Apache-2.0). Security reports: see SECURITY.md there.

Security