Skip to content
SDKs · ServerAvailableView source

@rootherald/node

Node 18+, built-in fetch, no dependencies. Holds the rh_sk_ key and does every Root Herald call. Wire 8.0 from 0.1.0-alpha.20.

terminalbash
npm install @rootherald/node

The calls

  • new RootHeraldClient({ secretKey, baseUrl? }) — baseUrl defaults to https://rootherald.io; only https or loopback is accepted.
  • relayEnroll(enrollRequestBlob) → { challenge }, the 201 body to hand to the device's EnrollComplete verbatim; relayActivate(activationResponse) → { deviceId, status, enrolledAt }. deviceId is your per-tenant id, the same value as device.ueid; it stays on your backend.
  • issueChallenge({ ask?, expectedKey?, expectedDevices? }) → { nonce, challenge, expiresAt }. nonce is your handle for the challenge; challenge is relayed to the device verbatim.
  • verify(evidence, { nonce, requestedDisclosureClass?, expectedKey?, expectedDevices? }) → verdict plus assuranceClaimsMet, enrollmentRequired, expected?. Pass the same expectedKey / expectedDevices as the challenge: a verdict that does not echo them is refused with code EXPECTED_NOT_ENFORCED.
  • issueKeyChallenge({ purpose, expectedDevices? }) → { nonce, keyChallenge, expiresAt }; certifyKey(nonce, certification) → { deviceId, keyId, purpose, alg, format?, jwk, hardwareBound, certifiedAt }. purpose is sign or decrypt; format is on a decrypt key.
  • verifyKeySignature(jwk, message, signature) → boolean. ES256 or RS256, by the JWK's type, with Node crypto; raw r||s, DER or PKCS#1 v1.5; never throws.
  • encryptToDevice(key, plaintext) → the JWE compact serialization as a string. key is the certifyKey result for a decrypt key; plaintext is bytes or a UTF-8 string. ECDH-ES for an EC key, RSA-OAEP-256 for an RSA key, A256GCM for both, with Node crypto and no Root Herald call. A sign key is SignKeyError, a macOS apple-ecies key is AppleEciesKeyError; both extend EncryptToDeviceError.
  • Errors: InvalidSecretKeyError, ChallengeError, InvalidEvidenceError, InvalidAskError, UnknownPolicyError, AdmissionRefusedError, QuotaExceededError, ActivationRefusedError, RateLimitedError; expected_unknown, key_disclosure_too_low and key_rotation_conflict arrive as a RootHeraldApiError with errorCode set. A failing device is a verdict, not an error. Each is an error code in the API reference.