TypeScript SDK authentication

import { DiligenceApiKeyCredential, createManagementClient, createProductClient } from '@diligenceid/sdk';

const credential = new DiligenceApiKeyCredential(process.env.DILIGENCE_API_KEY!);
const endpoint = 'https://api.example.diligence.id';

const management = createManagementClient(endpoint, credential);
const product = createProductClient(endpoint, credential);

Server-side only

Do not construct a credential in code that reaches a browser. A DiligenceID key is a long-lived server-side credential; anything shipped to a browser is readable by whoever is using it.

There is no browser-safe mode, and adding one would not make a long-lived key safe there.

Where the key comes from

Your secret store or environment. The credential does not read it for you, and it never writes it anywhere — no localStorage, no sessionStorage, no IndexedDB, no cookies, no files.

Assert the environment at startup

if (!credential.isSandbox) {
  throw new Error('Refusing to run integration tests against production.');
}

The key never reaches a log

toString() returns DiligenceApiKeyCredential(sandbox), and toJSON() returns the same — so JSON.stringify(config), which is how secrets most often reach logs, discloses nothing.

Edit this page on GitHub