IResolver.getDIDComponentById() method
This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Dereferences a DID URL fragment and returns the corresponding DID document entry.
Signature:
getDIDComponentById(args: GetDIDComponentArgs): Promise<DIDDocComponent>;
Parameters
Parameter | Type | Description |
---|---|---|
args | GetDIDComponentArgs | The description of the component you want. |
Returns:
Promise<DIDDocComponent>
a Promise
containing the or
Exceptions
not_found:...
in case the fragment is not displayed in the DID document
This API may change without a BREAKING CHANGE notice.
Example
const did = 'did:ethr:0xb09b66026ba5909a7cfe99b76875431d2b8d5190'
const didFragment = `${did}#controller`
const fragment = await agent.getDIDComponentById({
didDocument: (await agent.resolveDid({ didUrl: did }))?.didDocument,
didUrl: didFragment,
section: 'authentication',
})
expect(fragment).toEqual({
id: 'did:ethr:0xb09b66026ba5909a7cfe99b76875431d2b8d5190#controller',
type: 'EcdsaSecp256k1RecoveryMethod2020',
controller: 'did:ethr:0xb09b66026ba5909a7cfe99b76875431d2b8d5190',
blockchainAccountId: 'eip155:1:0xb09B66026bA5909A7CFE99b76875431D2b8D5190',
})