New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@windingtree/org.id-resolver

Package Overview
Dependencies
Maintainers
3
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@windingtree/org.id-resolver

ORGiD DID resolver

  • 2.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-83.33%
Maintainers
3
Weekly downloads
 
Created
Source

Build Status Coverage Status

ORG.ID

ORG.ID DID Resolver

ORG.ID DID Resolver is an application for resolving ORG.ID data in W3C DID format.

Usage

Command Line

git clone git@github.com:windingtree/org.id-resolver.git
cd org.id-resolver
npm i
npm link
chmod +x src/cli.js
./src/cli.js endpoint=<WEB3_PROVIDER> orgid=<ORGID_ADDRESS> did=did:orgid:0x6d98103810d50b3711ea81c187a48245109ba094644ddbc54f8d0c4c

NPM Module

npm i @windingtree/org.id-resolver
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:
  4. Try to resolve assertions and credentials

The response of the resolver contains the following information

{
    // 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:

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:

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

npm run test
npm run test ./<path_to_test_file>.js

Test coverage

npm run coverage

Lint

npm run lint

ORG.ID Ecosystem

  • Winding Tree DAO controls ORG.ID Registry smart contract and some Directories (including their rules)
  • ORG.ID Registry contains records of all organizations and organizational units
  • ORG.JSON Schema is a data format for describing organizations
  • ORG.ID Resolver (you are here)
  • ORG.ID Directories are curated lists of organizations
  • Arbor can be used to look up an ORG.ID, and also to create and manage your own ORG.ID

Keywords

FAQs

Package last updated on 21 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc