Reference · @hexaeight/sdk

Node.js SDK Reference

The Node SDK wraps the .NET Bridge with idiomatic JavaScript/TypeScript bindings. The full reference is being regenerated against Bridge preview9.

Status: Wrapper update against preview9 in progress. The underlying surface is identical to the .NET Bridge API — every method is exposed in camelCase, every Task<T> becomes a Promise<T>, and every record becomes a plain object.

Install

npm install @hexaeight/sdk@preview

Requires .NET 8+ on the host. The postinstall script detects and offers to install it.

Naming map

.NET BridgeNode SDK
new Client()await HexaEight.connect()
EncryptEnvelopeAsync(...)he.envelope.encrypt(...)
DecryptEnvelopeAsync(...)he.envelope.decrypt(...)
Client.InspectEnvelope(...) (static)HexaEight.inspectEnvelope(...)
FetchAskAsync(...)he.ask.fetch(...)
PinAsk(recipient, kgt, ask)he.ask.pin(recipient, kgt, ask)
PinAskForSession(sessionId, ask)he.ask.pinForSession(sessionId, ask)
UnpinAsk(recipient, kgt)he.ask.unpin(recipient, kgt)
UnpinAskForSession(sessionId)he.ask.unpinForSession(sessionId)
HasCachedAsk(recipient, kgt)he.ask.has(recipient, kgt)
HasCachedSession(sessionId)he.ask.hasSession(sessionId)
ClearAskCache()he.ask.clear()
SaveAskCacheToDiskAsync(path)he.ask.saveToDisk(path)
LoadAskCacheFromDiskAsync(path)he.ask.loadFromDisk(path)
EnableAutoPersistAsync(path, loadIfExists)he.ask.enableAutoPersist(path, { loadIfExists })
DisableAutoPersist()he.ask.disableAutoPersist()

Quick example (sessioned round-trip)

import { HexaEight } from '@hexaeight/sdk';

const alice = await HexaEight.connect();
const sessionId = crypto.randomUUID();
const kgt = currentKgt();

const ask = await alice.ask.fetch('bob.example.com', kgt);
alice.ask.pinForSession(sessionId, ask);

const env = await alice.envelope.encrypt('bob.example.com', 'hello', { sessionId });

// On Bob's side:
const bob = await HexaEight.connect();
const askB = await bob.ask.fetch('alice.example.com', kgt);
bob.ask.pinForSession(sessionId, askB);
const msg = await bob.envelope.decrypt(env);
console.log(msg.sender, msg.body);   // "alice.example.com" "hello"

See also