# tz-did-resolver

> W3C compliant DID Resolver for the Tezos DID Method

Latest version **1.13.0** (published 2023-03-30) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install tz-did-resolver
pnpm add tz-did-resolver
yarn add tz-did-resolver
bun add tz-did-resolver
```

Provides the command `tz-did-resolver`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.13.0 |
| Published | 2023-03-30 |
| First published | 2021-12-07 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 31.4 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | François Guérin |
| Maintainers | francois.guerin, julien-gravity |
| Keywords | did:tz, DID, DID Document, Decentralized Identity, Tezos |

## Links

- npm: https://www.npmjs.com/package/tz-did-resolver
- Repository: https://github.com/GravityID/tz-did-resolver
- Homepage: https://github.com/GravityID/tz-did-resolver#readme
- Issues: https://github.com/GravityID/tz-did-resolver/issues
- npm.io page: https://npm.io/package/tz-did-resolver

## Dependencies (7)

- [axios](https://npm.io/package/axios.md) ^0.24.0
- [@taquito/utils](https://npm.io/package/@taquito/utils.md) ~16.0.0
- [@taquito/tzip16](https://npm.io/package/@taquito/tzip16.md) ~16.0.0
- [fast-json-patch](https://npm.io/package/fast-json-patch.md) ^3.1.0
- [@taquito/taquito](https://npm.io/package/@taquito/taquito.md) ~16.0.0
- [@transmute/jose-ld](https://npm.io/package/@transmute/jose-ld.md) ^0.7.0-unstable.59
- [@transmute/ed25519-key-pair](https://npm.io/package/@transmute/ed25519-key-pair.md) ^0.7.0-unstable.59

## Alternatives

- [@cantoo/pdf-lib](https://npm.io/package/@cantoo/pdf-lib.md) — 297.9K weekly downloads
- [datatables.net-buttons](https://npm.io/package/datatables.net-buttons.md) — 200.1K weekly downloads
- [@ckeditor/ckeditor5-export-pdf](https://npm.io/package/@ckeditor/ckeditor5-export-pdf.md) — 167.0K weekly downloads
- [scanbot-web-sdk](https://npm.io/package/scanbot-web-sdk.md) — 15.0K weekly downloads
- [@syncfusion/ej2-angular-pdfviewer](https://npm.io/package/@syncfusion/ej2-angular-pdfviewer.md) — 8.8K weekly downloads

## Recent versions

- 1.13.0 (latest) — 2023-03-30
- 1.12.0 — 2023-01-19
- 1.11.0 — 2022-10-11
- 1.10.0 — 2022-07-04
- 1.9.0 — 2022-07-01
- 1.8.0 — 2022-06-30
- 1.7.0 — 2022-06-24
- 1.6.0 — 2022-06-16
- 1.5.1 — 2022-04-29
- 1.5.0 — 2022-04-29
- 1.4.0 — 2022-01-03
- 1.3.0 — 2021-12-12
- 1.2.0 — 2021-12-07

## README

# tz-did-resolver

W3C compliant DID Resolver for the Tezos DID Method

## tz DID Resolver

This library is intended to use Tezos accounts and smart contract addresses as fully self-managed [Decentralized Identifiers](https://w3c.github.io/did-core/#identifier) and wrap them in a [DID Document](https://w3c.github.io/did-core/#did-document-properties)

It supports the proposed [`did:tz` method spec](https://did-tezos-draft.spruceid.com/) spec from [`did-tezos`](https://github.com/spruceid/did-tezos).

It requires the `did-resolver` library, which is the primary interface for resolving DIDs.

## DID method

 To encode a DID for a Tezos address on the Tezos mainnet, simply prepend `did:tz:`

eg:

`did:tz:tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8`

Multi-network DIDs are also supported, if the proper configuration is provided during setup.

For example: `did:tz:granadanet:tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8` gets resolved on the Granadanet testnet, and represents a distinct identifier than the generic one, with different DID Documents and different key rotation history.

## DID Document

The minimal DID Document for a Tezos address `did:tz:tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8` with no transactions to the registry looks like this:

```json
{
  "@context": [
    "https://www.w3.org/ns/did/v1",
    "https://w3id.org/security/v1"
  ],
  "id": "did:tz:tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8",
  "verificationMethod": [
    {
      "id": "did:tz:tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8#blockchainAccountId",
      "type": "Ed25519PublicKeyBLAKE2BDigestSize20Base58CheckEncoded2021",
      "controller": "did:tz:tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8",
      "blockchainAccountId": "tezos:NetXdQprcVkpaWU:tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8"
    }
  ],
  "authentication": [
    "did:tz:tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8#blockchainAccountId"
  ],
  "assertionMethod": [
    "did:tz:tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8#blockchainAccountId"
  ]
}
```

##  Building a DID document

The DID Document is not stored as a file, but is built by using [`tzip-16`](https://tzip.tezosagora.org/proposal/tzip-16/) views functions present on the DID Manager smart contract.

Please see the [spec](https://tzip.tezosagora.org/proposal/tzip-19/) for details of how the DID document and corresponding metadata are computed.

## Resolving a DID document

The library presents a `resolve()` function that returns a `Promise` including the DID Document. It is not meant to be used directly but through the [`did-resolver`](https://github.com/decentralized-identity/did-resolver) aggregator.

You can use the `getResolver()` method to produce an entry that can be used with the `Resolver` constructor:

```ts
import { Resolver } from 'did-resolver'
import { getResolver } from 'tz-did-resolver'

const tzResolver = getResolver()

const didResolver = new Resolver({
  ...tzResolver
  //...you can flatten multiple resolver methods into the Resolver
})

didResolver.resolve('did:tz:tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8').then(({ didDocument }) => console.log(didDocument))

// You can also use ES7 async/await syntax
const { didDocument } = await didResolver.resolve('did:tz:tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8')
console.log(didDocument)
```

---
_Source: https://npm.io/package/tz-did-resolver · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
