You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-22Lines changed: 21 additions & 22 deletions
Original file line number
Diff line number
Diff line change
@@ -1,42 +1,43 @@
1
1
# Overview
2
2
3
3
This package implements a generic resolver for the `dsnp` DID method (that is, DIDs of the form `did:dsnp:123456`, where `123456` is a [DSNP User Id](https://spec.dsnp.org/DSNP/Identifiers.html#dsnp-user-id) in decimal format).
4
-
This resolver should be used with one or more plugins for specific DSNP systems (see below).
4
+
This resolver must be used with one or more plugins for specific DSNP systems (see below).
5
5
6
6
# Usage
7
7
8
-
This package follows the conventions described in the [`did-resolver`](https://github.com/decentralized-identity/did-resolver) package and exposes a `getResolver()` function which returns a mapping from the `dsnp` DID method to a resolver function.
9
-
Pass an array of plugins to the `getResolver()` method.
8
+
This package follows the conventions described in the [`@digitalbazaar/did-io`](https://github.com/digitalbazaar/did-io) package and exposes a `driver()` function which returns an object with a `get(options)`method.
9
+
Pass an array of DSNPResolver objects to the `driver()` method.
10
10
11
11
## Usage for DSNP DID method only
12
12
13
13
```
14
-
import { Resolver } from "did-resolver";
15
-
import dsnpResolver from "@dsnp/did-resolver";
14
+
import { CachedResolver } from "@digitalbazaar/did-io";
15
+
import didDsnp from "@dsnp/did-resolver";
16
16
import { FooResolver} from "dsnp-did-resolver-plugin-foo"; // See below for known plugins
17
17
// ... additional dsnp-did-resolver plugins if needed
18
18
19
-
const resolver = new Resolver(dsnpResolver.getResolver(
20
-
[ new FooResolver() ]
21
-
));
19
+
const resolver = new CachedResolver();
20
+
resolver.use(didDsnp.driver([ new FooResolver() ]));
21
+
22
22
const myDid = "did:dsnp:123456";
23
-
const result = await resolver.resolve(myDid);
23
+
const result = await resolver.get({ did: myDid });
24
24
console.log(JSON.stringify(result, null, 2));
25
25
```
26
26
27
27
## Usage with other DID method resolvers
28
28
29
-
The Resolver constructor can combine resolvers for multiple DID methods as described in the `did-resolver`[documentation](https://github.com/decentralized-identity/did-resolver#readme).
30
-
For example, if you also want to be able to resolve `did:ethr:*` DIDs, you would import and include the `ethr` resolver and pass its destructured resolver alongside the DSNP one to the constructor as follows:
29
+
The CachedResolver can combine drivers for multiple DID methods as described in the `did-io`[documentation](https://github.com/digitalbazaar/did-io#readme).
30
+
For example, if you also want to be able to resolve `did:web:*` DIDs, you can use the `did-method-web` driver alongside the DSNP driver.
31
31
32
32
```
33
-
import ethrResolver from "ethr-did-resolver";
34
-
// ... additional did-resolver packages;
33
+
import { CachedResolver } from "@digitalbazaar/did-io";
34
+
import didWeb from "@digitalbazaar/did-method-web";
35
+
import didDsnp from "@dsnp/did-resolver";
36
+
37
+
const resolver = new CachedResolver();
38
+
resolver.use(didWeb.driver());
39
+
resolver.use(didDsnp.driver([ new FooResolver() ]));
35
40
36
-
const resolver = new Resolver({
37
-
...dsnpResolver.getResolver([plugin]),
38
-
...ethrResolver.getResolver()
39
-
});
40
41
// usage is same as in previous example
41
42
```
42
43
@@ -52,22 +53,20 @@ Plugins should implement the `DSNPResolver` interface, which includes a `resolve
The `DIDDocument` type is defined in the `did-resolver` package.
60
-
61
60
The `resolve()` function should return `null` if the DSNP User Id cannot be resolved to a DID document for any reason.
62
61
Plugins should avoid throwing errors except in dire circumstances, as errors from one plugin will cause any further plugins that have been registered to *not* be called.
63
62
64
-
`DSNPResolver` instances are passed to the `getResolver()` function.
63
+
`DSNPResolver` instances can be passed to the `CachedResolver``use()` function.
65
64
66
65
## Known plugins
67
66
68
67
| System | Plugin package
69
68
|---|---|
70
-
| Frequency |[`@dsnp/did-resolver-plugin-frequency`](https://github.com/AmplicaLabs/dsnp-did-resolver-plugin-frequency)|
69
+
| Frequency |[`@dsnp/did-resolver-plugin-frequency`](https://github.com/ProjectLibertyLabs/dsnp-did-resolver-plugin-frequency)|
71
70
72
71
Please submit a pull request with any additional plugins.
0 commit comments