@mavennet/stllr-did-resolver
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

DID Stellar resolver

This library is intended to be used in conjunction with the did-stellar-registry smart contract, to resolve stllr DIDs into a DID Document.

It supports the Decentralized Identifiers Specification.

The full did method specification is outlined in docs/did-method-spec.md

Status of the library

This library is currently in development and is not yet ready for production use.

The library relies on the did-resolver library.

Since soroban is currently not on mainnet, the resolver will only work on futurenet.

TODO:

  1. Add did document resolution metadata
  2. include delegation information
  3. increase test coverage
  4. This assumes you are using the default soroban url, we should allow for a custom url to be passed in.

DID Method

To encode a DID for a Stellar account, the following format is used, since the app is currently only on the futurenet network, if the network identifier is not included it defaults to futurenet.

did:stllr:<stellar_address>

for example:

did:stllr:GAICHJM4OUNAVKALCO2ANSXVSOD7Z2UTXE55R5RY3RX352LSJC6SYZXV

Multiple networks are also supported by adding the network identifier after the stllr method name:

did:stllr:03:GAICHJM4OUNAVKALCO2ANSXVSOD7Z2UTXE55R5RY3RX352LSJC6SYZXV

uses the futurenet network.

Structure of the DID Document

Stellar currently only uses Ed25519 Keys, so the verification method is always of type JsonWebKey2020 and the publicKeyJwk field is always present, with a type of OKP and a curve of Ed25519.

    {
      '@context': ['https://www.w3.org/ns/did/v1', 'https://w3id.org/security/suites/jws-2020/v1'],
      id: did,
      verificationMethod: [
        {
          id: `${did}`,
          type: 'JsonWebKey2020',
          controller: `did:stllr:${owner.toString()}`,
          publicKeyJwk: {
            kty: 'OKP',
            crv: 'Ed25519',
            x: '9GXjPGGvmRq9F6Ng5dQQ_s31mfhxrcNZxRGONrmH30k'
          }
        }
      ]
    }

Resolving the DID Document

To use this library you can pass it to the did-resolver library:

import { Resolver } from "did-resolver";
import { getResolver } from "stllr-did-resolver";

const stllrDidResolver = getResolver();

const didResolver = new Resolver(stllrDidResolver);

didResolver
  .resolve("did:stllr:GAICHJM4OUNAVKALCO2ANSXVSOD7Z2UTXE55R5RY3RX352LSJC6SYZXV")
  .then((doc) => console.log(doc));

To use a different network, you can pass in the network identifier as the second parameter:

import { Resolver } from "did-resolver";
import { getResolver } from "stllr-did-resolver";

const stllrDidResolver = getResolver();

const didResolver = new Resolver(stllrDidResolver);

didResolver
  .resolve("did:stllr:2:GAICHJM4OUNAVKALCO2ANSXVSOD7Z2UTXE55R5RY3RX352LSJC6SYZXV")
  .then((doc) => console.log(doc));

Readme

Keywords

none

Package Sidebar

Install

npm i @mavennet/stllr-did-resolver

Weekly Downloads

0

Version

0.1.1

License

MIT

Unpacked Size

73.4 kB

Total Files

78

Last publish

Collaborators

  • mkhraisha