@sphereon/ssi-sdk.wellknown-did-issuer
TypeScript icon, indicating that this package has built-in type declarations

0.30.1 • Public • Published


Sphereon
Well-Known DID Issuer (Typescript)


Warning: This package still is in very early development. Breaking changes without notice will happen at this point!


A Sphereon SSI-SDK plugin to create DID configuration resources and domain linkage credentials conforming to the DIF spec for well-known DID Configurations. It is written in Typescript and can be compiled to any target JavaScript version.

Available functions

  • addLinkedDomainsService
  • getDidConfigurationResource
  • issueDidConfigurationResource
  • issueDomainLinkageCredential
  • registerCredentialIssuance
  • removeCredentialIssuance
  • saveDidConfigurationResource

Usage

Adding the plugin to an agent:

import { IWellKnownDidIssuer, WellKnownDidIssuer } from '@sphereon/ssi-sdk.wellknown-did-issuer'

const agent = createAgent<IWellKnownDidIssuer>({
  plugins: [
    new WellKnownDidIssuer({
      credentialIssuances: { issueVc: () => Promise.resolve({ ...attestationCredential }) },
    }),
  ],
})

Register credential issuance callback:

Registers a callback function.

agent
  .registerCredentialIssuance({
    callbackName: 'example_key',
    credentialIssuance: () => Promise.resolve({ ...attestationCredential }),
  })
  .then(() => console.log('success'))
  .catch(() => console.log('failed'))

Remove credential issuance callback:

Removes a registered callback function.

agent
  .removeCredentialIssuance({ callbackName: 'example_key' })
  .then(() => console.log('success'))
  .catch(() => console.log('failed'))

Issue DID configuration resource:

Issues a DID configuration resource. Can optionally save it to a database using the save flag.

agent
  .issueDidConfigurationResource({
    issuances: [
      {
        did: DID,
        origin: ORIGIN,
        issuanceDate: new Date().toISOString(),
        expirationDate: new Date().toISOString(),
        options: { proofFormat: ProofFormatTypesEnum.JSON_WEB_TOKEN },
      },
    ],
    credentialIssuance: 'example_key',
    save: true,
  })
  .then((result: IDidConfiguration) => console.log(result))
  .catch(() => console.log('failed'))

Get DID configuration resource:

Get a DID configuration resource from the database.

agent
  .getDidConfigurationResource({
    origin: 'https://example.com',
  })
  .then((result: IDidConfiguration) => console.log(result))
  .catch(() => console.log('failed'))

Save DID configuration resource:

Saves a DID configuration resource to a database.

agent
  .saveDidConfigurationResource({
    origin: 'https://example.com',
    didConfiguration,
  })
  .then((result: IResourceValidation) => console.log(result.status))

Issue domain linkage credential:

Issues a domain linkage credential. Can optionally save it to a database using the save flag.

agent
  .issueDomainLinkageCredential({
    did: DID,
    origin: ORIGIN,
    issuanceDate: new Date().toISOString(),
    expirationDate: new Date().toISOString(),
    options: { proofFormat: ProofFormatTypesEnum.JSON_WEB_TOKEN },
    credentialIssuance: 'example_key',
    save: true,
  })
  .then((result: IResourceValidation) => console.log(result.status))

Add linked domains service:

Adds a LinkedDomains service to a DID.

agent
  .addLinkedDomainsService({
    did: 'did:key:example',
    origin: 'https://example.com',
    servideId: 'linkedDomains1',
  })
  .then((result: IResourceValidation) => console.log(result.status))

Installation

yarn add @sphereon/ssi-sdk.wellknown-did-issuer

Build

yarn build

Package Sidebar

Install

npm i @sphereon/ssi-sdk.wellknown-did-issuer

Weekly Downloads

1,630

Version

0.30.1

License

Apache-2.0

Unpacked Size

104 kB

Total Files

54

Last publish

Collaborators

  • nklomp78
  • nklomp
  • spostma
  • bramtencate