SDK reference

Client

new DidConnect(options) — key, project, base URL, timeouts and errors.

const dc = new DidConnect({
  apiKey: process.env.DIDCONNECT_API_KEY!,
  project: 'consumer',
  timeoutMs: 15_000,
});
OptionTypeDefault
apiKeystring—dc_test_… or dc_live_…
projectstringthe default projectSent as DidConnect-Project
baseUrlstringhttps://api.didconnect.xyz
timeoutMsnumber30000
fetchtypeof fetchglobal fetchFor tests or a custom agent

dc.withProject(slug) returns a client bound to another project.

Errors

Every answer outside 2xx throws a DidConnectError:

import { DidConnectError } from '@didconnect/sdk';

try {
  await dc.verify.sessions.decide(id, { decision: 'approved' });
} catch (err) {
  if (err instanceof DidConnectError && err.code === 'VERIFY_INVALID_TRANSITION') {
    // the session was decided meanwhile
  }
}
Property
statusHTTP status
code, type, paramFrom the envelope
requestIdQuote it to support

A network error or a timeout throws a DidConnectError with status 0 and code NETWORK_ERROR or TIMEOUT.

On this page