Invite a collaborator
Peerborne’s initial invitation flow lets a document founder invite one active collaborator with a separate signing identity. The founder and recipient must both be online and reachable through a Circuit Relay while the invitation is accepted. Application-level signing must remain enabled on both nodes.
Invitations require the bundled Automerge provider, ACL and keychain
providers, and JSON serializers with SubtleCrypto. A Yjs or Loro document
cannot create or accept one, and no other path admits a new identity, so in
the default document mode a Yjs or Loro document has only its founder.
The offer is a bearer capability. It contains public metadata, not a document key, but anyone who obtains it can claim its reader or editor role first. Send it through a channel you trust and keep it out of server logs and analytics. There is no selective cancellation API in the initial release: use a short lifetime for a link you may need to abandon. Closing the founder document or stopping its node makes every outstanding offer unavailable, but also disrupts the active session.
Founder
Section titled “Founder”Install a P-256 ECDH key pair with a non-extractable private key before creating
the offer. generateEciesKeyPair() returns an exportable public half so
Peerborne can encode its raw point. The rendezvous address must end at the
founder through the relay, not at the relay itself.
import { encodeInvitationOffer, generateEciesKeyPair,} from '@peerborne/core';
const founderKem = await generateEciesKeyPair();
const note = peerborne.doc('/notes/launch-plan');await note.create();// The initial invitation path intentionally shares the retained document// history, so this choice must be explicit.note.historyVisibility = 'full_history';await note.setKemKeyPair(founderKem);
// Supply the relay's complete, peer-ID-qualified multiaddr from deployment// configuration, connect, and advertise only a reservation the node reports.const relayMultiaddr = '/dns4/relay.peerborne.io/tcp/443/wss/p2p/REPLACE_WITH_RELAY_PEER_ID';await peerborne.connect([relayMultiaddr]);
async function waitForCircuitAddress(timeoutMs = 30_000): Promise<string> { const suffix = `/p2p-circuit/p2p/${peerborne.peerId}`; const deadline = Date.now() + timeoutMs; while (Date.now() < deadline) { const address = peerborne.libp2p .getMultiaddrs() .map((value) => value.toString()) .find((value) => value.includes('/p2p-circuit/') && value.endsWith(suffix), ); if (address) return address; await new Promise((resolve) => setTimeout(resolve, 250)); } throw new Error('Circuit Relay reservation was not observed');}
const founderCircuitAddress = await waitForCircuitAddress();
const offer = await note.createInvitation({ role: 'editor', rendezvous: [founderCircuitAddress], expiresInMs: 15 * 60 * 1000, // Record the new member before the acceptance releases the document key. // saveCheckpoint is the application's local store; storageKey is its // non-extractable AES-GCM key. beforeAcceptance: async () => saveCheckpoint(await note.exportEncryptedCheckpoint(storageKey)),});
const offerBytes = encodeInvitationOffer(offer);// Encode offerBytes as unpadded Base64url in a URL fragment or QR code.Every offer requires beforeAcceptance. It runs after the recipient’s
membership is committed in the founder document and before the acceptance that
carries the document key is signed. Store a checkpoint there, encrypted as
exportEncryptedCheckpoint() returns it: it holds the document keys, so never
send it to another party. If the founder
stops after the recipient has the key but before a checkpoint records it, a
founder restored from an earlier checkpoint has no record of the collaborator
and cannot remove it, while the collaborator keeps reading every later founder
edit. Peerborne cannot store the checkpoint for the application.
The recipient then catches up from the founder. If the founder document
changed after beforeAcceptance last ran, the founder runs it again before it
answers, so every change the recipient receives outside a published frame is
in a stored checkpoint. Otherwise a founder that edited during the acceptance
and then restored its checkpoint would lack an edit the recipient shows, and a
reader cannot return a change it did not receive as a frame. The founder
waits up to 10 seconds for this run before it answers. A rejection or timeout
declines the catch-up, and acceptInvitation() rejects; calling it again with
the same offer from the same recipient process retries the catch-up until the
offer expires. Only the founder process that produced the acceptance answers
its catch-up, until 60 seconds after the offer expires. The callback can
therefore run more than once per invitation, so it should only store a
checkpoint.
beforeAcceptance must settle within 10 seconds and before the offer expires.
A rejection or timeout withholds the acceptance. The recipient’s retry from the
same process runs it again and can complete the committed membership until the
offer expires. If no acceptance was produced by then, the founder removes the
claimant and frees the slot.
The default lifetime is 15 minutes, the minimum is 60 seconds, and the maximum
is seven days. The founder must keep the same Peerborne process, open
document, signing identity, and KEM state alive until acceptance completes.
Each rendezvous attempt has a 30-second deadline; stale addresses are aborted
so the next signed address can be tried. The final founder catch-up stream has
the same deadline. Up to eight addresses are tried sequentially, and the
initial release does not expose caller-driven cancellation.
Offers use absolute wall-clock timestamps. Keep founder and recipient device clocks reasonably synchronized: verifiers tolerate an issuer timestamp up to 60 seconds in the future, but there is no clock-skew grace after the signed expiry.
Recipient
Section titled “Recipient”Decode the fragment back to the exact bytes and accept it with the recipient’s own signing identity and a fresh or safely persisted P-256 KEM key pair:
const recipientKem = await generateEciesKeyPair();
const note = await peerborne.acceptInvitation(offerBytes, recipientKem);
await note.change((draft) => { draft.title = 'Shared launch plan';}, 'Edit note');acceptInvitation() verifies the offer signature and expiry, signs a
recipient/KEM-bound join request, verifies the founder’s acceptance, opens the
sealed BeeKEM Welcome, authenticates the encrypted document bootstrap, checks
the resulting ACL, requires every advertised bootstrap change to be present,
subscribes, and performs an issuer-signed catch-up load with the same
advertised-change completeness check before returning. It never falls back to
creating a new document when any step fails.
An editor is added as both reader and writer. A reader can decrypt and
follow updates but cannot publish document changes.
addReader() is not an onboarding path. A recipient that has only installed
a KEM key pair cannot authenticate a broadcast Welcome or decrypt the reader
ACL row that admits it, so it could never open the document. addReader
rejects an identity that is not already a reader before changing any state.
Removing and inviting again
Section titled “Removing and inviting again”To remove an editor, demote it and then revoke its read access. Both calls run on the founder:
await note.removeWriter(editorSigningPublicKey);await note.removeReader(editorSigningPublicKey);
const replacement = await note.createInvitation({ role: 'reader', rendezvous: [founderCircuitAddress], beforeAcceptance: async () => saveCheckpoint(await note.exportEncryptedCheckpoint(storageKey)),});removeReader() rotates the document key, so the removed member cannot read
anything written after it. Once the founder has no remaining collaborator, it
can invite a replacement into a fresh founder-plus-one BeeKEM tree. Every
offer created before a completed removeReader() becomes unavailable, so a
link that was never claimed, or a retry by the removed member, cannot take the
freed slot. The removed member keeps whatever it already received.
Trust and recovery boundaries
Section titled “Trust and recovery boundaries”- The offer exposes its document ID, issuer identity, role, timestamps, and rendezvous addresses. URL fragments avoid ordinary HTTP request logs, but browser history, extensions, screenshots, and the person receiving the link can still reveal it.
- The signature proves that one signing key created the offer; it does not give that key a human identity. Verify the issuer fingerprint or deliver the link through an already authenticated channel when that distinction matters.
- Initial-release invitations require
historyVisibility = 'full_history'. The recipient can receive the retained CRDT operation history, including operations for values later changed or deleted.current_onlyandsince_invitedfilter epoch keys but are not safe historical-content confidentiality boundaries, so the invitation API rejects them. - One active collaborator per document is enforced in the initial release. Add-side BeeKEM updates for larger groups are not implemented. The bounded invitation path supports the first collaborator, exact retries for that identity, and a replacement after the founder removes that collaborator.
- Only the founder that created the document, in its original process or
restored from its own checkpoint, can issue an initial-release offer, and
only while it has no collaborator. Founder and recipient signing identities
must be distinct, and a
readeracceptance is rejected if its bootstrap grants writer access. - A founder that stops during acceptance and restores a checkpoint from before
it has no record of the new collaborator unless
beforeAcceptancestored a newer checkpoint. A commitment pin does not close that window. - A founder that restarts while an unsent acceptance is pending loses the
timer that would remove its claimant at expiry. If its checkpoint recorded
the claimant, remove it with
removeWriter()andremoveReader(). - Offers and replay protection are in memory. An inviter restart invalidates
outstanding links. A lost response can be retried only from the same
recipient
Peerborneprocess, which reuses the exact signed request. The founder uses the signed request fields as its identity. Signing those same fields again returns the original acceptance. Unit tests cover the request cache. Browser coverage of a dropped-response retry is still pending. - Membership onboarding is not transactional. Once a valid signed request begins mutation, a later ACL publication, Welcome sealing, signing, encryption, stream, or expiry failure can leave partial or complete founder- side membership without returning a usable acceptance. Isolated coordinator and exact-retry membership suites cover the intended retry path, but it is not yet proven as one end-to-end dropped-response scenario. A different request or process restart cannot use that path. Offer expiry remains strict, so work that completes after expiry cannot produce a usable acceptance.
- Peerborne does not persist signing or KEM key pairs. The application must protect and restore them without logging or exporting private material into an invitation.
- The bundled Automerge JSON CRDT, ACL, and keychain adapters plus SubtleCrypto declare the tested initial-release capacity profile: P-384 ECDSA with SHA-384 and AES-GCM. Other provider combinations fail before membership changes unless they deliberately attest the same bounds; a custom provider that does so is responsible for preserving every size and algorithm invariant in that profile.
- Each sealed Welcome and encrypted bootstrap is limited to 1 MiB. Before changing membership, Peerborne conservatively sizes one combined bootstrap projection containing the retained sync tree, complete keychain, latest snapshot, served tips, signature, founder-plus-one ACL growth, encryption framing, and a 128 KiB reserve. The sealed Welcome is projected separately, and both exact encrypted fields are checked again after construction. Large retained histories or snapshots need a different bootstrap or chunking design; there is no streaming fallback.
- Delivery, reconnect, revocation after restart, relay failover, and offline acceptance are not guaranteed. See Limitations before using this flow for sensitive or durable data.