@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/nodeThe calls
new RootHeraldClient({ secretKey, baseUrl? })—baseUrldefaults tohttps://rootherald.io; only https or loopback is accepted.relayEnroll(enrollRequestBlob)→{ challenge }, the 201 body to hand to the device'sEnrollCompleteverbatim;relayActivate(activationResponse)→{ deviceId, status, enrolledAt }.deviceIdis your per-tenant id, the same value asdevice.ueid; it stays on your backend.issueChallenge({ ask?, expectedKey?, expectedDevices? })→{ nonce, challenge, expiresAt }.nonceis your handle for the challenge;challengeis relayed to the device verbatim.verify(evidence, { nonce, requestedDisclosureClass?, expectedKey?, expectedDevices? })→ verdict plusassuranceClaimsMet,enrollmentRequired,expected?. Pass the sameexpectedKey/expectedDevicesas the challenge: a verdict that does not echo them is refused with codeEXPECTED_NOT_ENFORCED.issueKeyChallenge({ purpose, expectedDevices? })→{ nonce, keyChallenge, expiresAt };certifyKey(nonce, certification)→{ deviceId, keyId, purpose, alg, format?, jwk, hardwareBound, certifiedAt }.purposeissignordecrypt;formatis on a decrypt key.verifyKeySignature(jwk, message, signature)→boolean. ES256 or RS256, by the JWK's type, with Nodecrypto; rawr||s, DER or PKCS#1 v1.5; never throws.encryptToDevice(key, plaintext)→ the JWE compact serialization as a string.keyis thecertifyKeyresult for a decrypt key;plaintextis bytes or a UTF-8 string. ECDH-ES for an EC key, RSA-OAEP-256 for an RSA key, A256GCM for both, with Nodecryptoand no Root Herald call. A sign key isSignKeyError, a macOSapple-ecieskey isAppleEciesKeyError; both extendEncryptToDeviceError.- Errors:
InvalidSecretKeyError,ChallengeError,InvalidEvidenceError,InvalidAskError,UnknownPolicyError,AdmissionRefusedError,QuotaExceededError,ActivationRefusedError,RateLimitedError;expected_unknown,key_disclosure_too_lowandkey_rotation_conflictarrive as aRootHeraldApiErrorwitherrorCodeset. A failing device is a verdict, not an error. Each is an error code in the API reference.