Skip to content
undertext developers
Skip to Content
undertext developers

Set up check-ins

Let your users add security keys and check in while they write, so their seals can show Verified Presence.

A check-in is a tap on a security key while someone writes. It shows that a person with the key was there when asked, which is the one signal on a seal that neither an agent nor your own server can produce. When check-ins vouch for every sitting anyone wrote in, the seal's presence ring turns electric blue, shows a shield, and reads Verified Presence.

By the end of this guide, your users can add a key from your own settings page, and turn Verified Presence on in the documents that need it.

Check-ins are optional, and each person turns them on a document at a time: Verified Presence is a switch of their own in each document, off until they turn it on. A message needs none; a take-home exam might ask for them.

Why the settings are Undertext's

Security keys are tied to the website that registered them. For a key to vouch for writing recorded by Undertext, it has to be registered on Undertext's own domain, not yours. So adding keys happens in Undertext's presence settings, served from embed.undertext.sh: framed in your own settings page, or in a small window your page opens. Everything else about check-ins happens inside the editor, or through your own controls for it.

Add presence settings to your app

  1. Add a presence session route. It's like the editor's session route, with purpose: "presence" instead of a document.

    server.ts
    app.post("/undertext/presence-session", requireSignIn, async (req, res) => {
      // undertextUserId: the helper from Embed the editor.
      const session = await undertext.sessions.create({ user: await undertextUserId(req.user), purpose: "presence" });
      res.json({ token: session.token });
    });
  2. Show them in your settings page. Frame them where your settings are, with your platform's slug:

    settings.ts
    import { mountPresenceSettings } from "@undertext/embed";
    
    mountPresenceSettings(document.querySelector("#presence")!, {
      getToken: async () => (await (await fetch("/undertext/presence-session", { method: "POST" })).json()).token,
      platform: "acme",
    }, ({ keys }) => {
      presenceLabel.textContent = keys ? `${keys} key${keys === 1 ? "" : "s"}` : "No key yet";
    });

    Or open them in a window of their own, which browsers that won't create a key in a frame need:

    settings.ts
    import { openPresenceSettings } from "@undertext/embed";
    
    document.querySelector("#presence-settings").addEventListener("click", () => {
      openPresenceSettings({
        getToken: async () => {
          const response = await fetch("/undertext/presence-session", { method: "POST" });
          return (await response.json()).token;
        },
      });
    });

    Call it from a click: browsers only let a page open a window in answer to one.

  3. Let people add keys. People add, order and remove keys, and try a check-in (recorded nowhere). Framed, your callback hears each change; in the window, openPresenceSettings resolves with how many keys they have once they close it.

    const { keys } = await openPresenceSettings({ getToken });
    presenceLabel.textContent = keys ? `${keys} key${keys === 1 ? "" : "s"}` : "No key yet";

To know whether someone has a key without opening the window, ask your server:

const { security_keys } = await undertext.users.retrieveCheckins("usr_5Kq2Lm8R");

Turn Verified Presence on in a document

People turn Verified Presence on or off in each document from the editor's breakdown. If your page has its own menu for the document, add a switch there: the editor's status event says whether it's on, null for someone who can't write in the document, and setVerifiedPresence turns it on or off.

document.ts
editor.on("status", ({ verifiedPresence }) => {
  presenceSwitch.hidden = !verifiedPresence;
  presenceSwitch.checked = verifiedPresence?.on ?? false;
  presenceSwitch.disabled = verifiedPresence?.required ?? false;
});
presenceSwitch.addEventListener("change", async () => {
  presenceSwitch.checked = await editor.setVerifiedPresence(presenceSwitch.checked);
});

Turning it on needs a key. Without one it stays off and the editor sends a presence-settings event: open presence settings for them, as you do when a check-in or the breakdown asks for them. It turns on once they come back to the editor with a key.

editor.on("presence-settings", () => openPresenceSettings({ getToken: presenceToken }));

Your server can turn it on too, for example for every person writing a take-home exam who already has a key:

await undertext.documents.updateCheckins("doc_8Hq2Lm4R", "usr_5Kq2Lm8R", { enabled: true });

Without a key, it answers 409 no_security_keys.

Require it, or choose how often

A take-home exam can't leave Verified Presence to each writer. Require it of everyone writing in your documents, and choose how often check-ins come, in the console's Check-ins section or with the API:

await undertext.platform.update({ checkins_required: true, checkin_minutes: 5 });

Required, it's on for everyone, whatever their switch said, and no one can turn it off: the editor's status says verifiedPresence.required, and setVerifiedPresence(false) leaves it on, so show your switch as on and locked. Someone without a key is asked all the same; the card offers to add one, and the editor sends presence-settings. Until they add one, their check-ins go unanswered and their writing unverified.

checkin_minutes is 1, 5, 10 or 30. Shorter asks more often, and each check-in vouches for less writing: about one and a half intervals. A seal's breakdown says how often its check-ins came, so readers can tell.

To let your people choose how often, list the intervals they may pick from in checkin_choices. checkin_minutes stays the default, and is always among them:

await undertext.platform.update({ checkin_minutes: 5, checkin_choices: [5, 10, 30] });

Each person then picks one in presence settings, for all their documents. Leave checkin_choices empty, as it is unless you set it, and everyone is asked at checkin_minutes.

Which keys work

Undertext sorts each key when it's added:

  • Hardware keys, such as a YubiKey or Windows Hello on a TPM, prove the model they are. These count fully.
  • Built-in authenticators that can't prove their model, such as Touch ID through iCloud Keychain or Google Password Manager, are accepted as they are.
  • Password managers and unknown software are refused, because the key could be anywhere.

The kind is kept with each check-in, so a reader of the seal's breakdown can see which keys vouched.

What people see while writing

Nothing changes until a check-in is due, and none is asked in a document where Verified Presence isn't on. Undertext asks on someone's first edit there after half an hour away from writing, then about every 5 minutes (or as often as you chose), at random times between half and one and a half intervals apart. A small card beside the seal asks for a tap. Reading, pointing and clicking never ask; writing, and accepting or rejecting suggestions, do.

A tap within a minute passes. No tap is recorded as missed. Nothing stops writing either way: a miss only means the writing that follows it isn't verified, until the next check-in passes.

How check-ins show on seals

The seal's inner ring is presence: the share of the session with a person there, writing or reading as they write. The part vouched for by check-ins is drawn in electric blue.

  • When every sitting anyone wrote in was verified, the ring is blue all round, the shield shows, and the seal line ends (verified).
  • When only some were, the line says how much, such as (98% verified).
  • Someone who doesn't check in only goes unverified. Nothing counts against them.

The seal object carries the same numbers, so your app can show them:

const seal = await undertext.seals.retrieve("66G4LF343");
seal.presence; // { share: 99, verified_share: 98, verified: false }

See Presence and check-ins for exactly what counts as verified.

Next

  • Seal and verify: what readers see on a sealed document.
  • Trust model: why check-ins are the signal your own server can't produce.
  • Embed API for every option of mountPresenceSettings and openPresenceSettings.

On this page