Function getVerificationRelationshipsById

  • Retrieves a list of DID verification relationships by a specific method ID from a DID document.

    This function examines the specified DID document to identify any verification relationships (e.g., authentication, assertionMethod) that reference a verification method by its method ID or contain an embedded verification method matching the method ID. The method ID is typically a fragment of a DID (e.g., did:example:123#key-1) that uniquely identifies a verification method within the DID document.

    The search considers both direct references to verification methods by their IDs and verification methods embedded within the verification relationship arrays. It returns an array of DidVerificationRelationship enums corresponding to the verification relationships that contain the specified method ID.

    Parameters

    • params: {
          didDocument: DidDocument;
          methodId: string;
      }

      An object containing input parameters for retrieving verification relationships.

      • didDocument: DidDocument

        The DID document to search for verification relationships.

      • methodId: string

        The method ID to search for within the verification relationships.

    Returns DidVerificationRelationship[]

    An array of DidVerificationRelationship enums representing the types of verification relationships that reference the specified method ID.

    Example

    const didDocument: DidDocument = {
    // ...contents of a DID document...
    };

    const relationships = getVerificationRelationshipsById({
    didDocument,
    methodId: 'key-1'
    });
    console.log(relationships);
    // Output might include ['authentication', 'assertionMethod'] if those relationships
    // reference or contain the specified method ID.