npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@yourd/did-parser

v1.0.3

Published

The `@yourd/did-parser` is a sophisticated library meticulously crafted for parsing and managing Decentralized Identifiers (DIDs). Its core foundation is built upon the esteemed DID specification standards set by the **W3C**.

Downloads

53

Readme

@yourd/did-parser: A Decentralized Identifier (DID) Parser

The @yourd/did-parser is a sophisticated library meticulously crafted for parsing and managing Decentralized Identifiers (DIDs). Its core foundation is built upon the esteemed DID specification standards set by the W3C.

📌 Key Features:

  • Precision in Parsing: Harnesses advanced algorithms to ensure accurate DID parsing.
  • W3C Conformance: Adheres strictly to the DID Core Specification by W3C, guaranteeing reliability and industry-standard compliance.
  • Flexible and Robust: Designed to accommodate various DID structures while maintaining robustness.

📘 For those keen on understanding the intricacies of the DID specification, we recommend diving into the official W3C documentation.

Table of Contents

Introduction

Decentralized Identifiers (DIDs) are a new type of identifier for verifiable, self-sovereign digital identities. DIDs are fully under the control of the DID subject, independent from any centralized registry, authority, or intermediary.

The @yourd/did-parser aims to provide a robust solution for applications and systems to correctly interpret and handle these identifiers.

Installation

npm install @yourd/did-parser

or

yarn add @yourd/did-parser

Supported DID Syntax

According to the DID specification, the general syntax of a DID is:

did:[method-name]:[method-specific-id]

did is a fixed string.

  • [method-name] is a string that specifies the DID method. It is case-insensitive and must be a string from the set of lowercase alphanumeric characters.
  • [method-specific-id] is a method-specific identifier. The yourdi-parser ensures that DIDs are correctly parsed and validated based on the above syntax.

Specifications:

  • did: A constant string that indicates the identifier is a DID.
  • [method-name]: Specifies the DID method and adheres to the following characteristics:
    • Type: String
    • Case Sensitivity: Insensitive
    • Valid Characters: Lowercase alphanumeric characters
    • Description: A string that describes the DID method and is integral in determining how the DID interacts with a verifiable data registry.
  • [method-specific-id]: A method-specific identifier which is unique to the DID.

Parsing DID URLs

In addition to basic DIDs, the @yourd/did-parser is also capable of parsing DID URLs, which extend the basic DID format to include additional components such as paths, query parameters, and fragments.

The general structure of a DID URL is:

did:[method-name]:[method-specific-id][path][?query][#fragment]
  • did: A constant prefix indicating the identifier type.
  • [method-name]: Represents the specific DID method being utilized.
  • [method-specific-id]: A unique identifier specific to the chosen method.
  • [path]: (Optional) A hierarchical path.
  • [?query]: (Optional) A query component which provides additional information.
  • [#fragment]: (Optional) A fragment identifier to indicate a secondary resource.

📜 Conformance to W3C Specification

@yourd/did-parser strictly adheres to the W3C's DID Core Specification, ensuring:

  • Accuracy and Reliability: DIDs and DID URLs are parsed and handled with the utmost precision.
  • 🔄 Syntactical Correctness: Guarantees that DIDs are syntactically correct as per the standard.
  • 🌐 Compatibility and Interoperability: Ensures seamless integration across different platforms and systems that leverage DIDs.

📘 For a deeper dive into the DID Core Specification, readers are highly encouraged to explore the official W3C documentation.

Usage

Importing the Parser

import { Parser } from '@yourd/did-parser';

Parsing a DID

To parse a DID string:

const parser = new Parser();
const parsedDID = parser.parseDID('did:example:123');

If the DID string is valid, parsedDID will contain the method and methodSpecificId. If not, it will return null.

Parsing a DID URL

To parse a DID URL:

const parsedDIDURL = parser.parseDIDURL('did:example:123/path?query=value#fragment');

A valid DID URL will return an object containing the method, methodSpecificId, and optionally, pathAbempty, query, and fragment.

Assurance with @yourd/did-parser

The @yourd/did-parser ensures rigorous parsing and validation, affirming that DIDs are syntactically correct and conform to the established DID syntax, providing a layer of assurance and reliability in DID operations.

⚠️ Disclaimer

While we've put in great effort to ensure the accuracy and reliability of @yourd/did-parser, please be aware that all tools come with their own set of limitations. Any consequences or results stemming from the use of this library fall under the responsibility of the user. Always double-check your results, and use the library wisely and cautiously.

🤝 Contribution

Contributions to @yourd/did-parser are always welcome. If you're looking to contribute, please follow these steps:

  1. Open an Issue: Before making any changes, it's recommended to open an issue to discuss potential improvements or fixes.
  2. Refer to the Issue: Once you've opened an issue and are ready to make your changes, please reference your issue in your commits. This helps in tracking contributions and ensuring that your additions are in line with the project's goals.
  3. Follow the Code Style: Ensure that your code adheres to the project's coding standards.
  4. Submit a Pull Request: Once your changes are ready, submit a pull request for review.

Your contributions are greatly appreciated, and they help in making the library better for everyone.

📜 License

@yourd/did-parser is licensed under the GNU General Public License v3.0. For more details, check the LICENSE file in the repository.