TrustGraphSDK

API Reference

Client methods, inputs, outputs, and error behavior for the trust graph SDK.

API Reference

createTrustGraphSdk(options)

const client = createTrustGraphSdk({
  serverUrl: "https://trust.rebellion.systems",
  authToken: async () => authenseeJwt,
  fetch: customFetch,
});
OptionTypeDescription
serverUrlstringTrust graph service base URL. Trailing slashes are normalized.
authTokenstring | () => string | Promise<string>Optional bearer token or token provider.
fetchFetchLikeOptional fetch-compatible implementation.

Authenticated Methods

These methods send Authorization: Bearer <token> when a token is configured:

  • registerGraphKey(input, options?)
  • listMyGraphKeys(options?)
  • confirmEdge(edgeId, options?)
  • revokeEdge(edgeId, options?)

registerGraphKey

const key = await client.registerGraphKey({
  publicKeyJwk,
  label: "Work laptop",
  nodeKind: "human",
  authenseePersonaId: "per_123",
  providerPersonaId: "provider-persona-123",
  providerPersonaIdDerivative: "ppid_derivative_123",
  metadata: {
    displayName: "Alice",
  },
});

Returns GraphKey.

nodeKind is "human" or "agent" and defaults to "human". Persona fields are optional so providers can choose the least revealing stable identifier:

FieldDescription
authenseePersonaIdAuthenSee persona identifier when the caller is allowed to expose it to the graph service.
providerPersonaIdProvider-local persona ID, if the provider wants it queryable.
providerPersonaIdDerivativePreferred privacy-preserving provider-specific derivative.
metadataJSON object for display names, capabilities, app-local tags, or other non-secret metadata.

listMyGraphKeys

const keys = await client.listMyGraphKeys();

Returns GraphKey[].

confirmEdge

const confirmed = await client.confirmEdge(edgeId);

Returns { edge, graphEpochRoot, eventLogRoot }.

revokeEdge

const revoked = await client.revokeEdge(edgeId);

Returns { edge, graphEpochRoot, eventLogRoot }.

Public Methods

These methods deliberately do not send the configured bearer token:

  • requestEdge(input)
  • listEdges(query?)
  • getCurrentEpoch()
  • queryReachability(input)
  • verifyProof(input)

requestEdge

await client.requestEdge({
  signerGraphKeyId,
  subjectGraphKeyId,
  trust: 75,
  scope: "identity",
  createdAt,
  nonce,
  signature,
});

Returns { edge, graphEpochRoot, eventLogRoot }.

listEdges

await client.listEdges({ graphKeyId });

Returns every edge where graphKeyId is signer or subject. With no query, it returns all visible edges.

getCurrentEpoch

const roots = await client.getCurrentEpoch();

Returns { graphEpochRoot, eventLogRoot }.

queryReachability

const result = await client.queryReachability({
  sourceGraphKeyId,
  targetGraphKeyId,
  policy: {
    scope: "identity",
    minTrust: 50,
    maxHops: 3,
  },
});

Returns:

{
  reachable: boolean;
  pathLength: number | null;
  proof: ReachabilityProof | null;
}

verifyProof

const verification = await client.verifyProof(result.proof);

Returns { valid, warning }.

Errors

Non-2xx responses throw TrustGraphSdkError:

try {
  await client.confirmEdge(edgeId);
} catch (error) {
  if (error instanceof TrustGraphSdkError) {
    console.error(error.statusCode, error.code, error.details);
  }
}

The SDK maps both trust graph { error } responses and structured validation responses with { code, message, issues }.

On this page