@cofhe/sdk 0.6.0 → 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 (114) hide show
  1. package/CHANGELOG.md +49 -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/debug.ts +72 -0
  27. package/core/decrypt/MockThresholdNetworkAbi.ts +20 -11
  28. package/core/decrypt/apiError.ts +104 -0
  29. package/core/decrypt/cofheMocksDecryptForTx.ts +11 -11
  30. package/core/decrypt/cofheMocksDecryptForView.ts +7 -7
  31. package/core/decrypt/decryptForTxBuilder.ts +102 -102
  32. package/core/decrypt/decryptForViewBuilder.ts +90 -90
  33. package/core/decrypt/submitRetry.ts +38 -30
  34. package/core/decrypt/tnDecryptV1.ts +5 -5
  35. package/core/decrypt/tnDecryptV2.ts +45 -34
  36. package/core/decrypt/tnSealOutputV1.ts +4 -3
  37. package/core/decrypt/tnSealOutputV2.ts +44 -31
  38. package/core/encrypt/cofheMocksZkVerifySign.ts +59 -74
  39. package/core/encrypt/encryptInputsBuilder.ts +86 -52
  40. package/core/encrypt/zkPackProveVerify.ts +25 -18
  41. package/core/error.ts +34 -6
  42. package/core/index.ts +14 -14
  43. package/core/test/acpDefaults.test.ts +52 -0
  44. package/core/test/acps.test.ts +596 -0
  45. package/core/test/apiError.test.ts +130 -0
  46. package/core/test/client.test.ts +22 -19
  47. package/core/test/config.test.ts +25 -5
  48. package/core/test/decrypt.test.ts +40 -35
  49. package/core/test/decryptBuilders.test.ts +68 -68
  50. package/core/test/decryptErrorCodes.test.ts +217 -0
  51. package/core/test/encryptInputsBuilder.test.ts +72 -41
  52. package/core/test/pollCallbacks.test.ts +89 -18
  53. package/core/test/stagingRedirect.ts +18 -0
  54. package/core/test/submitRetry.test.ts +182 -0
  55. package/core/types.ts +9 -69
  56. package/dist/acp-Wi6isVQI.d.cts +407 -0
  57. package/dist/acp-Wi6isVQI.d.ts +407 -0
  58. package/dist/acps.cjs +1081 -0
  59. package/dist/acps.d.cts +480 -0
  60. package/dist/acps.d.ts +480 -0
  61. package/dist/acps.js +2 -0
  62. package/dist/chains.cjs +14 -1
  63. package/dist/chains.d.cts +30 -1
  64. package/dist/chains.d.ts +30 -1
  65. package/dist/chains.js +1 -1
  66. package/dist/{chunk-PE5V5CCV.js → chunk-43USWPEH.js} +1000 -604
  67. package/dist/{chunk-MTRAXQXC.js → chunk-N6IDQRRU.js} +14 -2
  68. package/dist/chunk-Q7CBWGQX.js +1029 -0
  69. package/dist/{clientTypes-CyUvRRzA.d.ts → clientTypes-BN3nbzYM.d.ts} +342 -165
  70. package/dist/{clientTypes-BDy1qIBu.d.cts → clientTypes-CYZjFznO.d.cts} +342 -165
  71. package/dist/core.cjs +1431 -1026
  72. package/dist/core.d.cts +55 -10
  73. package/dist/core.d.ts +55 -10
  74. package/dist/core.js +3 -3
  75. package/dist/node.cjs +1356 -976
  76. package/dist/node.d.cts +2 -2
  77. package/dist/node.d.ts +2 -2
  78. package/dist/node.js +3 -3
  79. package/dist/web.cjs +1356 -976
  80. package/dist/web.d.cts +2 -2
  81. package/dist/web.d.ts +2 -2
  82. package/dist/web.js +3 -3
  83. package/node/test/inherited.test.ts +75 -65
  84. package/node/test/tfheinit.test.ts +23 -8
  85. package/package.json +6 -6
  86. package/web/test/client.web.test.ts +5 -1
  87. package/web/test/inherited.web.test.ts +75 -65
  88. package/web/test/tfheinit.web.test.ts +14 -5
  89. package/web/test/worker.config.web.test.ts +38 -23
  90. package/web/test/worker.output.web.test.ts +25 -24
  91. package/core/encrypt/encryptUtils.ts +0 -67
  92. package/core/permits.ts +0 -206
  93. package/core/test/permits.test.ts +0 -534
  94. package/dist/chunk-VB62WYPL.js +0 -978
  95. package/dist/permit-DnVMDT5h.d.cts +0 -376
  96. package/dist/permit-DnVMDT5h.d.ts +0 -376
  97. package/dist/permits.cjs +0 -1026
  98. package/dist/permits.d.cts +0 -353
  99. package/dist/permits.d.ts +0 -353
  100. package/dist/permits.js +0 -2
  101. package/permits/index.ts +0 -68
  102. package/permits/permit.ts +0 -385
  103. package/permits/sealing.ts +0 -131
  104. package/permits/signature.ts +0 -79
  105. package/permits/store.ts +0 -157
  106. package/permits/test/localstorage.test.ts +0 -113
  107. package/permits/test/permit.test.ts +0 -557
  108. package/permits/test/sealing.test.ts +0 -84
  109. package/permits/test/store.test.ts +0 -88
  110. package/permits/test/validation.test.ts +0 -361
  111. package/permits/test-utils.ts +0 -28
  112. package/permits/types.ts +0 -204
  113. package/permits/validation.ts +0 -327
  114. /package/{permits → acps}/utils.ts +0 -0
@@ -0,0 +1,1029 @@
1
+ import { TASK_MANAGER_ADDRESS } from './chunk-ESMZCFJY.js';
2
+ import { isAddress, getAddress, zeroAddress, isHex, keccak256, toHex, BaseError, ContractFunctionRevertedError, decodeErrorResult, parseAbi } from 'viem';
3
+ import nacl from 'tweetnacl';
4
+ import { z } from 'zod';
5
+ import { createStore } from 'zustand/vanilla';
6
+ import { persist } from 'zustand/middleware';
7
+ import { produce } from 'immer';
8
+
9
+ // acps/utils.ts
10
+ var fromHexString = (hexString) => {
11
+ const cleanString = hexString.length % 2 === 1 ? `0${hexString}` : hexString;
12
+ const arr = cleanString.replace(/^0x/, "").match(/.{1,2}/g);
13
+ if (!arr)
14
+ return new Uint8Array();
15
+ return new Uint8Array(arr.map((byte) => parseInt(byte, 16)));
16
+ };
17
+ var toHexString = (bytes) => bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, "0"), "");
18
+ function toBigInt(value) {
19
+ if (typeof value === "string") {
20
+ return BigInt(value);
21
+ } else if (typeof value === "number") {
22
+ return BigInt(value);
23
+ } else if (typeof value === "object") {
24
+ return BigInt("0x" + toHexString(value));
25
+ } else {
26
+ return value;
27
+ }
28
+ }
29
+ function toBeArray(value) {
30
+ const bigIntValue = typeof value === "number" ? BigInt(value) : value;
31
+ const hex = bigIntValue.toString(16);
32
+ const paddedHex = hex.length % 2 === 0 ? hex : "0" + hex;
33
+ return fromHexString(paddedHex);
34
+ }
35
+ function isString(value) {
36
+ if (typeof value !== "string") {
37
+ throw new Error(`Expected value which is \`string\`, received value of type \`${typeof value}\`.`);
38
+ }
39
+ }
40
+ function isNumber(value) {
41
+ const is = typeof value === "number" && !Number.isNaN(value);
42
+ if (!is) {
43
+ throw new Error(`Expected value which is \`number\`, received value of type \`${typeof value}\`.`);
44
+ }
45
+ }
46
+ function isBigIntOrNumber(value) {
47
+ const is = typeof value === "bigint";
48
+ if (!is) {
49
+ try {
50
+ isNumber(value);
51
+ } catch (e) {
52
+ throw new Error(`Value ${value} is not a number or bigint: ${typeof value}`);
53
+ }
54
+ }
55
+ }
56
+
57
+ // acps/sealing.ts
58
+ var KEY_HEX_LENGTH = 64;
59
+ var GenerateSealingKey = () => {
60
+ const sodiumKeypair = nacl.box.keyPair();
61
+ return {
62
+ privateKey: `0x${toHexString(sodiumKeypair.secretKey)}`,
63
+ publicKey: `0x${toHexString(sodiumKeypair.publicKey)}`
64
+ };
65
+ };
66
+ var seal = (value, publicKey) => {
67
+ isString(publicKey);
68
+ isBigIntOrNumber(value);
69
+ assertKeyLength(publicKey, "Public");
70
+ const ephemeralKeyPair = nacl.box.keyPair();
71
+ const nonce = nacl.randomBytes(nacl.box.nonceLength);
72
+ const encryptedMessage = nacl.box(toBeArray(value), nonce, fromHexString(publicKey), ephemeralKeyPair.secretKey);
73
+ return {
74
+ data: encryptedMessage,
75
+ public_key: ephemeralKeyPair.publicKey,
76
+ nonce
77
+ };
78
+ };
79
+ var unsealWithPrivateKey = (privateKey, parsedData) => {
80
+ assertKeyLength(privateKey, "Private");
81
+ const nonce = parsedData.nonce instanceof Uint8Array ? parsedData.nonce : new Uint8Array(parsedData.nonce);
82
+ const ephemPublicKey = parsedData.public_key instanceof Uint8Array ? parsedData.public_key : new Uint8Array(parsedData.public_key);
83
+ const dataToDecrypt = parsedData.data instanceof Uint8Array ? parsedData.data : new Uint8Array(parsedData.data);
84
+ const decryptedMessage = nacl.box.open(dataToDecrypt, nonce, ephemPublicKey, fromHexString(privateKey));
85
+ if (!decryptedMessage) {
86
+ throw new Error("Failed to decrypt message");
87
+ }
88
+ return toBigInt(decryptedMessage);
89
+ };
90
+ var assertKeyLength = (key, kind) => {
91
+ const bare = key.startsWith("0x") ? key.slice(2) : key;
92
+ if (bare.length !== KEY_HEX_LENGTH) {
93
+ throw new Error(`${kind} key must be of length ${KEY_HEX_LENGTH}`);
94
+ }
95
+ };
96
+ var ACPScope = {
97
+ Global: 0,
98
+ Contract: 1,
99
+ Handles: 2
100
+ };
101
+ var addressSchema = z.string().refine((val) => isAddress(val), {
102
+ error: "Invalid address"
103
+ }).transform((val) => getAddress(val));
104
+ var addressNotZeroSchema = addressSchema.refine((val) => val !== zeroAddress, {
105
+ error: "Must not be zeroAddress"
106
+ });
107
+ var bytesSchema = z.custom(
108
+ (val) => {
109
+ return typeof val === "string" && isHex(val);
110
+ },
111
+ {
112
+ message: "Invalid hex value"
113
+ }
114
+ );
115
+ var bytesNotEmptySchema = bytesSchema.refine((val) => val !== "0x", {
116
+ error: "Must not be empty"
117
+ });
118
+ var DEFAULT_EXPIRATION_FN = () => Math.round(Date.now() / 1e3) + 7 * 24 * 60 * 60;
119
+ var handlesSchema = z.array(z.string().regex(/^0x[0-9a-fA-F]{64}$/, "Invalid handle: expected 32-byte hex")).optional().default([]);
120
+ var contractsSchema = z.array(addressSchema).optional().default([]);
121
+ var SCOPE_GLOBAL = 0;
122
+ var SCOPE_CONTRACT = 1;
123
+ var SCOPE_HANDLES = 2;
124
+ var ScopeConsistencyRefinement = [
125
+ (data) => data.scope === SCOPE_GLOBAL && data.contracts.length === 0 && data.handles.length === 0 || data.scope === SCOPE_CONTRACT && data.contracts.length > 0 && data.handles.length === 0 || data.scope === SCOPE_HANDLES && data.handles.length > 0 && data.contracts.length === 0,
126
+ {
127
+ error: "ACP scope :: arrays must match the scope mode (Global: both empty; Contract: contracts only; Handles: handles only)",
128
+ path: ["scope"]
129
+ }
130
+ ];
131
+ var withDerivedScope = (data) => ({
132
+ ...data,
133
+ scope: data.scope ?? (data.contracts.length > 0 ? SCOPE_CONTRACT : data.handles.length > 0 ? SCOPE_HANDLES : SCOPE_GLOBAL)
134
+ });
135
+ var zACPWithDefaults = z.object({
136
+ name: z.string().optional().default("Unnamed ACP"),
137
+ type: z.enum(["self", "sharing", "recipient"]),
138
+ issuer: addressNotZeroSchema,
139
+ expiration: z.int().optional().default(DEFAULT_EXPIRATION_FN),
140
+ recipient: addressSchema.optional().default(zeroAddress),
141
+ revokerData: z.int().optional().default(0),
142
+ revokerContract: addressSchema.optional().default(zeroAddress),
143
+ scope: z.int().min(0).max(2).optional().default(0),
144
+ contracts: contractsSchema,
145
+ handles: handlesSchema,
146
+ issuerSignature: bytesSchema.optional().default("0x"),
147
+ recipientSignature: bytesSchema.optional().default("0x")
148
+ });
149
+ var zACPWithSealingKeys = zACPWithDefaults.extend({
150
+ /** X25519 private key, 0x-prefixed 32-byte hex; never leaves the client */
151
+ sealingPrivateKey: z.string().regex(/^0x[0-9a-fA-F]{64}$/, "Invalid sealing private key").optional(),
152
+ sealingKey: z.string().regex(/^0x[0-9a-fA-F]{64}$/, "Invalid sealing key").optional()
153
+ });
154
+ var ExternalValidatorRefinement = [
155
+ (data) => data.revokerData !== 0 && data.revokerContract !== zeroAddress || data.revokerData === 0 && data.revokerContract === zeroAddress,
156
+ {
157
+ error: "ACP external revoker :: revokerData and revokerContract must either both be set or both be unset.",
158
+ path: ["revokerData", "revokerContract"]
159
+ }
160
+ ];
161
+ var RecipientRefinement = [
162
+ (data) => data.issuer !== data.recipient,
163
+ {
164
+ error: "Sharing acp :: issuer and recipient must not be the same",
165
+ path: ["issuer", "recipient"]
166
+ }
167
+ ];
168
+ var SelfACPOptionsValidator = z.object({
169
+ type: z.literal("self").optional().default("self"),
170
+ issuer: addressNotZeroSchema,
171
+ name: z.string().optional().default("Unnamed ACP"),
172
+ expiration: z.int().optional().default(DEFAULT_EXPIRATION_FN),
173
+ recipient: addressSchema.optional().default(zeroAddress),
174
+ revokerData: z.int().optional().default(0),
175
+ revokerContract: addressSchema.optional().default(zeroAddress),
176
+ scope: z.int().min(0).max(2).optional(),
177
+ contracts: contractsSchema,
178
+ handles: handlesSchema,
179
+ issuerSignature: bytesSchema.optional().default("0x"),
180
+ recipientSignature: bytesSchema.optional().default("0x")
181
+ }).refine(...ExternalValidatorRefinement).transform(withDerivedScope).refine(...ScopeConsistencyRefinement);
182
+ var SelfACPValidator = zACPWithSealingKeys.refine((data) => data.type === "self", {
183
+ error: "Type must be 'self'"
184
+ }).refine((data) => data.recipient === zeroAddress, {
185
+ error: "Recipient must be zeroAddress"
186
+ }).refine((data) => data.issuerSignature !== "0x", {
187
+ error: "IssuerSignature must be populated"
188
+ }).refine((data) => data.recipientSignature === "0x", {
189
+ error: "RecipientSignature must be empty"
190
+ }).refine(...ExternalValidatorRefinement);
191
+ var SharingACPOptionsValidator = z.object({
192
+ type: z.literal("sharing").optional().default("sharing"),
193
+ issuer: addressNotZeroSchema,
194
+ recipient: addressNotZeroSchema,
195
+ name: z.string().optional().default("Unnamed ACP"),
196
+ expiration: z.int().optional().default(DEFAULT_EXPIRATION_FN),
197
+ revokerData: z.int().optional().default(0),
198
+ revokerContract: addressSchema.optional().default(zeroAddress),
199
+ scope: z.int().min(0).max(2).optional(),
200
+ contracts: contractsSchema,
201
+ handles: handlesSchema,
202
+ issuerSignature: bytesSchema.optional().default("0x"),
203
+ recipientSignature: bytesSchema.optional().default("0x")
204
+ }).refine(...RecipientRefinement).refine(...ExternalValidatorRefinement).transform(withDerivedScope).refine(...ScopeConsistencyRefinement);
205
+ var SharingACPValidator = zACPWithSealingKeys.refine((data) => data.type === "sharing", {
206
+ error: "Type must be 'sharing'"
207
+ }).refine((data) => data.recipient !== zeroAddress, {
208
+ error: "Recipient must not be zeroAddress"
209
+ }).refine((data) => data.issuerSignature !== "0x", {
210
+ error: "IssuerSignature must be populated"
211
+ }).refine((data) => data.recipientSignature === "0x", {
212
+ error: "RecipientSignature must be empty"
213
+ }).refine(...ExternalValidatorRefinement);
214
+ var ImportACPOptionsValidator = z.object({
215
+ type: z.literal("recipient").optional().default("recipient"),
216
+ issuer: addressNotZeroSchema,
217
+ recipient: addressNotZeroSchema,
218
+ name: z.string().optional().default("Unnamed ACP"),
219
+ expiration: z.int(),
220
+ revokerData: z.int().optional().default(0),
221
+ revokerContract: addressSchema.optional().default(zeroAddress),
222
+ scope: z.int().min(0).max(2).optional(),
223
+ contracts: contractsSchema,
224
+ handles: handlesSchema,
225
+ issuerSignature: bytesNotEmptySchema,
226
+ recipientSignature: bytesSchema.optional().default("0x")
227
+ }).refine(...ExternalValidatorRefinement).transform(withDerivedScope).refine(...ScopeConsistencyRefinement);
228
+ var ImportACPValidator = zACPWithSealingKeys.refine((data) => data.type === "recipient", {
229
+ error: "Type must be 'recipient'"
230
+ }).refine((data) => data.recipient !== zeroAddress, {
231
+ error: "Recipient must not be zeroAddress"
232
+ }).refine((data) => data.issuerSignature !== "0x", {
233
+ error: "IssuerSignature must be populated"
234
+ }).refine((data) => data.recipientSignature !== "0x", {
235
+ error: "RecipientSignature must be populated"
236
+ }).refine(...ExternalValidatorRefinement);
237
+ var safeParseAndThrowFormatted = (schema, data, message) => {
238
+ const result = schema.safeParse(data);
239
+ if (!result.success) {
240
+ throw new Error(`${message}: ${z.prettifyError(result.error)}`, { cause: result.error });
241
+ }
242
+ return result.data;
243
+ };
244
+ var validateSelfACPOptions = (options) => {
245
+ return safeParseAndThrowFormatted(SelfACPOptionsValidator, options, "Invalid self acp options");
246
+ };
247
+ var validateSharingACPOptions = (options) => {
248
+ return safeParseAndThrowFormatted(SharingACPOptionsValidator, options, "Invalid sharing acp options");
249
+ };
250
+ var validateImportACPOptions = (options) => {
251
+ return safeParseAndThrowFormatted(ImportACPOptionsValidator, options, "Invalid import acp options");
252
+ };
253
+ var validateSelfACP = (acp) => {
254
+ return safeParseAndThrowFormatted(SelfACPValidator, acp, "Invalid self acp");
255
+ };
256
+ var validateSharingACP = (acp) => {
257
+ return safeParseAndThrowFormatted(SharingACPValidator, acp, "Invalid sharing acp");
258
+ };
259
+ var validateImportACP = (acp) => {
260
+ return safeParseAndThrowFormatted(ImportACPValidator, acp, "Invalid import acp");
261
+ };
262
+ var ValidationUtils = {
263
+ /**
264
+ * Check if acp is expired
265
+ */
266
+ isExpired: (acp) => {
267
+ return acp.expiration < Math.floor(Date.now() / 1e3);
268
+ },
269
+ /**
270
+ * Check if acp is signed by the active party
271
+ */
272
+ isSigned: (acp) => {
273
+ if (acp.type === "self" || acp.type === "sharing") {
274
+ return acp.issuerSignature !== "0x";
275
+ }
276
+ if (acp.type === "recipient") {
277
+ return acp.recipientSignature !== "0x";
278
+ }
279
+ return false;
280
+ },
281
+ /**
282
+ * Checks that an ACP is signed and not expired.
283
+ */
284
+ isSignedAndNotExpired: (acp) => {
285
+ if (ValidationUtils.isExpired(acp)) {
286
+ return { valid: false, error: "expired" };
287
+ }
288
+ if (!ValidationUtils.isSigned(acp)) {
289
+ return { valid: false, error: "not-signed" };
290
+ }
291
+ return { valid: true, error: null };
292
+ },
293
+ /**
294
+ * Asserts that an ACP is signed and not expired.
295
+ *
296
+ * Throws `Error` with message:
297
+ * - `ACP is expired`
298
+ * - `ACP is not signed`
299
+ */
300
+ assertSignedAndNotExpired: (acp) => {
301
+ const result = ValidationUtils.isSignedAndNotExpired(acp);
302
+ if (result.valid)
303
+ return;
304
+ if (result.error === "expired") {
305
+ throw new Error("ACP is expired");
306
+ }
307
+ if (result.error === "not-signed") {
308
+ throw new Error("ACP is not signed");
309
+ }
310
+ throw new Error("ACP is invalid");
311
+ },
312
+ isValid: (acp) => {
313
+ const schema = acp.type === "self" ? SelfACPValidator : acp.type === "sharing" ? SharingACPValidator : acp.type === "recipient" ? ImportACPValidator : null;
314
+ if (schema == null)
315
+ return { valid: false, error: "invalid-schema" };
316
+ const schemaResult = schema.safeParse(acp);
317
+ if (!schemaResult.success)
318
+ return { valid: false, error: "invalid-schema" };
319
+ return ValidationUtils.isSignedAndNotExpired(acp);
320
+ }
321
+ };
322
+
323
+ // acps/signature.ts
324
+ var ACPSignatureAllFields = [
325
+ { name: "issuer", type: "address" },
326
+ { name: "expiration", type: "uint64" },
327
+ { name: "recipient", type: "address" },
328
+ { name: "revokerData", type: "uint256" },
329
+ { name: "revokerContract", type: "address" },
330
+ { name: "scope", type: "uint8" },
331
+ { name: "contracts", type: "address[]" },
332
+ { name: "handles", type: "bytes32[]" },
333
+ { name: "sealingKey", type: "bytes32" },
334
+ { name: "issuerSignature", type: "bytes" }
335
+ ];
336
+ var SignatureTypes = {
337
+ ACPIssuerSelf: [
338
+ "issuer",
339
+ "expiration",
340
+ "recipient",
341
+ "revokerData",
342
+ "revokerContract",
343
+ "scope",
344
+ "contracts",
345
+ "handles",
346
+ "sealingKey"
347
+ ],
348
+ ACPIssuerShared: [
349
+ "issuer",
350
+ "expiration",
351
+ "recipient",
352
+ "revokerData",
353
+ "revokerContract",
354
+ "scope",
355
+ "contracts",
356
+ "handles"
357
+ ],
358
+ ACPRecipient: ["sealingKey", "issuerSignature"]
359
+ };
360
+ var getSignatureTypesAndMessage = (primaryType, fields, values) => {
361
+ const types = {
362
+ [primaryType]: ACPSignatureAllFields.filter((fieldType) => fields.includes(fieldType.name))
363
+ };
364
+ const message = {};
365
+ fields.forEach((field) => {
366
+ if (field in values) {
367
+ message[field] = values[field];
368
+ }
369
+ });
370
+ return { types, primaryType, message };
371
+ };
372
+ var SignatureUtils = {
373
+ /**
374
+ * Get signature parameters for an ACP
375
+ */
376
+ getSignatureParams: (acp, primaryType) => {
377
+ return getSignatureTypesAndMessage(primaryType, SignatureTypes[primaryType], acp);
378
+ },
379
+ /**
380
+ * Determine the required signature type based on acp type
381
+ */
382
+ getPrimaryType: (acpType) => {
383
+ if (acpType === "self")
384
+ return "ACPIssuerSelf";
385
+ if (acpType === "sharing")
386
+ return "ACPIssuerShared";
387
+ if (acpType === "recipient")
388
+ return "ACPRecipient";
389
+ throw new Error(`Unknown acp type: ${acpType}`);
390
+ }
391
+ };
392
+ var getAclAddress = async (publicClient) => {
393
+ const ACL_IFACE = "function acl() view returns (address)";
394
+ const aclAbi = parseAbi([ACL_IFACE]);
395
+ return await publicClient.readContract({
396
+ address: TASK_MANAGER_ADDRESS,
397
+ abi: aclAbi,
398
+ functionName: "acl"
399
+ });
400
+ };
401
+ var getAclEIP712Domain = async (publicClient) => {
402
+ const aclAddress = await getAclAddress(publicClient);
403
+ const EIP712_DOMAIN_IFACE = "function eip712Domain() public view returns (bytes1 fields, string name, string version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] extensions)";
404
+ const domainAbi = parseAbi([EIP712_DOMAIN_IFACE]);
405
+ const domain = await publicClient.readContract({
406
+ address: aclAddress,
407
+ abi: domainAbi,
408
+ functionName: "eip712Domain"
409
+ });
410
+ const [_fields, name, version, chainId, verifyingContract, _salt, _extensions] = domain;
411
+ if (version !== "2") {
412
+ throw new Error(
413
+ `Chain ${chainId}'s ACL serves EIP-712 domain version "${version}" \u2014 this SDK requires the upgraded (ACP-era) ACL, which signs as version "2". Pre-upgrade (V2 Permission) chains are not supported.`
414
+ );
415
+ }
416
+ return {
417
+ name,
418
+ version,
419
+ chainId: Number(chainId),
420
+ verifyingContract
421
+ };
422
+ };
423
+ var checkACPValidityOnChain = async (acp, publicClient) => {
424
+ const aclAddress = await getAclAddress(publicClient);
425
+ try {
426
+ await publicClient.simulateContract({
427
+ address: aclAddress,
428
+ abi: checkACPValidityAbi,
429
+ functionName: "checkPermissionValidity",
430
+ args: [
431
+ {
432
+ issuer: acp.issuer,
433
+ expiration: BigInt(acp.expiration),
434
+ recipient: acp.recipient,
435
+ revokerData: BigInt(acp.revokerData),
436
+ revokerContract: acp.revokerContract,
437
+ scope: acp.scope,
438
+ contracts: acp.contracts,
439
+ handles: acp.handles,
440
+ sealingKey: acp.sealingKey,
441
+ issuerSignature: acp.issuerSignature,
442
+ recipientSignature: acp.recipientSignature
443
+ }
444
+ ]
445
+ });
446
+ return true;
447
+ } catch (err) {
448
+ if (err instanceof BaseError) {
449
+ const revertError = err.walk((err2) => err2 instanceof ContractFunctionRevertedError);
450
+ if (revertError instanceof ContractFunctionRevertedError) {
451
+ const errorName = revertError.data?.errorName ?? "";
452
+ throw new Error(errorName);
453
+ }
454
+ }
455
+ const customErrorName = extractCustomErrorFromDetails(err, checkACPValidityAbi);
456
+ if (customErrorName) {
457
+ throw new Error(customErrorName);
458
+ }
459
+ const hhDetailsData = extractReturnData(err);
460
+ if (hhDetailsData != null) {
461
+ const decoded = decodeErrorResult({
462
+ abi: checkACPValidityAbi,
463
+ data: hhDetailsData
464
+ });
465
+ throw new Error(decoded.errorName);
466
+ }
467
+ throw err;
468
+ }
469
+ };
470
+ function extractCustomErrorFromDetails(err, abi) {
471
+ const anyErr = err;
472
+ const details = anyErr?.details ?? anyErr?.cause?.details;
473
+ if (typeof details === "string") {
474
+ const customErrorMatch = details.match(/reverted with custom error '(\w+)\(\)'/);
475
+ if (customErrorMatch) {
476
+ const errorName = customErrorMatch[1];
477
+ const errorExists = abi.some((item) => item.type === "error" && item.name === errorName);
478
+ if (errorExists) {
479
+ return errorName;
480
+ }
481
+ }
482
+ }
483
+ return void 0;
484
+ }
485
+ function extractReturnData(err) {
486
+ const anyErr = err;
487
+ const s = anyErr?.details ?? anyErr?.cause?.details ?? anyErr?.shortMessage ?? anyErr?.message ?? String(err);
488
+ return s.match(/return data:\s*(0x[a-fA-F0-9]+)/)?.[1];
489
+ }
490
+ var checkACPValidityAbi = [
491
+ {
492
+ type: "function",
493
+ name: "checkPermissionValidity",
494
+ inputs: [
495
+ {
496
+ name: "acp",
497
+ type: "tuple",
498
+ internalType: "struct ACP",
499
+ components: [
500
+ {
501
+ name: "issuer",
502
+ type: "address",
503
+ internalType: "address"
504
+ },
505
+ {
506
+ name: "expiration",
507
+ type: "uint64",
508
+ internalType: "uint64"
509
+ },
510
+ {
511
+ name: "recipient",
512
+ type: "address",
513
+ internalType: "address"
514
+ },
515
+ {
516
+ name: "revokerData",
517
+ type: "uint256",
518
+ internalType: "uint256"
519
+ },
520
+ {
521
+ name: "revokerContract",
522
+ type: "address",
523
+ internalType: "address"
524
+ },
525
+ {
526
+ name: "scope",
527
+ type: "uint8",
528
+ internalType: "uint8"
529
+ },
530
+ {
531
+ name: "contracts",
532
+ type: "address[]",
533
+ internalType: "address[]"
534
+ },
535
+ {
536
+ name: "handles",
537
+ type: "bytes32[]",
538
+ internalType: "bytes32[]"
539
+ },
540
+ {
541
+ name: "sealingKey",
542
+ type: "bytes32",
543
+ internalType: "bytes32"
544
+ },
545
+ {
546
+ name: "issuerSignature",
547
+ type: "bytes",
548
+ internalType: "bytes"
549
+ },
550
+ {
551
+ name: "recipientSignature",
552
+ type: "bytes",
553
+ internalType: "bytes"
554
+ }
555
+ ]
556
+ }
557
+ ],
558
+ outputs: [
559
+ {
560
+ name: "",
561
+ type: "bool",
562
+ internalType: "bool"
563
+ }
564
+ ],
565
+ stateMutability: "view"
566
+ },
567
+ {
568
+ type: "error",
569
+ name: "PermissionInvalid_Disabled",
570
+ inputs: []
571
+ },
572
+ {
573
+ type: "error",
574
+ name: "PermissionInvalid_Expired",
575
+ inputs: []
576
+ },
577
+ {
578
+ type: "error",
579
+ name: "PermissionInvalid_IssuerSignature",
580
+ inputs: []
581
+ },
582
+ {
583
+ type: "error",
584
+ name: "PermissionInvalid_RecipientSignature",
585
+ inputs: []
586
+ }
587
+ ];
588
+
589
+ // acps/acp.ts
590
+ var ACPUtils = {
591
+ /**
592
+ * Create a self acp for personal use
593
+ */
594
+ createSelf: (options) => {
595
+ const validation = validateSelfACPOptions(options);
596
+ const sealingPair = GenerateSealingKey();
597
+ const acp = {
598
+ hash: ACPUtils.getHash(validation),
599
+ ...validation,
600
+ sealingPrivateKey: sealingPair.privateKey,
601
+ sealingKey: sealingPair.publicKey,
602
+ _signedDomain: void 0
603
+ };
604
+ return acp;
605
+ },
606
+ /**
607
+ * Create a sharing acp to be shared with another user
608
+ */
609
+ createSharing: (options) => {
610
+ const validation = validateSharingACPOptions(options);
611
+ const sealingPair = GenerateSealingKey();
612
+ const acp = {
613
+ hash: ACPUtils.getHash(validation),
614
+ ...validation,
615
+ sealingPrivateKey: sealingPair.privateKey,
616
+ sealingKey: sealingPair.publicKey,
617
+ _signedDomain: void 0
618
+ };
619
+ return acp;
620
+ },
621
+ /**
622
+ * Import a shared acp from various input formats
623
+ */
624
+ importShared: (options) => {
625
+ let parsedOptions;
626
+ if (typeof options === "string") {
627
+ try {
628
+ parsedOptions = JSON.parse(options);
629
+ } catch (error) {
630
+ throw new Error(`Failed to parse JSON string: ${error}`);
631
+ }
632
+ } else if (typeof options === "object" && options !== null) {
633
+ parsedOptions = options;
634
+ } else {
635
+ throw new Error("Invalid input type, expected ImportSharedACPOptions, object, or string");
636
+ }
637
+ if (parsedOptions.type != null && parsedOptions.type !== "sharing") {
638
+ throw new Error(`Invalid acp type <${parsedOptions.type}>, must be "sharing"`);
639
+ }
640
+ const validation = validateImportACPOptions({ ...parsedOptions, type: "recipient" });
641
+ const sealingPair = GenerateSealingKey();
642
+ const acp = {
643
+ hash: ACPUtils.getHash(validation),
644
+ ...validation,
645
+ sealingPrivateKey: sealingPair.privateKey,
646
+ sealingKey: sealingPair.publicKey,
647
+ _signedDomain: void 0
648
+ };
649
+ return acp;
650
+ },
651
+ /**
652
+ * Sign an ACP with the provided wallet client
653
+ */
654
+ sign: async (acp, publicClient, walletClient) => {
655
+ if (walletClient == null || walletClient.account == null) {
656
+ throw new Error(
657
+ "Missing walletClient, you must pass in a `walletClient` for the connected user to create an ACP signature"
658
+ );
659
+ }
660
+ const primaryType = SignatureUtils.getPrimaryType(acp.type);
661
+ const domain = await getAclEIP712Domain(publicClient);
662
+ const { types, message } = SignatureUtils.getSignatureParams(ACPUtils.getPublic(acp, true), primaryType);
663
+ const signature = await walletClient.signTypedData({
664
+ domain,
665
+ types,
666
+ primaryType,
667
+ message,
668
+ account: walletClient.account
669
+ });
670
+ let updatedACP;
671
+ if (acp.type === "self" || acp.type === "sharing") {
672
+ updatedACP = {
673
+ ...acp,
674
+ issuerSignature: signature,
675
+ _signedDomain: domain
676
+ };
677
+ } else {
678
+ updatedACP = {
679
+ ...acp,
680
+ recipientSignature: signature,
681
+ _signedDomain: domain
682
+ };
683
+ }
684
+ return updatedACP;
685
+ },
686
+ /**
687
+ * Create and sign a self acp in one operation
688
+ */
689
+ createSelfAndSign: async (options, publicClient, walletClient) => {
690
+ const acp = ACPUtils.createSelf(options);
691
+ return ACPUtils.sign(acp, publicClient, walletClient);
692
+ },
693
+ /**
694
+ * Create and sign a sharing acp in one operation
695
+ */
696
+ createSharingAndSign: async (options, publicClient, walletClient) => {
697
+ const acp = ACPUtils.createSharing(options);
698
+ return ACPUtils.sign(acp, publicClient, walletClient);
699
+ },
700
+ /**
701
+ * Import and sign a shared acp in one operation from various input formats
702
+ */
703
+ importSharedAndSign: async (options, publicClient, walletClient) => {
704
+ const acp = ACPUtils.importShared(options);
705
+ return ACPUtils.sign(acp, publicClient, walletClient);
706
+ },
707
+ /**
708
+ * Deserialize an ACP from serialized data
709
+ */
710
+ deserialize: (data) => {
711
+ return { ...data };
712
+ },
713
+ /**
714
+ * Serialize an ACP for storage
715
+ */
716
+ serialize: (acp) => {
717
+ return {
718
+ hash: acp.hash,
719
+ name: acp.name,
720
+ type: acp.type,
721
+ issuer: acp.issuer,
722
+ expiration: acp.expiration,
723
+ recipient: acp.recipient,
724
+ revokerData: acp.revokerData,
725
+ revokerContract: acp.revokerContract,
726
+ scope: acp.scope,
727
+ contracts: acp.contracts,
728
+ handles: acp.handles,
729
+ sealingKey: acp.sealingKey,
730
+ issuerSignature: acp.issuerSignature,
731
+ recipientSignature: acp.recipientSignature,
732
+ _signedDomain: acp._signedDomain,
733
+ sealingPrivateKey: acp.sealingPrivateKey
734
+ };
735
+ },
736
+ /**
737
+ * Validate an ACP (schema-level validation)
738
+ */
739
+ validateSchema: (acp) => {
740
+ if (acp.type === "self") {
741
+ return validateSelfACP(acp);
742
+ } else if (acp.type === "sharing") {
743
+ return validateSharingACP(acp);
744
+ } else if (acp.type === "recipient") {
745
+ return validateImportACP(acp);
746
+ } else {
747
+ throw new Error("Invalid ACP type");
748
+ }
749
+ },
750
+ /**
751
+ * Validate an ACP (holistic validation).
752
+ *
753
+ * This validates:
754
+ * - ACP schema (shape + invariants)
755
+ * - ACP is signed
756
+ * - ACP is not expired
757
+ *
758
+ * For schema-only validation, use `validateSchema(acp)`.
759
+ */
760
+ validate: (acp) => {
761
+ const validated = ACPUtils.validateSchema(acp);
762
+ ValidationUtils.assertSignedAndNotExpired(validated);
763
+ return validated;
764
+ },
765
+ /**
766
+ * Get the public component of an ACP — the signed struct sent on-chain / to the decryption backend.
767
+ * Strips the private component (hash, name, type, sealing pair).
768
+ */
769
+ getPublic: (acp, skipValidation = false) => {
770
+ if (!skipValidation) {
771
+ ACPUtils.validateSchema(acp);
772
+ }
773
+ return {
774
+ issuer: acp.issuer,
775
+ expiration: acp.expiration,
776
+ recipient: acp.recipient,
777
+ revokerData: acp.revokerData,
778
+ revokerContract: acp.revokerContract,
779
+ scope: acp.scope,
780
+ contracts: acp.contracts,
781
+ handles: acp.handles,
782
+ sealingKey: acp.sealingKey,
783
+ issuerSignature: acp.issuerSignature,
784
+ recipientSignature: acp.recipientSignature
785
+ };
786
+ },
787
+ /**
788
+ * Get a stable hash for the acp (used as key in storage)
789
+ */
790
+ getHash: (acp) => {
791
+ const data = JSON.stringify({
792
+ type: acp.type,
793
+ issuer: acp.issuer,
794
+ expiration: acp.expiration,
795
+ recipient: acp.recipient,
796
+ revokerData: acp.revokerData,
797
+ revokerContract: acp.revokerContract,
798
+ scope: acp.scope,
799
+ contracts: acp.contracts,
800
+ handles: acp.handles
801
+ });
802
+ return keccak256(toHex(data));
803
+ },
804
+ /**
805
+ * Export acp data for sharing (strips the private component).
806
+ * Fixed `SharedACP` shape — every field always present, aligned with
807
+ * `ACPPublic` and the on-chain sharing payload.
808
+ */
809
+ export: (acp) => {
810
+ if (acp.type !== "sharing") {
811
+ throw new Error(
812
+ `Cannot export a '${acp.type}' ACP \u2014 only 'sharing' ACPs are exportable. The export includes the issuer signature.`
813
+ );
814
+ }
815
+ if (acp.issuerSignature === "0x") {
816
+ throw new Error(
817
+ "Cannot export an unsigned sharing ACP \u2014 sign it first (the recipient needs the issuer signature)."
818
+ );
819
+ }
820
+ const shared = {
821
+ name: acp.name,
822
+ type: acp.type,
823
+ issuer: acp.issuer,
824
+ expiration: acp.expiration,
825
+ recipient: acp.recipient,
826
+ revokerData: acp.revokerData,
827
+ revokerContract: acp.revokerContract,
828
+ scope: acp.scope,
829
+ contracts: acp.contracts,
830
+ handles: acp.handles,
831
+ issuerSignature: acp.issuerSignature
832
+ };
833
+ return JSON.stringify(shared, void 0, 2);
834
+ },
835
+ /**
836
+ * Unseal encrypted data using the acp's sealing key
837
+ */
838
+ unseal: (acp, ciphertext) => {
839
+ return unsealWithPrivateKey(acp.sealingPrivateKey, ciphertext);
840
+ },
841
+ /**
842
+ * Check if acp is expired
843
+ */
844
+ isExpired: (acp) => {
845
+ return ValidationUtils.isExpired(acp);
846
+ },
847
+ /**
848
+ * Check if acp is signed
849
+ */
850
+ isSigned: (acp) => {
851
+ return ValidationUtils.isSigned(acp);
852
+ },
853
+ /**
854
+ * Check if acp is signed and not expired
855
+ */
856
+ isSignedAndNotExpired: (acp) => {
857
+ return ValidationUtils.isSignedAndNotExpired(acp);
858
+ },
859
+ /**
860
+ * Assert that acp is signed and not expired
861
+ */
862
+ assertSignedAndNotExpired: (acp) => {
863
+ return ValidationUtils.assertSignedAndNotExpired(acp);
864
+ },
865
+ isValid: (acp) => {
866
+ return ValidationUtils.isValid(acp);
867
+ },
868
+ /**
869
+ * Update acp name (returns new acp instance)
870
+ */
871
+ updateName: (acp, name) => {
872
+ return { ...acp, name };
873
+ },
874
+ /**
875
+ * Fetch EIP712 domain from the blockchain
876
+ */
877
+ fetchEIP712Domain: async (publicClient) => {
878
+ return getAclEIP712Domain(publicClient);
879
+ },
880
+ /**
881
+ * Check if acp's signed domain matches the provided domain
882
+ */
883
+ matchesDomain: (acp, domain) => {
884
+ return acp._signedDomain?.name === domain.name && acp._signedDomain?.version === domain.version && acp._signedDomain?.verifyingContract === domain.verifyingContract && acp._signedDomain?.chainId === domain.chainId;
885
+ },
886
+ /**
887
+ * Check if acp's signed domain is valid for the current chain
888
+ */
889
+ checkSignedDomainValid: async (acp, publicClient) => {
890
+ if (acp._signedDomain == null)
891
+ return false;
892
+ const domain = await getAclEIP712Domain(publicClient);
893
+ return ACPUtils.matchesDomain(acp, domain);
894
+ },
895
+ /**
896
+ * Check if acp passes the on-chain validation
897
+ */
898
+ checkValidityOnChain: async (acp, publicClient) => {
899
+ const publicAcp = ACPUtils.getPublic(acp);
900
+ return checkACPValidityOnChain(publicAcp, publicClient);
901
+ }
902
+ };
903
+ var ACP_STORE_DEFAULTS = {
904
+ acps: {},
905
+ activeACPHash: {}
906
+ };
907
+ var ACP_STORE_VERSION = 3;
908
+ var _acpStore = createStore()(
909
+ persist(() => ACP_STORE_DEFAULTS, {
910
+ name: "cofhesdk-acps",
911
+ version: ACP_STORE_VERSION,
912
+ migrate: (persistedState, version) => {
913
+ if (version < ACP_STORE_VERSION)
914
+ return ACP_STORE_DEFAULTS;
915
+ return persistedState;
916
+ }
917
+ })
918
+ );
919
+ var clearStaleStore = () => {
920
+ const state = _acpStore.getState();
921
+ const hasExpectedStructure = state && typeof state === "object" && "acps" in state && "activeACPHash" in state && typeof state.acps === "object" && typeof state.activeACPHash === "object";
922
+ if (hasExpectedStructure)
923
+ return;
924
+ _acpStore.setState({ acps: {}, activeACPHash: {} });
925
+ };
926
+ var getACP = (chainId, account, hash) => {
927
+ clearStaleStore();
928
+ if (chainId == null || account == null || hash == null)
929
+ return;
930
+ const savedACP = _acpStore.getState().acps[chainId]?.[account]?.[hash];
931
+ if (savedACP == null)
932
+ return;
933
+ return ACPUtils.deserialize(savedACP);
934
+ };
935
+ var getActiveACP = (chainId, account) => {
936
+ clearStaleStore();
937
+ if (chainId == null || account == null)
938
+ return;
939
+ const activeACPHash = _acpStore.getState().activeACPHash[chainId]?.[account];
940
+ return getACP(chainId, account, activeACPHash);
941
+ };
942
+ var getACPs = (chainId, account) => {
943
+ clearStaleStore();
944
+ if (chainId == null || account == null)
945
+ return {};
946
+ return Object.entries(_acpStore.getState().acps[chainId]?.[account] ?? {}).reduce(
947
+ (acc, [hash, acp]) => {
948
+ if (acp == void 0)
949
+ return acc;
950
+ return { ...acc, [hash]: ACPUtils.deserialize(acp) };
951
+ },
952
+ {}
953
+ );
954
+ };
955
+ var setACP = (chainId, account, acp) => {
956
+ clearStaleStore();
957
+ _acpStore.setState(
958
+ produce((state) => {
959
+ if (state.acps[chainId] == null)
960
+ state.acps[chainId] = {};
961
+ if (state.acps[chainId][account] == null)
962
+ state.acps[chainId][account] = {};
963
+ state.acps[chainId][account][acp.hash] = ACPUtils.serialize(acp);
964
+ })
965
+ );
966
+ };
967
+ var removeACP = (chainId, account, hash) => {
968
+ clearStaleStore();
969
+ _acpStore.setState(
970
+ produce((state) => {
971
+ if (state.acps[chainId] == null)
972
+ state.acps[chainId] = {};
973
+ if (state.activeACPHash[chainId] == null)
974
+ state.activeACPHash[chainId] = {};
975
+ const accountACPs = state.acps[chainId][account];
976
+ if (accountACPs == null)
977
+ return;
978
+ if (accountACPs[hash] == null)
979
+ return;
980
+ if (state.activeACPHash[chainId][account] === hash) {
981
+ state.activeACPHash[chainId][account] = void 0;
982
+ }
983
+ accountACPs[hash] = void 0;
984
+ })
985
+ );
986
+ };
987
+ var getActiveACPHash = (chainId, account) => {
988
+ clearStaleStore();
989
+ if (chainId == null || account == null)
990
+ return void 0;
991
+ return _acpStore.getState().activeACPHash[chainId]?.[account];
992
+ };
993
+ var setActiveACPHash = (chainId, account, hash) => {
994
+ clearStaleStore();
995
+ _acpStore.setState(
996
+ produce((state) => {
997
+ if (state.activeACPHash[chainId] == null)
998
+ state.activeACPHash[chainId] = {};
999
+ state.activeACPHash[chainId][account] = hash;
1000
+ })
1001
+ );
1002
+ };
1003
+ var removeActiveACPHash = (chainId, account) => {
1004
+ clearStaleStore();
1005
+ _acpStore.setState(
1006
+ produce((state) => {
1007
+ if (state.activeACPHash[chainId])
1008
+ state.activeACPHash[chainId][account] = void 0;
1009
+ })
1010
+ );
1011
+ };
1012
+ var resetStore = () => {
1013
+ clearStaleStore();
1014
+ _acpStore.setState({ acps: {}, activeACPHash: {} });
1015
+ };
1016
+ var acpStore = {
1017
+ store: _acpStore,
1018
+ getACP,
1019
+ getActiveACP,
1020
+ getACPs,
1021
+ setACP,
1022
+ removeACP,
1023
+ getActiveACPHash,
1024
+ setActiveACPHash,
1025
+ removeActiveACPHash,
1026
+ resetStore
1027
+ };
1028
+
1029
+ export { ACPScope, ACPUtils, ACP_STORE_DEFAULTS, GenerateSealingKey, ImportACPOptionsValidator, ImportACPValidator, SelfACPOptionsValidator, SelfACPValidator, SharingACPOptionsValidator, SharingACPValidator, SignatureTypes, SignatureUtils, ValidationUtils, _acpStore, acpStore, addressNotZeroSchema, addressSchema, bytesNotEmptySchema, bytesSchema, clearStaleStore, contractsSchema, getACP, getACPs, getActiveACP, getActiveACPHash, getSignatureTypesAndMessage, handlesSchema, removeACP, removeActiveACPHash, resetStore, seal, setACP, setActiveACPHash, unsealWithPrivateKey, validateImportACP, validateImportACPOptions, validateSelfACP, validateSelfACPOptions, validateSharingACP, validateSharingACPOptions };