Skip to content

Latest commit

 

History

History

wellknown-did-verifier


Sphereon
Well-Known DID Verifier (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 verify relationships between the controller of an origin and a DID 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

  • registerSignatureValidation
  • removeSignatureValidation
  • verifyDomainLinkage
  • verifyDidConfigurationResource

Usage

Adding the plugin to an agent:

import { IWellKnownDidVerifier, WellKnownDidVerifier } from '@sphereon/ssi-sdk.wellknown-did-verifier'

const agent = createAgent<IWellKnownDidVerifier>({
  plugins: [
    new WellKnownDidVerifier({
      signatureVerifications: { verified: () => Promise.resolve({ verified: true }) },
      onlyVerifyServiceDids: true,
    }),
  ],
})

Register signature verification callback:

Registers a callback function to be called within the verification process, to verify the signature of the credentials within the DID configuration resource.

agent
  .registerSignatureVerification({
    callbackName: 'example_key',
    signatureVerification: () => Promise.resolve({ verified: true }),
  })
  .then(() => console.log('success'))
  .catch(() => console.log('failed'))

Remove signature verification callback:

Removes a registered callback function.

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

Verify domain linkage:

Verifies the relationship between the controller of an origin and a given DID. Option available to only verify the service DID.

agent
  .verifyDomainLinkage({
    did: 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM',
    signatureVerification: 'verified',
    onlyVerifyServiceDids: false,
  })
  .then((result: IDomainLinkageValidation) => console.log(result.status))

Verify DID configuration resource:

Verifies a DID configuration resource and domain linkage credentials it holds.

You can either pass in a DID configuration resource or fetch it remotely by setting a secure well-known location (origin). Option available to only verify a given DID.

agent
  .verifyDidConfigurationResource({
    signatureVerification: () => Promise.resolve({ verified: true }),
    origin: 'https://example.com',
    did: 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM#foo',
  })
  .then((result: IResourceValidation) => console.log(result.status))

Installation

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

Build

yarn build