IDAClient

View as Markdown

Constructor

1class IDAClient {
2 constructor(config: IDAClientConfig);
3}
4
5interface IDAClientConfig {
6 apiUrl: string; // Base URL, e.g. "https://adid.dev"
7 apiKey?: string; // JWT or API key (sent as `Authorization: Bearer …`)
8 timeout?: number; // Request timeout in ms; default 30 000
9}

Source: packages/sdk/src/index.ts:65-82, packages/sdk/src/types.ts:412-416.

Example

1import { IDAClient } from '@infinia/ida-sdk';
2
3const client = new IDAClient({
4 apiUrl: 'https://adid.dev',
5 apiKey: process.env.IDA_API_KEY!, // or a JWT obtained via /auth/verify-otp
6 timeout: 15_000,
7});

The apiUrl is normalised — trailing slashes are stripped (index.ts:76). All operations are routed through one of four sub-modules:

1client.didOps // private
2client.credentialOps // private
3client.agentOps // private
4client.zkpOps // private

…but the public surface is the flat method list on IDAClient itself (see following sections). You may prefer the sub-module style for tree-shaking; the SDK exposes them via type-level aliases (see §10.7 below for direct module imports).

Switching auth at runtime

The SDK does not currently support per-call header overrides; instantiate a second client if you need to switch identities mid-process:

1const adminClient = new IDAClient({ apiUrl, apiKey: ADMIN_KEY });
2const userClient = new IDAClient({ apiUrl, apiKey: jwtFromOtp });

Error handling

All failed HTTP calls throw IDAHTTPError (re-exported from http.ts):

1import { IDAClient } from '@infinia/ida-sdk';
2
3try {
4 await client.resolveDID('did:adi:does-not-exist');
5} catch (err) {
6 if (err instanceof Error && err.name === 'IDAHTTPError') {
7 // err.status, err.code (string), err.message
8 }
9}

The error wraps { status, code, message }. Wrapped error envelope unwrapping is automatic (http.ts:48-62).