• Checks if a given object is a DwnDidService.

    A DwnDidService is defined as DidService object with a type of "DecentralizedWebNode" and enc and sig properties, where both properties are either strings or arrays of strings.

    Parameters

    • obj: unknown

      The object to be checked.

    Returns obj is DwnDidService

    true if obj is a DwnDidService; otherwise, false.

    Example

    const didDocument: DidDocument = {
    id: 'did:example:123',
    verificationMethod: [
    {
    id: 'did:example:123#key-1',
    type: 'JsonWebKey2020',
    controller: 'did:example:123',
    publicKeyJwk: { ... }
    },
    {
    id: 'did:example:123#key-2',
    type: 'JsonWebKey2020',
    controller: 'did:example:123',
    publicKeyJwk: { ... }
    }
    ],
    service: [
    {
    id: 'did:example:123#dwn',
    type: 'DecentralizedWebNode',
    serviceEndpoint: 'https://dwn.tbddev.org/dwn0',
    enc: 'did:example:123#key-1',
    sig: 'did:example:123#key-2'
    }
    ]
    };

    if (isDwnService(didDocument.service[0])) {
    console.log('The object is a DwnDidService');
    } else {
    console.log('The object is not a DwnDidService');
    }

    See

    Decentralized Web Node (DWN) Specification