Skip to navigation

IDAClient

View as Markdown

Constructor

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

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

Example

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

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

client.didOps // private
client.credentialOps // private
client.agentOps // private
client.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:

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

Error handling

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

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

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