@alphea/foundation
v0.1.3
Published
Credential-bearing Foundation RPC SDK for trusted ALPHEA tooling
Readme
@alphea/foundation
Credential-bearing Foundation RPC SDK for trusted ALPHEA tooling and server code.
It serves as the credential-bearing public proto RPC mirror layer, while browser and function facades remain narrower. It provides safe typed low-level mirror access for public Foundation RPCs, as well as ergonomic facades for auth, storage, and functions.
Use this package only where the caller is allowed to provide a Foundation bearer/session through the configured transport:
import { createAlpheaFoundationClient } from "@alphea/foundation";
// Use an ergonomic facade:
await alphea.storage.read("wallet://0xabc", "/notes.md");
// Or use the low-level typed mirror call surface for other RPCs:
const response = await alphea.rpc("Monitor.GetStats", {});
for await (const event of alphea.rpcStream("Monitor.StreamStats", {})) {
console.log(event);
}
async function* nodeMessages() {
yield { hello: { node_id: "node_1" } };
}
for await (const message of alphea.rpcBidiStream("Node.ConnectNode", nodeMessages())) {
console.log(message);
}The built-in fetch transport frames streams with Connect JSON over fetch and
duplex: "half". That supports server-streaming calls and finite bidirectional
request streams. Production Node.ConnectNode workers that keep heartbeats open
while concurrently receiving assignments need an injected full-duplex Connect or
gRPC transport.
Do not inject this package into browser app code or user-authored function code.
