@veridid/kanon 0.0.0-stage → 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 (96) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +156 -2
  3. package/build/KanonApi.d.ts +52 -0
  4. package/build/KanonApi.d.ts.map +1 -0
  5. package/build/KanonApi.js +92 -0
  6. package/build/KanonApi.js.map +1 -0
  7. package/build/KanonModule.d.ts +15 -0
  8. package/build/KanonModule.d.ts.map +1 -0
  9. package/build/KanonModule.js +53 -0
  10. package/build/KanonModule.js.map +1 -0
  11. package/build/KanonModuleConfig.d.ts +123 -0
  12. package/build/KanonModuleConfig.d.ts.map +1 -0
  13. package/build/KanonModuleConfig.js +84 -0
  14. package/build/KanonModuleConfig.js.map +1 -0
  15. package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.js +10 -0
  16. package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.js +7 -0
  17. package/build/_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateParam.js +9 -0
  18. package/build/anoncreds/helpers/buildKanonCredentialAttributes.d.ts +33 -0
  19. package/build/anoncreds/helpers/buildKanonCredentialAttributes.d.ts.map +1 -0
  20. package/build/anoncreds/helpers/buildKanonCredentialAttributes.js +43 -0
  21. package/build/anoncreds/helpers/buildKanonCredentialAttributes.js.map +1 -0
  22. package/build/anoncreds/helpers/buildKanonProofRequest.d.ts +45 -0
  23. package/build/anoncreds/helpers/buildKanonProofRequest.d.ts.map +1 -0
  24. package/build/anoncreds/helpers/buildKanonProofRequest.js +45 -0
  25. package/build/anoncreds/helpers/buildKanonProofRequest.js.map +1 -0
  26. package/build/anoncreds/helpers/buildKanonSchema.d.ts +23 -0
  27. package/build/anoncreds/helpers/buildKanonSchema.d.ts.map +1 -0
  28. package/build/anoncreds/helpers/buildKanonSchema.js +27 -0
  29. package/build/anoncreds/helpers/buildKanonSchema.js.map +1 -0
  30. package/build/anoncreds/helpers/index.js +3 -0
  31. package/build/anoncreds/index.d.ts +8 -0
  32. package/build/anoncreds/index.js +9 -0
  33. package/build/anoncreds/services/KanonAnonCredsRegistry.d.ts +36 -0
  34. package/build/anoncreds/services/KanonAnonCredsRegistry.d.ts.map +1 -0
  35. package/build/anoncreds/services/KanonAnonCredsRegistry.js +298 -0
  36. package/build/anoncreds/services/KanonAnonCredsRegistry.js.map +1 -0
  37. package/build/anoncreds/services/KanonIssuanceTracker.d.ts +39 -0
  38. package/build/anoncreds/services/KanonIssuanceTracker.d.ts.map +1 -0
  39. package/build/anoncreds/services/KanonIssuanceTracker.js +141 -0
  40. package/build/anoncreds/services/KanonIssuanceTracker.js.map +1 -0
  41. package/build/anoncreds/services/KanonWrappedAnonCredsHolderService.d.ts +82 -0
  42. package/build/anoncreds/services/KanonWrappedAnonCredsHolderService.d.ts.map +1 -0
  43. package/build/anoncreds/services/KanonWrappedAnonCredsHolderService.js +316 -0
  44. package/build/anoncreds/services/KanonWrappedAnonCredsHolderService.js.map +1 -0
  45. package/build/anoncreds/services/KanonWrappedAnonCredsVerifierService.d.ts +67 -0
  46. package/build/anoncreds/services/KanonWrappedAnonCredsVerifierService.d.ts.map +1 -0
  47. package/build/anoncreds/services/KanonWrappedAnonCredsVerifierService.js +330 -0
  48. package/build/anoncreds/services/KanonWrappedAnonCredsVerifierService.js.map +1 -0
  49. package/build/anoncreds/utils/credIdHash.d.ts +2 -0
  50. package/build/anoncreds/utils/credIdHash.js +3 -0
  51. package/build/dids/KanonDidRegistrar.d.ts +47 -0
  52. package/build/dids/KanonDidRegistrar.d.ts.map +1 -0
  53. package/build/dids/KanonDidRegistrar.js +140 -0
  54. package/build/dids/KanonDidRegistrar.js.map +1 -0
  55. package/build/dids/KanonDidResolver.d.ts +18 -0
  56. package/build/dids/KanonDidResolver.d.ts.map +1 -0
  57. package/build/dids/KanonDidResolver.js +88 -0
  58. package/build/dids/KanonDidResolver.js.map +1 -0
  59. package/build/dids/didEtherUtils.d.ts +18 -0
  60. package/build/dids/didEtherUtils.d.ts.map +1 -0
  61. package/build/dids/didEtherUtils.js +47 -0
  62. package/build/dids/didEtherUtils.js.map +1 -0
  63. package/build/dids/index.js +3 -0
  64. package/build/index.d.ts +24 -0
  65. package/build/index.js +25 -0
  66. package/build/ledger/KanonClientService.d.ts +45 -0
  67. package/build/ledger/KanonClientService.d.ts.map +1 -0
  68. package/build/ledger/KanonClientService.js +111 -0
  69. package/build/ledger/KanonClientService.js.map +1 -0
  70. package/build/ledger/index.d.ts +1 -0
  71. package/build/ledger/index.js +1 -0
  72. package/build/utils/identifiers.d.ts +24 -0
  73. package/build/utils/identifiers.d.ts.map +1 -0
  74. package/build/utils/identifiers.js +39 -0
  75. package/build/utils/identifiers.js.map +1 -0
  76. package/build/zk/KanonZkApi.d.ts +186 -0
  77. package/build/zk/KanonZkApi.d.ts.map +1 -0
  78. package/build/zk/KanonZkApi.js +226 -0
  79. package/build/zk/KanonZkApi.js.map +1 -0
  80. package/build/zk/KanonZkIssuerKeyService.d.ts +107 -0
  81. package/build/zk/KanonZkIssuerKeyService.d.ts.map +1 -0
  82. package/build/zk/KanonZkIssuerKeyService.js +137 -0
  83. package/build/zk/KanonZkIssuerKeyService.js.map +1 -0
  84. package/build/zk/KanonZkPathService.d.ts +66 -0
  85. package/build/zk/KanonZkPathService.d.ts.map +1 -0
  86. package/build/zk/KanonZkPathService.js +163 -0
  87. package/build/zk/KanonZkPathService.js.map +1 -0
  88. package/build/zk/KanonZkService.d.ts +91 -0
  89. package/build/zk/KanonZkService.d.ts.map +1 -0
  90. package/build/zk/KanonZkService.js +165 -0
  91. package/build/zk/KanonZkService.js.map +1 -0
  92. package/build/zk/index.d.ts +4 -0
  93. package/build/zk/index.js +4 -0
  94. package/build/zk/modeBLeaves.js +48 -0
  95. package/build/zk/modeBLeaves.js.map +1 -0
  96. package/package.json +66 -3
package/LICENSE ADDED
@@ -0,0 +1,201 @@
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 tracking or 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 describing the origin of the Work and
141
+ 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 Support. 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 support.
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 2026 Ajna Inc
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
200
+ implied. See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,157 @@
1
- # Temporary Holding Version
1
+ <h1 align="center"><b>@veridid/kanon</b></h1>
2
+ <p align="center">
3
+ <a href="https://www.typescriptlang.org/"><img alt="typescript" src="https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg"/></a>
4
+ <a href="https://www.npmjs.com/package/@veridid/kanon"><img alt="npm version" src="https://img.shields.io/npm/v/@veridid/kanon"/></a>
5
+ <a href="https://www.npmjs.com/package/@ajna-inc/kanon-sdk"><img alt="sdk version" src="https://img.shields.io/npm/v/@ajna-inc/kanon-sdk?label=sdk"/></a>
6
+ </p>
2
7
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
8
+ Credo plugin for the **Kanon AnonCreds VDR** — runs on any EVM chain (Hyperledger Besu, Ethereum, L2s, private rollups). Drops into Credo agents unmodified, no changes to `@credo-ts/anoncreds` or `anoncreds-rs`.
9
+
10
+ > **Credo-ts 0.7.x.** `@veridid/kanon` 1.x targets Credo `0.7.x`. Earlier Credo lines were published as `@ajna-inc/kanon` (`^0.6` for Credo 0.6, `^0.5` for Credo 0.5).
11
+
12
+ What's inside:
13
+
14
+ - `did:kanon` registrar + resolver
15
+ - `KanonAnonCredsRegistry` — AnonCreds VDR backed by the Kanon contracts
16
+ - Wrapped `AnonCredsVerifierService` — after `verifyProof` succeeds, ANDs an on-chain `AnonCredsStatusRegistry.isRevoked(credDefId, credIdHash)` check
17
+ - `KanonIssuanceTracker` — subscribes to `DidCommCredentialStateChanged` and writes an on-chain issuance record when issuance finalises
18
+ - Chore-hiding helpers — `buildKanonSchema`, `buildKanonCredentialAttributes`, `buildKanonProofRequest` so schema authors and verifier authors never type `kanonCredId` by hand
19
+
20
+ ## Install
21
+
22
+ ```sh
23
+ pnpm add @veridid/kanon ethers
24
+ ```
25
+
26
+ (`@ajna-inc/kanon-sdk` is pulled in transitively from npm.)
27
+
28
+ ### Peer dependencies
29
+
30
+ - `@credo-ts/core` `>=0.7.0 <0.8`
31
+ - `@credo-ts/anoncreds` `>=0.7.0 <0.8`
32
+ - `@credo-ts/didcomm` `>=0.7.0 <0.8`
33
+ - `ethers` `^6.13.0` (shared with `@ajna-inc/kanon-sdk`, so the app has a single copy)
34
+
35
+ ## Usage
36
+
37
+ ```ts
38
+ import { Agent, DidsModule } from '@credo-ts/core'
39
+ import { AnonCredsModule } from '@credo-ts/anoncreds'
40
+ import {
41
+ KanonModule,
42
+ KanonAnonCredsRegistry,
43
+ KanonDidRegistrar,
44
+ KanonDidResolver,
45
+ buildKanonSchema,
46
+ } from '@veridid/kanon'
47
+
48
+ const agent = new Agent({
49
+ config: { /* … */ },
50
+ modules: {
51
+ anoncreds: new AnonCredsModule({
52
+ registries: [new KanonAnonCredsRegistry()],
53
+ }),
54
+ dids: new DidsModule({
55
+ registrars: [new KanonDidRegistrar()],
56
+ resolvers: [new KanonDidResolver()],
57
+ }),
58
+ // KanonModule MUST come AFTER AnonCredsModule so its
59
+ // AnonCredsVerifierService override (on-chain status check) wins.
60
+ kanon: new KanonModule({
61
+ rpcUrl: process.env.KANON_RPC_URL!,
62
+ privateKey: process.env.KANON_PRIVATE_KEY!,
63
+ // Either pass the on-chain address book (single contract for all 7
64
+ // registries — recommended) …
65
+ addressBook: process.env.KANON_ADDRESS_BOOK,
66
+ // … or pass a deployment inline / by file / by chainId:
67
+ // deployment: { chainId, addresses: { … } }
68
+ // deploymentPath: './deployments/1947.json'
69
+ // chainId: 1947
70
+ issuerOrgId: process.env.KANON_ISSUER_ORG_ID!, // 0x<64 hex> bytes32
71
+ }),
72
+ },
73
+ })
74
+
75
+ // 1. Mint the issuer DID (once per org).
76
+ const { didState } = await agent.dids.create({
77
+ method: 'kanon',
78
+ scope: 'org',
79
+ orgId: process.env.KANON_ISSUER_ORG_ID!,
80
+ })
81
+ const issuerDid = didState.did!
82
+
83
+ // 2. Register a schema on the kanon VDR. buildKanonSchema prepends the
84
+ // canonical `kanonCredId` attribute so revocation works.
85
+ await agent.modules.anoncreds.registerSchema({
86
+ schema: buildKanonSchema({
87
+ name: 'DriverLicense',
88
+ version: '1.0',
89
+ attrNames: ['fullName', 'dateOfBirth', 'licenseNumber'],
90
+ issuerId: issuerDid,
91
+ }),
92
+ options: { supportRevocation: false },
93
+ })
94
+ ```
95
+
96
+ ## What ships under the hood
97
+
98
+ - `kanonCredId` attribute injection in `buildKanonSchema` / `buildKanonCredentialAttributes` / `buildKanonProofRequest`
99
+ - Canonical hash via `@ajna-inc/kanon-sdk/anoncreds` (single source of truth)
100
+ - On-chain calls via the SDK's contract bindings — Kanon ABIs, addresses, deployment loader all come from one place
101
+
102
+ ## Mode B (optional ZK non-revocation)
103
+
104
+ A credential definition chooses its revocation mode when it is registered (`policyMask`):
105
+
106
+ - **Mode A** (`TIER_ONE_TIME`, default): per-credential issued/revoked status in the `AnonCredsStatusRegistry` contract.
107
+ - **Mode B** (`TIER_ZK_SNARK`): the issuer publishes credentials as leaves of a Poseidon Merkle tree in the `MerkleStateRegistry`
108
+ contract, and the holder adds a Groth16 proof of non-revocation to the presentation. Verifiers learn only that the
109
+ credential is valid, not which one it is.
110
+ - `TIER_ALL`: both.
111
+
112
+ Issuance, presentation and verification for Mode B are handled by this module. To revoke, use
113
+ `agent.modules.kanon.revokeCredential(credDefId, credId)`, which writes to every tier the credential definition uses.
114
+
115
+ To build a Mode B proof the holder needs the credential definition's current leaf set. It is fetched from the issuer's
116
+ CrMS at `GET {base}/api/kanon/mode-b/leaves?cred_def_id=…` (falling back to an on-chain event scan, which can hit RPC
117
+ block-range limits on a long-running chain). The base URL is resolved in this order:
118
+
119
+ 1. the `resolveLeavesBaseUrl(credDefId)` module option (sync or async);
120
+ 2. `KANON_ORG_BASE_URLS`: JSON `{"<orgHash>": "<crmsBase>"}`, keyed by the org in `did:kanon:org:<orgHash>/…`;
121
+ 3. `KANON_MODEB_LEAVES_BASE_URL`.
122
+
123
+ ```ts
124
+ new KanonModule({
125
+ // …
126
+ resolveLeavesBaseUrl: (credDefId) => crmsBaseUrlForIssuer(credDefId), // your issuer → CrMS routing
127
+ })
128
+ ```
129
+
130
+ ## React Native
131
+
132
+ The package is plain JavaScript (no native code) and works on React Native with Credo's
133
+ `@credo-ts/react-native` agent dependencies.
134
+
135
+ - Pass the deployment inline (`deployment`), by `chainId`, or use `addressBook`. `deploymentPath` needs Node.js file
136
+ system access and throws a clear error on React Native.
137
+ - Env vars are not available on a device: pass `resolveLeavesBaseUrl` so Mode B presentations can fetch the leaf set
138
+ (see above).
139
+ - `@ajna-inc/kanon-sdk` imports some Node.js built-ins (`fs`, `path`, `url`); map them to shims in your
140
+ Metro config (`resolver.resolveRequest`) as for other Credo modules.
141
+
142
+ ### Migrating from `kanon-react-native`
143
+
144
+ `kanon-react-native` (Credo 0.6) was a copy of this module with React Native fixes; those fixes are included here.
145
+
146
+ ```diff
147
+ - import { KanonModule, KanonAnonCredsRegistry } from 'kanon-react-native'
148
+ + import { KanonModule, KanonAnonCredsRegistry } from '@veridid/kanon'
149
+ ```
150
+
151
+ - Requires Credo 0.7 (`@credo-ts/*` `>=0.7.0 <0.8`).
152
+ - The API and module options are the same, including `resolveLeavesBaseUrl`.
153
+ - Remove any `kanon-react-native` patches; no `pod install` changes are needed.
154
+
155
+ ## License
156
+
157
+ Apache-2.0.
@@ -0,0 +1,52 @@
1
+ import { KanonZkApi } from "./zk/KanonZkApi.js";
2
+ import "./zk/index.js";
3
+ import { AgentContext } from "@credo-ts/core";
4
+
5
+ //#region src/KanonApi.d.ts
6
+ /**
7
+ * High-level facade over {@link KanonClientService}'s AnonCredsStatusRegistry
8
+ * methods. Each operation takes a `credDefId` — either the on-chain bytes32
9
+ * form OR the DID-URL form emitted by the AnonCreds module; we normalize on
10
+ * the way in — and a `credId` (the human-readable id placed in the
11
+ * `kanonCredId` attribute, hashed on the caller's behalf).
12
+ */
13
+ declare class KanonApi {
14
+ private agentContext;
15
+ constructor(agentContext: AgentContext);
16
+ private get ledger();
17
+ /** Mode B (Groth16 non-revocation) revoke + introspection surface. */
18
+ get zk(): KanonZkApi;
19
+ /**
20
+ * Writes an issuance record to `AnonCredsStatusRegistry`. Idempotent on the
21
+ * contract side; safe to call after `KanonIssuanceTracker` has already done it.
22
+ */
23
+ issueCredentialOnChain(credDefId: string, credId: string): Promise<any>;
24
+ /**
25
+ * Marks the (credDefId, credIdHash) pair as revoked on-chain. **Mode A only**
26
+ * — writes to AnonCredsStatusRegistry. Skips the write (no-op) when the
27
+ * credDef did not opt into TIER_ONE_TIME; in that case use `zk.revoke`.
28
+ */
29
+ revokeCredentialOnChain(credDefId: string, credId: string): Promise<any>;
30
+ /**
31
+ * Canonical revoke entry point. Reads the credDef's on-chain `policyMask`
32
+ * and writes to every tier it opted into:
33
+ * - `TIER_ONE_TIME` → AnonCredsStatusRegistry.revokeCredential
34
+ * - `TIER_ZK_SNARK` → MerkleStateRegistry.batchUpdate (rotates the root)
35
+ *
36
+ * Callers shouldn't reach for `revokeCredentialOnChain` (Mode A only) or
37
+ * the internal `KanonZkService.revoke` directly — this method routes
38
+ * correctly without the caller having to track the mask.
39
+ */
40
+ revokeCredential(credDefId: string, credId: string): Promise<void>;
41
+ /**
42
+ * Reads the revocation flag from the on-chain status registry.
43
+ */
44
+ isCredentialRevokedOnChain(credDefId: string, credId: string): Promise<boolean>;
45
+ /**
46
+ * Reads the full status enum (issued / revoked / unknown depending on contract).
47
+ */
48
+ getCredentialStatus(credDefId: string, credId: string): Promise<number>;
49
+ }
50
+ //#endregion
51
+ export { KanonApi };
52
+ //# sourceMappingURL=KanonApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KanonApi.d.ts","names":[],"sources":["../src/KanonApi.ts"],"mappings":";;;;;;;;AAgCA;;;;cACa,QAAA;EAAA,QACH,YAAA;cAEW,YAAA,EAAc,YAAA;EAAA,YAIrB,MAAA,CAAA;EAyDgE;EAAA,IApDjE,EAAA,CAAA,GAAM,UAAA;EA2D2D;;;;EAnD/D,sBAAA,CAAuB,SAAA,UAAmB,MAAA,WAAc,OAAA;EAjBlD;;;;;EA0BN,uBAAA,CAAwB,SAAA,UAAmB,MAAA,WAAc,OAAA;EATf;;;;;;;;;;EAuB1C,gBAAA,CAAiB,SAAA,UAAmB,MAAA,WAAiB,OAAA;EAqB1B;;;EAA3B,0BAAA,CAA2B,SAAA,UAAmB,MAAA,WAAiB,OAAA;EAO3C;;;EAApB,mBAAA,CAAoB,SAAA,UAAmB,MAAA,WAAiB,OAAA;AAAA"}
@@ -0,0 +1,92 @@
1
+ import { __decorate } from "./_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.js";
2
+ import { __decorateMetadata } from "./_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.js";
3
+ import { KanonClientService } from "./ledger/KanonClientService.js";
4
+ import "./ledger/index.js";
5
+ import { kanonCredIdHash } from "./anoncreds/utils/credIdHash.js";
6
+ import { KanonZkService } from "./zk/KanonZkService.js";
7
+ import { KanonZkApi } from "./zk/KanonZkApi.js";
8
+ import "./zk/index.js";
9
+ import { AgentContext, injectable } from "@credo-ts/core";
10
+ import { resourceIdToBytes32 } from "@ajna-inc/kanon-sdk/anoncreds";
11
+
12
+ //#region src/KanonApi.ts
13
+ var _ref;
14
+ /**
15
+ * Normalize a credDefId to its on-chain bytes32 form.
16
+ *
17
+ * The AnonCreds module emits credDefIds in the DID-URL form
18
+ * `did:kanon:org:0x.../anoncreds/v0/CLAIM_DEF/<schemaTag>/<tag>`
19
+ * — but the on-chain registries are keyed by the bytes32 hash of that URL.
20
+ * Every method on this API previously required callers to convert by hand
21
+ * via `resourceIdToBytes32`, which produced the worst kind of surprise when
22
+ * a caller passed the URL form and ethers' ABI encoder threw a cryptic
23
+ * "Invalid byte-string" error halfway through a contract call. We accept
24
+ * either form here and forward the bytes32 to the SDK.
25
+ */
26
+ function toBytes32CredDefId(credDefId) {
27
+ if (/^0x[0-9a-fA-F]{64}$/.test(credDefId)) return credDefId;
28
+ return resourceIdToBytes32(credDefId);
29
+ }
30
+ let KanonApi = class KanonApi {
31
+ constructor(agentContext) {
32
+ this.agentContext = agentContext;
33
+ }
34
+ get ledger() {
35
+ return this.agentContext.dependencyManager.resolve(KanonClientService);
36
+ }
37
+ /** Mode B (Groth16 non-revocation) revoke + introspection surface. */
38
+ get zk() {
39
+ return this.agentContext.dependencyManager.resolve(KanonZkApi);
40
+ }
41
+ /**
42
+ * Writes an issuance record to `AnonCredsStatusRegistry`. Idempotent on the
43
+ * contract side; safe to call after `KanonIssuanceTracker` has already done it.
44
+ */
45
+ async issueCredentialOnChain(credDefId, credId) {
46
+ return this.ledger.issueCredentialStatus(toBytes32CredDefId(credDefId), kanonCredIdHash(credId));
47
+ }
48
+ /**
49
+ * Marks the (credDefId, credIdHash) pair as revoked on-chain. **Mode A only**
50
+ * — writes to AnonCredsStatusRegistry. Skips the write (no-op) when the
51
+ * credDef did not opt into TIER_ONE_TIME; in that case use `zk.revoke`.
52
+ */
53
+ async revokeCredentialOnChain(credDefId, credId) {
54
+ return this.ledger.revokeCredentialStatus(toBytes32CredDefId(credDefId), kanonCredIdHash(credId));
55
+ }
56
+ /**
57
+ * Canonical revoke entry point. Reads the credDef's on-chain `policyMask`
58
+ * and writes to every tier it opted into:
59
+ * - `TIER_ONE_TIME` → AnonCredsStatusRegistry.revokeCredential
60
+ * - `TIER_ZK_SNARK` → MerkleStateRegistry.batchUpdate (rotates the root)
61
+ *
62
+ * Callers shouldn't reach for `revokeCredentialOnChain` (Mode A only) or
63
+ * the internal `KanonZkService.revoke` directly — this method routes
64
+ * correctly without the caller having to track the mask.
65
+ */
66
+ async revokeCredential(credDefId, credId) {
67
+ const client = this.ledger.client;
68
+ const credDefIdBytes32 = toBytes32CredDefId(credDefId);
69
+ const mask = await client.getCredDefPolicy(credDefIdBytes32);
70
+ const TIER_ONE_TIME = 1;
71
+ const TIER_ZK_SNARK = 2;
72
+ if ((mask & TIER_ONE_TIME) !== 0 && this.ledger.hasAnonCredsStatusRegistry()) await this.ledger.revokeCredentialStatus(credDefIdBytes32, kanonCredIdHash(credId));
73
+ if ((mask & TIER_ZK_SNARK) !== 0) await this.agentContext.dependencyManager.resolve(KanonZkService).revoke(this.agentContext, credDefId, [credId]);
74
+ }
75
+ /**
76
+ * Reads the revocation flag from the on-chain status registry.
77
+ */
78
+ async isCredentialRevokedOnChain(credDefId, credId) {
79
+ return this.ledger.isCredentialRevokedOnStatus(toBytes32CredDefId(credDefId), kanonCredIdHash(credId));
80
+ }
81
+ /**
82
+ * Reads the full status enum (issued / revoked / unknown depending on contract).
83
+ */
84
+ async getCredentialStatus(credDefId, credId) {
85
+ return this.ledger.getCredentialStatus(toBytes32CredDefId(credDefId), kanonCredIdHash(credId));
86
+ }
87
+ };
88
+ KanonApi = __decorate([injectable(), __decorateMetadata("design:paramtypes", [AgentContext])], KanonApi);
89
+
90
+ //#endregion
91
+ export { KanonApi };
92
+ //# sourceMappingURL=KanonApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KanonApi.js","names":[],"sources":["../src/KanonApi.ts"],"sourcesContent":["import { AgentContext, injectable } from '@credo-ts/core'\n\nimport { resourceIdToBytes32 } from '@ajna-inc/kanon-sdk/anoncreds'\n\nimport { kanonCredIdHash } from './anoncreds/utils/credIdHash'\nimport { KanonClientService } from './ledger'\nimport { KanonZkApi, KanonZkService } from './zk'\n\n/**\n * Normalize a credDefId to its on-chain bytes32 form.\n *\n * The AnonCreds module emits credDefIds in the DID-URL form\n * `did:kanon:org:0x.../anoncreds/v0/CLAIM_DEF/<schemaTag>/<tag>`\n * — but the on-chain registries are keyed by the bytes32 hash of that URL.\n * Every method on this API previously required callers to convert by hand\n * via `resourceIdToBytes32`, which produced the worst kind of surprise when\n * a caller passed the URL form and ethers' ABI encoder threw a cryptic\n * \"Invalid byte-string\" error halfway through a contract call. We accept\n * either form here and forward the bytes32 to the SDK.\n */\nfunction toBytes32CredDefId(credDefId: string): string {\n if (/^0x[0-9a-fA-F]{64}$/.test(credDefId)) return credDefId\n return resourceIdToBytes32(credDefId)\n}\n\n/**\n * High-level facade over {@link KanonClientService}'s AnonCredsStatusRegistry\n * methods. Each operation takes a `credDefId` — either the on-chain bytes32\n * form OR the DID-URL form emitted by the AnonCreds module; we normalize on\n * the way in — and a `credId` (the human-readable id placed in the\n * `kanonCredId` attribute, hashed on the caller's behalf).\n */\n@injectable()\nexport class KanonApi {\n private agentContext: AgentContext\n\n public constructor(agentContext: AgentContext) {\n this.agentContext = agentContext\n }\n\n private get ledger(): KanonClientService {\n return this.agentContext.dependencyManager.resolve(KanonClientService)\n }\n\n /** Mode B (Groth16 non-revocation) revoke + introspection surface. */\n public get zk(): KanonZkApi {\n return this.agentContext.dependencyManager.resolve(KanonZkApi)\n }\n\n /**\n * Writes an issuance record to `AnonCredsStatusRegistry`. Idempotent on the\n * contract side; safe to call after `KanonIssuanceTracker` has already done it.\n */\n public async issueCredentialOnChain(credDefId: string, credId: string) {\n return this.ledger.issueCredentialStatus(toBytes32CredDefId(credDefId), kanonCredIdHash(credId))\n }\n\n /**\n * Marks the (credDefId, credIdHash) pair as revoked on-chain. **Mode A only**\n * — writes to AnonCredsStatusRegistry. Skips the write (no-op) when the\n * credDef did not opt into TIER_ONE_TIME; in that case use `zk.revoke`.\n */\n public async revokeCredentialOnChain(credDefId: string, credId: string) {\n return this.ledger.revokeCredentialStatus(toBytes32CredDefId(credDefId), kanonCredIdHash(credId))\n }\n\n /**\n * Canonical revoke entry point. Reads the credDef's on-chain `policyMask`\n * and writes to every tier it opted into:\n * - `TIER_ONE_TIME` → AnonCredsStatusRegistry.revokeCredential\n * - `TIER_ZK_SNARK` → MerkleStateRegistry.batchUpdate (rotates the root)\n *\n * Callers shouldn't reach for `revokeCredentialOnChain` (Mode A only) or\n * the internal `KanonZkService.revoke` directly — this method routes\n * correctly without the caller having to track the mask.\n */\n public async revokeCredential(credDefId: string, credId: string): Promise<void> {\n const client = this.ledger.client\n const credDefIdBytes32 = toBytes32CredDefId(credDefId)\n const mask = await client.getCredDefPolicy(credDefIdBytes32)\n const TIER_ONE_TIME = 0b01\n const TIER_ZK_SNARK = 0b10\n if ((mask & TIER_ONE_TIME) !== 0 && this.ledger.hasAnonCredsStatusRegistry()) {\n await this.ledger.revokeCredentialStatus(credDefIdBytes32, kanonCredIdHash(credId))\n }\n if ((mask & TIER_ZK_SNARK) !== 0) {\n const zkService = this.agentContext.dependencyManager.resolve(KanonZkService)\n // KanonZkService's checkpoint/path-cache keys use the DID-URL form, so\n // pass through the original. The service does its own bytes32 conversion\n // when it actually hits chain.\n await zkService.revoke(this.agentContext, credDefId, [credId])\n }\n }\n\n /**\n * Reads the revocation flag from the on-chain status registry.\n */\n public async isCredentialRevokedOnChain(credDefId: string, credId: string): Promise<boolean> {\n return this.ledger.isCredentialRevokedOnStatus(toBytes32CredDefId(credDefId), kanonCredIdHash(credId))\n }\n\n /**\n * Reads the full status enum (issued / revoked / unknown depending on contract).\n */\n public async getCredentialStatus(credDefId: string, credId: string): Promise<number> {\n return this.ledger.getCredentialStatus(toBytes32CredDefId(credDefId), kanonCredIdHash(credId))\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,SAAS,mBAAmB,WAA2B;AACrD,KAAI,sBAAsB,KAAK,UAAU,CAAE,QAAO;AAClD,QAAO,oBAAoB,UAAU;;AAWhC,qBAAM,SAAS;CAGpB,AAAO,YAAY,cAA4B;AAC7C,OAAK,eAAe;;CAGtB,IAAY,SAA6B;AACvC,SAAO,KAAK,aAAa,kBAAkB,QAAQ,mBAAmB;;;CAIxE,IAAW,KAAiB;AAC1B,SAAO,KAAK,aAAa,kBAAkB,QAAQ,WAAW;;;;;;CAOhE,MAAa,uBAAuB,WAAmB,QAAgB;AACrE,SAAO,KAAK,OAAO,sBAAsB,mBAAmB,UAAU,EAAE,gBAAgB,OAAO,CAAC;;;;;;;CAQlG,MAAa,wBAAwB,WAAmB,QAAgB;AACtE,SAAO,KAAK,OAAO,uBAAuB,mBAAmB,UAAU,EAAE,gBAAgB,OAAO,CAAC;;;;;;;;;;;;CAanG,MAAa,iBAAiB,WAAmB,QAA+B;EAC9E,MAAM,SAAS,KAAK,OAAO;EAC3B,MAAM,mBAAmB,mBAAmB,UAAU;EACtD,MAAM,OAAO,MAAM,OAAO,iBAAiB,iBAAiB;EAC5D,MAAM,gBAAgB;EACtB,MAAM,gBAAgB;AACtB,OAAK,OAAO,mBAAmB,KAAK,KAAK,OAAO,4BAA4B,CAC1E,OAAM,KAAK,OAAO,uBAAuB,kBAAkB,gBAAgB,OAAO,CAAC;AAErF,OAAK,OAAO,mBAAmB,EAK7B,OAJkB,KAAK,aAAa,kBAAkB,QAAQ,eAAe,CAI7D,OAAO,KAAK,cAAc,WAAW,CAAC,OAAO,CAAC;;;;;CAOlE,MAAa,2BAA2B,WAAmB,QAAkC;AAC3F,SAAO,KAAK,OAAO,4BAA4B,mBAAmB,UAAU,EAAE,gBAAgB,OAAO,CAAC;;;;;CAMxG,MAAa,oBAAoB,WAAmB,QAAiC;AACnF,SAAO,KAAK,OAAO,oBAAoB,mBAAmB,UAAU,EAAE,gBAAgB,OAAO,CAAC;;;uBAzEjG,YAAY"}
@@ -0,0 +1,15 @@
1
+ import { KanonModuleConfig, KanonModuleConfigOptions } from "./KanonModuleConfig.js";
2
+ import { KanonApi } from "./KanonApi.js";
3
+ import { AgentContext, DependencyManager, Module } from "@credo-ts/core";
4
+
5
+ //#region src/KanonModule.d.ts
6
+ declare class KanonModule implements Module {
7
+ readonly config: KanonModuleConfig;
8
+ readonly api: typeof KanonApi;
9
+ constructor(configOptions: KanonModuleConfigOptions);
10
+ register(dependencyManager: DependencyManager): void;
11
+ initialize(agentContext: AgentContext): Promise<void>;
12
+ }
13
+ //#endregion
14
+ export { KanonModule };
15
+ //# sourceMappingURL=KanonModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KanonModule.d.ts","names":[],"sources":["../src/KanonModule.ts"],"mappings":";;;;;cAuBa,WAAA,YAAuB,MAAA;EAAA,SAClB,MAAA,EAAQ,iBAAA;EAAA,SACR,GAAA,SAAG,QAAA;cAEA,aAAA,EAAe,wBAAA;EAI3B,QAAA,CAAS,iBAAA,EAAmB,iBAAA;EAmBtB,UAAA,CAAW,YAAA,EAAc,YAAA,GAAe,OAAA;AAAA"}
@@ -0,0 +1,53 @@
1
+ import { KanonZkIssuerKeyService } from "./zk/KanonZkIssuerKeyService.js";
2
+ import { KanonModuleConfig } from "./KanonModuleConfig.js";
3
+ import { KanonClientService } from "./ledger/KanonClientService.js";
4
+ import "./ledger/index.js";
5
+ import { KanonZkService } from "./zk/KanonZkService.js";
6
+ import { KanonZkPathService } from "./zk/KanonZkPathService.js";
7
+ import { KanonWrappedAnonCredsHolderService, OriginalAnonCredsHolderServiceSymbol } from "./anoncreds/services/KanonWrappedAnonCredsHolderService.js";
8
+ import { KanonWrappedAnonCredsVerifierService, OriginalAnonCredsVerifierServiceSymbol } from "./anoncreds/services/KanonWrappedAnonCredsVerifierService.js";
9
+ import { KanonZkApi } from "./zk/KanonZkApi.js";
10
+ import "./zk/index.js";
11
+ import { KanonIssuanceTracker } from "./anoncreds/services/KanonIssuanceTracker.js";
12
+ import "./anoncreds/index.js";
13
+ import { KanonDidRegistrar } from "./dids/KanonDidRegistrar.js";
14
+ import { KanonDidResolver } from "./dids/KanonDidResolver.js";
15
+ import { KanonApi } from "./KanonApi.js";
16
+ import "./dids/index.js";
17
+ import { AnonCredsHolderServiceSymbol, AnonCredsVerifierServiceSymbol } from "@credo-ts/anoncreds";
18
+
19
+ //#region src/KanonModule.ts
20
+ var KanonModule = class {
21
+ constructor(configOptions) {
22
+ this.api = KanonApi;
23
+ this.config = new KanonModuleConfig(configOptions);
24
+ }
25
+ register(dependencyManager) {
26
+ dependencyManager.registerInstance(KanonModuleConfig, this.config);
27
+ dependencyManager.registerSingleton(KanonClientService);
28
+ dependencyManager.registerSingleton(KanonIssuanceTracker);
29
+ dependencyManager.registerSingleton(KanonDidRegistrar);
30
+ dependencyManager.registerSingleton(KanonDidResolver);
31
+ dependencyManager.registerSingleton(KanonZkIssuerKeyService);
32
+ dependencyManager.registerSingleton(KanonZkPathService);
33
+ dependencyManager.registerSingleton(KanonZkService);
34
+ dependencyManager.registerSingleton(KanonZkApi);
35
+ }
36
+ async initialize(agentContext) {
37
+ const dm = agentContext.dependencyManager;
38
+ if (this.config.anonCredsStatusRegistryAddress || this.config.addressBook) {
39
+ const originalVerifier = dm.resolve(AnonCredsVerifierServiceSymbol);
40
+ dm.registerInstance(OriginalAnonCredsVerifierServiceSymbol, originalVerifier);
41
+ dm.registerSingleton(AnonCredsVerifierServiceSymbol, KanonWrappedAnonCredsVerifierService);
42
+ }
43
+ const originalHolder = dm.resolve(AnonCredsHolderServiceSymbol);
44
+ dm.registerInstance(OriginalAnonCredsHolderServiceSymbol, originalHolder);
45
+ dm.registerSingleton(AnonCredsHolderServiceSymbol, KanonWrappedAnonCredsHolderService);
46
+ await dm.resolve(KanonClientService).init();
47
+ dm.resolve(KanonIssuanceTracker).attach(agentContext);
48
+ }
49
+ };
50
+
51
+ //#endregion
52
+ export { KanonModule };
53
+ //# sourceMappingURL=KanonModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KanonModule.js","names":[],"sources":["../src/KanonModule.ts"],"sourcesContent":["import type { AnonCredsHolderService, AnonCredsVerifierService } from '@credo-ts/anoncreds'\nimport type { AgentContext, DependencyManager, Module } from '@credo-ts/core'\n\nimport { AnonCredsHolderServiceSymbol, AnonCredsVerifierServiceSymbol } from '@credo-ts/anoncreds'\n\nimport { KanonApi } from './KanonApi'\nimport {\n KanonIssuanceTracker,\n KanonWrappedAnonCredsHolderService,\n KanonWrappedAnonCredsVerifierService,\n OriginalAnonCredsHolderServiceSymbol,\n OriginalAnonCredsVerifierServiceSymbol,\n} from './anoncreds'\nimport { KanonDidRegistrar, KanonDidResolver } from './dids'\nimport { KanonModuleConfig, type KanonModuleConfigOptions } from './KanonModuleConfig'\nimport { KanonClientService } from './ledger'\nimport {\n KanonZkApi,\n KanonZkIssuerKeyService,\n KanonZkPathService,\n KanonZkService,\n} from './zk'\n\nexport class KanonModule implements Module {\n public readonly config: KanonModuleConfig\n public readonly api = KanonApi\n\n public constructor(configOptions: KanonModuleConfigOptions) {\n this.config = new KanonModuleConfig(configOptions)\n }\n\n public register(dependencyManager: DependencyManager) {\n // Register config\n dependencyManager.registerInstance(KanonModuleConfig, this.config)\n\n // Core singletons\n dependencyManager.registerSingleton(KanonClientService)\n dependencyManager.registerSingleton(KanonIssuanceTracker)\n dependencyManager.registerSingleton(KanonDidRegistrar)\n dependencyManager.registerSingleton(KanonDidResolver)\n // Mode B (Groth16 non-revocation) — restart-survivable issuer state +\n // public revoke API. Holds an IssuerService per credDef in-process, with\n // a GenericRecords-backed checkpoint so cold start resumes from the last\n // synced block instead of replaying the chain from genesis.\n dependencyManager.registerSingleton(KanonZkIssuerKeyService)\n dependencyManager.registerSingleton(KanonZkPathService)\n dependencyManager.registerSingleton(KanonZkService)\n dependencyManager.registerSingleton(KanonZkApi)\n }\n\n public async initialize(agentContext: AgentContext): Promise<void> {\n const dm = agentContext.dependencyManager\n\n // Wrap the AnonCreds verifier + holder services HERE (in `initialize`),\n // not in `register`. The two symbols we override (`AnonCredsHolderServiceSymbol`,\n // `AnonCredsVerifierServiceSymbol`) are bound by `AnonCredsModule.register`,\n // and Credo's `DependencyManager` runs every module's `register` before\n // any module's `initialize`. Doing the wrapping in `register` would\n // require KanonModule to be listed AFTER `AnonCredsModule` in the\n // user's `modules` map AND for Credo to honour that insertion order\n // when iterating — fragile across Credo versions. Wrapping at\n // `initialize` time avoids the ordering constraint entirely.\n if (this.config.anonCredsStatusRegistryAddress || this.config.addressBook) {\n const originalVerifier = dm.resolve<AnonCredsVerifierService>(AnonCredsVerifierServiceSymbol)\n dm.registerInstance(OriginalAnonCredsVerifierServiceSymbol, originalVerifier)\n dm.registerSingleton(AnonCredsVerifierServiceSymbol, KanonWrappedAnonCredsVerifierService)\n }\n\n const originalHolder = dm.resolve<AnonCredsHolderService>(AnonCredsHolderServiceSymbol)\n dm.registerInstance(OriginalAnonCredsHolderServiceSymbol, originalHolder)\n dm.registerSingleton(AnonCredsHolderServiceSymbol, KanonWrappedAnonCredsHolderService)\n\n // Eagerly resolve so the client service picks up its config, and resolve the\n // registries from the address book (no-op for explicit deployments).\n const clientService = dm.resolve(KanonClientService)\n await clientService.init()\n\n // The tracker handles Mode A AND Mode B issuance routing based on each\n // credDef's on-chain policyMask. Attach unconditionally so Mode-B-only\n // deployments (no AnonCredsStatusRegistry) still publish leaves; the\n // tracker logs + skips Mode A when the status registry is missing.\n const tracker = dm.resolve(KanonIssuanceTracker)\n tracker.attach(agentContext)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuBA,IAAa,cAAb,MAA2C;CAIzC,AAAO,YAAY,eAAyC;OAF5C,MAAM;AAGpB,OAAK,SAAS,IAAI,kBAAkB,cAAc;;CAGpD,AAAO,SAAS,mBAAsC;AAEpD,oBAAkB,iBAAiB,mBAAmB,KAAK,OAAO;AAGlE,oBAAkB,kBAAkB,mBAAmB;AACvD,oBAAkB,kBAAkB,qBAAqB;AACzD,oBAAkB,kBAAkB,kBAAkB;AACtD,oBAAkB,kBAAkB,iBAAiB;AAKrD,oBAAkB,kBAAkB,wBAAwB;AAC5D,oBAAkB,kBAAkB,mBAAmB;AACvD,oBAAkB,kBAAkB,eAAe;AACnD,oBAAkB,kBAAkB,WAAW;;CAGjD,MAAa,WAAW,cAA2C;EACjE,MAAM,KAAK,aAAa;AAWxB,MAAI,KAAK,OAAO,kCAAkC,KAAK,OAAO,aAAa;GACzE,MAAM,mBAAmB,GAAG,QAAkC,+BAA+B;AAC7F,MAAG,iBAAiB,wCAAwC,iBAAiB;AAC7E,MAAG,kBAAkB,gCAAgC,qCAAqC;;EAG5F,MAAM,iBAAiB,GAAG,QAAgC,6BAA6B;AACvF,KAAG,iBAAiB,sCAAsC,eAAe;AACzE,KAAG,kBAAkB,8BAA8B,mCAAmC;AAKtF,QADsB,GAAG,QAAQ,mBAAmB,CAChC,MAAM;AAO1B,EADgB,GAAG,QAAQ,qBAAqB,CACxC,OAAO,aAAa"}