# psqr-did-resolver

> Resolve DID documents via HTTPS

Latest version **0.1.0** (published 2022-04-29) · Apache-2.0 license · 0 weekly downloads

## Install

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

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2022-04-29 |
| First published | 2022-04-29 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 100.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Virtual Public Square |
| Maintainers | vpsqr-protocol |

## Links

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

## Dependencies (3)

- [runtypes](https://npm.io/package/runtypes.md) ^6.5.1
- [cross-fetch](https://npm.io/package/cross-fetch.md) ^3.1.2
- [did-resolver](https://npm.io/package/did-resolver.md) ^3.1.5

## Recent versions

- 0.1.0 (latest) — 2022-04-29

## README

[![npm](https://img.shields.io/npm/dt/psqr-did-resolver.svg)](https://www.npmjs.com/package/psqr-did-resolver)
[![npm](https://img.shields.io/npm/v/psqr-did-resolver.svg)](https://www.npmjs.com/package/psqr-did-resolver)

# PSQR DID Resolver

This library is intended to represent an https URL as a
[Decentralized Identifier](https://w3c.github.io/did-core/#identifier) and retrieve an associated
[DID Document](https://w3c.github.io/did-core/#did-document-properties).

It supports the proposed [`did:psqr` method spec](https://vpsqr.com/did-method-psqr/v1/).

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

## DID method

To encode a DID for an HTTPS URL, simply replace `https://` with `did:psqr:`.

Examples:

`https://example.com -> did:psqr:example.com`

`https://example.com/alice -> did:psqr:example.com/alice`


## DID Document

The DID resolver is a webserver serving DID Documents via https. Domain root DIDs are
avaialable at a [well-known URI](https://tools.ietf.org/html/rfc5785), and DIDs associated
with individuals or items at the same URLs via HTTP content negotiation keying on the
`Accept:` request header.

For a DID `did:psqr:example.com`, the resolver will attempt to access the document at
`https://example.com/.well-known/psqr`.

For a DID `did:psqr:id.ology.com/joe-test`, the resolver will attempt to access the document at
`https://id.ology.com/joe-test` with an `Accept:` header requesting `application/json` or
`application/did+json`.

A minimal DID Document might contain the information below. Additional information outside the
`psqr` element is also supported for interoperability with other DID methods:

```json
{
    "@context": [
        "https://www.w3.org/ns/did/v1",
        "https://vpsqr.com/ns/did-psqr/v1"
    ],
    "id": "did:psqr:id.ology.com/joe-test",
    "psqr": {
        "publicIdentity": {
            "name": "Joe Test"
        },
        "publicKeys": [
            {
                "kty": "EC",
                "x": "GSswmWMS8j-KXycyyKUZ5MZ4Zf6u-oJ4WJ2BVnTG_ZFBPt1tAdZ_aVNmWAJ-9CeW",
                "y": "fmhXHl66obOeGW1hDOtqBrdf1OKFL1jXmSTtZ7d9piPDPrAfwYYRoez7yEBUuG7o",
                "crv": "P-384",
                "alg": "ES384",
                "kid": "did:psqr:id.ology.com/joe-test#publish"
            }
        ],
        "permissions": [
            {
                "grant": [
                    "publish",
                    "provenance"
                ],
                "kid": "did:psqr:id.ology.com/joe-test#publish"
            }
        ],
        "updated": 1649247931161
    }
}
```

## Resolving a DID document

The resolver presents a simple `resolver()` function that returns a ES6 Promise returning the DID document.

```js
import { Resolver } from 'did-resolver'
import { getResolver } from 'psqr-did-resolver'

const psqrResolver = getResolver()

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

didResolver.resolve('did:psqr:id.ology.com/joe-test').then(doc => console.log(doc))

// You can also use ES7 async/await syntax
;(async () => {
    const doc = await didResolver.resolve('did:psqr:id.ology.com/joe-test')
    console.log(doc)
})();
```

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