项目作者: AraBlocks

项目描述 :
Decentralized Identity (DID) URI parser and formatter
高级语言: JavaScript
项目地址: git://github.com/AraBlocks/did-uri.git
创建时间: 2018-04-25T17:41:24Z
项目社区:https://github.com/AraBlocks/did-uri

开源协议:MIT License

下载


did-uri

Decentralized Identity (DID) URI parser and formatter.

Abstract

In this module we provide a w3 compliant interface for parsing and serializing
Decentralized Identity (DID) URIs
as specified by Decentralized
Identifiers

specification. This module provides an interface similar to that of the
url module in the Node standard library.

Installation

  1. $ npm install did-uri

Example Usage

  1. const did = require('did-uri')
  2. const spec = did.parse('did:ara:68656c6c6f/music?key=mk706c6179206d65')
  3. console.log(spec)

outputs:

  1. { reference: 'did:ara:68656c6c6f/music?key=mk706c6179206d65',
  2. did: 'did:ara:68656c6c6f',
  3. method: 'ara',
  4. identifier: '68656c6c6f',
  5. path: '/music',
  6. fragment: '',
  7. query: 'key=mk706c6179206d65',
  8. param: '' }

API

parsed = did.parse(uri)

Parses a given DID uri and returns an object similar to a DID
instance.

formated = did.format(obj)

Formats a given DID URI or object into a normalized formatted URI.

did = new DID(uri [,base])

Parses and creates a new DID instance.

did.reference

A reference to the uri that was parsed as input.

did.did

The component of the URI containing the protocol, method, and
identifier in the form of did:method:identifier.

did.method

The method component of the URI.

did.identifier

The identifier component of the URI.

did.param

The param (;) component of the URI.

did.path

The path component of the URI.

did.fragment

The fragment (#) component of the URI.

did.query

The query (?) component of the URI.

did.parameters

The param string component of the URI parsed into an object.

did.queryParameters

The query string component of the URI parsed into an object.

did.fragmentParameters

The fragment string component of the URI parsed into an object.

See Also

License

MIT