Skip to content

Commit

Permalink
Merge 5a5f52c into faa7940
Browse files Browse the repository at this point in the history
  • Loading branch information
mirceanis authored Mar 26, 2021
2 parents faa7940 + 5a5f52c commit d2fea68
Show file tree
Hide file tree
Showing 36 changed files with 884 additions and 387 deletions.
10 changes: 1 addition & 9 deletions __tests__/localAgent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,7 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
}),
new DIDResolverPlugin({
resolver: new Resolver({
...ethrDidResolver({
networks: [
{ name: 'mainnet', rpcUrl: 'https://mainnet.infura.io/v3/' + infuraProjectId },
{ name: 'rinkeby', rpcUrl: 'https://rinkeby.infura.io/v3/' + infuraProjectId },
{ name: 'ropsten', rpcUrl: 'https://ropsten.infura.io/v3/' + infuraProjectId },
{ name: 'kovan', rpcUrl: 'https://kovan.infura.io/v3/' + infuraProjectId },
{ name: 'goerli', rpcUrl: 'https://goerli.infura.io/v3/' + infuraProjectId },
],
}),
...ethrDidResolver({ infuraProjectId }),
...webDidResolver(),
}),
}),
Expand Down
12 changes: 2 additions & 10 deletions __tests__/restAgent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,8 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
}),
new DIDResolverPlugin({
resolver: new Resolver({
ethr: ethrDidResolver({
networks: [
{ name: 'mainnet', rpcUrl: 'https://mainnet.infura.io/v3/' + infuraProjectId },
{ name: 'rinkeby', rpcUrl: 'https://rinkeby.infura.io/v3/' + infuraProjectId },
{ name: 'ropsten', rpcUrl: 'https://ropsten.infura.io/v3/' + infuraProjectId },
{ name: 'kovan', rpcUrl: 'https://kovan.infura.io/v3/' + infuraProjectId },
{ name: 'goerli', rpcUrl: 'https://goerli.infura.io/v3/' + infuraProjectId },
],
}).ethr,
web: webDidResolver().web,
...ethrDidResolver({ infuraProjectId }),
...webDidResolver(),
}),
}),
new DataStore(dbConnection),
Expand Down
21 changes: 9 additions & 12 deletions __tests__/shared/documentationExamples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,21 @@ export default (testContext: {
const doc = await agent.resolveDid({
didUrl: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190',
})

expect(doc).toEqual({
'@context': 'https://w3id.org/did/v1',
expect(doc.didDocument).toEqual({
'@context': [
'https://www.w3.org/ns/did/v1',
'https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld',
],
id: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190',
publicKey: [
verificationMethod: [
{
id: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190#controller',
type: 'Secp256k1VerificationKey2018',
type: 'EcdsaSecp256k1RecoveryMethod2020',
controller: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190',
ethereumAddress: '0xb09b66026ba5909a7cfe99b76875431d2b8d5190',
},
],
authentication: [
{
type: 'Secp256k1SignatureAuthentication2018',
publicKey: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190#controller',
blockchainAccountId: '0xb09B66026bA5909A7CFE99b76875431D2b8D5190@eip155:4',
},
],
authentication: ['did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190#controller'],
})
})

Expand Down
4 changes: 1 addition & 3 deletions __tests__/shared/keyManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,7 @@ export default (testContext: {
data: 'test',
})

expect(signature).toHaveProperty('r')
expect(signature).toHaveProperty('s')
expect(signature).toHaveProperty('recoveryParam')
expect(signature).toBeDefined()
})

it('should sign EthTX', async () => {
Expand Down
33 changes: 24 additions & 9 deletions __tests__/shared/resolveDid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,38 @@ export default (testContext: {

it('should resolve didUrl', async () => {
const didUrl = 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190'
const didDoc = await agent.resolveDid({ didUrl })
expect(didDoc.id).toEqual(didUrl)
const didDoc = (await agent.resolveDid({ didUrl })).didDocument
expect(didDoc?.id).toEqual(didUrl)
})

it('should throw an error for unsupported did methods', async () => {
await expect(agent.resolveDid({ didUrl: 'did:foo:bar' })).rejects.toThrow(
"Unsupported DID method: 'foo'",
)
it('should return an error for unsupported did methods', async () => {
expect.assertions(1)
await expect(agent.resolveDid({ didUrl: 'did:foo:bar' })).resolves.toEqual({
didDocument: null,
didResolutionMetadata: { error: 'unsupportedDidMethod' },
didDocumentMetadata: {},
})
})

it('should throw error when resolving garbage', async () => {
//@ts-ignore
await expect(agent.resolveDid()).rejects.toHaveProperty('name', 'Error')
await expect(agent.resolveDid()).resolves.toEqual({
didDocument: null,
didDocumentMetadata: {},
didResolutionMetadata: { error: 'invalidDid' },
})
//@ts-ignore
await expect(agent.resolveDid({})).rejects.toHaveProperty('name', 'Error')
await expect(agent.resolveDid({})).resolves.toEqual({
didDocument: null,
didDocumentMetadata: {},
didResolutionMetadata: { error: 'invalidDid' },
})
//@ts-ignore
await expect(agent.resolveDid({ didUrl: 1 })).rejects.toThrow()
await expect(agent.resolveDid({ didUrl: "garbage" })).resolves.toEqual({
didDocument: null,
didDocumentMetadata: {},
didResolutionMetadata: { error: 'invalidDid' },
})
})
})

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@types/jest": "26.0.20",
"codecov": "3.8.1",
"cross-fetch": "3.0.6",
"husky": "5.0.9",
"husky": "5.1.3",
"jest": "26.6.3",
"jest-fetch-mock": "3.0.3",
"json-schema": "0.3.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/default/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ didResolver:
$ref: /ethr-did-resolver
web:
$ref: /web-did-resolver
io:
key:
$ref: /universal-resolver
elem:
$ref: /universal-resolver
key:
io:
$ref: /universal-resolver
ion:
$ref: /universal-resolver
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
"cross-fetch": "^3.0.6",
"date-fns": "^2.8.1",
"debug": "^4.1.1",
"did-resolver": "^2.1.2",
"did-resolver": "3.1.0",
"dotenv": "^8.2.0",
"ethr-did-resolver": "^3.0.2",
"ethr-did-resolver": "4.0.1",
"express": "^4.17.1",
"express-handlebars": "^5.2.0",
"fuzzy": "^0.1.3",
Expand All @@ -64,7 +64,7 @@
"ts-json-schema-generator": "^0.84.0",
"typeorm": "0.2.30",
"url-parse": "^1.4.7",
"web-did-resolver": "^1.3.5",
"web-did-resolver": "2.0.4",
"ws": "^7.2.0",
"yaml": "^1.10.0"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
},
"dependencies": {
"debug": "^4.1.1",
"did-jwt-vc": "^1.0.3",
"did-jwt-vc": "2.0.2",
"events": "^3.0.0",
"z-schema": "^5.0.0"
},
"devDependencies": {
"@types/debug": "4.1.5",
"did-resolver": "2.1.2",
"did-resolver": "3.1.0",
"typescript": "4.1.3"
},
"files": [
Expand Down
Loading

0 comments on commit d2fea68

Please sign in to comment.