@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/browserThe calls
enroll({ enroll, activate }, { timeoutMs? })→{ ak }. The two callbacks post each leg to your backend'srelayEnroll/relayActivate;enrollreturns the 201 body verbatim ({ challenge }), and nothing the server assigns comes back to the page. Keepak, the installation's attestation key blob.attest(challenge, { ak, timeoutMs? })→{ evidence }. Answers the relayedrhc1.string; anything else is aTypeError.mintKey(keyChallenge, { ak })→{ certification, key }. Answers the relayedrhk1c.string; keepkey, the new key's blob.sign(key, data)→{ alg, signature }.algisES256orRS256, from the key; base64url. No network.decrypt(envelope, { key })→{ plaintext }, aUint8Array. Opens the JWE your backend'sencryptToDeviceproduced, with the decrypt key's blob. No network. A sign key isInvalidArgumentError; an envelope that does not open isDecryptFailedError.setUp(relay, { purpose })→{ ak, key, verified }:enroll, thenattest, thenmintKeyon a pass, with your backend passing the verdict's alias into the key challenge'sexpectedDevices.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 withinstanceof.KeyUnloadableErrorforakmeans 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.