@cofhe/sdk 0.0.0-alpha-20260409113701

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