authra-sdk
v0.1.0
Published
The agent-facing SDK for [Authra](https://www.npmjs.com/package/authra-cli) — a non-custodial identity and authorization control plane for autonomous agents. Every action is authorized by an on-chain, EIP-712-signed delegation with real caveats (spend cap
Readme
authra-sdk
The agent-facing SDK for Authra — a non-custodial identity and authorization control plane for autonomous agents. Every action is authorized by an on-chain, EIP-712-signed delegation with real caveats (spend caps, allowed targets, expiry), not by a private key with unlimited scope. A call outside policy doesn't fail silently — it returns a structured denial naming the caveat that refused it.
Two sides:
- Issuing (
authra-sdk/issue) — create a workspace, issue a capped root delegation, hire sub-agents with narrower redelegated slices, revoke. - Redeeming (
@authra/sdk, theAuthraAgentclass) — an agent holding a delegation performs scoped, on-chain-enforced actions.
Install
npm i authra-sdkRedeem (the agent side)
import { AuthraAgent } from "authra-sdk";
const agent = new AuthraAgent({
sessionPrivateKey: "0x…", // this agent's own session key
permissionContext: "0x…", // the delegation chain it was issued
delegationManager: "0x…",
});
const result = await agent.transferErc20({ token: "0x…", to: "0x…", amount: 1_000_000n });
if (result.ok) {
console.log("allowed, tx:", result.txHash);
} else {
console.log("denied:", result.reason, result.failedCaveat);
}Issue (the hiring side)
import { signup, issueRootDelegation, hireAgent } from "authra-sdk/issue";
const org = await signup({ baseUrl, ownerPrivateKey });
const root = await issueRootDelegation({ baseUrl, apiKey: org.apiKey, ownerPrivateKey, policy });
const hired = await hireAgent({
baseUrl,
apiKey: org.apiKey,
parentDelegationId: root.delegationId,
parentSessionPrivateKey: root.sessionPrivateKey,
hiredAgentAddress,
policy: narrowerPolicy,
});See authra-cli for a full command-line reference —
every operation this SDK exposes, with real captured output.
