@nucypher/taco 0.7.0-alpha.2 → 0.7.0-dev.viem

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 (297) hide show
  1. package/README.md +149 -0
  2. package/dist/cjs/access-client/client.d.ts +237 -0
  3. package/dist/cjs/access-client/client.js +196 -0
  4. package/dist/cjs/access-client/client.js.map +1 -0
  5. package/dist/cjs/access-client/config-validator.d.ts +92 -0
  6. package/dist/cjs/access-client/config-validator.js +204 -0
  7. package/dist/cjs/access-client/config-validator.js.map +1 -0
  8. package/dist/cjs/access-client/config.d.ts +50 -0
  9. package/dist/cjs/access-client/config.js +27 -0
  10. package/dist/cjs/access-client/config.js.map +1 -0
  11. package/dist/cjs/access-client/index.d.ts +2 -0
  12. package/dist/cjs/access-client/index.js +19 -0
  13. package/dist/cjs/access-client/index.js.map +1 -0
  14. package/dist/cjs/conditions/base/contract.d.ts +4 -4
  15. package/dist/cjs/conditions/base/contract.js +8 -8
  16. package/dist/cjs/conditions/base/contract.js.map +1 -1
  17. package/dist/cjs/conditions/base/index.d.ts +6 -9
  18. package/dist/cjs/conditions/base/index.js +7 -10
  19. package/dist/cjs/conditions/base/index.js.map +1 -1
  20. package/dist/cjs/conditions/base/json-api.d.ts +4 -4
  21. package/dist/cjs/conditions/base/json-api.js +8 -8
  22. package/dist/cjs/conditions/base/json-api.js.map +1 -1
  23. package/dist/cjs/conditions/base/json-rpc.d.ts +4 -4
  24. package/dist/cjs/conditions/base/json-rpc.js +8 -8
  25. package/dist/cjs/conditions/base/json-rpc.js.map +1 -1
  26. package/dist/cjs/conditions/base/jwt.d.ts +4 -4
  27. package/dist/cjs/conditions/base/jwt.js +9 -9
  28. package/dist/cjs/conditions/base/jwt.js.map +1 -1
  29. package/dist/cjs/conditions/base/rpc.d.ts +4 -4
  30. package/dist/cjs/conditions/base/rpc.js +8 -8
  31. package/dist/cjs/conditions/base/rpc.js.map +1 -1
  32. package/dist/cjs/conditions/base/time.d.ts +4 -4
  33. package/dist/cjs/conditions/base/time.js +9 -9
  34. package/dist/cjs/conditions/base/time.js.map +1 -1
  35. package/dist/cjs/conditions/compound-condition.d.ts +4 -4
  36. package/dist/cjs/conditions/compound-condition.js +9 -9
  37. package/dist/cjs/conditions/compound-condition.js.map +1 -1
  38. package/dist/cjs/conditions/condition-expr.d.ts +1 -1
  39. package/dist/cjs/conditions/condition-expr.js +7 -7
  40. package/dist/cjs/conditions/condition-expr.js.map +1 -1
  41. package/dist/cjs/conditions/condition-factory.d.ts +1 -1
  42. package/dist/cjs/conditions/condition-factory.js +27 -38
  43. package/dist/cjs/conditions/condition-factory.js.map +1 -1
  44. package/dist/cjs/conditions/condition.d.ts +1 -1
  45. package/dist/cjs/conditions/condition.js +6 -6
  46. package/dist/cjs/conditions/condition.js.map +1 -1
  47. package/dist/cjs/conditions/context/context.d.ts +2 -6
  48. package/dist/cjs/conditions/context/context.js +16 -41
  49. package/dist/cjs/conditions/context/context.js.map +1 -1
  50. package/dist/cjs/conditions/context/index.d.ts +1 -1
  51. package/dist/cjs/conditions/context/index.js +2 -2
  52. package/dist/cjs/conditions/context/index.js.map +1 -1
  53. package/dist/cjs/conditions/if-then-else-condition.d.ts +4 -4
  54. package/dist/cjs/conditions/if-then-else-condition.js +8 -8
  55. package/dist/cjs/conditions/if-then-else-condition.js.map +1 -1
  56. package/dist/cjs/conditions/index.d.ts +9 -9
  57. package/dist/cjs/conditions/index.js +10 -10
  58. package/dist/cjs/conditions/index.js.map +1 -1
  59. package/dist/cjs/conditions/multi-condition.d.ts +1 -1
  60. package/dist/cjs/conditions/multi-condition.js +8 -8
  61. package/dist/cjs/conditions/multi-condition.js.map +1 -1
  62. package/dist/cjs/conditions/predefined/erc20.d.ts +1 -1
  63. package/dist/cjs/conditions/predefined/erc20.js +3 -3
  64. package/dist/cjs/conditions/predefined/erc20.js.map +1 -1
  65. package/dist/cjs/conditions/predefined/erc721.d.ts +1 -1
  66. package/dist/cjs/conditions/predefined/erc721.js +5 -5
  67. package/dist/cjs/conditions/predefined/erc721.js.map +1 -1
  68. package/dist/cjs/conditions/predefined/index.d.ts +2 -2
  69. package/dist/cjs/conditions/predefined/index.js +2 -2
  70. package/dist/cjs/conditions/predefined/index.js.map +1 -1
  71. package/dist/cjs/conditions/schemas/common.d.ts +0 -2
  72. package/dist/cjs/conditions/schemas/common.js +8 -25
  73. package/dist/cjs/conditions/schemas/common.js.map +1 -1
  74. package/dist/cjs/conditions/schemas/compound.js +6 -6
  75. package/dist/cjs/conditions/schemas/compound.js.map +1 -1
  76. package/dist/cjs/conditions/schemas/context.js +5 -5
  77. package/dist/cjs/conditions/schemas/context.js.map +1 -1
  78. package/dist/cjs/conditions/schemas/contract.d.ts +30 -33
  79. package/dist/cjs/conditions/schemas/contract.js +4 -4
  80. package/dist/cjs/conditions/schemas/contract.js.map +1 -1
  81. package/dist/cjs/conditions/schemas/export-for-zod-doc-gen.d.ts +13 -16
  82. package/dist/cjs/conditions/schemas/export-for-zod-doc-gen.js +13 -17
  83. package/dist/cjs/conditions/schemas/export-for-zod-doc-gen.js.map +1 -1
  84. package/dist/cjs/conditions/schemas/if-then-else.js +10 -10
  85. package/dist/cjs/conditions/schemas/if-then-else.js.map +1 -1
  86. package/dist/cjs/conditions/schemas/json-api.d.ts +14 -47
  87. package/dist/cjs/conditions/schemas/json-api.js +9 -23
  88. package/dist/cjs/conditions/schemas/json-api.js.map +1 -1
  89. package/dist/cjs/conditions/schemas/json-rpc.d.ts +13 -48
  90. package/dist/cjs/conditions/schemas/json-rpc.js +9 -23
  91. package/dist/cjs/conditions/schemas/json-rpc.js.map +1 -1
  92. package/dist/cjs/conditions/schemas/jwt.d.ts +4 -2
  93. package/dist/cjs/conditions/schemas/jwt.js +4 -4
  94. package/dist/cjs/conditions/schemas/jwt.js.map +1 -1
  95. package/dist/cjs/conditions/schemas/return-value-test.d.ts +12 -28
  96. package/dist/cjs/conditions/schemas/return-value-test.js +8 -22
  97. package/dist/cjs/conditions/schemas/return-value-test.js.map +1 -1
  98. package/dist/cjs/conditions/schemas/rpc.d.ts +16 -22
  99. package/dist/cjs/conditions/schemas/rpc.js +8 -8
  100. package/dist/cjs/conditions/schemas/rpc.js.map +1 -1
  101. package/dist/cjs/conditions/schemas/sequential.js +18 -38
  102. package/dist/cjs/conditions/schemas/sequential.js.map +1 -1
  103. package/dist/cjs/conditions/schemas/time.d.ts +10 -18
  104. package/dist/cjs/conditions/schemas/time.js +2 -2
  105. package/dist/cjs/conditions/schemas/time.js.map +1 -1
  106. package/dist/cjs/conditions/schemas/utils.js +18 -25
  107. package/dist/cjs/conditions/schemas/utils.js.map +1 -1
  108. package/dist/cjs/conditions/sequential.d.ts +4 -4
  109. package/dist/cjs/conditions/sequential.js +8 -8
  110. package/dist/cjs/conditions/sequential.js.map +1 -1
  111. package/dist/cjs/conditions/shared.d.ts +2 -2
  112. package/dist/cjs/conditions/shared.js +6 -6
  113. package/dist/cjs/conditions/shared.js.map +1 -1
  114. package/dist/cjs/index.d.ts +3 -3
  115. package/dist/cjs/index.js +8 -9
  116. package/dist/cjs/index.js.map +1 -1
  117. package/dist/cjs/taco.d.ts +82 -43
  118. package/dist/cjs/taco.js +28 -86
  119. package/dist/cjs/taco.js.map +1 -1
  120. package/dist/cjs/tdec.d.ts +2 -2
  121. package/dist/cjs/tdec.js +7 -7
  122. package/dist/cjs/tdec.js.map +1 -1
  123. package/dist/cjs/types.d.ts +0 -1
  124. package/dist/es/access-client/client.d.ts +237 -0
  125. package/dist/es/access-client/client.js +192 -0
  126. package/dist/es/access-client/client.js.map +1 -0
  127. package/dist/es/access-client/config-validator.d.ts +92 -0
  128. package/dist/es/access-client/config-validator.js +200 -0
  129. package/dist/es/access-client/config-validator.js.map +1 -0
  130. package/dist/es/access-client/config.d.ts +50 -0
  131. package/dist/es/access-client/config.js +23 -0
  132. package/dist/es/access-client/config.js.map +1 -0
  133. package/dist/es/access-client/index.d.ts +2 -0
  134. package/dist/es/access-client/index.js +3 -0
  135. package/dist/es/access-client/index.js.map +1 -0
  136. package/dist/es/conditions/base/contract.d.ts +4 -4
  137. package/dist/es/conditions/base/contract.js +3 -3
  138. package/dist/es/conditions/base/contract.js.map +1 -1
  139. package/dist/es/conditions/base/index.d.ts +6 -9
  140. package/dist/es/conditions/base/index.js +6 -9
  141. package/dist/es/conditions/base/index.js.map +1 -1
  142. package/dist/es/conditions/base/json-api.d.ts +4 -4
  143. package/dist/es/conditions/base/json-api.js +3 -3
  144. package/dist/es/conditions/base/json-api.js.map +1 -1
  145. package/dist/es/conditions/base/json-rpc.d.ts +4 -4
  146. package/dist/es/conditions/base/json-rpc.js +3 -3
  147. package/dist/es/conditions/base/json-rpc.js.map +1 -1
  148. package/dist/es/conditions/base/jwt.d.ts +4 -4
  149. package/dist/es/conditions/base/jwt.js +3 -3
  150. package/dist/es/conditions/base/jwt.js.map +1 -1
  151. package/dist/es/conditions/base/rpc.d.ts +4 -4
  152. package/dist/es/conditions/base/rpc.js +3 -3
  153. package/dist/es/conditions/base/rpc.js.map +1 -1
  154. package/dist/es/conditions/base/time.d.ts +4 -4
  155. package/dist/es/conditions/base/time.js +3 -3
  156. package/dist/es/conditions/base/time.js.map +1 -1
  157. package/dist/es/conditions/compound-condition.d.ts +4 -4
  158. package/dist/es/conditions/compound-condition.js +3 -3
  159. package/dist/es/conditions/compound-condition.js.map +1 -1
  160. package/dist/es/conditions/condition-expr.d.ts +1 -1
  161. package/dist/es/conditions/condition-expr.js +2 -2
  162. package/dist/es/conditions/condition-expr.js.map +1 -1
  163. package/dist/es/conditions/condition-factory.d.ts +1 -1
  164. package/dist/es/conditions/condition-factory.js +9 -20
  165. package/dist/es/conditions/condition-factory.js.map +1 -1
  166. package/dist/es/conditions/condition.d.ts +1 -1
  167. package/dist/es/conditions/condition.js +3 -3
  168. package/dist/es/conditions/condition.js.map +1 -1
  169. package/dist/es/conditions/context/context.d.ts +2 -6
  170. package/dist/es/conditions/context/context.js +6 -31
  171. package/dist/es/conditions/context/context.js.map +1 -1
  172. package/dist/es/conditions/context/index.d.ts +1 -1
  173. package/dist/es/conditions/context/index.js +1 -1
  174. package/dist/es/conditions/context/index.js.map +1 -1
  175. package/dist/es/conditions/if-then-else-condition.d.ts +4 -4
  176. package/dist/es/conditions/if-then-else-condition.js +3 -3
  177. package/dist/es/conditions/if-then-else-condition.js.map +1 -1
  178. package/dist/es/conditions/index.d.ts +9 -9
  179. package/dist/es/conditions/index.js +9 -9
  180. package/dist/es/conditions/index.js.map +1 -1
  181. package/dist/es/conditions/multi-condition.d.ts +1 -1
  182. package/dist/es/conditions/multi-condition.js +3 -3
  183. package/dist/es/conditions/multi-condition.js.map +1 -1
  184. package/dist/es/conditions/predefined/erc20.d.ts +1 -1
  185. package/dist/es/conditions/predefined/erc20.js +1 -1
  186. package/dist/es/conditions/predefined/erc20.js.map +1 -1
  187. package/dist/es/conditions/predefined/erc721.d.ts +1 -1
  188. package/dist/es/conditions/predefined/erc721.js +1 -1
  189. package/dist/es/conditions/predefined/erc721.js.map +1 -1
  190. package/dist/es/conditions/predefined/index.d.ts +2 -2
  191. package/dist/es/conditions/predefined/index.js +2 -2
  192. package/dist/es/conditions/predefined/index.js.map +1 -1
  193. package/dist/es/conditions/schemas/common.d.ts +0 -2
  194. package/dist/es/conditions/schemas/common.js +3 -20
  195. package/dist/es/conditions/schemas/common.js.map +1 -1
  196. package/dist/es/conditions/schemas/compound.js +3 -3
  197. package/dist/es/conditions/schemas/compound.js.map +1 -1
  198. package/dist/es/conditions/schemas/context.js +2 -2
  199. package/dist/es/conditions/schemas/context.js.map +1 -1
  200. package/dist/es/conditions/schemas/contract.d.ts +30 -33
  201. package/dist/es/conditions/schemas/contract.js +2 -2
  202. package/dist/es/conditions/schemas/contract.js.map +1 -1
  203. package/dist/es/conditions/schemas/export-for-zod-doc-gen.d.ts +13 -16
  204. package/dist/es/conditions/schemas/export-for-zod-doc-gen.js +13 -17
  205. package/dist/es/conditions/schemas/export-for-zod-doc-gen.js.map +1 -1
  206. package/dist/es/conditions/schemas/if-then-else.js +3 -3
  207. package/dist/es/conditions/schemas/if-then-else.js.map +1 -1
  208. package/dist/es/conditions/schemas/json-api.d.ts +14 -47
  209. package/dist/es/conditions/schemas/json-api.js +5 -19
  210. package/dist/es/conditions/schemas/json-api.js.map +1 -1
  211. package/dist/es/conditions/schemas/json-rpc.d.ts +13 -48
  212. package/dist/es/conditions/schemas/json-rpc.js +5 -19
  213. package/dist/es/conditions/schemas/json-rpc.js.map +1 -1
  214. package/dist/es/conditions/schemas/jwt.d.ts +4 -2
  215. package/dist/es/conditions/schemas/jwt.js +2 -2
  216. package/dist/es/conditions/schemas/jwt.js.map +1 -1
  217. package/dist/es/conditions/schemas/return-value-test.d.ts +12 -28
  218. package/dist/es/conditions/schemas/return-value-test.js +6 -20
  219. package/dist/es/conditions/schemas/return-value-test.js.map +1 -1
  220. package/dist/es/conditions/schemas/rpc.d.ts +16 -22
  221. package/dist/es/conditions/schemas/rpc.js +3 -3
  222. package/dist/es/conditions/schemas/rpc.js.map +1 -1
  223. package/dist/es/conditions/schemas/sequential.js +14 -34
  224. package/dist/es/conditions/schemas/sequential.js.map +1 -1
  225. package/dist/es/conditions/schemas/time.d.ts +10 -18
  226. package/dist/es/conditions/schemas/time.js +1 -1
  227. package/dist/es/conditions/schemas/time.js.map +1 -1
  228. package/dist/es/conditions/schemas/utils.js +10 -17
  229. package/dist/es/conditions/schemas/utils.js.map +1 -1
  230. package/dist/es/conditions/sequential.d.ts +4 -4
  231. package/dist/es/conditions/sequential.js +3 -3
  232. package/dist/es/conditions/sequential.js.map +1 -1
  233. package/dist/es/conditions/shared.d.ts +2 -2
  234. package/dist/es/conditions/shared.js +2 -2
  235. package/dist/es/conditions/shared.js.map +1 -1
  236. package/dist/es/index.d.ts +3 -3
  237. package/dist/es/index.js +3 -3
  238. package/dist/es/index.js.map +1 -1
  239. package/dist/es/package.json +3 -0
  240. package/dist/es/taco.d.ts +82 -43
  241. package/dist/es/taco.js +25 -82
  242. package/dist/es/taco.js.map +1 -1
  243. package/dist/es/tdec.d.ts +2 -2
  244. package/dist/es/tdec.js +5 -5
  245. package/dist/es/tdec.js.map +1 -1
  246. package/dist/es/types.d.ts +0 -1
  247. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  248. package/dist/tsconfig.es.tsbuildinfo +1 -1
  249. package/package.json +12 -8
  250. package/dist/cjs/conditions/base/address-allowlist.d.ts +0 -10
  251. package/dist/cjs/conditions/base/address-allowlist.js +0 -19
  252. package/dist/cjs/conditions/base/address-allowlist.js.map +0 -1
  253. package/dist/cjs/conditions/base/ecdsa.d.ts +0 -7
  254. package/dist/cjs/conditions/base/ecdsa.js +0 -21
  255. package/dist/cjs/conditions/base/ecdsa.js.map +0 -1
  256. package/dist/cjs/conditions/base/signing.d.ts +0 -10
  257. package/dist/cjs/conditions/base/signing.js +0 -32
  258. package/dist/cjs/conditions/base/signing.js.map +0 -1
  259. package/dist/cjs/conditions/schemas/address-allowlist.d.ts +0 -16
  260. package/dist/cjs/conditions/schemas/address-allowlist.js +0 -20
  261. package/dist/cjs/conditions/schemas/address-allowlist.js.map +0 -1
  262. package/dist/cjs/conditions/schemas/ecdsa.d.ts +0 -38
  263. package/dist/cjs/conditions/schemas/ecdsa.js +0 -40
  264. package/dist/cjs/conditions/schemas/ecdsa.js.map +0 -1
  265. package/dist/cjs/conditions/schemas/signing.d.ts +0 -12
  266. package/dist/cjs/conditions/schemas/signing.js +0 -204
  267. package/dist/cjs/conditions/schemas/signing.js.map +0 -1
  268. package/dist/cjs/conditions/zod.d.ts +0 -3
  269. package/dist/cjs/conditions/zod.js +0 -19
  270. package/dist/cjs/conditions/zod.js.map +0 -1
  271. package/dist/cjs/sign.d.ts +0 -26
  272. package/dist/cjs/sign.js +0 -99
  273. package/dist/cjs/sign.js.map +0 -1
  274. package/dist/es/conditions/base/address-allowlist.d.ts +0 -10
  275. package/dist/es/conditions/base/address-allowlist.js +0 -15
  276. package/dist/es/conditions/base/address-allowlist.js.map +0 -1
  277. package/dist/es/conditions/base/ecdsa.d.ts +0 -7
  278. package/dist/es/conditions/base/ecdsa.js +0 -12
  279. package/dist/es/conditions/base/ecdsa.js.map +0 -1
  280. package/dist/es/conditions/base/signing.d.ts +0 -10
  281. package/dist/es/conditions/base/signing.js +0 -20
  282. package/dist/es/conditions/base/signing.js.map +0 -1
  283. package/dist/es/conditions/schemas/address-allowlist.d.ts +0 -16
  284. package/dist/es/conditions/schemas/address-allowlist.js +0 -17
  285. package/dist/es/conditions/schemas/address-allowlist.js.map +0 -1
  286. package/dist/es/conditions/schemas/ecdsa.d.ts +0 -38
  287. package/dist/es/conditions/schemas/ecdsa.js +0 -37
  288. package/dist/es/conditions/schemas/ecdsa.js.map +0 -1
  289. package/dist/es/conditions/schemas/signing.d.ts +0 -12
  290. package/dist/es/conditions/schemas/signing.js +0 -201
  291. package/dist/es/conditions/schemas/signing.js.map +0 -1
  292. package/dist/es/conditions/zod.d.ts +0 -3
  293. package/dist/es/conditions/zod.js +0 -17
  294. package/dist/es/conditions/zod.js.map +0 -1
  295. package/dist/es/sign.d.ts +0 -26
  296. package/dist/es/sign.js +0 -95
  297. package/dist/es/sign.js.map +0 -1
package/README.md CHANGED
@@ -64,6 +64,155 @@ const decryptedMessage = await decrypt(
64
64
  );
65
65
  ```
66
66
 
67
+ ## Viem Support
68
+
69
+ The TACo SDK supports both [ethers.js](https://docs.ethers.org/) natively, and [viem](https://viem.sh). The same `encrypt` and `decrypt` functions work with both libraries. Here is how to use them with viem:
70
+
71
+ ```bash
72
+ $ yarn add @nucypher/taco viem
73
+ ```
74
+
75
+ ```typescript
76
+ import { encrypt, decrypt, conditions, domains, initialize } from '@nucypher/taco';
77
+ import { createPublicClient, http } from 'viem';
78
+ import { privateKeyToAccount } from 'viem/accounts';
79
+ import { polygonAmoy } from 'viem/chains';
80
+
81
+ // Initialize TACo
82
+ await initialize();
83
+
84
+ const viemClient = createPublicClient({
85
+ chain: polygonAmoy,
86
+ transport: http(),
87
+ });
88
+ const viemAccount = privateKeyToAccount('0x...');
89
+
90
+ const ownsNFT = new conditions.predefined.ERC721Ownership({
91
+ contractAddress: '0x1e988ba4692e52Bc50b375bcC8585b95c48AaD77',
92
+ parameters: [3591],
93
+ chain: 5,
94
+ });
95
+
96
+ // Same function names work with viem - TypeScript automatically selects the right overload
97
+ const messageKit = await encrypt(
98
+ viemClient, // viem PublicClient
99
+ domains.TESTNET,
100
+ 'my secret message',
101
+ ownsNFT,
102
+ ritualId,
103
+ viemAccount, // viem Signer Account (`LocalAccount` or `WalletClient`)
104
+ );
105
+
106
+ // Decrypt with viem
107
+ const decryptedMessage = await decrypt(
108
+ viemClient,
109
+ domains.TESTNET,
110
+ messageKit,
111
+ );
112
+ ```
113
+
114
+ ### Automatic Library Detection
115
+
116
+ TypeScript automatically detects which library objects you're passing and works seamlessly:
117
+
118
+ ```typescript
119
+ // Using ethers.js - automatically uses ethers implementation
120
+ const ethersEncrypted = await encrypt(
121
+ ethersProvider, // ethers.providers.Provider
122
+ domains.TESTNET,
123
+ message,
124
+ condition,
125
+ ritualId,
126
+ ethersSigner // ethers.Signer
127
+ );
128
+
129
+ // Using viem - automatically uses viem implementation
130
+ const viemEncrypted = await encrypt(
131
+ publicClient, // viem PublicClient
132
+ domains.TESTNET,
133
+ message,
134
+ condition,
135
+ ritualId,
136
+ viemAccount // viem Signer Account (`LocalAccount` or `WalletClient`)
137
+ );
138
+ ```
139
+
140
+ For detailed viem documentation, see [VIEM_SUPPORT.md](./VIEM_SUPPORT.md).
141
+
142
+ ## AccessClient - Object-Oriented Interface
143
+
144
+ For applications requiring multiple TACo cryptographic operations or complex configuration management, the TACo SDK provides an optional object-oriented interface through the `AccessClient` class. This provides a stateful, higher-level abstraction over the functional API.
145
+
146
+ The Object-Oriented API is fully backward compatible - you can use both APIs in
147
+ the same application as needed. Except that the AccessClient has additional validations
148
+ and hence throws some errors earlier with different error messages.
149
+
150
+ NOTE: Using `AccessClient` is equivalent to using the functional API.
151
+ There are no specific recommendations on which approach to use.
152
+ Choose the one that best suits your development preferences.
153
+
154
+ ### Basic Usage
155
+
156
+ ```typescript
157
+ import { AccessClient, ConditionContext, DOMAIN_NAMES } from '@nucypher/taco';
158
+ import { createPublicClient, http } from 'viem';
159
+ import { privateKeyToAccount } from 'viem/accounts';
160
+ import { polygonAmoy } from 'viem/chains';
161
+
162
+ // Initialize TACo
163
+ await initialize();
164
+
165
+ // Set up viem client and account
166
+ const viemClient = createPublicClient({
167
+ chain: polygonAmoy,
168
+ transport: http(),
169
+ });
170
+ const viemAccount = privateKeyToAccount('0x...');
171
+
172
+ // Create AccessClient instance with domain constants
173
+ const accessClient = new AccessClient({
174
+ domain: DOMAIN_NAMES.TESTNET, // TESTNET -> 'tapir'
175
+ ritualId: 6,
176
+ viemClient
177
+ });
178
+
179
+ // Encrypt data
180
+ const messageKit = await accessClient.encrypt('Hello, secret!', condition, viemAccount);
181
+
182
+ // Decrypt
183
+ const conditionContext = ConditionContext.fromMessageKit(messageKit);
184
+
185
+ // if needed Add authentication for ":userAddress" in condition...
186
+
187
+ const decryptedMessage = await accessClient.decrypt(messageKit, conditionContext);
188
+ // OR with encrypted bytes:
189
+ // const decryptedMessage = await accessClient.decrypt(messageKit.toBytes(), conditionContext);
190
+ ```
191
+
192
+ ### Dual Configuration Support
193
+
194
+ AccessClient supports both viem and ethers.js configurations:
195
+
196
+ ```typescript
197
+ import { AccessClient, DOMAIN_NAMES } from '@nucypher/taco';
198
+
199
+ // With viem
200
+ const accessClientViem = new AccessClient({
201
+ domain: DOMAIN_NAMES.TESTNET,
202
+ ritualId: 6,
203
+ viemClient
204
+ });
205
+ const messageKit = await accessClientViem.encrypt(data, condition, viemAccount);
206
+
207
+ // With ethers.js
208
+ const accessClientEthers = new AccessClient({
209
+ domain: DOMAIN_NAMES.TESTNET,
210
+ ritualId: 6,
211
+ ethersProvider
212
+ });
213
+ const messageKit2 = await accessClientEthers.encrypt(data, condition, ethersSigner);
214
+ ```
215
+
67
216
  ## Learn more
68
217
 
69
218
  Please find developer documentation for
@@ -0,0 +1,237 @@
1
+ import { DkgPublicKey, ThresholdMessageKit } from '@nucypher/nucypher-core';
2
+ import { SignerAccount } from '@nucypher/shared';
3
+ import { ethers } from 'ethers';
4
+ import { Condition } from '../conditions/condition.js';
5
+ import { ConditionContext } from '../conditions/context/index.js';
6
+ import { type AccessClientConfig } from './config.js';
7
+ /**
8
+ * AccessClient provides an object-oriented interface for TACo cryptographic operations
9
+ *
10
+ * This class encapsulates TACo access-control configuration and provides simplified methods
11
+ * for encryption and decryption operations. It handles configuration validation,
12
+ * automatic WASM initialization, and provides enhanced error messages.
13
+ *
14
+ * @example Using with viem:
15
+ * ```typescript
16
+ * import { AccessClient, DOMAIN_NAMES } from '@nucypher/taco';
17
+ * import { createPublicClient, http } from 'viem';
18
+ * import { polygonAmoy } from 'viem/chains';
19
+ * import { privateKeyToAccount } from 'viem/accounts';
20
+ *
21
+ * // Create viem client and account
22
+ * const viemClient = createPublicClient({
23
+ * chain: polygonAmoy,
24
+ * transport: http()
25
+ * });
26
+ * const viemAccount = privateKeyToAccount('0x...');
27
+ *
28
+ * // Create AccessClient - WASM initializes automatically
29
+ * const accessClient = new AccessClient({
30
+ * domain: DOMAIN_NAMES.TESTNET, // 'tapir'
31
+ * ritualId: 6,
32
+ * viemClient
33
+ * });
34
+ *
35
+ * // Pass signer to encrypt operation
36
+ * const messageKit = await accessClient.encrypt('Hello, secret!', condition, viemAccount);
37
+ * // Decrypt doesn't require signer
38
+ * const decrypted = await accessClient.decrypt(messageKit, conditionContext);
39
+ * ```
40
+ *
41
+ * @example Using with ethers.js:
42
+ * ```typescript
43
+ * import { AccessClient, DOMAIN_NAMES } from '@nucypher/taco';
44
+ * import { ethers } from 'ethers';
45
+ *
46
+ * // Create ethers provider and signer
47
+ * const ethersProvider = new ethers.providers.JsonRpcProvider('https://rpc-amoy.polygon.technology');
48
+ * const ethersSigner = new ethers.Wallet('0x...', ethersProvider);
49
+ *
50
+ * // Create AccessClient - WASM initializes automatically
51
+ * const accessClient = new AccessClient({
52
+ * domain: DOMAIN_NAMES.TESTNET,
53
+ * ritualId: 6,
54
+ * ethersProvider
55
+ * });
56
+ *
57
+ * // Pass signer to encrypt operation
58
+ * const messageKit = await accessClient.encrypt('Hello, secret!', condition, ethersSigner);
59
+ * // Decrypt doesn't require signer
60
+ * const decrypted = await accessClient.decrypt(messageKit, conditionContext);
61
+ * ```
62
+ */
63
+ export declare class AccessClient {
64
+ private config;
65
+ private static initializationPromise;
66
+ /**
67
+ * Initialize TACo WASM globally (singleton pattern)
68
+ *
69
+ * This method ensures TACo WASM is initialized exactly once across all AccessClient instances.
70
+ * Initialization happens automatically when creating clients or calling operations, but you can
71
+ * call this explicitly for performance optimization or error handling.
72
+ *
73
+ * @returns {Promise<void>} Promise that resolves when TACo WASM is initialized
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * // Optional: Pre-initialize for better performance
78
+ * await AccessClient.initialize();
79
+ *
80
+ * // All AccessClient instances share the same initialization
81
+ * const client1 = new AccessClient(config1);
82
+ * const client2 = new AccessClient(config2);
83
+ *
84
+ * // Operations automatically wait for initialization
85
+ * const encrypted = await client1.encrypt(data, condition);
86
+ * ```
87
+ */
88
+ static initialize(): Promise<void>;
89
+ /**
90
+ * Create a new AccessClient instance
91
+ *
92
+ * @param {AccessClientConfig} config - Configuration for the AccessClient
93
+ * @throws {Error} If configuration is invalid
94
+ */
95
+ constructor(config: AccessClientConfig);
96
+ /**
97
+ * Fully validate the configuration including network provider checks
98
+ *
99
+ * This method performs comprehensive validation including:
100
+ * - Domain and ritual ID validation
101
+ * - Provider/signer configuration validation
102
+ * - Network compatibility check (calls provider to verify chain ID matches domain)
103
+ *
104
+ * @returns {Promise<ValidationResult>} Promise resolving to validation result with isValid boolean and errors array
105
+ * @throws {Error} If configuration validation fails
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * try {
110
+ * await accessClient.validateConfig();
111
+ * console.log('Configuration is valid.');
112
+ * } catch (error) {
113
+ * console.error('Configuration validation failed:', error.message);
114
+ * }
115
+ * ```
116
+ */
117
+ validateConfig(): Promise<void>;
118
+ /**
119
+ * Encrypt data with the given access condition.
120
+ *
121
+ * Use this overload when your application uses ethers.js.
122
+ *
123
+ * @export
124
+ * @param {string | Uint8Array} data - String or Uint8Array to encrypt
125
+ * @param {Condition} accessCondition - Access condition (single or composite) that must be satisfied at decryption time.
126
+ * @param {ethers.Signer} authSigner - Signer used to identify encryptor and verify authorization.
127
+ *
128
+ * @returns {Promise<ThresholdMessageKit>} Encrypted message kit representing the ciphertext and associated metadata.
129
+ *
130
+ * @throws {Error} If the ritual cannot be retrieved or encryption fails.
131
+ *
132
+ * @example
133
+ * ```typescript
134
+ * const messageKit = await accessClient.encrypt('Hello, secret!', condition, authSigner);
135
+ * ```
136
+ */
137
+ encrypt(data: string | Uint8Array, accessCondition: Condition, authSigner: ethers.Signer): Promise<ThresholdMessageKit>;
138
+ /**
139
+ * Encrypt data with the given access condition.
140
+ *
141
+ * Use this overload when your application uses viem.
142
+ *
143
+ * @export
144
+ * @param {string | Uint8Array} data - String or Uint8Array to encrypt
145
+ * @param {Condition} accessCondition - Access condition (single or composite) that must be satisfied at decryption time.
146
+ * @param {SignerAccount} authAccount - Viem account used to identify encryptor and verify authorization.
147
+ *
148
+ * @returns {Promise<ThresholdMessageKit>} Encrypted message kit representing the ciphertext and associated metadata.
149
+ *
150
+ * @throws {Error} If the ritual cannot be retrieved or encryption fails.
151
+ * @example
152
+ * ```typescript
153
+ * const messageKit = await accessClient.encrypt('Hello, secret!', condition, authAccount);
154
+ * ```
155
+ */
156
+ encrypt(data: string | Uint8Array, accessCondition: Condition, authAccount: SignerAccount): Promise<ThresholdMessageKit>;
157
+ /**
158
+ * Encrypt data with a provided DKG public key under a specified condition
159
+ *
160
+ * This method can be used offline since it doesn't require network access to fetch
161
+ * the DKG public key (unlike the `encrypt` method which fetches it from the ritual).
162
+ *
163
+ * Use this overload when your application uses ethers.js.
164
+ *
165
+ * @export
166
+ * @param {string | Uint8Array} data - String or Uint8Array to encrypt
167
+ * @param {Condition} condition - Access condition (single or composite) that must be satisfied at decryption time.
168
+ * @param {DkgPublicKey} dkgPublicKey - The public key of an active DKG Ritual to be used for encryption
169
+ * @param {ethers.Signer} authSigner - ethers.Signer used to identify encryptor and verify authorization.
170
+ *
171
+ * @returns {Promise<ThresholdMessageKit>} Encrypted message kit representing the ciphertext and associated metadata.
172
+ *
173
+ * @throws {Error} If encryption fails
174
+ *
175
+ * @example
176
+ * ```typescript
177
+ * // Get DKG public key from ritual or cache
178
+ * const dkgPublicKey = await getDkgPublicKey(domain, ritualId);
179
+ *
180
+ * // Encrypt offline using the public key
181
+ * const messageKit = await accessClient.encryptWithPublicKey('Hello, secret!', condition, dkgPublicKey, authSigner);
182
+ * ```
183
+ */
184
+ encryptWithPublicKey(data: Uint8Array | string, condition: Condition, dkgPublicKey: DkgPublicKey, authSigner: ethers.Signer): Promise<ThresholdMessageKit>;
185
+ /**
186
+ * Encrypt data with a provided DKG public key under a specified condition
187
+ *
188
+ * This method can be used offline since it doesn't require network access to fetch
189
+ * the DKG public key (unlike the `encrypt` method which fetches it from the ritual).
190
+ *
191
+ * Use this overload when your application uses viem.
192
+ *
193
+ * @export
194
+ * @param {string | Uint8Array} data - String or Uint8Array to encrypt
195
+ * @param {Condition} condition - Access condition (single or composite) that must be satisfied at decryption time.
196
+ * @param {DkgPublicKey} dkgPublicKey - The public key of an active DKG Ritual to be used for encryption
197
+ * @param {SignerAccount} authAccount - Viem signer account used to identify encryptor and verify authorization.
198
+ *
199
+ * @returns {Promise<ThresholdMessageKit>} Encrypted message kit representing the ciphertext and associated metadata.
200
+ *
201
+ * @throws {Error} If encryption fails
202
+ *
203
+ * @example
204
+ * ```typescript
205
+ * // Get DKG public key from ritual or cache
206
+ * const dkgPublicKey = await getDkgPublicKey(domain, ritualId);
207
+ *
208
+ * // Encrypt offline using the public key
209
+ * const messageKit = await accessClient.encryptWithPublicKey('Hello, secret!', condition, dkgPublicKey, authAccount);
210
+ * ```
211
+ */
212
+ encryptWithPublicKey(data: Uint8Array | string, condition: Condition, dkgPublicKey: DkgPublicKey, authAccount: SignerAccount): Promise<ThresholdMessageKit>;
213
+ /**
214
+ * Decrypt data using TACo
215
+ *
216
+ * @param {ThresholdMessageKit | Uint8Array} encryptedData - Either a ThresholdMessageKit or encrypted bytes (Uint8Array)
217
+ * @param {ConditionContext} [conditionContext] - Optional condition context for time-based conditions
218
+ * @returns {Promise<Uint8Array>} Decrypted data
219
+ * @throws {Error} If decryption fails
220
+ *
221
+ * @example
222
+ * ```typescript
223
+ * // With messageKit
224
+ * const decrypted = await accessClient.decrypt(messageKit, conditionContext);
225
+ *
226
+ * // With encrypted bytes
227
+ * const decrypted = await accessClient.decrypt(encryptedBytes, conditionContext);
228
+ * ```
229
+ */
230
+ decrypt(encryptedData: ThresholdMessageKit | Uint8Array, conditionContext?: ConditionContext): Promise<Uint8Array>;
231
+ /**
232
+ * Get current client configuration
233
+ *
234
+ * @returns {Readonly<AccessClientConfig>} Client configuration
235
+ */
236
+ getConfig(): Readonly<AccessClientConfig>;
237
+ }
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccessClient = void 0;
4
+ const nucypher_core_1 = require("@nucypher/nucypher-core");
5
+ const taco_js_1 = require("../taco.js");
6
+ const config_validator_js_1 = require("./config-validator.js");
7
+ /**
8
+ * AccessClient provides an object-oriented interface for TACo cryptographic operations
9
+ *
10
+ * This class encapsulates TACo access-control configuration and provides simplified methods
11
+ * for encryption and decryption operations. It handles configuration validation,
12
+ * automatic WASM initialization, and provides enhanced error messages.
13
+ *
14
+ * @example Using with viem:
15
+ * ```typescript
16
+ * import { AccessClient, DOMAIN_NAMES } from '@nucypher/taco';
17
+ * import { createPublicClient, http } from 'viem';
18
+ * import { polygonAmoy } from 'viem/chains';
19
+ * import { privateKeyToAccount } from 'viem/accounts';
20
+ *
21
+ * // Create viem client and account
22
+ * const viemClient = createPublicClient({
23
+ * chain: polygonAmoy,
24
+ * transport: http()
25
+ * });
26
+ * const viemAccount = privateKeyToAccount('0x...');
27
+ *
28
+ * // Create AccessClient - WASM initializes automatically
29
+ * const accessClient = new AccessClient({
30
+ * domain: DOMAIN_NAMES.TESTNET, // 'tapir'
31
+ * ritualId: 6,
32
+ * viemClient
33
+ * });
34
+ *
35
+ * // Pass signer to encrypt operation
36
+ * const messageKit = await accessClient.encrypt('Hello, secret!', condition, viemAccount);
37
+ * // Decrypt doesn't require signer
38
+ * const decrypted = await accessClient.decrypt(messageKit, conditionContext);
39
+ * ```
40
+ *
41
+ * @example Using with ethers.js:
42
+ * ```typescript
43
+ * import { AccessClient, DOMAIN_NAMES } from '@nucypher/taco';
44
+ * import { ethers } from 'ethers';
45
+ *
46
+ * // Create ethers provider and signer
47
+ * const ethersProvider = new ethers.providers.JsonRpcProvider('https://rpc-amoy.polygon.technology');
48
+ * const ethersSigner = new ethers.Wallet('0x...', ethersProvider);
49
+ *
50
+ * // Create AccessClient - WASM initializes automatically
51
+ * const accessClient = new AccessClient({
52
+ * domain: DOMAIN_NAMES.TESTNET,
53
+ * ritualId: 6,
54
+ * ethersProvider
55
+ * });
56
+ *
57
+ * // Pass signer to encrypt operation
58
+ * const messageKit = await accessClient.encrypt('Hello, secret!', condition, ethersSigner);
59
+ * // Decrypt doesn't require signer
60
+ * const decrypted = await accessClient.decrypt(messageKit, conditionContext);
61
+ * ```
62
+ */
63
+ class AccessClient {
64
+ config;
65
+ static initializationPromise;
66
+ /**
67
+ * Initialize TACo WASM globally (singleton pattern)
68
+ *
69
+ * This method ensures TACo WASM is initialized exactly once across all AccessClient instances.
70
+ * Initialization happens automatically when creating clients or calling operations, but you can
71
+ * call this explicitly for performance optimization or error handling.
72
+ *
73
+ * @returns {Promise<void>} Promise that resolves when TACo WASM is initialized
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * // Optional: Pre-initialize for better performance
78
+ * await AccessClient.initialize();
79
+ *
80
+ * // All AccessClient instances share the same initialization
81
+ * const client1 = new AccessClient(config1);
82
+ * const client2 = new AccessClient(config2);
83
+ *
84
+ * // Operations automatically wait for initialization
85
+ * const encrypted = await client1.encrypt(data, condition);
86
+ * ```
87
+ */
88
+ static async initialize() {
89
+ if (!AccessClient.initializationPromise) {
90
+ AccessClient.initializationPromise = (async () => {
91
+ try {
92
+ await (0, nucypher_core_1.initialize)();
93
+ }
94
+ catch (error) {
95
+ console.error(`TACo initialization failed: ${error}`);
96
+ throw error; // Re-throw to maintain error propagation
97
+ }
98
+ })();
99
+ }
100
+ return AccessClient.initializationPromise;
101
+ }
102
+ /**
103
+ * Create a new AccessClient instance
104
+ *
105
+ * @param {AccessClientConfig} config - Configuration for the AccessClient
106
+ * @throws {Error} If configuration is invalid
107
+ */
108
+ constructor(config) {
109
+ // Validate configuration using AccessConfig
110
+ const result = config_validator_js_1.AccessConfigValidator.validateFast(config);
111
+ if (!result.isValid) {
112
+ throw new Error(`Invalid configuration: ${result.errors.join(', ')}`);
113
+ }
114
+ this.config = config;
115
+ AccessClient.initialize();
116
+ }
117
+ /**
118
+ * Fully validate the configuration including network provider checks
119
+ *
120
+ * This method performs comprehensive validation including:
121
+ * - Domain and ritual ID validation
122
+ * - Provider/signer configuration validation
123
+ * - Network compatibility check (calls provider to verify chain ID matches domain)
124
+ *
125
+ * @returns {Promise<ValidationResult>} Promise resolving to validation result with isValid boolean and errors array
126
+ * @throws {Error} If configuration validation fails
127
+ *
128
+ * @example
129
+ * ```typescript
130
+ * try {
131
+ * await accessClient.validateConfig();
132
+ * console.log('Configuration is valid.');
133
+ * } catch (error) {
134
+ * console.error('Configuration validation failed:', error.message);
135
+ * }
136
+ * ```
137
+ */
138
+ async validateConfig() {
139
+ const validationResult = await config_validator_js_1.AccessConfigValidator.validate(this.config);
140
+ if (!validationResult.isValid) {
141
+ throw new Error(`Invalid configuration: ${validationResult.errors.join(', ')}`);
142
+ }
143
+ }
144
+ async encrypt(data, accessCondition, signerLike) {
145
+ await AccessClient.initialize();
146
+ const messageKit = await (0, taco_js_1.encrypt)(this.config.ethersProvider ||
147
+ this.config.viemClient, this.config.domain, data, accessCondition, this.config.ritualId,
148
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
149
+ signerLike);
150
+ return messageKit;
151
+ }
152
+ async encryptWithPublicKey(data, accessCondition, dkgPublicKey, signerLike) {
153
+ await AccessClient.initialize();
154
+ const messageKit = await (0, taco_js_1.encryptWithPublicKey)(data, accessCondition, dkgPublicKey,
155
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
156
+ signerLike);
157
+ return messageKit;
158
+ }
159
+ /**
160
+ * Decrypt data using TACo
161
+ *
162
+ * @param {ThresholdMessageKit | Uint8Array} encryptedData - Either a ThresholdMessageKit or encrypted bytes (Uint8Array)
163
+ * @param {ConditionContext} [conditionContext] - Optional condition context for time-based conditions
164
+ * @returns {Promise<Uint8Array>} Decrypted data
165
+ * @throws {Error} If decryption fails
166
+ *
167
+ * @example
168
+ * ```typescript
169
+ * // With messageKit
170
+ * const decrypted = await accessClient.decrypt(messageKit, conditionContext);
171
+ *
172
+ * // With encrypted bytes
173
+ * const decrypted = await accessClient.decrypt(encryptedBytes, conditionContext);
174
+ * ```
175
+ */
176
+ async decrypt(encryptedData, conditionContext) {
177
+ await AccessClient.initialize();
178
+ // Handle both messageKit and encrypted bytes
179
+ const messageKit = encryptedData instanceof nucypher_core_1.ThresholdMessageKit
180
+ ? encryptedData
181
+ : nucypher_core_1.ThresholdMessageKit.fromBytes(encryptedData);
182
+ const decrypted = await (0, taco_js_1.decrypt)(this.config.ethersProvider ||
183
+ this.config.viemClient, this.config.domain, messageKit, conditionContext, this.config.porterUris);
184
+ return decrypted;
185
+ }
186
+ /**
187
+ * Get current client configuration
188
+ *
189
+ * @returns {Readonly<AccessClientConfig>} Client configuration
190
+ */
191
+ getConfig() {
192
+ return Object.freeze({ ...this.config });
193
+ }
194
+ }
195
+ exports.AccessClient = AccessClient;
196
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/access-client/client.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * TACo Domain Configuration and Validation
3
+ *
4
+ * This module provides domain configuration management, validation utilities,
5
+ * and configuration processing for TACo operations across different networks.
6
+ */
7
+ import { DomainName, ProviderLike } from '@nucypher/shared';
8
+ import { type AccessClientConfig } from './index.js';
9
+ /**
10
+ * Generic validation result interface
11
+ */
12
+ export interface ValidationResult {
13
+ isValid: boolean;
14
+ errors: string[];
15
+ }
16
+ /**
17
+ * Access Configuration Validator
18
+ *
19
+ * Validates Access client configurations, domains, and provider compatibility.
20
+ * Provides both fast and full validation methods for TACo operations.
21
+ */
22
+ export declare class AccessConfigValidator {
23
+ /**
24
+ * Get all supported TACo domain names
25
+ * @returns {DomainName[]} Array of supported TACo domain names ('lynx', 'tapir', 'mainnet')
26
+ */
27
+ static getSupportedDomains(): DomainName[];
28
+ /**
29
+ * Check if domain is valid
30
+ * @param {DomainName} domain - TACo domain name to check ('lynx', 'tapir', 'mainnet')
31
+ * @returns {boolean} True if domain exists
32
+ */
33
+ static isValidDomain(domain: DomainName): boolean;
34
+ /**
35
+ * Get expected chain ID for domain from DOMAINS configuration
36
+ * @param {DomainName} domain - Domain name to look up
37
+ * @returns {number | undefined} Chain ID for the domain, undefined if not found
38
+ * @private
39
+ */
40
+ private static getExpectedChainId;
41
+ /**
42
+ * Validate ritual ID (basic validation - positive integer or 0)
43
+ * @param {number} ritualId - Ritual ID to validate
44
+ * @returns {boolean} True if valid (positive integer or 0)
45
+ */
46
+ static isValidRitualId(ritualId: number): boolean;
47
+ /**
48
+ * Validate provider compatibility with domain
49
+ * @param {DomainName} domain - Domain name
50
+ * @param {ProviderLike} provider - Provider to validate (ethers Provider or viem PublicClient)
51
+ * @returns {Promise<boolean>} True if provider is valid for domain
52
+ */
53
+ static isValidProvider(domain: DomainName, provider: ProviderLike): Promise<boolean>;
54
+ /**
55
+ * Fast validation (everything except provider network checks)
56
+ *
57
+ * Performs synchronous validation of configuration including:
58
+ * - Domain name validation
59
+ * - Ritual ID validation to ensure it is a positive integer
60
+ * - Provider/signer presence validation
61
+ * - Chain compatibility check (if chain info is available synchronously)
62
+ *
63
+ * @param {TacoClientConfig} config - Configuration to validate
64
+ * @returns {ValidationResult} Validation result with isValid boolean and errors array
65
+ */
66
+ static validateFast(config: AccessClientConfig): ValidationResult;
67
+ /**
68
+ * Synchronous chain compatibility validation
69
+ *
70
+ * Validates provider chain compatibility with domain requirements using
71
+ * synchronously available chain information.
72
+ *
73
+ * @param {TacoClientConfig} config - Configuration to validate
74
+ * @returns {ValidationResult} Validation result
75
+ * @private
76
+ */
77
+ private static validateChainCompatibility;
78
+ /**
79
+ * Full validation including async provider network checks
80
+ *
81
+ * Performs comprehensive validation including:
82
+ * - All fast validation checks
83
+ * - Async network calls to verify provider chain ID matches domain requirements
84
+ *
85
+ * Use this method when you need complete validation including network connectivity checks.
86
+ * For faster validation without network calls, use validateFast().
87
+ *
88
+ * @param {TacoClientConfig} config - Configuration to validate
89
+ * @returns {Promise<ValidationResult>} Promise resolving to validation result with isValid boolean and errors array
90
+ */
91
+ static validate(config: AccessClientConfig): Promise<ValidationResult>;
92
+ }