Skip to main content

Exporting a KILT DID

The DID Document exporter provides the functionality needed to convert an instance of an SDK DidDocument object into a document that is compliant with the W3C specification. This component is required for the KILT plugin for the DIF Universal Resolver.

How to use the exporter

The exporter interface and used types are part of the @kiltprotocol/types package, while the actual DidDocumentExporter is part of the @kiltprotocol/did package. Both types and DID packages are accessible via the top-level @kiltprotocol/sdk-js import. The following shows how to use the exporter to generate a W3C-compliant DID Document from a given DidDocument, which can represent either a light or a full DID.

import * as Kilt from '@kiltprotocol/sdk-js'

export async function exportDid(
did: Kilt.DidDocument,
exportType: 'application/json' | 'application/ld+json'
) {
const conformingDidDocument = Kilt.Did.exportToDidDocument(did, exportType)

// Will print the DID URI.

// Will print all the public keys associated with the DID.

// Will print all the assertion keys IDs.

// Will print all the encryption keys IDs.

// Will print all the delegation keys IDs.

// Will print all the external services referenced inside the `DidDocument` instance.

return conformingDidDocument