Skip to content

Commit

Permalink
docs: cleanup and refactoring in did-comm
Browse files Browse the repository at this point in the history
  • Loading branch information
mirceanis committed Jun 17, 2021
1 parent 19661ed commit 1e5b276
Show file tree
Hide file tree
Showing 11 changed files with 441 additions and 386 deletions.
31 changes: 16 additions & 15 deletions __tests__/shared/documentationExamples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ export default (testContext: {

//DO NOT EDIT MANUALLY START

it('core-IResolver-dereferenceDidUri example', async () => {
const did = 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190'
const didFragment = `${did}#controller`
const fragment = await agent.dereferenceDidUri({
didDocument: (await agent.resolveDid({ didUrl: did }))?.didDocument,
didURI: didFragment,
section: 'authentication',
})
expect(fragment).toEqual({
id: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190#controller',
type: 'EcdsaSecp256k1RecoveryMethod2020',
controller: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190',
blockchainAccountId: '0xb09B66026bA5909A7CFE99b76875431D2b8D5190@eip155:4',
})
})

it('core-IResolver-resolveDid example', async () => {
const doc = await agent.resolveDid({
didUrl: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190',
Expand All @@ -46,21 +62,6 @@ export default (testContext: {
})
})

it('core-IResolver-resolveDidFragment example', async () => {
const did = 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190'
const didFragment = `${did}#controller`
const fragment = await agent.resolveDidFragment({
didURI: didFragment,
didDocument: (await agent.resolveDid({ didUrl: did }))?.didDocument,
})
expect(fragment).toEqual({
id: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190#controller',
type: 'EcdsaSecp256k1RecoveryMethod2020',
controller: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190',
blockchainAccountId: '0xb09B66026bA5909A7CFE99b76875431D2b8D5190@eip155:4',
})
})

it('core-IDIDManager-didManagerCreate example', async () => {
const identifier = await agent.didManagerCreate({
alias: 'alice',
Expand Down
9 changes: 5 additions & 4 deletions packages/core/src/types/IResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,16 @@ export interface IResolver extends IPluginMethodMap {
resolveDid(args: ResolveDidArgs): Promise<DIDResolutionResult>

/**
* Resolves DID URI and returns the corresponding fragment
* Dereference a DID URI fragment and return the corresponding DID document entry.
*
* @example
* ```typescript
* const did = 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190'
* const didFragment = `${did}#controller`
* const fragment = await agent.resolveDidFragment({
* const fragment = await agent.dereferenceDidUri({
* didDocument: (await agent.resolveDid({didUrl: did}))?.didDocument,
* didURI: didFragment,
* didDocument: (await agent.resolveDid({didUrl: did}))?.didDocument
* section: 'authentication'
* })
* expect(fragment).toEqual({
* id: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190#controller',
Expand All @@ -97,7 +98,7 @@ export interface IResolver extends IPluginMethodMap {
*
* @beta
*/
resolveDidFragment(args: {
dereferenceDidUri(args: {
/**
* the DID document from which to extract the fragment. This MUST be the document resolved by {@link resolveDid}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ let agent = {
execute: jest.fn(),
availableMethods: jest.fn(),
resolveDid: jest.fn(),
resolveDidFragment: jest.fn(),
dereferenceDidUri: jest.fn(),
emit: jest.fn(),
keyManagerSign: jest.fn().mockImplementation(async (args): Promise<string> => 'mockJWT'),
dataStoreSaveVerifiableCredential: jest.fn().mockImplementation(async (args): Promise<boolean> => true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('@veramo/credential-w3c', () => {
}
}
},
resolveDidFragment: jest.fn()
dereferenceDidUri: jest.fn()
}
}

Expand Down
Loading

0 comments on commit 1e5b276

Please sign in to comment.