did-resolver

  • Version 6.0.0
  • Published
  • 74.5 kB
  • No dependencies
  • Apache-2.0 license

Install

npm i did-resolver
yarn add did-resolver
pnpm add did-resolver

Overview

Resolve DID documents

Index

Variables

variable VerificationRelationship

const VerificationRelationship: {
readonly authentication: 'authentication';
readonly assertionMethod: 'assertionMethod';
readonly keyAgreement: 'keyAgreement';
readonly capabilityInvocation: 'capabilityInvocation';
readonly capabilityDelegation: 'capabilityDelegation';
};

Functions

function inMemoryCache

inMemoryCache: () => DIDCache;

    function noCache

    noCache: (
    parsed: ParsedDID,
    resolve: WrappedResolver
    ) => Promise<DIDResolutionResult>;

      function parse

      parse: (didUrl: string) => ParsedDID | null;
      • Parses a DID URL strictly according to the DID Core v1.0 specification ABNF (§3.1 DID Syntax, §3.2 DID URL Syntax). Unlike parse, this method does not accept legacy DID parameters (;key=value) and enforces the RFC 3986 character sets for path, query, and fragment components.

        Parameter didUrl

        the DID URL string to be parsed

        Returns

        a ParsedDID object, or null if the input does not conform to the spec

      function wrapLegacyResolver

      wrapLegacyResolver: (resolve: LegacyDIDResolver) => DIDResolver;

        Classes

        class Resolver

        class Resolver implements Resolvable {}
        • This implementation of Resolvable bundles together multiple implementations of DIDResolver and presents a single function call to users.

        constructor

        constructor(registry?: ResolverRegistry, options?: ResolverOptions);

          method resolve

          resolve: (
          didUrl: string,
          options?: DIDResolutionOptions
          ) => Promise<DIDResolutionResult>;

            Interfaces

            interface ConditionWeightedThreshold

            interface ConditionWeightedThreshold {}

              property condition

              condition: VerificationMethod;

                property weight

                weight: number;

                  interface DIDDocumentMetadata

                  interface DIDDocumentMetadata extends Extensible {}

                  property canonicalId

                  canonicalId?: string;

                    property created

                    created?: string;

                      property deactivated

                      deactivated?: boolean;

                        property equivalentId

                        equivalentId?: string | string[];

                          property nextUpdate

                          nextUpdate?: string;

                            property nextVersionId

                            nextVersionId?: string;

                              property updated

                              updated?: string;

                                property versionId

                                versionId?: string;

                                  interface DIDResolutionMetadata

                                  interface DIDResolutionMetadata extends Extensible {}

                                  property contentType

                                  contentType?: string;

                                    property error

                                    error?:
                                    | 'invalidDid'
                                    | 'notFound'
                                    | 'representationNotSupported'
                                    | 'unsupportedDidMethod'
                                    | (string & {});

                                      interface DIDResolutionOptions

                                      interface DIDResolutionOptions extends Extensible {}

                                      property accept

                                      accept?: string;

                                        property cache

                                        cache?: boolean;

                                          interface DIDResolutionResult

                                          interface DIDResolutionResult {}

                                          property '@context'

                                          '@context'?:
                                          | 'https://w3id.org/did-resolution/v1'
                                          | ContextEntry
                                          | ContextEntry[];

                                            property didDocument

                                            didDocument: DIDDocument | null;

                                              property didDocumentMetadata

                                              didDocumentMetadata: DIDDocumentMetadata;

                                                property didResolutionMetadata

                                                didResolutionMetadata: DIDResolutionMetadata;

                                                  interface DIDResolver

                                                  interface DIDResolver {}
                                                  • The DID resolution function that DID Resolver implementations must implement. Can optionally have a .parser property for method-specific DID validation.

                                                  property parser

                                                  parser?: DIDParser;

                                                    call signature

                                                    (
                                                    did: string,
                                                    parsed: ParsedDID,
                                                    resolver: Resolvable,
                                                    options: DIDResolutionOptions
                                                    ): Promise<DIDResolutionResult>;

                                                      interface JsonWebKey

                                                      interface JsonWebKey extends Extensible {}
                                                      • Encapsulates a JSON web key type that includes only the public properties that can be used in DID documents.

                                                        The private properties are intentionally omitted to discourage the use (and accidental disclosure) of private keys in DID documents.

                                                        See Also

                                                      property alg

                                                      alg?: string;

                                                        property crv

                                                        crv?: string;

                                                          property e

                                                          e?: string;

                                                            property ext

                                                            ext?: boolean;

                                                              property key_ops

                                                              key_ops?: string[];

                                                                property kid

                                                                kid?: string;

                                                                  property kty

                                                                  kty: string;

                                                                    property n

                                                                    n?: string;

                                                                      property use

                                                                      use?: string;

                                                                        property x

                                                                        x?: string;

                                                                          property y

                                                                          y?: string;

                                                                            interface LegacyResolverRegistry

                                                                            interface LegacyResolverRegistry {}

                                                                              index signature

                                                                              [index: string]: LegacyDIDResolver;

                                                                                interface Params

                                                                                interface Params {}
                                                                                • URI params resulting from parsing a DID URI

                                                                                index signature

                                                                                [index: string]: string;

                                                                                  interface ParsedDID

                                                                                  interface ParsedDID {}
                                                                                  • An object containing the results of parsing a DID URI string.

                                                                                    This is forwarded to implementations of particular DID resolvers when calling the resolve method.

                                                                                    See Also

                                                                                  property did

                                                                                  did: string;

                                                                                    property didUrl

                                                                                    didUrl: string;

                                                                                      property fragment

                                                                                      fragment?: string;

                                                                                        property id

                                                                                        id: string;

                                                                                          property method

                                                                                          method: string;

                                                                                            property path

                                                                                            path?: string;

                                                                                              property query

                                                                                              query?: string;

                                                                                                interface Resolvable

                                                                                                interface Resolvable {}
                                                                                                • The method signature implemented by this resolver.

                                                                                                property resolve

                                                                                                resolve: (
                                                                                                didUrl: string,
                                                                                                options?: DIDResolutionOptions
                                                                                                ) => Promise<DIDResolutionResult>;

                                                                                                  interface ResolverOptions

                                                                                                  interface ResolverOptions {}

                                                                                                    property cache

                                                                                                    cache?: DIDCache | boolean | undefined;

                                                                                                      property legacyResolvers

                                                                                                      legacyResolvers?: LegacyResolverRegistry;

                                                                                                        interface Service

                                                                                                        interface Service {}

                                                                                                        property id

                                                                                                        id: string;

                                                                                                          property serviceEndpoint

                                                                                                          serviceEndpoint: ServiceEndpoint | ServiceEndpoint[];

                                                                                                            property type

                                                                                                            type: string;

                                                                                                              index signature

                                                                                                              [x: string]: any;

                                                                                                                interface VerificationMethod

                                                                                                                interface VerificationMethod {}

                                                                                                                property blockchainAccountId

                                                                                                                blockchainAccountId?: string;

                                                                                                                  property conditionAnd

                                                                                                                  conditionAnd?: VerificationMethod[];

                                                                                                                    property conditionDelegated

                                                                                                                    conditionDelegated?: string;

                                                                                                                      property conditionOr

                                                                                                                      conditionOr?: VerificationMethod[];

                                                                                                                        property conditionThreshold

                                                                                                                        conditionThreshold?: VerificationMethod[];

                                                                                                                          property conditionWeightedThreshold

                                                                                                                          conditionWeightedThreshold?: ConditionWeightedThreshold[];

                                                                                                                            property controller

                                                                                                                            controller: string;

                                                                                                                              property ethereumAddress

                                                                                                                              ethereumAddress?: string;
                                                                                                                              • Deprecated

                                                                                                                              property id

                                                                                                                              id: string;

                                                                                                                                property publicKeyBase58

                                                                                                                                publicKeyBase58?: string;
                                                                                                                                • Deprecated

                                                                                                                                property publicKeyBase64

                                                                                                                                publicKeyBase64?: string;
                                                                                                                                • Deprecated

                                                                                                                                property publicKeyHex

                                                                                                                                publicKeyHex?: string;
                                                                                                                                • Deprecated

                                                                                                                                property publicKeyJwk

                                                                                                                                publicKeyJwk?: JsonWebKey;

                                                                                                                                  property publicKeyMultibase

                                                                                                                                  publicKeyMultibase?: string;

                                                                                                                                    property publicKeyPem

                                                                                                                                    publicKeyPem?: string;
                                                                                                                                    • Deprecated

                                                                                                                                    property relationshipChild

                                                                                                                                    relationshipChild?: string[];

                                                                                                                                      property relationshipParent

                                                                                                                                      relationshipParent?: string[];

                                                                                                                                        property relationshipSibling

                                                                                                                                        relationshipSibling?: string[];

                                                                                                                                          property threshold

                                                                                                                                          threshold?: number;

                                                                                                                                            property type

                                                                                                                                            type: string;

                                                                                                                                              Type Aliases

                                                                                                                                              type ContextEntry

                                                                                                                                              type ContextEntry = (string & {}) | Extensible;
                                                                                                                                              • Defines a JSON-LD context entry.

                                                                                                                                              type DIDCache

                                                                                                                                              type DIDCache = (
                                                                                                                                              parsed: ParsedDID,
                                                                                                                                              resolve: WrappedResolver,
                                                                                                                                              options?: DIDResolutionOptions
                                                                                                                                              ) => Promise<DIDResolutionResult>;

                                                                                                                                                type DIDDocument

                                                                                                                                                type DIDDocument = {
                                                                                                                                                '@context'?: 'https://www.w3.org/ns/did/v1' | ContextEntry | ContextEntry[];
                                                                                                                                                id: string;
                                                                                                                                                alsoKnownAs?: string[];
                                                                                                                                                controller?: string | string[];
                                                                                                                                                verificationMethod?: VerificationMethod[];
                                                                                                                                                service?: Service[];
                                                                                                                                                /**
                                                                                                                                                * @deprecated
                                                                                                                                                */
                                                                                                                                                publicKey?: VerificationMethod[];
                                                                                                                                                } & {
                                                                                                                                                [x in VerificationRelationship]?: (string | VerificationMethod)[];
                                                                                                                                                };

                                                                                                                                                type DIDParser

                                                                                                                                                type DIDParser = (parsed: ParsedDID) => ParsedDID | null;
                                                                                                                                                • Optional parser function that can be attached to a DIDResolver to provide method-specific validation of the ParsedDID before resolution.

                                                                                                                                                type Extensible

                                                                                                                                                type Extensible = Record<string, any>;
                                                                                                                                                • Defines an object type that can be extended with other properties.

                                                                                                                                                type KeyCapabilitySection

                                                                                                                                                type KeyCapabilitySection = VerificationRelationship;
                                                                                                                                                • Backwards-compatibility alias

                                                                                                                                                type LegacyDIDResolver

                                                                                                                                                type LegacyDIDResolver = (
                                                                                                                                                did: string,
                                                                                                                                                parsed: ParsedDID,
                                                                                                                                                resolver: Resolvable
                                                                                                                                                ) => Promise<DIDDocument>;

                                                                                                                                                  type ResolverRegistry

                                                                                                                                                  type ResolverRegistry = Record<string, DIDResolver>;

                                                                                                                                                    type ServiceEndpoint

                                                                                                                                                    type ServiceEndpoint = string | Record<string, any>;

                                                                                                                                                    type VerificationRelationship

                                                                                                                                                    type VerificationRelationship = keyof typeof VerificationRelationship;

                                                                                                                                                      type WrappedResolver

                                                                                                                                                      type WrappedResolver = () => Promise<DIDResolutionResult>;

                                                                                                                                                        Package Files (1)

                                                                                                                                                        Dependencies (0)

                                                                                                                                                        No dependencies.

                                                                                                                                                        Dev Dependencies (12)

                                                                                                                                                        Peer Dependencies (0)

                                                                                                                                                        No peer dependencies.

                                                                                                                                                        Badge

                                                                                                                                                        To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                        You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/did-resolver.

                                                                                                                                                        • Markdown
                                                                                                                                                          [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/did-resolver)
                                                                                                                                                        • HTML
                                                                                                                                                          <a href="https://www.jsdocs.io/package/did-resolver"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>