Skip to content

Latest commit

 

History

History
76 lines (57 loc) · 2.36 KB

README.md

File metadata and controls

76 lines (57 loc) · 2.36 KB

Decentralized Identifiers

CI CD

TypeScript implementations of did core and related utilities.

These modules are agnostic to DID Methods.

Usage with Verifiable Credentials

import { factory, DidDocument } from '@did-core/data-model';
import { representation } from '@did-core/did-ld-json';

const didDocument: DidDocument = factory.build({
  entries: {
    '@context': 'https://www.w3.org/ns/did/v1',
    id: 'did:example:123',
  },
});

const representation: Buffer = await didDocument
  .addRepresentation({ 'application/did+ld+json': representation })
  .produce('application/did+ld+json');

Usage with JOSE

import { factory, DidDocument } from '@did-core/data-model';
import { representation } from '@did-core/did-json';

const didDocument: DidDocument = factory.build({
  entries: {
    // @context is required for use with jsonld verifiable credentials
    // but technically optional here
    '@context': 'https://www.w3.org/ns/did/v1',
    id: 'did:example:123',
  },
});

const representation: Buffer = await didDocument
  .addRepresentation({ 'application/did+json': representation })
  .produce('application/did+json');

Usage with IPLD

import { factory, DidDocument } from '@did-core/data-model';
import { representation } from '@did-core/did-dag-cbor';

const didDocument: DidDocument = factory.build({
  entries: {
    // @context is required for use with jsonld verifiable credentials
    // but technically optional here
    '@context': 'https://www.w3.org/ns/did/v1',
    id: 'did:example:123',
  },
});

const representation: Buffer = await didDocument
  .addRepresentation({ 'application/did+dag+cbor': representation })
  .produce('application/did+dag+cbor');

DID Test Suite

This module is used to produce test fixtures for the did core test suite.

The DID Method implementations used for these tests are hosted in the following repos: