@credo-ts/indy-vdr 0.5.0-alpha.101

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 (75) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +35 -0
  3. package/build/IndyVdrApi.d.ts +31 -0
  4. package/build/IndyVdrApi.js +82 -0
  5. package/build/IndyVdrApi.js.map +1 -0
  6. package/build/IndyVdrModule.d.ts +14 -0
  7. package/build/IndyVdrModule.js +38 -0
  8. package/build/IndyVdrModule.js.map +1 -0
  9. package/build/IndyVdrModuleConfig.d.ts +66 -0
  10. package/build/IndyVdrModuleConfig.js +18 -0
  11. package/build/IndyVdrModuleConfig.js.map +1 -0
  12. package/build/anoncreds/IndyVdrAnonCredsRegistry.d.ts +113 -0
  13. package/build/anoncreds/IndyVdrAnonCredsRegistry.js +681 -0
  14. package/build/anoncreds/IndyVdrAnonCredsRegistry.js.map +1 -0
  15. package/build/anoncreds/index.d.ts +1 -0
  16. package/build/anoncreds/index.js +18 -0
  17. package/build/anoncreds/index.js.map +1 -0
  18. package/build/anoncreds/utils/identifiers.d.ts +9 -0
  19. package/build/anoncreds/utils/identifiers.js +44 -0
  20. package/build/anoncreds/utils/identifiers.js.map +1 -0
  21. package/build/anoncreds/utils/transform.d.ts +32 -0
  22. package/build/anoncreds/utils/transform.js +104 -0
  23. package/build/anoncreds/utils/transform.js.map +1 -0
  24. package/build/dids/IndyVdrIndyDidRegistrar.d.ts +85 -0
  25. package/build/dids/IndyVdrIndyDidRegistrar.js +339 -0
  26. package/build/dids/IndyVdrIndyDidRegistrar.js.map +1 -0
  27. package/build/dids/IndyVdrIndyDidResolver.d.ts +6 -0
  28. package/build/dids/IndyVdrIndyDidResolver.js +38 -0
  29. package/build/dids/IndyVdrIndyDidResolver.js.map +1 -0
  30. package/build/dids/IndyVdrSovDidResolver.d.ts +8 -0
  31. package/build/dids/IndyVdrSovDidResolver.js +79 -0
  32. package/build/dids/IndyVdrSovDidResolver.js.map +1 -0
  33. package/build/dids/didIndyUtil.d.ts +47 -0
  34. package/build/dids/didIndyUtil.js +234 -0
  35. package/build/dids/didIndyUtil.js.map +1 -0
  36. package/build/dids/didSovUtil.d.ts +26 -0
  37. package/build/dids/didSovUtil.js +155 -0
  38. package/build/dids/didSovUtil.js.map +1 -0
  39. package/build/dids/index.d.ts +3 -0
  40. package/build/dids/index.js +10 -0
  41. package/build/dids/index.js.map +1 -0
  42. package/build/error/IndyVdrError.d.ts +6 -0
  43. package/build/error/IndyVdrError.js +11 -0
  44. package/build/error/IndyVdrError.js.map +1 -0
  45. package/build/error/IndyVdrNotConfiguredError.d.ts +6 -0
  46. package/build/error/IndyVdrNotConfiguredError.js +11 -0
  47. package/build/error/IndyVdrNotConfiguredError.js.map +1 -0
  48. package/build/error/IndyVdrNotFound.d.ts +6 -0
  49. package/build/error/IndyVdrNotFound.js +11 -0
  50. package/build/error/IndyVdrNotFound.js.map +1 -0
  51. package/build/error/index.d.ts +3 -0
  52. package/build/error/index.js +20 -0
  53. package/build/error/index.js.map +1 -0
  54. package/build/index.d.ts +5 -0
  55. package/build/index.js +27 -0
  56. package/build/index.js.map +1 -0
  57. package/build/pool/IndyVdrPool.d.ts +54 -0
  58. package/build/pool/IndyVdrPool.js +131 -0
  59. package/build/pool/IndyVdrPool.js.map +1 -0
  60. package/build/pool/IndyVdrPoolService.d.ts +52 -0
  61. package/build/pool/IndyVdrPoolService.js +173 -0
  62. package/build/pool/IndyVdrPoolService.js.map +1 -0
  63. package/build/pool/index.d.ts +2 -0
  64. package/build/pool/index.js +19 -0
  65. package/build/pool/index.js.map +1 -0
  66. package/build/utils/did.d.ts +32 -0
  67. package/build/utils/did.js +57 -0
  68. package/build/utils/did.js.map +1 -0
  69. package/build/utils/promises.d.ts +11 -0
  70. package/build/utils/promises.js +27 -0
  71. package/build/utils/promises.js.map +1 -0
  72. package/build/utils/sign.d.ts +5 -0
  73. package/build/utils/sign.js +24 -0
  74. package/build/utils/sign.js.map +1 -0
  75. package/package.json +44 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2020-present Hyperledger Contributors.
190
+ Copyright 2021 Queen’s Printer for Ontario. Mostafa Youssef (https://github.com/MosCD3), Amit Padmani (https://github.com/nbAmit), Prasad Katkar (https://github.com/NB-PrasadKatkar), Mike Richardson (https://github.com/NB-MikeRichardson)
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,35 @@
1
+ <p align="center">
2
+ <br />
3
+ <img
4
+ alt="Hyperledger Aries logo"
5
+ src="https://raw.githubusercontent.com/openwallet-foundation/credo-ts/aa31131825e3331dc93694bc58414d955dcb1129/images/aries-logo.png"
6
+ height="250px"
7
+ />
8
+ </p>
9
+ <h1 align="center"><b>Credo - Indy Verifiable Data Registry (Indy-Vdr)</b></h1>
10
+ <p align="center">
11
+ <a
12
+ href="https://raw.githubusercontent.com/openwallet-foundation/credo-ts/main/LICENSE"
13
+ ><img
14
+ alt="License"
15
+ src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"
16
+ /></a>
17
+ <a href="https://www.typescriptlang.org/"
18
+ ><img
19
+ alt="typescript"
20
+ src="https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg"
21
+ /></a>
22
+ <a href="https://www.npmjs.com/package/@credo-ts/indy-vdr"
23
+ ><img
24
+ alt="@credo-ts/anoncreds version"
25
+ src="https://img.shields.io/npm/v/@credo-ts/indy-vdr"
26
+ /></a>
27
+
28
+ </p>
29
+ <br />
30
+
31
+ ### Installation
32
+
33
+ ### Quick start
34
+
35
+ ### Example of usage
@@ -0,0 +1,31 @@
1
+ import { AgentContext } from '@credo-ts/core';
2
+ import { IndyVdrPoolService } from './pool';
3
+ export declare class IndyVdrApi {
4
+ private agentContext;
5
+ private indyVdrPoolService;
6
+ constructor(agentContext: AgentContext, indyVdrPoolService: IndyVdrPoolService);
7
+ private multiSignRequest;
8
+ private signRequest;
9
+ /**
10
+ * This method refreshes the pool connection and ensures the pool is up to date with the ledger.
11
+ */
12
+ refreshPoolConnections(): Promise<PromiseSettledResult<void>[]>;
13
+ /**
14
+ * This method gets the updated transactions of the pool.
15
+ * @returns The transactions of the pool ledger
16
+ */
17
+ getAllPoolTransactions(): Promise<PromiseSettledResult<import("@hyperledger/indy-vdr-shared").Transactions>[]>;
18
+ /**
19
+ * This method endorses a transaction. The transaction can be either a string or a JSON object.
20
+ * If the transaction has a signature, it means the transaction was created by another author and will be endorsed.
21
+ * This requires the `endorser` on the transaction to be equal to the unqualified variant of the `endorserDid`.
22
+ *
23
+ * If the transaction is not signed, we have a special case where the endorser will author the transaction.
24
+ * This is required when a new did is created, as the author and the endorser did must already exist on the ledger.
25
+ * In this case, the author did (`identifier`) must be equal to the unqualified identifier of the `endorserDid`.
26
+ * @param transaction the transaction body to be endorsed
27
+ * @param endorserDid the did of the endorser
28
+ * @returns An endorsed transaction
29
+ */
30
+ endorseTransaction(transaction: string | Record<string, unknown>, endorserDid: string): Promise<string>;
31
+ }
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.IndyVdrApi = void 0;
13
+ const anoncreds_1 = require("@credo-ts/anoncreds");
14
+ const core_1 = require("@credo-ts/core");
15
+ const indy_vdr_shared_1 = require("@hyperledger/indy-vdr-shared");
16
+ const didIndyUtil_1 = require("./dids/didIndyUtil");
17
+ const error_1 = require("./error");
18
+ const pool_1 = require("./pool");
19
+ const sign_1 = require("./utils/sign");
20
+ let IndyVdrApi = class IndyVdrApi {
21
+ constructor(agentContext, indyVdrPoolService) {
22
+ this.agentContext = agentContext;
23
+ this.indyVdrPoolService = indyVdrPoolService;
24
+ }
25
+ async multiSignRequest(request, signingKey, identifier) {
26
+ return (0, sign_1.multiSignRequest)(this.agentContext, request, signingKey, identifier);
27
+ }
28
+ async signRequest(request, submitterDid) {
29
+ const { pool } = await this.indyVdrPoolService.getPoolForDid(this.agentContext, submitterDid);
30
+ return (0, sign_1.signRequest)(this.agentContext, pool, request, submitterDid);
31
+ }
32
+ /**
33
+ * This method refreshes the pool connection and ensures the pool is up to date with the ledger.
34
+ */
35
+ refreshPoolConnections() {
36
+ return this.indyVdrPoolService.refreshPoolConnections();
37
+ }
38
+ /**
39
+ * This method gets the updated transactions of the pool.
40
+ * @returns The transactions of the pool ledger
41
+ */
42
+ getAllPoolTransactions() {
43
+ return this.indyVdrPoolService.getAllPoolTransactions();
44
+ }
45
+ /**
46
+ * This method endorses a transaction. The transaction can be either a string or a JSON object.
47
+ * If the transaction has a signature, it means the transaction was created by another author and will be endorsed.
48
+ * This requires the `endorser` on the transaction to be equal to the unqualified variant of the `endorserDid`.
49
+ *
50
+ * If the transaction is not signed, we have a special case where the endorser will author the transaction.
51
+ * This is required when a new did is created, as the author and the endorser did must already exist on the ledger.
52
+ * In this case, the author did (`identifier`) must be equal to the unqualified identifier of the `endorserDid`.
53
+ * @param transaction the transaction body to be endorsed
54
+ * @param endorserDid the did of the endorser
55
+ * @returns An endorsed transaction
56
+ */
57
+ async endorseTransaction(transaction, endorserDid) {
58
+ const endorserSigningKey = await (0, didIndyUtil_1.verificationKeyForIndyDid)(this.agentContext, endorserDid);
59
+ const { namespaceIdentifier } = (0, anoncreds_1.parseIndyDid)(endorserDid);
60
+ const request = new indy_vdr_shared_1.CustomRequest({ customRequest: transaction });
61
+ let endorsedTransaction;
62
+ // the request is not parsed correctly due to too large numbers. The reqId overflows.
63
+ const txBody = typeof transaction === 'string' ? JSON.parse(transaction) : transaction;
64
+ if (txBody.signature) {
65
+ if (txBody.endorser !== namespaceIdentifier)
66
+ throw new error_1.IndyVdrError('Submitter does not match Endorser');
67
+ endorsedTransaction = await this.multiSignRequest(request, endorserSigningKey, namespaceIdentifier);
68
+ }
69
+ else {
70
+ if (txBody.identifier !== namespaceIdentifier)
71
+ throw new error_1.IndyVdrError('Submitter does not match identifier');
72
+ endorsedTransaction = await this.signRequest(request, endorserDid);
73
+ }
74
+ return endorsedTransaction.body;
75
+ }
76
+ };
77
+ IndyVdrApi = __decorate([
78
+ (0, core_1.injectable)(),
79
+ __metadata("design:paramtypes", [core_1.AgentContext, pool_1.IndyVdrPoolService])
80
+ ], IndyVdrApi);
81
+ exports.IndyVdrApi = IndyVdrApi;
82
+ //# sourceMappingURL=IndyVdrApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IndyVdrApi.js","sourceRoot":"","sources":["../src/IndyVdrApi.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,mDAAkD;AAClD,yCAAyD;AACzD,kEAA4D;AAE5D,oDAA8D;AAC9D,mCAAsC;AACtC,iCAA2C;AAC3C,uCAA4D;AAGrD,IAAM,UAAU,GAAhB,MAAM,UAAU;IAIrB,YAAmB,YAA0B,EAAE,kBAAsC;QACnF,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;IAC9C,CAAC;IAEO,KAAK,CAAC,gBAAgB,CAC5B,OAAgB,EAChB,UAAe,EACf,UAAkB;QAElB,OAAO,IAAA,uBAAgB,EAAC,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,CAAC,CAAA;IAC7E,CAAC;IAEO,KAAK,CAAC,WAAW,CAAiC,OAAgB,EAAE,YAAoB;QAC9F,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,CAAA;QAC7F,OAAO,IAAA,kBAAW,EAAC,IAAI,CAAC,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,CAAC,CAAA;IACpE,CAAC;IAED;;OAEG;IACI,sBAAsB;QAC3B,OAAO,IAAI,CAAC,kBAAkB,CAAC,sBAAsB,EAAE,CAAA;IACzD,CAAC;IAED;;;OAGG;IACI,sBAAsB;QAC3B,OAAO,IAAI,CAAC,kBAAkB,CAAC,sBAAsB,EAAE,CAAA;IACzD,CAAC;IAED;;;;;;;;;;;OAWG;IACI,KAAK,CAAC,kBAAkB,CAAC,WAA6C,EAAE,WAAmB;QAChG,MAAM,kBAAkB,GAAG,MAAM,IAAA,uCAAyB,EAAC,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,CAAA;QAC1F,MAAM,EAAE,mBAAmB,EAAE,GAAG,IAAA,wBAAY,EAAC,WAAW,CAAC,CAAA;QAEzD,MAAM,OAAO,GAAG,IAAI,+BAAa,CAAC,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC,CAAA;QACjE,IAAI,mBAAkC,CAAA;QAEtC,qFAAqF;QACrF,MAAM,MAAM,GAAG,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAA;QACtF,IAAI,MAAM,CAAC,SAAS,EAAE;YACpB,IAAI,MAAM,CAAC,QAAQ,KAAK,mBAAmB;gBAAE,MAAM,IAAI,oBAAY,CAAC,mCAAmC,CAAC,CAAA;YACxG,mBAAmB,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,CAAC,CAAA;SACpG;aAAM;YACL,IAAI,MAAM,CAAC,UAAU,KAAK,mBAAmB;gBAAE,MAAM,IAAI,oBAAY,CAAC,qCAAqC,CAAC,CAAA;YAC5G,mBAAmB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;SACnE;QACD,OAAO,mBAAmB,CAAC,IAAI,CAAA;IACjC,CAAC;CACF,CAAA;AAnEY,UAAU;IADtB,IAAA,iBAAU,GAAE;qCAKsB,mBAAY,EAAsB,yBAAkB;GAJ1E,UAAU,CAmEtB;AAnEY,gCAAU"}
@@ -0,0 +1,14 @@
1
+ import type { IndyVdrModuleConfigOptions } from './IndyVdrModuleConfig';
2
+ import type { AgentContext, DependencyManager, Module } from '@credo-ts/core';
3
+ import { IndyVdrApi } from './IndyVdrApi';
4
+ import { IndyVdrModuleConfig } from './IndyVdrModuleConfig';
5
+ /**
6
+ * @public
7
+ * */
8
+ export declare class IndyVdrModule implements Module {
9
+ readonly config: IndyVdrModuleConfig;
10
+ readonly api: typeof IndyVdrApi;
11
+ constructor(config: IndyVdrModuleConfigOptions);
12
+ register(dependencyManager: DependencyManager): void;
13
+ initialize(agentContext: AgentContext): Promise<void>;
14
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IndyVdrModule = void 0;
4
+ const core_1 = require("@credo-ts/core");
5
+ const IndyVdrApi_1 = require("./IndyVdrApi");
6
+ const IndyVdrModuleConfig_1 = require("./IndyVdrModuleConfig");
7
+ const IndyVdrPoolService_1 = require("./pool/IndyVdrPoolService");
8
+ /**
9
+ * @public
10
+ * */
11
+ class IndyVdrModule {
12
+ constructor(config) {
13
+ this.api = IndyVdrApi_1.IndyVdrApi;
14
+ this.config = new IndyVdrModuleConfig_1.IndyVdrModuleConfig(config);
15
+ }
16
+ register(dependencyManager) {
17
+ // Warn about experimental module
18
+ dependencyManager
19
+ .resolve(core_1.AgentConfig)
20
+ .logger.warn("The '@credo-ts/indy-vdr' module is experimental and could have unexpected breaking changes. When using this module, make sure to use strict versions for all @aries-framework packages.");
21
+ // Config
22
+ dependencyManager.registerInstance(IndyVdrModuleConfig_1.IndyVdrModuleConfig, this.config);
23
+ // Services
24
+ dependencyManager.registerSingleton(IndyVdrPoolService_1.IndyVdrPoolService);
25
+ // Api
26
+ dependencyManager.registerContextScoped(IndyVdrApi_1.IndyVdrApi);
27
+ }
28
+ async initialize(agentContext) {
29
+ const indyVdrPoolService = agentContext.dependencyManager.resolve(IndyVdrPoolService_1.IndyVdrPoolService);
30
+ for (const pool of indyVdrPoolService.pools) {
31
+ if (pool.config.connectOnStartup) {
32
+ await pool.connect();
33
+ }
34
+ }
35
+ }
36
+ }
37
+ exports.IndyVdrModule = IndyVdrModule;
38
+ //# sourceMappingURL=IndyVdrModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IndyVdrModule.js","sourceRoot":"","sources":["../src/IndyVdrModule.ts"],"names":[],"mappings":";;;AAGA,yCAA4C;AAE5C,6CAAyC;AACzC,+DAA2D;AAC3D,kEAA8D;AAE9D;;KAEK;AACL,MAAa,aAAa;IAIxB,YAAmB,MAAkC;QAFrC,QAAG,GAAG,uBAAU,CAAA;QAG9B,IAAI,CAAC,MAAM,GAAG,IAAI,yCAAmB,CAAC,MAAM,CAAC,CAAA;IAC/C,CAAC;IAEM,QAAQ,CAAC,iBAAoC;QAClD,iCAAiC;QACjC,iBAAiB;aACd,OAAO,CAAC,kBAAW,CAAC;aACpB,MAAM,CAAC,IAAI,CACV,yLAAyL,CAC1L,CAAA;QAEH,SAAS;QACT,iBAAiB,CAAC,gBAAgB,CAAC,yCAAmB,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QAEpE,WAAW;QACX,iBAAiB,CAAC,iBAAiB,CAAC,uCAAkB,CAAC,CAAA;QAEvD,MAAM;QACN,iBAAiB,CAAC,qBAAqB,CAAC,uBAAU,CAAC,CAAA;IACrD,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,YAA0B;QAChD,MAAM,kBAAkB,GAAG,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,uCAAkB,CAAC,CAAA;QAErF,KAAK,MAAM,IAAI,IAAI,kBAAkB,CAAC,KAAK,EAAE;YAC3C,IAAI,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE;gBAChC,MAAM,IAAI,CAAC,OAAO,EAAE,CAAA;aACrB;SACF;IACH,CAAC;CACF;AAnCD,sCAmCC"}
@@ -0,0 +1,66 @@
1
+ import type { IndyVdrPoolConfig } from './pool';
2
+ import type { IndyVdr } from '@hyperledger/indy-vdr-shared';
3
+ export interface IndyVdrModuleConfigOptions {
4
+ /**
5
+ *
6
+ * ## Node.JS
7
+ *
8
+ * ```ts
9
+ * import { indyVdr } from '@hyperledger/indy-vdr-nodejs';
10
+ *
11
+ * const agent = new Agent({
12
+ * config: {},
13
+ * dependencies: agentDependencies,
14
+ * modules: {
15
+ * indyVdr: new IndyVdrModule({
16
+ * indyVdr,
17
+ * })
18
+ * }
19
+ * })
20
+ * ```
21
+ *
22
+ * ## React Native
23
+ *
24
+ * ```ts
25
+ * import { indyVdr } from '@hyperledger/indy-vdr-react-native';
26
+ *
27
+ * const agent = new Agent({
28
+ * config: {},
29
+ * dependencies: agentDependencies,
30
+ * modules: {
31
+ * indyVdr: new IndyVdrModule({
32
+ * indyVdr,
33
+ * })
34
+ * }
35
+ * })
36
+ * ```
37
+ */
38
+ indyVdr: IndyVdr;
39
+ /**
40
+ * Array of indy networks to connect to.
41
+ *
42
+ * @default []
43
+ *
44
+ * @example
45
+ * ```
46
+ * {
47
+ * isProduction: false,
48
+ * genesisTransactions: 'xxx',
49
+ * indyNamespace: 'localhost:test',
50
+ * transactionAuthorAgreement: {
51
+ * version: '1',
52
+ * acceptanceMechanism: 'accept'
53
+ * }
54
+ * }
55
+ * ```
56
+ */
57
+ networks: [IndyVdrPoolConfig, ...IndyVdrPoolConfig[]];
58
+ }
59
+ export declare class IndyVdrModuleConfig {
60
+ private options;
61
+ constructor(options: IndyVdrModuleConfigOptions);
62
+ /** See {@link IndyVdrModuleConfigOptions.networks} */
63
+ get networks(): [IndyVdrPoolConfig, ...IndyVdrPoolConfig[]];
64
+ /** See {@link IndyVdrModuleConfigOptions.indyVdr} */
65
+ get indyVdr(): IndyVdr;
66
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IndyVdrModuleConfig = void 0;
4
+ class IndyVdrModuleConfig {
5
+ constructor(options) {
6
+ this.options = options;
7
+ }
8
+ /** See {@link IndyVdrModuleConfigOptions.networks} */
9
+ get networks() {
10
+ return this.options.networks;
11
+ }
12
+ /** See {@link IndyVdrModuleConfigOptions.indyVdr} */
13
+ get indyVdr() {
14
+ return this.options.indyVdr;
15
+ }
16
+ }
17
+ exports.IndyVdrModuleConfig = IndyVdrModuleConfig;
18
+ //# sourceMappingURL=IndyVdrModuleConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IndyVdrModuleConfig.js","sourceRoot":"","sources":["../src/IndyVdrModuleConfig.ts"],"names":[],"mappings":";;;AA6DA,MAAa,mBAAmB;IAG9B,YAAmB,OAAmC;QACpD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,sDAAsD;IACtD,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAA;IAC9B,CAAC;IAED,qDAAqD;IACrD,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAA;IAC7B,CAAC;CACF;AAhBD,kDAgBC"}
@@ -0,0 +1,113 @@
1
+ import type { AnonCredsRegistry, GetCredentialDefinitionReturn, GetSchemaReturn, RegisterSchemaReturn, RegisterCredentialDefinitionReturn, GetRevocationStatusListReturn, GetRevocationRegistryDefinitionReturn, AnonCredsRevocationRegistryDefinition, RegisterRevocationRegistryDefinitionReturn, RegisterRevocationStatusListReturn, AnonCredsSchema, AnonCredsCredentialDefinition, RegisterSchemaReturnStateFailed, RegisterSchemaReturnStateFinished, RegisterSchemaReturnStateAction, RegisterSchemaReturnStateWait, RegisterCredentialDefinitionReturnStateAction, RegisterCredentialDefinitionReturnStateWait, RegisterCredentialDefinitionReturnStateFinished, RegisterCredentialDefinitionReturnStateFailed, RegisterRevocationRegistryDefinitionReturnStateFinished, RegisterRevocationRegistryDefinitionReturnStateFailed, RegisterRevocationRegistryDefinitionReturnStateWait, RegisterRevocationRegistryDefinitionReturnStateAction, RegisterRevocationStatusListReturnStateFinished, RegisterRevocationStatusListReturnStateFailed, RegisterRevocationStatusListReturnStateWait, RegisterRevocationStatusListReturnStateAction, RegisterRevocationStatusListOptions } from '@credo-ts/anoncreds';
2
+ import type { AgentContext } from '@credo-ts/core';
3
+ export declare class IndyVdrAnonCredsRegistry implements AnonCredsRegistry {
4
+ readonly methodName = "indy";
5
+ readonly supportedIdentifier: RegExp;
6
+ getSchema(agentContext: AgentContext, schemaId: string): Promise<GetSchemaReturn>;
7
+ registerSchema(agentContext: AgentContext, options: IndyVdrRegisterSchema): Promise<IndyVdrRegisterSchemaReturn>;
8
+ getCredentialDefinition(agentContext: AgentContext, credentialDefinitionId: string): Promise<GetCredentialDefinitionReturn>;
9
+ registerCredentialDefinition(agentContext: AgentContext, options: IndyVdrRegisterCredentialDefinition): Promise<IndyVdrRegisterCredentialDefinitionReturn>;
10
+ getRevocationRegistryDefinition(agentContext: AgentContext, revocationRegistryDefinitionId: string): Promise<GetRevocationRegistryDefinitionReturn>;
11
+ registerRevocationRegistryDefinition(agentContext: AgentContext, { options, revocationRegistryDefinition }: IndyVdrRegisterRevocationRegistryDefinition): Promise<IndyVdrRegisterRevocationRegistryDefinitionReturn>;
12
+ getRevocationStatusList(agentContext: AgentContext, revocationRegistryDefinitionId: string, timestamp: number): Promise<GetRevocationStatusListReturn>;
13
+ registerRevocationStatusList(agentContext: AgentContext, { options, revocationStatusList }: IndyVdrRegisterRevocationStatusList): Promise<IndyVdrRegisterRevocationStatusListReturn>;
14
+ private fetchIndySchemaWithSeqNo;
15
+ private fetchIndyRevocationDelta;
16
+ }
17
+ type InternalEndorsement = {
18
+ endorserMode: 'internal';
19
+ endorserDid: string;
20
+ endorsedTransaction?: never;
21
+ };
22
+ type ExternalEndorsementCreate = {
23
+ endorserMode: 'external';
24
+ endorserDid: string;
25
+ endorsedTransaction?: never;
26
+ };
27
+ type ExternalEndorsementSubmit = {
28
+ endorserMode: 'external';
29
+ endorserDid?: never;
30
+ endorsedTransaction: string;
31
+ };
32
+ export interface IndyVdrRegisterSchemaInternalOptions {
33
+ schema: AnonCredsSchema;
34
+ options: InternalEndorsement;
35
+ }
36
+ export interface IndyVdrRegisterSchemaExternalCreateOptions {
37
+ schema: AnonCredsSchema;
38
+ options: ExternalEndorsementCreate;
39
+ }
40
+ export interface IndyVdrRegisterSchemaExternalSubmitOptions {
41
+ schema: AnonCredsSchema;
42
+ options: ExternalEndorsementSubmit;
43
+ }
44
+ export interface IndyVdrRegisterSchemaReturnStateAction extends RegisterSchemaReturnStateAction {
45
+ action: 'endorseIndyTransaction';
46
+ schemaRequest: string;
47
+ }
48
+ export interface IndyVdrRegisterSchemaReturn extends RegisterSchemaReturn {
49
+ schemaState: RegisterSchemaReturnStateWait | IndyVdrRegisterSchemaReturnStateAction | RegisterSchemaReturnStateFinished | RegisterSchemaReturnStateFailed;
50
+ }
51
+ export type IndyVdrRegisterSchema = IndyVdrRegisterSchemaInternalOptions | IndyVdrRegisterSchemaExternalCreateOptions | IndyVdrRegisterSchemaExternalSubmitOptions;
52
+ export type IndyVdrRegisterSchemaOptions = IndyVdrRegisterSchema['options'];
53
+ export interface IndyVdrRegisterCredentialDefinitionInternalOptions {
54
+ credentialDefinition: AnonCredsCredentialDefinition;
55
+ options: InternalEndorsement;
56
+ }
57
+ export interface IndyVdrRegisterCredentialDefinitionExternalCreateOptions {
58
+ credentialDefinition: AnonCredsCredentialDefinition;
59
+ options: ExternalEndorsementCreate;
60
+ }
61
+ export interface IndyVdrRegisterCredentialDefinitionExternalSubmitOptions {
62
+ credentialDefinition: AnonCredsCredentialDefinition;
63
+ options: ExternalEndorsementSubmit;
64
+ }
65
+ export interface IndyVdrRegisterCredentialDefinitionReturnStateAction extends RegisterCredentialDefinitionReturnStateAction {
66
+ action: 'endorseIndyTransaction';
67
+ credentialDefinitionRequest: string;
68
+ }
69
+ export interface IndyVdrRegisterCredentialDefinitionReturn extends RegisterCredentialDefinitionReturn {
70
+ credentialDefinitionState: RegisterCredentialDefinitionReturnStateWait | IndyVdrRegisterCredentialDefinitionReturnStateAction | RegisterCredentialDefinitionReturnStateFinished | RegisterCredentialDefinitionReturnStateFailed;
71
+ }
72
+ export type IndyVdrRegisterCredentialDefinition = IndyVdrRegisterCredentialDefinitionInternalOptions | IndyVdrRegisterCredentialDefinitionExternalCreateOptions | IndyVdrRegisterCredentialDefinitionExternalSubmitOptions;
73
+ export type IndyVdrRegisterCredentialDefinitionOptions = IndyVdrRegisterCredentialDefinition['options'];
74
+ export interface IndyVdrRegisterRevocationRegistryDefinitionInternalOptions {
75
+ revocationRegistryDefinition: AnonCredsRevocationRegistryDefinition;
76
+ options: InternalEndorsement;
77
+ }
78
+ export interface IndyVdrRegisterRevocationRegistryDefinitionExternalCreateOptions {
79
+ revocationRegistryDefinition: AnonCredsRevocationRegistryDefinition;
80
+ options: ExternalEndorsementCreate;
81
+ }
82
+ export interface IndyVdrRegisterRevocationRegistryDefinitionExternalSubmitOptions {
83
+ revocationRegistryDefinition: AnonCredsRevocationRegistryDefinition;
84
+ options: ExternalEndorsementSubmit;
85
+ }
86
+ export interface IndyVdrRegisterRevocationRegistryDefinitionReturnStateAction extends RegisterRevocationRegistryDefinitionReturnStateAction {
87
+ action: 'endorseIndyTransaction';
88
+ revocationRegistryDefinitionRequest: string;
89
+ }
90
+ export interface IndyVdrRegisterRevocationRegistryDefinitionReturn extends RegisterRevocationRegistryDefinitionReturn {
91
+ revocationRegistryDefinitionState: IndyVdrRegisterRevocationRegistryDefinitionReturnStateAction | RegisterRevocationRegistryDefinitionReturnStateWait | RegisterRevocationRegistryDefinitionReturnStateFinished | RegisterRevocationRegistryDefinitionReturnStateFailed;
92
+ }
93
+ export type IndyVdrRegisterRevocationRegistryDefinition = IndyVdrRegisterRevocationRegistryDefinitionInternalOptions | IndyVdrRegisterRevocationRegistryDefinitionExternalCreateOptions | IndyVdrRegisterRevocationRegistryDefinitionExternalSubmitOptions;
94
+ export type IndyVdrRegisterRevocationRegistryDefinitionOptions = IndyVdrRegisterRevocationRegistryDefinition['options'];
95
+ export interface IndyVdrRegisterRevocationStatusListInternalOptions extends RegisterRevocationStatusListOptions {
96
+ options: InternalEndorsement;
97
+ }
98
+ export interface IndyVdrRegisterRevocationStatusListExternalCreateOptions extends RegisterRevocationStatusListOptions {
99
+ options: ExternalEndorsementCreate;
100
+ }
101
+ export interface IndyVdrRegisterRevocationStatusListExternalSubmitOptions extends RegisterRevocationStatusListOptions {
102
+ options: ExternalEndorsementSubmit;
103
+ }
104
+ export interface IndyVdrRegisterRevocationStatusListReturnStateAction extends RegisterRevocationStatusListReturnStateAction {
105
+ action: 'endorseIndyTransaction';
106
+ revocationStatusListRequest: string;
107
+ }
108
+ export interface IndyVdrRegisterRevocationStatusListReturn extends RegisterRevocationStatusListReturn {
109
+ revocationStatusListState: IndyVdrRegisterRevocationStatusListReturnStateAction | RegisterRevocationStatusListReturnStateWait | RegisterRevocationStatusListReturnStateFinished | RegisterRevocationStatusListReturnStateFailed;
110
+ }
111
+ export type IndyVdrRegisterRevocationStatusList = IndyVdrRegisterRevocationStatusListInternalOptions | IndyVdrRegisterRevocationStatusListExternalCreateOptions | IndyVdrRegisterRevocationStatusListExternalSubmitOptions;
112
+ export type IndyVdrRegisterRevocationStatusListOptions = IndyVdrRegisterRevocationStatusList['options'];
113
+ export {};