@red-isbe/isbe-service-did-registry 1.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 (51) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +129 -0
  3. package/dist/index.d.ts +26 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +26 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/src/ServiceDidRegistryContext.d.ts +40 -0
  8. package/dist/src/ServiceDidRegistryContext.d.ts.map +1 -0
  9. package/dist/src/ServiceDidRegistryContext.js +42 -0
  10. package/dist/src/ServiceDidRegistryContext.js.map +1 -0
  11. package/dist/src/ServiceDidRegistryQueries.d.ts +127 -0
  12. package/dist/src/ServiceDidRegistryQueries.d.ts.map +1 -0
  13. package/dist/src/ServiceDidRegistryQueries.js +226 -0
  14. package/dist/src/ServiceDidRegistryQueries.js.map +1 -0
  15. package/dist/src/ServiceDidRegistryTransactions.d.ts +90 -0
  16. package/dist/src/ServiceDidRegistryTransactions.d.ts.map +1 -0
  17. package/dist/src/ServiceDidRegistryTransactions.js +134 -0
  18. package/dist/src/ServiceDidRegistryTransactions.js.map +1 -0
  19. package/dist/src/ServiceDidTransactionExecutor.d.ts +31 -0
  20. package/dist/src/ServiceDidTransactionExecutor.d.ts.map +1 -0
  21. package/dist/src/ServiceDidTransactionExecutor.js +37 -0
  22. package/dist/src/ServiceDidTransactionExecutor.js.map +1 -0
  23. package/dist/src/abi/IServiceDidRegistry.abi.d.ts +578 -0
  24. package/dist/src/abi/IServiceDidRegistry.abi.d.ts.map +1 -0
  25. package/dist/src/abi/IServiceDidRegistry.abi.js +741 -0
  26. package/dist/src/abi/IServiceDidRegistry.abi.js.map +1 -0
  27. package/dist/src/serviceDid.types.d.ts +78 -0
  28. package/dist/src/serviceDid.types.d.ts.map +1 -0
  29. package/dist/src/serviceDid.types.js +16 -0
  30. package/dist/src/serviceDid.types.js.map +1 -0
  31. package/dist/src/types.d.ts +35 -0
  32. package/dist/src/types.d.ts.map +1 -0
  33. package/dist/src/types.js +16 -0
  34. package/dist/src/types.js.map +1 -0
  35. package/dist/src/utils/blockchain.utils.d.ts +49 -0
  36. package/dist/src/utils/blockchain.utils.d.ts.map +1 -0
  37. package/dist/src/utils/blockchain.utils.js +102 -0
  38. package/dist/src/utils/blockchain.utils.js.map +1 -0
  39. package/dist/src/utils/did.utils.d.ts +20 -0
  40. package/dist/src/utils/did.utils.d.ts.map +1 -0
  41. package/dist/src/utils/did.utils.js +57 -0
  42. package/dist/src/utils/did.utils.js.map +1 -0
  43. package/dist/src/utils/serviceDid.utils.d.ts +71 -0
  44. package/dist/src/utils/serviceDid.utils.d.ts.map +1 -0
  45. package/dist/src/utils/serviceDid.utils.js +142 -0
  46. package/dist/src/utils/serviceDid.utils.js.map +1 -0
  47. package/dist/src/utils/serviceDocument.utils.d.ts +61 -0
  48. package/dist/src/utils/serviceDocument.utils.d.ts.map +1 -0
  49. package/dist/src/utils/serviceDocument.utils.js +101 -0
  50. package/dist/src/utils/serviceDocument.utils.js.map +1 -0
  51. package/package.json +45 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,129 @@
1
+ # @red-isbe/isbe-service-did-registry
2
+
3
+ Client library for the **ISBE Service DID Registry**: operational identities — services,
4
+ pipelines, agents — under the `did:isbe:svc:` sub-namespace, controlled by an
5
+ organisational `did:isbe`.
6
+
7
+ The registry is a facet of the same EIP-2535 Diamond the organisational DID Registry lives
8
+ in, so this library points at the same address. What differs is the ABI each one carries.
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ npm install @red-isbe/isbe-service-did-registry
14
+ ```
15
+
16
+ ## Use
17
+
18
+ ```ts
19
+ import {
20
+ ServiceDidRegistryContext,
21
+ ServiceDidRegistryQueries,
22
+ ServiceDidRegistryTransactions,
23
+ } from "@red-isbe/isbe-service-did-registry";
24
+
25
+ const context = new ServiceDidRegistryContext(
26
+ provider, // ethers JsonRpcProvider
27
+ "uc-dev", // model deploy id
28
+ diamondAddress,
29
+ 1, // network curve: 1 = secp256k1, 2 = P-256
30
+ );
31
+
32
+ // Writes return an UNSIGNED transaction. This library never holds a key.
33
+ const tx = await new ServiceDidRegistryTransactions(context)
34
+ .buildRegisterServiceDidTx(controllerDid, publicKey, 1, "billing pipeline", 0, from);
35
+
36
+ // …the caller signs it, broadcasts it, and then:
37
+ const doc = await new ServiceDidRegistryQueries(context).toDidDocumentW3C(serviceDid);
38
+ ```
39
+
40
+ Every write builder returns the transaction fields and stops there. `from` is used only to
41
+ look up that account's nonce — it authorises nothing. Who may perform the call is decided
42
+ on-chain, from the signature.
43
+
44
+ ## What it offers
45
+
46
+ | | |
47
+ |---|---|
48
+ | `ServiceDidRegistryContext` | Provider, Diamond address, network discriminator and curve |
49
+ | `ServiceDidRegistryTransactions` | `buildRegisterServiceDidTx`, `buildUpdateServiceDocumentTx`, `buildRotateSigningKeyTx`, `buildUpdateExpiryTx`, `buildDeactivateServiceDidTx`, `buildInitializeServiceDidRegistryTx` |
50
+ | `ServiceDidRegistryQueries` | `getServiceDid`, `getServiceDocument`, `getServiceDidsByController`, `isServiceDidActive`, `signingKeyAddressOf`, `computeServiceDid`, `toDidDocumentW3C` |
51
+ | `ServiceDidTransactionExecutor` | Broadcasts a signed transaction and waits for its receipt |
52
+ | Derivation helpers | `buildServiceDid`, `parseServiceDid`, `computeServiceDidHex`, `serviceDidToHex`, `signingKeyAddress`, `toUncompressedPublicKey` |
53
+
54
+ ## Service documents
55
+
56
+ On top of the fixed minimum — controller, key, curve, label, expiry — each service may
57
+ carry any fields its organisation wants, as one JSON object:
58
+
59
+ ```ts
60
+ await transactions.buildRegisterServiceDidTx(
61
+ controllerDid, publicKey, 1, "billing pipeline", 0, from,
62
+ { serviceEndpoint: "https://billing.example.com", companyName: "Example Ltd" },
63
+ );
64
+ await transactions.buildUpdateServiceDocumentTx(serviceDid, { serviceEndpoint: "https://new.example.com" }, from);
65
+ ```
66
+
67
+ It is stored on-chain and `toDidDocumentW3C` adds its fields to the DID Document. It may
68
+ 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.
71
+
72
+ ## The identifier
73
+
74
+ On-chain a service identity is keyed by `keccak256(abi.encode(controllerDid, uint64 nonce))`
75
+ — a full digest, not invertible. The readable form therefore carries its own pre-image:
76
+
77
+ ```
78
+ did:isbe:svc:<network>:<parent segment>:<nonce>
79
+ ```
80
+
81
+ so the string can be turned back into the digest with no network call, and so a reader can
82
+ see which organisation owns it. `computeServiceDidHex` and `parseServiceDid` are the two
83
+ halves of that translation.
84
+
85
+ ## Resolution
86
+
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.
92
+
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:
96
+
97
+ ```ts
98
+ await queries.toDidDocumentW3C(serviceDid, { isControllerActive, now });
99
+ ```
100
+
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".
104
+
105
+ ## Relationship with `@red-isbe/did-isbe-registry`
106
+
107
+ This package is independent: it imports nothing from the organisational registry library,
108
+ and a consumer that only deals with service identities does not need it.
109
+
110
+ What the two share is the encoding of an organisational DID into its bytes32 form. Those
111
+ functions — `didToHex` and `hexToDid` — are duplicated here rather than depended upon, and
112
+ are exported so the equivalence can be checked from outside. **They must never diverge**: a
113
+ service registered through one package would become unresolvable through the other, with
114
+ nothing failing loudly. `src/utils/__test__/did.utils.test.ts` pins the behaviour with
115
+ vectors read from the DEV network, not computed by the functions themselves.
116
+
117
+ ## Tests
118
+
119
+ ```bash
120
+ npm test
121
+ ```
122
+
123
+ 53 tests across two suites. The ESM one exists because `multiformats` is ESM-only and the
124
+ base58 encoding has to be exercised for real, not mocked.
125
+
126
+ ## Requirement
127
+
128
+ The Diamond must have the Service DID Registry facet cut into it. Without it every call
129
+ from this library reverts.
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright (c) 2025 Comunidad de Madrid & Alastria
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ *
7
+ * You may obtain a copy of the License at
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export { ServiceDidRegistryContext } from "./src/ServiceDidRegistryContext.js";
17
+ export { ServiceDidRegistryQueries } from "./src/ServiceDidRegistryQueries.js";
18
+ export { ServiceDidRegistryTransactions } from "./src/ServiceDidRegistryTransactions.js";
19
+ export { ServiceDidTransactionExecutor } from "./src/ServiceDidTransactionExecutor.js";
20
+ export type { ServiceDidRecord, ServiceDidParts, ServiceDidInactiveReason, GetServiceDidsByControllerResult, } from "./src/serviceDid.types.js";
21
+ export type { DidW3CDocument } from "./src/types.js";
22
+ export { MAX_SERVICE_DOCUMENT_BYTES, RESERVED_DOCUMENT_KEYS, ServiceDocumentError, parseServiceDocument, serializeServiceDocument, } from "./src/utils/serviceDocument.utils.js";
23
+ export type { ServiceDocument } from "./src/utils/serviceDocument.utils.js";
24
+ export { buildServiceDid, parseServiceDid, serviceDidToHex, computeServiceDidHex, signingKeyAddress, toUncompressedPublicKey, } from "./src/utils/serviceDid.utils.js";
25
+ export { didToHex, hexToDid } from "./src/utils/did.utils.js";
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,CAAC;AAC/E,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AACzF,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAEvF,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,wBAAwB,EACxB,gCAAgC,GACjC,MAAM,2BAA2B,CAAC;AACnC,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,EACtB,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"}
package/dist/index.js ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright (c) 2025 Comunidad de Madrid & Alastria
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ *
7
+ * You may obtain a copy of the License at
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export { ServiceDidRegistryContext } from "./src/ServiceDidRegistryContext.js";
17
+ export { ServiceDidRegistryQueries } from "./src/ServiceDidRegistryQueries.js";
18
+ export { ServiceDidRegistryTransactions } from "./src/ServiceDidRegistryTransactions.js";
19
+ export { ServiceDidTransactionExecutor } from "./src/ServiceDidTransactionExecutor.js";
20
+ export { MAX_SERVICE_DOCUMENT_BYTES, RESERVED_DOCUMENT_KEYS, ServiceDocumentError, parseServiceDocument, serializeServiceDocument, } from "./src/utils/serviceDocument.utils.js";
21
+ export { buildServiceDid, parseServiceDid, serviceDidToHex, computeServiceDidHex, signingKeyAddress, toUncompressedPublicKey, } from "./src/utils/serviceDid.utils.js";
22
+ // La codificación del DID organizacional se exporta a propósito: es la pieza que este
23
+ // paquete comparte con @red-isbe/did-isbe-registry, y tenerla accesible permite
24
+ // comprobar desde fuera que ambas implementaciones coinciden.
25
+ export { didToHex, hexToDid } from "./src/utils/did.utils.js";
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAEF,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AACzF,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AASvF,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EACL,eAAe,EACf,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,iCAAiC,CAAC;AAEzC,sFAAsF;AACtF,gFAAgF;AAChF,8DAA8D;AAC9D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Copyright (c) 2025 Comunidad de Madrid & Alastria
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ *
7
+ * You may obtain a copy of the License at
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Contract, JsonRpcProvider } from "ethers";
17
+ /**
18
+ * Binding to the Service DID Registry facet.
19
+ *
20
+ * The address is the same diamond the DID Registry lives in — the registry is a facet,
21
+ * not a separate contract — so a consumer that needs both surfaces holds two contexts
22
+ * pointing at one address, each carrying its own ABI.
23
+ *
24
+ * `modelDeployId` is the network discriminator that appears in DID strings ("uc" for
25
+ * Case), the same value `DidRegistryContext` carries.
26
+ *
27
+ * `networkEllipticType` is the curve the network itself operates on — secp256k1 on
28
+ * Case, P-256 on Bare. It is configuration rather than something read from the chain:
29
+ * the registry stores the curve of each key but exposes no getter for the network's
30
+ * own, and a resolver needs it to decide whether a derived address is usable.
31
+ */
32
+ export declare class ServiceDidRegistryContext {
33
+ provider: JsonRpcProvider;
34
+ modelDeployId: string;
35
+ contractAddress: string;
36
+ networkEllipticType: number;
37
+ contract: Contract;
38
+ constructor(provider: JsonRpcProvider, modelDeployId: string, diamondAddress: string, networkEllipticType?: number);
39
+ }
40
+ //# sourceMappingURL=ServiceDidRegistryContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServiceDidRegistryContext.d.ts","sourceRoot":"","sources":["../../src/ServiceDidRegistryContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAEF,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAGnD;;;;;;;;;;;;;;GAcG;AACH,qBAAa,yBAAyB;IACpC,QAAQ,EAAE,eAAe,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,QAAQ,CAAC;gBAGjB,QAAQ,EAAE,eAAe,EACzB,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,EACtB,mBAAmB,SAAI;CAY1B"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Copyright (c) 2025 Comunidad de Madrid & Alastria
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ *
7
+ * You may obtain a copy of the License at
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { Contract, JsonRpcProvider } from "ethers";
17
+ import { IServiceDidRegistryAbi } from "./abi/IServiceDidRegistry.abi.js";
18
+ /**
19
+ * Binding to the Service DID Registry facet.
20
+ *
21
+ * The address is the same diamond the DID Registry lives in — the registry is a facet,
22
+ * not a separate contract — so a consumer that needs both surfaces holds two contexts
23
+ * pointing at one address, each carrying its own ABI.
24
+ *
25
+ * `modelDeployId` is the network discriminator that appears in DID strings ("uc" for
26
+ * Case), the same value `DidRegistryContext` carries.
27
+ *
28
+ * `networkEllipticType` is the curve the network itself operates on — secp256k1 on
29
+ * Case, P-256 on Bare. It is configuration rather than something read from the chain:
30
+ * the registry stores the curve of each key but exposes no getter for the network's
31
+ * own, and a resolver needs it to decide whether a derived address is usable.
32
+ */
33
+ export class ServiceDidRegistryContext {
34
+ constructor(provider, modelDeployId, diamondAddress, networkEllipticType = 1) {
35
+ this.provider = provider;
36
+ this.modelDeployId = modelDeployId;
37
+ this.contractAddress = diamondAddress;
38
+ this.networkEllipticType = networkEllipticType;
39
+ this.contract = new Contract(this.contractAddress, IServiceDidRegistryAbi, this.provider);
40
+ }
41
+ }
42
+ //# sourceMappingURL=ServiceDidRegistryContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServiceDidRegistryContext.js","sourceRoot":"","sources":["../../src/ServiceDidRegistryContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAEF,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAE1E;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,yBAAyB;IAOpC,YACE,QAAyB,EACzB,aAAqB,EACrB,cAAsB,EACtB,mBAAmB,GAAG,CAAC;QAEvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QACtC,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;QAC/C,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAC1B,IAAI,CAAC,eAAe,EACpB,sBAA0C,EAC1C,IAAI,CAAC,QAAQ,CACd,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Copyright (c) 2025 Comunidad de Madrid & Alastria
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ *
7
+ * You may obtain a copy of the License at
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { parseServiceDid, serviceDidToHex } from "./utils/serviceDid.utils.js";
17
+ import { ServiceDidRegistryContext } from "./ServiceDidRegistryContext.js";
18
+ import { type ServiceDocument } from "./utils/serviceDocument.utils.js";
19
+ import type { GetServiceDidsByControllerResult, ServiceDidInactiveReason, ServiceDidRecord } from "./serviceDid.types.js";
20
+ import type { DidW3CDocument } from "./types.js";
21
+ /** secp256k1, the curve the Case network operates on. */
22
+ export declare const ELLIPTIC_TYPE_SECP256K1 = 1;
23
+ /** P-256, the curve the Bare network operates on. */
24
+ export declare const ELLIPTIC_TYPE_P256 = 2;
25
+ /**
26
+ * Options for resolving a service identity into a W3C DID Document.
27
+ */
28
+ export type ResolveServiceDidOptions = {
29
+ /**
30
+ * Reports whether the controlling organisation is still operative.
31
+ *
32
+ * Deactivating a parent is not propagated on-chain — writing to every child would
33
+ * cost gas and add nothing the parent's own state does not already say — so the
34
+ * cascade is applied here, at resolution time. Supplied as a callback rather than
35
+ * by importing the organisational queries, so this module stays independent of them
36
+ * and the caller decides what "operative" means for its deployment.
37
+ *
38
+ * When omitted the cascade is not evaluated, and a service whose parent is no longer
39
+ * operative will still resolve as valid.
40
+ */
41
+ isControllerActive?: (controllerDid: string) => Promise<boolean>;
42
+ /** Seconds since the epoch to evaluate expiry against. Defaults to now. */
43
+ now?: number;
44
+ };
45
+ /**
46
+ * Read surface of the Service DID Registry, and the resolver for the
47
+ * `did:isbe:svc:` sub-namespace.
48
+ */
49
+ export declare class ServiceDidRegistryQueries {
50
+ private configManager;
51
+ constructor(configManager: ServiceDidRegistryContext);
52
+ /**
53
+ * Reads a service identity.
54
+ *
55
+ * Reverts on-chain for an identifier that was never registered; use
56
+ * `isServiceDidActive` to probe without an exception. Expired and deactivated
57
+ * records are returned verbatim, so the caller applies its own validity policy.
58
+ */
59
+ getServiceDid(serviceDid: string): Promise<ServiceDidRecord>;
60
+ /**
61
+ * Lists the service identities of a controller.
62
+ *
63
+ * Pages start at one, matching the registry's other paginated getters, and `total`
64
+ * comes back alongside the page — which is why there is no separate count call.
65
+ */
66
+ getServiceDidsByController(controllerDid: string, page?: number, pageSize?: number): Promise<GetServiceDidsByControllerResult>;
67
+ /**
68
+ * Reports whether a service identity is usable right now.
69
+ *
70
+ * False for an unknown identifier as well as for one deactivated or past its expiry,
71
+ * so it never throws. It does not evaluate the parent: that cascade belongs to
72
+ * `toDidDocumentW3C`.
73
+ */
74
+ isServiceDidActive(serviceDid: string): Promise<boolean>;
75
+ /**
76
+ * Address derived from the signing key of a service identity.
77
+ *
78
+ * Only meaningful when the key is on the curve the network operates on. For any
79
+ * other curve no account can transact with it, and it must not be published as a
80
+ * `blockchainAccountId`.
81
+ */
82
+ signingKeyAddressOf(serviceDid: string): Promise<string>;
83
+ /**
84
+ * Reads the free-form fields of a service identity, or `null` when it has none.
85
+ *
86
+ * Also `null` against a registry deployed before documents existed, where the call
87
+ * itself fails: resolution keeps working there, it just has no extra fields to add.
88
+ */
89
+ getServiceDocument(serviceDid: string): Promise<ServiceDocument | null>;
90
+ /**
91
+ * Resolves a service identity into a W3C DID Document.
92
+ *
93
+ * Three things can make an identity resolve as no longer valid, and they are checked
94
+ * in this order: it was deactivated, it passed its expiry, or its controlling
95
+ * organisation stopped being operative. The last one is only evaluated when the
96
+ * caller supplies `isControllerActive`.
97
+ *
98
+ * The verification method depends on the curve, not on the network: a key on the
99
+ * network's own curve yields `EcdsaSecp256k1RecoveryMethod2020` with a
100
+ * `blockchainAccountId`, and any other curve yields `JsonWebKey2020` carrying the
101
+ * coordinates. Emitting a `blockchainAccountId` for a key no account can use would
102
+ * point a verifier at an address that can never sign.
103
+ *
104
+ * The service's free-form fields, if any, are added to the document. They can never
105
+ * override what the registry asserts: the identifier, the controller, the keys and
106
+ * the deactivation status always come from the record.
107
+ */
108
+ toDidDocumentW3C(serviceDid: string, options?: ResolveServiceDidOptions): Promise<DidW3CDocument & {
109
+ deactivated?: boolean;
110
+ reason?: ServiceDidInactiveReason;
111
+ }>;
112
+ /** Derives the identifier a controller and nonce produce, without a network call. */
113
+ computeServiceDid(controllerDid: string, nonce: bigint | number): string;
114
+ private inactiveReason;
115
+ private buildDocument;
116
+ /**
117
+ * Maps the on-chain struct into the shape this library returns.
118
+ *
119
+ * The readable identifier is rebuilt from the controller and the nonce rather than
120
+ * from the record's own key: a service identifier is a full digest, so the DID string
121
+ * cannot be recovered from it. Storing the nonce is what makes this possible.
122
+ */
123
+ private toRecord;
124
+ }
125
+ /** Re-exported so a caller can parse a service DID without importing the utils path. */
126
+ export { parseServiceDid, serviceDidToHex };
127
+ //# sourceMappingURL=ServiceDidRegistryQueries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServiceDidRegistryQueries.d.ts","sourceRoot":"","sources":["../../src/ServiceDidRegistryQueries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;EAcE;AAGF,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,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;;;;;;OAMG;IACG,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAO9D;;;;;;OAMG;IACG,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAO9D;;;;;OAKG;IACG,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAY7E;;;;;;;;;;;;;;;;;OAiBG;IACG,gBAAgB,CACpB,UAAU,EAAE,MAAM,EAClB,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,cAAc,GAAG;QAAE,WAAW,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,wBAAwB,CAAA;KAAE,CAAC;IAUzF,qFAAqF;IACrF,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM;YAI1D,cAAc;YAkBd,aAAa;IAiD3B;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ;CAsBjB;AAED,wFAAwF;AACxF,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,CAAC"}