@cofhe/sdk 0.6.1 → 0.7.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 (113) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/acps/acp.ts +411 -0
  3. package/acps/index.ts +70 -0
  4. package/{permits → acps}/onchain-utils.ts +49 -24
  5. package/acps/sealing.ts +90 -0
  6. package/acps/signature.ts +89 -0
  7. package/acps/store.ts +172 -0
  8. package/acps/test/acp.test.ts +615 -0
  9. package/acps/test/localstorage.test.ts +105 -0
  10. package/acps/test/sealing.test.ts +77 -0
  11. package/acps/test/store.test.ts +88 -0
  12. package/acps/test/validation.test.ts +361 -0
  13. package/acps/test-utils.ts +32 -0
  14. package/acps/types.ts +252 -0
  15. package/acps/validation.ts +392 -0
  16. package/adapters/test/ethers5.test.ts +4 -1
  17. package/adapters/test/ethers6.test.ts +4 -1
  18. package/adapters/test/wagmi.test.ts +5 -2
  19. package/chains/chains/stagingCofhe.ts +21 -0
  20. package/chains/index.ts +3 -1
  21. package/chains/test/chains.test.ts +2 -1
  22. package/core/acps.ts +625 -0
  23. package/core/client.ts +136 -39
  24. package/core/clientTypes.ts +52 -41
  25. package/core/config.ts +66 -5
  26. package/core/decrypt/MockThresholdNetworkAbi.ts +20 -11
  27. package/core/decrypt/apiError.ts +104 -0
  28. package/core/decrypt/cofheMocksDecryptForTx.ts +11 -11
  29. package/core/decrypt/cofheMocksDecryptForView.ts +7 -7
  30. package/core/decrypt/decryptForTxBuilder.ts +102 -102
  31. package/core/decrypt/decryptForViewBuilder.ts +90 -90
  32. package/core/decrypt/submitRetry.ts +38 -30
  33. package/core/decrypt/tnDecryptV1.ts +5 -5
  34. package/core/decrypt/tnDecryptV2.ts +25 -21
  35. package/core/decrypt/tnSealOutputV1.ts +4 -3
  36. package/core/decrypt/tnSealOutputV2.ts +24 -18
  37. package/core/encrypt/cofheMocksZkVerifySign.ts +59 -74
  38. package/core/encrypt/encryptInputsBuilder.ts +86 -52
  39. package/core/encrypt/zkPackProveVerify.ts +25 -18
  40. package/core/error.ts +34 -6
  41. package/core/index.ts +4 -14
  42. package/core/test/acpDefaults.test.ts +52 -0
  43. package/core/test/acps.test.ts +596 -0
  44. package/core/test/apiError.test.ts +130 -0
  45. package/core/test/client.test.ts +22 -19
  46. package/core/test/config.test.ts +25 -5
  47. package/core/test/decrypt.test.ts +40 -35
  48. package/core/test/decryptBuilders.test.ts +68 -68
  49. package/core/test/decryptErrorCodes.test.ts +217 -0
  50. package/core/test/encryptInputsBuilder.test.ts +72 -41
  51. package/core/test/pollCallbacks.test.ts +89 -18
  52. package/core/test/stagingRedirect.ts +18 -0
  53. package/core/test/submitRetry.test.ts +182 -0
  54. package/core/types.ts +9 -69
  55. package/dist/acp-Wi6isVQI.d.cts +407 -0
  56. package/dist/acp-Wi6isVQI.d.ts +407 -0
  57. package/dist/acps.cjs +1081 -0
  58. package/dist/acps.d.cts +480 -0
  59. package/dist/acps.d.ts +480 -0
  60. package/dist/acps.js +2 -0
  61. package/dist/chains.cjs +14 -1
  62. package/dist/chains.d.cts +30 -1
  63. package/dist/chains.d.ts +30 -1
  64. package/dist/chains.js +1 -1
  65. package/dist/{chunk-NOC3PYB7.js → chunk-43USWPEH.js} +930 -580
  66. package/dist/{chunk-MTRAXQXC.js → chunk-N6IDQRRU.js} +14 -2
  67. package/dist/chunk-Q7CBWGQX.js +1029 -0
  68. package/dist/{clientTypes-CyUvRRzA.d.ts → clientTypes-BN3nbzYM.d.ts} +342 -165
  69. package/dist/{clientTypes-BDy1qIBu.d.cts → clientTypes-CYZjFznO.d.cts} +342 -165
  70. package/dist/core.cjs +1358 -1002
  71. package/dist/core.d.cts +31 -9
  72. package/dist/core.d.ts +31 -9
  73. package/dist/core.js +3 -3
  74. package/dist/node.cjs +1293 -952
  75. package/dist/node.d.cts +2 -2
  76. package/dist/node.d.ts +2 -2
  77. package/dist/node.js +3 -3
  78. package/dist/web.cjs +1293 -952
  79. package/dist/web.d.cts +2 -2
  80. package/dist/web.d.ts +2 -2
  81. package/dist/web.js +3 -3
  82. package/node/test/inherited.test.ts +75 -65
  83. package/node/test/tfheinit.test.ts +23 -8
  84. package/package.json +6 -6
  85. package/web/test/client.web.test.ts +5 -1
  86. package/web/test/inherited.web.test.ts +75 -65
  87. package/web/test/tfheinit.web.test.ts +14 -5
  88. package/web/test/worker.config.web.test.ts +38 -23
  89. package/web/test/worker.output.web.test.ts +25 -24
  90. package/core/encrypt/encryptUtils.ts +0 -67
  91. package/core/permits.ts +0 -216
  92. package/core/test/permits.test.ts +0 -596
  93. package/dist/chunk-VB62WYPL.js +0 -978
  94. package/dist/permit-DnVMDT5h.d.cts +0 -376
  95. package/dist/permit-DnVMDT5h.d.ts +0 -376
  96. package/dist/permits.cjs +0 -1026
  97. package/dist/permits.d.cts +0 -353
  98. package/dist/permits.d.ts +0 -353
  99. package/dist/permits.js +0 -2
  100. package/permits/index.ts +0 -68
  101. package/permits/permit.ts +0 -385
  102. package/permits/sealing.ts +0 -131
  103. package/permits/signature.ts +0 -79
  104. package/permits/store.ts +0 -157
  105. package/permits/test/localstorage.test.ts +0 -113
  106. package/permits/test/permit.test.ts +0 -557
  107. package/permits/test/sealing.test.ts +0 -84
  108. package/permits/test/store.test.ts +0 -88
  109. package/permits/test/validation.test.ts +0 -361
  110. package/permits/test-utils.ts +0 -28
  111. package/permits/types.ts +0 -204
  112. package/permits/validation.ts +0 -327
  113. /package/{permits → acps}/utils.ts +0 -0
@@ -0,0 +1,480 @@
1
+ import { A as ACP, V as ValidationResult, a as ACPPublic, b as ACPSignaturePrimaryType, E as EIP712Types, c as EIP712Message, S as SerializedACP } from './acp-Wi6isVQI.cjs';
2
+ export { v as ACPHashFields, e as ACPMetadata, o as ACPOf, m as ACPPrivate, r as ACPScope, t as ACPScopeOptions, n as ACPType, i as ACPUtils, C as CreateSelfACPOptions, d as CreateSharingACPOptions, h as EIP712Domain, l as EIP712Type, k as EthEncryptedData, w as Expand, G as GenerateSealingKey, I as ImportACPOptions, I as ImportSharedACPOptions, g as IncomingShare, R as RecipientACP, j as SealingKeyPair, p as SelfACP, C as SelfACPOptions, f as SharedACP, q as SharingACP, d as SharingACPOptions, s as seal, u as unsealWithPrivateKey } from './acp-Wi6isVQI.cjs';
3
+ import { z } from 'zod';
4
+ import * as zustand_middleware from 'zustand/middleware';
5
+ import * as zustand_vanilla from 'zustand/vanilla';
6
+ import 'viem';
7
+
8
+ declare const addressSchema: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
9
+ declare const addressNotZeroSchema: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
10
+ declare const bytesSchema: z.ZodCustom<`0x${string}`, `0x${string}`>;
11
+ declare const bytesNotEmptySchema: z.ZodCustom<`0x${string}`, `0x${string}`>;
12
+ /** (scope) ciphertext handles — bytes32 hex strings */
13
+ declare const handlesSchema: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodType<`0x${string}`, unknown, z.core.$ZodTypeInternals<`0x${string}`, unknown>>>>>;
14
+ /** (scope) contract addresses */
15
+ declare const contractsSchema: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>>;
16
+ /**
17
+ * Validator for self acp creation options
18
+ */
19
+ declare const SelfACPOptionsValidator: z.ZodPipe<z.ZodObject<{
20
+ type: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"self">>>;
21
+ issuer: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
22
+ name: z.ZodDefault<z.ZodOptional<z.ZodString>>;
23
+ expiration: z.ZodDefault<z.ZodOptional<z.ZodInt>>;
24
+ recipient: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>;
25
+ revokerData: z.ZodDefault<z.ZodOptional<z.ZodInt>>;
26
+ revokerContract: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>;
27
+ scope: z.ZodOptional<z.ZodInt>;
28
+ contracts: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>>;
29
+ handles: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodType<`0x${string}`, unknown, z.core.$ZodTypeInternals<`0x${string}`, unknown>>>>>;
30
+ issuerSignature: z.ZodDefault<z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>>;
31
+ recipientSignature: z.ZodDefault<z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>>;
32
+ }, z.core.$strip>, z.ZodTransform<{
33
+ type: "self";
34
+ issuer: `0x${string}`;
35
+ name: string;
36
+ expiration: number;
37
+ recipient: `0x${string}`;
38
+ revokerData: number;
39
+ revokerContract: `0x${string}`;
40
+ contracts: `0x${string}`[];
41
+ handles: `0x${string}`[];
42
+ issuerSignature: `0x${string}`;
43
+ recipientSignature: `0x${string}`;
44
+ scope?: number | undefined;
45
+ } & {
46
+ scope: number;
47
+ }, {
48
+ type: "self";
49
+ issuer: `0x${string}`;
50
+ name: string;
51
+ expiration: number;
52
+ recipient: `0x${string}`;
53
+ revokerData: number;
54
+ revokerContract: `0x${string}`;
55
+ contracts: `0x${string}`[];
56
+ handles: `0x${string}`[];
57
+ issuerSignature: `0x${string}`;
58
+ recipientSignature: `0x${string}`;
59
+ scope?: number | undefined;
60
+ }>>;
61
+ /**
62
+ * Validator for fully formed self acps
63
+ */
64
+ declare const SelfACPValidator: z.ZodObject<{
65
+ name: z.ZodDefault<z.ZodOptional<z.ZodString>>;
66
+ type: z.ZodEnum<{
67
+ self: "self";
68
+ sharing: "sharing";
69
+ recipient: "recipient";
70
+ }>;
71
+ issuer: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
72
+ expiration: z.ZodDefault<z.ZodOptional<z.ZodInt>>;
73
+ recipient: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>;
74
+ revokerData: z.ZodDefault<z.ZodOptional<z.ZodInt>>;
75
+ revokerContract: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>;
76
+ scope: z.ZodDefault<z.ZodOptional<z.ZodInt>>;
77
+ contracts: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>>;
78
+ handles: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodType<`0x${string}`, unknown, z.core.$ZodTypeInternals<`0x${string}`, unknown>>>>>;
79
+ issuerSignature: z.ZodDefault<z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>>;
80
+ recipientSignature: z.ZodDefault<z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>>;
81
+ sealingPrivateKey: z.ZodOptional<z.ZodString>;
82
+ sealingKey: z.ZodOptional<z.ZodString>;
83
+ }, z.core.$strip>;
84
+ /**
85
+ * Validator for sharing acp creation options
86
+ */
87
+ declare const SharingACPOptionsValidator: z.ZodPipe<z.ZodObject<{
88
+ type: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"sharing">>>;
89
+ issuer: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
90
+ recipient: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
91
+ name: z.ZodDefault<z.ZodOptional<z.ZodString>>;
92
+ expiration: z.ZodDefault<z.ZodOptional<z.ZodInt>>;
93
+ revokerData: z.ZodDefault<z.ZodOptional<z.ZodInt>>;
94
+ revokerContract: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>;
95
+ scope: z.ZodOptional<z.ZodInt>;
96
+ contracts: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>>;
97
+ handles: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodType<`0x${string}`, unknown, z.core.$ZodTypeInternals<`0x${string}`, unknown>>>>>;
98
+ issuerSignature: z.ZodDefault<z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>>;
99
+ recipientSignature: z.ZodDefault<z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>>;
100
+ }, z.core.$strip>, z.ZodTransform<{
101
+ type: "sharing";
102
+ issuer: `0x${string}`;
103
+ recipient: `0x${string}`;
104
+ name: string;
105
+ expiration: number;
106
+ revokerData: number;
107
+ revokerContract: `0x${string}`;
108
+ contracts: `0x${string}`[];
109
+ handles: `0x${string}`[];
110
+ issuerSignature: `0x${string}`;
111
+ recipientSignature: `0x${string}`;
112
+ scope?: number | undefined;
113
+ } & {
114
+ scope: number;
115
+ }, {
116
+ type: "sharing";
117
+ issuer: `0x${string}`;
118
+ recipient: `0x${string}`;
119
+ name: string;
120
+ expiration: number;
121
+ revokerData: number;
122
+ revokerContract: `0x${string}`;
123
+ contracts: `0x${string}`[];
124
+ handles: `0x${string}`[];
125
+ issuerSignature: `0x${string}`;
126
+ recipientSignature: `0x${string}`;
127
+ scope?: number | undefined;
128
+ }>>;
129
+ /**
130
+ * Validator for fully formed sharing acps
131
+ */
132
+ declare const SharingACPValidator: z.ZodObject<{
133
+ name: z.ZodDefault<z.ZodOptional<z.ZodString>>;
134
+ type: z.ZodEnum<{
135
+ self: "self";
136
+ sharing: "sharing";
137
+ recipient: "recipient";
138
+ }>;
139
+ issuer: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
140
+ expiration: z.ZodDefault<z.ZodOptional<z.ZodInt>>;
141
+ recipient: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>;
142
+ revokerData: z.ZodDefault<z.ZodOptional<z.ZodInt>>;
143
+ revokerContract: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>;
144
+ scope: z.ZodDefault<z.ZodOptional<z.ZodInt>>;
145
+ contracts: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>>;
146
+ handles: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodType<`0x${string}`, unknown, z.core.$ZodTypeInternals<`0x${string}`, unknown>>>>>;
147
+ issuerSignature: z.ZodDefault<z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>>;
148
+ recipientSignature: z.ZodDefault<z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>>;
149
+ sealingPrivateKey: z.ZodOptional<z.ZodString>;
150
+ sealingKey: z.ZodOptional<z.ZodString>;
151
+ }, z.core.$strip>;
152
+ /**
153
+ * Validator for import acp creation options (recipient receiving shared acp)
154
+ */
155
+ declare const ImportACPOptionsValidator: z.ZodPipe<z.ZodObject<{
156
+ type: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"recipient">>>;
157
+ issuer: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
158
+ recipient: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
159
+ name: z.ZodDefault<z.ZodOptional<z.ZodString>>;
160
+ expiration: z.ZodInt;
161
+ revokerData: z.ZodDefault<z.ZodOptional<z.ZodInt>>;
162
+ revokerContract: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>;
163
+ scope: z.ZodOptional<z.ZodInt>;
164
+ contracts: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>>;
165
+ handles: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodType<`0x${string}`, unknown, z.core.$ZodTypeInternals<`0x${string}`, unknown>>>>>;
166
+ issuerSignature: z.ZodCustom<`0x${string}`, `0x${string}`>;
167
+ recipientSignature: z.ZodDefault<z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>>;
168
+ }, z.core.$strip>, z.ZodTransform<{
169
+ type: "recipient";
170
+ issuer: `0x${string}`;
171
+ recipient: `0x${string}`;
172
+ name: string;
173
+ expiration: number;
174
+ revokerData: number;
175
+ revokerContract: `0x${string}`;
176
+ contracts: `0x${string}`[];
177
+ handles: `0x${string}`[];
178
+ issuerSignature: `0x${string}`;
179
+ recipientSignature: `0x${string}`;
180
+ scope?: number | undefined;
181
+ } & {
182
+ scope: number;
183
+ }, {
184
+ type: "recipient";
185
+ issuer: `0x${string}`;
186
+ recipient: `0x${string}`;
187
+ name: string;
188
+ expiration: number;
189
+ revokerData: number;
190
+ revokerContract: `0x${string}`;
191
+ contracts: `0x${string}`[];
192
+ handles: `0x${string}`[];
193
+ issuerSignature: `0x${string}`;
194
+ recipientSignature: `0x${string}`;
195
+ scope?: number | undefined;
196
+ }>>;
197
+ /**
198
+ * Validator for fully formed import/recipient acps
199
+ */
200
+ declare const ImportACPValidator: z.ZodObject<{
201
+ name: z.ZodDefault<z.ZodOptional<z.ZodString>>;
202
+ type: z.ZodEnum<{
203
+ self: "self";
204
+ sharing: "sharing";
205
+ recipient: "recipient";
206
+ }>;
207
+ issuer: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
208
+ expiration: z.ZodDefault<z.ZodOptional<z.ZodInt>>;
209
+ recipient: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>;
210
+ revokerData: z.ZodDefault<z.ZodOptional<z.ZodInt>>;
211
+ revokerContract: z.ZodDefault<z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>;
212
+ scope: z.ZodDefault<z.ZodOptional<z.ZodInt>>;
213
+ contracts: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>>>>;
214
+ handles: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodType<`0x${string}`, unknown, z.core.$ZodTypeInternals<`0x${string}`, unknown>>>>>;
215
+ issuerSignature: z.ZodDefault<z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>>;
216
+ recipientSignature: z.ZodDefault<z.ZodOptional<z.ZodCustom<`0x${string}`, `0x${string}`>>>;
217
+ sealingPrivateKey: z.ZodOptional<z.ZodString>;
218
+ sealingKey: z.ZodOptional<z.ZodString>;
219
+ }, z.core.$strip>;
220
+ /**
221
+ * Validates self acp creation options
222
+ */
223
+ declare const validateSelfACPOptions: (options: any) => {
224
+ type: "self";
225
+ issuer: `0x${string}`;
226
+ name: string;
227
+ expiration: number;
228
+ recipient: `0x${string}`;
229
+ revokerData: number;
230
+ revokerContract: `0x${string}`;
231
+ contracts: `0x${string}`[];
232
+ handles: `0x${string}`[];
233
+ issuerSignature: `0x${string}`;
234
+ recipientSignature: `0x${string}`;
235
+ scope?: number | undefined;
236
+ } & {
237
+ scope: number;
238
+ };
239
+ /**
240
+ * Validates sharing acp creation options
241
+ */
242
+ declare const validateSharingACPOptions: (options: any) => {
243
+ type: "sharing";
244
+ issuer: `0x${string}`;
245
+ recipient: `0x${string}`;
246
+ name: string;
247
+ expiration: number;
248
+ revokerData: number;
249
+ revokerContract: `0x${string}`;
250
+ contracts: `0x${string}`[];
251
+ handles: `0x${string}`[];
252
+ issuerSignature: `0x${string}`;
253
+ recipientSignature: `0x${string}`;
254
+ scope?: number | undefined;
255
+ } & {
256
+ scope: number;
257
+ };
258
+ /**
259
+ * Validates import acp creation options
260
+ */
261
+ declare const validateImportACPOptions: (options: any) => {
262
+ type: "recipient";
263
+ issuer: `0x${string}`;
264
+ recipient: `0x${string}`;
265
+ name: string;
266
+ expiration: number;
267
+ revokerData: number;
268
+ revokerContract: `0x${string}`;
269
+ contracts: `0x${string}`[];
270
+ handles: `0x${string}`[];
271
+ issuerSignature: `0x${string}`;
272
+ recipientSignature: `0x${string}`;
273
+ scope?: number | undefined;
274
+ } & {
275
+ scope: number;
276
+ };
277
+ /**
278
+ * Validates a fully formed self acp
279
+ */
280
+ declare const validateSelfACP: (acp: any) => {
281
+ name: string;
282
+ type: "self" | "sharing" | "recipient";
283
+ issuer: `0x${string}`;
284
+ expiration: number;
285
+ recipient: `0x${string}`;
286
+ revokerData: number;
287
+ revokerContract: `0x${string}`;
288
+ scope: number;
289
+ contracts: `0x${string}`[];
290
+ handles: `0x${string}`[];
291
+ issuerSignature: `0x${string}`;
292
+ recipientSignature: `0x${string}`;
293
+ sealingPrivateKey?: string | undefined;
294
+ sealingKey?: string | undefined;
295
+ };
296
+ /**
297
+ * Validates a fully formed sharing acp
298
+ */
299
+ declare const validateSharingACP: (acp: any) => {
300
+ name: string;
301
+ type: "self" | "sharing" | "recipient";
302
+ issuer: `0x${string}`;
303
+ expiration: number;
304
+ recipient: `0x${string}`;
305
+ revokerData: number;
306
+ revokerContract: `0x${string}`;
307
+ scope: number;
308
+ contracts: `0x${string}`[];
309
+ handles: `0x${string}`[];
310
+ issuerSignature: `0x${string}`;
311
+ recipientSignature: `0x${string}`;
312
+ sealingPrivateKey?: string | undefined;
313
+ sealingKey?: string | undefined;
314
+ };
315
+ /**
316
+ * Validates a fully formed import/recipient acp
317
+ */
318
+ declare const validateImportACP: (acp: any) => {
319
+ name: string;
320
+ type: "self" | "sharing" | "recipient";
321
+ issuer: `0x${string}`;
322
+ expiration: number;
323
+ recipient: `0x${string}`;
324
+ revokerData: number;
325
+ revokerContract: `0x${string}`;
326
+ scope: number;
327
+ contracts: `0x${string}`[];
328
+ handles: `0x${string}`[];
329
+ issuerSignature: `0x${string}`;
330
+ recipientSignature: `0x${string}`;
331
+ sealingPrivateKey?: string | undefined;
332
+ sealingKey?: string | undefined;
333
+ };
334
+ /**
335
+ * Simple validation functions for common checks
336
+ */
337
+ declare const ValidationUtils: {
338
+ /**
339
+ * Check if acp is expired
340
+ */
341
+ isExpired: (acp: ACP) => boolean;
342
+ /**
343
+ * Check if acp is signed by the active party
344
+ */
345
+ isSigned: (acp: ACP) => boolean;
346
+ /**
347
+ * Checks that an ACP is signed and not expired.
348
+ */
349
+ isSignedAndNotExpired: (acp: ACP) => ValidationResult;
350
+ /**
351
+ * Asserts that an ACP is signed and not expired.
352
+ *
353
+ * Throws `Error` with message:
354
+ * - `ACP is expired`
355
+ * - `ACP is not signed`
356
+ */
357
+ assertSignedAndNotExpired: (acp: ACP) => void;
358
+ isValid: (acp: ACP) => ValidationResult;
359
+ };
360
+
361
+ declare const ACPSignatureAllFields: readonly [{
362
+ readonly name: "issuer";
363
+ readonly type: "address";
364
+ }, {
365
+ readonly name: "expiration";
366
+ readonly type: "uint64";
367
+ }, {
368
+ readonly name: "recipient";
369
+ readonly type: "address";
370
+ }, {
371
+ readonly name: "revokerData";
372
+ readonly type: "uint256";
373
+ }, {
374
+ readonly name: "revokerContract";
375
+ readonly type: "address";
376
+ }, {
377
+ readonly name: "scope";
378
+ readonly type: "uint8";
379
+ }, {
380
+ readonly name: "contracts";
381
+ readonly type: "address[]";
382
+ }, {
383
+ readonly name: "handles";
384
+ readonly type: "bytes32[]";
385
+ }, {
386
+ readonly name: "sealingKey";
387
+ readonly type: "bytes32";
388
+ }, {
389
+ readonly name: "issuerSignature";
390
+ readonly type: "bytes";
391
+ }];
392
+ type ACPSignatureFieldOption = (typeof ACPSignatureAllFields)[number]['name'];
393
+ declare const SignatureTypes: {
394
+ readonly ACPIssuerSelf: ("recipient" | "issuer" | "expiration" | "revokerData" | "revokerContract" | "scope" | "contracts" | "handles" | "sealingKey")[];
395
+ readonly ACPIssuerShared: ("recipient" | "issuer" | "expiration" | "revokerData" | "revokerContract" | "scope" | "contracts" | "handles")[];
396
+ readonly ACPRecipient: ("sealingKey" | "issuerSignature")[];
397
+ };
398
+ /**
399
+ * Get signature types and message for EIP712 signing
400
+ */
401
+ declare const getSignatureTypesAndMessage: <T extends ACPSignatureFieldOption>(primaryType: ACPSignaturePrimaryType, fields: T[] | readonly T[], values: Pick<ACPPublic, T> & Partial<ACPPublic>) => {
402
+ types: EIP712Types;
403
+ primaryType: string;
404
+ message: EIP712Message;
405
+ };
406
+ /**
407
+ * Signature utilities for ACP operations
408
+ */
409
+ declare const SignatureUtils: {
410
+ /**
411
+ * Get signature parameters for an ACP
412
+ */
413
+ getSignatureParams: (acp: ACPPublic, primaryType: ACPSignaturePrimaryType) => {
414
+ types: EIP712Types;
415
+ primaryType: string;
416
+ message: EIP712Message;
417
+ };
418
+ /**
419
+ * Determine the required signature type based on acp type
420
+ */
421
+ getPrimaryType: (acpType: "self" | "sharing" | "recipient") => ACPSignaturePrimaryType;
422
+ };
423
+
424
+ type ChainRecord<T> = Record<number, T>;
425
+ type AccountRecord<T> = Record<string, T>;
426
+ type HashRecord<T> = Record<string, T>;
427
+ type ACPsStore = {
428
+ acps: ChainRecord<AccountRecord<HashRecord<SerializedACP | undefined>>>;
429
+ activeACPHash: ChainRecord<AccountRecord<string | undefined>>;
430
+ };
431
+ declare const ACP_STORE_DEFAULTS: ACPsStore;
432
+ declare const _acpStore: Omit<zustand_vanilla.StoreApi<ACPsStore>, "setState" | "persist"> & {
433
+ setState(partial: ACPsStore | Partial<ACPsStore> | ((state: ACPsStore) => ACPsStore | Partial<ACPsStore>), replace?: false | undefined): unknown;
434
+ setState(state: ACPsStore | ((state: ACPsStore) => ACPsStore), replace: true): unknown;
435
+ persist: {
436
+ setOptions: (options: Partial<zustand_middleware.PersistOptions<ACPsStore, ACPsStore, unknown>>) => void;
437
+ clearStorage: () => void;
438
+ rehydrate: () => Promise<void> | void;
439
+ hasHydrated: () => boolean;
440
+ onHydrate: (fn: (state: ACPsStore) => void) => () => void;
441
+ onFinishHydration: (fn: (state: ACPsStore) => void) => () => void;
442
+ getOptions: () => Partial<zustand_middleware.PersistOptions<ACPsStore, ACPsStore, unknown>>;
443
+ };
444
+ };
445
+ declare const clearStaleStore: () => void;
446
+ declare const getACP: (chainId: number | undefined, account: string | undefined, hash: string | undefined) => ACP | undefined;
447
+ declare const getActiveACP: (chainId: number | undefined, account: string | undefined) => ACP | undefined;
448
+ declare const getACPs: (chainId: number | undefined, account: string | undefined) => Record<string, ACP>;
449
+ declare const setACP: (chainId: number, account: string, acp: ACP) => void;
450
+ declare const removeACP: (chainId: number, account: string, hash: string) => void;
451
+ declare const getActiveACPHash: (chainId: number | undefined, account: string | undefined) => string | undefined;
452
+ declare const setActiveACPHash: (chainId: number, account: string, hash: string) => void;
453
+ declare const removeActiveACPHash: (chainId: number, account: string) => void;
454
+ declare const resetStore: () => void;
455
+ declare const acpStore: {
456
+ store: Omit<zustand_vanilla.StoreApi<ACPsStore>, "setState" | "persist"> & {
457
+ setState(partial: ACPsStore | Partial<ACPsStore> | ((state: ACPsStore) => ACPsStore | Partial<ACPsStore>), replace?: false | undefined): unknown;
458
+ setState(state: ACPsStore | ((state: ACPsStore) => ACPsStore), replace: true): unknown;
459
+ persist: {
460
+ setOptions: (options: Partial<zustand_middleware.PersistOptions<ACPsStore, ACPsStore, unknown>>) => void;
461
+ clearStorage: () => void;
462
+ rehydrate: () => Promise<void> | void;
463
+ hasHydrated: () => boolean;
464
+ onHydrate: (fn: (state: ACPsStore) => void) => () => void;
465
+ onFinishHydration: (fn: (state: ACPsStore) => void) => () => void;
466
+ getOptions: () => Partial<zustand_middleware.PersistOptions<ACPsStore, ACPsStore, unknown>>;
467
+ };
468
+ };
469
+ getACP: (chainId: number | undefined, account: string | undefined, hash: string | undefined) => ACP | undefined;
470
+ getActiveACP: (chainId: number | undefined, account: string | undefined) => ACP | undefined;
471
+ getACPs: (chainId: number | undefined, account: string | undefined) => Record<string, ACP>;
472
+ setACP: (chainId: number, account: string, acp: ACP) => void;
473
+ removeACP: (chainId: number, account: string, hash: string) => void;
474
+ getActiveACPHash: (chainId: number | undefined, account: string | undefined) => string | undefined;
475
+ setActiveACPHash: (chainId: number, account: string, hash: string) => void;
476
+ removeActiveACPHash: (chainId: number, account: string) => void;
477
+ resetStore: () => void;
478
+ };
479
+
480
+ export { ACP, ACPPublic, ACPSignaturePrimaryType, ACP_STORE_DEFAULTS, EIP712Message, EIP712Types, ImportACPOptionsValidator, ImportACPValidator, SelfACPOptionsValidator, SelfACPValidator, SerializedACP, SharingACPOptionsValidator, SharingACPValidator, SignatureTypes, SignatureUtils, ValidationResult, ValidationUtils, _acpStore, acpStore, addressNotZeroSchema, addressSchema, bytesNotEmptySchema, bytesSchema, clearStaleStore, contractsSchema, getACP, getACPs, getActiveACP, getActiveACPHash, getSignatureTypesAndMessage, handlesSchema, removeACP, removeActiveACPHash, resetStore, setACP, setActiveACPHash, validateImportACP, validateImportACPOptions, validateSelfACP, validateSelfACPOptions, validateSharingACP, validateSharingACPOptions };