diff --git a/packages/daf-cli/README.md b/packages/daf-cli/README.md index 3ae7d4369..ef957d220 100644 --- a/packages/daf-cli/README.md +++ b/packages/daf-cli/README.md @@ -1 +1,61 @@ -# DAF command line tool \ No newline at end of file +# DAF command line interface + +## Install + +``` +npm -g i daf-cli +``` + +## Configuration + ENV | Default | Description +---|---|--- + `DAF_IDENTITY_STORE` | `~/.daf/identity-store.json` | Identity keyPair storage + `DAF_DATA_STORE` | `~/.daf/data-store.sqlite3` | Sqlite3 database containing messages, credentials, presentations, etc. + `DAF_ENCRYPTION_STORE` | `~/.daf/encryption-store.json` | Encryption keyPair storage. Used for DIDComm + `DAF_INFURA_ID` | `5ffc47f65c4042ce847ef66a3fa70d4c` | Used for calls to the Ethereum blockchain + `DAF_UNIVERSAL_RESOLVER_URL` | `undefined` | Example `https://uniresolver.io/1.0/identifiers/`. If not provided - will use internal resolver + +## Usage + +``` +Usage: daf [options] [command] + +Options: + -h, --help output usage information + +Commands: + identity-manager [options] Manage identities + resolve Resolve DID Document +``` + +### Identity manager + +``` +daf identity-manager -h + +Usage: daf identity-manager [options] + +Manage identities + +Options: + -l, --list List managed identities + -t, --types List available identity controller types + -c, --create Create identity using identity controller + -d, --delete Create identity using identity controller + -h, --help output usage information +``` + + +### DID Document resolver + +Internal resolver (`did-resolver`) + +``` +daf resolve did:web:uport.me +``` + +Universal resolver + +``` +DAF_UNIVERSAL_RESOLVER_URL=https://uniresolver.io/1.0/identifiers/ daf resolve did:github:gjgd +``` \ No newline at end of file diff --git a/packages/daf-cli/bin/daf.js b/packages/daf-cli/bin/daf.js new file mode 100644 index 000000000..bc017cec5 --- /dev/null +++ b/packages/daf-cli/bin/daf.js @@ -0,0 +1,3 @@ +#!/usr/bin/env node + +require('../build/cli') \ No newline at end of file diff --git a/packages/daf-cli/package-lock.json b/packages/daf-cli/package-lock.json index 467607788..6d7d76157 100644 --- a/packages/daf-cli/package-lock.json +++ b/packages/daf-cli/package-lock.json @@ -56,34 +56,6 @@ "color-convert": "^1.9.0" } }, - "babel-runtime": { - "version": "6.26.0", - "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", - "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", - "requires": { - "core-js": "^2.4.0", - "regenerator-runtime": "^0.11.0" - } - }, - "base64-js": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", - "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==" - }, - "bn.js": { - "version": "4.11.6", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", - "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=" - }, - "buffer": { - "version": "5.4.3", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.4.3.tgz", - "integrity": "sha512-zvj65TkFeIt3i6aj5bIvJDzjjQQGs4o/sNoezg1F1kYap9Nu2jcUdpwzRSJTHMMzG0H7bZkn4rNQpImhuxWX2A==", - "requires": { - "base64-js": "^1.0.2", - "ieee754": "^1.1.4" - } - }, "chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -135,20 +107,6 @@ "resolved": "https://registry.npmjs.org/console-table-printer/-/console-table-printer-1.1.15.tgz", "integrity": "sha512-sxuNBhKxler9E2l50DiVFCM/he4yYBzxiI4aaumRR8KY2E+fX1Q3OU8d6ekdmjL5uNVMKzLSb56x+7eq8HvFMQ==" }, - "core-js": { - "version": "2.6.10", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.10.tgz", - "integrity": "sha512-I39t74+4t+zau64EN1fE5v2W31Adtc/REhzWN+gWRRXg6WH5qAsZm62DHpQ1+Yhe4047T55jvzz7MUqF/dBBlA==" - }, - "cross-fetch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.0.4.tgz", - "integrity": "sha512-MSHgpjQqgbT/94D4CyADeNoYh52zMkCX4pcJvPP5WqPsLFMKjr2TCMg381ox5qI0ii2dPwaLx/00477knXqXVw==", - "requires": { - "node-fetch": "2.6.0", - "whatwg-fetch": "3.0.0" - } - }, "debug": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", @@ -157,18 +115,6 @@ "ms": "^2.1.1" } }, - "did-resolver": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/did-resolver/-/did-resolver-1.1.0.tgz", - "integrity": "sha512-Q02Sc5VuQnJzzR8fQ/DzyCHiYb31WpQdocOsxppI66wwT4XalYRDeCr3a48mL6sYPQo76AkBh0mxte9ZBuQzxA==" - }, - "ed2curve": { - "version": "git+https://github.com/uport-project/ed2curve-js.git#0eed8c601a5ad48e8bec1c61c335acac5428f51c", - "from": "git+https://github.com/uport-project/ed2curve-js.git", - "requires": { - "tweetnacl": "^1.0.0" - } - }, "emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", @@ -179,124 +125,6 @@ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" }, - "ethjs-abi": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/ethjs-abi/-/ethjs-abi-0.2.1.tgz", - "integrity": "sha1-4KepOn6BFjqUR3utVu3lJKtt5TM=", - "requires": { - "bn.js": "4.11.6", - "js-sha3": "0.5.5", - "number-to-bn": "1.7.0" - } - }, - "ethjs-contract": { - "version": "0.1.9", - "resolved": "https://registry.npmjs.org/ethjs-contract/-/ethjs-contract-0.1.9.tgz", - "integrity": "sha1-HCdmiWpW1H7B1tZhgpxJzDilUgo=", - "requires": { - "ethjs-abi": "0.2.0", - "ethjs-filter": "0.1.5", - "ethjs-util": "0.1.3", - "js-sha3": "0.5.5" - }, - "dependencies": { - "ethjs-abi": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/ethjs-abi/-/ethjs-abi-0.2.0.tgz", - "integrity": "sha1-0+LCIQEVIPxJm3FoIDbBT8wvWyU=", - "requires": { - "bn.js": "4.11.6", - "js-sha3": "0.5.5", - "number-to-bn": "1.7.0" - } - } - } - }, - "ethjs-filter": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/ethjs-filter/-/ethjs-filter-0.1.5.tgz", - "integrity": "sha1-ARKvYBfCRnfjK4/esg5hlgGbdZg=" - }, - "ethjs-format": { - "version": "0.2.7", - "resolved": "https://registry.npmjs.org/ethjs-format/-/ethjs-format-0.2.7.tgz", - "integrity": "sha512-uNYAi+r3/mvR3xYu2AfSXx5teP4ovy9z2FrRsblU+h2logsaIKZPi9V3bn3V7wuRcnG0HZ3QydgZuVaRo06C4Q==", - "requires": { - "bn.js": "4.11.6", - "ethjs-schema": "0.2.1", - "ethjs-util": "0.1.3", - "is-hex-prefixed": "1.0.0", - "number-to-bn": "1.7.0", - "strip-hex-prefix": "1.0.0" - } - }, - "ethjs-provider-http": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/ethjs-provider-http/-/ethjs-provider-http-0.1.6.tgz", - "integrity": "sha1-HsXZtL4lfvHValALIqdBmF6IlCA=", - "requires": { - "xhr2": "0.1.3" - } - }, - "ethjs-query": { - "version": "0.3.8", - "resolved": "https://registry.npmjs.org/ethjs-query/-/ethjs-query-0.3.8.tgz", - "integrity": "sha512-/J5JydqrOzU8O7VBOwZKUWXxHDGr46VqNjBCJgBVNNda+tv7Xc8Y2uJc6aMHHVbeN3YOQ7YRElgIc0q1CI02lQ==", - "requires": { - "babel-runtime": "^6.26.0", - "ethjs-format": "0.2.7", - "ethjs-rpc": "0.2.0", - "promise-to-callback": "^1.0.0" - } - }, - "ethjs-rpc": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/ethjs-rpc/-/ethjs-rpc-0.2.0.tgz", - "integrity": "sha512-RINulkNZTKnj4R/cjYYtYMnFFaBcVALzbtEJEONrrka8IeoarNB9Jbzn+2rT00Cv8y/CxAI+GgY1d0/i2iQeOg==", - "requires": { - "promise-to-callback": "^1.0.0" - } - }, - "ethjs-schema": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/ethjs-schema/-/ethjs-schema-0.2.1.tgz", - "integrity": "sha512-DXd8lwNrhT9sjsh/Vd2Z+4pfyGxhc0POVnLBUfwk5udtdoBzADyq+sK39dcb48+ZU+2VgtwHxtGWnLnCfmfW5g==" - }, - "ethjs-util": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/ethjs-util/-/ethjs-util-0.1.3.tgz", - "integrity": "sha1-39XqSkANxeQhqInK9H4IGtp4u1U=", - "requires": { - "is-hex-prefixed": "1.0.0", - "strip-hex-prefix": "1.0.0" - } - }, - "ethr-did-registry": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/ethr-did-registry/-/ethr-did-registry-0.0.3.tgz", - "integrity": "sha512-4BPvMGkxAK9vTduCq6D5b8ZqjteD2cvDIPPriXP6nnmPhWKFSxypo+AFvyQ0omJGa0cGTR+dkdI/8jiF7U/qaw==" - }, - "ethr-did-resolver": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/ethr-did-resolver/-/ethr-did-resolver-1.0.3.tgz", - "integrity": "sha512-9XtaB+4Ozc4W0gWHZ4J2HA+c+M7r0xcktmQI6v3GMjFto7b42Mq9zhh24kAxCqmtkqQhmUDJeqqSOIOwHrNbmQ==", - "requires": { - "buffer": "^5.1.0", - "did-resolver": "1.0.0", - "ethjs-abi": "^0.2.1", - "ethjs-contract": "^0.1.9", - "ethjs-provider-http": "^0.1.6", - "ethjs-query": "^0.3.5", - "ethr-did-registry": "^0.0.3" - }, - "dependencies": { - "did-resolver": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/did-resolver/-/did-resolver-1.0.0.tgz", - "integrity": "sha512-mgJG0oqlkG7jfRzW0yN9qKawp24M4thGFdfIaZI30SAJXhpkkjqbkRxqMZLJNwqXEM0cqFbXaiFDqnd9Q1UUaw==" - } - } - }, "external-editor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", @@ -328,11 +156,6 @@ "safer-buffer": ">= 2.1.2 < 3" } }, - "ieee754": { - "version": "1.1.13", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", - "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" - }, "inquirer": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.0.0.tgz", @@ -353,31 +176,16 @@ "through": "^2.3.6" } }, - "is-fn": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fn/-/is-fn-1.0.0.tgz", - "integrity": "sha1-lUPV3nvPWwiiLsiiC65uKG1RDYw=" - }, "is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" }, - "is-hex-prefixed": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz", - "integrity": "sha1-fY035q135dEnFIkTxXPggtd39VQ=" - }, "is-promise": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=" }, - "js-sha3": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.5.tgz", - "integrity": "sha1-uvDA6MVK1ZA0R9+Wreekobynmko=" - }, "lodash": { "version": "4.17.15", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", @@ -398,31 +206,6 @@ "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==" }, - "nacl-did": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/nacl-did/-/nacl-did-1.0.0.tgz", - "integrity": "sha512-HM2iJFRgw9+X4nNJjgWgRSKW7e+6t1LlH38HEz1Td9X6LmU4h/9PenN7ESDblQLZdPx+YG5yJdOV22tLVSDQ1Q==", - "requires": { - "did-resolver": "^1.0.0", - "ed2curve": "git+https://github.com/uport-project/ed2curve-js.git", - "tweetnacl": "^1.0.0", - "tweetnacl-util": "^0.15.0" - } - }, - "node-fetch": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", - "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" - }, - "number-to-bn": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/number-to-bn/-/number-to-bn-1.7.0.tgz", - "integrity": "sha1-uzYjWS9+X54AMLGXe9QaDFP+HqA=", - "requires": { - "bn.js": "4.11.6", - "strip-hex-prefix": "1.0.0" - } - }, "onetime": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.0.tgz", @@ -436,20 +219,6 @@ "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" }, - "promise-to-callback": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/promise-to-callback/-/promise-to-callback-1.0.0.tgz", - "integrity": "sha1-XSp0kBC/tn2WNZj805YHRqaP7vc=", - "requires": { - "is-fn": "^1.0.0", - "set-immediate-shim": "^1.0.1" - } - }, - "regenerator-runtime": { - "version": "0.11.1", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", - "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==" - }, "restore-cursor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", @@ -480,11 +249,6 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, - "set-immediate-shim": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", - "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=" - }, "signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", @@ -525,14 +289,6 @@ } } }, - "strip-hex-prefix": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-hex-prefix/-/strip-hex-prefix-1.0.0.tgz", - "integrity": "sha1-DF8VX+8RUTczd96du1iNoFUA428=", - "requires": { - "is-hex-prefixed": "1.0.0" - } - }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -559,16 +315,6 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" }, - "tweetnacl": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.1.tgz", - "integrity": "sha512-kcoMoKTPYnoeS50tzoqjPY3Uv9axeuuFAZY9M/9zFnhoVvRfxz9K29IMPD7jGmt2c8SW7i3gT9WqDl2+nV7p4A==" - }, - "tweetnacl-util": { - "version": "0.15.0", - "resolved": "https://registry.npmjs.org/tweetnacl-util/-/tweetnacl-util-0.15.0.tgz", - "integrity": "sha1-RXbBzuXi1j0gf+5S8boCgZSAvHU=" - }, "type-fest": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.5.2.tgz", @@ -579,32 +325,6 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz", "integrity": "sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==", "dev": true - }, - "web-did-resolver": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/web-did-resolver/-/web-did-resolver-1.2.0.tgz", - "integrity": "sha512-nTZHRVhjZpUazmZdkuV9M5UA8BpkRQRxoVw1UTd+hreLR+q/xeQsYs55eWTOr9jmPG1fePTrgXcoFVfkz1YCbQ==", - "requires": { - "cross-fetch": "^3.0.4", - "did-resolver": "1.0.0" - }, - "dependencies": { - "did-resolver": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/did-resolver/-/did-resolver-1.0.0.tgz", - "integrity": "sha512-mgJG0oqlkG7jfRzW0yN9qKawp24M4thGFdfIaZI30SAJXhpkkjqbkRxqMZLJNwqXEM0cqFbXaiFDqnd9Q1UUaw==" - } - } - }, - "whatwg-fetch": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz", - "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==" - }, - "xhr2": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/xhr2/-/xhr2-0.1.3.tgz", - "integrity": "sha1-y/xHWaabSoiOeM9PILBRA4dXvRE=" } } } diff --git a/packages/daf-cli/package.json b/packages/daf-cli/package.json index 9760ae9af..4b5745979 100644 --- a/packages/daf-cli/package.json +++ b/packages/daf-cli/package.json @@ -5,7 +5,7 @@ "main": "build/cli.js", "types": "build/cli.d.ts", "bin": { - "daf": "build/cli.js" + "daf": "bin/daf.js" }, "scripts": { "build": "tsc", @@ -21,16 +21,14 @@ "daf-did-jwt": "^0.0.18", "daf-ethr-did-fs": "^0.0.18", "daf-node-sqlite3": "^0.0.18", + "daf-resolver": "^0.0.18", + "daf-resolver-universal": "^0.0.18", "daf-selective-disclosure": "^0.0.18", "daf-sodium-fs": "^0.0.18", "daf-trust-graph": "^0.0.18", "daf-w3c": "^0.0.18", "debug": "^4.1.1", - "did-resolver": "^1.1.0", - "ethr-did-resolver": "^1.0.3", - "inquirer": "^7.0.0", - "nacl-did": "^1.0.0", - "web-did-resolver": "^1.2.0" + "inquirer": "^7.0.0" }, "devDependencies": { "@types/debug": "^4.1.5", @@ -38,6 +36,7 @@ "typescript": "^3.7.2" }, "files": [ + "bin/**/*", "build/**/*", "src/**/*", "README.md", diff --git a/packages/daf-cli/src/cli.ts b/packages/daf-cli/src/cli.ts index dc0a5edda..dc612732a 100644 --- a/packages/daf-cli/src/cli.ts +++ b/packages/daf-cli/src/cli.ts @@ -1,70 +1,9 @@ import Debug from 'debug' Debug.enable('*') -import { core, dataStore } from './setup' -import inquirer from 'inquirer' import program from 'commander' -import { printTable } from 'console-table-printer' - - -program - .command('identity-manager') - .description('Manage identities') - .option('-l, --list', 'List managed identities') - .option('-t, --types', 'List available identity controller types') - .option('-c, --create ', 'Create identity using identity controller') - .option('-d, --delete ', 'Create identity using identity controller') - .action(async (cmd) => { - if (cmd.types) { - const list = await core.identityManager.listTypes() - - if (list.length > 0) { - const types = list.map(item => ({ type: item })) - printTable(types) - } else { - console.log('No controllers') - } - } - - if (cmd.list) { - const list = await core.identityManager.listIssuers() - - if (list.length > 0) { - const dids = list.map(item => ({type: item.type, did: item.did})) - printTable(dids) - } else { - console.log('No dids') - } - } - - if (cmd.create) { - try { - const did = await core.identityManager.create(cmd.create) - printTable([{ type: cmd.create, did }]) - - } catch (e) { - console.error(e) - } - } - - if (cmd.delete) { - try { - const issuers = await core.identityManager.listIssuers() - const issuer = issuers.find(item => item.did === cmd.delete) - if (issuer) { - const result = await core.identityManager.delete(issuer.type, issuer.did) - console.log('Success:', result) - } else { - console.log('Did not found') - } - - } catch (e) { - console.error(e) - } - } - - - }) +import './identity-manager' +import './did-resolver' program.parse(process.argv) diff --git a/packages/daf-cli/src/did-resolver.ts b/packages/daf-cli/src/did-resolver.ts new file mode 100644 index 000000000..f293e155a --- /dev/null +++ b/packages/daf-cli/src/did-resolver.ts @@ -0,0 +1,15 @@ +import { core } from './setup' +import program from 'commander' + +program + .command('resolve ') + .description('Resolve DID Document') + .action(async (did) => { + try { + const ddo = await core.didResolver.resolve(did) + console.log(ddo) + } catch (e) { + console.error(e) + } + }) + \ No newline at end of file diff --git a/packages/daf-cli/src/identity-manager.ts b/packages/daf-cli/src/identity-manager.ts new file mode 100644 index 000000000..6d12bea0c --- /dev/null +++ b/packages/daf-cli/src/identity-manager.ts @@ -0,0 +1,65 @@ +import { core, dataStore } from './setup' +import inquirer from 'inquirer' +import program from 'commander' +import { printTable } from 'console-table-printer' + + +program + .command('identity-manager') + .description('Manage identities') + .option('-l, --list', 'List managed identities') + .option('-t, --types', 'List available identity controller types') + .option('-c, --create ', 'Create identity using identity controller') + .option('-d, --delete ', 'Create identity using identity controller') + .action(async (cmd) => { + if (cmd.types) { + const list = await core.identityManager.listTypes() + + if (list.length > 0) { + const types = list.map(item => ({ type: item })) + printTable(types) + } else { + console.log('No controllers') + } + } + + if (cmd.list) { + const list = await core.identityManager.listIssuers() + + if (list.length > 0) { + const dids = list.map(item => ({type: item.type, did: item.did})) + printTable(dids) + } else { + console.log('No dids') + } + } + + if (cmd.create) { + try { + const did = await core.identityManager.create(cmd.create) + printTable([{ type: cmd.create, did }]) + + } catch (e) { + console.error(e) + } + } + + if (cmd.delete) { + try { + const issuers = await core.identityManager.listIssuers() + const issuer = issuers.find(item => item.did === cmd.delete) + if (issuer) { + const result = await core.identityManager.delete(issuer.type, issuer.did) + console.log('Success:', result) + } else { + console.log('Did not found') + } + + } catch (e) { + console.error(e) + } + } + + + }) + \ No newline at end of file diff --git a/packages/daf-cli/src/setup.ts b/packages/daf-cli/src/setup.ts index ee5935c84..c4c091e25 100644 --- a/packages/daf-cli/src/setup.ts +++ b/packages/daf-cli/src/setup.ts @@ -1,7 +1,5 @@ -import { Resolver } 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' +import { DafResolver } from 'daf-resolver' +import { DafUniversalResolver } from 'daf-resolver-universal' import * as Daf from 'daf-core' import * as DidJwt from 'daf-did-jwt' @@ -23,9 +21,9 @@ const debug = Debug('main') const defaultPath = process.env.HOME + '/.daf' -const identityStoreFilename = process.env.DAF_IDENTITY_STORE ?? defaultPath + '/identity.json' -const dataStoreFilename = process.env.DAF_DATA_STORE ?? defaultPath + '/database.sqlite3' -const encryptionStoreFilename = process.env.DAF_ENCRYPTION_STORE ?? defaultPath + '/encryption.json' +const identityStoreFilename = process.env.DAF_IDENTITY_STORE ?? defaultPath + '/identity-store.json' +const dataStoreFilename = process.env.DAF_DATA_STORE ?? defaultPath + '/data-store.sqlite3' +const encryptionStoreFilename = process.env.DAF_ENCRYPTION_STORE ?? defaultPath + '/encryption-store.json' const infuraProjectId = process.env.DAF_INFURA_ID ?? '5ffc47f65c4042ce847ef66a3fa70d4c' if (!process.env.DAF_IDENTITY_STORE || process.env.DAF_DATA_STORE || process.env.DAF_ENCRYPTION_STORE) { @@ -36,14 +34,16 @@ if (!process.env.DAF_IDENTITY_STORE || process.env.DAF_DATA_STORE || process.env } // DID Document Resolver -const didResolver = new Resolver({ - ...ethrDidResolver({ - rpcUrl: 'https://mainnet.infura.io/v3/' + infuraProjectId, - }), - ...webDidResolver(), - nacl: naclDidResolver +let didResolver: Daf.Resolver = new DafResolver({ + infuraProjectId }) +if (process.env.DAF_UNIVERSAL_RESOLVER_URL) { + didResolver = new DafUniversalResolver({ + url: process.env.DAF_UNIVERSAL_RESOLVER_URL + }) +} + const identityControllers = [new EthrDidFsController(identityStoreFilename)] const messageValidator = new DBG.MessageValidator() diff --git a/packages/daf-cli/tsconfig.json b/packages/daf-cli/tsconfig.json index 031008bca..56f87999f 100644 --- a/packages/daf-cli/tsconfig.json +++ b/packages/daf-cli/tsconfig.json @@ -11,6 +11,8 @@ "daf-did-comm": ["../daf-did-comm"], "daf-did-jwt": ["../daf-did-jwt"], "daf-node-sqlite3": ["../daf-node-sqlite3"], + "daf-resolver": ["../daf-resolver"], + "daf-resolver-universal": ["../daf-resolver-universal"], "daf-selective-disclosure": ["../daf-selective-disclosure"], "daf-sodium-fs": ["../daf-sodium-fs"], "daf-trust-graph": ["../daf-trust-graph"], @@ -24,9 +26,16 @@ {"path": "../daf-did-comm"}, {"path": "../daf-did-jwt"}, {"path": "../daf-node-sqlite3"}, + {"path": "../daf-resolver"}, + {"path": "../daf-resolver-universal"}, {"path": "../daf-selective-disclosure"}, {"path": "../daf-sodium-fs"}, {"path": "../daf-trust-graph"}, {"path": "../daf-w3c"}, + ], + "exclude": [ + "**/__tests__/**/*", + "**/build/**/*", + "**/bin/**/*" ] } \ No newline at end of file diff --git a/packages/daf-core/src/core.ts b/packages/daf-core/src/core.ts index b4cfae4bd..f65943e97 100644 --- a/packages/daf-core/src/core.ts +++ b/packages/daf-core/src/core.ts @@ -1,5 +1,5 @@ import PubSub from 'pubsub-js' -import { Resolver } from 'did-resolver' +import { DIDDocument } from 'did-resolver' import { IdentityManager, IdentityController } from './identity-manager' import { ServiceManager, @@ -25,6 +25,10 @@ export const EventTypes = { error: 'error', } +export interface Resolver { + resolve(did: string): Promise +} + interface Config { didResolver: Resolver identityControllers: IdentityController[] diff --git a/packages/daf-core/src/index.ts b/packages/daf-core/src/index.ts index ec4da0a90..38cec8b41 100644 --- a/packages/daf-core/src/index.ts +++ b/packages/daf-core/src/index.ts @@ -1,4 +1,4 @@ -export { Core, EventTypes } from './core' +export { Core, EventTypes, Resolver } from './core' export { AbstractActionHandler } from './action-handler' export { EncryptionKeyManager, KeyPair } from './encryption-manager' export { IdentityController, IdentityManager, Issuer } from './identity-manager' diff --git a/packages/daf-core/src/service-manager.ts b/packages/daf-core/src/service-manager.ts index 267c0cc57..279ae69f8 100644 --- a/packages/daf-core/src/service-manager.ts +++ b/packages/daf-core/src/service-manager.ts @@ -1,4 +1,5 @@ -import { Resolver, DIDDocument } from 'did-resolver' +import { DIDDocument } from 'did-resolver' +import { Resolver } from './core' import { Issuer } from './identity-manager' import { RawMessage } from './types' diff --git a/packages/daf-did-jwt/src/message-validator.ts b/packages/daf-did-jwt/src/message-validator.ts index ed376b8e4..5f2cd2edc 100644 --- a/packages/daf-did-jwt/src/message-validator.ts +++ b/packages/daf-did-jwt/src/message-validator.ts @@ -1,5 +1,4 @@ -import { Core, AbstractMessageValidator, Types } from 'daf-core' -import { Resolver } from 'did-resolver' +import { Core, AbstractMessageValidator, Types, Resolver } from 'daf-core' import { verifyJWT, decodeJWT } from 'did-jwt' import Debug from 'debug' const debug = Debug('did-jwt-validator') diff --git a/packages/daf-resolver-universal/LICENSE b/packages/daf-resolver-universal/LICENSE new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/packages/daf-resolver-universal/LICENSE @@ -0,0 +1,201 @@ + 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 [yyyy] [name of copyright owner] + + 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 new file mode 100644 index 000000000..042af18e5 --- /dev/null +++ b/packages/daf-resolver-universal/README.md @@ -0,0 +1 @@ +# DAF DID Document resolver \ No newline at end of file diff --git a/packages/daf-resolver-universal/package-lock.json b/packages/daf-resolver-universal/package-lock.json new file mode 100644 index 000000000..82ea116bc --- /dev/null +++ b/packages/daf-resolver-universal/package-lock.json @@ -0,0 +1,52 @@ +{ + "name": "daf-resolver-universal", + "version": "0.0.18", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/debug": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.5.tgz", + "integrity": "sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ==", + "dev": true + }, + "cross-fetch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.0.4.tgz", + "integrity": "sha512-MSHgpjQqgbT/94D4CyADeNoYh52zMkCX4pcJvPP5WqPsLFMKjr2TCMg381ox5qI0ii2dPwaLx/00477knXqXVw==", + "requires": { + "node-fetch": "2.6.0", + "whatwg-fetch": "3.0.0" + } + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node-fetch": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", + "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" + }, + "typescript": { + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz", + "integrity": "sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==", + "dev": true + }, + "whatwg-fetch": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz", + "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==" + } + } +} diff --git a/packages/daf-resolver-universal/package.json b/packages/daf-resolver-universal/package.json new file mode 100644 index 000000000..a27abfb85 --- /dev/null +++ b/packages/daf-resolver-universal/package.json @@ -0,0 +1,29 @@ +{ + "name": "daf-resolver-universal", + "description": "DAF universal resolver", + "version": "0.0.18", + "main": "build/index.js", + "types": "build/index.d.ts", + "scripts": { + "build": "tsc" + }, + "dependencies": { + "debug": "^4.1.1", + "cross-fetch": "^3.0.4" + }, + "devDependencies": { + "@types/debug": "^4.1.5", + "typescript": "^3.7.2" + }, + "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/index.ts b/packages/daf-resolver-universal/src/index.ts new file mode 100644 index 000000000..ae6282568 --- /dev/null +++ b/packages/daf-resolver-universal/src/index.ts @@ -0,0 +1 @@ +export { DafUniversalResolver } from './resolver' \ No newline at end of file diff --git a/packages/daf-resolver-universal/src/resolver.ts b/packages/daf-resolver-universal/src/resolver.ts new file mode 100644 index 000000000..0247d5687 --- /dev/null +++ b/packages/daf-resolver-universal/src/resolver.ts @@ -0,0 +1,27 @@ +import 'cross-fetch/polyfill' +import Debug from 'debug' + +const debug = Debug('resolver-universal') + +interface Options { + url: string +} + +export class DafUniversalResolver { + private url: string + + constructor(options: Options) { + this.url = options.url + } + + async resolve(did: string) { + debug('Resolving %s', did) + try { + const result = await fetch(this.url + did) + 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 new file mode 100644 index 000000000..a6912085b --- /dev/null +++ b/packages/daf-resolver-universal/tsconfig.json @@ -0,0 +1,14 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build", + "baseUrl": ".", + "paths": { + "daf-core": ["../daf-core"] + } + }, + "references": [ + {"path": "../daf-core"} + ] +} \ No newline at end of file diff --git a/packages/daf-resolver/LICENSE b/packages/daf-resolver/LICENSE new file mode 100644 index 000000000..261eeb9e9 --- /dev/null +++ b/packages/daf-resolver/LICENSE @@ -0,0 +1,201 @@ + 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 [yyyy] [name of copyright owner] + + 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/README.md b/packages/daf-resolver/README.md new file mode 100644 index 000000000..042af18e5 --- /dev/null +++ b/packages/daf-resolver/README.md @@ -0,0 +1 @@ +# DAF DID Document resolver \ No newline at end of file diff --git a/packages/daf-resolver/package-lock.json b/packages/daf-resolver/package-lock.json new file mode 100644 index 000000000..1365af359 --- /dev/null +++ b/packages/daf-resolver/package-lock.json @@ -0,0 +1,313 @@ +{ + "name": "daf-resolver", + "version": "0.0.18", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/debug": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.5.tgz", + "integrity": "sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ==", + "dev": true + }, + "babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "requires": { + "core-js": "^2.4.0", + "regenerator-runtime": "^0.11.0" + } + }, + "base64-js": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", + "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==" + }, + "bn.js": { + "version": "4.11.6", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", + "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=" + }, + "buffer": { + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.4.3.tgz", + "integrity": "sha512-zvj65TkFeIt3i6aj5bIvJDzjjQQGs4o/sNoezg1F1kYap9Nu2jcUdpwzRSJTHMMzG0H7bZkn4rNQpImhuxWX2A==", + "requires": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4" + } + }, + "core-js": { + "version": "2.6.10", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.10.tgz", + "integrity": "sha512-I39t74+4t+zau64EN1fE5v2W31Adtc/REhzWN+gWRRXg6WH5qAsZm62DHpQ1+Yhe4047T55jvzz7MUqF/dBBlA==" + }, + "cross-fetch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.0.4.tgz", + "integrity": "sha512-MSHgpjQqgbT/94D4CyADeNoYh52zMkCX4pcJvPP5WqPsLFMKjr2TCMg381ox5qI0ii2dPwaLx/00477knXqXVw==", + "requires": { + "node-fetch": "2.6.0", + "whatwg-fetch": "3.0.0" + } + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "requires": { + "ms": "^2.1.1" + } + }, + "did-resolver": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/did-resolver/-/did-resolver-1.1.0.tgz", + "integrity": "sha512-Q02Sc5VuQnJzzR8fQ/DzyCHiYb31WpQdocOsxppI66wwT4XalYRDeCr3a48mL6sYPQo76AkBh0mxte9ZBuQzxA==" + }, + "ed2curve": { + "version": "git+https://github.com/uport-project/ed2curve-js.git#0eed8c601a5ad48e8bec1c61c335acac5428f51c", + "from": "git+https://github.com/uport-project/ed2curve-js.git", + "requires": { + "tweetnacl": "^1.0.0" + } + }, + "ethjs-abi": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/ethjs-abi/-/ethjs-abi-0.2.1.tgz", + "integrity": "sha1-4KepOn6BFjqUR3utVu3lJKtt5TM=", + "requires": { + "bn.js": "4.11.6", + "js-sha3": "0.5.5", + "number-to-bn": "1.7.0" + } + }, + "ethjs-contract": { + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/ethjs-contract/-/ethjs-contract-0.1.9.tgz", + "integrity": "sha1-HCdmiWpW1H7B1tZhgpxJzDilUgo=", + "requires": { + "ethjs-abi": "0.2.0", + "ethjs-filter": "0.1.5", + "ethjs-util": "0.1.3", + "js-sha3": "0.5.5" + }, + "dependencies": { + "ethjs-abi": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/ethjs-abi/-/ethjs-abi-0.2.0.tgz", + "integrity": "sha1-0+LCIQEVIPxJm3FoIDbBT8wvWyU=", + "requires": { + "bn.js": "4.11.6", + "js-sha3": "0.5.5", + "number-to-bn": "1.7.0" + } + } + } + }, + "ethjs-filter": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/ethjs-filter/-/ethjs-filter-0.1.5.tgz", + "integrity": "sha1-ARKvYBfCRnfjK4/esg5hlgGbdZg=" + }, + "ethjs-format": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/ethjs-format/-/ethjs-format-0.2.7.tgz", + "integrity": "sha512-uNYAi+r3/mvR3xYu2AfSXx5teP4ovy9z2FrRsblU+h2logsaIKZPi9V3bn3V7wuRcnG0HZ3QydgZuVaRo06C4Q==", + "requires": { + "bn.js": "4.11.6", + "ethjs-schema": "0.2.1", + "ethjs-util": "0.1.3", + "is-hex-prefixed": "1.0.0", + "number-to-bn": "1.7.0", + "strip-hex-prefix": "1.0.0" + } + }, + "ethjs-provider-http": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/ethjs-provider-http/-/ethjs-provider-http-0.1.6.tgz", + "integrity": "sha1-HsXZtL4lfvHValALIqdBmF6IlCA=", + "requires": { + "xhr2": "0.1.3" + } + }, + "ethjs-query": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/ethjs-query/-/ethjs-query-0.3.8.tgz", + "integrity": "sha512-/J5JydqrOzU8O7VBOwZKUWXxHDGr46VqNjBCJgBVNNda+tv7Xc8Y2uJc6aMHHVbeN3YOQ7YRElgIc0q1CI02lQ==", + "requires": { + "babel-runtime": "^6.26.0", + "ethjs-format": "0.2.7", + "ethjs-rpc": "0.2.0", + "promise-to-callback": "^1.0.0" + } + }, + "ethjs-rpc": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/ethjs-rpc/-/ethjs-rpc-0.2.0.tgz", + "integrity": "sha512-RINulkNZTKnj4R/cjYYtYMnFFaBcVALzbtEJEONrrka8IeoarNB9Jbzn+2rT00Cv8y/CxAI+GgY1d0/i2iQeOg==", + "requires": { + "promise-to-callback": "^1.0.0" + } + }, + "ethjs-schema": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/ethjs-schema/-/ethjs-schema-0.2.1.tgz", + "integrity": "sha512-DXd8lwNrhT9sjsh/Vd2Z+4pfyGxhc0POVnLBUfwk5udtdoBzADyq+sK39dcb48+ZU+2VgtwHxtGWnLnCfmfW5g==" + }, + "ethjs-util": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/ethjs-util/-/ethjs-util-0.1.3.tgz", + "integrity": "sha1-39XqSkANxeQhqInK9H4IGtp4u1U=", + "requires": { + "is-hex-prefixed": "1.0.0", + "strip-hex-prefix": "1.0.0" + } + }, + "ethr-did-registry": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/ethr-did-registry/-/ethr-did-registry-0.0.3.tgz", + "integrity": "sha512-4BPvMGkxAK9vTduCq6D5b8ZqjteD2cvDIPPriXP6nnmPhWKFSxypo+AFvyQ0omJGa0cGTR+dkdI/8jiF7U/qaw==" + }, + "ethr-did-resolver": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/ethr-did-resolver/-/ethr-did-resolver-1.0.3.tgz", + "integrity": "sha512-9XtaB+4Ozc4W0gWHZ4J2HA+c+M7r0xcktmQI6v3GMjFto7b42Mq9zhh24kAxCqmtkqQhmUDJeqqSOIOwHrNbmQ==", + "requires": { + "buffer": "^5.1.0", + "did-resolver": "1.0.0", + "ethjs-abi": "^0.2.1", + "ethjs-contract": "^0.1.9", + "ethjs-provider-http": "^0.1.6", + "ethjs-query": "^0.3.5", + "ethr-did-registry": "^0.0.3" + }, + "dependencies": { + "did-resolver": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/did-resolver/-/did-resolver-1.0.0.tgz", + "integrity": "sha512-mgJG0oqlkG7jfRzW0yN9qKawp24M4thGFdfIaZI30SAJXhpkkjqbkRxqMZLJNwqXEM0cqFbXaiFDqnd9Q1UUaw==" + } + } + }, + "ieee754": { + "version": "1.1.13", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", + "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" + }, + "is-fn": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fn/-/is-fn-1.0.0.tgz", + "integrity": "sha1-lUPV3nvPWwiiLsiiC65uKG1RDYw=" + }, + "is-hex-prefixed": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz", + "integrity": "sha1-fY035q135dEnFIkTxXPggtd39VQ=" + }, + "js-sha3": { + "version": "0.5.5", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.5.5.tgz", + "integrity": "sha1-uvDA6MVK1ZA0R9+Wreekobynmko=" + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "nacl-did": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/nacl-did/-/nacl-did-1.0.0.tgz", + "integrity": "sha512-HM2iJFRgw9+X4nNJjgWgRSKW7e+6t1LlH38HEz1Td9X6LmU4h/9PenN7ESDblQLZdPx+YG5yJdOV22tLVSDQ1Q==", + "requires": { + "did-resolver": "^1.0.0", + "ed2curve": "git+https://github.com/uport-project/ed2curve-js.git", + "tweetnacl": "^1.0.0", + "tweetnacl-util": "^0.15.0" + } + }, + "node-fetch": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", + "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" + }, + "number-to-bn": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/number-to-bn/-/number-to-bn-1.7.0.tgz", + "integrity": "sha1-uzYjWS9+X54AMLGXe9QaDFP+HqA=", + "requires": { + "bn.js": "4.11.6", + "strip-hex-prefix": "1.0.0" + } + }, + "promise-to-callback": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/promise-to-callback/-/promise-to-callback-1.0.0.tgz", + "integrity": "sha1-XSp0kBC/tn2WNZj805YHRqaP7vc=", + "requires": { + "is-fn": "^1.0.0", + "set-immediate-shim": "^1.0.1" + } + }, + "regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==" + }, + "set-immediate-shim": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", + "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=" + }, + "strip-hex-prefix": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-hex-prefix/-/strip-hex-prefix-1.0.0.tgz", + "integrity": "sha1-DF8VX+8RUTczd96du1iNoFUA428=", + "requires": { + "is-hex-prefixed": "1.0.0" + } + }, + "tweetnacl": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.1.tgz", + "integrity": "sha512-kcoMoKTPYnoeS50tzoqjPY3Uv9axeuuFAZY9M/9zFnhoVvRfxz9K29IMPD7jGmt2c8SW7i3gT9WqDl2+nV7p4A==" + }, + "tweetnacl-util": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/tweetnacl-util/-/tweetnacl-util-0.15.0.tgz", + "integrity": "sha1-RXbBzuXi1j0gf+5S8boCgZSAvHU=" + }, + "typescript": { + "version": "3.7.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.2.tgz", + "integrity": "sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==", + "dev": true + }, + "web-did-resolver": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/web-did-resolver/-/web-did-resolver-1.2.0.tgz", + "integrity": "sha512-nTZHRVhjZpUazmZdkuV9M5UA8BpkRQRxoVw1UTd+hreLR+q/xeQsYs55eWTOr9jmPG1fePTrgXcoFVfkz1YCbQ==", + "requires": { + "cross-fetch": "^3.0.4", + "did-resolver": "1.0.0" + }, + "dependencies": { + "did-resolver": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/did-resolver/-/did-resolver-1.0.0.tgz", + "integrity": "sha512-mgJG0oqlkG7jfRzW0yN9qKawp24M4thGFdfIaZI30SAJXhpkkjqbkRxqMZLJNwqXEM0cqFbXaiFDqnd9Q1UUaw==" + } + } + }, + "whatwg-fetch": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz", + "integrity": "sha512-9GSJUgz1D4MfyKU7KRqwOjXCXTqWdFNvEr7eUBYchQiVc744mqK/MzXPNR2WsPkmkOa4ywfg8C2n8h+13Bey1Q==" + }, + "xhr2": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/xhr2/-/xhr2-0.1.3.tgz", + "integrity": "sha1-y/xHWaabSoiOeM9PILBRA4dXvRE=" + } + } +} diff --git a/packages/daf-resolver/package.json b/packages/daf-resolver/package.json new file mode 100644 index 000000000..df5a557b5 --- /dev/null +++ b/packages/daf-resolver/package.json @@ -0,0 +1,32 @@ +{ + "name": "daf-resolver", + "description": "DAF resolver", + "version": "0.0.18", + "main": "build/index.js", + "types": "build/index.d.ts", + "scripts": { + "build": "tsc" + }, + "dependencies": { + "debug": "^4.1.1", + "did-resolver": "^1.1.0", + "ethr-did-resolver": "^1.0.3", + "nacl-did": "^1.0.0", + "web-did-resolver": "^1.2.0" + }, + "devDependencies": { + "@types/debug": "^4.1.5", + "typescript": "^3.7.2" + }, + "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/src/index.ts b/packages/daf-resolver/src/index.ts new file mode 100644 index 000000000..76c750970 --- /dev/null +++ b/packages/daf-resolver/src/index.ts @@ -0,0 +1 @@ +export { DafResolver } from './resolver' \ No newline at end of file diff --git a/packages/daf-resolver/src/resolver.ts b/packages/daf-resolver/src/resolver.ts new file mode 100644 index 000000000..c4a764ba1 --- /dev/null +++ b/packages/daf-resolver/src/resolver.ts @@ -0,0 +1,30 @@ +import { Resolver } 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' +import Debug from 'debug' + +const debug = Debug('resolver') + +interface Options { + infuraProjectId: string +} + +export class DafResolver { + private didResolver: Resolver + + constructor(options: Options) { + this.didResolver = new Resolver({ + ...ethrDidResolver({ + rpcUrl: 'https://mainnet.infura.io/v3/' + options.infuraProjectId, + }), + ...webDidResolver(), + nacl: naclDidResolver + }) + } + + async resolve(did: string) { + debug('Resolving %s', did) + return this.didResolver.resolve(did) + } +} diff --git a/packages/daf-resolver/tsconfig.json b/packages/daf-resolver/tsconfig.json new file mode 100644 index 000000000..a6912085b --- /dev/null +++ b/packages/daf-resolver/tsconfig.json @@ -0,0 +1,14 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build", + "baseUrl": ".", + "paths": { + "daf-core": ["../daf-core"] + } + }, + "references": [ + {"path": "../daf-core"} + ] +} \ No newline at end of file diff --git a/packages/daf-cli/types/ethr-did-resolver/index.d.ts b/packages/daf-resolver/types/ethr-did-resolver/index.d.ts similarity index 100% rename from packages/daf-cli/types/ethr-did-resolver/index.d.ts rename to packages/daf-resolver/types/ethr-did-resolver/index.d.ts diff --git a/packages/daf-selective-disclosure/src/payload-validator.ts b/packages/daf-selective-disclosure/src/payload-validator.ts index 5010e9210..8e7b8a838 100644 --- a/packages/daf-selective-disclosure/src/payload-validator.ts +++ b/packages/daf-selective-disclosure/src/payload-validator.ts @@ -1,6 +1,5 @@ import { DidJwtPayloadValidator } from 'daf-did-jwt' -import { Types } from 'daf-core' -import { Resolver } from 'did-resolver' +import { Types, Resolver } from 'daf-core' import Debug from 'debug' const debug = Debug('sdr-validator') diff --git a/packages/daf-w3c/src/payload-validator.ts b/packages/daf-w3c/src/payload-validator.ts index 2056c5dd3..a2c6a1394 100644 --- a/packages/daf-w3c/src/payload-validator.ts +++ b/packages/daf-w3c/src/payload-validator.ts @@ -1,6 +1,5 @@ import { DidJwtPayloadValidator } from 'daf-did-jwt' -import { Types } from 'daf-core' -import { Resolver } from 'did-resolver' +import { Types, Resolver } from 'daf-core' import { verifyCredential, validateVerifiableCredentialAttributes, @@ -27,7 +26,7 @@ export class PayloadValidator implements DidJwtPayloadValidator { const vc = await Promise.all( verifiedJwt.payload.vp.verifiableCredential.map((vcJwt: string) => - verifyCredential(vcJwt, didResolver), + verifyCredential(vcJwt, didResolver ), ), )