• Retrieves services from a given DID document, optionally filtered by id or type.

    If no id or type filters are provided, all defined services are returned.

    The given DID Document must adhere to the W3C DID Core Specification.

    Parameters

    • params: {
          didDocument: DidDocument;
          id?: string;
          type?: string;
      }

      An object containing input parameters for retrieving services.

      • didDocument: DidDocument

        The DID document from which services are retrieved.

      • Optional id?: string

        Optional. A string representing the specific service ID to match. If provided, only the service with this ID will be returned.

      • Optional type?: string

        Optional. A string representing the specific service type to match. If provided, only the service(s) of this type will be returned.

    Returns DidService[]

    An array of services. If no matching service is found, an empty array is returned.

    Example

    const didDocument = { ... }; // W3C DID document
    const services = getServices({ didDocument, type: 'DecentralizedWebNode' });