@cofhe/sdk 0.1.1 → 0.2.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 (96) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/adapters/ethers6.ts +28 -28
  3. package/adapters/hardhat.ts +0 -1
  4. package/adapters/index.test.ts +14 -19
  5. package/adapters/smartWallet.ts +81 -73
  6. package/adapters/test-utils.ts +45 -45
  7. package/adapters/types.ts +3 -3
  8. package/chains/chains/localcofhe.ts +14 -0
  9. package/chains/chains.test.ts +2 -1
  10. package/chains/index.ts +3 -1
  11. package/core/baseBuilder.ts +30 -49
  12. package/core/client.test.ts +94 -77
  13. package/core/client.ts +133 -149
  14. package/core/clientTypes.ts +108 -0
  15. package/core/config.test.ts +22 -11
  16. package/core/config.ts +16 -9
  17. package/core/decrypt/decryptHandleBuilder.ts +51 -45
  18. package/core/decrypt/{tnSealOutput.ts → tnSealOutputV1.ts} +1 -1
  19. package/core/decrypt/tnSealOutputV2.ts +298 -0
  20. package/core/encrypt/cofheMocksZkVerifySign.ts +16 -10
  21. package/core/encrypt/encryptInputsBuilder.test.ts +132 -116
  22. package/core/encrypt/encryptInputsBuilder.ts +159 -111
  23. package/core/encrypt/encryptUtils.ts +6 -3
  24. package/core/encrypt/zkPackProveVerify.ts +70 -8
  25. package/core/error.ts +0 -2
  26. package/core/fetchKeys.test.ts +1 -18
  27. package/core/fetchKeys.ts +0 -26
  28. package/core/index.ts +29 -17
  29. package/core/keyStore.ts +65 -38
  30. package/core/permits.test.ts +253 -1
  31. package/core/permits.ts +80 -16
  32. package/core/types.ts +198 -152
  33. package/core/utils.ts +43 -1
  34. package/dist/adapters.d.cts +38 -20
  35. package/dist/adapters.d.ts +38 -20
  36. package/dist/chains.cjs +14 -1
  37. package/dist/chains.d.cts +23 -1
  38. package/dist/chains.d.ts +23 -1
  39. package/dist/chains.js +1 -1
  40. package/dist/{chunk-LU7BMUUT.js → chunk-UGBVZNRT.js} +39 -25
  41. package/dist/{chunk-GZCQQYVI.js → chunk-WEAZ25JO.js} +14 -2
  42. package/dist/{chunk-KFGPTJ6X.js → chunk-WGCRJCBR.js} +1920 -1692
  43. package/dist/{types-bB7wLj0q.d.cts → clientTypes-5_1nwtUe.d.cts} +308 -347
  44. package/dist/{types-PhwGgQvs.d.ts → clientTypes-Es7fyi65.d.ts} +308 -347
  45. package/dist/core.cjs +2872 -2632
  46. package/dist/core.d.cts +101 -6
  47. package/dist/core.d.ts +101 -6
  48. package/dist/core.js +3 -3
  49. package/dist/node.cjs +2716 -2520
  50. package/dist/node.d.cts +3 -3
  51. package/dist/node.d.ts +3 -3
  52. package/dist/node.js +4 -3
  53. package/dist/{permit-S9CnI6MF.d.cts → permit-fUSe6KKq.d.cts} +31 -15
  54. package/dist/{permit-S9CnI6MF.d.ts → permit-fUSe6KKq.d.ts} +31 -15
  55. package/dist/permits.cjs +39 -24
  56. package/dist/permits.d.cts +137 -148
  57. package/dist/permits.d.ts +137 -148
  58. package/dist/permits.js +1 -1
  59. package/dist/web.cjs +2929 -2518
  60. package/dist/web.d.cts +21 -5
  61. package/dist/web.d.ts +21 -5
  62. package/dist/web.js +185 -9
  63. package/dist/zkProve.worker.cjs +93 -0
  64. package/dist/zkProve.worker.d.cts +2 -0
  65. package/dist/zkProve.worker.d.ts +2 -0
  66. package/dist/zkProve.worker.js +91 -0
  67. package/node/client.test.ts +20 -25
  68. package/node/encryptInputs.test.ts +18 -38
  69. package/node/index.ts +1 -0
  70. package/package.json +14 -14
  71. package/permits/index.ts +1 -0
  72. package/permits/localstorage.test.ts +0 -1
  73. package/permits/permit.test.ts +25 -22
  74. package/permits/permit.ts +30 -21
  75. package/permits/sealing.test.ts +3 -3
  76. package/permits/sealing.ts +2 -2
  77. package/permits/store.ts +5 -7
  78. package/permits/test-utils.ts +1 -1
  79. package/permits/types.ts +17 -0
  80. package/permits/utils.ts +0 -1
  81. package/permits/validation.ts +24 -4
  82. package/web/client.web.test.ts +20 -25
  83. package/web/config.web.test.ts +0 -2
  84. package/web/encryptInputs.web.test.ts +31 -54
  85. package/web/index.ts +65 -1
  86. package/web/storage.ts +19 -5
  87. package/web/worker.builder.web.test.ts +148 -0
  88. package/web/worker.config.web.test.ts +329 -0
  89. package/web/worker.output.web.test.ts +84 -0
  90. package/web/workerManager.test.ts +80 -0
  91. package/web/workerManager.ts +214 -0
  92. package/web/workerManager.web.test.ts +114 -0
  93. package/web/zkProve.worker.ts +133 -0
  94. package/core/result.test.ts +0 -180
  95. package/core/result.ts +0 -67
  96. package/core/test-utils.ts +0 -45
@@ -78,12 +78,12 @@ declare function WagmiAdapter(walletClient: WalletClient, publicClient: PublicCl
78
78
  gas: bigint;
79
79
  nonce: number;
80
80
  value: bigint;
81
- maxFeePerBlobGas?: undefined;
81
+ blobVersionedHashes?: undefined;
82
82
  gasPrice: bigint;
83
+ maxFeePerBlobGas?: undefined;
83
84
  maxFeePerGas?: undefined;
84
85
  maxPriorityFeePerGas?: undefined;
85
86
  accessList?: undefined;
86
- blobVersionedHashes?: undefined;
87
87
  authorizationList?: undefined;
88
88
  hash: viem.Hash;
89
89
  r: viem.Hex;
@@ -103,12 +103,12 @@ declare function WagmiAdapter(walletClient: WalletClient, publicClient: PublicCl
103
103
  gas: bigint;
104
104
  nonce: number;
105
105
  value: bigint;
106
- maxFeePerBlobGas?: undefined;
106
+ blobVersionedHashes?: undefined;
107
107
  gasPrice: bigint;
108
+ maxFeePerBlobGas?: undefined;
108
109
  maxFeePerGas?: undefined;
109
110
  maxPriorityFeePerGas?: undefined;
110
111
  accessList: viem.AccessList;
111
- blobVersionedHashes?: undefined;
112
112
  authorizationList?: undefined;
113
113
  hash: viem.Hash;
114
114
  r: viem.Hex;
@@ -128,12 +128,12 @@ declare function WagmiAdapter(walletClient: WalletClient, publicClient: PublicCl
128
128
  gas: bigint;
129
129
  nonce: number;
130
130
  value: bigint;
131
- maxFeePerBlobGas?: undefined;
131
+ blobVersionedHashes?: undefined;
132
132
  gasPrice?: undefined;
133
+ maxFeePerBlobGas?: undefined;
133
134
  maxFeePerGas: bigint;
134
135
  maxPriorityFeePerGas: bigint;
135
136
  accessList: viem.AccessList;
136
- blobVersionedHashes?: undefined;
137
137
  authorizationList?: undefined;
138
138
  hash: viem.Hash;
139
139
  r: viem.Hex;
@@ -153,12 +153,12 @@ declare function WagmiAdapter(walletClient: WalletClient, publicClient: PublicCl
153
153
  gas: bigint;
154
154
  nonce: number;
155
155
  value: bigint;
156
- maxFeePerBlobGas: bigint;
156
+ blobVersionedHashes: readonly viem.Hex[];
157
157
  gasPrice?: undefined;
158
+ maxFeePerBlobGas: bigint;
158
159
  maxFeePerGas: bigint;
159
160
  maxPriorityFeePerGas: bigint;
160
161
  accessList: viem.AccessList;
161
- blobVersionedHashes: readonly viem.Hex[];
162
162
  authorizationList?: undefined;
163
163
  hash: viem.Hash;
164
164
  r: viem.Hex;
@@ -178,12 +178,12 @@ declare function WagmiAdapter(walletClient: WalletClient, publicClient: PublicCl
178
178
  gas: bigint;
179
179
  nonce: number;
180
180
  value: bigint;
181
- maxFeePerBlobGas?: undefined;
181
+ blobVersionedHashes?: undefined;
182
182
  gasPrice?: undefined;
183
+ maxFeePerBlobGas?: undefined;
183
184
  maxFeePerGas: bigint;
184
185
  maxPriorityFeePerGas: bigint;
185
186
  accessList: viem.AccessList;
186
- blobVersionedHashes?: undefined;
187
187
  authorizationList: viem.SignedAuthorizationList;
188
188
  hash: viem.Hash;
189
189
  r: viem.Hex;
@@ -228,12 +228,12 @@ declare function WagmiAdapter(walletClient: WalletClient, publicClient: PublicCl
228
228
  gas: bigint;
229
229
  nonce: number;
230
230
  value: bigint;
231
- maxFeePerBlobGas?: undefined;
231
+ blobVersionedHashes?: undefined;
232
232
  gasPrice: bigint;
233
+ maxFeePerBlobGas?: undefined;
233
234
  maxFeePerGas?: undefined;
234
235
  maxPriorityFeePerGas?: undefined;
235
236
  accessList?: undefined;
236
- blobVersionedHashes?: undefined;
237
237
  authorizationList?: undefined;
238
238
  hash: viem.Hash;
239
239
  r: viem.Hex;
@@ -253,12 +253,12 @@ declare function WagmiAdapter(walletClient: WalletClient, publicClient: PublicCl
253
253
  gas: bigint;
254
254
  nonce: number;
255
255
  value: bigint;
256
- maxFeePerBlobGas?: undefined;
256
+ blobVersionedHashes?: undefined;
257
257
  gasPrice: bigint;
258
+ maxFeePerBlobGas?: undefined;
258
259
  maxFeePerGas?: undefined;
259
260
  maxPriorityFeePerGas?: undefined;
260
261
  accessList: viem.AccessList;
261
- blobVersionedHashes?: undefined;
262
262
  authorizationList?: undefined;
263
263
  hash: viem.Hash;
264
264
  r: viem.Hex;
@@ -278,12 +278,12 @@ declare function WagmiAdapter(walletClient: WalletClient, publicClient: PublicCl
278
278
  gas: bigint;
279
279
  nonce: number;
280
280
  value: bigint;
281
- maxFeePerBlobGas?: undefined;
281
+ blobVersionedHashes?: undefined;
282
282
  gasPrice?: undefined;
283
+ maxFeePerBlobGas?: undefined;
283
284
  maxFeePerGas: bigint;
284
285
  maxPriorityFeePerGas: bigint;
285
286
  accessList: viem.AccessList;
286
- blobVersionedHashes?: undefined;
287
287
  authorizationList?: undefined;
288
288
  hash: viem.Hash;
289
289
  r: viem.Hex;
@@ -303,12 +303,12 @@ declare function WagmiAdapter(walletClient: WalletClient, publicClient: PublicCl
303
303
  gas: bigint;
304
304
  nonce: number;
305
305
  value: bigint;
306
- maxFeePerBlobGas: bigint;
306
+ blobVersionedHashes: readonly viem.Hex[];
307
307
  gasPrice?: undefined;
308
+ maxFeePerBlobGas: bigint;
308
309
  maxFeePerGas: bigint;
309
310
  maxPriorityFeePerGas: bigint;
310
311
  accessList: viem.AccessList;
311
- blobVersionedHashes: readonly viem.Hex[];
312
312
  authorizationList?: undefined;
313
313
  hash: viem.Hash;
314
314
  r: viem.Hex;
@@ -328,12 +328,12 @@ declare function WagmiAdapter(walletClient: WalletClient, publicClient: PublicCl
328
328
  gas: bigint;
329
329
  nonce: number;
330
330
  value: bigint;
331
- maxFeePerBlobGas?: undefined;
331
+ blobVersionedHashes?: undefined;
332
332
  gasPrice?: undefined;
333
+ maxFeePerBlobGas?: undefined;
333
334
  maxFeePerGas: bigint;
334
335
  maxPriorityFeePerGas: bigint;
335
336
  accessList: viem.AccessList;
336
- blobVersionedHashes?: undefined;
337
337
  authorizationList: viem.SignedAuthorizationList;
338
338
  hash: viem.Hash;
339
339
  r: viem.Hex;
@@ -6858,6 +6858,7 @@ declare function WagmiAdapter(walletClient: WalletClient, publicClient: PublicCl
6858
6858
  }, (request["parameters"] extends readonly viem.PrepareTransactionRequestParameterType[] ? request["parameters"][number] : "type" | "gas" | "nonce" | "blobVersionedHashes" | "fees" | "chainId") extends infer T_8 ? T_8 extends (request["parameters"] extends readonly viem.PrepareTransactionRequestParameterType[] ? request["parameters"][number] : "type" | "gas" | "nonce" | "blobVersionedHashes" | "fees" | "chainId") ? T_8 extends "fees" ? "gasPrice" | "maxFeePerGas" | "maxPriorityFeePerGas" : T_8 : never : never> & (unknown extends request["kzg"] ? {} : Pick<request, "kzg">))[K]; } : never>;
6859
6859
  readContract: <const abi extends viem.Abi | readonly unknown[], functionName extends viem.ContractFunctionName<abi, "pure" | "view">, const args extends viem.ContractFunctionArgs<abi, "pure" | "view", functionName>>(args: viem.ReadContractParameters<abi, functionName, args>) => Promise<viem.ReadContractReturnType<abi, functionName, args>>;
6860
6860
  sendRawTransaction: (args: viem.SendRawTransactionParameters) => Promise<viem.SendRawTransactionReturnType>;
6861
+ sendRawTransactionSync: (args: viem.SendRawTransactionSyncParameters) => Promise<viem.TransactionReceipt>;
6861
6862
  simulate: <const calls extends readonly unknown[]>(args: viem.SimulateBlocksParameters<calls>) => Promise<viem.SimulateBlocksReturnType<calls>>;
6862
6863
  simulateBlocks: <const calls extends readonly unknown[]>(args: viem.SimulateBlocksParameters<calls>) => Promise<viem.SimulateBlocksReturnType<calls>>;
6863
6864
  simulateCalls: <const calls extends readonly unknown[]>(args: viem.SimulateCallsParameters<calls>) => Promise<viem.SimulateCallsReturnType<calls>>;
@@ -13425,8 +13426,24 @@ declare function WagmiAdapter(walletClient: WalletClient, publicClient: PublicCl
13425
13426
  } | undefined;
13426
13427
  id: string;
13427
13428
  }>;
13429
+ sendCallsSync: <const calls extends readonly unknown[], chainOverride extends viem.Chain | undefined = undefined>(parameters: viem.SendCallsSyncParameters<viem.Chain | undefined, viem.Account | undefined, chainOverride, calls>) => Promise<{
13430
+ id: string;
13431
+ atomic: boolean;
13432
+ capabilities?: {
13433
+ [key: string]: any;
13434
+ } | {
13435
+ [x: string]: any;
13436
+ } | undefined;
13437
+ chainId: number;
13438
+ receipts?: viem.WalletCallReceipt<bigint, "success" | "reverted">[] | undefined;
13439
+ version: string;
13440
+ statusCode: number;
13441
+ status: "pending" | "success" | "failure" | undefined;
13442
+ }>;
13428
13443
  sendRawTransaction: (args: viem.SendRawTransactionParameters) => Promise<viem.SendRawTransactionReturnType>;
13444
+ sendRawTransactionSync: (args: viem.SendRawTransactionSyncParameters) => Promise<viem.TransactionReceipt>;
13429
13445
  sendTransaction: <const request extends viem.SendTransactionRequest<viem.Chain | undefined, chainOverride>, chainOverride extends viem.Chain | undefined = undefined>(args: viem.SendTransactionParameters<viem.Chain | undefined, viem.Account | undefined, chainOverride, request>) => Promise<viem.SendTransactionReturnType>;
13446
+ sendTransactionSync: <const request extends viem.SendTransactionSyncRequest<viem.Chain | undefined, chainOverride>, chainOverride extends viem.Chain | undefined = undefined>(args: viem.SendTransactionSyncParameters<viem.Chain | undefined, viem.Account | undefined, chainOverride, request>) => Promise<viem.SendTransactionSyncReturnType>;
13430
13447
  showCallsStatus: (parameters: viem.ShowCallsStatusParameters) => Promise<viem.ShowCallsStatusReturnType>;
13431
13448
  signAuthorization: (parameters: viem.SignAuthorizationParameters<viem.Account | undefined>) => Promise<viem.SignAuthorizationReturnType>;
13432
13449
  signMessage: (args: viem.SignMessageParameters<viem.Account | undefined>) => Promise<viem.SignMessageReturnType>;
@@ -14534,6 +14551,7 @@ declare function WagmiAdapter(walletClient: WalletClient, publicClient: PublicCl
14534
14551
  waitForCallsStatus: (parameters: viem.WaitForCallsStatusParameters) => Promise<viem.WaitForCallsStatusReturnType>;
14535
14552
  watchAsset: (args: viem.WatchAssetParameters) => Promise<viem.WatchAssetReturnType>;
14536
14553
  writeContract: <const abi extends viem.Abi | readonly unknown[], functionName extends viem.ContractFunctionName<abi, "nonpayable" | "payable">, args_1 extends viem.ContractFunctionArgs<abi, "nonpayable" | "payable", functionName>, chainOverride extends viem.Chain | undefined = undefined>(args: viem.WriteContractParameters<abi, functionName, args_1, viem.Chain | undefined, viem.Account | undefined, chainOverride>) => Promise<viem.WriteContractReturnType>;
14554
+ writeContractSync: <const abi extends viem.Abi | readonly unknown[], functionName extends viem.ContractFunctionName<abi, "nonpayable" | "payable">, args_1 extends viem.ContractFunctionArgs<abi, "nonpayable" | "payable", functionName>, chainOverride extends viem.Chain | undefined = undefined>(args: viem.WriteContractSyncParameters<abi, functionName, args_1, viem.Chain | undefined, viem.Account | undefined, chainOverride>) => Promise<viem.WriteContractSyncReturnType>;
14537
14555
  extend: <const client extends {
14538
14556
  [x: string]: unknown;
14539
14557
  account?: undefined;
package/dist/chains.cjs CHANGED
@@ -76,12 +76,24 @@ var hardhat = defineChain({
76
76
  environment: "MOCK"
77
77
  });
78
78
 
79
+ // chains/chains/localcofhe.ts
80
+ var localcofhe = defineChain({
81
+ id: 420105,
82
+ name: "Local Cofhe",
83
+ network: "localhost",
84
+ coFheUrl: "http://127.0.0.1:9448",
85
+ verifierUrl: "http://127.0.0.1:3001",
86
+ thresholdNetworkUrl: "http://127.0.0.1:3000",
87
+ environment: "TESTNET"
88
+ });
89
+
79
90
  // chains/index.ts
80
91
  var chains = {
81
92
  sepolia,
82
93
  arbSepolia,
83
94
  baseSepolia,
84
- hardhat
95
+ hardhat,
96
+ localcofhe
85
97
  };
86
98
  var getChainById = (chainId) => {
87
99
  return Object.values(chains).find((chain) => chain.id === chainId);
@@ -98,4 +110,5 @@ exports.chains = chains;
98
110
  exports.getChainById = getChainById;
99
111
  exports.getChainByName = getChainByName;
100
112
  exports.hardhat = hardhat;
113
+ exports.localcofhe = localcofhe;
101
114
  exports.sepolia = sepolia;
package/dist/chains.d.cts CHANGED
@@ -54,6 +54,19 @@ declare const hardhat: {
54
54
  environment: "MOCK" | "TESTNET" | "MAINNET";
55
55
  };
56
56
 
57
+ /**
58
+ * Localcofhe chain configuration
59
+ */
60
+ declare const localcofhe: {
61
+ name: string;
62
+ id: number;
63
+ network: string;
64
+ coFheUrl: string;
65
+ verifierUrl: string;
66
+ thresholdNetworkUrl: string;
67
+ environment: "MOCK" | "TESTNET" | "MAINNET";
68
+ };
69
+
57
70
  declare const chains: {
58
71
  readonly sepolia: {
59
72
  name: string;
@@ -91,9 +104,18 @@ declare const chains: {
91
104
  thresholdNetworkUrl: string;
92
105
  environment: "MOCK" | "TESTNET" | "MAINNET";
93
106
  };
107
+ readonly localcofhe: {
108
+ name: string;
109
+ id: number;
110
+ network: string;
111
+ coFheUrl: string;
112
+ verifierUrl: string;
113
+ thresholdNetworkUrl: string;
114
+ environment: "MOCK" | "TESTNET" | "MAINNET";
115
+ };
94
116
  };
95
117
 
96
118
  declare const getChainById: (chainId: number) => CofheChain | undefined;
97
119
  declare const getChainByName: (name: string) => CofheChain | undefined;
98
120
 
99
- export { CofheChain, arbSepolia, baseSepolia, chains, getChainById, getChainByName, hardhat, sepolia };
121
+ export { CofheChain, arbSepolia, baseSepolia, chains, getChainById, getChainByName, hardhat, localcofhe, sepolia };
package/dist/chains.d.ts CHANGED
@@ -54,6 +54,19 @@ declare const hardhat: {
54
54
  environment: "MOCK" | "TESTNET" | "MAINNET";
55
55
  };
56
56
 
57
+ /**
58
+ * Localcofhe chain configuration
59
+ */
60
+ declare const localcofhe: {
61
+ name: string;
62
+ id: number;
63
+ network: string;
64
+ coFheUrl: string;
65
+ verifierUrl: string;
66
+ thresholdNetworkUrl: string;
67
+ environment: "MOCK" | "TESTNET" | "MAINNET";
68
+ };
69
+
57
70
  declare const chains: {
58
71
  readonly sepolia: {
59
72
  name: string;
@@ -91,9 +104,18 @@ declare const chains: {
91
104
  thresholdNetworkUrl: string;
92
105
  environment: "MOCK" | "TESTNET" | "MAINNET";
93
106
  };
107
+ readonly localcofhe: {
108
+ name: string;
109
+ id: number;
110
+ network: string;
111
+ coFheUrl: string;
112
+ verifierUrl: string;
113
+ thresholdNetworkUrl: string;
114
+ environment: "MOCK" | "TESTNET" | "MAINNET";
115
+ };
94
116
  };
95
117
 
96
118
  declare const getChainById: (chainId: number) => CofheChain | undefined;
97
119
  declare const getChainByName: (name: string) => CofheChain | undefined;
98
120
 
99
- export { CofheChain, arbSepolia, baseSepolia, chains, getChainById, getChainByName, hardhat, sepolia };
121
+ export { CofheChain, arbSepolia, baseSepolia, chains, getChainById, getChainByName, hardhat, localcofhe, sepolia };
package/dist/chains.js CHANGED
@@ -1 +1 @@
1
- export { arbSepolia, baseSepolia, chains, getChainById, getChainByName, hardhat, sepolia } from './chunk-GZCQQYVI.js';
1
+ export { arbSepolia, baseSepolia, chains, getChainById, getChainByName, hardhat, localcofhe, sepolia } from './chunk-WEAZ25JO.js';
@@ -136,7 +136,7 @@ var SealingKey = class _SealingKey {
136
136
  };
137
137
  };
138
138
  };
139
- var GenerateSealingKey = async () => {
139
+ var GenerateSealingKey = () => {
140
140
  const sodiumKeypair = nacl.box.keyPair();
141
141
  return new SealingKey(toHexString(sodiumKeypair.secretKey), toHexString(sodiumKeypair.publicKey));
142
142
  };
@@ -144,6 +144,7 @@ var SerializedSealingPair = z.object({
144
144
  privateKey: z.string(),
145
145
  publicKey: z.string()
146
146
  });
147
+ var DEFAULT_EXPIRATION_FN = () => Math.round(Date.now() / 1e3) + 7 * 24 * 60 * 60;
147
148
  var zPermitWithDefaults = z.object({
148
149
  name: z.string().optional().default("Unnamed Permit"),
149
150
  type: z.enum(["self", "sharing", "recipient"]),
@@ -152,7 +153,7 @@ var zPermitWithDefaults = z.object({
152
153
  }).refine((val) => val !== zeroAddress, {
153
154
  message: "Permit issuer :: must not be zeroAddress"
154
155
  }),
155
- expiration: z.number().optional().default(1e12),
156
+ expiration: z.number().optional().default(DEFAULT_EXPIRATION_FN),
156
157
  recipient: z.string().optional().default(zeroAddress).refine((val) => isAddress(val), {
157
158
  message: "Permit recipient :: invalid address"
158
159
  }),
@@ -177,13 +178,17 @@ var SelfPermitOptionsValidator = z.object({
177
178
  type: z.literal("self").optional().default("self"),
178
179
  issuer: z.string().refine((val) => isAddress(val), {
179
180
  message: "Self permit issuer :: invalid address"
181
+ }).refine((val) => is0xPrefixed(val), {
182
+ message: "Self permit issuer :: must be 0x prefixed"
180
183
  }).refine((val) => val !== zeroAddress, {
181
184
  message: "Self permit issuer :: must not be zeroAddress"
182
185
  }),
183
186
  name: z.string().optional().default("Unnamed Permit"),
184
- expiration: z.number().optional().default(1e12),
187
+ expiration: z.number().optional().default(DEFAULT_EXPIRATION_FN),
185
188
  recipient: z.string().optional().default(zeroAddress).refine((val) => isAddress(val), {
186
189
  message: "Self permit recipient :: invalid address"
190
+ }).refine((val) => is0xPrefixed(val), {
191
+ message: "Self permit recipient :: must be 0x prefixed"
187
192
  }).refine((val) => val === zeroAddress, {
188
193
  message: "Self permit recipient :: must be zeroAddress"
189
194
  }),
@@ -211,16 +216,20 @@ var SharingPermitOptionsValidator = z.object({
211
216
  type: z.literal("sharing").optional().default("sharing"),
212
217
  issuer: z.string().refine((val) => isAddress(val), {
213
218
  message: "Sharing permit issuer :: invalid address"
219
+ }).refine((val) => is0xPrefixed(val), {
220
+ message: "Sharing permit issuer :: must be 0x prefixed"
214
221
  }).refine((val) => val !== zeroAddress, {
215
222
  message: "Sharing permit issuer :: must not be zeroAddress"
216
223
  }),
217
224
  recipient: z.string().refine((val) => isAddress(val), {
218
225
  message: "Sharing permit recipient :: invalid address"
226
+ }).refine((val) => is0xPrefixed(val), {
227
+ message: "Sharing permit recipient :: must be 0x prefixed"
219
228
  }).refine((val) => val !== zeroAddress, {
220
229
  message: "Sharing permit recipient :: must not be zeroAddress"
221
230
  }),
222
231
  name: z.string().optional().default("Unnamed Permit"),
223
- expiration: z.number().optional().default(1e12),
232
+ expiration: z.number().optional().default(DEFAULT_EXPIRATION_FN),
224
233
  validatorId: z.number().optional().default(0),
225
234
  validatorContract: z.string().optional().default(zeroAddress).refine((val) => isAddress(val), {
226
235
  message: "Sharing permit validatorContract :: invalid address"
@@ -245,11 +254,15 @@ var ImportPermitOptionsValidator = z.object({
245
254
  type: z.literal("recipient").optional().default("recipient"),
246
255
  issuer: z.string().refine((val) => isAddress(val), {
247
256
  message: "Import permit issuer :: invalid address"
257
+ }).refine((val) => is0xPrefixed(val), {
258
+ message: "Import permit issuer :: must be 0x prefixed"
248
259
  }).refine((val) => val !== zeroAddress, {
249
260
  message: "Import permit issuer :: must not be zeroAddress"
250
261
  }),
251
262
  recipient: z.string().refine((val) => isAddress(val), {
252
263
  message: "Import permit recipient :: invalid address"
264
+ }).refine((val) => is0xPrefixed(val), {
265
+ message: "Import permit recipient :: must be 0x prefixed"
253
266
  }).refine((val) => val !== zeroAddress, {
254
267
  message: "Import permit recipient :: must not be zeroAddress"
255
268
  }),
@@ -259,7 +272,7 @@ var ImportPermitOptionsValidator = z.object({
259
272
  message: "Import permit :: issuerSignature must be provided"
260
273
  }),
261
274
  name: z.string().optional().default("Unnamed Permit"),
262
- expiration: z.number().optional().default(1e12),
275
+ expiration: z.number().optional().default(DEFAULT_EXPIRATION_FN),
263
276
  validatorId: z.number().optional().default(0),
264
277
  validatorContract: z.string().optional().default(zeroAddress).refine((val) => isAddress(val), {
265
278
  message: "Import permit validatorContract :: invalid address"
@@ -382,41 +395,43 @@ var PermitUtils = {
382
395
  /**
383
396
  * Create a self permit for personal use
384
397
  */
385
- createSelf: async (options) => {
398
+ createSelf: (options) => {
386
399
  const validation = validateSelfPermitOptions(options);
387
400
  if (!validation.success) {
388
401
  throw new Error(
389
402
  "PermitUtils :: createSelf :: Parsing SelfPermitOptions failed " + JSON.stringify(validation.error, null, 2)
390
403
  );
391
404
  }
392
- const sealingPair = await GenerateSealingKey();
393
- return {
405
+ const sealingPair = GenerateSealingKey();
406
+ const permit = {
394
407
  ...validation.data,
395
408
  sealingPair,
396
409
  _signedDomain: void 0
397
410
  };
411
+ return permit;
398
412
  },
399
413
  /**
400
414
  * Create a sharing permit to be shared with another user
401
415
  */
402
- createSharing: async (options) => {
416
+ createSharing: (options) => {
403
417
  const validation = validateSharingPermitOptions(options);
404
418
  if (!validation.success) {
405
419
  throw new Error(
406
420
  "PermitUtils :: createSharing :: Parsing SharingPermitOptions failed " + JSON.stringify(validation.error, null, 2)
407
421
  );
408
422
  }
409
- const sealingPair = await GenerateSealingKey();
410
- return {
423
+ const sealingPair = GenerateSealingKey();
424
+ const permit = {
411
425
  ...validation.data,
412
426
  sealingPair,
413
427
  _signedDomain: void 0
414
428
  };
429
+ return permit;
415
430
  },
416
431
  /**
417
432
  * Import a shared permit from various input formats
418
433
  */
419
- importShared: async (options) => {
434
+ importShared: (options) => {
420
435
  let parsedOptions;
421
436
  if (typeof options === "string") {
422
437
  try {
@@ -440,12 +455,13 @@ var PermitUtils = {
440
455
  "PermitUtils :: importShared :: Parsing ImportPermitOptions failed " + JSON.stringify(validation.error, null, 2)
441
456
  );
442
457
  }
443
- const sealingPair = await GenerateSealingKey();
444
- return {
458
+ const sealingPair = GenerateSealingKey();
459
+ const permit = {
445
460
  ...validation.data,
446
461
  sealingPair,
447
462
  _signedDomain: void 0
448
463
  };
464
+ return permit;
449
465
  },
450
466
  /**
451
467
  * Sign a permit with the provided wallet client
@@ -486,21 +502,21 @@ var PermitUtils = {
486
502
  * Create and sign a self permit in one operation
487
503
  */
488
504
  createSelfAndSign: async (options, publicClient, walletClient) => {
489
- const permit = await PermitUtils.createSelf(options);
505
+ const permit = PermitUtils.createSelf(options);
490
506
  return PermitUtils.sign(permit, publicClient, walletClient);
491
507
  },
492
508
  /**
493
509
  * Create and sign a sharing permit in one operation
494
510
  */
495
511
  createSharingAndSign: async (options, publicClient, walletClient) => {
496
- const permit = await PermitUtils.createSharing(options);
512
+ const permit = PermitUtils.createSharing(options);
497
513
  return PermitUtils.sign(permit, publicClient, walletClient);
498
514
  },
499
515
  /**
500
516
  * Import and sign a shared permit in one operation from various input formats
501
517
  */
502
518
  importSharedAndSign: async (options, publicClient, walletClient) => {
503
- const permit = await PermitUtils.importShared(options);
519
+ const permit = PermitUtils.importShared(options);
504
520
  return PermitUtils.sign(permit, publicClient, walletClient);
505
521
  },
506
522
  /**
@@ -674,14 +690,12 @@ var PermitUtils = {
674
690
  return PermitUtils.matchesDomain(permit, domain);
675
691
  }
676
692
  };
693
+ var PERMIT_STORE_DEFAULTS = {
694
+ permits: {},
695
+ activePermitHash: {}
696
+ };
677
697
  var _permitStore = createStore()(
678
- persist(
679
- () => ({
680
- permits: {},
681
- activePermitHash: {}
682
- }),
683
- { name: "cofhesdk-permits" }
684
- )
698
+ persist(() => PERMIT_STORE_DEFAULTS, { name: "cofhesdk-permits" })
685
699
  );
686
700
  var clearStaleStore = () => {
687
701
  const state = _permitStore.getState();
@@ -801,4 +815,4 @@ var permitStore = {
801
815
  resetStore
802
816
  };
803
817
 
804
- export { GenerateSealingKey, ImportPermitOptionsValidator, ImportPermitValidator, PermitUtils, SealingKey, SelfPermitOptionsValidator, SelfPermitValidator, SharingPermitOptionsValidator, SharingPermitValidator, SignatureTypes, SignatureUtils, ValidationUtils, _permitStore, clearStaleStore, getActivePermit, getActivePermitHash, getPermit, getPermits, getSignatureTypesAndMessage, permitStore, removeActivePermitHash, removePermit, resetStore, setActivePermitHash, setPermit, validateImportPermit, validateImportPermitOptions, validateSelfPermit, validateSelfPermitOptions, validateSharingPermit, validateSharingPermitOptions };
818
+ export { GenerateSealingKey, ImportPermitOptionsValidator, ImportPermitValidator, PERMIT_STORE_DEFAULTS, PermitUtils, SealingKey, SelfPermitOptionsValidator, SelfPermitValidator, SharingPermitOptionsValidator, SharingPermitValidator, SignatureTypes, SignatureUtils, ValidationUtils, _permitStore, clearStaleStore, getActivePermit, getActivePermitHash, getPermit, getPermits, getSignatureTypesAndMessage, permitStore, removeActivePermitHash, removePermit, resetStore, setActivePermitHash, setPermit, validateImportPermit, validateImportPermitOptions, validateSelfPermit, validateSelfPermitOptions, validateSharingPermit, validateSharingPermitOptions };
@@ -74,12 +74,24 @@ var hardhat = defineChain({
74
74
  environment: "MOCK"
75
75
  });
76
76
 
77
+ // chains/chains/localcofhe.ts
78
+ var localcofhe = defineChain({
79
+ id: 420105,
80
+ name: "Local Cofhe",
81
+ network: "localhost",
82
+ coFheUrl: "http://127.0.0.1:9448",
83
+ verifierUrl: "http://127.0.0.1:3001",
84
+ thresholdNetworkUrl: "http://127.0.0.1:3000",
85
+ environment: "TESTNET"
86
+ });
87
+
77
88
  // chains/index.ts
78
89
  var chains = {
79
90
  sepolia,
80
91
  arbSepolia,
81
92
  baseSepolia,
82
- hardhat
93
+ hardhat,
94
+ localcofhe
83
95
  };
84
96
  var getChainById = (chainId) => {
85
97
  return Object.values(chains).find((chain) => chain.id === chainId);
@@ -90,4 +102,4 @@ var getChainByName = (name) => {
90
102
  );
91
103
  };
92
104
 
93
- export { arbSepolia, baseSepolia, chains, getChainById, getChainByName, hardhat, sepolia };
105
+ export { arbSepolia, baseSepolia, chains, getChainById, getChainByName, hardhat, localcofhe, sepolia };