@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,123 @@
1
+ import { KanonDeployment } from "@ajna-inc/kanon-sdk/core";
2
+
3
+ //#region src/KanonModuleConfig.d.ts
4
+ /**
5
+ * The address book for a kanon deployment. Mirrors the `addresses` block of a
6
+ * kanon `deployments/<chainId>.json` file. `AnonCredsStatusRegistry` is optional
7
+ * here (the SDK's own deployment type does not carry it) but is required for
8
+ * per-credential issuance + revocation status.
9
+ */
10
+ interface KanonDeploymentAddresses {
11
+ OrganizationRegistry: string;
12
+ DIDRegistry: string;
13
+ SchemaRegistry: string;
14
+ CredentialDefinitionRegistry: string;
15
+ MerkleStateRegistry: string;
16
+ Halo2VerifierRegistry: string;
17
+ AnonCredsStatusRegistry?: string;
18
+ }
19
+ /**
20
+ * A kanon deployment record. Either passed inline or loaded from a deployment
21
+ * JSON file path (`deploymentPath`). Matches the SDK's `KanonDeployment` shape
22
+ * but the `addresses` block may additionally carry `AnonCredsStatusRegistry`.
23
+ */
24
+ interface KanonDeploymentInput {
25
+ chainId: number;
26
+ network?: string;
27
+ deployedAt?: string;
28
+ deployer?: string;
29
+ rootAdmin?: string;
30
+ addresses: KanonDeploymentAddresses;
31
+ implementations?: Partial<KanonDeploymentAddresses>;
32
+ }
33
+ /**
34
+ * KanonModuleConfigOptions defines the interface for the options of the
35
+ * KanonModuleConfig class. The full kanon deployment is required so the SDK
36
+ * `KanonClient` can be constructed; the issuing org id is required for issuer
37
+ * (schema / credential-definition) flows.
38
+ */
39
+ interface KanonModuleConfigOptions {
40
+ /** RPC endpoint of the chain the kanon registries are deployed to. */
41
+ rpcUrl: string;
42
+ /** Private key of the operator account used to sign on-chain writes. */
43
+ privateKey: string;
44
+ /**
45
+ * Address of the on-chain `KanonAddressBook` directory contract. When set,
46
+ * the seven registry addresses are resolved from it on-chain (single-address
47
+ * ergonomics) and an explicit `deployment`/`deploymentPath`/`chainId` is not
48
+ * required. Falls back to the `KANON_ADDRESS_BOOK` env var.
49
+ */
50
+ addressBook?: string;
51
+ /**
52
+ * The kanon deployment. Provide either an inline deployment object or a
53
+ * `deploymentPath` to a deployment JSON file. If neither is given, the
54
+ * deployment is loaded by `chainId` via the SDK's `loadDeployment`.
55
+ */
56
+ deployment?: KanonDeploymentInput;
57
+ /** Path to a kanon deployment JSON file (alternative to `deployment`). */
58
+ deploymentPath?: string;
59
+ /** Chain id to load a bundled deployment for (when no inline/path given). */
60
+ chainId?: number;
61
+ /**
62
+ * Organization this agent issues under. Org-scoped issuer DIDs are
63
+ * `did:kanon:org:<issuerOrgId>`. The orgId is a bytes32 value encoded as a
64
+ * 0x<64 hex> string. Required for issuer flows.
65
+ */
66
+ issuerOrgId?: string;
67
+ /**
68
+ * Address of the kanon AnonCredsStatusRegistry contract for per-credential
69
+ * issuance + revocation status. Falls back to
70
+ * `deployment.addresses.AnonCredsStatusRegistry`. If unset, status checks are
71
+ * skipped (every credential is treated as not-revoked) and the issuance
72
+ * tracker does nothing. Set this in production.
73
+ */
74
+ anonCredsStatusRegistryAddress?: string;
75
+ /**
76
+ * Resolves the base URL of the CrMS that serves a credential definition's
77
+ * Mode B (Groth16 non-revocation) leaf set at
78
+ * `GET {base}/api/kanon/mode-b/leaves?cred_def_id=…`. The holder needs that
79
+ * leaf set to build a presentation.
80
+ *
81
+ * Tried first. If it is not set, or returns `undefined`/`''`, the
82
+ * `KANON_ORG_BASE_URLS` / `KANON_MODEB_LEAVES_BASE_URL` env vars are used,
83
+ * then an on-chain event scan. Use this on React Native, where env vars are
84
+ * not available, e.g. backed by the app's issuer org → CrMS routing.
85
+ * May be sync or async.
86
+ */
87
+ resolveLeavesBaseUrl?: KanonLeavesBaseUrlResolver;
88
+ }
89
+ /** See {@link KanonModuleConfigOptions.resolveLeavesBaseUrl}. */
90
+ type KanonLeavesBaseUrlResolver = (credDefId: string) => string | undefined | Promise<string | undefined>;
91
+ declare class KanonModuleConfig {
92
+ private options;
93
+ private resolvedDeployment;
94
+ constructor(options: KanonModuleConfigOptions);
95
+ private static resolveDeployment;
96
+ /** See {@link KanonModuleConfigOptions.addressBook} */
97
+ get addressBook(): string | undefined;
98
+ /** See {@link KanonModuleConfigOptions.rpcUrl} */
99
+ get rpcUrl(): string;
100
+ /** See {@link KanonModuleConfigOptions.privateKey} */
101
+ get privateKey(): string;
102
+ /** See {@link KanonModuleConfigOptions.issuerOrgId} */
103
+ get issuerOrgId(): string | undefined;
104
+ /** The resolved kanon deployment (inline, file, or bundled), if any.
105
+ * Undefined when the registries are resolved via an `addressBook`. */
106
+ get deployment(): KanonDeploymentInput | undefined;
107
+ /**
108
+ * The deployment in the exact shape the SDK's `connectKanon` / `KanonClient`
109
+ * expects (i.e. without the optional AnonCredsStatusRegistry field that the
110
+ * SDK type does not declare). Throws if only an `addressBook` is configured
111
+ * (use `KanonClient.fromAddressBook` in that case).
112
+ */
113
+ get sdkDeployment(): KanonDeployment;
114
+ /** See {@link KanonModuleConfigOptions.anonCredsStatusRegistryAddress}.
115
+ * When only an `addressBook` is configured, this may be resolved on-chain
116
+ * by the client service during init (see `KanonClientService`). */
117
+ get anonCredsStatusRegistryAddress(): string | undefined;
118
+ /** See {@link KanonModuleConfigOptions.resolveLeavesBaseUrl} */
119
+ get resolveLeavesBaseUrl(): KanonLeavesBaseUrlResolver | undefined;
120
+ }
121
+ //#endregion
122
+ export { KanonDeploymentAddresses, KanonDeploymentInput, KanonLeavesBaseUrlResolver, KanonModuleConfig, KanonModuleConfigOptions };
123
+ //# sourceMappingURL=KanonModuleConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KanonModuleConfig.d.ts","names":[],"sources":["../src/KanonModuleConfig.ts"],"mappings":";;;;;AAUA;;;;UAAiB,wBAAA;EACf,oBAAA;EACA,WAAA;EACA,cAAA;EACA,4BAAA;EACA,mBAAA;EACA,qBAAA;EACA,uBAAA;AAAA;AAQF;;;;;AAAA,UAAiB,oBAAA;EACf,OAAA;EACA,OAAA;EACA,UAAA;EACA,QAAA;EACA,SAAA;EACA,SAAA,EAAW,wBAAA;EACX,eAAA,GAAkB,OAAA,CAAQ,wBAAA;AAAA;;;;;;;UASX,wBAAA;EAAwB;EAEvC,MAAA;EA8CiD;EA5CjD,UAAA;EAAA;;;;;;EAOA,WAAA;EAwBA;;;;;EAlBA,UAAA,GAAa,oBAAA;EAmCuB;EAjCpC,cAAA;EAiCwC;EA/BxC,OAAA;EAmDW;;;;;EA7CX,WAAA;EAyImC;;;;;;;EAjInC,8BAAA;EA8Ce;;;;;;;;;;;;EAjCf,oBAAA,GAAuB,0BAAA;AAAA;;KAIb,0BAAA,IAA8B,SAAA,kCAA2C,OAAA;AAAA,cAoBxE,iBAAA;EAAA,QACH,OAAA;EAAA,QACA,kBAAA;cAEW,OAAA,EAAS,wBAAA;EAAA,eAKb,iBAAA;;MAgBJ,WAAA,CAAA;;MAKA,MAAA,CAAA;;MAKA,UAAA,CAAA;;MAKA,WAAA,CAAA;;;MAMA,UAAA,CAAA,GAAc,oBAAA;;;;;;;MAUd,aAAA,CAAA,GAAiB,eAAA;;;;MA2BjB,8BAAA,CAAA;;MASA,oBAAA,CAAA,GAAwB,0BAAA;AAAA"}
@@ -0,0 +1,84 @@
1
+ import { loadDeployment } from "@ajna-inc/kanon-sdk";
2
+
3
+ //#region src/KanonModuleConfig.ts
4
+ function readDeploymentFile(path) {
5
+ const fs = globalThis.process?.getBuiltinModule?.("node:fs");
6
+ if (!fs) throw new Error(`KanonModuleConfig: deploymentPath ("${path}") needs Node.js file system access, which this runtime does not have. Pass the deployment inline via \`deployment\` or use \`addressBook\`.`);
7
+ const raw = fs.readFileSync(path, "utf-8");
8
+ const data = JSON.parse(raw);
9
+ if (!data || typeof data !== "object" || !data.addresses) throw new Error(`Kanon deployment file ${path} is missing an 'addresses' block`);
10
+ return data;
11
+ }
12
+ var KanonModuleConfig = class KanonModuleConfig {
13
+ constructor(options) {
14
+ this.options = options;
15
+ this.resolvedDeployment = KanonModuleConfig.resolveDeployment(options);
16
+ }
17
+ static resolveDeployment(options) {
18
+ if (options.deployment) return options.deployment;
19
+ if (options.deploymentPath) return readDeploymentFile(options.deploymentPath);
20
+ if (options.chainId != null) return loadDeployment(options.chainId);
21
+ if (options.addressBook || process.env.KANON_ADDRESS_BOOK) return void 0;
22
+ throw new Error("KanonModuleConfig: a kanon deployment is required — pass `deployment`, `deploymentPath`, `chainId`, or `addressBook`.");
23
+ }
24
+ /** See {@link KanonModuleConfigOptions.addressBook} */
25
+ get addressBook() {
26
+ return this.options.addressBook ?? process.env.KANON_ADDRESS_BOOK ?? void 0;
27
+ }
28
+ /** See {@link KanonModuleConfigOptions.rpcUrl} */
29
+ get rpcUrl() {
30
+ return this.options.rpcUrl;
31
+ }
32
+ /** See {@link KanonModuleConfigOptions.privateKey} */
33
+ get privateKey() {
34
+ return this.options.privateKey;
35
+ }
36
+ /** See {@link KanonModuleConfigOptions.issuerOrgId} */
37
+ get issuerOrgId() {
38
+ return this.options.issuerOrgId;
39
+ }
40
+ /** The resolved kanon deployment (inline, file, or bundled), if any.
41
+ * Undefined when the registries are resolved via an `addressBook`. */
42
+ get deployment() {
43
+ return this.resolvedDeployment;
44
+ }
45
+ /**
46
+ * The deployment in the exact shape the SDK's `connectKanon` / `KanonClient`
47
+ * expects (i.e. without the optional AnonCredsStatusRegistry field that the
48
+ * SDK type does not declare). Throws if only an `addressBook` is configured
49
+ * (use `KanonClient.fromAddressBook` in that case).
50
+ */
51
+ get sdkDeployment() {
52
+ const d = this.resolvedDeployment;
53
+ if (!d) throw new Error("KanonModuleConfig.sdkDeployment is unavailable when only an addressBook is configured; resolve the client via KanonClient.fromAddressBook.");
54
+ return {
55
+ chainId: d.chainId,
56
+ network: d.network ?? "kanon",
57
+ deployedAt: d.deployedAt ?? "",
58
+ deployer: d.deployer ?? "",
59
+ rootAdmin: d.rootAdmin ?? "",
60
+ addresses: {
61
+ OrganizationRegistry: d.addresses.OrganizationRegistry,
62
+ DIDRegistry: d.addresses.DIDRegistry,
63
+ SchemaRegistry: d.addresses.SchemaRegistry,
64
+ CredentialDefinitionRegistry: d.addresses.CredentialDefinitionRegistry,
65
+ MerkleStateRegistry: d.addresses.MerkleStateRegistry,
66
+ Halo2VerifierRegistry: d.addresses.Halo2VerifierRegistry
67
+ }
68
+ };
69
+ }
70
+ /** See {@link KanonModuleConfigOptions.anonCredsStatusRegistryAddress}.
71
+ * When only an `addressBook` is configured, this may be resolved on-chain
72
+ * by the client service during init (see `KanonClientService`). */
73
+ get anonCredsStatusRegistryAddress() {
74
+ return this.options.anonCredsStatusRegistryAddress ?? this.resolvedDeployment?.addresses.AnonCredsStatusRegistry ?? process.env.KANON_ANONCREDS_STATUS_REGISTRY_ADDRESS;
75
+ }
76
+ /** See {@link KanonModuleConfigOptions.resolveLeavesBaseUrl} */
77
+ get resolveLeavesBaseUrl() {
78
+ return this.options.resolveLeavesBaseUrl;
79
+ }
80
+ };
81
+
82
+ //#endregion
83
+ export { KanonModuleConfig };
84
+ //# sourceMappingURL=KanonModuleConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KanonModuleConfig.js","names":[],"sources":["../src/KanonModuleConfig.ts"],"sourcesContent":["import type { KanonDeployment } from '@ajna-inc/kanon-sdk/core'\n\nimport { loadDeployment } from '@ajna-inc/kanon-sdk'\n\n/**\n * The address book for a kanon deployment. Mirrors the `addresses` block of a\n * kanon `deployments/<chainId>.json` file. `AnonCredsStatusRegistry` is optional\n * here (the SDK's own deployment type does not carry it) but is required for\n * per-credential issuance + revocation status.\n */\nexport interface KanonDeploymentAddresses {\n OrganizationRegistry: string\n DIDRegistry: string\n SchemaRegistry: string\n CredentialDefinitionRegistry: string\n MerkleStateRegistry: string\n Halo2VerifierRegistry: string\n AnonCredsStatusRegistry?: string\n}\n\n/**\n * A kanon deployment record. Either passed inline or loaded from a deployment\n * JSON file path (`deploymentPath`). Matches the SDK's `KanonDeployment` shape\n * but the `addresses` block may additionally carry `AnonCredsStatusRegistry`.\n */\nexport interface KanonDeploymentInput {\n chainId: number\n network?: string\n deployedAt?: string\n deployer?: string\n rootAdmin?: string\n addresses: KanonDeploymentAddresses\n implementations?: Partial<KanonDeploymentAddresses>\n}\n\n/**\n * KanonModuleConfigOptions defines the interface for the options of the\n * KanonModuleConfig class. The full kanon deployment is required so the SDK\n * `KanonClient` can be constructed; the issuing org id is required for issuer\n * (schema / credential-definition) flows.\n */\nexport interface KanonModuleConfigOptions {\n /** RPC endpoint of the chain the kanon registries are deployed to. */\n rpcUrl: string\n /** Private key of the operator account used to sign on-chain writes. */\n privateKey: string\n /**\n * Address of the on-chain `KanonAddressBook` directory contract. When set,\n * the seven registry addresses are resolved from it on-chain (single-address\n * ergonomics) and an explicit `deployment`/`deploymentPath`/`chainId` is not\n * required. Falls back to the `KANON_ADDRESS_BOOK` env var.\n */\n addressBook?: string\n /**\n * The kanon deployment. Provide either an inline deployment object or a\n * `deploymentPath` to a deployment JSON file. If neither is given, the\n * deployment is loaded by `chainId` via the SDK's `loadDeployment`.\n */\n deployment?: KanonDeploymentInput\n /** Path to a kanon deployment JSON file (alternative to `deployment`). */\n deploymentPath?: string\n /** Chain id to load a bundled deployment for (when no inline/path given). */\n chainId?: number\n /**\n * Organization this agent issues under. Org-scoped issuer DIDs are\n * `did:kanon:org:<issuerOrgId>`. The orgId is a bytes32 value encoded as a\n * 0x<64 hex> string. Required for issuer flows.\n */\n issuerOrgId?: string\n /**\n * Address of the kanon AnonCredsStatusRegistry contract for per-credential\n * issuance + revocation status. Falls back to\n * `deployment.addresses.AnonCredsStatusRegistry`. If unset, status checks are\n * skipped (every credential is treated as not-revoked) and the issuance\n * tracker does nothing. Set this in production.\n */\n anonCredsStatusRegistryAddress?: string\n /**\n * Resolves the base URL of the CrMS that serves a credential definition's\n * Mode B (Groth16 non-revocation) leaf set at\n * `GET {base}/api/kanon/mode-b/leaves?cred_def_id=…`. The holder needs that\n * leaf set to build a presentation.\n *\n * Tried first. If it is not set, or returns `undefined`/`''`, the\n * `KANON_ORG_BASE_URLS` / `KANON_MODEB_LEAVES_BASE_URL` env vars are used,\n * then an on-chain event scan. Use this on React Native, where env vars are\n * not available, e.g. backed by the app's issuer org → CrMS routing.\n * May be sync or async.\n */\n resolveLeavesBaseUrl?: KanonLeavesBaseUrlResolver\n}\n\n/** See {@link KanonModuleConfigOptions.resolveLeavesBaseUrl}. */\nexport type KanonLeavesBaseUrlResolver = (credDefId: string) => string | undefined | Promise<string | undefined>\n\nfunction readDeploymentFile(path: string): KanonDeploymentInput {\n // `node:fs` is loaded only here, never imported at module level, so the\n // package bundles on React Native without a `node:fs` shim. On React Native\n // pass `deployment` inline or use `addressBook` instead.\n const fs = globalThis.process?.getBuiltinModule?.('node:fs') as typeof import('node:fs') | undefined\n if (!fs) {\n throw new Error(\n `KanonModuleConfig: deploymentPath (\"${path}\") needs Node.js file system access, which this runtime does not have. Pass the deployment inline via \\`deployment\\` or use \\`addressBook\\`.`\n )\n }\n const raw = fs.readFileSync(path, 'utf-8')\n const data = JSON.parse(raw)\n if (!data || typeof data !== 'object' || !data.addresses) {\n throw new Error(`Kanon deployment file ${path} is missing an 'addresses' block`)\n }\n return data as KanonDeploymentInput\n}\n\nexport class KanonModuleConfig {\n private options: KanonModuleConfigOptions\n private resolvedDeployment: KanonDeploymentInput | undefined\n\n public constructor(options: KanonModuleConfigOptions) {\n this.options = options\n this.resolvedDeployment = KanonModuleConfig.resolveDeployment(options)\n }\n\n private static resolveDeployment(options: KanonModuleConfigOptions): KanonDeploymentInput | undefined {\n if (options.deployment) return options.deployment\n if (options.deploymentPath) return readDeploymentFile(options.deploymentPath)\n if (options.chainId != null) {\n // The SDK's bundled deployment for the chain id (throws if not found).\n return loadDeployment(options.chainId) as unknown as KanonDeploymentInput\n }\n // An address book resolves the registries on-chain, so an explicit\n // deployment is not required when one is configured.\n if (options.addressBook || process.env.KANON_ADDRESS_BOOK) return undefined\n throw new Error(\n 'KanonModuleConfig: a kanon deployment is required — pass `deployment`, `deploymentPath`, `chainId`, or `addressBook`.'\n )\n }\n\n /** See {@link KanonModuleConfigOptions.addressBook} */\n public get addressBook(): string | undefined {\n return this.options.addressBook ?? process.env.KANON_ADDRESS_BOOK ?? undefined\n }\n\n /** See {@link KanonModuleConfigOptions.rpcUrl} */\n public get rpcUrl(): string {\n return this.options.rpcUrl\n }\n\n /** See {@link KanonModuleConfigOptions.privateKey} */\n public get privateKey(): string {\n return this.options.privateKey\n }\n\n /** See {@link KanonModuleConfigOptions.issuerOrgId} */\n public get issuerOrgId(): string | undefined {\n return this.options.issuerOrgId\n }\n\n /** The resolved kanon deployment (inline, file, or bundled), if any.\n * Undefined when the registries are resolved via an `addressBook`. */\n public get deployment(): KanonDeploymentInput | undefined {\n return this.resolvedDeployment\n }\n\n /**\n * The deployment in the exact shape the SDK's `connectKanon` / `KanonClient`\n * expects (i.e. without the optional AnonCredsStatusRegistry field that the\n * SDK type does not declare). Throws if only an `addressBook` is configured\n * (use `KanonClient.fromAddressBook` in that case).\n */\n public get sdkDeployment(): KanonDeployment {\n const d = this.resolvedDeployment\n if (!d) {\n throw new Error(\n 'KanonModuleConfig.sdkDeployment is unavailable when only an addressBook is configured; resolve the client via KanonClient.fromAddressBook.'\n )\n }\n return {\n chainId: d.chainId,\n network: d.network ?? 'kanon',\n deployedAt: d.deployedAt ?? '',\n deployer: d.deployer ?? '',\n rootAdmin: d.rootAdmin ?? '',\n addresses: {\n OrganizationRegistry: d.addresses.OrganizationRegistry,\n DIDRegistry: d.addresses.DIDRegistry,\n SchemaRegistry: d.addresses.SchemaRegistry,\n CredentialDefinitionRegistry: d.addresses.CredentialDefinitionRegistry,\n MerkleStateRegistry: d.addresses.MerkleStateRegistry,\n Halo2VerifierRegistry: d.addresses.Halo2VerifierRegistry,\n },\n }\n }\n\n /** See {@link KanonModuleConfigOptions.anonCredsStatusRegistryAddress}.\n * When only an `addressBook` is configured, this may be resolved on-chain\n * by the client service during init (see `KanonClientService`). */\n public get anonCredsStatusRegistryAddress(): string | undefined {\n return (\n this.options.anonCredsStatusRegistryAddress ??\n this.resolvedDeployment?.addresses.AnonCredsStatusRegistry ??\n process.env.KANON_ANONCREDS_STATUS_REGISTRY_ADDRESS\n )\n }\n\n /** See {@link KanonModuleConfigOptions.resolveLeavesBaseUrl} */\n public get resolveLeavesBaseUrl(): KanonLeavesBaseUrlResolver | undefined {\n return this.options.resolveLeavesBaseUrl\n }\n}\n"],"mappings":";;;AA+FA,SAAS,mBAAmB,MAAoC;CAI9D,MAAM,KAAK,WAAW,SAAS,mBAAmB,UAAU;AAC5D,KAAI,CAAC,GACH,OAAM,IAAI,MACR,uCAAuC,KAAK,8IAC7C;CAEH,MAAM,MAAM,GAAG,aAAa,MAAM,QAAQ;CAC1C,MAAM,OAAO,KAAK,MAAM,IAAI;AAC5B,KAAI,CAAC,QAAQ,OAAO,SAAS,YAAY,CAAC,KAAK,UAC7C,OAAM,IAAI,MAAM,yBAAyB,KAAK,kCAAkC;AAElF,QAAO;;AAGT,IAAa,oBAAb,MAAa,kBAAkB;CAI7B,AAAO,YAAY,SAAmC;AACpD,OAAK,UAAU;AACf,OAAK,qBAAqB,kBAAkB,kBAAkB,QAAQ;;CAGxE,OAAe,kBAAkB,SAAqE;AACpG,MAAI,QAAQ,WAAY,QAAO,QAAQ;AACvC,MAAI,QAAQ,eAAgB,QAAO,mBAAmB,QAAQ,eAAe;AAC7E,MAAI,QAAQ,WAAW,KAErB,QAAO,eAAe,QAAQ,QAAQ;AAIxC,MAAI,QAAQ,eAAe,QAAQ,IAAI,mBAAoB,QAAO;AAClE,QAAM,IAAI,MACR,wHACD;;;CAIH,IAAW,cAAkC;AAC3C,SAAO,KAAK,QAAQ,eAAe,QAAQ,IAAI,sBAAsB;;;CAIvE,IAAW,SAAiB;AAC1B,SAAO,KAAK,QAAQ;;;CAItB,IAAW,aAAqB;AAC9B,SAAO,KAAK,QAAQ;;;CAItB,IAAW,cAAkC;AAC3C,SAAO,KAAK,QAAQ;;;;CAKtB,IAAW,aAA+C;AACxD,SAAO,KAAK;;;;;;;;CASd,IAAW,gBAAiC;EAC1C,MAAM,IAAI,KAAK;AACf,MAAI,CAAC,EACH,OAAM,IAAI,MACR,6IACD;AAEH,SAAO;GACL,SAAS,EAAE;GACX,SAAS,EAAE,WAAW;GACtB,YAAY,EAAE,cAAc;GAC5B,UAAU,EAAE,YAAY;GACxB,WAAW,EAAE,aAAa;GAC1B,WAAW;IACT,sBAAsB,EAAE,UAAU;IAClC,aAAa,EAAE,UAAU;IACzB,gBAAgB,EAAE,UAAU;IAC5B,8BAA8B,EAAE,UAAU;IAC1C,qBAAqB,EAAE,UAAU;IACjC,uBAAuB,EAAE,UAAU;IACpC;GACF;;;;;CAMH,IAAW,iCAAqD;AAC9D,SACE,KAAK,QAAQ,kCACb,KAAK,oBAAoB,UAAU,2BACnC,QAAQ,IAAI;;;CAKhB,IAAW,uBAA+D;AACxE,SAAO,KAAK,QAAQ"}
@@ -0,0 +1,10 @@
1
+ //#region \0@oxc-project+runtime@0.112.0/helpers/decorate.js
2
+ function __decorate(decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ }
8
+
9
+ //#endregion
10
+ export { __decorate };
@@ -0,0 +1,7 @@
1
+ //#region \0@oxc-project+runtime@0.112.0/helpers/decorateMetadata.js
2
+ function __decorateMetadata(k, v) {
3
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
4
+ }
5
+
6
+ //#endregion
7
+ export { __decorateMetadata };
@@ -0,0 +1,9 @@
1
+ //#region \0@oxc-project+runtime@0.112.0/helpers/decorateParam.js
2
+ function __decorateParam(paramIndex, decorator) {
3
+ return function(target, key) {
4
+ decorator(target, key, paramIndex);
5
+ };
6
+ }
7
+
8
+ //#endregion
9
+ export { __decorateParam };
@@ -0,0 +1,33 @@
1
+ //#region src/anoncreds/helpers/buildKanonCredentialAttributes.d.ts
2
+ /**
3
+ * Standard AnonCreds credential attribute entry.
4
+ */
5
+ interface KanonCredentialAttribute {
6
+ name: string;
7
+ value: string;
8
+ }
9
+ interface BuildKanonCredentialAttributesResult {
10
+ /**
11
+ * The (possibly augmented) attribute list. If the caller did not include a
12
+ * `kanonCredId` entry one is prepended with a freshly-generated UUID. The
13
+ * original array is not mutated.
14
+ */
15
+ attributes: KanonCredentialAttribute[];
16
+ /**
17
+ * The credId value that ends up on the credential, regardless of whether it
18
+ * was supplied by the caller or generated here. Issuers want this so they can
19
+ * record (credDefId, credId) in their off-chain ledger for later revocation.
20
+ */
21
+ credId: string;
22
+ }
23
+ /**
24
+ * Ensures the AnonCreds attribute list carries a `kanonCredId` entry. If the
25
+ * caller already included one its value is reused; otherwise a UUID is
26
+ * generated and prepended. Returns the final attribute list plus the credId
27
+ * for callers that need it for off-chain bookkeeping (revocation indexing,
28
+ * receipts, etc.).
29
+ */
30
+ declare function buildKanonCredentialAttributes(attrs: KanonCredentialAttribute[]): BuildKanonCredentialAttributesResult;
31
+ //#endregion
32
+ export { BuildKanonCredentialAttributesResult, KanonCredentialAttribute, buildKanonCredentialAttributes };
33
+ //# sourceMappingURL=buildKanonCredentialAttributes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildKanonCredentialAttributes.d.ts","names":[],"sources":["../../../src/anoncreds/helpers/buildKanonCredentialAttributes.ts"],"mappings":";;AAKA;;UAAiB,wBAAA;EACf,IAAA;EACA,KAAA;AAAA;AAAA,UAGe,oCAAA;;;;;;EAMf,UAAA,EAAY,wBAAA;EAMN;AA0BR;;;;EA1BE,MAAA;AAAA;;;;;;;;iBA0Bc,8BAAA,CACd,KAAA,EAAO,wBAAA,KACN,oCAAA"}
@@ -0,0 +1,43 @@
1
+ import { KANON_CRED_ID_ATTRIBUTE } from "../utils/credIdHash.js";
2
+
3
+ //#region src/anoncreds/helpers/buildKanonCredentialAttributes.ts
4
+ /**
5
+ * Generates a v4 UUID using the platform-provided `crypto.randomUUID`. Available
6
+ * on Node 19+, modern browsers, and React Native (Hermes). We deliberately avoid
7
+ * adding the `uuid` npm dependency to keep the package footprint minimal.
8
+ */
9
+ function randomUuid() {
10
+ const c = globalThis.crypto;
11
+ if (!c || typeof c.randomUUID !== "function") throw new Error("buildKanonCredentialAttributes: globalThis.crypto.randomUUID() is unavailable in this runtime. Use Node >= 19, a modern browser, or polyfill globalThis.crypto.");
12
+ return c.randomUUID();
13
+ }
14
+ /**
15
+ * Ensures the AnonCreds attribute list carries a `kanonCredId` entry. If the
16
+ * caller already included one its value is reused; otherwise a UUID is
17
+ * generated and prepended. Returns the final attribute list plus the credId
18
+ * for callers that need it for off-chain bookkeeping (revocation indexing,
19
+ * receipts, etc.).
20
+ */
21
+ function buildKanonCredentialAttributes(attrs) {
22
+ if (!Array.isArray(attrs)) throw new Error("buildKanonCredentialAttributes: attrs must be an array");
23
+ const existing = attrs.find((a) => a.name === KANON_CRED_ID_ATTRIBUTE);
24
+ if (existing) {
25
+ if (typeof existing.value !== "string" || existing.value.length === 0) throw new Error(`buildKanonCredentialAttributes: existing '${KANON_CRED_ID_ATTRIBUTE}' attribute must have a non-empty string value`);
26
+ return {
27
+ attributes: [...attrs],
28
+ credId: existing.value
29
+ };
30
+ }
31
+ const credId = randomUuid();
32
+ return {
33
+ attributes: [{
34
+ name: KANON_CRED_ID_ATTRIBUTE,
35
+ value: credId
36
+ }, ...attrs],
37
+ credId
38
+ };
39
+ }
40
+
41
+ //#endregion
42
+ export { buildKanonCredentialAttributes };
43
+ //# sourceMappingURL=buildKanonCredentialAttributes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildKanonCredentialAttributes.js","names":[],"sources":["../../../src/anoncreds/helpers/buildKanonCredentialAttributes.ts"],"sourcesContent":["import { KANON_CRED_ID_ATTRIBUTE } from '../utils/credIdHash'\n\n/**\n * Standard AnonCreds credential attribute entry.\n */\nexport interface KanonCredentialAttribute {\n name: string\n value: string\n}\n\nexport interface BuildKanonCredentialAttributesResult {\n /**\n * The (possibly augmented) attribute list. If the caller did not include a\n * `kanonCredId` entry one is prepended with a freshly-generated UUID. The\n * original array is not mutated.\n */\n attributes: KanonCredentialAttribute[]\n /**\n * The credId value that ends up on the credential, regardless of whether it\n * was supplied by the caller or generated here. Issuers want this so they can\n * record (credDefId, credId) in their off-chain ledger for later revocation.\n */\n credId: string\n}\n\n/**\n * Generates a v4 UUID using the platform-provided `crypto.randomUUID`. Available\n * on Node 19+, modern browsers, and React Native (Hermes). We deliberately avoid\n * adding the `uuid` npm dependency to keep the package footprint minimal.\n */\nfunction randomUuid(): string {\n // biome-ignore lint/suspicious/noExplicitAny: globalThis.crypto typing varies across runtimes\n const c: any = (globalThis as any).crypto\n if (!c || typeof c.randomUUID !== 'function') {\n throw new Error(\n 'buildKanonCredentialAttributes: globalThis.crypto.randomUUID() is unavailable in this runtime. Use Node >= 19, a modern browser, or polyfill globalThis.crypto.'\n )\n }\n return c.randomUUID()\n}\n\n/**\n * Ensures the AnonCreds attribute list carries a `kanonCredId` entry. If the\n * caller already included one its value is reused; otherwise a UUID is\n * generated and prepended. Returns the final attribute list plus the credId\n * for callers that need it for off-chain bookkeeping (revocation indexing,\n * receipts, etc.).\n */\nexport function buildKanonCredentialAttributes(\n attrs: KanonCredentialAttribute[]\n): BuildKanonCredentialAttributesResult {\n if (!Array.isArray(attrs)) {\n throw new Error('buildKanonCredentialAttributes: attrs must be an array')\n }\n\n const existing = attrs.find((a) => a.name === KANON_CRED_ID_ATTRIBUTE)\n if (existing) {\n if (typeof existing.value !== 'string' || existing.value.length === 0) {\n throw new Error(\n `buildKanonCredentialAttributes: existing '${KANON_CRED_ID_ATTRIBUTE}' attribute must have a non-empty string value`\n )\n }\n return { attributes: [...attrs], credId: existing.value }\n }\n\n const credId = randomUuid()\n return {\n attributes: [{ name: KANON_CRED_ID_ATTRIBUTE, value: credId }, ...attrs],\n credId,\n }\n}\n"],"mappings":";;;;;;;;AA8BA,SAAS,aAAqB;CAE5B,MAAM,IAAU,WAAmB;AACnC,KAAI,CAAC,KAAK,OAAO,EAAE,eAAe,WAChC,OAAM,IAAI,MACR,kKACD;AAEH,QAAO,EAAE,YAAY;;;;;;;;;AAUvB,SAAgB,+BACd,OACsC;AACtC,KAAI,CAAC,MAAM,QAAQ,MAAM,CACvB,OAAM,IAAI,MAAM,yDAAyD;CAG3E,MAAM,WAAW,MAAM,MAAM,MAAM,EAAE,SAAS,wBAAwB;AACtE,KAAI,UAAU;AACZ,MAAI,OAAO,SAAS,UAAU,YAAY,SAAS,MAAM,WAAW,EAClE,OAAM,IAAI,MACR,6CAA6C,wBAAwB,gDACtE;AAEH,SAAO;GAAE,YAAY,CAAC,GAAG,MAAM;GAAE,QAAQ,SAAS;GAAO;;CAG3D,MAAM,SAAS,YAAY;AAC3B,QAAO;EACL,YAAY,CAAC;GAAE,MAAM;GAAyB,OAAO;GAAQ,EAAE,GAAG,MAAM;EACxE;EACD"}
@@ -0,0 +1,45 @@
1
+ //#region src/anoncreds/helpers/buildKanonProofRequest.d.ts
2
+ type KanonProofRequest = Record<string, any>;
3
+ interface BuildKanonProofRequestInput {
4
+ /**
5
+ * The verifier's existing AnonCreds proof request. Not mutated.
6
+ */
7
+ proofRequest: KanonProofRequest;
8
+ /**
9
+ * The list of credDefIds the caller knows live on the Kanon VDR. For each
10
+ * entry an extra revealed attribute named `kanon_<credDefId>_credId` is added
11
+ * with `restrictions: [{ cred_def_id: credDefId }]`, so the verifier can
12
+ * extract the credId per credDef during {@link KanonWrappedAnonCredsVerifierService}.
13
+ *
14
+ * Entries already present (by referent name) are left untouched, making the
15
+ * helper idempotent.
16
+ */
17
+ kanonCredDefIds: string[];
18
+ /**
19
+ * Subset of `kanonCredDefIds` (or a separate list) for credDefs that
20
+ * additionally opt into Mode B (Groth16 non-revocation). For each entry a
21
+ * SELF-ATTESTABLE referent named `kanon_<credDefId>_zkProof` is added so the
22
+ * holder's `KanonWrappedAnonCredsHolderService` can inject the SNARK proof
23
+ * and the matching verifier wrapper can validate it on chain.
24
+ *
25
+ * Leaving this empty / unset means the proof request does NOT carry a Mode B
26
+ * slot — non-revocation will not be checked on chain even if the credDef
27
+ * supports it. This is the "graceful downgrade" behaviour: legacy verifiers
28
+ * keep accepting standard AnonCreds proofs unchanged.
29
+ */
30
+ modeBCredDefIds?: string[];
31
+ }
32
+ /**
33
+ * Augments an AnonCreds proof request with the `kanonCredId` revealed entries
34
+ * required by the Kanon verifier wrapper. The caller passes in the set of
35
+ * credDefIds known to live on the Kanon VDR; for each one we add a uniquely
36
+ * named revealed attribute (`kanon_<credDefId>_credId`) restricted to that
37
+ * credDefId. Idempotent — calling twice produces the same request.
38
+ *
39
+ * The original `proofRequest` argument is not mutated; a shallow copy with a
40
+ * cloned `requested_attributes` map is returned.
41
+ */
42
+ declare function buildKanonProofRequest(input: BuildKanonProofRequestInput): KanonProofRequest;
43
+ //#endregion
44
+ export { BuildKanonProofRequestInput, KanonProofRequest, buildKanonProofRequest };
45
+ //# sourceMappingURL=buildKanonProofRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildKanonProofRequest.d.ts","names":[],"sources":["../../../src/anoncreds/helpers/buildKanonProofRequest.ts"],"mappings":";KAQY,iBAAA,GAAoB,MAAA;AAAA,UAEf,2BAAA;EAFY;;;EAM3B,YAAA,EAAc,iBAAA;EAJC;;;;;;;;;EAcf,eAAA;EA0Bc;;;;;;;;;;;;EAbd,eAAA;AAAA;;;;;;;;;;;iBAac,sBAAA,CAAuB,KAAA,EAAO,2BAAA,GAA8B,iBAAA"}
@@ -0,0 +1,45 @@
1
+ import { KANON_CRED_ID_ATTRIBUTE as KANON_CRED_ID_ATTRIBUTE$1 } from "../utils/credIdHash.js";
2
+ import { KANON_ZK_PROOF_ATTRIBUTE } from "@ajna-inc/kanon-sdk";
3
+
4
+ //#region src/anoncreds/helpers/buildKanonProofRequest.ts
5
+ /**
6
+ * Augments an AnonCreds proof request with the `kanonCredId` revealed entries
7
+ * required by the Kanon verifier wrapper. The caller passes in the set of
8
+ * credDefIds known to live on the Kanon VDR; for each one we add a uniquely
9
+ * named revealed attribute (`kanon_<credDefId>_credId`) restricted to that
10
+ * credDefId. Idempotent — calling twice produces the same request.
11
+ *
12
+ * The original `proofRequest` argument is not mutated; a shallow copy with a
13
+ * cloned `requested_attributes` map is returned.
14
+ */
15
+ function buildKanonProofRequest(input) {
16
+ const { proofRequest, kanonCredDefIds, modeBCredDefIds } = input;
17
+ if (!proofRequest || typeof proofRequest !== "object") throw new Error("buildKanonProofRequest: proofRequest must be an object");
18
+ if (!Array.isArray(kanonCredDefIds)) throw new Error("buildKanonProofRequest: kanonCredDefIds must be an array of strings");
19
+ if (modeBCredDefIds !== void 0 && !Array.isArray(modeBCredDefIds)) throw new Error("buildKanonProofRequest: modeBCredDefIds must be an array of strings");
20
+ const requestedAttributes = { ...proofRequest.requested_attributes ?? {} };
21
+ for (const credDefId of kanonCredDefIds) {
22
+ if (typeof credDefId !== "string" || credDefId.length === 0) throw new Error("buildKanonProofRequest: each kanonCredDefIds entry must be a non-empty string");
23
+ const referent = `kanon_${credDefId}_credId`;
24
+ if (referent in requestedAttributes) continue;
25
+ requestedAttributes[referent] = {
26
+ name: KANON_CRED_ID_ATTRIBUTE$1,
27
+ restrictions: [{ cred_def_id: credDefId }]
28
+ };
29
+ }
30
+ if (modeBCredDefIds) for (const credDefId of modeBCredDefIds) {
31
+ if (typeof credDefId !== "string" || credDefId.length === 0) throw new Error("buildKanonProofRequest: each modeBCredDefIds entry must be a non-empty string");
32
+ const referent = `kanon_${credDefId.toLowerCase()}_zkProof`;
33
+ if (referent in requestedAttributes) continue;
34
+ requestedAttributes[referent] = { name: KANON_ZK_PROOF_ATTRIBUTE };
35
+ }
36
+ return {
37
+ ...proofRequest,
38
+ requested_attributes: requestedAttributes,
39
+ requested_predicates: { ...proofRequest.requested_predicates ?? {} }
40
+ };
41
+ }
42
+
43
+ //#endregion
44
+ export { buildKanonProofRequest };
45
+ //# sourceMappingURL=buildKanonProofRequest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildKanonProofRequest.js","names":["KANON_CRED_ID_ATTRIBUTE"],"sources":["../../../src/anoncreds/helpers/buildKanonProofRequest.ts"],"sourcesContent":["import { KANON_ZK_PROOF_ATTRIBUTE } from '@ajna-inc/kanon-sdk'\n\nimport { KANON_CRED_ID_ATTRIBUTE } from '../utils/credIdHash'\n\n// AnonCreds proof requests are inherently permissive shapes; we don't import a\n// concrete type from `@credo-ts/anoncreds` to keep this helper usable from both\n// issuer and verifier code paths without dragging the full module surface in.\n// biome-ignore lint/suspicious/noExplicitAny: AnonCreds proof request is permissive\nexport type KanonProofRequest = Record<string, any>\n\nexport interface BuildKanonProofRequestInput {\n /**\n * The verifier's existing AnonCreds proof request. Not mutated.\n */\n proofRequest: KanonProofRequest\n /**\n * The list of credDefIds the caller knows live on the Kanon VDR. For each\n * entry an extra revealed attribute named `kanon_<credDefId>_credId` is added\n * with `restrictions: [{ cred_def_id: credDefId }]`, so the verifier can\n * extract the credId per credDef during {@link KanonWrappedAnonCredsVerifierService}.\n *\n * Entries already present (by referent name) are left untouched, making the\n * helper idempotent.\n */\n kanonCredDefIds: string[]\n /**\n * Subset of `kanonCredDefIds` (or a separate list) for credDefs that\n * additionally opt into Mode B (Groth16 non-revocation). For each entry a\n * SELF-ATTESTABLE referent named `kanon_<credDefId>_zkProof` is added so the\n * holder's `KanonWrappedAnonCredsHolderService` can inject the SNARK proof\n * and the matching verifier wrapper can validate it on chain.\n *\n * Leaving this empty / unset means the proof request does NOT carry a Mode B\n * slot — non-revocation will not be checked on chain even if the credDef\n * supports it. This is the \"graceful downgrade\" behaviour: legacy verifiers\n * keep accepting standard AnonCreds proofs unchanged.\n */\n modeBCredDefIds?: string[]\n}\n\n/**\n * Augments an AnonCreds proof request with the `kanonCredId` revealed entries\n * required by the Kanon verifier wrapper. The caller passes in the set of\n * credDefIds known to live on the Kanon VDR; for each one we add a uniquely\n * named revealed attribute (`kanon_<credDefId>_credId`) restricted to that\n * credDefId. Idempotent — calling twice produces the same request.\n *\n * The original `proofRequest` argument is not mutated; a shallow copy with a\n * cloned `requested_attributes` map is returned.\n */\nexport function buildKanonProofRequest(input: BuildKanonProofRequestInput): KanonProofRequest {\n const { proofRequest, kanonCredDefIds, modeBCredDefIds } = input\n if (!proofRequest || typeof proofRequest !== 'object') {\n throw new Error('buildKanonProofRequest: proofRequest must be an object')\n }\n if (!Array.isArray(kanonCredDefIds)) {\n throw new Error('buildKanonProofRequest: kanonCredDefIds must be an array of strings')\n }\n if (modeBCredDefIds !== undefined && !Array.isArray(modeBCredDefIds)) {\n throw new Error('buildKanonProofRequest: modeBCredDefIds must be an array of strings')\n }\n\n const requestedAttributes = { ...(proofRequest.requested_attributes ?? {}) }\n\n for (const credDefId of kanonCredDefIds) {\n if (typeof credDefId !== 'string' || credDefId.length === 0) {\n throw new Error('buildKanonProofRequest: each kanonCredDefIds entry must be a non-empty string')\n }\n const referent = `kanon_${credDefId}_credId`\n if (referent in requestedAttributes) continue\n requestedAttributes[referent] = {\n name: KANON_CRED_ID_ATTRIBUTE,\n restrictions: [{ cred_def_id: credDefId }],\n }\n }\n\n // Mode B: per-credDef self-attestable referent. `restrictions` is\n // intentionally omitted — that's how AnonCreds marks an attribute as\n // self-attestable, which is what lets the holder's wrapper fill it with\n // the Groth16 proof blob without needing a matching credential. The\n // referent name uses lower-cased credDefId so the holder + verifier\n // wrappers both reproduce the same string (see `kanonZkProofReferent`).\n if (modeBCredDefIds) {\n for (const credDefId of modeBCredDefIds) {\n if (typeof credDefId !== 'string' || credDefId.length === 0) {\n throw new Error('buildKanonProofRequest: each modeBCredDefIds entry must be a non-empty string')\n }\n const referent = `kanon_${credDefId.toLowerCase()}_zkProof`\n if (referent in requestedAttributes) continue\n requestedAttributes[referent] = { name: KANON_ZK_PROOF_ATTRIBUTE }\n }\n }\n\n return {\n ...proofRequest,\n requested_attributes: requestedAttributes,\n requested_predicates: { ...(proofRequest.requested_predicates ?? {}) },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAkDA,SAAgB,uBAAuB,OAAuD;CAC5F,MAAM,EAAE,cAAc,iBAAiB,oBAAoB;AAC3D,KAAI,CAAC,gBAAgB,OAAO,iBAAiB,SAC3C,OAAM,IAAI,MAAM,yDAAyD;AAE3E,KAAI,CAAC,MAAM,QAAQ,gBAAgB,CACjC,OAAM,IAAI,MAAM,sEAAsE;AAExF,KAAI,oBAAoB,UAAa,CAAC,MAAM,QAAQ,gBAAgB,CAClE,OAAM,IAAI,MAAM,sEAAsE;CAGxF,MAAM,sBAAsB,EAAE,GAAI,aAAa,wBAAwB,EAAE,EAAG;AAE5E,MAAK,MAAM,aAAa,iBAAiB;AACvC,MAAI,OAAO,cAAc,YAAY,UAAU,WAAW,EACxD,OAAM,IAAI,MAAM,gFAAgF;EAElG,MAAM,WAAW,SAAS,UAAU;AACpC,MAAI,YAAY,oBAAqB;AACrC,sBAAoB,YAAY;GAC9B,MAAMA;GACN,cAAc,CAAC,EAAE,aAAa,WAAW,CAAC;GAC3C;;AASH,KAAI,gBACF,MAAK,MAAM,aAAa,iBAAiB;AACvC,MAAI,OAAO,cAAc,YAAY,UAAU,WAAW,EACxD,OAAM,IAAI,MAAM,gFAAgF;EAElG,MAAM,WAAW,SAAS,UAAU,aAAa,CAAC;AAClD,MAAI,YAAY,oBAAqB;AACrC,sBAAoB,YAAY,EAAE,MAAM,0BAA0B;;AAItE,QAAO;EACL,GAAG;EACH,sBAAsB;EACtB,sBAAsB,EAAE,GAAI,aAAa,wBAAwB,EAAE,EAAG;EACvE"}
@@ -0,0 +1,23 @@
1
+ //#region src/anoncreds/helpers/buildKanonSchema.d.ts
2
+ /**
3
+ * Input shape for {@link buildKanonSchema}: the standard AnonCreds schema shape
4
+ * minus the `kanonCredId` housekeeping attribute.
5
+ */
6
+ interface BuildKanonSchemaInput {
7
+ name: string;
8
+ version: string;
9
+ attrNames: string[];
10
+ issuerId: string;
11
+ }
12
+ /**
13
+ * Returns an AnonCreds schema with the canonical `kanonCredId` attribute prepended
14
+ * to `attrNames` when missing. Idempotent: if the caller already included
15
+ * `kanonCredId` the schema is returned unchanged (modulo array copies).
16
+ *
17
+ * Throws when `attrNames` already contains a duplicate of `kanonCredId` (defensive
18
+ * — AnonCreds schemas must not have duplicate attribute names).
19
+ */
20
+ declare function buildKanonSchema(input: BuildKanonSchemaInput): BuildKanonSchemaInput;
21
+ //#endregion
22
+ export { BuildKanonSchemaInput, buildKanonSchema };
23
+ //# sourceMappingURL=buildKanonSchema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildKanonSchema.d.ts","names":[],"sources":["../../../src/anoncreds/helpers/buildKanonSchema.ts"],"mappings":";;AAMA;;;UAAiB,qBAAA;EACf,IAAA;EACA,OAAA;EACA,SAAA;EACA,QAAA;AAAA;;AAWF;;;;;;;iBAAgB,gBAAA,CAAiB,KAAA,EAAO,qBAAA,GAAwB,qBAAA"}
@@ -0,0 +1,27 @@
1
+ import { KANON_CRED_ID_ATTRIBUTE } from "../utils/credIdHash.js";
2
+
3
+ //#region src/anoncreds/helpers/buildKanonSchema.ts
4
+ /**
5
+ * Returns an AnonCreds schema with the canonical `kanonCredId` attribute prepended
6
+ * to `attrNames` when missing. Idempotent: if the caller already included
7
+ * `kanonCredId` the schema is returned unchanged (modulo array copies).
8
+ *
9
+ * Throws when `attrNames` already contains a duplicate of `kanonCredId` (defensive
10
+ * — AnonCreds schemas must not have duplicate attribute names).
11
+ */
12
+ function buildKanonSchema(input) {
13
+ if (!Array.isArray(input.attrNames)) throw new Error("buildKanonSchema: attrNames must be an array of strings");
14
+ const occurrences = input.attrNames.filter((n) => n === KANON_CRED_ID_ATTRIBUTE).length;
15
+ if (occurrences > 1) throw new Error(`buildKanonSchema: attrNames already contains duplicate '${KANON_CRED_ID_ATTRIBUTE}' entries; schemas may not declare duplicate attribute names`);
16
+ const attrNames = occurrences === 1 ? [...input.attrNames] : [KANON_CRED_ID_ATTRIBUTE, ...input.attrNames];
17
+ return {
18
+ name: input.name,
19
+ version: input.version,
20
+ issuerId: input.issuerId,
21
+ attrNames
22
+ };
23
+ }
24
+
25
+ //#endregion
26
+ export { buildKanonSchema };
27
+ //# sourceMappingURL=buildKanonSchema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildKanonSchema.js","names":[],"sources":["../../../src/anoncreds/helpers/buildKanonSchema.ts"],"sourcesContent":["import { KANON_CRED_ID_ATTRIBUTE } from '../utils/credIdHash'\n\n/**\n * Input shape for {@link buildKanonSchema}: the standard AnonCreds schema shape\n * minus the `kanonCredId` housekeeping attribute.\n */\nexport interface BuildKanonSchemaInput {\n name: string\n version: string\n attrNames: string[]\n issuerId: string\n}\n\n/**\n * Returns an AnonCreds schema with the canonical `kanonCredId` attribute prepended\n * to `attrNames` when missing. Idempotent: if the caller already included\n * `kanonCredId` the schema is returned unchanged (modulo array copies).\n *\n * Throws when `attrNames` already contains a duplicate of `kanonCredId` (defensive\n * — AnonCreds schemas must not have duplicate attribute names).\n */\nexport function buildKanonSchema(input: BuildKanonSchemaInput): BuildKanonSchemaInput {\n if (!Array.isArray(input.attrNames)) {\n throw new Error('buildKanonSchema: attrNames must be an array of strings')\n }\n\n const occurrences = input.attrNames.filter((n) => n === KANON_CRED_ID_ATTRIBUTE).length\n if (occurrences > 1) {\n throw new Error(\n `buildKanonSchema: attrNames already contains duplicate '${KANON_CRED_ID_ATTRIBUTE}' entries; schemas may not declare duplicate attribute names`\n )\n }\n\n const attrNames =\n occurrences === 1 ? [...input.attrNames] : [KANON_CRED_ID_ATTRIBUTE, ...input.attrNames]\n\n return {\n name: input.name,\n version: input.version,\n issuerId: input.issuerId,\n attrNames,\n }\n}\n"],"mappings":";;;;;;;;;;;AAqBA,SAAgB,iBAAiB,OAAqD;AACpF,KAAI,CAAC,MAAM,QAAQ,MAAM,UAAU,CACjC,OAAM,IAAI,MAAM,0DAA0D;CAG5E,MAAM,cAAc,MAAM,UAAU,QAAQ,MAAM,MAAM,wBAAwB,CAAC;AACjF,KAAI,cAAc,EAChB,OAAM,IAAI,MACR,2DAA2D,wBAAwB,8DACpF;CAGH,MAAM,YACJ,gBAAgB,IAAI,CAAC,GAAG,MAAM,UAAU,GAAG,CAAC,yBAAyB,GAAG,MAAM,UAAU;AAE1F,QAAO;EACL,MAAM,MAAM;EACZ,SAAS,MAAM;EACf,UAAU,MAAM;EAChB;EACD"}
@@ -0,0 +1,3 @@
1
+ import { buildKanonSchema } from "./buildKanonSchema.js";
2
+ import { buildKanonCredentialAttributes } from "./buildKanonCredentialAttributes.js";
3
+ import { buildKanonProofRequest } from "./buildKanonProofRequest.js";
@@ -0,0 +1,8 @@
1
+ import { KanonAnonCredsRegistry } from "./services/KanonAnonCredsRegistry.js";
2
+ import { KanonWrappedAnonCredsVerifierService, OriginalAnonCredsVerifierServiceSymbol } from "./services/KanonWrappedAnonCredsVerifierService.js";
3
+ import { KanonWrappedAnonCredsHolderService, OriginalAnonCredsHolderServiceSymbol, kanonZkProofReferent } from "./services/KanonWrappedAnonCredsHolderService.js";
4
+ import { KanonIssuanceTracker } from "./services/KanonIssuanceTracker.js";
5
+ import { KANON_CRED_ID_ATTRIBUTE, kanonCredIdHash } from "./utils/credIdHash.js";
6
+ import { BuildKanonSchemaInput, buildKanonSchema } from "./helpers/buildKanonSchema.js";
7
+ import { BuildKanonCredentialAttributesResult, KanonCredentialAttribute, buildKanonCredentialAttributes } from "./helpers/buildKanonCredentialAttributes.js";
8
+ import { BuildKanonProofRequestInput, KanonProofRequest, buildKanonProofRequest } from "./helpers/buildKanonProofRequest.js";
@@ -0,0 +1,9 @@
1
+ import { KANON_CRED_ID_ATTRIBUTE, kanonCredIdHash } from "./utils/credIdHash.js";
2
+ import { KanonAnonCredsRegistry } from "./services/KanonAnonCredsRegistry.js";
3
+ import { KanonWrappedAnonCredsHolderService, OriginalAnonCredsHolderServiceSymbol, kanonZkProofReferent } from "./services/KanonWrappedAnonCredsHolderService.js";
4
+ import { KanonWrappedAnonCredsVerifierService, OriginalAnonCredsVerifierServiceSymbol } from "./services/KanonWrappedAnonCredsVerifierService.js";
5
+ import { KanonIssuanceTracker } from "./services/KanonIssuanceTracker.js";
6
+ import { buildKanonSchema } from "./helpers/buildKanonSchema.js";
7
+ import { buildKanonCredentialAttributes } from "./helpers/buildKanonCredentialAttributes.js";
8
+ import { buildKanonProofRequest } from "./helpers/buildKanonProofRequest.js";
9
+ import "./helpers/index.js";
@@ -0,0 +1,36 @@
1
+ import { AgentContext } from "@credo-ts/core";
2
+ import { AnonCredsRegistry, GetCredentialDefinitionReturn, GetRevocationRegistryDefinitionReturn, GetRevocationStatusListReturn, GetSchemaReturn, RegisterCredentialDefinitionOptions, RegisterCredentialDefinitionReturn, RegisterRevocationRegistryDefinitionOptions, RegisterRevocationRegistryDefinitionReturn, RegisterRevocationStatusListOptions, RegisterRevocationStatusListReturn, RegisterSchemaOptions, RegisterSchemaReturn } from "@credo-ts/anoncreds";
3
+
4
+ //#region src/anoncreds/services/KanonAnonCredsRegistry.d.ts
5
+ declare class KanonAnonCredsRegistry implements AnonCredsRegistry {
6
+ supportedIdentifier: RegExp;
7
+ methodName: string;
8
+ registerSchema(agentContext: AgentContext, options: RegisterSchemaOptions): Promise<RegisterSchemaReturn>;
9
+ getSchema(agentContext: AgentContext, schemaId: string): Promise<GetSchemaReturn>;
10
+ registerCredentialDefinition(agentContext: AgentContext, options: RegisterCredentialDefinitionOptions): Promise<RegisterCredentialDefinitionReturn>;
11
+ getCredentialDefinition(agentContext: AgentContext, credentialDefinitionId: string): Promise<GetCredentialDefinitionReturn>;
12
+ private storeCredDefBody;
13
+ private loadCredDefBody;
14
+ /**
15
+ * Kanon does NOT implement the AnonCreds CKS revocation-registry model.
16
+ * Per-credential status is tracked in `AnonCredsStatusRegistry` instead,
17
+ * looked up by the verifier after `verifyProof` succeeds. These four methods
18
+ * stay rejected so callers expecting CKS revocation surface a clear error.
19
+ */
20
+ getRevocationRegistryDefinition(_agentContext: AgentContext, revocationRegistryDefinitionId: string): Promise<GetRevocationRegistryDefinitionReturn>;
21
+ registerRevocationRegistryDefinition(_agentContext: AgentContext, options: RegisterRevocationRegistryDefinitionOptions): Promise<RegisterRevocationRegistryDefinitionReturn>;
22
+ getRevocationStatusList(_agentContext: AgentContext, _revocationRegistryId: string, _timestamp: number): Promise<GetRevocationStatusListReturn>;
23
+ registerRevocationStatusList(_agentContext: AgentContext, options: RegisterRevocationStatusListOptions): Promise<RegisterRevocationStatusListReturn>;
24
+ /**
25
+ * Revokes a previously-issued credential by writing to the on-chain
26
+ * `AnonCredsStatusRegistry`. The signer must be a member of the credDef's org.
27
+ */
28
+ revokeCredentialOnChain(agentContext: AgentContext, credDefId: string, credId: string): Promise<void>;
29
+ /**
30
+ * Reads the on-chain revocation status of a credential.
31
+ */
32
+ isCredentialRevokedOnChain(agentContext: AgentContext, credDefId: string, credId: string): Promise<boolean>;
33
+ }
34
+ //#endregion
35
+ export { KanonAnonCredsRegistry };
36
+ //# sourceMappingURL=KanonAnonCredsRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KanonAnonCredsRegistry.d.ts","names":[],"sources":["../../../src/anoncreds/services/KanonAnonCredsRegistry.ts"],"mappings":";;;;cAsGa,sBAAA,YAAkC,iBAAA;EACtC,mBAAA,EAAmB,MAAA;EAEnB,UAAA;EAIM,cAAA,CACX,YAAA,EAAc,YAAA,EACd,OAAA,EAAS,qBAAA,GACR,OAAA,CAAQ,oBAAA;EAoCE,SAAA,CAAU,YAAA,EAAc,YAAA,EAAc,QAAA,WAAmB,OAAA,CAAQ,eAAA;EAgCjE,4BAAA,CACX,YAAA,EAAc,YAAA,EACd,OAAA,EAAS,mCAAA,GACR,OAAA,CAAQ,kCAAA;EAgFE,uBAAA,CACX,YAAA,EAAc,YAAA,EACd,sBAAA,WACC,OAAA,CAAQ,6BAAA;EAAA,QAsCG,gBAAA;EAAA,QAmBA,eAAA;EAnNX;;;;;;EAsOU,+BAAA,CACX,aAAA,EAAe,YAAA,EACf,8BAAA,WACC,OAAA,CAAQ,qCAAA;EAYE,oCAAA,CACX,aAAA,EAAe,YAAA,EACf,OAAA,EAAS,2CAAA,GACR,OAAA,CAAQ,0CAAA;EAaE,uBAAA,CACX,aAAA,EAAe,YAAA,EACf,qBAAA,UACA,UAAA,WACC,OAAA,CAAQ,6BAAA;EAUE,4BAAA,CACX,aAAA,EAAe,YAAA,EACf,OAAA,EAAS,mCAAA,GACR,OAAA,CAAQ,kCAAA;EA5HR;;;;EAiJU,uBAAA,CAAwB,YAAA,EAAc,YAAA,EAAc,SAAA,UAAmB,MAAA,WAAiB,OAAA;EApD1F;;;EA+DE,0BAAA,CACX,YAAA,EAAc,YAAA,EACd,SAAA,UACA,MAAA,WACC,OAAA;AAAA"}