The object to be checked.
true
if obj
is a DwnDidService; otherwise, false
.
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');
}
Checks if a given object is a DwnDidService.
A DwnDidService is defined as DidService object with a
type
of "DecentralizedWebNode" andenc
andsig
properties, where both properties are either strings or arrays of strings.