@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
@@ -0,0 +1,88 @@
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 { parsekanonDid } from "../utils/identifiers.js";
6
+ import { DidDocument, TypedArrayEncoder, injectable } from "@credo-ts/core";
7
+ import { ethers } from "ethers";
8
+
9
+ //#region src/dids/KanonDidResolver.ts
10
+ var _ref;
11
+ const VM_TYPES = [
12
+ "Ed25519VerificationKey2020",
13
+ "EcdsaSecp256k1VerificationKey2019",
14
+ "Bls12381G2Key2020",
15
+ "JsonWebKey2020"
16
+ ];
17
+ let KanonDidResolver = class KanonDidResolver {
18
+ constructor(clientService) {
19
+ this.clientService = clientService;
20
+ this.supportedMethods = ["kanon"];
21
+ this.allowsCaching = true;
22
+ this.allowsLocalDidRecord = true;
23
+ }
24
+ async resolve(agentContext, did, _parsed) {
25
+ try {
26
+ const parsed = parsekanonDid(did);
27
+ if (!parsed) return this.errorResponse("notFound", `not a did:kanon DID: ${did}`);
28
+ const baseDid = parsed.did;
29
+ const record = await this.clientService.client.resolveDidRecord(baseDid);
30
+ if (!record) return this.errorResponse("notFound", `no DID document on chain for ${baseDid}`);
31
+ if (record.deactivated) return this.errorResponse("notFound", `DID is deactivated: ${baseDid}`);
32
+ return {
33
+ didDocument: this.toDidDocument(baseDid, record),
34
+ didDocumentMetadata: {},
35
+ didResolutionMetadata: { contentType: "application/did+ld+json" }
36
+ };
37
+ } catch (error) {
38
+ const message = error instanceof Error ? error.message : String(error);
39
+ agentContext.config.logger.error(`KanonDidResolver: error resolving DID ${did}: ${message}`);
40
+ return this.errorResponse("notFound", `error resolving DID: ${message}`);
41
+ }
42
+ }
43
+ toDidDocument(did, record) {
44
+ const idToFragment = /* @__PURE__ */ new Map();
45
+ const verificationMethod = record.verificationMethods.map((vm, i) => {
46
+ const fragment = `${did}#key-${i + 1}`;
47
+ idToFragment.set(vm.id.toLowerCase(), fragment);
48
+ const entry = {
49
+ id: fragment,
50
+ type: vm.vmType < VM_TYPES.length ? VM_TYPES[vm.vmType] : "JsonWebKey2020",
51
+ controller: did
52
+ };
53
+ const keyBytes = ethers.getBytes(vm.publicKeyHex);
54
+ if (vm.vmType === 0) entry.publicKeyBase58 = TypedArrayEncoder.toBase58(keyBytes);
55
+ else entry.publicKeyHex = vm.publicKeyHex.replace(/^0x/, "");
56
+ return entry;
57
+ });
58
+ const refs = (ids) => ids.map((r) => idToFragment.get(r.toLowerCase())).filter((f) => Boolean(f));
59
+ const service = record.services.map((svc, i) => ({
60
+ id: `${did}#service-${i + 1}`,
61
+ type: svc.serviceType,
62
+ serviceEndpoint: svc.endpoint
63
+ }));
64
+ return new DidDocument({
65
+ id: did,
66
+ context: ["https://www.w3.org/ns/did/v1", "https://w3id.org/security/suites/ed25519-2020/v1"],
67
+ verificationMethod,
68
+ authentication: refs(record.authentication),
69
+ assertionMethod: refs(record.assertionMethod),
70
+ service: service.length ? service : void 0
71
+ });
72
+ }
73
+ errorResponse(error, message) {
74
+ return {
75
+ didDocument: null,
76
+ didDocumentMetadata: {},
77
+ didResolutionMetadata: {
78
+ error,
79
+ message
80
+ }
81
+ };
82
+ }
83
+ };
84
+ KanonDidResolver = __decorate([injectable(), __decorateMetadata("design:paramtypes", [KanonClientService])], KanonDidResolver);
85
+
86
+ //#endregion
87
+ export { KanonDidResolver };
88
+ //# sourceMappingURL=KanonDidResolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KanonDidResolver.js","names":[],"sources":["../../src/dids/KanonDidResolver.ts"],"sourcesContent":["import type { AgentContext, DidResolutionResult, DidResolver, ParsedDid } from '@credo-ts/core'\n\nimport { DidDocument, injectable, TypedArrayEncoder } from '@credo-ts/core'\nimport { ethers } from 'ethers'\n\nimport { parsekanonDid } from '../utils/identifiers'\nimport { KanonClientService } from '../ledger'\n\n// VerificationMethodType (on-chain enum index) -> W3C type string.\nconst VM_TYPES = [\n 'Ed25519VerificationKey2020',\n 'EcdsaSecp256k1VerificationKey2019',\n 'Bls12381G2Key2020',\n 'JsonWebKey2020',\n]\n\n@injectable()\nexport class KanonDidResolver implements DidResolver {\n public readonly supportedMethods = ['kanon']\n public readonly allowsCaching = true\n public readonly allowsLocalDidRecord = true\n\n public constructor(private clientService: KanonClientService) {}\n\n public async resolve(agentContext: AgentContext, did: string, _parsed: ParsedDid): Promise<DidResolutionResult> {\n try {\n const parsed = parsekanonDid(did)\n if (!parsed) return this.errorResponse('notFound', `not a did:kanon DID: ${did}`)\n const baseDid = parsed.did\n\n const record = await this.clientService.client.resolveDidRecord(baseDid)\n if (!record) return this.errorResponse('notFound', `no DID document on chain for ${baseDid}`)\n if (record.deactivated) return this.errorResponse('notFound', `DID is deactivated: ${baseDid}`)\n\n const didDocument = this.toDidDocument(baseDid, record)\n return {\n didDocument,\n didDocumentMetadata: {},\n didResolutionMetadata: { contentType: 'application/did+ld+json' },\n }\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error)\n agentContext.config.logger.error(`KanonDidResolver: error resolving DID ${did}: ${message}`)\n return this.errorResponse('notFound', `error resolving DID: ${message}`)\n }\n }\n\n private toDidDocument(\n did: string,\n record: NonNullable<Awaited<ReturnType<KanonClientService['client']['resolveDidRecord']>>>\n ): DidDocument {\n // On-chain VM ids are keccak hashes (not reversible), so we synthesize stable\n // `#key-N` fragments by position and map relationship references back to them.\n const idToFragment = new Map<string, string>()\n const verificationMethod = record.verificationMethods.map((vm, i) => {\n const fragment = `${did}#key-${i + 1}`\n idToFragment.set(vm.id.toLowerCase(), fragment)\n const type = vm.vmType < VM_TYPES.length ? VM_TYPES[vm.vmType] : 'JsonWebKey2020'\n const entry: Record<string, unknown> = { id: fragment, type, controller: did }\n const keyBytes = ethers.getBytes(vm.publicKeyHex)\n if (vm.vmType === 0) {\n entry.publicKeyBase58 = TypedArrayEncoder.toBase58(keyBytes)\n } else {\n entry.publicKeyHex = vm.publicKeyHex.replace(/^0x/, '')\n }\n return entry\n })\n\n const refs = (ids: string[]): string[] =>\n ids.map((r) => idToFragment.get(r.toLowerCase())).filter((f): f is string => Boolean(f))\n\n const service = record.services.map((svc, i) => ({\n id: `${did}#service-${i + 1}`,\n type: svc.serviceType,\n serviceEndpoint: svc.endpoint,\n }))\n\n return new DidDocument({\n id: did,\n context: ['https://www.w3.org/ns/did/v1', 'https://w3id.org/security/suites/ed25519-2020/v1'],\n // biome-ignore lint/suspicious/noExplicitAny: VM entries are dynamically typed per key type\n verificationMethod: verificationMethod as any,\n authentication: refs(record.authentication),\n assertionMethod: refs(record.assertionMethod),\n service: service.length ? service : undefined,\n })\n }\n\n private errorResponse(error: string, message: string): DidResolutionResult {\n return {\n didDocument: null,\n didDocumentMetadata: {},\n didResolutionMetadata: { error, message },\n }\n }\n}\n"],"mappings":";;;;;;;;;;AASA,MAAM,WAAW;CACf;CACA;CACA;CACA;CACD;AAGM,6BAAM,iBAAwC;CAKnD,AAAO,YAAY,AAAQ,eAAmC;EAAnC;OAJX,mBAAmB,CAAC,QAAQ;OAC5B,gBAAgB;OAChB,uBAAuB;;CAIvC,MAAa,QAAQ,cAA4B,KAAa,SAAkD;AAC9G,MAAI;GACF,MAAM,SAAS,cAAc,IAAI;AACjC,OAAI,CAAC,OAAQ,QAAO,KAAK,cAAc,YAAY,wBAAwB,MAAM;GACjF,MAAM,UAAU,OAAO;GAEvB,MAAM,SAAS,MAAM,KAAK,cAAc,OAAO,iBAAiB,QAAQ;AACxE,OAAI,CAAC,OAAQ,QAAO,KAAK,cAAc,YAAY,gCAAgC,UAAU;AAC7F,OAAI,OAAO,YAAa,QAAO,KAAK,cAAc,YAAY,uBAAuB,UAAU;AAG/F,UAAO;IACL,aAFkB,KAAK,cAAc,SAAS,OAAO;IAGrD,qBAAqB,EAAE;IACvB,uBAAuB,EAAE,aAAa,2BAA2B;IAClE;WACM,OAAO;GACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AACtE,gBAAa,OAAO,OAAO,MAAM,yCAAyC,IAAI,IAAI,UAAU;AAC5F,UAAO,KAAK,cAAc,YAAY,wBAAwB,UAAU;;;CAI5E,AAAQ,cACN,KACA,QACa;EAGb,MAAM,+BAAe,IAAI,KAAqB;EAC9C,MAAM,qBAAqB,OAAO,oBAAoB,KAAK,IAAI,MAAM;GACnE,MAAM,WAAW,GAAG,IAAI,OAAO,IAAI;AACnC,gBAAa,IAAI,GAAG,GAAG,aAAa,EAAE,SAAS;GAE/C,MAAM,QAAiC;IAAE,IAAI;IAAU,MAD1C,GAAG,SAAS,SAAS,SAAS,SAAS,GAAG,UAAU;IACJ,YAAY;IAAK;GAC9E,MAAM,WAAW,OAAO,SAAS,GAAG,aAAa;AACjD,OAAI,GAAG,WAAW,EAChB,OAAM,kBAAkB,kBAAkB,SAAS,SAAS;OAE5D,OAAM,eAAe,GAAG,aAAa,QAAQ,OAAO,GAAG;AAEzD,UAAO;IACP;EAEF,MAAM,QAAQ,QACZ,IAAI,KAAK,MAAM,aAAa,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,QAAQ,MAAmB,QAAQ,EAAE,CAAC;EAE1F,MAAM,UAAU,OAAO,SAAS,KAAK,KAAK,OAAO;GAC/C,IAAI,GAAG,IAAI,WAAW,IAAI;GAC1B,MAAM,IAAI;GACV,iBAAiB,IAAI;GACtB,EAAE;AAEH,SAAO,IAAI,YAAY;GACrB,IAAI;GACJ,SAAS,CAAC,gCAAgC,mDAAmD;GAEzE;GACpB,gBAAgB,KAAK,OAAO,eAAe;GAC3C,iBAAiB,KAAK,OAAO,gBAAgB;GAC7C,SAAS,QAAQ,SAAS,UAAU;GACrC,CAAC;;CAGJ,AAAQ,cAAc,OAAe,SAAsC;AACzE,SAAO;GACL,aAAa;GACb,qBAAqB,EAAE;GACvB,uBAAuB;IAAE;IAAO;IAAS;GAC1C;;;+BA7EJ,YAAY"}
@@ -0,0 +1,18 @@
1
+ import { DidDocument } from "@credo-ts/core";
2
+
3
+ //#region src/dids/didEtherUtils.d.ts
4
+ declare function validateSpecCompliantPayload(didDocument: DidDocument): SpecValidationResult;
5
+ type SpecValidationResult = {
6
+ valid: boolean;
7
+ error?: string;
8
+ protobufVerificationMethod?: unknown[];
9
+ protobufService?: unknown[];
10
+ };
11
+ declare enum VerificationMethods {
12
+ Ed255192020 = "Ed25519VerificationKey2020",
13
+ Ed255192018 = "Ed25519VerificationKey2018",
14
+ JWK = "JsonWebKey2020"
15
+ }
16
+ //#endregion
17
+ export { SpecValidationResult, VerificationMethods, validateSpecCompliantPayload };
18
+ //# sourceMappingURL=didEtherUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"didEtherUtils.d.ts","names":[],"sources":["../../src/dids/didEtherUtils.ts"],"mappings":";;;iBAEgB,4BAAA,CAA6B,WAAA,EAAa,WAAA,GAAc,oBAAA;AAAA,KAsC5D,oBAAA;EACV,KAAA;EACA,KAAA;EACA,0BAAA;EACA,eAAA;AAAA;AAAA,aAGU,mBAAA;EACV,WAAA;EACA,WAAA;EACA,GAAA;AAAA"}
@@ -0,0 +1,47 @@
1
+ //#region src/dids/didEtherUtils.ts
2
+ function validateSpecCompliantPayload(didDocument) {
3
+ if (!didDocument.id || !didDocument.id.startsWith("did:kanon:")) return {
4
+ valid: false,
5
+ error: "id is required and must be a did:kanon DID"
6
+ };
7
+ if (!didDocument.verificationMethod) return {
8
+ valid: false,
9
+ error: "verificationMethod is required"
10
+ };
11
+ if (!Array.isArray(didDocument.verificationMethod)) return {
12
+ valid: false,
13
+ error: "verificationMethod must be an array"
14
+ };
15
+ if (!didDocument.verificationMethod.length) return {
16
+ valid: false,
17
+ error: "verificationMethod must be not be empty"
18
+ };
19
+ if (!didDocument.verificationMethod.every((vm) => {
20
+ switch (vm.type) {
21
+ case VerificationMethods.Ed255192020: return vm.publicKeyMultibase != null;
22
+ case VerificationMethods.JWK: return vm.publicKeyJwk != null;
23
+ case VerificationMethods.Ed255192018: return vm.publicKeyBase58 != null;
24
+ default: return false;
25
+ }
26
+ })) return {
27
+ valid: false,
28
+ error: "verificationMethod publicKey is Invalid"
29
+ };
30
+ if (!(didDocument.service ? didDocument?.service?.every((s) => {
31
+ return s?.serviceEndpoint && s?.id && s?.type;
32
+ }) : true)) return {
33
+ valid: false,
34
+ error: "Service is Invalid"
35
+ };
36
+ return { valid: true };
37
+ }
38
+ let VerificationMethods = /* @__PURE__ */ function(VerificationMethods) {
39
+ VerificationMethods["Ed255192020"] = "Ed25519VerificationKey2020";
40
+ VerificationMethods["Ed255192018"] = "Ed25519VerificationKey2018";
41
+ VerificationMethods["JWK"] = "JsonWebKey2020";
42
+ return VerificationMethods;
43
+ }({});
44
+
45
+ //#endregion
46
+ export { VerificationMethods, validateSpecCompliantPayload };
47
+ //# sourceMappingURL=didEtherUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"didEtherUtils.js","names":[],"sources":["../../src/dids/didEtherUtils.ts"],"sourcesContent":["import type { DidDocument } from '@credo-ts/core'\n\nexport function validateSpecCompliantPayload(didDocument: DidDocument): SpecValidationResult {\n if (!didDocument.id || !didDocument.id.startsWith('did:kanon:'))\n return { valid: false, error: 'id is required and must be a did:kanon DID' }\n\n if (!didDocument.verificationMethod)\n return { valid: false, error: 'verificationMethod is required' }\n\n if (!Array.isArray(didDocument.verificationMethod))\n return { valid: false, error: 'verificationMethod must be an array' }\n\n if (!didDocument.verificationMethod.length)\n return { valid: false, error: 'verificationMethod must be not be empty' }\n\n const isValidVerificationMethod = didDocument.verificationMethod.every((vm) => {\n switch (vm.type) {\n case VerificationMethods.Ed255192020:\n return vm.publicKeyMultibase != null\n case VerificationMethods.JWK:\n return vm.publicKeyJwk != null\n case VerificationMethods.Ed255192018:\n return vm.publicKeyBase58 != null\n default:\n return false\n }\n })\n\n if (!isValidVerificationMethod) return { valid: false, error: 'verificationMethod publicKey is Invalid' }\n\n const isValidService = didDocument.service\n ? didDocument?.service?.every((s) => {\n return s?.serviceEndpoint && s?.id && s?.type\n })\n : true\n\n if (!isValidService) return { valid: false, error: 'Service is Invalid' }\n return { valid: true } as SpecValidationResult\n}\n\nexport type SpecValidationResult = {\n valid: boolean\n error?: string\n protobufVerificationMethod?: unknown[]\n protobufService?: unknown[]\n}\n\nexport enum VerificationMethods {\n Ed255192020 = 'Ed25519VerificationKey2020',\n Ed255192018 = 'Ed25519VerificationKey2018',\n JWK = 'JsonWebKey2020',\n}\n"],"mappings":";AAEA,SAAgB,6BAA6B,aAAgD;AAC3F,KAAI,CAAC,YAAY,MAAM,CAAC,YAAY,GAAG,WAAW,aAAa,CAC7D,QAAO;EAAE,OAAO;EAAO,OAAO;EAA8C;AAE9E,KAAI,CAAC,YAAY,mBACf,QAAO;EAAE,OAAO;EAAO,OAAO;EAAkC;AAElE,KAAI,CAAC,MAAM,QAAQ,YAAY,mBAAmB,CAChD,QAAO;EAAE,OAAO;EAAO,OAAO;EAAuC;AAEvE,KAAI,CAAC,YAAY,mBAAmB,OAClC,QAAO;EAAE,OAAO;EAAO,OAAO;EAA2C;AAe3E,KAAI,CAb8B,YAAY,mBAAmB,OAAO,OAAO;AAC7E,UAAQ,GAAG,MAAX;GACE,KAAK,oBAAoB,YACvB,QAAO,GAAG,sBAAsB;GAClC,KAAK,oBAAoB,IACvB,QAAO,GAAG,gBAAgB;GAC5B,KAAK,oBAAoB,YACvB,QAAO,GAAG,mBAAmB;GAC/B,QACE,QAAO;;GAEX,CAE8B,QAAO;EAAE,OAAO;EAAO,OAAO;EAA2C;AAQzG,KAAI,EANmB,YAAY,UAC/B,aAAa,SAAS,OAAO,MAAM;AACjC,SAAO,GAAG,mBAAmB,GAAG,MAAM,GAAG;GACzC,GACF,MAEiB,QAAO;EAAE,OAAO;EAAO,OAAO;EAAsB;AACzE,QAAO,EAAE,OAAO,MAAM;;AAUxB,IAAY,oEAAL;AACL;AACA;AACA"}
@@ -0,0 +1,3 @@
1
+ import { KanonDidRegistrar } from "./KanonDidRegistrar.js";
2
+ import { KanonDidResolver } from "./KanonDidResolver.js";
3
+ import { VerificationMethods, validateSpecCompliantPayload } from "./didEtherUtils.js";
@@ -0,0 +1,24 @@
1
+ import { KanonAnonCredsRegistry } from "./anoncreds/services/KanonAnonCredsRegistry.js";
2
+ import { KanonDeploymentAddresses, KanonDeploymentInput, KanonLeavesBaseUrlResolver, KanonModuleConfig, KanonModuleConfigOptions } from "./KanonModuleConfig.js";
3
+ import { KanonClientService } from "./ledger/KanonClientService.js";
4
+ import "./ledger/index.js";
5
+ import { KanonWrappedAnonCredsVerifierService, OriginalAnonCredsVerifierServiceSymbol } from "./anoncreds/services/KanonWrappedAnonCredsVerifierService.js";
6
+ import { KanonZkPathService } from "./zk/KanonZkPathService.js";
7
+ import { KanonWrappedAnonCredsHolderService, OriginalAnonCredsHolderServiceSymbol, kanonZkProofReferent } from "./anoncreds/services/KanonWrappedAnonCredsHolderService.js";
8
+ import { KanonZkIssuerKeyService } from "./zk/KanonZkIssuerKeyService.js";
9
+ import { KANON_ZK_CIRCUIT_ATTRS, KanonZkService, padAttrsToCircuit } from "./zk/KanonZkService.js";
10
+ import { KanonZkApi, KanonZkCredentialPrep, KanonZkPresentationPrep, KanonZkProvisionResult } from "./zk/KanonZkApi.js";
11
+ import "./zk/index.js";
12
+ import { KanonIssuanceTracker } from "./anoncreds/services/KanonIssuanceTracker.js";
13
+ import { KANON_CRED_ID_ATTRIBUTE, kanonCredIdHash } from "./anoncreds/utils/credIdHash.js";
14
+ import { BuildKanonSchemaInput, buildKanonSchema } from "./anoncreds/helpers/buildKanonSchema.js";
15
+ import { BuildKanonCredentialAttributesResult, KanonCredentialAttribute, buildKanonCredentialAttributes } from "./anoncreds/helpers/buildKanonCredentialAttributes.js";
16
+ import { BuildKanonProofRequestInput, KanonProofRequest, buildKanonProofRequest } from "./anoncreds/helpers/buildKanonProofRequest.js";
17
+ import "./anoncreds/index.js";
18
+ import { KanonDidCreateOptions, KanonDidDeactivateOptions, KanonDidRegistrar, KanonDidServiceOptions, KanonDidUpdateOptions } from "./dids/KanonDidRegistrar.js";
19
+ import { KanonDidResolver } from "./dids/KanonDidResolver.js";
20
+ import { SpecValidationResult, VerificationMethods, validateSpecCompliantPayload } from "./dids/didEtherUtils.js";
21
+ import { ParsedKanonDid, kanonDidRegex, kanonDidUrlRegex, kanonPrefixRegex, orgDid, parsekanonDid, userDid } from "./utils/identifiers.js";
22
+ import { KanonApi } from "./KanonApi.js";
23
+ import { KanonModule } from "./KanonModule.js";
24
+ export { type BuildKanonCredentialAttributesResult, type BuildKanonProofRequestInput, type BuildKanonSchemaInput, KANON_CRED_ID_ATTRIBUTE, KANON_ZK_CIRCUIT_ATTRS, KanonAnonCredsRegistry, KanonApi, KanonClientService, type KanonCredentialAttribute, type KanonDeploymentAddresses, type KanonDeploymentInput, type KanonDidCreateOptions, type KanonDidDeactivateOptions, KanonDidRegistrar, KanonDidResolver, type KanonDidServiceOptions, type KanonDidUpdateOptions, KanonIssuanceTracker, type KanonLeavesBaseUrlResolver, KanonModule, KanonModuleConfig, type KanonModuleConfigOptions, type KanonProofRequest, KanonWrappedAnonCredsHolderService, KanonWrappedAnonCredsVerifierService, KanonZkApi, type KanonZkCredentialPrep, KanonZkIssuerKeyService, KanonZkPathService, type KanonZkPresentationPrep, type KanonZkProvisionResult, KanonZkService, OriginalAnonCredsHolderServiceSymbol, OriginalAnonCredsVerifierServiceSymbol, type ParsedKanonDid, type SpecValidationResult, VerificationMethods, buildKanonCredentialAttributes, buildKanonProofRequest, buildKanonSchema, kanonCredIdHash, kanonDidRegex, kanonDidUrlRegex, kanonPrefixRegex, kanonZkProofReferent, orgDid, padAttrsToCircuit, parsekanonDid, userDid, validateSpecCompliantPayload };
package/build/index.js ADDED
@@ -0,0 +1,25 @@
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 { KANON_CRED_ID_ATTRIBUTE, kanonCredIdHash } from "./anoncreds/utils/credIdHash.js";
6
+ import { KanonAnonCredsRegistry } from "./anoncreds/services/KanonAnonCredsRegistry.js";
7
+ import { KANON_ZK_CIRCUIT_ATTRS, KanonZkService, padAttrsToCircuit } from "./zk/KanonZkService.js";
8
+ import { KanonZkPathService } from "./zk/KanonZkPathService.js";
9
+ import { KanonWrappedAnonCredsHolderService, OriginalAnonCredsHolderServiceSymbol, kanonZkProofReferent } from "./anoncreds/services/KanonWrappedAnonCredsHolderService.js";
10
+ import { KanonWrappedAnonCredsVerifierService, OriginalAnonCredsVerifierServiceSymbol } from "./anoncreds/services/KanonWrappedAnonCredsVerifierService.js";
11
+ import { KanonZkApi } from "./zk/KanonZkApi.js";
12
+ import "./zk/index.js";
13
+ import { KanonIssuanceTracker } from "./anoncreds/services/KanonIssuanceTracker.js";
14
+ import { buildKanonSchema } from "./anoncreds/helpers/buildKanonSchema.js";
15
+ import { buildKanonCredentialAttributes } from "./anoncreds/helpers/buildKanonCredentialAttributes.js";
16
+ import { buildKanonProofRequest } from "./anoncreds/helpers/buildKanonProofRequest.js";
17
+ import "./anoncreds/index.js";
18
+ import { KanonDidRegistrar } from "./dids/KanonDidRegistrar.js";
19
+ import { kanonDidRegex, kanonDidUrlRegex, kanonPrefixRegex, orgDid, parsekanonDid, userDid } from "./utils/identifiers.js";
20
+ import { KanonDidResolver } from "./dids/KanonDidResolver.js";
21
+ import { VerificationMethods, validateSpecCompliantPayload } from "./dids/didEtherUtils.js";
22
+ import { KanonApi } from "./KanonApi.js";
23
+ import { KanonModule } from "./KanonModule.js";
24
+
25
+ export { KANON_CRED_ID_ATTRIBUTE, KANON_ZK_CIRCUIT_ATTRS, KanonAnonCredsRegistry, KanonApi, KanonClientService, KanonDidRegistrar, KanonDidResolver, KanonIssuanceTracker, KanonModule, KanonModuleConfig, KanonWrappedAnonCredsHolderService, KanonWrappedAnonCredsVerifierService, KanonZkApi, KanonZkIssuerKeyService, KanonZkPathService, KanonZkService, OriginalAnonCredsHolderServiceSymbol, OriginalAnonCredsVerifierServiceSymbol, VerificationMethods, buildKanonCredentialAttributes, buildKanonProofRequest, buildKanonSchema, kanonCredIdHash, kanonDidRegex, kanonDidUrlRegex, kanonPrefixRegex, kanonZkProofReferent, orgDid, padAttrsToCircuit, parsekanonDid, userDid, validateSpecCompliantPayload };
@@ -0,0 +1,45 @@
1
+ import { KanonLeavesBaseUrlResolver, KanonModuleConfig } from "../KanonModuleConfig.js";
2
+ import { KanonClient } from "@ajna-inc/kanon-sdk";
3
+ import { Logger } from "@credo-ts/core";
4
+ import { ethers } from "ethers";
5
+ import { KanonContracts } from "@ajna-inc/kanon-sdk/core";
6
+
7
+ //#region src/ledger/KanonClientService.d.ts
8
+ /**
9
+ * Thin wrapper over the kanon SDK `KanonClient`. Builds an ethers provider +
10
+ * signer from the module config and exposes the SDK client, its typechain
11
+ * registries, and the per-credential AnonCredsStatusRegistry helpers.
12
+ */
13
+ declare class KanonClientService {
14
+ private logger;
15
+ private provider;
16
+ private signer;
17
+ private _client?;
18
+ private statusRegistryAddress?;
19
+ private addressBook?;
20
+ /** App-provided Mode B leaf-set base URL resolver (see `KanonModuleConfigOptions.resolveLeavesBaseUrl`). */
21
+ readonly resolveLeavesBaseUrl?: KanonLeavesBaseUrlResolver;
22
+ constructor(config: KanonModuleConfig, logger: Logger);
23
+ /**
24
+ * Resolve the registries via the configured address book and build the SDK
25
+ * client. No-op when an explicit deployment was used (client already built).
26
+ * Called by the module's async `initialize`.
27
+ */
28
+ init(): Promise<void>;
29
+ /** The SDK orchestration client. */
30
+ get client(): KanonClient;
31
+ /** Typechain registries (orgRegistry, didRegistry, schemaRegistry, …). */
32
+ get contracts(): KanonContracts;
33
+ /** The operator signer used for on-chain writes. */
34
+ getSigner(): ethers.Wallet;
35
+ hasAnonCredsStatusRegistry(): boolean;
36
+ private getStatusRegistryAddress;
37
+ private getStatusRegistry;
38
+ issueCredentialStatus(credDefId: string, credIdHash: string): Promise<any>;
39
+ revokeCredentialStatus(credDefId: string, credIdHash: string): Promise<any>;
40
+ isCredentialRevokedOnStatus(credDefId: string, credIdHash: string): Promise<boolean>;
41
+ getCredentialStatus(credDefId: string, credIdHash: string): Promise<number>;
42
+ }
43
+ //#endregion
44
+ export { KanonClientService };
45
+ //# sourceMappingURL=KanonClientService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KanonClientService.d.ts","names":[],"sources":["../../src/ledger/KanonClientService.ts"],"mappings":";;;;;;;;;AA0CA;;;cACa,kBAAA;EAAA,QACH,MAAA;EAAA,QACA,QAAA;EAAA,QACA,MAAA;EAAA,QACA,OAAA;EAAA,QACA,qBAAA;EAAA,QACA,WAAA;EAsFgE;EAAA,SApFxD,oBAAA,GAAuB,0BAAA;cAEpB,MAAA,EAAQ,iBAAA,EAAoD,MAAA,EAAQ,MAAA;EAmGd;;;;;EA3E5D,IAAA,CAAA,GAAQ,OAAA;EA9Bb;EAAA,IAiDG,MAAA,CAAA,GAAU,WAAA;EA/Cb;EAAA,IAuDG,SAAA,CAAA,GAAa,cAAA;EArDe;EA0DhC,SAAA,CAAA,GAAa,MAAA,CAAO,MAAA;EAQpB,0BAAA,CAAA;EAAA,QAIC,wBAAA;EAAA,QASA,iBAAA;EAKK,qBAAA,CAAsB,SAAA,UAAmB,UAAA,WAAkB,OAAA;EAM3D,sBAAA,CAAuB,SAAA,UAAmB,UAAA,WAAkB,OAAA;EAM5D,2BAAA,CAA4B,SAAA,UAAmB,UAAA,WAAqB,OAAA;EAKpE,mBAAA,CAAoB,SAAA,UAAmB,UAAA,WAAqB,OAAA;AAAA"}
@@ -0,0 +1,111 @@
1
+ import { __decorate } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorate.js";
2
+ import { KanonModuleConfig } from "../KanonModuleConfig.js";
3
+ import { __decorateMetadata } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateMetadata.js";
4
+ import { __decorateParam } from "../_virtual/_@oxc-project_runtime@0.112.0/helpers/decorateParam.js";
5
+ import { KanonClient } from "@ajna-inc/kanon-sdk";
6
+ import { InjectionSymbols, inject, injectable } from "@credo-ts/core";
7
+ import { ethers } from "ethers";
8
+
9
+ //#region src/ledger/KanonClientService.ts
10
+ var _ref;
11
+ /**
12
+ * ABI for the kanon AnonCredsStatusRegistry (per-credential issuance + revocation
13
+ * status). The status registry is keyed by (credDefId, credIdHash) bytes32 pairs.
14
+ */
15
+ const ANONCREDS_STATUS_REGISTRY_ABI = [
16
+ "function issueCredential(bytes32 credDefId, bytes32 credIdHash)",
17
+ "function revokeCredential(bytes32 credDefId, bytes32 credIdHash)",
18
+ "function getStatus(bytes32 credDefId, bytes32 credIdHash) view returns (uint8)",
19
+ "function isRevoked(bytes32 credDefId, bytes32 credIdHash) view returns (bool)",
20
+ "function isActive(bytes32 credDefId, bytes32 credIdHash) view returns (bool)",
21
+ "event CredentialIssued(bytes32 indexed credDefId, bytes32 indexed credIdHash, address indexed issuer, uint64 issuedAt)",
22
+ "event CredentialRevoked(bytes32 indexed credDefId, bytes32 indexed credIdHash, address indexed issuer, uint64 revokedAt)"
23
+ ];
24
+ /**
25
+ * Thin wrapper over the kanon SDK `KanonClient`. Builds an ethers provider +
26
+ * signer from the module config and exposes the SDK client, its typechain
27
+ * registries, and the per-credential AnonCredsStatusRegistry helpers.
28
+ */
29
+ /**
30
+ * Minimal ABI for the kanon AnonCredsStatusRegistry getter on the address book.
31
+ * The address book's `registries()` tuple exposes the status registry at the
32
+ * `anonCredsStatusRegistry` field, but the SDK's `KanonClient` does not surface
33
+ * it, so we read it directly when resolving via an address book.
34
+ */
35
+ const ADDRESS_BOOK_STATUS_ABI = ["function anonCredsStatusRegistry() view returns (address)"];
36
+ const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
37
+ let KanonClientService = class KanonClientService {
38
+ constructor(config, logger) {
39
+ this.logger = logger;
40
+ if (!config.rpcUrl) throw new Error("KanonClientService: rpcUrl is required");
41
+ if (!config.privateKey) throw new Error("KanonClientService: privateKey is required");
42
+ this.provider = new ethers.JsonRpcProvider(config.rpcUrl);
43
+ this.signer = new ethers.Wallet(config.privateKey, this.provider);
44
+ this.statusRegistryAddress = config.anonCredsStatusRegistryAddress;
45
+ this.addressBook = config.addressBook;
46
+ this.resolveLeavesBaseUrl = config.resolveLeavesBaseUrl;
47
+ if (!this.addressBook) this._client = new KanonClient(config.sdkDeployment, this.signer);
48
+ }
49
+ /**
50
+ * Resolve the registries via the configured address book and build the SDK
51
+ * client. No-op when an explicit deployment was used (client already built).
52
+ * Called by the module's async `initialize`.
53
+ */
54
+ async init() {
55
+ if (this._client) return;
56
+ if (!this.addressBook) throw new Error("KanonClientService.init: no addressBook configured and client not built");
57
+ this._client = await KanonClient.fromAddressBook(this.addressBook, this.signer);
58
+ if (!this.statusRegistryAddress) try {
59
+ const addr = await new ethers.Contract(this.addressBook, ADDRESS_BOOK_STATUS_ABI, this.provider).anonCredsStatusRegistry();
60
+ if (addr && addr !== ZERO_ADDRESS) this.statusRegistryAddress = addr;
61
+ } catch (error) {
62
+ this.logger.debug(`KanonClientService: could not resolve AnonCredsStatusRegistry from address book: ${error}`);
63
+ }
64
+ }
65
+ /** The SDK orchestration client. */
66
+ get client() {
67
+ if (!this._client) throw new Error("KanonClientService: client not initialized — addressBook resolution pending (call init()).");
68
+ return this._client;
69
+ }
70
+ /** Typechain registries (orgRegistry, didRegistry, schemaRegistry, …). */
71
+ get contracts() {
72
+ return this.client.contracts;
73
+ }
74
+ /** The operator signer used for on-chain writes. */
75
+ getSigner() {
76
+ return this.signer;
77
+ }
78
+ hasAnonCredsStatusRegistry() {
79
+ return Boolean(this.statusRegistryAddress);
80
+ }
81
+ getStatusRegistryAddress() {
82
+ if (!this.statusRegistryAddress) throw new Error("AnonCredsStatusRegistry address not configured. Set anonCredsStatusRegistryAddress in KanonModuleConfig (or in the deployment addresses).");
83
+ return this.statusRegistryAddress;
84
+ }
85
+ getStatusRegistry(forWrite = false) {
86
+ const runner = forWrite ? this.signer : this.provider;
87
+ return new ethers.Contract(this.getStatusRegistryAddress(), ANONCREDS_STATUS_REGISTRY_ABI, runner);
88
+ }
89
+ async issueCredentialStatus(credDefId, credIdHash) {
90
+ return (await this.getStatusRegistry(true).issueCredential(credDefId, credIdHash)).wait();
91
+ }
92
+ async revokeCredentialStatus(credDefId, credIdHash) {
93
+ return (await this.getStatusRegistry(true).revokeCredential(credDefId, credIdHash)).wait();
94
+ }
95
+ async isCredentialRevokedOnStatus(credDefId, credIdHash) {
96
+ return this.getStatusRegistry(false).isRevoked(credDefId, credIdHash);
97
+ }
98
+ async getCredentialStatus(credDefId, credIdHash) {
99
+ const status = await this.getStatusRegistry(false).getStatus(credDefId, credIdHash);
100
+ return Number(status);
101
+ }
102
+ };
103
+ KanonClientService = __decorate([
104
+ injectable(),
105
+ __decorateParam(1, inject(InjectionSymbols.Logger)),
106
+ __decorateMetadata("design:paramtypes", [KanonModuleConfig, Object])
107
+ ], KanonClientService);
108
+
109
+ //#endregion
110
+ export { KanonClientService };
111
+ //# sourceMappingURL=KanonClientService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KanonClientService.js","names":[],"sources":["../../src/ledger/KanonClientService.ts"],"sourcesContent":["import type { KanonContracts } from '@ajna-inc/kanon-sdk/core'\n\nimport { KanonClient } from '@ajna-inc/kanon-sdk'\nimport { inject, injectable, InjectionSymbols, type Logger } from '@credo-ts/core'\nimport { ethers } from 'ethers'\n\nimport { type KanonLeavesBaseUrlResolver, KanonModuleConfig } from '../KanonModuleConfig'\n\n/**\n * ABI for the kanon AnonCredsStatusRegistry (per-credential issuance + revocation\n * status). The status registry is keyed by (credDefId, credIdHash) bytes32 pairs.\n */\nconst ANONCREDS_STATUS_REGISTRY_ABI = [\n 'function issueCredential(bytes32 credDefId, bytes32 credIdHash)',\n 'function revokeCredential(bytes32 credDefId, bytes32 credIdHash)',\n 'function getStatus(bytes32 credDefId, bytes32 credIdHash) view returns (uint8)',\n 'function isRevoked(bytes32 credDefId, bytes32 credIdHash) view returns (bool)',\n 'function isActive(bytes32 credDefId, bytes32 credIdHash) view returns (bool)',\n 'event CredentialIssued(bytes32 indexed credDefId, bytes32 indexed credIdHash, address indexed issuer, uint64 issuedAt)',\n 'event CredentialRevoked(bytes32 indexed credDefId, bytes32 indexed credIdHash, address indexed issuer, uint64 revokedAt)',\n]\n\n/**\n * Thin wrapper over the kanon SDK `KanonClient`. Builds an ethers provider +\n * signer from the module config and exposes the SDK client, its typechain\n * registries, and the per-credential AnonCredsStatusRegistry helpers.\n */\n/**\n * Minimal ABI for the kanon AnonCredsStatusRegistry getter on the address book.\n * The address book's `registries()` tuple exposes the status registry at the\n * `anonCredsStatusRegistry` field, but the SDK's `KanonClient` does not surface\n * it, so we read it directly when resolving via an address book.\n */\nconst ADDRESS_BOOK_STATUS_ABI = ['function anonCredsStatusRegistry() view returns (address)']\n\nconst ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'\n\n/**\n * Thin wrapper over the kanon SDK `KanonClient`. Builds an ethers provider +\n * signer from the module config and exposes the SDK client, its typechain\n * registries, and the per-credential AnonCredsStatusRegistry helpers.\n */\n@injectable()\nexport class KanonClientService {\n private logger: Logger\n private provider: ethers.JsonRpcProvider\n private signer: ethers.Wallet\n private _client?: KanonClient\n private statusRegistryAddress?: string\n private addressBook?: string\n /** App-provided Mode B leaf-set base URL resolver (see `KanonModuleConfigOptions.resolveLeavesBaseUrl`). */\n public readonly resolveLeavesBaseUrl?: KanonLeavesBaseUrlResolver\n\n public constructor(config: KanonModuleConfig, @inject(InjectionSymbols.Logger) logger: Logger) {\n this.logger = logger\n if (!config.rpcUrl) throw new Error('KanonClientService: rpcUrl is required')\n if (!config.privateKey) throw new Error('KanonClientService: privateKey is required')\n\n this.provider = new ethers.JsonRpcProvider(config.rpcUrl)\n this.signer = new ethers.Wallet(config.privateKey, this.provider)\n this.statusRegistryAddress = config.anonCredsStatusRegistryAddress\n this.addressBook = config.addressBook\n this.resolveLeavesBaseUrl = config.resolveLeavesBaseUrl\n\n // With an explicit deployment the client is built synchronously here. With\n // an address book the registries must be read on-chain first, so the client\n // is built lazily by `init()` (awaited by the module's `initialize`).\n if (!this.addressBook) {\n this._client = new KanonClient(config.sdkDeployment, this.signer)\n }\n }\n\n /**\n * Resolve the registries via the configured address book and build the SDK\n * client. No-op when an explicit deployment was used (client already built).\n * Called by the module's async `initialize`.\n */\n public async init(): Promise<void> {\n if (this._client) return\n if (!this.addressBook) {\n throw new Error('KanonClientService.init: no addressBook configured and client not built')\n }\n this._client = await KanonClient.fromAddressBook(this.addressBook, this.signer)\n // Resolve the status registry from the address book if not set explicitly.\n if (!this.statusRegistryAddress) {\n try {\n const book = new ethers.Contract(this.addressBook, ADDRESS_BOOK_STATUS_ABI, this.provider)\n const addr: string = await book.anonCredsStatusRegistry()\n if (addr && addr !== ZERO_ADDRESS) this.statusRegistryAddress = addr\n } catch (error) {\n this.logger.debug(`KanonClientService: could not resolve AnonCredsStatusRegistry from address book: ${error}`)\n }\n }\n }\n\n /** The SDK orchestration client. */\n public get client(): KanonClient {\n if (!this._client) {\n throw new Error('KanonClientService: client not initialized — addressBook resolution pending (call init()).')\n }\n return this._client\n }\n\n /** Typechain registries (orgRegistry, didRegistry, schemaRegistry, …). */\n public get contracts(): KanonContracts {\n return this.client.contracts\n }\n\n /** The operator signer used for on-chain writes. */\n public getSigner(): ethers.Wallet {\n return this.signer\n }\n\n // ─────────────────────────────────────────────────────────────────────────\n // AnonCredsStatusRegistry — kanon per-credential issuance + revocation status\n // ─────────────────────────────────────────────────────────────────────────\n\n public hasAnonCredsStatusRegistry(): boolean {\n return Boolean(this.statusRegistryAddress)\n }\n\n private getStatusRegistryAddress(): string {\n if (!this.statusRegistryAddress) {\n throw new Error(\n 'AnonCredsStatusRegistry address not configured. Set anonCredsStatusRegistryAddress in KanonModuleConfig (or in the deployment addresses).'\n )\n }\n return this.statusRegistryAddress\n }\n\n private getStatusRegistry(forWrite = false) {\n const runner = forWrite ? this.signer : this.provider\n return new ethers.Contract(this.getStatusRegistryAddress(), ANONCREDS_STATUS_REGISTRY_ABI, runner)\n }\n\n public async issueCredentialStatus(credDefId: string, credIdHash: string) {\n const contract = this.getStatusRegistry(true)\n const tx = await contract.issueCredential(credDefId, credIdHash)\n return tx.wait()\n }\n\n public async revokeCredentialStatus(credDefId: string, credIdHash: string) {\n const contract = this.getStatusRegistry(true)\n const tx = await contract.revokeCredential(credDefId, credIdHash)\n return tx.wait()\n }\n\n public async isCredentialRevokedOnStatus(credDefId: string, credIdHash: string): Promise<boolean> {\n const contract = this.getStatusRegistry(false)\n return contract.isRevoked(credDefId, credIdHash)\n }\n\n public async getCredentialStatus(credDefId: string, credIdHash: string): Promise<number> {\n const contract = this.getStatusRegistry(false)\n const status: bigint = await contract.getStatus(credDefId, credIdHash)\n return Number(status)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,MAAM,gCAAgC;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;;;;;;AAaD,MAAM,0BAA0B,CAAC,4DAA4D;AAE7F,MAAM,eAAe;AAQd,+BAAM,mBAAmB;CAU9B,AAAO,YAAY,QAA2B,AAAiC,QAAgB;AAC7F,OAAK,SAAS;AACd,MAAI,CAAC,OAAO,OAAQ,OAAM,IAAI,MAAM,yCAAyC;AAC7E,MAAI,CAAC,OAAO,WAAY,OAAM,IAAI,MAAM,6CAA6C;AAErF,OAAK,WAAW,IAAI,OAAO,gBAAgB,OAAO,OAAO;AACzD,OAAK,SAAS,IAAI,OAAO,OAAO,OAAO,YAAY,KAAK,SAAS;AACjE,OAAK,wBAAwB,OAAO;AACpC,OAAK,cAAc,OAAO;AAC1B,OAAK,uBAAuB,OAAO;AAKnC,MAAI,CAAC,KAAK,YACR,MAAK,UAAU,IAAI,YAAY,OAAO,eAAe,KAAK,OAAO;;;;;;;CASrE,MAAa,OAAsB;AACjC,MAAI,KAAK,QAAS;AAClB,MAAI,CAAC,KAAK,YACR,OAAM,IAAI,MAAM,0EAA0E;AAE5F,OAAK,UAAU,MAAM,YAAY,gBAAgB,KAAK,aAAa,KAAK,OAAO;AAE/E,MAAI,CAAC,KAAK,sBACR,KAAI;GAEF,MAAM,OAAe,MADR,IAAI,OAAO,SAAS,KAAK,aAAa,yBAAyB,KAAK,SAAS,CAC1D,yBAAyB;AACzD,OAAI,QAAQ,SAAS,aAAc,MAAK,wBAAwB;WACzD,OAAO;AACd,QAAK,OAAO,MAAM,oFAAoF,QAAQ;;;;CAMpH,IAAW,SAAsB;AAC/B,MAAI,CAAC,KAAK,QACR,OAAM,IAAI,MAAM,6FAA6F;AAE/G,SAAO,KAAK;;;CAId,IAAW,YAA4B;AACrC,SAAO,KAAK,OAAO;;;CAIrB,AAAO,YAA2B;AAChC,SAAO,KAAK;;CAOd,AAAO,6BAAsC;AAC3C,SAAO,QAAQ,KAAK,sBAAsB;;CAG5C,AAAQ,2BAAmC;AACzC,MAAI,CAAC,KAAK,sBACR,OAAM,IAAI,MACR,4IACD;AAEH,SAAO,KAAK;;CAGd,AAAQ,kBAAkB,WAAW,OAAO;EAC1C,MAAM,SAAS,WAAW,KAAK,SAAS,KAAK;AAC7C,SAAO,IAAI,OAAO,SAAS,KAAK,0BAA0B,EAAE,+BAA+B,OAAO;;CAGpG,MAAa,sBAAsB,WAAmB,YAAoB;AAGxE,UADW,MADM,KAAK,kBAAkB,KAAK,CACnB,gBAAgB,WAAW,WAAW,EACtD,MAAM;;CAGlB,MAAa,uBAAuB,WAAmB,YAAoB;AAGzE,UADW,MADM,KAAK,kBAAkB,KAAK,CACnB,iBAAiB,WAAW,WAAW,EACvD,MAAM;;CAGlB,MAAa,4BAA4B,WAAmB,YAAsC;AAEhG,SADiB,KAAK,kBAAkB,MAAM,CAC9B,UAAU,WAAW,WAAW;;CAGlD,MAAa,oBAAoB,WAAmB,YAAqC;EAEvF,MAAM,SAAiB,MADN,KAAK,kBAAkB,MAAM,CACR,UAAU,WAAW,WAAW;AACtE,SAAO,OAAO,OAAO;;;;CAjHxB,YAAY;oBAWoC,OAAO,iBAAiB,OAAO"}
@@ -0,0 +1 @@
1
+ import { KanonClientService } from "./KanonClientService.js";
@@ -0,0 +1 @@
1
+ import { KanonClientService } from "./KanonClientService.js";
@@ -0,0 +1,24 @@
1
+ import { ParsedDid } from "@credo-ts/core";
2
+ import { ParsedKanonDid, orgDid as orgDid$1, userDid } from "@ajna-inc/kanon-sdk/anoncreds";
3
+
4
+ //#region src/utils/identifiers.d.ts
5
+ /** Matches a bare did:kanon DID (no path/query/fragment). */
6
+ declare const kanonDidRegex: RegExp;
7
+ /** Matches a did:kanon DID URL (with optional path/query/fragment). */
8
+ declare const kanonDidUrlRegex: RegExp;
9
+ /**
10
+ * Matches anything starting with `did:kanon:` — used as the resolver's
11
+ * `supportedMethods` guard and the AnonCreds registry's `supportedIdentifier`
12
+ * (schema / credDef IDs are DID URLs under the issuer DID).
13
+ */
14
+ declare const kanonPrefixRegex: RegExp;
15
+ type ParsedKanonDid$1 = ParsedDid & {
16
+ scope: ParsedKanonDid['scope']; /** bytes32 orgId as a 0x<64 hex> string (org-scoped DIDs only). */
17
+ orgId?: string;
18
+ userHex?: string;
19
+ };
20
+ /** Return the decomposed did:kanon URI, or null if it does not match. */
21
+ declare function parsekanonDid(didUrl: string): ParsedKanonDid$1 | null;
22
+ //#endregion
23
+ export { ParsedKanonDid$1 as ParsedKanonDid, kanonDidRegex, kanonDidUrlRegex, kanonPrefixRegex, orgDid$1 as orgDid, parsekanonDid, userDid };
24
+ //# sourceMappingURL=identifiers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identifiers.d.ts","names":[],"sources":["../../src/utils/identifiers.ts"],"mappings":";;;;;cAkCa,aAAA,EAAa,MAAA;;cAGb,gBAAA,EAAgB,MAAA;;;;;;cAOhB,gBAAA,EAAgB,MAAA;AAAA,KAEjB,gBAAA,GAAiB,SAAA;EAC3B,KAAA,EAAO,cAAA,WAOO;EALd,KAAA;EACA,OAAA;AAAA;;iBAIc,aAAA,CAAc,MAAA,WAAiB,gBAAA"}
@@ -0,0 +1,39 @@
1
+ import { orgDid as orgDid$1, parseKanonDid, userDid } from "@ajna-inc/kanon-sdk/anoncreds";
2
+
3
+ //#region src/utils/identifiers.ts
4
+ const ORG_ID = String.raw`(?<orgId>0x[0-9a-fA-F]{64})`;
5
+ const USER_HEX = String.raw`(?<userHex>0x[0-9a-fA-F]{64})`;
6
+ const SUBJECT = String.raw`(?:org:${ORG_ID}|user:${USER_HEX})`;
7
+ const PATH = String.raw`(?<path>/[^#?]*)?`;
8
+ const QUERY = String.raw`(?<query>\?[^#]*)?`;
9
+ const FRAGMENT = String.raw`(?<fragment>#.*)?`;
10
+ /** Matches a bare did:kanon DID (no path/query/fragment). */
11
+ const kanonDidRegex = new RegExp(`^did:kanon:${SUBJECT}$`);
12
+ /** Matches a did:kanon DID URL (with optional path/query/fragment). */
13
+ const kanonDidUrlRegex = new RegExp(`^did:kanon:${SUBJECT}${PATH}${QUERY}${FRAGMENT}$`);
14
+ /**
15
+ * Matches anything starting with `did:kanon:` — used as the resolver's
16
+ * `supportedMethods` guard and the AnonCreds registry's `supportedIdentifier`
17
+ * (schema / credDef IDs are DID URLs under the issuer DID).
18
+ */
19
+ const kanonPrefixRegex = /^did:kanon:.+$/;
20
+ /** Return the decomposed did:kanon URI, or null if it does not match. */
21
+ function parsekanonDid(didUrl) {
22
+ if (!didUrl) return null;
23
+ const parsed = parseKanonDid(didUrl);
24
+ if (!parsed) return null;
25
+ return {
26
+ did: parsed.did,
27
+ method: "kanon",
28
+ id: parsed.scope === "org" ? parsed.orgId ?? "" : parsed.userHex ?? "",
29
+ didUrl,
30
+ scope: parsed.scope,
31
+ orgId: parsed.orgId,
32
+ userHex: parsed.userHex,
33
+ path: parsed.path
34
+ };
35
+ }
36
+
37
+ //#endregion
38
+ export { kanonDidRegex, kanonDidUrlRegex, kanonPrefixRegex, orgDid$1 as orgDid, parsekanonDid, userDid };
39
+ //# sourceMappingURL=identifiers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identifiers.js","names":["sdkParseKanonDid"],"sources":["../../src/utils/identifiers.ts"],"sourcesContent":["/**\n * did:kanon identifier parsing for the kanon registries.\n *\n * kanon binds the DID identifier to its subject, so there are exactly two\n * shapes (no free-form network segment like the legacy method had):\n *\n * * org-scoped : `did:kanon:org:0x<64 hex>` (the bytes32 orgId)\n * * user-scoped : `did:kanon:user:0x<64 hex>` (bound to controller+salt)\n *\n * AnonCreds resource IDs are DID URLs under the issuer DID, e.g.\n * `did:kanon:org:0x<64 hex>/anoncreds/v0/SCHEMA/<name>/<version>`.\n *\n * Parsing is delegated to the SDK's `parseKanonDid` so the on-chain convention\n * stays authoritative; this module adapts the result into a Credo `ParsedDid`.\n */\nimport type { ParsedDid } from '@credo-ts/core'\n\nimport {\n orgDid,\n parseKanonDid as sdkParseKanonDid,\n userDid,\n type ParsedKanonDid as SdkParsedKanonDid,\n} from '@ajna-inc/kanon-sdk/anoncreds'\n\nexport { orgDid, userDid }\n\nconst ORG_ID = String.raw`(?<orgId>0x[0-9a-fA-F]{64})`\nconst USER_HEX = String.raw`(?<userHex>0x[0-9a-fA-F]{64})`\nconst SUBJECT = String.raw`(?:org:${ORG_ID}|user:${USER_HEX})`\nconst PATH = String.raw`(?<path>/[^#?]*)?`\nconst QUERY = String.raw`(?<query>\\?[^#]*)?`\nconst FRAGMENT = String.raw`(?<fragment>#.*)?`\n\n/** Matches a bare did:kanon DID (no path/query/fragment). */\nexport const kanonDidRegex = new RegExp(`^did:kanon:${SUBJECT}$`)\n\n/** Matches a did:kanon DID URL (with optional path/query/fragment). */\nexport const kanonDidUrlRegex = new RegExp(`^did:kanon:${SUBJECT}${PATH}${QUERY}${FRAGMENT}$`)\n\n/**\n * Matches anything starting with `did:kanon:` — used as the resolver's\n * `supportedMethods` guard and the AnonCreds registry's `supportedIdentifier`\n * (schema / credDef IDs are DID URLs under the issuer DID).\n */\nexport const kanonPrefixRegex = /^did:kanon:.+$/\n\nexport type ParsedKanonDid = ParsedDid & {\n scope: SdkParsedKanonDid['scope']\n /** bytes32 orgId as a 0x<64 hex> string (org-scoped DIDs only). */\n orgId?: string\n userHex?: string\n}\n\n/** Return the decomposed did:kanon URI, or null if it does not match. */\nexport function parsekanonDid(didUrl: string): ParsedKanonDid | null {\n if (!didUrl) return null\n const parsed = sdkParseKanonDid(didUrl)\n if (!parsed) return null\n return {\n did: parsed.did,\n method: 'kanon',\n id: parsed.scope === 'org' ? (parsed.orgId ?? '') : (parsed.userHex ?? ''),\n didUrl,\n scope: parsed.scope,\n orgId: parsed.orgId,\n userHex: parsed.userHex,\n path: parsed.path,\n }\n}\n"],"mappings":";;;AA0BA,MAAM,SAAS,OAAO,GAAG;AACzB,MAAM,WAAW,OAAO,GAAG;AAC3B,MAAM,UAAU,OAAO,GAAG,UAAU,OAAO,QAAQ,SAAS;AAC5D,MAAM,OAAO,OAAO,GAAG;AACvB,MAAM,QAAQ,OAAO,GAAG;AACxB,MAAM,WAAW,OAAO,GAAG;;AAG3B,MAAa,gBAAgB,IAAI,OAAO,cAAc,QAAQ,GAAG;;AAGjE,MAAa,mBAAmB,IAAI,OAAO,cAAc,UAAU,OAAO,QAAQ,SAAS,GAAG;;;;;;AAO9F,MAAa,mBAAmB;;AAUhC,SAAgB,cAAc,QAAuC;AACnE,KAAI,CAAC,OAAQ,QAAO;CACpB,MAAM,SAASA,cAAiB,OAAO;AACvC,KAAI,CAAC,OAAQ,QAAO;AACpB,QAAO;EACL,KAAK,OAAO;EACZ,QAAQ;EACR,IAAI,OAAO,UAAU,QAAS,OAAO,SAAS,KAAO,OAAO,WAAW;EACvE;EACA,OAAO,OAAO;EACd,OAAO,OAAO;EACd,SAAS,OAAO;EAChB,MAAM,OAAO;EACd"}