Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

didjs

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

didjs

Decentralized Identifiers parser for javascript

  • 0.0.4
  • latest
  • npm
  • Socket score

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

didjs

didjs is a javascript package that parses and stringifies Decentralized Identifiers (DIDs).

Install

yarn add didjs

or

<script type="text/javascript" src="./dist/didjs.min.js"></script>

Example

import * as didjs from 'didjs'

const d = didjs.parse('did:example:1234567890/asdf/qwerty')
console.log(d)

The above example parses the input string according to the rules defined in the DID Grammar and prints the following object:

{
    id: "1234567890",
    idStrings: ["1234567890"],
    method: "example",
    path: "asdf/qwerty",
    pathSegments: ["asdf", "qwerty"]
}

The input string may also be a DID Reference with a DID Fragment:

const d = didjs.parse("did:example:1234567890#keys-1")
console.log(d.fragment)
// Output: keys-1

This package also stringifies DID objects into valid DID strings:

const d = {
    method: 'example',
    id: '1234567890'
}
console.log(didjs.stringify(d))
// Output: did:example:1234567890

or with a refence with a fragment:

const d = {
    method: 'example',
    id: '1234567890',
    fragment: 'keys-1'
}
console.log(didjs.stringify(d))
// Output: did:example:1234567890#keys-1

Build

To compile the code in this repository, run:

webpack

Test

This repository includes a suite of tests that check for various edge cases within the DID Grammar.

To run the tests, run:

npm run test

License

This package is licensed under Apache License 2.0.

Keywords

FAQs

Package last updated on 29 May 2019

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