zklicensing 0.1.0-beta.2 → 0.1.0-beta.21

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 (317) hide show
  1. package/README.md +417 -201
  2. package/build/agent.d.ts +371 -0
  3. package/build/agent.d.ts.map +1 -0
  4. package/build/agent.js +553 -0
  5. package/build/agent.js.map +1 -0
  6. package/build/agentActions.d.ts +841 -0
  7. package/build/agentActions.d.ts.map +1 -0
  8. package/build/agentActions.js +581 -0
  9. package/build/agentActions.js.map +1 -0
  10. package/build/agentRecord.d.ts +83 -0
  11. package/build/agentRecord.d.ts.map +1 -0
  12. package/build/agentRecord.js +69 -0
  13. package/build/agentRecord.js.map +1 -0
  14. package/build/agentVendor.d.ts +220 -0
  15. package/build/agentVendor.d.ts.map +1 -0
  16. package/build/agentVendor.js +306 -0
  17. package/build/agentVendor.js.map +1 -0
  18. package/build/appsLookup.d.ts +14 -0
  19. package/build/appsLookup.d.ts.map +1 -0
  20. package/build/appsLookup.js +12 -0
  21. package/build/appsLookup.js.map +1 -0
  22. package/build/archiveBootstrap.d.ts +31 -5
  23. package/build/archiveBootstrap.d.ts.map +1 -0
  24. package/build/archiveBootstrap.js +140 -47
  25. package/build/archiveBootstrap.js.map +1 -0
  26. package/build/atomicJson.d.ts +5 -0
  27. package/build/atomicJson.d.ts.map +1 -0
  28. package/build/atomicJson.js +55 -0
  29. package/build/atomicJson.js.map +1 -0
  30. package/build/bindClient.d.ts +85 -0
  31. package/build/bindClient.d.ts.map +1 -0
  32. package/build/bindClient.js +187 -0
  33. package/build/bindClient.js.map +1 -0
  34. package/build/buyClient.d.ts +27 -4
  35. package/build/buyClient.d.ts.map +1 -0
  36. package/build/buyClient.js +72 -26
  37. package/build/buyClient.js.map +1 -0
  38. package/build/chainHead.d.ts +61 -0
  39. package/build/chainHead.d.ts.map +1 -0
  40. package/build/chainHead.js +88 -0
  41. package/build/chainHead.js.map +1 -0
  42. package/build/compactMerkleMap.d.ts +72 -0
  43. package/build/compactMerkleMap.d.ts.map +1 -0
  44. package/build/compactMerkleMap.js +224 -0
  45. package/build/compactMerkleMap.js.map +1 -0
  46. package/build/contractInterface.d.ts +191 -51
  47. package/build/contractInterface.d.ts.map +1 -0
  48. package/build/contractInterface.js +234 -43
  49. package/build/contractInterface.js.map +1 -0
  50. package/build/contractTypes.d.ts +9 -0
  51. package/build/contractTypes.d.ts.map +1 -0
  52. package/build/contractTypes.js +28 -0
  53. package/build/contractTypes.js.map +1 -0
  54. package/build/countryStats.d.ts +12 -3
  55. package/build/countryStats.d.ts.map +1 -0
  56. package/build/countryStats.js +87 -23
  57. package/build/countryStats.js.map +1 -0
  58. package/build/deployClient.d.ts +138 -24
  59. package/build/deployClient.d.ts.map +1 -0
  60. package/build/deployClient.js +91 -31
  61. package/build/deployClient.js.map +1 -0
  62. package/build/deviceIdentity.d.ts +68 -0
  63. package/build/deviceIdentity.d.ts.map +1 -0
  64. package/build/deviceIdentity.js +209 -0
  65. package/build/deviceIdentity.js.map +1 -0
  66. package/build/freezeClient.d.ts +26 -6
  67. package/build/freezeClient.d.ts.map +1 -0
  68. package/build/freezeClient.js +30 -6
  69. package/build/freezeClient.js.map +1 -0
  70. package/build/generationClient.d.ts +6 -3
  71. package/build/generationClient.d.ts.map +1 -0
  72. package/build/generationClient.js +25 -38
  73. package/build/generationClient.js.map +1 -0
  74. package/build/holderSecret.d.ts +70 -0
  75. package/build/holderSecret.d.ts.map +1 -0
  76. package/build/holderSecret.js +76 -0
  77. package/build/holderSecret.js.map +1 -0
  78. package/build/index.d.ts +38 -38
  79. package/build/index.d.ts.map +1 -0
  80. package/build/index.js +97 -121
  81. package/build/index.js.map +1 -0
  82. package/build/keysClient.d.ts +142 -0
  83. package/build/keysClient.d.ts.map +1 -0
  84. package/build/keysClient.js +109 -0
  85. package/build/keysClient.js.map +1 -0
  86. package/build/licenseLeaf.d.ts +76 -0
  87. package/build/licenseLeaf.d.ts.map +1 -0
  88. package/build/licenseLeaf.js +189 -0
  89. package/build/licenseLeaf.js.map +1 -0
  90. package/build/licenseRecord.d.ts +68 -5
  91. package/build/licenseRecord.d.ts.map +1 -0
  92. package/build/licenseRecord.js +26 -1
  93. package/build/licenseRecord.js.map +1 -0
  94. package/build/licenseStore.d.ts +81 -4
  95. package/build/licenseStore.d.ts.map +1 -0
  96. package/build/licenseStore.js +400 -30
  97. package/build/licenseStore.js.map +1 -0
  98. package/build/licenseTrustless.d.ts +43 -0
  99. package/build/licenseTrustless.d.ts.map +1 -0
  100. package/build/licenseTrustless.js +180 -0
  101. package/build/licenseTrustless.js.map +1 -0
  102. package/build/manifestVerify.d.ts +29 -1
  103. package/build/manifestVerify.d.ts.map +1 -0
  104. package/build/manifestVerify.js +46 -4
  105. package/build/manifestVerify.js.map +1 -0
  106. package/build/minaPriceHistory.d.ts +9 -0
  107. package/build/minaPriceHistory.d.ts.map +1 -0
  108. package/build/minaPriceHistory.js +152 -0
  109. package/build/minaPriceHistory.js.map +1 -0
  110. package/build/onChainRoot.d.ts +60 -0
  111. package/build/onChainRoot.d.ts.map +1 -0
  112. package/build/onChainRoot.js +74 -0
  113. package/build/onChainRoot.js.map +1 -0
  114. package/build/ownershipLicenseHash.d.ts +25 -0
  115. package/build/ownershipLicenseHash.d.ts.map +1 -0
  116. package/build/ownershipLicenseHash.js +29 -0
  117. package/build/ownershipLicenseHash.js.map +1 -0
  118. package/build/ownershipSignature.d.ts +153 -0
  119. package/build/ownershipSignature.d.ts.map +1 -0
  120. package/build/ownershipSignature.js +297 -0
  121. package/build/ownershipSignature.js.map +1 -0
  122. package/build/permitCheckFlow.d.ts +155 -0
  123. package/build/permitCheckFlow.d.ts.map +1 -0
  124. package/build/permitCheckFlow.js +196 -0
  125. package/build/permitCheckFlow.js.map +1 -0
  126. package/build/permitDescribe.d.ts +124 -0
  127. package/build/permitDescribe.d.ts.map +1 -0
  128. package/build/permitDescribe.js +324 -0
  129. package/build/permitDescribe.js.map +1 -0
  130. package/build/permitInterface.d.ts +85 -0
  131. package/build/permitInterface.d.ts.map +1 -0
  132. package/build/permitInterface.js +121 -0
  133. package/build/permitInterface.js.map +1 -0
  134. package/build/permitMessages.d.ts +313 -0
  135. package/build/permitMessages.d.ts.map +1 -0
  136. package/build/permitMessages.js +462 -0
  137. package/build/permitMessages.js.map +1 -0
  138. package/build/permitProof.d.ts +108 -0
  139. package/build/permitProof.d.ts.map +1 -0
  140. package/build/permitProof.js +202 -0
  141. package/build/permitProof.js.map +1 -0
  142. package/build/permitRegistryRebuild.d.ts +166 -0
  143. package/build/permitRegistryRebuild.d.ts.map +1 -0
  144. package/build/permitRegistryRebuild.js +347 -0
  145. package/build/permitRegistryRebuild.js.map +1 -0
  146. package/build/permitTree.d.ts +88 -0
  147. package/build/permitTree.d.ts.map +1 -0
  148. package/build/permitTree.js +230 -0
  149. package/build/permitTree.js.map +1 -0
  150. package/build/permitsClient.d.ts +680 -0
  151. package/build/permitsClient.d.ts.map +1 -0
  152. package/build/permitsClient.js +597 -0
  153. package/build/permitsClient.js.map +1 -0
  154. package/build/proveErrors.d.ts +50 -0
  155. package/build/proveErrors.d.ts.map +1 -0
  156. package/build/proveErrors.js +76 -0
  157. package/build/proveErrors.js.map +1 -0
  158. package/build/receipt.d.ts +95 -0
  159. package/build/receipt.d.ts.map +1 -0
  160. package/build/receipt.js +84 -0
  161. package/build/receipt.js.map +1 -0
  162. package/build/refundClient.d.ts +7 -12
  163. package/build/refundClient.d.ts.map +1 -0
  164. package/build/refundClient.js +52 -21
  165. package/build/refundClient.js.map +1 -0
  166. package/build/registryTrustVerify.d.ts +78 -0
  167. package/build/registryTrustVerify.d.ts.map +1 -0
  168. package/build/registryTrustVerify.js +129 -0
  169. package/build/registryTrustVerify.js.map +1 -0
  170. package/build/releaseClient.d.ts +26 -0
  171. package/build/releaseClient.d.ts.map +1 -0
  172. package/build/releaseClient.js +65 -0
  173. package/build/releaseClient.js.map +1 -0
  174. package/build/renewClient.d.ts +28 -2
  175. package/build/renewClient.d.ts.map +1 -0
  176. package/build/renewClient.js +31 -27
  177. package/build/renewClient.js.map +1 -0
  178. package/build/seatName.d.ts +8 -0
  179. package/build/seatName.d.ts.map +1 -0
  180. package/build/seatName.js +136 -0
  181. package/build/seatName.js.map +1 -0
  182. package/build/slotConstants.d.ts +15 -0
  183. package/build/slotConstants.d.ts.map +1 -0
  184. package/build/slotConstants.js +17 -0
  185. package/build/slotConstants.js.map +1 -0
  186. package/build/statsClient.d.ts +61 -7
  187. package/build/statsClient.d.ts.map +1 -0
  188. package/build/statsClient.js +44 -5
  189. package/build/statsClient.js.map +1 -0
  190. package/build/successorChain.d.ts +35 -0
  191. package/build/successorChain.d.ts.map +1 -0
  192. package/build/successorChain.js +69 -0
  193. package/build/successorChain.js.map +1 -0
  194. package/build/taxId.d.ts +44 -0
  195. package/build/taxId.d.ts.map +1 -0
  196. package/build/taxId.js +212 -0
  197. package/build/taxId.js.map +1 -0
  198. package/build/trustAnchorVerify.d.ts +49 -0
  199. package/build/trustAnchorVerify.d.ts.map +1 -0
  200. package/build/trustAnchorVerify.js +432 -0
  201. package/build/trustAnchorVerify.js.map +1 -0
  202. package/build/trustAnchorVerifyCli.d.ts +45 -0
  203. package/build/trustAnchorVerifyCli.d.ts.map +1 -0
  204. package/build/trustAnchorVerifyCli.js +235 -0
  205. package/build/trustAnchorVerifyCli.js.map +1 -0
  206. package/build/txBroadcastClient.d.ts +26 -0
  207. package/build/txBroadcastClient.d.ts.map +1 -0
  208. package/build/txBroadcastClient.js +20 -0
  209. package/build/txBroadcastClient.js.map +1 -0
  210. package/build/unbindClient.d.ts +77 -0
  211. package/build/unbindClient.d.ts.map +1 -0
  212. package/build/unbindClient.js +169 -0
  213. package/build/unbindClient.js.map +1 -0
  214. package/build/units.d.ts +28 -0
  215. package/build/units.d.ts.map +1 -0
  216. package/build/units.js +65 -0
  217. package/build/units.js.map +1 -0
  218. package/build/vatRates.d.ts +54 -0
  219. package/build/vatRates.d.ts.map +1 -0
  220. package/build/vatRates.js +82 -0
  221. package/build/vatRates.js.map +1 -0
  222. package/build/vatRatesData.d.ts +5 -0
  223. package/build/vatRatesData.d.ts.map +1 -0
  224. package/build/vatRatesData.js +42 -0
  225. package/build/vatRatesData.js.map +1 -0
  226. package/build/vendorAccountClient.d.ts +66 -0
  227. package/build/vendorAccountClient.d.ts.map +1 -0
  228. package/build/vendorAccountClient.js +47 -0
  229. package/build/vendorAccountClient.js.map +1 -0
  230. package/build/verifyCore.d.ts +4 -1
  231. package/build/verifyCore.d.ts.map +1 -0
  232. package/build/verifyCore.js +21 -10
  233. package/build/verifyCore.js.map +1 -0
  234. package/build/verifyOffline.d.ts +85 -0
  235. package/build/verifyOffline.d.ts.map +1 -0
  236. package/build/verifyOffline.js +139 -0
  237. package/build/verifyOffline.js.map +1 -0
  238. package/build/verifyService.d.ts.map +1 -0
  239. package/build/verifyService.js +571 -501
  240. package/build/verifyService.js.map +1 -0
  241. package/build/verifyWithAncestors.d.ts +19 -0
  242. package/build/verifyWithAncestors.d.ts.map +1 -0
  243. package/build/verifyWithAncestors.js +127 -0
  244. package/build/verifyWithAncestors.js.map +1 -0
  245. package/build/zipToState.d.ts +2 -0
  246. package/build/zipToState.d.ts.map +1 -0
  247. package/build/zipToState.js +94 -0
  248. package/build/zipToState.js.map +1 -0
  249. package/package.json +141 -16
  250. package/src/agent.ts +682 -0
  251. package/src/agentActions.ts +637 -0
  252. package/src/agentRecord.ts +121 -0
  253. package/src/agentVendor.ts +356 -0
  254. package/src/appsLookup.ts +48 -0
  255. package/src/archiveBootstrap.ts +386 -0
  256. package/src/atomicJson.ts +53 -0
  257. package/src/bindClient.ts +297 -0
  258. package/src/buyClient.ts +344 -0
  259. package/src/chainHead.ts +106 -0
  260. package/src/compactMerkleMap.ts +222 -0
  261. package/src/contractInterface.ts +465 -0
  262. package/src/contractTypes.ts +31 -0
  263. package/src/countryStats.ts +200 -0
  264. package/src/deployClient.ts +517 -0
  265. package/src/deviceIdentity.ts +249 -0
  266. package/src/freezeClient.ts +162 -0
  267. package/src/generationClient.ts +145 -0
  268. package/src/holderSecret.ts +91 -0
  269. package/src/index.ts +362 -0
  270. package/src/keysClient.ts +135 -0
  271. package/src/licenseLeaf.ts +221 -0
  272. package/src/licenseRecord.ts +190 -0
  273. package/src/licenseStore.ts +767 -0
  274. package/src/licenseTrustless.ts +207 -0
  275. package/src/manifestVerify.ts +164 -0
  276. package/src/minaPriceHistory.ts +166 -0
  277. package/src/onChainRoot.ts +90 -0
  278. package/src/ownershipLicenseHash.ts +31 -0
  279. package/src/ownershipSignature.ts +421 -0
  280. package/src/permitCheckFlow.ts +227 -0
  281. package/src/permitDescribe.ts +362 -0
  282. package/src/permitInterface.ts +146 -0
  283. package/src/permitMessages.ts +572 -0
  284. package/src/permitProof.ts +230 -0
  285. package/src/permitRegistryRebuild.ts +423 -0
  286. package/src/permitTree.ts +232 -0
  287. package/src/permitsClient.ts +746 -0
  288. package/src/proveErrors.ts +98 -0
  289. package/src/receipt.ts +156 -0
  290. package/src/refundClient.ts +177 -0
  291. package/src/registryTrustVerify.ts +192 -0
  292. package/src/releaseClient.ts +101 -0
  293. package/src/renewClient.ts +234 -0
  294. package/src/seatName.ts +165 -0
  295. package/src/slotConstants.ts +18 -0
  296. package/src/statsClient.ts +249 -0
  297. package/src/successorChain.ts +87 -0
  298. package/src/taxId.ts +227 -0
  299. package/src/trustAnchorVerify.ts +550 -0
  300. package/src/trustAnchorVerifyCli.ts +234 -0
  301. package/src/txBroadcastClient.ts +48 -0
  302. package/src/unbindClient.ts +233 -0
  303. package/src/units.ts +74 -0
  304. package/src/vatRates.ts +100 -0
  305. package/src/vatRatesData.ts +43 -0
  306. package/src/vendorAccountClient.ts +120 -0
  307. package/src/verifyCore.ts +100 -0
  308. package/src/verifyOffline.ts +212 -0
  309. package/src/verifyService.ts +982 -0
  310. package/src/verifyWithAncestors.ts +163 -0
  311. package/src/zipToState.ts +94 -0
  312. package/build/licenseProof.d.ts +0 -26
  313. package/build/licenseProof.js +0 -41
  314. package/build/migrateClient.d.ts +0 -43
  315. package/build/migrateClient.js +0 -47
  316. package/build/ownership.d.ts +0 -34
  317. package/build/ownership.js +0 -147
@@ -0,0 +1,306 @@
1
+ // Copyright (c) 2025-2026 zkLicensing project developers
2
+ // SPDX-License-Identifier: BUSL-1.1
3
+ /**
4
+ * agentVendor.ts — part of `zklicensing/agent/actions`
5
+ *
6
+ * A vendor run by an AI agent: the agent's key is the vendor wallet (it
7
+ * receives the payments and signs for the app), acting for its owner.
8
+ *
9
+ * acceptVendorTerms the Vendor Terms and legal details, under a standing
10
+ * consent covering vendor-terms (recorded as given by
11
+ * the agent)
12
+ * registerApp deploys the app's contract (paying the registration
13
+ * fee; the consent covers its withdrawal waiver) and
14
+ * lists it
15
+ * setPrices changes the tier prices on chain
16
+ * updateListing edits the listing (re-reviewed on mainnet)
17
+ * updateDetails changes the legal details on every app
18
+ * status, feeStatement, trustManifest
19
+ *
20
+ * Every step checks the owner's policy (allowed actions, networks, targets,
21
+ * per-action and daily caps); paying steps return a signed action record.
22
+ * What an agent cannot do: host files on the vendor's own website (the
23
+ * trust manifest, and on mainnet the vendor's buy, renew and refund pages).
24
+ */
25
+ import { AgentError } from './agent.js';
26
+ import { checkActionPolicy, consentFor, } from './agentActions.js';
27
+ import { signActionRecord, policyHash } from './agentRecord.js';
28
+ /** Registration fee per network (MINA), as the keeper charges it; plus 1 MINA account creation and the transaction fee. */
29
+ export const REGISTRATION_FEE_MINA = { devnet: 10, mainnet: 1200 };
30
+ const VENDOR_TC_ORIGIN = 'https://zklicensing.com';
31
+ /** The vendor acceptance text the wallet signs (the keeper derives the same). */
32
+ export function vendorAcceptanceMessage(f) {
33
+ return [
34
+ 'I accept the zkLicensing Vendor Terms of Service.',
35
+ '',
36
+ `Document: ${f.terms.title}`,
37
+ `Version: ${f.terms.version}`,
38
+ `Published: ${VENDOR_TC_ORIGIN}${f.terms.archiveUrl}`,
39
+ `Fingerprint: ${f.terms.documentHash}`,
40
+ '',
41
+ `Legal entity: ${f.legalName}`,
42
+ `Country: ${f.country}`,
43
+ f.vatId.length > 0 ? `VAT: ${f.vatId}` : 'VAT: (not registered)',
44
+ `Billing address: ${f.billingHash}`,
45
+ '',
46
+ `Signed by wallet: ${f.vendorAddress}`,
47
+ `Accepted at (UTC): ${f.acceptedAt}`,
48
+ ].join('\n');
49
+ }
50
+ /** "sha256:<hex>" of the billing address in the keeper's fixed key order. */
51
+ export async function billingHash(a) {
52
+ const canonical = JSON.stringify({ line1: a.line1, line2: a.line2 ?? '', city: a.city, postalCode: a.postalCode });
53
+ const d = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(canonical));
54
+ return 'sha256:' + [...new Uint8Array(d)].map(b => b.toString(16).padStart(2, '0')).join('');
55
+ }
56
+ export function createVendorAgent(opts) {
57
+ const base = opts.keeperUrl.replace(/\/+$/, '');
58
+ const f = opts.fetcher ?? fetch;
59
+ const net = opts.network;
60
+ const w = opts.wallet;
61
+ const site = opts.siteUrl ?? (net === 'mainnet' ? 'https://zklicensing.com' : 'https://dev.zklicensing.com');
62
+ let permits = null;
63
+ // The wallet sign-in (VendorSession) the vendor endpoints need: the same one the permits client makes.
64
+ const session = async () => (await (permits ??= import('./permitsClient.js').then(m => m.createPermitsClient({ keeperUrl: opts.keeperUrl, network: net, wallet: w, fetcher: opts.fetcher })))).signIn();
65
+ async function call(method, path, body, auth = false) {
66
+ const headers = { Accept: 'application/json' };
67
+ if (body !== undefined)
68
+ headers['Content-Type'] = 'application/json';
69
+ if (auth)
70
+ headers.Authorization = `VendorSession ${await session()}`;
71
+ const r = await f(base + path, { method, headers, body: body === undefined ? undefined : JSON.stringify(body) });
72
+ const text = await r.text();
73
+ let j = null;
74
+ try {
75
+ j = text ? JSON.parse(text) : null;
76
+ }
77
+ catch {
78
+ j = text;
79
+ }
80
+ if (!r.ok)
81
+ throw new AgentError(j?.error ?? `HTTP ${r.status}`, j?.code ?? (r.status === 404 ? 'NOT_FOUND' : 'HTTP_ERROR'), r.status, r.status >= 500);
82
+ return j;
83
+ }
84
+ /** The owner's standing consent covering vendor-terms (fails closed, as for buyers). */
85
+ const vendorConsent = () => consentFor({
86
+ requiresConsent: ['vendor-terms'], agentMayConsent: true, approvalUrl: `${site}/register.html`, network: net,
87
+ }, w.address, opts.consent, { keeperUrl: opts.keeperUrl, fetcher: opts.fetcher });
88
+ const toMinaNano = (m) => BigInt(Math.round(m * 1e9));
89
+ async function record(action, a) {
90
+ try {
91
+ const actionRecord = await signActionRecord(w, {
92
+ network: net, action, target: a.target, reference: a.reference, summary: a.summary,
93
+ amounts: { total: a.totalNano.toString(), toRecipient: a.totalNano.toString(), toPlatform: a.totalNano.toString(), recipient: 'zkLicensing platform' },
94
+ txHash: a.txHash, receipt: null, policySha256: await policyHash(opts.policy),
95
+ consent: a.consent.givenBy === 'agent' ? { givenBy: 'agent', statementSha256: a.consent.statementSha256, kinds: [...a.consent.kinds] } : { givenBy: 'none' },
96
+ at: new Date().toISOString(),
97
+ });
98
+ return { actionRecord, warnings: [] };
99
+ }
100
+ catch (e) {
101
+ return { warnings: [`The action record could not be signed (${e?.message ?? e}).`] };
102
+ }
103
+ }
104
+ /** Refuses an App ID this wallet can't register on this network (taken, or its prefix reserved by another vendor). */
105
+ async function appIdFree(appId) {
106
+ const r = await (opts.fetcher ?? fetch)(`${opts.keeperUrl.replace(/\/+$/, '')}/apps/${encodeURIComponent(appId)}?network=${net}&vendor=${encodeURIComponent(w.address)}`);
107
+ const b = await r.json().catch(() => null);
108
+ if (r.status === 409)
109
+ throw new AgentError(b?.error ?? `App ID prefix of "${appId}" is reserved by another vendor`, 'APP_ID_PREFIX_RESERVED', 409, false);
110
+ if (r.ok)
111
+ throw new AgentError(`App ID "${appId}" is already registered on ${net}`, 'APP_ID_TAKEN', 409, false);
112
+ if (r.status === 404 && b?.ownedBy && b.ownedBy !== w.address)
113
+ throw new AgentError(`App ID "${appId}" belongs to another vendor`, 'APP_ID_TAKEN', 409, false);
114
+ if (r.status !== 404)
115
+ throw new AgentError(b?.error ?? `Could not check App ID "${appId}" (${r.status})`, 'UPSTREAM_UNAVAILABLE', r.status, true);
116
+ }
117
+ return {
118
+ address: w.address,
119
+ /** The Vendor Terms and legal details, signed by the agent key for its owner. */
120
+ async acceptVendorTerms(legal, terms) {
121
+ checkActionPolicy(opts.policy, { action: 'accept-vendor-terms', network: net });
122
+ await vendorConsent();
123
+ const acceptedAt = new Date().toISOString();
124
+ const signedMessage = vendorAcceptanceMessage({
125
+ vendorAddress: w.address, terms, legalName: legal.legalName, country: legal.country, vatId: legal.vatId,
126
+ billingHash: await billingHash(legal.billingAddress), acceptedAt,
127
+ });
128
+ const signature = await w.signMessage(signedMessage);
129
+ return call('POST', '/vendors/accept', {
130
+ vendorAddress: w.address, network: net, tcVersion: terms.version, tcDocumentHash: terms.documentHash, acceptedAt,
131
+ signature, signedMessage, legal, agentConsent: opts.consent,
132
+ });
133
+ },
134
+ /** Review status on this network, the terms accepted and the tax ID check. */
135
+ status: () => call('GET', `/vendors/${w.address}/tos?network=${net}`, undefined, true),
136
+ /** Changes the legal details on every app the vendor owns. */
137
+ async updateDetails(legal) {
138
+ checkActionPolicy(opts.policy, { action: 'update-vendor-details', network: net });
139
+ return call('PATCH', `/vendors/${w.address}/legal`, { payload: legal }, true);
140
+ },
141
+ /**
142
+ * Deploys the app's contract (the agent wallet pays the registration fee:
143
+ * the owner's policy caps it, the standing consent covers its withdrawal
144
+ * waiver) and lists it. The legal details are the ones signed in
145
+ * acceptVendorTerms (changed with updateDetails), never given per app.
146
+ */
147
+ async registerApp(listing) {
148
+ const feeNano = toMinaNano(REGISTRATION_FEE_MINA[net] + 1);
149
+ checkActionPolicy(opts.policy, { action: 'register-app', network: net, amountNano: feeNano }, opts.ledger);
150
+ const consent = await vendorConsent();
151
+ const p = listing.prices;
152
+ if (![p.monthly, p.yearly, p.fiveYear, p.perpetual].some(x => x > 0))
153
+ throw new AgentError('At least one tier needs a price above 0', 'INVALID_REQUEST', 0, false);
154
+ if (!/^https:\/\//.test(listing.website))
155
+ throw new AgentError('website must be an https:// URL (it is written into the contract)', 'INVALID_REQUEST', 0, false);
156
+ await appIdFree(listing.appId); // before anything is signed or paid: the listing can't then be refused for it
157
+ const appSig = await w.signMessage(listing.appId);
158
+ await session(); // sign in before paying: the listing step needs it
159
+ const { proveDeploy } = await import('./deployClient.js');
160
+ const proved = await proveDeploy({
161
+ keeperUrl: opts.keeperUrl, senderPublicKey: w.address, vendorAddress: w.address,
162
+ priceMonthlyMina: p.monthly, priceYearlyMina: p.yearly, priceFiveYearMina: p.fiveYear, pricePerpetualMina: p.perpetual,
163
+ deviceCap: listing.deviceCap ?? 0, website: listing.website, network: net, fetcher: opts.fetcher,
164
+ });
165
+ const waiverAt = new Date().toISOString();
166
+ const txHash = await w.signAndSendTransaction(proved.provenTxJson);
167
+ opts.ledger?.record(feeNano);
168
+ const warnings = [];
169
+ await call('POST', '/apps', {
170
+ appId: listing.appId, name: listing.name, description: listing.description, longDescription: listing.longDescription ?? '',
171
+ category: listing.category, website: listing.website, zkAppAddress: proved.zkAppAddress, vendorAddress: w.address,
172
+ priceMonthlyMina: p.monthly, priceYearlyMina: p.yearly, priceFiveYearMina: p.fiveYear, pricePerpetualMina: p.perpetual,
173
+ deviceCap: listing.deviceCap ?? 0, txHash, verificationKeyHash: proved.verificationKeyHash,
174
+ tags: listing.tags ?? [], contactEmail: listing.contactEmail ?? '', supportEmail: listing.supportEmail,
175
+ showInMarketplace: listing.showInMarketplace !== false,
176
+ ...(listing.buyUrl ? { buyUrl: listing.buyUrl } : {}), ...(listing.renewUrl ? { renewUrl: listing.renewUrl } : {}),
177
+ ...(listing.refundUrl ? { refundUrl: listing.refundUrl } : {}),
178
+ ...(listing.termsOfServiceUrl ? { termsOfServiceUrl: listing.termsOfServiceUrl } : {}),
179
+ ...(listing.privacyPolicyUrl ? { privacyPolicyUrl: listing.privacyPolicyUrl } : {}),
180
+ ...(listing.refundPolicyUrl ? { refundPolicyUrl: listing.refundPolicyUrl } : {}),
181
+ deployFeeWaiverAcceptedAt: waiverAt, network: net, signature: appSig,
182
+ // The waiver is the agent's, under the owner's consent: the keeper records it as such.
183
+ ...(consent.givenBy === 'agent' ? { agentConsent: opts.consent } : {}),
184
+ }, true).catch(e => {
185
+ // The contract is deployed and paid for: never throw past this point; say how to finish.
186
+ warnings.push(`The contract is deployed (${proved.zkAppAddress}) but the listing was not recorded (${e.message}). Finish it from the dashboard with this address.`);
187
+ });
188
+ const rec = await record('register-app', { target: proved.zkAppAddress, reference: listing.appId, summary: `Register ${listing.name} (${listing.appId}) on ${net}`, totalNano: feeNano, txHash, consent });
189
+ return {
190
+ appId: listing.appId, zkAppAddress: proved.zkAppAddress, verificationKeyHash: proved.verificationKeyHash, txHash,
191
+ warnings: [...warnings, ...rec.warnings], ...(rec.actionRecord ? { actionRecord: rec.actionRecord } : {}),
192
+ next: [
193
+ `Host the trust manifest: trustManifest('${listing.appId}') gives the file for ${listing.website.replace(/\/+$/, '')}/.well-known/zklicensing/${proved.zkAppAddress}.json`,
194
+ net === 'mainnet' ? 'Mainnet listings are reviewed before they appear; buy, renew and refund pages on your own site are required.' : 'Devnet listings appear once the deployment is seen on chain.',
195
+ ],
196
+ };
197
+ },
198
+ /** Changes the tier prices on chain (and the listing's copy). */
199
+ async setPrices(appId, prices) {
200
+ const r = await call('GET', `/apps/${encodeURIComponent(appId)}?network=${net}`);
201
+ const zkAppAddress = r.app?.deployments?.[net]?.zkAppAddress;
202
+ if (r.app?.vendorAddress && r.app.vendorAddress !== w.address)
203
+ throw new AgentError(`${appId} belongs to another vendor wallet`, 'FORBIDDEN', 403, false);
204
+ if (!zkAppAddress)
205
+ throw new AgentError(`${appId} has no ${net} deployment`, 'NOT_FOUND', 404, false);
206
+ checkActionPolicy(opts.policy, { action: 'set-prices', network: net, target: zkAppAddress, amountNano: 0n });
207
+ const proved = await call('POST', '/prove/setPrice', {
208
+ vendorAddress: w.address, zkAppAddress, network: net,
209
+ priceMonthlyMina: prices.monthly, priceYearlyMina: prices.yearly, priceFiveYearMina: prices.fiveYear, pricePerpetualMina: prices.perpetual,
210
+ });
211
+ const txHash = await w.signAndSendTransaction(proved.provenTxJson);
212
+ const warnings = [];
213
+ // The listing's cached prices (the chain is the source of truth; the keeper reconciles).
214
+ await call('PUT', `/apps/${encodeURIComponent(appId)}`, {
215
+ vendorAddress: w.address, signature: await w.signMessage(appId),
216
+ payload: { priceMonthlyMina: prices.monthly, priceYearlyMina: prices.yearly, priceFiveYearMina: prices.fiveYear, pricePerpetualMina: prices.perpetual },
217
+ }, true).catch(e => warnings.push(`Prices are set on chain; the listing will catch up (${e.message}).`));
218
+ const rec = await record('set-prices', { target: zkAppAddress, reference: appId, summary: `Set prices of ${appId} on ${net}`, totalNano: 0n, txHash, consent: { givenBy: 'none' } });
219
+ return { appId, zkAppAddress, txHash, warnings: [...warnings, ...rec.warnings], ...(rec.actionRecord ? { actionRecord: rec.actionRecord } : {}) };
220
+ },
221
+ /**
222
+ * Takes the app's next redeploy step: it moves to a new contract account
223
+ * with every license carried over. The first call pauses its sales and
224
+ * answers `draining` (call again after readyAt); the agent key then signs
225
+ * the retirement, and the agent wallet sends and pays for each step:
226
+ * before a hard fork the retirement alone (`retired`, the new account
227
+ * follows after the fork); otherwise the new account's deployment (1 MINA
228
+ * account creation + fee).
229
+ */
230
+ async redeployApp(appId) {
231
+ const r = await call('GET', `/apps/${encodeURIComponent(appId)}?network=${net}`);
232
+ const zkAppAddress = r.app?.deployments?.[net]?.zkAppAddress;
233
+ if (r.app?.vendorAddress && r.app.vendorAddress !== w.address)
234
+ throw new AgentError(`${appId} belongs to another vendor wallet`, 'FORBIDDEN', 403, false);
235
+ if (!zkAppAddress)
236
+ throw new AgentError(`${appId} has no ${net} deployment`, 'NOT_FOUND', 404, false);
237
+ checkActionPolicy(opts.policy, { action: 'redeploy-app', network: net, target: zkAppAddress, amountNano: toMinaNano(1.1) }, opts.ledger);
238
+ const d = await import('./deployClient.js');
239
+ let retireSignature;
240
+ for (let round = 0; round < 3; round++) {
241
+ const { nonce } = await d.getVendorRedeployChallenge({ keeperUrl: opts.keeperUrl, appId, network: net, fetcher: opts.fetcher });
242
+ const signature = await w.signMessage(nonce);
243
+ const res = await d.proveVendorRedeploy({ keeperUrl: opts.keeperUrl, appId, nonce, signature, senderPublicKey: w.address, retireSignature, fetcher: opts.fetcher });
244
+ if ('status' in res && res.status === 'draining')
245
+ return { appId, status: 'draining', readyAt: res.readyAt, expiresAt: res.expiresAt, next: 'Sales are paused while in-flight proofs land: call redeploy_app again after readyAt.' };
246
+ if ('status' in res && res.status === 'sign-retire') {
247
+ retireSignature = await w.signFields(res.retireMessage);
248
+ continue;
249
+ }
250
+ if (!('provenTxJson' in res))
251
+ break;
252
+ const txHash = await w.signAndSendTransaction(res.provenTxJson);
253
+ await d.registerVendorRedeploy({ keeperUrl: opts.keeperUrl, appId, redeployId: res.redeployId, txHash, fetcher: opts.fetcher });
254
+ if (res.step === 'retire') {
255
+ opts.ledger?.record(toMinaNano(0.1));
256
+ return { appId, status: 'retired', txHash, next: 'Retired ahead of the hard fork: call redeploy_app again after the fork to deploy the new account.' };
257
+ }
258
+ opts.ledger?.record(toMinaNano(1.1));
259
+ return { appId, status: 'deployed', zkAppAddress: res.zkAppAddress, txHash, next: 'The listing moves to the new address once it is seen on chain; host the trust manifest for it (trustManifest).' };
260
+ }
261
+ throw new AgentError('The keeper did not accept the retire signature', 'HTTP_ERROR', 0, false);
262
+ },
263
+ /** Calls off this vendor's redeploy before the app is retired on chain (sales resume). */
264
+ async cancelRedeploy(appId) {
265
+ const d = await import('./deployClient.js');
266
+ const { nonce } = await d.getVendorRedeployChallenge({ keeperUrl: opts.keeperUrl, appId, network: net, fetcher: opts.fetcher });
267
+ return d.cancelVendorRedeploy({ keeperUrl: opts.keeperUrl, appId, nonce, signature: await w.signMessage(nonce), fetcher: opts.fetcher });
268
+ },
269
+ /** Edits the listing (name, descriptions, category, tags, emails, page links); mainnet edits are re-reviewed. */
270
+ async updateListing(appId, payload, visibility) {
271
+ checkActionPolicy(opts.policy, { action: 'update-listing', network: net });
272
+ return call('PUT', `/apps/${encodeURIComponent(appId)}`, {
273
+ vendorAddress: w.address, signature: await w.signMessage(appId), payload,
274
+ ...(visibility ? { network: net, status: visibility } : {}),
275
+ }, true);
276
+ },
277
+ /**
278
+ * What forced retirements left in escrow on this vendor's retired
279
+ * contracts (Vendor Terms §8.7): per contract, the purchases whose funds
280
+ * stay there, their buyers and the total.
281
+ */
282
+ stranded: () => call('GET', `/vendors/${w.address}/stranded?network=${net}`, undefined, true),
283
+ /** The platform's monthly fee statement for this vendor (month YYYY-MM). */
284
+ feeStatement: (month) => call('GET', `/vendors/${w.address}/fee-statements?network=${net}&month=${encodeURIComponent(month)}`, undefined, true).then(r => r.statement),
285
+ /**
286
+ * The platform-signed trust manifest the vendor hosts on its website, at
287
+ * /.well-known/zklicensing/<address>.json for every generation address.
288
+ * An agent can't upload it: give the files to the owner.
289
+ */
290
+ async trustManifest(appId) {
291
+ const r = await f(`${base}/apps/${encodeURIComponent(appId)}?network=${net}`, { headers: { Accept: 'application/json' } });
292
+ if (!r.ok)
293
+ throw new AgentError(`No manifest for ${appId} on ${net} (HTTP ${r.status})`, r.status === 404 ? 'NOT_FOUND' : 'HTTP_ERROR', r.status, false);
294
+ // The same bytes the dashboard's "Download manifest" saves: the signed generation list (and the public listing).
295
+ const content = await r.text();
296
+ const j = JSON.parse(content);
297
+ const gens = j.generations ?? [];
298
+ const website = j.app?.website ?? null;
299
+ return {
300
+ content,
301
+ files: gens.map(g => ({ path: `/.well-known/zklicensing/${g.zkAppAddress}.json`, url: website ? `${website.replace(/\/+$/, '')}/.well-known/zklicensing/${g.zkAppAddress}.json` : null })),
302
+ };
303
+ },
304
+ };
305
+ }
306
+ //# sourceMappingURL=agentVendor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentVendor.js","sourceRoot":"","sources":["../src/agentVendor.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,o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MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YACzJ,iHAAiH;YACjH,MAAM,OAAO,GAAG,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;YAC/B,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAkF,CAAC;YAC/G,MAAM,IAAI,GAAG,CAAC,CAAC,WAAW,IAAI,EAAE,CAAC;YACjC,MAAM,OAAO,GAAG,CAAC,CAAC,GAAG,EAAE,OAAO,IAAI,IAAI,CAAC;YACvC,OAAO;gBACL,OAAO;gBACP,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,4BAA4B,CAAC,CAAC,YAAY,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,4BAA4B,CAAC,CAAC,YAAY,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;aAC3L,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ export type LookupableDeployment = {
2
+ zkAppAddress: string;
3
+ deploymentHistory?: Array<{
4
+ zkAppAddress: string;
5
+ }>;
6
+ };
7
+ export type LookupableApp = {
8
+ deployments: {
9
+ devnet?: LookupableDeployment;
10
+ mainnet?: LookupableDeployment;
11
+ };
12
+ };
13
+ export declare function findAppByAnyAddress<T extends LookupableApp>(apps: readonly T[], zkAppAddress: string): T | undefined;
14
+ //# sourceMappingURL=appsLookup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appsLookup.d.ts","sourceRoot":"","sources":["../src/appsLookup.ts"],"names":[],"mappings":"AAkBA,MAAM,MAAM,oBAAoB,GAAG;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,KAAK,CAAC;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrD,CAAC;AAKF,MAAM,MAAM,aAAa,GAAG;IAC1B,WAAW,EAAE;QACX,MAAM,CAAC,EAAG,oBAAoB,CAAC;QAC/B,OAAO,CAAC,EAAE,oBAAoB,CAAC;KAChC,CAAC;CACH,CAAC;AAMF,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,aAAa,EACzD,IAAI,EAAE,SAAS,CAAC,EAAE,EAClB,YAAY,EAAE,MAAM,GACnB,CAAC,GAAG,SAAS,CAOf"}
@@ -0,0 +1,12 @@
1
+ // Copyright (c) 2025-2026 zkLicensing project developers
2
+ // SPDX-License-Identifier: BUSL-1.1
3
+ // Return the first app whose devnet OR mainnet deployment matches (current
4
+ // live address or any retired generation in deploymentHistory). Under the
5
+ // backend-routing design a buyer who pinned an original devnet address stays
6
+ // resolvable across N mainnet promotions and any number of retired gens.
7
+ export function findAppByAnyAddress(apps, zkAppAddress) {
8
+ const matches = (d) => !!d && (d.zkAppAddress === zkAppAddress ||
9
+ (d.deploymentHistory ?? []).some(h => h.zkAppAddress === zkAppAddress));
10
+ return apps.find(a => matches(a.deployments.devnet) || matches(a.deployments.mainnet));
11
+ }
12
+ //# sourceMappingURL=appsLookup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appsLookup.js","sourceRoot":"","sources":["../src/appsLookup.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,oCAAoC;AAgCpC,2EAA2E;AAC3E,0EAA0E;AAC1E,6EAA6E;AAC7E,yEAAyE;AACzE,MAAM,UAAU,mBAAmB,CACjC,IAAkB,EAClB,YAAoB;IAEpB,MAAM,OAAO,GAAG,CAAC,CAAwB,EAAW,EAAE,CACpD,CAAC,CAAC,CAAC,IAAI,CACL,CAAC,CAAC,YAAY,KAAK,YAAY;QAC/B,CAAC,CAAC,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,YAAY,CAAC,CACvE,CAAC;IACJ,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;AACzF,CAAC"}
@@ -1,6 +1,6 @@
1
1
  export declare const SYNC_CHUNK_SLOTS = 10000;
2
2
  export declare const MAX_LOOKBACK_SLOTS = 525600;
3
- export type Tier = 'monthly' | 'yearly' | 'fiveYear';
3
+ export type Tier = 'monthly' | 'yearly' | 'fiveYear' | 'perpetual';
4
4
  export type NormalizedEvent = {
5
5
  kind: 'licenseIssued';
6
6
  slot: number;
@@ -8,6 +8,8 @@ export type NormalizedEvent = {
8
8
  amount: bigint;
9
9
  issuedSlot: number;
10
10
  expirySlot: number;
11
+ buyerAddress: string;
12
+ cap: number;
11
13
  } | {
12
14
  kind: 'licenseIssuedNoEscrow';
13
15
  slot: number;
@@ -15,17 +17,21 @@ export type NormalizedEvent = {
15
17
  amount: bigint;
16
18
  issuedSlot: number;
17
19
  expirySlot: number;
20
+ buyerAddress: string;
21
+ cap: number;
18
22
  } | {
19
23
  kind: 'licenseRenewed';
20
24
  slot: number;
21
25
  licenseHash: string;
22
26
  newExpiry: number;
23
27
  } | {
24
- kind: 'licenseMigrated';
28
+ kind: 'appCreated';
25
29
  slot: number;
26
- licenseHash: string;
27
- expirySlot: number;
28
- ancestorGen: number;
30
+ predecessor: string | null;
31
+ } | {
32
+ kind: 'appRetired';
33
+ slot: number;
34
+ licensesRoot: string;
29
35
  } | {
30
36
  kind: 'refundIssued';
31
37
  slot: number;
@@ -34,12 +40,32 @@ export type NormalizedEvent = {
34
40
  kind: 'fundsReleased';
35
41
  slot: number;
36
42
  licenseHash: string;
43
+ } | {
44
+ kind: 'deviceBound';
45
+ slot: number;
46
+ licenseHash: string;
47
+ slotIndex: number;
48
+ deviceCommitment: string;
49
+ boundAtSlot: number;
50
+ } | {
51
+ kind: 'deviceUnbound';
52
+ slot: number;
53
+ licenseHash: string;
54
+ slotIndex: number;
55
+ freedAtSlot: number;
37
56
  } | {
38
57
  kind: 'priceUpdated';
39
58
  slot: number;
40
59
  priceMonthly: bigint;
41
60
  priceYearly: bigint;
42
61
  priceFiveYear: bigint;
62
+ pricePerpetual: bigint;
63
+ } | {
64
+ kind: 'licenseTransferred';
65
+ slot: number;
66
+ from: string;
67
+ to: string;
68
+ wallet: string;
43
69
  };
44
70
  export declare function tierFromExpiryDelta(slots: number): Tier | null;
45
71
  export type FetchRange = {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archiveBootstrap.d.ts","sourceRoot":"","sources":["../src/archiveBootstrap.ts"],"names":[],"mappings":"AAuDA,eAAO,MAAM,gBAAgB,QAAS,CAAC;AACvC,eAAO,MAAM,kBAAkB,SAAU,CAAC;AAE1C,MAAM,MAAM,IAAI,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,GAAG,WAAW,CAAC;AAEnE,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,eAAe,CAAC;IAAU,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAChK;IAAE,IAAI,EAAE,uBAAuB,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAChK;IAAE,IAAI,EAAE,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