diff --git a/__tests__/localAgent.test.ts b/__tests__/localAgent.test.ts index 46265063f..705af118c 100644 --- a/__tests__/localAgent.test.ts +++ b/__tests__/localAgent.test.ts @@ -32,6 +32,9 @@ import { DataStore, DataStoreORM, } from '../packages/daf-typeorm/src' +import { Resolver } from 'did-resolver' +import { getResolver as ethrDidResolver } from 'ethr-did-resolver' +import { getResolver as webDidResolver } from 'web-did-resolver' import fs from 'fs' jest.setTimeout(30000) @@ -118,7 +121,20 @@ const setup = async (options?: IAgentOptions): Promise => { }), }, }), - new DafResolver({ infuraProjectId }), + new DafResolver({ + 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 + }) + }), new DataStore(dbConnection), new DataStoreORM(dbConnection), new MessageHandler({ diff --git a/__tests__/restAgent.test.ts b/__tests__/restAgent.test.ts index 43bc5972e..d1d0381a3 100644 --- a/__tests__/restAgent.test.ts +++ b/__tests__/restAgent.test.ts @@ -38,6 +38,9 @@ import { AgentRestClient } from '../packages/daf-rest/src' import express from 'express' import { Server } from 'http' import { AgentRouter } from '../packages/daf-express/src' +import { Resolver } from 'did-resolver' +import { getResolver as ethrDidResolver } from 'ethr-did-resolver' +import { getResolver as webDidResolver } from 'web-did-resolver' import fs from 'fs' jest.setTimeout(30000) @@ -125,7 +128,20 @@ const setup = async (options?: IAgentOptions): Promise => { }), }, }), - new DafResolver({ infuraProjectId }), + new DafResolver({ + 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 + }) + }), new DataStore(dbConnection), new DataStoreORM(dbConnection), new MessageHandler({ @@ -151,7 +167,7 @@ const setup = async (options?: IAgentOptions): Promise => { const app = express() app.use(basePath, agentRouter) restServer = app.listen(port, () => { - resolve() + resolve(true) }) }) } diff --git a/packages/daf-cli/default/default.yml b/packages/daf-cli/default/default.yml index 3dbff3a04..77277b757 100644 --- a/packages/daf-cli/default/default.yml +++ b/packages/daf-cli/default/default.yml @@ -25,6 +25,7 @@ server: constants: secretKey: 29739248cad1bd1a0fc4d9b75cd4d2990de535baf5caadfdf8d8f86664aa830c databaseFile: ./database.sqlite + dbConnection: $require: typeorm?t=function#createConnection $args: @@ -35,6 +36,7 @@ dbConnection: logging: false entities: $require: daf-typeorm?t=object#Entities + messageHandler: $require: daf-message-handler#MessageHandler $args: @@ -43,6 +45,43 @@ messageHandler: - $require: daf-did-jwt#JwtMessageHandler - $require: daf-w3c#W3cMessageHandler - $require: daf-selective-disclosure#SdrMessageHandler + +ethr-did-resolver: + $require: ethr-did-resolver?t=function&p=/ethr#getResolver + $args: + - networks: + - name: mainnet + rpcUrl: https://mainnet.infura.io/v3/5ffc47f65c4042ce847ef66a3fa70d4c + - name: rinkeby + rpcUrl: https://rinkeby.infura.io/v3/5ffc47f65c4042ce847ef66a3fa70d4c + - name: ropsten + rpcUrl: https://ropsten.infura.io/v3/5ffc47f65c4042ce847ef66a3fa70d4c + - name: kovan + rpcUrl: https://kovan.infura.io/v3/5ffc47f65c4042ce847ef66a3fa70d4c + - name: goerli + rpcUrl: https://goerli.infura.io/v3/5ffc47f65c4042ce847ef66a3fa70d4c + - name: private + rpcUrl: http://localhost:8545/ + registry: '0x05cc574b19a3c11308f761b3d7263bd8608bc532' + +web-did-resolver: + $require: web-did-resolver?t=function&p=/web#getResolver + +universal-resolver: + $require: daf-resolver#UniversalResolver + $args: + - url: https://dev.uniresolver.io/1.0/identifiers/ + +resolver: + $require: did-resolver#Resolver + $args: + - ethr: + $ref: /ethr-did-resolver + web: + $ref: /web-did-resolver + io: + $ref: /universal-resolver + agent: $require: daf-core#Agent $args: @@ -120,23 +159,8 @@ agent: - defaultKms: local - $require: daf-resolver#DafResolver $args: - - networks: - - name: mainnet - rpcUrl: https://mainnet.infura.io/v3/5ffc47f65c4042ce847ef66a3fa70d4c - - name: rinkeby - rpcUrl: https://rinkeby.infura.io/v3/5ffc47f65c4042ce847ef66a3fa70d4c - - name: ropsten - rpcUrl: https://ropsten.infura.io/v3/5ffc47f65c4042ce847ef66a3fa70d4c - - name: kovan - rpcUrl: https://kovan.infura.io/v3/5ffc47f65c4042ce847ef66a3fa70d4c - - name: goerli - rpcUrl: https://goerli.infura.io/v3/5ffc47f65c4042ce847ef66a3fa70d4c - - name: private - rpcUrl: http://localhost:8545/ - registry: '0x05cc574b19a3c11308f761b3d7263bd8608bc532' - # - $require: daf-resolver-universal#DafUniversalResolver - # $args: - # - url: https://dev.uniresolver.io/1.0/identifiers/ + - resolver: + $ref: /resolver - $require: daf-typeorm#DataStore $args: - $ref: /dbConnection diff --git a/packages/daf-cli/package.json b/packages/daf-cli/package.json index 0a3f2ac67..821a97e6c 100644 --- a/packages/daf-cli/package.json +++ b/packages/daf-cli/package.json @@ -10,7 +10,7 @@ "scripts": { "build": "tsc", "watch": "tsc -b --watch", - "update-daf-beta": "yarn add daf-core@beta daf-resolver@beta daf-did-jwt@beta daf-w3c@beta daf-ethr-did@beta daf-web-did@beta daf-did-comm@beta daf-libsodium@beta daf-selective-disclosure@beta daf-typeorm@beta daf-key-manager@beta daf-message-handler@beta daf-identity-manager@beta daf-resolver-universal@beta daf-url@beta" + "update-daf-beta": "yarn add daf-core@beta daf-resolver@beta daf-did-jwt@beta daf-w3c@beta daf-ethr-did@beta daf-web-did@beta daf-did-comm@beta daf-libsodium@beta daf-selective-disclosure@beta daf-typeorm@beta daf-key-manager@beta daf-message-handler@beta daf-identity-manager@beta daf-url@beta" }, "dependencies": { "@microsoft/api-extractor": "7.9.22", @@ -32,7 +32,6 @@ "daf-libsodium": "^7.0.0-beta.56", "daf-message-handler": "^7.0.0-beta.56", "daf-resolver": "^7.0.0-beta.56", - "daf-resolver-universal": "^7.0.0-beta.56", "daf-rest": "^7.0.0-beta.56", "daf-selective-disclosure": "^7.0.0-beta.56", "daf-typeorm": "^7.0.0-beta.56", @@ -41,7 +40,9 @@ "daf-web-did": "^7.0.0-beta.56", "date-fns": "^2.8.1", "debug": "^4.1.1", + "did-resolver": "^2.1.2", "dotenv": "^8.2.0", + "ethr-did-resolver": "^3.0.2", "express": "^4.17.1", "express-handlebars": "^5.2.0", "fuzzy": "^0.1.3", @@ -62,6 +63,7 @@ "ts-json-schema-generator": "^0.80.0", "typeorm": "0.2.24", "url-parse": "^1.4.7", + "web-did-resolver": "^1.3.5", "ws": "^7.2.0", "yaml": "^1.10.0" }, diff --git a/packages/daf-cli/src/lib/objectCreator.ts b/packages/daf-cli/src/lib/objectCreator.ts index 10a37d509..507bc7286 100644 --- a/packages/daf-cli/src/lib/objectCreator.ts +++ b/packages/daf-cli/src/lib/objectCreator.ts @@ -43,6 +43,7 @@ export function createObjects(config: object, pointers: Record): let module = parsed.pathname const member = parsed.hash.length > 1 ? parsed.hash.slice(1) : 'default' const type = parsed.query['t'] || 'class' + const pointer = parsed.query['p'] const args = objectConfig['$args'] // console.log({module, member, type, query: parsed.query}) @@ -59,6 +60,9 @@ export function createObjects(config: object, pointers: Record): } else if (type === 'object') { object = required } + if (pointer) { + return get(object, pointer) + } return object } diff --git a/packages/daf-cli/tsconfig.json b/packages/daf-cli/tsconfig.json index 13ac5dd77..dd00d4d6b 100644 --- a/packages/daf-cli/tsconfig.json +++ b/packages/daf-cli/tsconfig.json @@ -15,7 +15,6 @@ { "path": "../daf-key-manager" }, { "path": "../daf-libsodium" }, { "path": "../daf-message-handler" }, - { "path": "../daf-resolver-universal" }, { "path": "../daf-resolver" }, { "path": "../daf-rest" }, { "path": "../daf-express" }, diff --git a/packages/daf-resolver-universal/CHANGELOG.md b/packages/daf-resolver-universal/CHANGELOG.md deleted file mode 100644 index 7f42903cf..000000000 --- a/packages/daf-resolver-universal/CHANGELOG.md +++ /dev/null @@ -1,642 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -# [7.0.0-beta.56](https://github.com/uport-project/daf/compare/v7.0.0-beta.55...v7.0.0-beta.56) (2020-12-09) - - -### Bug Fixes - -* **daf-did-jwt:** Fix parsing of JWT with missing `typ` in header ([#293](https://github.com/uport-project/daf/issues/293)) ([48e4c60](https://github.com/uport-project/daf/commit/48e4c607f78ac19be2ba83291cb68f414edb5b6b)), closes [#291](https://github.com/uport-project/daf/issues/291) - - - - - -# [7.0.0-beta.55](https://github.com/uport-project/daf/compare/v7.0.0-beta.54...v7.0.0-beta.55) (2020-12-08) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.54](https://github.com/uport-project/daf/compare/v7.0.0-beta.53...v7.0.0-beta.54) (2020-12-08) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.53](https://github.com/uport-project/daf/compare/v7.0.0-beta.52...v7.0.0-beta.53) (2020-12-04) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.52](https://github.com/uport-project/daf/compare/v7.0.0-beta.51...v7.0.0-beta.52) (2020-12-01) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.51](https://github.com/uport-project/daf/compare/v7.0.0-beta.50...v7.0.0-beta.51) (2020-11-26) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.50](https://github.com/uport-project/daf/compare/v7.0.0-beta.49...v7.0.0-beta.50) (2020-11-25) - - -### Features - -* Generate plugin schema ([#277](https://github.com/uport-project/daf/issues/277)) ([c90473a](https://github.com/uport-project/daf/commit/c90473a67731eb0cfcaf545afe0d64dfee77809c)) - - - - - -# [7.0.0-beta.49](https://github.com/uport-project/daf/compare/v7.0.0-beta.48...v7.0.0-beta.49) (2020-11-24) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.48](https://github.com/uport-project/daf/compare/v7.0.0-beta.47...v7.0.0-beta.48) (2020-11-24) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.47](https://github.com/uport-project/daf/compare/v7.0.0-beta.46...v7.0.0-beta.47) (2020-11-23) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.46](https://github.com/uport-project/daf/compare/v7.0.0-beta.45...v7.0.0-beta.46) (2020-11-19) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.45](https://github.com/uport-project/daf/compare/v7.0.0-beta.44...v7.0.0-beta.45) (2020-10-22) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.44](https://github.com/uport-project/daf/compare/v7.0.0-beta.43...v7.0.0-beta.44) (2020-10-21) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.43](https://github.com/uport-project/daf/compare/v7.0.0-beta.42...v7.0.0-beta.43) (2020-10-21) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.42](https://github.com/uport-project/daf/compare/v7.0.0-beta.41...v7.0.0-beta.42) (2020-10-20) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.41](https://github.com/uport-project/daf/compare/v7.0.0-beta.40...v7.0.0-beta.41) (2020-10-20) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.40](https://github.com/uport-project/daf/compare/v7.0.0-beta.39...v7.0.0-beta.40) (2020-10-20) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.39](https://github.com/uport-project/daf/compare/v7.0.0-beta.38...v7.0.0-beta.39) (2020-10-20) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.38](https://github.com/uport-project/daf/compare/v7.0.0-beta.37...v7.0.0-beta.38) (2020-10-19) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.37](https://github.com/uport-project/daf/compare/v7.0.0-beta.36...v7.0.0-beta.37) (2020-10-19) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.36](https://github.com/uport-project/daf/compare/v7.0.0-beta.35...v7.0.0-beta.36) (2020-10-18) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.35](https://github.com/uport-project/daf/compare/v7.0.0-beta.34...v7.0.0-beta.35) (2020-10-18) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.34](https://github.com/uport-project/daf/compare/v7.0.0-beta.33...v7.0.0-beta.34) (2020-10-15) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.33](https://github.com/uport-project/daf/compare/v7.0.0-beta.32...v7.0.0-beta.33) (2020-10-15) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.32](https://github.com/uport-project/daf/compare/v7.0.0-beta.31...v7.0.0-beta.32) (2020-10-15) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.31](https://github.com/uport-project/daf/compare/v7.0.0-beta.30...v7.0.0-beta.31) (2020-10-14) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.30](https://github.com/uport-project/daf/compare/v7.0.0-beta.29...v7.0.0-beta.30) (2020-10-13) - - -### Features - -* Generating plugin schemas ([d4450cd](https://github.com/uport-project/daf/commit/d4450cd30e27ebc8bf961400b871757662e202c3)) -* Validating returnType ([c7d1ef3](https://github.com/uport-project/daf/commit/c7d1ef3bd77dd4a77cf9dcfa32a2ed8b47fe04e0)) - - - - - -# [7.0.0-beta.29](https://github.com/uport-project/daf/compare/v7.0.0-beta.28...v7.0.0-beta.29) (2020-10-02) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.28](https://github.com/uport-project/daf/compare/v7.0.0-beta.27...v7.0.0-beta.28) (2020-10-01) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.27](https://github.com/uport-project/daf/compare/v7.0.0-beta.26...v7.0.0-beta.27) (2020-09-30) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.26](https://github.com/uport-project/daf/compare/v7.0.0-beta.25...v7.0.0-beta.26) (2020-09-29) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.25](https://github.com/uport-project/daf/compare/v7.0.0-beta.24...v7.0.0-beta.25) (2020-09-28) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.24](https://github.com/uport-project/daf/compare/v7.0.0-beta.23...v7.0.0-beta.24) (2020-09-25) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.23](https://github.com/uport-project/daf/compare/v7.0.0-beta.22...v7.0.0-beta.23) (2020-09-22) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.22](https://github.com/uport-project/daf/compare/v7.0.0-beta.21...v7.0.0-beta.22) (2020-09-22) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.21](https://github.com/uport-project/daf/compare/v7.0.0-beta.20...v7.0.0-beta.21) (2020-09-17) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.20](https://github.com/uport-project/daf/compare/v7.0.0-beta.19...v7.0.0-beta.20) (2020-09-15) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.19](https://github.com/uport-project/daf/compare/v7.0.0-beta.18...v7.0.0-beta.19) (2020-09-14) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.18](https://github.com/uport-project/daf/compare/v6.3.0...v7.0.0-beta.18) (2020-09-09) - - -### Bug Fixes - -* Resolver tests ([65b3ff0](https://github.com/uport-project/daf/commit/65b3ff0cb46fdd5913bdca31c31726c2fa9bbe14)) - - -### Code Refactoring - -* Refactor and add inline documentation to daf-w3c package ([f0e2cb9](https://github.com/uport-project/daf/commit/f0e2cb9748dc04b0d46ac1d80bac9a0b7f7546cd)) - - -### BREAKING CHANGES - -* the `IW3c` type and `W3c` class have been renamed to -`ICredentialIssuer` and `CredentialIssuer` - -fix(deps): update `did-resolver` and `did-jwt` libs for all packages to maintain type consistency - - - - - -# [7.0.0-beta.17](https://github.com/uport-project/daf/compare/v6.1.1...v7.0.0-beta.17) (2020-09-04) - - -### Bug Fixes - -* Resolver tests ([7aaf946](https://github.com/uport-project/daf/commit/7aaf946e375f0aadcee25e9a465a7d50dace5b1e)) - - -### Code Refactoring - -* Refactor and add inline documentation to daf-w3c package ([af2cec1](https://github.com/uport-project/daf/commit/af2cec1e604cff194b2b909f79365138b0b5ba17)) - - -### BREAKING CHANGES - -* the `IW3c` type and `W3c` class have been renamed to -`ICredentialIssuer` and `CredentialIssuer` - -fix(deps): update `did-resolver` and `did-jwt` libs for all packages to maintain type consistency - - - - - -# [7.0.0-beta.16](https://github.com/uport-project/daf/compare/v7.0.0-beta.15...v7.0.0-beta.16) (2020-09-02) - - -### Code Refactoring - -* Refactor and add inline documentation to daf-w3c package ([91ff4d9](https://github.com/uport-project/daf/commit/91ff4d936d11bf48c56aec6cebc91e268d44f730)) - - -### BREAKING CHANGES - -* the `IW3c` type and `W3c` class have been renamed to -`ICredentialIssuer` and `CredentialIssuer` - -fix(deps): update `did-resolver` and `did-jwt` libs for all packages to maintain type consistency - - - - - -# [7.0.0-beta.15](https://github.com/uport-project/daf/compare/v7.0.0-beta.14...v7.0.0-beta.15) (2020-08-27) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.14](https://github.com/uport-project/daf/compare/v7.0.0-beta.13...v7.0.0-beta.14) (2020-08-26) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.13](https://github.com/uport-project/daf/compare/v7.0.0-beta.12...v7.0.0-beta.13) (2020-08-26) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.12](https://github.com/uport-project/daf/compare/v7.0.0-beta.11...v7.0.0-beta.12) (2020-08-26) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.11](https://github.com/uport-project/daf/compare/v7.0.0-beta.10...v7.0.0-beta.11) (2020-08-17) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.10](https://github.com/uport-project/daf/compare/v7.0.0-beta.9...v7.0.0-beta.10) (2020-08-17) - -**Note:** Version bump only for package daf-resolver-universal - - - - - -# [7.0.0-beta.9](https://github.com/uport-project/daf/compare/v7.0.0-beta.8...v7.0.0-beta.9) (2020-08-14) - -**Note:** Version bump only for package daf-resolver-universal - -# [7.0.0-beta.8](https://github.com/uport-project/daf/compare/v7.0.0-beta.7...v7.0.0-beta.8) (2020-07-14) - -**Note:** Version bump only for package daf-resolver-universal - -# [7.0.0-beta.7](https://github.com/uport-project/daf/compare/v7.0.0-beta.6...v7.0.0-beta.7) (2020-07-10) - -**Note:** Version bump only for package daf-resolver-universal - -# [7.0.0-beta.6](https://github.com/uport-project/daf/compare/v7.0.0-beta.5...v7.0.0-beta.6) (2020-07-10) - -**Note:** Version bump only for package daf-resolver-universal - -# [7.0.0-beta.5](https://github.com/uport-project/daf/compare/v7.0.0-beta.4...v7.0.0-beta.5) (2020-07-10) - -**Note:** Version bump only for package daf-resolver-universal - -# [7.0.0-beta.4](https://github.com/uport-project/daf/compare/v7.0.0-beta.3...v7.0.0-beta.4) (2020-07-09) - -**Note:** Version bump only for package daf-resolver-universal - -# [7.0.0-beta.3](https://github.com/uport-project/daf/compare/v7.0.0-beta.2...v7.0.0-beta.3) (2020-07-09) - -**Note:** Version bump only for package daf-resolver-universal - -# [7.0.0-beta.2](https://github.com/uport-project/daf/compare/v7.0.0-beta.1...v7.0.0-beta.2) (2020-07-07) - -**Note:** Version bump only for package daf-resolver-universal - -# [7.0.0-beta.1](https://github.com/uport-project/daf/compare/v6.1.1...v7.0.0-beta.1) (2020-07-07) - -### Bug Fixes - -- Resolver tests ([8a21aed](https://github.com/uport-project/daf/commit/8a21aed769fc5c1ea31774bbe0fb06d2db185d90)) - -# [6.3.0](https://github.com/uport-project/daf/compare/v6.1.1...v6.3.0) (2020-09-04) - - -### Features - -* **release:** Fix package descriptions and trigger new minor release ([#233](https://github.com/uport-project/daf/issues/233)) ([e67f4da](https://github.com/uport-project/daf/commit/e67f4da055d1f0b1b0ba4205726b79979d234a06)) -* **release:** Trigger a new minor release ([#234](https://github.com/uport-project/daf/issues/234)) ([7c905e1](https://github.com/uport-project/daf/commit/7c905e1ea7c4851f7f06e87e06efe34d4eac7b0f)) - - - - - -# [6.2.0](https://github.com/uport-project/daf/compare/v6.1.2...v6.2.0) (2020-09-04) - - -### Features - -* **release:** Fix package descriptions and trigger new minor release ([#233](https://github.com/uport-project/daf/issues/233)) ([e67f4da](https://github.com/uport-project/daf/commit/e67f4da055d1f0b1b0ba4205726b79979d234a06)) - - - - - -# [6.0.0](https://github.com/uport-project/daf/compare/v5.7.0...v6.0.0) (2020-05-29) - -**Note:** Version bump only for package daf-resolver-universal - -## [5.6.6](https://github.com/uport-project/daf/compare/v5.6.5...v5.6.6) (2020-05-26) - -**Note:** Version bump only for package daf-resolver-universal - -# [5.3.0](https://github.com/uport-project/daf/compare/v5.2.0...v5.3.0) (2020-05-06) - -### Features - -- Universal resolver unit tests ([8b92d1c](https://github.com/uport-project/daf/commit/8b92d1c032b19124271bff7884ceebace6331a4e)) - -# [5.0.0](https://github.com/uport-project/daf/compare/v4.5.0...v5.0.0) (2020-05-05) - -**Note:** Version bump only for package daf-resolver-universal - -# [4.1.0](https://github.com/uport-project/daf/compare/v4.0.0...v4.1.0) (2020-04-23) - -**Note:** Version bump only for package daf-resolver-universal - -# [4.0.0](https://github.com/uport-project/daf/compare/v4.0.0-beta.48...v4.0.0) (2020-04-22) - -**Note:** Version bump only for package daf-resolver-universal - -# [4.0.0-beta.48](https://github.com/uport-project/daf/compare/v4.0.0-beta.47...v4.0.0-beta.48) (2020-04-22) - -**Note:** Version bump only for package daf-resolver-universal - -# [4.0.0-beta.47](https://github.com/uport-project/daf/compare/v4.0.0-beta.46...v4.0.0-beta.47) (2020-04-17) - -**Note:** Version bump only for package daf-resolver-universal - -# [4.0.0-beta.46](https://github.com/uport-project/daf/compare/v4.0.0-beta.45...v4.0.0-beta.46) (2020-04-17) - -**Note:** Version bump only for package daf-resolver-universal - -# [4.0.0-beta.45](https://github.com/uport-project/daf/compare/v4.0.0-beta.44...v4.0.0-beta.45) (2020-04-16) - -**Note:** Version bump only for package daf-resolver-universal - -# [4.0.0-beta.44](https://github.com/uport-project/daf/compare/v4.0.0-beta.43...v4.0.0-beta.44) (2020-04-15) - -**Note:** Version bump only for package daf-resolver-universal - -# [4.0.0-beta.43](https://github.com/uport-project/daf/compare/v4.0.0-beta.42...v4.0.0-beta.43) (2020-04-15) - -**Note:** Version bump only for package daf-resolver-universal - -# [4.0.0-beta.42](https://github.com/uport-project/daf/compare/v3.4.0...v4.0.0-beta.42) (2020-04-09) - -**Note:** Version bump only for package daf-resolver-universal - -## [3.0.1](https://github.com/uport-project/daf/compare/v3.0.0...v3.0.1) (2020-03-16) - -**Note:** Version bump only for package daf-resolver-universal - -# [3.0.0](https://github.com/uport-project/daf/compare/v2.5.0...v3.0.0) (2020-03-13) - -### Features - -- Updating examples to the new API ([13c7e3b](https://github.com/uport-project/daf/commit/13c7e3b625ed1924f2ff9346ff0ab40337fcc8d4)) - -## [2.3.18](https://github.com/uport-project/daf/compare/v2.3.17...v2.3.18) (2020-03-10) - -**Note:** Version bump only for package daf-resolver-universal - -## [2.3.16](https://github.com/uport-project/daf/compare/v2.3.15...v2.3.16) (2020-03-03) - -**Note:** Version bump only for package daf-resolver-universal - -## [2.3.15](https://github.com/uport-project/daf/compare/v2.3.14...v2.3.15) (2020-03-02) - -### Bug Fixes - -- Typescript types ([72c1899](https://github.com/uport-project/daf/commit/72c18993ddba6a7a75ae8397e6549cdd29dccb31)) - -# [2.0.0](https://github.com/uport-project/daf/compare/v1.5.1...v2.0.0) (2020-02-17) - -**Note:** Version bump only for package daf-resolver-universal - -# [1.1.0](https://github.com/uport-project/daf/compare/v0.10.3...v1.1.0) (2019-12-16) - -**Note:** Version bump only for package daf-resolver-universal - -## [0.10.3](https://github.com/uport-project/daf/compare/v0.10.2...v0.10.3) (2019-12-12) - -### Bug Fixes - -- Unifying debug messages ([efb4f3b](https://github.com/uport-project/daf/commit/efb4f3bf9f6d3f0d412eb80da7bb4ae92ce8ca72)) - -# [0.10.0](https://github.com/uport-project/daf/compare/v0.9.0...v0.10.0) (2019-12-10) - -**Note:** Version bump only for package daf-resolver-universal - -# [0.9.0](https://github.com/uport-project/daf/compare/v0.8.0...v0.9.0) (2019-12-05) - -**Note:** Version bump only for package daf-resolver-universal - -# [0.8.0](https://github.com/uport-project/daf/compare/v0.7.8...v0.8.0) (2019-12-04) - -**Note:** Version bump only for package daf-resolver-universal - -# [0.7.0](https://github.com/uport-project/daf/compare/v0.6.1...v0.7.0) (2019-11-29) - -**Note:** Version bump only for package daf-resolver-universal - -# [0.6.0](https://github.com/uport-project/daf/compare/v0.5.2...v0.6.0) (2019-11-27) - -**Note:** Version bump only for package daf-resolver-universal - -## [0.5.1](https://github.com/uport-project/daf/compare/v0.5.0...v0.5.1) (2019-11-26) - -**Note:** Version bump only for package daf-resolver-universal - -# [0.5.0](https://github.com/uport-project/daf/compare/v0.4.0...v0.5.0) (2019-11-26) - -**Note:** Version bump only for package daf-resolver-universal - -# [0.4.0](https://github.com/uport-project/daf/compare/v0.3.0...v0.4.0) (2019-11-25) - -**Note:** Version bump only for package daf-resolver-universal - -# [0.3.0](https://github.com/uport-project/daf/compare/v0.2.0...v0.3.0) (2019-11-24) - -**Note:** Version bump only for package daf-resolver-universal - -# [0.2.0](https://github.com/uport-project/daf/compare/v0.1.0...v0.2.0) (2019-11-23) - -**Note:** Version bump only for package daf-resolver-universal - -# [0.1.0](https://github.com/uport-project/daf/compare/v0.0.26...v0.1.0) (2019-11-22) - -**Note:** Version bump only for package daf-resolver-universal - -## [0.0.26](https://github.com/uport-project/daf/compare/v0.0.25...v0.0.26) (2019-11-22) - -**Note:** Version bump only for package daf-resolver-universal - -## [0.0.25](https://github.com/uport-project/daf/compare/v0.0.24...v0.0.25) (2019-11-21) - -**Note:** Version bump only for package daf-resolver-universal - -## [0.0.24](https://github.com/uport-project/daf/compare/v0.0.23...v0.0.24) (2019-11-19) - -**Note:** Version bump only for package daf-resolver-universal diff --git a/packages/daf-resolver-universal/LICENSE b/packages/daf-resolver-universal/LICENSE deleted file mode 100644 index fd815d7f8..000000000 --- a/packages/daf-resolver-universal/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2019 Consensys AG - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/packages/daf-resolver-universal/README.md b/packages/daf-resolver-universal/README.md deleted file mode 100644 index 7bb4a6312..000000000 --- a/packages/daf-resolver-universal/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# DAF DID Document resolver - -```typescript -const didResolver = new DafUniversalResolver({ url: 'https://uniresolver.io/1.0/identifiers/' }) -const didDoc = await didResolver.resolve('did:web:uport.me') -``` diff --git a/packages/daf-resolver-universal/api-extractor.json b/packages/daf-resolver-universal/api-extractor.json deleted file mode 100644 index 409d7f16c..000000000 --- a/packages/daf-resolver-universal/api-extractor.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", - "apiReport": { - "enabled": true, - "reportFolder": "./api", - "reportTempFolder": "./api" - }, - - "docModel": { - "enabled": true, - "apiJsonFilePath": "./api/.api.json" - }, - - "dtsRollup": { - "enabled": false - }, - "mainEntryPointFilePath": "/build/index.d.ts" -} diff --git a/packages/daf-resolver-universal/api/daf-resolver-universal.api.md b/packages/daf-resolver-universal/api/daf-resolver-universal.api.md deleted file mode 100644 index 25773458f..000000000 --- a/packages/daf-resolver-universal/api/daf-resolver-universal.api.md +++ /dev/null @@ -1,26 +0,0 @@ -## API Report File for "daf-resolver-universal" - -> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). - -```ts - -import { DIDDocument } from 'did-resolver'; -import { IAgentPlugin } from 'daf-core'; -import { IResolver } from 'daf-core'; - -// @public (undocumented) -export class DafUniversalResolver implements IAgentPlugin { - // Warning: (ae-forgotten-export) The symbol "Options" needs to be exported by the entry point index.d.ts - constructor(options: Options); - // (undocumented) - readonly methods: IResolver; - // (undocumented) - resolveDid({ didUrl }: { - didUrl: string; - }): Promise; - // (undocumented) - readonly schema: any; - } - - -``` diff --git a/packages/daf-resolver-universal/package.json b/packages/daf-resolver-universal/package.json deleted file mode 100644 index 8b8211635..000000000 --- a/packages/daf-resolver-universal/package.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "daf-resolver-universal", - "description": "DAF resolver plugin using the uniresolver.io API.", - "version": "7.0.0-beta.56", - "main": "build/index.js", - "types": "build/index.d.ts", - "scripts": { - "build": "tsc", - "extract-api": "yarn daf extract-api" - }, - "dependencies": { - "cross-fetch": "^3.0.5", - "daf-core": "^7.0.0-beta.56", - "debug": "^4.1.1", - "did-resolver": "2.1.2" - }, - "devDependencies": { - "@types/debug": "^4.1.5", - "jest-fetch-mock": "^3.0.3", - "typescript": "^4.0.3" - }, - "files": [ - "build/**/*", - "src/**/*", - "README.md", - "LICENSE" - ], - "repository": "git@github.com:uport-project/daf.git", - "author": "Simonas Karuzas ", - "license": "Apache-2.0", - "keywords": [], - "gitHead": "ec317e0f10cffe731648a8c2d8f58def3d3c85ff" -} diff --git a/packages/daf-resolver-universal/src/__tests__/resolver.test.ts b/packages/daf-resolver-universal/src/__tests__/resolver.test.ts deleted file mode 100644 index 595285ce2..000000000 --- a/packages/daf-resolver-universal/src/__tests__/resolver.test.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { DafUniversalResolver } from '../resolver' -import fetchMock from 'jest-fetch-mock' -fetchMock.enableMocks() - -describe('daf-resolver-universal', () => { - it('should throw error when misconfigured', () => { - expect(() => { - //@ts-ignore - new DafUniversalResolver({}) - }).toThrow() - }) - - it('should have resolve method', () => { - const resolver = new DafUniversalResolver({ url: 'https://example/' }) - expect(resolver).toHaveProperty('resolveDid') - }) - - it('should fetch did doc', async () => { - const resolver = new DafUniversalResolver({ url: 'https://example/' }) - fetchMock.mockResponse(JSON.stringify({ didDocument: { data: '12345' } })) - const doc = await resolver.resolveDid({ didUrl: 'did:example:123' }) - expect(doc).toEqual({ data: '12345' }) - }) -}) diff --git a/packages/daf-resolver-universal/src/index.ts b/packages/daf-resolver-universal/src/index.ts deleted file mode 100644 index a0314288d..000000000 --- a/packages/daf-resolver-universal/src/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Provides a {@link daf-resolver-universal#DafUniversalResolver | plugin} for the {@link daf-core#Agent} that implements {@link daf-core#IResolver } interface. Uses external "universal" resolver - * - * @packageDocumentation - */ -export { DafUniversalResolver } from './resolver' diff --git a/packages/daf-resolver-universal/src/resolver.ts b/packages/daf-resolver-universal/src/resolver.ts deleted file mode 100644 index 5c07ad6fa..000000000 --- a/packages/daf-resolver-universal/src/resolver.ts +++ /dev/null @@ -1,39 +0,0 @@ -import 'cross-fetch/polyfill' -import { IAgentPlugin, IResolver, schema } from 'daf-core' -import { DIDDocument } from 'did-resolver' -export { DIDDocument } -import Debug from 'debug' -const debug = Debug('daf:resolver-universal') - -interface Options { - url: string -} - -export class DafUniversalResolver implements IAgentPlugin { - readonly methods: IResolver - readonly schema = schema.IResolver - private url: string - - constructor(options: Options) { - if (!options.url) throw Error('[daf-resolver-universal] url required') - debug(options.url) - this.url = options.url - - this.resolveDid = this.resolveDid.bind(this) - - this.methods = { - resolveDid: this.resolveDid, - } - } - - async resolveDid({ didUrl }: { didUrl: string }): Promise { - debug('Resolving %s', didUrl) - try { - const result = await fetch(this.url + didUrl) - const ddo = await result.json() - return ddo.didDocument - } catch (e) { - return Promise.reject(e.message) - } - } -} diff --git a/packages/daf-resolver-universal/tsconfig.json b/packages/daf-resolver-universal/tsconfig.json deleted file mode 100644 index 53e51212f..000000000 --- a/packages/daf-resolver-universal/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../tsconfig.settings.json", - "compilerOptions": { - "rootDir": "src", - "outDir": "build", - "declarationDir": "build" - }, - "references": [{ "path": "../daf-core" }] -} diff --git a/packages/daf-resolver/api/daf-resolver.api.md b/packages/daf-resolver/api/daf-resolver.api.md index 57c6c7af0..a1909abb9 100644 --- a/packages/daf-resolver/api/daf-resolver.api.md +++ b/packages/daf-resolver/api/daf-resolver.api.md @@ -7,6 +7,7 @@ import { DIDDocument } from 'did-resolver'; import { IAgentPlugin } from 'daf-core'; import { IResolver } from 'daf-core'; +import { Resolver } from 'did-resolver'; // @public (undocumented) export class DafResolver implements IAgentPlugin { @@ -22,5 +23,11 @@ export class DafResolver implements IAgentPlugin { readonly schema: any; } +// @public (undocumented) +export class UniversalResolver { + // Warning: (ae-forgotten-export) The symbol "Options" needs to be exported by the entry point index.d.ts + constructor(options: Options_2); +} + ``` diff --git a/packages/daf-resolver/package.json b/packages/daf-resolver/package.json index 8c3758dd1..b64d42741 100644 --- a/packages/daf-resolver/package.json +++ b/packages/daf-resolver/package.json @@ -10,14 +10,11 @@ }, "dependencies": { "daf-core": "^7.0.0-beta.56", - "debug": "^4.1.1", - "did-resolver": "2.1.2", - "ethr-did-resolver": "^3.0.0", - "nacl-did": "^1.0.1", - "web-did-resolver": "^1.3.3" + "debug": "^4.1.1" }, "devDependencies": { "@types/debug": "^4.1.5", + "did-resolver": "^2.1.2", "typescript": "^4.0.3" }, "files": [ diff --git a/packages/daf-resolver/src/__tests__/resolver.test.ts b/packages/daf-resolver/src/__tests__/resolver.test.ts index a088e44bc..9e50ab8cd 100644 --- a/packages/daf-resolver/src/__tests__/resolver.test.ts +++ b/packages/daf-resolver/src/__tests__/resolver.test.ts @@ -1,14 +1,21 @@ import { DafResolver } from '../resolver' +import { Resolver } from 'did-resolver' describe('daf-resolver', () => { it('should throw error when misconfigured', () => { expect(() => { - new DafResolver({}) + new DafResolver({ + //@ts-ignore + resolver: undefined + }) }).toThrow() }) - +it.todo('should resolve example did') +it.todo('should fail predictably when unsupported method is resolved') +it.todo('should resolve ethr-did with RPC URL') +it.todo('should resolve ethr-did with custom web3 provider') it('should have resolve method', () => { - const resolver = new DafResolver({ infuraProjectId: 'xxx' }) + const resolver = new DafResolver({ resolver: new Resolver() }) expect(resolver).toHaveProperty('resolveDid') }) diff --git a/packages/daf-resolver/src/index.ts b/packages/daf-resolver/src/index.ts index 27c6a3e8e..f8a7ac8f3 100644 --- a/packages/daf-resolver/src/index.ts +++ b/packages/daf-resolver/src/index.ts @@ -4,3 +4,4 @@ * @packageDocumentation */ export { DafResolver } from './resolver' +export { UniversalResolver } from './universal-resolver' diff --git a/packages/daf-resolver/src/resolver.ts b/packages/daf-resolver/src/resolver.ts index 32691b8af..33f3daf3c 100644 --- a/packages/daf-resolver/src/resolver.ts +++ b/packages/daf-resolver/src/resolver.ts @@ -1,51 +1,21 @@ import { IAgentPlugin, IResolver, schema } from 'daf-core' import { Resolver, DIDDocument } from 'did-resolver' -import { getResolver as ethrDidResolver } from 'ethr-did-resolver' -import { resolver as naclDidResolver } from 'nacl-did' -import { getResolver as webDidResolver } from 'web-did-resolver' export { DIDDocument } import Debug from 'debug' - const debug = Debug('daf:resolver') -interface NetworkConfig { - name: string - rpcUrl: string - registry?: string -} - interface Options { - infuraProjectId?: string - networks?: NetworkConfig[] + resolver: Resolver } export class DafResolver implements IAgentPlugin { readonly methods: IResolver readonly schema = schema.IResolver private didResolver: Resolver - private networks: NetworkConfig[] constructor(options: Options) { - let networks: NetworkConfig[] - if (!options.networks && options.infuraProjectId) { - networks = [ - { name: 'mainnet', rpcUrl: 'https://mainnet.infura.io/v3/' + options.infuraProjectId }, - { name: 'rinkeby', rpcUrl: 'https://rinkeby.infura.io/v3/' + options.infuraProjectId }, - { name: 'ropsten', rpcUrl: 'https://ropsten.infura.io/v3/' + options.infuraProjectId }, - { name: 'kovan', rpcUrl: 'https://kovan.infura.io/v3/' + options.infuraProjectId }, - { name: 'goerli', rpcUrl: 'https://goerli.infura.io/v3/' + options.infuraProjectId }, - ] - } else if (!options.infuraProjectId && options.networks) { - networks = options.networks - } else { - throw Error('[daf-resolver] infuraProjectId or networks config required') - } - this.networks = networks - this.didResolver = new Resolver({ - ...ethrDidResolver({ networks }), - ...webDidResolver(), - nacl: naclDidResolver, - }) + if (!options.resolver) throw Error('Missing resolver') + this.didResolver = options.resolver this.resolveDid = this.resolveDid.bind(this) @@ -55,7 +25,6 @@ export class DafResolver implements IAgentPlugin { } async resolveDid({ didUrl }: { didUrl: string }): Promise { - debug('Networks config %o', this.networks) debug('Resolving %s', didUrl) return this.didResolver.resolve(didUrl) } diff --git a/packages/daf-resolver/src/universal-resolver.ts b/packages/daf-resolver/src/universal-resolver.ts new file mode 100644 index 000000000..23beb1f4e --- /dev/null +++ b/packages/daf-resolver/src/universal-resolver.ts @@ -0,0 +1,25 @@ +import { DIDDocument } from 'did-resolver' + +interface Options { + url: string +} + +export class UniversalResolver { + constructor(options: Options) { + if (!options.url) { + throw Error('[daf-resolver] Universal: url required') + } + + const resolve = async (didUrl: string): Promise => { + try { + const result = await fetch(options.url + didUrl) + const ddo = await result.json() + return ddo.didDocument + } catch (e) { + return Promise.reject(e.message) + } + } + + return resolve + } +} \ No newline at end of file diff --git a/packages/daf-typeorm/api/daf-typeorm.api.md b/packages/daf-typeorm/api/daf-typeorm.api.md index 5a4306700..3099b6168 100644 --- a/packages/daf-typeorm/api/daf-typeorm.api.md +++ b/packages/daf-typeorm/api/daf-typeorm.api.md @@ -135,7 +135,7 @@ export class DataStoreORM implements IAgentPlugin { } // @public (undocumented) -export const Entities: (typeof Key | typeof Identity | typeof Service | typeof Claim | typeof Credential_2 | typeof Presentation | typeof Message)[]; +export const Entities: (typeof Credential_2 | typeof Identity | typeof Claim | typeof Presentation | typeof Message | typeof Key | typeof Service)[]; // @public (undocumented) export interface FindArgs { diff --git a/packages/tsconfig.json b/packages/tsconfig.json index 535790217..081a0ddf7 100644 --- a/packages/tsconfig.json +++ b/packages/tsconfig.json @@ -12,7 +12,6 @@ { "path": "daf-libsodium" }, { "path": "daf-message-handler" }, { "path": "daf-resolver" }, - { "path": "daf-resolver-universal" }, { "path": "daf-rest" }, { "path": "daf-selective-disclosure" }, { "path": "daf-url" }, diff --git a/yarn.lock b/yarn.lock index 834982a5a..21a65178a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6077,11 +6077,6 @@ did-resolver@2.1.2, did-resolver@^2.1.2: resolved "https://registry.yarnpkg.com/did-resolver/-/did-resolver-2.1.2.tgz#f1194fdbc087161809ce545e13c11a596f4a3928" integrity sha512-n4YGS1CzbX48U/ChLRY3SdgiV5N3B/+yh0ToS5t+Sx4QjhVZN6ZyijUSSYbFGvz+I4qImeSZOdo6RX8JaieN7A== -did-resolver@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/did-resolver/-/did-resolver-1.1.0.tgz#27a63b6f2aa8dee3d622cd8b8b47360661e24f1e" - integrity sha512-Q02Sc5VuQnJzzR8fQ/DzyCHiYb31WpQdocOsxppI66wwT4XalYRDeCr3a48mL6sYPQo76AkBh0mxte9ZBuQzxA== - diff-sequences@^25.2.6: version "25.2.6" resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-25.2.6.tgz#5f467c00edd35352b7bca46d7927d60e687a76dd" @@ -6273,13 +6268,6 @@ ecc-jsbn@~0.1.1: jsbn "~0.1.0" safer-buffer "^2.1.0" -ed2curve-esm@^0.3.0-alpha-1: - version "0.3.0-alpha-1" - resolved "https://registry.yarnpkg.com/ed2curve-esm/-/ed2curve-esm-0.3.0-alpha-1.tgz#67a5722ea97976c3310aeaf0990a2b58ee383aef" - integrity sha512-Ydrqcf0NwKUBT4gL0Nnxp8/O5NG8iatN+/zbEgs/7eMGjgSVbgfE1YfWld2qYnoNIxOQvSWOFy5uBoaL3jCanw== - dependencies: - tweetnacl "^1.0.1" - editor@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/editor/-/editor-1.0.0.tgz#60c7f87bd62bcc6a894fa8ccd6afb7823a24f742" @@ -7193,13 +7181,13 @@ ethr-did-resolver@^0.2.0: ethjs-query "^0.3.5" ethr-did-registry "^0.0.3" -ethr-did-resolver@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/ethr-did-resolver/-/ethr-did-resolver-3.0.0.tgz#a7a3b8b4407d651007266b3a76463796bb79c0ce" - integrity sha512-o400l9p8ee6W09fZLMX2BERcyFRrebE7DCjb46Rzgypb7QzX1rBOzHJ0PorWRINXFqoPMoxR7OeIrD17obIbng== +ethr-did-resolver@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/ethr-did-resolver/-/ethr-did-resolver-3.0.2.tgz#9fd39f73d7ecf62781cd8eec0b2397f8ad68981d" + integrity sha512-dCsK5RWhnpDuV0TM8VL9LxY+RxdN9LxTud2sdaY4oT9WULP74uO/pQO8eWn9IQFz2c796ckzaKwDbeaOo+sogw== dependencies: buffer "^5.1.0" - did-resolver "2.1.1" + did-resolver "2.1.2" elliptic "^6.5.3" ethjs-abi "^0.2.1" ethjs-contract "^0.2.0" @@ -12054,16 +12042,6 @@ mz@^2.4.0, mz@^2.5.0: object-assign "^4.0.1" thenify-all "^1.0.0" -nacl-did@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/nacl-did/-/nacl-did-1.0.1.tgz#94a253430343038c8fee3ff0ecf394b1d34fe4b2" - integrity sha512-eGFtGk8v04QaYYQe0Y+suC0iLarPJh4NC5z/f1+JTQh7nRvA/+5ZT4eh/dtP/JGPtUkh2TdpdeiFtMJ0DEyIKQ== - dependencies: - did-resolver "^1.0.0" - ed2curve-esm "^0.3.0-alpha-1" - tweetnacl "^1.0.1" - tweetnacl-util "^0.15.0" - nan@^2.11.1, nan@^2.12.1, nan@^2.14.0, nan@^2.14.1: version "2.14.1" resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.1.tgz#d7be34dfa3105b91494c3147089315eff8874b01" @@ -17192,10 +17170,10 @@ wcwidth@^1.0.0: dependencies: defaults "^1.0.3" -web-did-resolver@^1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/web-did-resolver/-/web-did-resolver-1.3.3.tgz#88f897c4c39851dd5071338dd343ef27169a4225" - integrity sha512-CL/pBC/vatndMU84eaWA7QHRgwN2Op3hAhxTcBs7VMmqoNGmZXmW1/x3FU0w8kLhRRJae2XFUkkxHQfN1wJtTw== +web-did-resolver@^1.3.5: + version "1.3.5" + resolved "https://registry.yarnpkg.com/web-did-resolver/-/web-did-resolver-1.3.5.tgz#1240a94530fa5194827856b8ff7957d00d11a7d7" + integrity sha512-k+32CvrguvAwgvppYH0geMsmKJL1akuyWa3p5ArVON5swYvMb72e1yayM7XuPMwUW/6aZ2Z0HL14QkfvcIJRQw== dependencies: cross-fetch "^3.0.4" did-resolver "2.1.1"