@windingtree/org.id-resolver
Advanced tools
Comparing version 3.0.0-beta.3 to 3.0.0-beta.5
{ | ||
"name": "@windingtree/org.id-resolver", | ||
"version": "3.0.0-beta.2", | ||
"version": "3.0.0-beta.4", | ||
"description": "ORGiD DID resolver", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"main": "dist/src/index.js", | ||
"types": "dist/src/index.d.ts", | ||
"files": [ | ||
@@ -36,5 +36,5 @@ "dist" | ||
"@windingtree/org.id": "3.0.0-beta.6", | ||
"@windingtree/org.id-auth": "1.0.0-beta.22", | ||
"@windingtree/org.id-core": "1.0.0-beta.22", | ||
"@windingtree/org.id-utils": "1.0.0-beta.22", | ||
"@windingtree/org.id-auth": "1.0.0-beta.23", | ||
"@windingtree/org.id-core": "1.0.0-beta.23", | ||
"@windingtree/org.id-utils": "1.0.0-beta.23", | ||
"@windingtree/org.json-schema": "1.0.0-beta.5", | ||
@@ -51,3 +51,3 @@ "ethers": "5.5.1", | ||
"@types/mocha": "9.0.0", | ||
"@windingtree/org.id-test-setup": "1.0.0-beta.22", | ||
"@windingtree/org.id-test-setup": "1.0.0-beta.23", | ||
"chai": "4.3.4", | ||
@@ -54,0 +54,0 @@ "chai-as-promised": "7.1.1", |
{ | ||
"name": "@windingtree/org.id-resolver", | ||
"version": "3.0.0-beta.3", | ||
"version": "3.0.0-beta.5", | ||
"description": "ORGiD DID resolver", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"main": "dist/src/index.js", | ||
"types": "dist/src/index.d.ts", | ||
"files": [ | ||
@@ -36,5 +36,5 @@ "dist" | ||
"@windingtree/org.id": "3.0.0-beta.6", | ||
"@windingtree/org.id-auth": "1.0.0-beta.22", | ||
"@windingtree/org.id-core": "1.0.0-beta.22", | ||
"@windingtree/org.id-utils": "1.0.0-beta.22", | ||
"@windingtree/org.id-auth": "1.0.0-beta.23", | ||
"@windingtree/org.id-core": "1.0.0-beta.23", | ||
"@windingtree/org.id-utils": "1.0.0-beta.23", | ||
"@windingtree/org.json-schema": "1.0.0-beta.5", | ||
@@ -51,3 +51,3 @@ "ethers": "5.5.1", | ||
"@types/mocha": "9.0.0", | ||
"@windingtree/org.id-test-setup": "1.0.0-beta.22", | ||
"@windingtree/org.id-test-setup": "1.0.0-beta.23", | ||
"chai": "4.3.4", | ||
@@ -61,3 +61,3 @@ "chai-as-promised": "7.1.1", | ||
}, | ||
"gitHead": "6922711dbb7dd2ec3dd77b8948aa35a840fcaa1d" | ||
"gitHead": "cfe5c9afa432c23972f8f7658bd99ee93fc67bd1" | ||
} |
234
README.md
[](https://travis-ci.org/windingtree/org.id-resolver) | ||
[](https://coveralls.io/github/windingtree/org.id-resolver?branch=master&v=2.0) | ||
<a href="https://orgid.tech"><img src="https://github.com/windingtree/branding/raw/master/org.id/svg/org.id-logo.svg" height="50" alt="ORG.ID"></a> | ||
# ORGiD DID Resolver | ||
## ORG.ID DID Resolver | ||
A utility for ORGiD DID resolution according to [Decentralized Identifier Resolution](https://w3c-ccg.github.io/did-resolution/) specification. | ||
ORG.ID DID Resolver is an application for resolving ORG.ID data in [W3C DID](https://w3c.github.io/did-core/) format. | ||
## Documentation | ||
## Usage | ||
- [ORGiD DID resolver documentation](docs/index.md) | ||
- [ORGiD SDK documentation](https://windingtree.github.io/org.id-sdk/) | ||
### Command Line | ||
## Setup | ||
```sh | ||
git clone git@github.com:windingtree/org.id-resolver.git | ||
cd org.id-resolver | ||
npm i | ||
npm link | ||
chmod +x src/cli.js | ||
```bash | ||
yarn install | ||
``` | ||
```sh | ||
./src/cli.js endpoint=<WEB3_PROVIDER> orgid=<ORGID_ADDRESS> did=did:orgid:0x6d98103810d50b3711ea81c187a48245109ba094644ddbc54f8d0c4c | ||
``` | ||
## Build | ||
### NPM Module | ||
```sh | ||
npm i @windingtree/org.id-resolver | ||
``` | ||
```javascript | ||
const Web3 = require('web3'); | ||
const { | ||
OrgIdResolver, | ||
httpFetchMethod, | ||
linkedInFetchMethod, | ||
twitterFetchMethod, | ||
whoisService | ||
} = require('@windingtree/org.id-resolver'); | ||
const web3 = new Web3('<WEB3_PROVIDER>'); // HTTP(s) or WS(s) | ||
const resolver = new OrgIdResolver({ | ||
web3, | ||
orgId: '<ORGID_ADDRESS>', // TODO: #3 | ||
authorizedTrustProofsIssuers: [ | ||
'did:orgid:0x52f750...' // These DIDs will be allowed to be used as issuers and verifiers for the Trust proofs issuing in form of Verifiable Credentials | ||
] | ||
}); | ||
resolver.registerSocialFetchMethod(linkedInFetchMethod, { | ||
key: '<LINKEDIN_API_KEY>' | ||
}); | ||
resolver.registerSocialFetchMethod(twitterFetchMethod, { | ||
key: '<TWITTER_API_KEY>' | ||
}); | ||
resolver.registerFetchMethod(httpFetchMethod); | ||
resolver.registerService(whoisService); | ||
const result = await resolver.resolve('did:orgid:0x62a7502f4c44d8147b8f7b2a1dbeb8503e8446e77355bb2e4ebf999c7ecc5808'); | ||
``` | ||
## Algorithm | ||
1. Validate DID syntax (must be `did:orgid:bytes32`) | ||
2. Read organization data from ORG.ID Registry | ||
3. Fetch and validate [ORG.JSON](https://github.com/windingtree/org.json-schema): | ||
4. Try to resolve assertions and credentials | ||
The response of the resolver contains the following information | ||
```json | ||
{ | ||
// An object that has been resolved from the given DID. | ||
// Can be equal to `null` if JSON file not passed hashes equality check | ||
// or if the file is not passed validation against the ORG.ID schema | ||
"didDocument": {...}, | ||
// Organization identifier | ||
"id": "<organization_id>", | ||
"organization": { | ||
"orgId": "<organization_id>", | ||
"orgJsonHash": "<organization_json_hash>", | ||
"orgJsonUri": "<organization_json_uri>", | ||
"orgJsonUriBackup1": "<organization_json_uri>", | ||
"orgJsonUriBackup2": "<organization_json_uri>", | ||
"parentOrgId": "<parent_organization_hash_or_zero_hash>", | ||
"owner": "<owner_eth_address>", | ||
"director": "<director_eth_address>", | ||
"isActive": true,// true for `enabled` and false for `disabled` | ||
"isDirectorshipAccepted": true,// director confirmation status | ||
}, | ||
// List of validation results | ||
"checks": [ | ||
{ | ||
"type": "DID_SYNTAX", | ||
"passed": true, | ||
"errors": [], | ||
"warnings": [] | ||
}, | ||
{ | ||
"type": "ORGID", | ||
"passed": true, | ||
"errors": [], | ||
"warnings": [] | ||
}, | ||
{ | ||
"type": "DID_DOCUMENT", | ||
"passed": true, | ||
"errors": [], | ||
"warnings": [] | ||
}, | ||
{ | ||
"type": "TRUST_ASSERTIONS", | ||
"passed": true | ||
} | ||
], | ||
// Verified trust section of the `didDocument` | ||
"trust": { | ||
"assertions": [ | ||
{ | ||
"type": "dns", | ||
"claim": "test.com", | ||
"proof": "TXT", | ||
"verified": true | ||
}, | ||
{ | ||
"type": "domain", | ||
"claim": "test2.com", | ||
"proof": "http://test2.com/orgid.txt", | ||
"verified": true, | ||
"whois": { | ||
"domainName": "TEST2.COM", | ||
"registryDomainId": "1234567_DOMAIN_COM-VRSN", | ||
"registrarWhoisServer": "whois.server.net", | ||
"registrarUrl": "http://www.whois.net", | ||
"updatedDate": "2021-03-22T05:01:08Z", | ||
"creationDate": "2011-05-09T18:58:13Z", | ||
"expiryDate": "2024-05-09T18:58:13Z", | ||
"registrar": "Cool Domain", | ||
"registrarIanaId": "345", | ||
"registrarAbuseContactEmail": "abuse@support.server.net", | ||
"registrarAbuseContactPhone": "+33.1234567", | ||
"domainStatus": "clientTransferProhibited", | ||
"nameServer": "NS.SERVER.COM", | ||
"DNSSEC": "unsigned" | ||
} | ||
}, | ||
{ | ||
"type": "domain", | ||
"claim": "test3.com", | ||
"proof": "http://test3.com/orgid.txt", | ||
"verified": false // Not verified | ||
}, | ||
{ | ||
"type": "social", | ||
"claim": "twitter.com/jack", | ||
"proof": "https://twitter.com/jack/status/123456789/", | ||
"verified": true | ||
} | ||
] | ||
}, | ||
// Resolver meta-data like version, date of result and process duration | ||
"resolverMetadata": { | ||
"version": "2.0.0", | ||
"retrieved": "2020-02-21T18:14:13.278Z", | ||
"duration": 979, | ||
"orgIdAddress": "0x2cb8dCf26830B969555E04C2EDe3fc1D1BaD504E" | ||
} | ||
} | ||
``` | ||
## Fetching methods | ||
At least one fetching method is required to the proper working of the resolver. | ||
This library provides a simple fetching method of a file that available via http/https - `httpFetchMethod`. | ||
To use this method you can get its configuration from the package this way: | ||
```javascript | ||
const { OrgIdResolver, httpFetchMethod } = require('@windingtree/org.id-resolver'); | ||
const resolver = new OrgIdResolver({...}); | ||
resolver.registerFetchMethod(httpFetchMethod);// fetching method should be registered | ||
``` | ||
Future versions of `DID resolver` library will support more fetching methods like: | ||
IPFS, Swarm and Arweave | ||
Creation of custom fetching methods is quite simple task. Look at the example of simple fetching method configuration: | ||
```javascript | ||
module.exports = { | ||
name: 'unique_method_name', | ||
// Regexp to match your URI schema | ||
pattern: '^yourpatternrule:', | ||
fetch: async uri => { | ||
const data = await yourCustomHandler(uri); | ||
return data; | ||
} | ||
}; | ||
``` | ||
## Development | ||
### Test | ||
```sh | ||
npm run test | ||
npm run test ./<path_to_test_file>.js | ||
``` | ||
## Test coverage | ||
```bash | ||
npm run coverage | ||
yarn build | ||
``` | ||
## Lint | ||
## Linting & Testing | ||
```bash | ||
npm run lint | ||
yarn lint | ||
yarn test | ||
``` | ||
## ORG.ID Ecosystem | ||
- [Winding Tree DAO](https://github.com/windingtree/dao) controls ORG.ID Registry smart contract and some Directories (including their rules) | ||
- [ORG.ID Registry](https://github.com/windingtree/org.id) contains records of all organizations and organizational units | ||
- [ORG.JSON Schema](https://github.com/windingtree/org.json-schema) is a data format for describing organizations | ||
- **ORG.ID Resolver (you are here)** | ||
- [ORG.ID Directories](https://github.com/windingtree/org.id-directories) are curated lists of organizations | ||
- [Arbor](https://arbor.fm) can be used to look up an ORG.ID, and also to create and manage your own ORG.ID |
36192
30
+ Added@windingtree/org.id-auth@1.0.0-beta.23(transitive)
+ Added@windingtree/org.id-core@1.0.0-beta.23(transitive)
+ Added@windingtree/org.id-utils@1.0.0-beta.23(transitive)
- Removed@windingtree/org.id-auth@1.0.0-beta.22(transitive)
- Removed@windingtree/org.id-core@1.0.0-beta.22(transitive)
- Removed@windingtree/org.id-utils@1.0.0-beta.22(transitive)