Skip to content
SDKs · ClientIn developmentView source

@rootherald/browser

Client ABI 8.0. Drives the TPM through a bridge to your client application and returns opaque blobs. Holds no Root Herald key, holds no device identifier, sees no verdict. Your page keeps the blobs it returns.

In development

This SDK is implemented but not yet published to its package registry. Until it ships, collect an opaque evidence blob on the device and appraise it server-side with @rootherald/node (or any available server SDK). The API shown below is the planned surface and may change before release.

terminalbash
npm install @rootherald/browser

The calls

  • enroll({ enroll, activate }, { timeoutMs? }) → { ak }. The two callbacks post each leg to your backend's relayEnroll / relayActivate; enroll returns the 201 body verbatim ({ challenge }), and nothing the server assigns comes back to the page. Keep ak, the installation's attestation key blob.
  • attest(challenge, { ak, timeoutMs? }) → { evidence }. Answers the relayed rhc1. string; anything else is a TypeError.
  • mintKey(keyChallenge, { ak }) → { certification, key }. Answers the relayed rhk1c. string; keep key, the new key's blob.
  • sign(key, data) → { alg, signature }. alg is ES256 or RS256, from the key; base64url. No network.
  • decrypt(envelope, { key }) → { plaintext }, a Uint8Array. Opens the JWE your backend's encryptToDevice produced, with the decrypt key's blob. No network. A sign key is InvalidArgumentError; an envelope that does not open is DecryptFailedError.
  • setUp(relay, { purpose }) → { ak, key, verified }: enroll, then attest, then mintKey on a pass, with your backend passing the verdict's alias into the key challenge's expectedDevices.
  • getClientStatus() / getPosture() — readiness signals: bridge, OS support, app keys, the host's ABI and capabilities. Never a verdict.
  • Errors: ExtensionMissingError, HostMissingError, NotEnrolledError, AskUnsupportedError, KeyUnloadableError, InvalidArgumentError, DecryptFailedError, AbiMismatchError, NotAttestedError, TimeoutError. Check with instanceof. KeyUnloadableError for ak means discard it, enroll(), and retry once.

Example

signup.tsts
import { attest, enroll, KeyUnloadableError } from "@rootherald/browser";

const post = (url: string, body: unknown) =>
  fetch(url, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) })
    .then((r) => (r.ok ? r.json() : Promise.reject(new Error(String(r.status)))));

const relay = {
  enroll: (blob) => post("/api/enroll", { enrollRequestBlob: blob }),
  activate: (blob) => post("/api/activate", { activationResponse: blob }),
};

let ak = loadAk() ?? (await enroll(relay)).ak;
storeAk(ak);

const { nonce, challenge } = await post("/api/challenge", {});

let evidence;
try {
  ({ evidence } = await attest(challenge, { ak }));
} catch (err) {
  if (!(err instanceof KeyUnloadableError)) throw err;
  ({ ak } = await enroll(relay));
  storeAk(ak);
  ({ evidence } = await attest(challenge, { ak }));
}

await post("/api/signup", { nonce, evidence, ...form });   // your backend: rh.verify(evidence, { nonce })
Coming soon

Root Herald bridges are in development and coming soon: an extension and host your pages will be able to use directly, instead of building your own.