@red-isbe/isbe-service-did-registry 1.1.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +73 -28
  2. package/dist/index.d.ts +5 -3
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +4 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/src/ServiceDidRegistryQueries.d.ts +46 -36
  7. package/dist/src/ServiceDidRegistryQueries.d.ts.map +1 -1
  8. package/dist/src/ServiceDidRegistryQueries.js +138 -107
  9. package/dist/src/ServiceDidRegistryQueries.js.map +1 -1
  10. package/dist/src/ServiceDidRegistryTransactions.d.ts +7 -0
  11. package/dist/src/ServiceDidRegistryTransactions.d.ts.map +1 -1
  12. package/dist/src/ServiceDidRegistryTransactions.js +9 -0
  13. package/dist/src/ServiceDidRegistryTransactions.js.map +1 -1
  14. package/dist/src/abi/IServiceDidRegistry.abi.d.ts +258 -40
  15. package/dist/src/abi/IServiceDidRegistry.abi.d.ts.map +1 -1
  16. package/dist/src/abi/IServiceDidRegistry.abi.js +338 -51
  17. package/dist/src/abi/IServiceDidRegistry.abi.js.map +1 -1
  18. package/dist/src/serviceDid.types.d.ts +25 -18
  19. package/dist/src/serviceDid.types.d.ts.map +1 -1
  20. package/dist/src/types.d.ts +10 -0
  21. package/dist/src/types.d.ts.map +1 -1
  22. package/dist/src/utils/blockchain.utils.d.ts +18 -0
  23. package/dist/src/utils/blockchain.utils.d.ts.map +1 -1
  24. package/dist/src/utils/blockchain.utils.js +69 -5
  25. package/dist/src/utils/blockchain.utils.js.map +1 -1
  26. package/dist/src/utils/serviceDocument.utils.d.ts +32 -6
  27. package/dist/src/utils/serviceDocument.utils.d.ts.map +1 -1
  28. package/dist/src/utils/serviceDocument.utils.js +124 -9
  29. package/dist/src/utils/serviceDocument.utils.js.map +1 -1
  30. package/package.json +1 -1
package/README.md CHANGED
@@ -34,7 +34,8 @@ const tx = await new ServiceDidRegistryTransactions(context)
34
34
  .buildRegisterServiceDidTx(controllerDid, publicKey, 1, "billing pipeline", 0, from);
35
35
 
36
36
  // …the caller signs it, broadcasts it, and then:
37
- const doc = await new ServiceDidRegistryQueries(context).toDidDocumentW3C(serviceDid);
37
+ const { didDocument, didDocumentMetadata } =
38
+ await new ServiceDidRegistryQueries(context).resolve(serviceDid);
38
39
  ```
39
40
 
40
41
  Every write builder returns the transaction fields and stops there. `from` is used only to
@@ -46,8 +47,8 @@ on-chain, from the signature.
46
47
  | | |
47
48
  |---|---|
48
49
  | `ServiceDidRegistryContext` | Provider, Diamond address, network discriminator and curve |
49
- | `ServiceDidRegistryTransactions` | `buildRegisterServiceDidTx`, `buildUpdateServiceDocumentTx`, `buildRotateSigningKeyTx`, `buildUpdateExpiryTx`, `buildDeactivateServiceDidTx`, `buildInitializeServiceDidRegistryTx` |
50
- | `ServiceDidRegistryQueries` | `getServiceDid`, `getServiceDocument`, `getServiceDidsByController`, `getServiceDidsByAddress`, `findServiceDidsByAddress`, `isServiceDidActive`, `signingKeyAddressOf`, `computeServiceDid`, `toDidDocumentW3C` |
50
+ | `ServiceDidRegistryTransactions` | `buildRegisterServiceDidTx`, `buildUpdateServiceDocumentTx`, `buildRotateSigningKeyTx`, `buildUpdateExpiryTx`, `buildDeactivateServiceDidTx`, `buildInitializeServiceDidRegistryTx`, `buildIndexServiceDidsByAddressTx`. They throw `ContractRevertError` when the call would revert |
51
+ | `ServiceDidRegistryQueries` | `getServiceDid`, `getServiceDocument`, `getServiceDidsByController`, `isServiceDidActive`, `signingKeyAddressOf`, `serviceDidOf`, `isKnownServiceDid`, `serviceDidsOf`, `computeServiceDid`, `toDidDocumentW3C`, `resolve` |
51
52
  | `ServiceDidTransactionExecutor` | Broadcasts a signed transaction and waits for its receipt |
52
53
  | Derivation helpers | `buildServiceDid`, `parseServiceDid`, `computeServiceDidHex`, `serviceDidToHex`, `signingKeyAddress`, `toUncompressedPublicKey` |
53
54
 
@@ -59,15 +60,32 @@ carry any fields its organisation wants, as one JSON object:
59
60
  ```ts
60
61
  await transactions.buildRegisterServiceDidTx(
61
62
  controllerDid, publicKey, 1, "billing pipeline", 0, from,
62
- { serviceEndpoint: "https://billing.example.com", companyName: "Example Ltd" },
63
+ {
64
+ name: "Billing",
65
+ service: [
66
+ { id: "#api", type: "InvoicingAPI", serviceEndpoint: "https://billing.example.com/v2" },
67
+ ],
68
+ },
63
69
  );
64
- await transactions.buildUpdateServiceDocumentTx(serviceDid, { serviceEndpoint: "https://new.example.com" }, from);
65
70
  ```
66
71
 
67
72
  It is stored on-chain and `toDidDocumentW3C` adds its fields to the DID Document. It may
68
73
  not set the members the registry derives (`RESERVED_DOCUMENT_KEYS`: `id`, `controller`,
69
- the keys and relationships…), it must fit in 4096 bytes, and it is public and permanent
70
- in the chain history. An update replaces the whole document; `null` clears it.
74
+ the keys and relationships, `deactivated`, `reason`), it must fit in 4096 bytes, and it
75
+ is public and permanent in the chain history. An update replaces the whole document;
76
+ `null` clears it.
77
+
78
+ Two members follow DID Core and are checked when the document is built:
79
+
80
+ - `service` is a list of entries with `id`, `type` and `serviceEndpoint` (§5.4). An `id`
81
+ may be relative (`#api`); the resolver expands it to `did:isbe:svc:…#api`. Ids must be
82
+ unique; if two expand to the same id, the DID document keeps the first.
83
+ - `@context` may add JSON-LD contexts for the extra fields, as absolute http(s) URLs.
84
+ They go after the two the registry always puts first.
85
+
86
+ `getServiceDocument` returns the stored members as they are, minus the reserved ones,
87
+ so a read, edit and write-back never loses data silently. Entries that break these
88
+ rules (written without this library) are left out of the DID document only.
71
89
 
72
90
  ## The identifier
73
91
 
@@ -84,23 +102,48 @@ halves of that translation.
84
102
 
85
103
  ## Resolution
86
104
 
87
- `toDidDocumentW3C` produces a W3C DID Document. The verification method follows the curve
88
- of the key, not the network: on the network's own curve it carries a `blockchainAccountId`,
89
- on any other curve the coordinates as a JWK — publishing an address for a key no account
90
- can use would point a verifier at something that can never sign. The declared `@context`
91
- follows that same branch.
105
+ `toDidDocumentW3C` produces a W3C DID Document with the same shape as an organisational
106
+ one from `@red-isbe/did-isbe-registry`:
107
+
108
+ - `@context`: `https://www.w3.org/ns/did/v1` and `https://w3id.org/security/suites/jws-2020/v1`;
109
+ - `controller`: the organisational DID;
110
+ - one `JsonWebKey2020` with the key in `publicKeyJwk`, on either curve;
111
+ - the method id is the DID plus the RFC 7638 thumbprint of the key, the same id `did-gen`
112
+ prints for an organisational key;
113
+ - `authentication` and `assertionMethod` point at that key.
114
+
115
+ ```json
116
+ {
117
+ "@context": ["https://www.w3.org/ns/did/v1", "https://w3id.org/security/suites/jws-2020/v1"],
118
+ "id": "did:isbe:svc:uc:z1Ms…:3",
119
+ "controller": ["did:isbe:uc:z1Ms…"],
120
+ "verificationMethod": [{
121
+ "id": "did:isbe:svc:uc:z1Ms…:3#9lfZ28jd…",
122
+ "type": "JsonWebKey2020",
123
+ "controller": "did:isbe:svc:uc:z1Ms…:3",
124
+ "publicKeyJwk": { "kty": "EC", "crv": "secp256k1", "x": "…", "y": "…" }
125
+ }],
126
+ "authentication": ["did:isbe:svc:uc:z1Ms…:3#9lfZ28jd…"],
127
+ "assertionMethod": ["did:isbe:svc:uc:z1Ms…:3#9lfZ28jd…"],
128
+ "name": "Billing",
129
+ "service": [{ "id": "did:isbe:svc:uc:z1Ms…:3#api", "type": "InvoicingAPI", "serviceEndpoint": "https://billing.example.com/v2" }]
130
+ }
131
+ ```
92
132
 
93
- A service also stops resolving as valid when its controlling organisation stops being
94
- operative. That cascade is evaluated only if the caller supplies it, because reading the
95
- organisational registry is not this library's job:
133
+ Whether the identity is still valid is not part of the document. DID Core puts it in the
134
+ document metadata (§7.1.3), which `resolve` returns next to the document:
96
135
 
97
136
  ```ts
98
- await queries.toDidDocumentW3C(serviceDid, { isControllerActive, now });
137
+ const { didDocument, didDocumentMetadata } =
138
+ await queries.resolve(serviceDid, { isControllerActive, now });
139
+ // didDocumentMetadata: { created, updated?, deactivated, reason? }
99
140
  ```
100
141
 
101
- The document then comes back marked `deactivated: true` with a `reason` —
102
- `deactivated`, `expired` or `controller-inactive` — so a caller can tell "this service was
103
- revoked" from "this service is fine but its organisation is not".
142
+ `deactivated` is `true` when the service was deactivated, has expired, or its controlling
143
+ organisation is no longer operative; `reason` says which — `deactivated`, `expired` or
144
+ `controller-inactive`. The cascade of the organisation is evaluated only if the caller
145
+ supplies `isControllerActive`, because reading the organisational registry is not this
146
+ library's job.
104
147
 
105
148
  ## Relationship with `@red-isbe/did-isbe-registry`
106
149
 
@@ -116,20 +159,22 @@ vectors read from the DEV network, not computed by the functions themselves.
116
159
 
117
160
  ## Search by address
118
161
 
119
- Which service identities does an address belong to? The registry keeps no index by
120
- address: it derives it from each stored key, walking every organisation and its services.
162
+ Which service identity does an address sign for? The registry keeps an index by address,
163
+ the counterpart of `didOf` in the organisational registry, so the answer is one read:
121
164
 
122
165
  ```ts
123
- // Every service whose current key is this address (all pages walked for you)
124
- const services = await queries.findServiceDidsByAddress("0x4f6A…", { activeOnly: true });
166
+ // The active service that address signs for, or null
167
+ const serviceDid = await queries.serviceDidOf("0x4f6A…");
125
168
 
126
- // Or one page at a time: pagination counts organisations, not matches
127
- const page = await queries.getServiceDidsByAddress("0x4f6A…", 1, 50);
169
+ // Every non-deactivated service whose current key is that address
170
+ const records = await queries.serviceDidsOf("0x4f6A…");
128
171
  ```
129
172
 
130
- Only the current key matches: after a rotation the old address no longer finds the
131
- service. The cost grows with the number of organisations, so it is meant for reads, not
132
- for hot paths. Needs a registry with the address search (isbe-contracts ISBECORE-354).
173
+ `serviceDidOf` also applies the cascade of the organisation: if it no longer holds a
174
+ capability invocation in force, the answer is `null`. Only the current key matches:
175
+ after a rotation the old address no longer finds the service. Needs a registry with the
176
+ address index; services registered before it are found once the admin has run
177
+ `indexServiceDidsByAddress` (`buildIndexServiceDidsByAddressTx`).
133
178
 
134
179
  ## Tests
135
180
 
package/dist/index.d.ts CHANGED
@@ -14,13 +14,15 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export { ServiceDidRegistryContext } from "./src/ServiceDidRegistryContext.js";
17
- export { ServiceDidRegistryQueries } from "./src/ServiceDidRegistryQueries.js";
17
+ export { ServiceDidRegistryQueries, SERVICE_DID_DOCUMENT_CONTEXT, } from "./src/ServiceDidRegistryQueries.js";
18
+ export type { ResolveServiceDidOptions } from "./src/ServiceDidRegistryQueries.js";
18
19
  export { ServiceDidRegistryTransactions } from "./src/ServiceDidRegistryTransactions.js";
19
20
  export { ServiceDidTransactionExecutor } from "./src/ServiceDidTransactionExecutor.js";
20
- export type { ServiceDidRecord, ServiceDidParts, ServiceDidInactiveReason, GetServiceDidsByControllerResult, GetServiceDidsByAddressResult, FindServiceDidsByAddressOptions, } from "./src/serviceDid.types.js";
21
- export type { DidW3CDocument } from "./src/types.js";
21
+ export type { ServiceDidRecord, ServiceDidParts, ServiceDidInactiveReason, GetServiceDidsByControllerResult, ServiceDidDocumentMetadata, ServiceDidResolutionResult, } from "./src/serviceDid.types.js";
22
+ export type { DidService, DidW3CDocument } from "./src/types.js";
22
23
  export { MAX_SERVICE_DOCUMENT_BYTES, RESERVED_DOCUMENT_KEYS, ServiceDocumentError, parseServiceDocument, serializeServiceDocument, } from "./src/utils/serviceDocument.utils.js";
23
24
  export type { ServiceDocument } from "./src/utils/serviceDocument.utils.js";
24
25
  export { buildServiceDid, parseServiceDid, serviceDidToHex, computeServiceDidHex, signingKeyAddress, toUncompressedPublicKey, } from "./src/utils/serviceDid.utils.js";
25
26
  export { didToHex, hexToDid } from "./src/utils/did.utils.js";
27
+ export { ContractRevertError } from "./src/utils/blockchain.utils.js";
26
28
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAEF,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CA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B,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,sCAAsC,CAAC;AAC9C,YAAY,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAE5E,OAAO,EACL,eAAe,EACf,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,iCAAiC,CAAC;AAKzC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAI9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC"}
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export { ServiceDidRegistryContext } from "./src/ServiceDidRegistryContext.js";
17
- export { ServiceDidRegistryQueries } from "./src/ServiceDidRegistryQueries.js";
17
+ export { ServiceDidRegistryQueries, SERVICE_DID_DOCUMENT_CONTEXT, } from "./src/ServiceDidRegistryQueries.js";
18
18
  export { ServiceDidRegistryTransactions } from "./src/ServiceDidRegistryTransactions.js";
19
19
  export { ServiceDidTransactionExecutor } from "./src/ServiceDidTransactionExecutor.js";
20
20
  export { MAX_SERVICE_DOCUMENT_BYTES, RESERVED_DOCUMENT_KEYS, ServiceDocumentError, parseServiceDocument, serializeServiceDocument, } from "./src/utils/serviceDocument.utils.js";
@@ -23,4 +23,7 @@ export { buildServiceDid, parseServiceDid, serviceDidToHex, computeServiceDidHex
23
23
  // paquete comparte con @red-isbe/did-isbe-registry, y tenerla accesible permite
24
24
  // comprobar desde fuera que ambas implementaciones coinciden.
25
25
  export { didToHex, hexToDid } from "./src/utils/did.utils.js";
26
+ // Lanzado al construir una transacción que revertiría; mismo error que la librería de
27
+ // organizaciones, para tratar los de ambos registros igual.
28
+ export { ContractRevertError } from "./src/utils/blockchain.utils.js";
26
29
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":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A0B,CAAC;AAE9D,sFAAsF;AACtF,4DAA4D;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC"}
@@ -16,12 +16,17 @@
16
16
  import { parseServiceDid, serviceDidToHex } from "./utils/serviceDid.utils.js";
17
17
  import { ServiceDidRegistryContext } from "./ServiceDidRegistryContext.js";
18
18
  import { type ServiceDocument } from "./utils/serviceDocument.utils.js";
19
- import type { FindServiceDidsByAddressOptions, GetServiceDidsByAddressResult, GetServiceDidsByControllerResult, ServiceDidInactiveReason, ServiceDidRecord } from "./serviceDid.types.js";
19
+ import type { GetServiceDidsByControllerResult, ServiceDidRecord, ServiceDidResolutionResult } from "./serviceDid.types.js";
20
20
  import type { DidW3CDocument } from "./types.js";
21
21
  /** secp256k1, the curve the Case network operates on. */
22
22
  export declare const ELLIPTIC_TYPE_SECP256K1 = 1;
23
23
  /** P-256, the curve the Bare network operates on. */
24
24
  export declare const ELLIPTIC_TYPE_P256 = 2;
25
+ /**
26
+ * Contexts every service DID Document starts with: DID Core, then the suite that
27
+ * defines `JsonWebKey2020`. The same pair the organisational registry publishes.
28
+ */
29
+ export declare const SERVICE_DID_DOCUMENT_CONTEXT: readonly string[];
25
30
  /**
26
31
  * Options for resolving a service identity into a W3C DID Document.
27
32
  */
@@ -65,35 +70,33 @@ export declare class ServiceDidRegistryQueries {
65
70
  */
66
71
  getServiceDidsByController(controllerDid: string, page?: number, pageSize?: number): Promise<GetServiceDidsByControllerResult>;
67
72
  /**
68
- * Lists, one page at a time, the service identities whose current signing key
69
- * derives `address`.
73
+ * Resolves an address to the service identity it currently signs for, the
74
+ * counterpart of `didOf` in the organisational registry.
70
75
  *
71
- * The registry keeps no index by address: it walks the global list of organisational
72
- * DIDs and, for each one, every service it controls, deriving the address from the
73
- * stored key. Pagination therefore applies to **organisations**, not to matches —
74
- * `total`, `howMany`, `prev` and `next` count organisations, and a page may come back
75
- * empty while a later one does not. Use `findServiceDidsByAddress` to walk them all.
76
+ * One read of the registry's address index, whatever the number of organisations.
77
+ * Returns `null` when nothing usable is found: no service holds a key deriving the
78
+ * address, every such service is deactivated or expired, or their organisation no
79
+ * longer holds a capability invocation in force (the registry applies that cascade
80
+ * itself here). When several services of one organisation share the key, the most
81
+ * recently registered active one is returned.
76
82
  *
77
- * Only the current key matches: a key rotated away no longer does. Deactivated and
78
- * expired identities are returned as well; filter them with `isServiceDidActive` or
79
- * the record's own fields. Needs a registry with the address search (ISBECORE-354).
83
+ * Needs a registry with the address index; against an older one the call fails.
80
84
  */
81
- getServiceDidsByAddress(address: string, page?: number, pageSize?: number): Promise<GetServiceDidsByAddressResult>;
85
+ serviceDidOf(address: string): Promise<string | null>;
86
+ /** The counterpart of `isKnownDid`: true when `serviceDidOf` finds a service. */
87
+ isKnownServiceDid(address: string): Promise<boolean>;
82
88
  /**
83
- * Finds every service identity whose current signing key derives `address`, walking
84
- * all the pages of `getServiceDidsByAddress`.
85
- *
86
- * With `activeOnly`, identities that are deactivated or past their expiry are left
87
- * out. The cascade of the controlling organisation is not evaluated here; it belongs
88
- * to `toDidDocumentW3C`.
89
+ * Every service identity whose current key derives `address`, read from the address
90
+ * index. Deactivated identities are not indexed; expired ones are, and the cascade
91
+ * of the organisation is not applied. Needs a registry with the address index.
89
92
  */
90
- findServiceDidsByAddress(address: string, options?: FindServiceDidsByAddressOptions): Promise<ServiceDidRecord[]>;
93
+ serviceDidsOf(address: string): Promise<ServiceDidRecord[]>;
91
94
  /**
92
95
  * Reports whether a service identity is usable right now.
93
96
  *
94
97
  * False for an unknown identifier as well as for one deactivated or past its expiry,
95
98
  * so it never throws. It does not evaluate the parent: that cascade belongs to
96
- * `toDidDocumentW3C`.
99
+ * `resolve`.
97
100
  */
98
101
  isServiceDidActive(serviceDid: string): Promise<boolean>;
99
102
  /**
@@ -114,25 +117,32 @@ export declare class ServiceDidRegistryQueries {
114
117
  /**
115
118
  * Resolves a service identity into a W3C DID Document.
116
119
  *
117
- * Three things can make an identity resolve as no longer valid, and they are checked
118
- * in this order: it was deactivated, it passed its expiry, or its controlling
119
- * organisation stopped being operative. The last one is only evaluated when the
120
- * caller supplies `isControllerActive`.
121
- *
122
- * The verification method depends on the curve, not on the network: a key on the
123
- * network's own curve yields `EcdsaSecp256k1RecoveryMethod2020` with a
124
- * `blockchainAccountId`, and any other curve yields `JsonWebKey2020` carrying the
125
- * coordinates. Emitting a `blockchainAccountId` for a key no account can use would
126
- * point a verifier at an address that can never sign.
120
+ * The document has the same shape as an organisational one from
121
+ * `@red-isbe/did-isbe-registry`: the same `@context`, a `JsonWebKey2020` with the key
122
+ * in `publicKeyJwk` whatever the curve, and a method id made of the DID and the RFC
123
+ * 7638 thumbprint of the key — the same id `did-gen` gives an organisational key.
127
124
  *
128
125
  * The service's free-form fields, if any, are added to the document. They can never
129
- * override what the registry asserts: the identifier, the controller, the keys and
130
- * the deactivation status always come from the record.
126
+ * override what the registry asserts: the identifier, the controller and the keys
127
+ * always come from the record. A `service` entry with a relative id (`#api`) is
128
+ * expanded against the service DID, and any `@context` the document declares is
129
+ * appended after the two the registry puts first.
130
+ *
131
+ * Whether the identity is still valid is not part of the document: DID Core puts it
132
+ * in the document metadata, which `resolve` returns.
133
+ */
134
+ toDidDocumentW3C(serviceDid: string): Promise<DidW3CDocument>;
135
+ /**
136
+ * Resolves a service identity into a DID resolution result: the document plus its
137
+ * metadata (DID Core §7.1).
138
+ *
139
+ * Three things can make an identity no longer valid, and they are checked in this
140
+ * order: it was deactivated, it passed its expiry, or its controlling organisation
141
+ * stopped being operative. The last one is only evaluated when the caller supplies
142
+ * `isControllerActive`. Any of them sets `deactivated: true` in the metadata, with
143
+ * the `reason`; the document is returned all the same, as DID Core allows.
131
144
  */
132
- toDidDocumentW3C(serviceDid: string, options?: ResolveServiceDidOptions): Promise<DidW3CDocument & {
133
- deactivated?: boolean;
134
- reason?: ServiceDidInactiveReason;
135
- }>;
145
+ resolve(serviceDid: string, options?: ResolveServiceDidOptions): Promise<ServiceDidResolutionResult>;
136
146
  /** Reads a service identity by its on-chain digest. */
137
147
  private getServiceDidByHex;
138
148
  /** Derives the identifier a controller and nonce produce, without a network call. */
@@ -1 +1 @@
1
- {"version":3,"file":"ServiceDidRegistryQueries.d.ts","sourceRoot":"","sources":["../../src/ServiceDidRegistryQueries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAIF,OAAO,EAEL,eAAe,EACf,eAAe,EAEhB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAEL,KAAK,eAAe,EACrB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EACV,+BAA+B,EAC/B,6BAA6B,EAC7B,gCAAgC,EAChC,wBAAwB,EACxB,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,yDAAyD;AACzD,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,qDAAqD;AACrD,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;;;;;;;;;OAWG;IACH,kBAAkB,CAAC,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjE,2EAA2E;IAC3E,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;GAGG;AACH,qBAAa,yBAAyB;IACpC,OAAO,CAAC,aAAa,CAA4B;gBAErC,aAAa,EAAE,yBAAyB;IAIpD;;;;;;OAMG;IACG,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAYlE;;;;;OAKG;IACG,0BAA0B,CAC9B,aAAa,EAAE,MAAM,EACrB,IAAI,SAAI,EACR,QAAQ,SAAK,GACZ,OAAO,CAAC,gCAAgC,CAAC;IAyB5C;;;;;;;;;;;;;OAaG;IACG,uBA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