@cofhe/sdk 0.1.1 → 0.2.1

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 (107) hide show
  1. package/CHANGELOG.md +22 -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/defineChain.ts +2 -2
  11. package/chains/index.ts +3 -1
  12. package/chains/types.ts +3 -3
  13. package/core/baseBuilder.ts +30 -49
  14. package/core/client.test.ts +200 -72
  15. package/core/client.ts +152 -148
  16. package/core/clientTypes.ts +114 -0
  17. package/core/config.test.ts +30 -11
  18. package/core/config.ts +26 -13
  19. package/core/consts.ts +18 -0
  20. package/core/decrypt/cofheMocksSealOutput.ts +2 -4
  21. package/core/decrypt/decryptHandleBuilder.ts +51 -45
  22. package/core/decrypt/{tnSealOutput.ts → tnSealOutputV1.ts} +1 -1
  23. package/core/decrypt/tnSealOutputV2.ts +298 -0
  24. package/core/encrypt/cofheMocksZkVerifySign.ts +15 -16
  25. package/core/encrypt/encryptInputsBuilder.test.ts +132 -116
  26. package/core/encrypt/encryptInputsBuilder.ts +159 -111
  27. package/core/encrypt/encryptUtils.ts +6 -3
  28. package/core/encrypt/zkPackProveVerify.ts +70 -8
  29. package/core/error.ts +0 -2
  30. package/core/fetchKeys.test.ts +1 -18
  31. package/core/fetchKeys.ts +0 -26
  32. package/core/index.ts +37 -17
  33. package/core/keyStore.ts +65 -38
  34. package/core/permits.test.ts +255 -4
  35. package/core/permits.ts +83 -18
  36. package/core/types.ts +198 -152
  37. package/core/utils.ts +43 -1
  38. package/dist/adapters.d.cts +38 -20
  39. package/dist/adapters.d.ts +38 -20
  40. package/dist/chains.cjs +18 -8
  41. package/dist/chains.d.cts +31 -9
  42. package/dist/chains.d.ts +31 -9
  43. package/dist/chains.js +1 -1
  44. package/dist/{chunk-KFGPTJ6X.js → chunk-I5WFEYXX.js} +1768 -1526
  45. package/dist/{chunk-LU7BMUUT.js → chunk-R3B5TMVX.js} +330 -197
  46. package/dist/{chunk-GZCQQYVI.js → chunk-TBLR7NNE.js} +18 -9
  47. package/dist/{types-PhwGgQvs.d.ts → clientTypes-RqkgkV2i.d.ts} +331 -429
  48. package/dist/{types-bB7wLj0q.d.cts → clientTypes-e4filDzK.d.cts} +331 -429
  49. package/dist/core.cjs +3000 -2625
  50. package/dist/core.d.cts +113 -7
  51. package/dist/core.d.ts +113 -7
  52. package/dist/core.js +3 -3
  53. package/dist/node.cjs +2851 -2526
  54. package/dist/node.d.cts +4 -4
  55. package/dist/node.d.ts +4 -4
  56. package/dist/node.js +4 -3
  57. package/dist/{permit-S9CnI6MF.d.cts → permit-MZ502UBl.d.cts} +54 -41
  58. package/dist/{permit-S9CnI6MF.d.ts → permit-MZ502UBl.d.ts} +54 -41
  59. package/dist/permits.cjs +328 -195
  60. package/dist/permits.d.cts +113 -825
  61. package/dist/permits.d.ts +113 -825
  62. package/dist/permits.js +1 -1
  63. package/dist/types-YiAC4gig.d.cts +33 -0
  64. package/dist/types-YiAC4gig.d.ts +33 -0
  65. package/dist/web.cjs +3067 -2527
  66. package/dist/web.d.cts +22 -6
  67. package/dist/web.d.ts +22 -6
  68. package/dist/web.js +185 -9
  69. package/dist/zkProve.worker.cjs +93 -0
  70. package/dist/zkProve.worker.d.cts +2 -0
  71. package/dist/zkProve.worker.d.ts +2 -0
  72. package/dist/zkProve.worker.js +91 -0
  73. package/node/client.test.ts +20 -25
  74. package/node/encryptInputs.test.ts +18 -38
  75. package/node/index.ts +1 -0
  76. package/package.json +15 -15
  77. package/permits/index.ts +1 -0
  78. package/permits/localstorage.test.ts +9 -14
  79. package/permits/onchain-utils.ts +221 -0
  80. package/permits/permit.test.ts +76 -27
  81. package/permits/permit.ts +58 -95
  82. package/permits/sealing.test.ts +3 -3
  83. package/permits/sealing.ts +2 -2
  84. package/permits/store.test.ts +10 -50
  85. package/permits/store.ts +9 -21
  86. package/permits/test-utils.ts +11 -3
  87. package/permits/types.ts +39 -9
  88. package/permits/utils.ts +0 -5
  89. package/permits/validation.test.ts +29 -32
  90. package/permits/validation.ts +114 -176
  91. package/web/client.web.test.ts +20 -25
  92. package/web/config.web.test.ts +0 -2
  93. package/web/encryptInputs.web.test.ts +31 -54
  94. package/web/index.ts +65 -1
  95. package/web/storage.ts +19 -5
  96. package/web/worker.builder.web.test.ts +148 -0
  97. package/web/worker.config.web.test.ts +329 -0
  98. package/web/worker.output.web.test.ts +84 -0
  99. package/web/workerManager.test.ts +80 -0
  100. package/web/workerManager.ts +214 -0
  101. package/web/workerManager.web.test.ts +114 -0
  102. package/web/zkProve.worker.ts +133 -0
  103. package/core/result.test.ts +0 -180
  104. package/core/result.ts +0 -67
  105. package/core/test-utils.ts +0 -45
  106. package/dist/types-KImPrEIe.d.cts +0 -48
  107. package/dist/types-KImPrEIe.d.ts +0 -48
package/dist/core.d.cts CHANGED
@@ -1,16 +1,122 @@
1
- import { C as CofhesdkClientParams, a as CofhesdkClient } from './types-bB7wLj0q.cjs';
2
- export { f as CofhesdkClientConnectionState, h as CofhesdkClientPermits, b as CofhesdkConfig, M as CofhesdkError, N as CofhesdkErrorCode, Q as CofhesdkErrorParams, d as CofhesdkInputConfig, e as CofhesdkInternalConfig, a5 as DecryptHandlesBuilder, a4 as EncryptInputsBuilder, B as EncryptSetStateFn, K as EncryptStep, H as Encryptable, o as EncryptableAddress, i as EncryptableBool, E as EncryptableItem, A as EncryptableToEncryptedItemInputMap, n as EncryptableUint128, k as EncryptableUint16, l as EncryptableUint32, m as EncryptableUint64, j as EncryptableUint8, y as EncryptedAddressInput, r as EncryptedBoolInput, q as EncryptedItemInput, z as EncryptedItemInputs, p as EncryptedNumber, w as EncryptedUint128Input, t as EncryptedUint16Input, x as EncryptedUint256Input, u as EncryptedUint32Input, v as EncryptedUint64Input, s as EncryptedUint8Input, G as FheAllUTypes, a0 as FheKeyDeserializer, F as FheTypes, D as FheUintUTypes, I as IStorage, a2 as KeysStorage, a3 as KeysStore, L as LiteralToPrimitive, P as Primitive, Z as Result, R as ResultErr, T as ResultErrOrInternal, V as ResultHttpError, S as ResultOk, W as ResultValidationError, U as UnsealedItem, a6 as ZkBuilderAndCrsGenerator, c as createCofhesdkConfigBase, a1 as createKeysStore, _ as fetchKeys, $ as fetchMultichainKeys, g as getCofhesdkConfigItem, O as isCofhesdkError, J as isEncryptableItem, X as resultWrapper, Y as resultWrapperSync } from './types-bB7wLj0q.cjs';
3
- import './permit-S9CnI6MF.cjs';
4
- import 'zod';
1
+ import { c as CofhesdkClientConnectionState, a as CofhesdkConfig, d as CofhesdkClientParams, b as CofhesdkClient, F as FheTypes } from './clientTypes-e4filDzK.cjs';
2
+ export { h as CofhesdkClientPermits, C as CofhesdkInputConfig, f as CofhesdkInternalConfig, X as DecryptHandlesBuilder, W as EncryptInputsBuilder, B as EncryptSetStateFn, M as EncryptStep, D as EncryptStepCallbackContext, J as Encryptable, o as EncryptableAddress, i as EncryptableBool, E as EncryptableItem, z as EncryptableToEncryptedItemInputMap, n as EncryptableUint128, k as EncryptableUint16, l as EncryptableUint32, m as EncryptableUint64, j as EncryptableUint8, x as EncryptedAddressInput, r as EncryptedBoolInput, q as EncryptedItemInput, y as EncryptedItemInputs, p as EncryptedNumber, w as EncryptedUint128Input, t as EncryptedUint16Input, u as EncryptedUint32Input, v as EncryptedUint64Input, s as EncryptedUint8Input, H as FheAllUTypes, R as FheKeyDeserializer, A as FheTypeValue, G as FheUintUTypes, I as IStorage, T as KeysStorage, V as KeysStore, L as LiteralToPrimitive, P as Primitive, U as UnsealedItem, Z as ZkBuilderAndCrsGenerator, Y as ZkProveWorkerFunction, _ as ZkProveWorkerRequest, $ as ZkProveWorkerResponse, O as assertCorrectEncryptedItemInput, e as createCofhesdkConfigBase, S as createKeysStore, Q as fetchKeys, g as getCofhesdkConfigItem, K as isEncryptableItem, N as isLastEncryptionStep, a0 as zkProveWithWorker } from './clientTypes-e4filDzK.cjs';
5
3
  import 'viem';
6
- import './types-KImPrEIe.cjs';
4
+ import './types-YiAC4gig.cjs';
5
+ import 'zod';
6
+ import './permit-MZ502UBl.cjs';
7
7
  import 'zustand/vanilla';
8
8
 
9
+ declare const InitialConnectStore: CofhesdkClientConnectionState;
9
10
  /**
10
11
  * Creates a CoFHE SDK client instance (base implementation)
11
12
  * @param {CofhesdkClientParams} opts - Initialization options including config and platform-specific serializers
12
13
  * @returns {CofhesdkClient} - The CoFHE SDK client instance
13
14
  */
14
- declare function createCofhesdkClientBase(opts: CofhesdkClientParams): CofhesdkClient;
15
+ declare function createCofhesdkClientBase<TConfig extends CofhesdkConfig>(opts: CofhesdkClientParams<TConfig>): CofhesdkClient<TConfig>;
16
+
17
+ declare enum CofhesdkErrorCode {
18
+ InternalError = "INTERNAL_ERROR",
19
+ UnknownEnvironment = "UNKNOWN_ENVIRONMENT",
20
+ InitTfheFailed = "INIT_TFHE_FAILED",
21
+ InitViemFailed = "INIT_VIEM_FAILED",
22
+ InitEthersFailed = "INIT_ETHERS_FAILED",
23
+ NotConnected = "NOT_CONNECTED",
24
+ MissingPublicClient = "MISSING_PUBLIC_CLIENT",
25
+ MissingWalletClient = "MISSING_WALLET_CLIENT",
26
+ MissingProviderParam = "MISSING_PROVIDER_PARAM",
27
+ EmptySecurityZonesParam = "EMPTY_SECURITY_ZONES_PARAM",
28
+ InvalidPermitData = "INVALID_PERMIT_DATA",
29
+ InvalidPermitDomain = "INVALID_PERMIT_DOMAIN",
30
+ PermitNotFound = "PERMIT_NOT_FOUND",
31
+ CannotRemoveLastPermit = "CANNOT_REMOVE_LAST_PERMIT",
32
+ AccountUninitialized = "ACCOUNT_UNINITIALIZED",
33
+ ChainIdUninitialized = "CHAIN_ID_UNINITIALIZED",
34
+ SealOutputFailed = "SEAL_OUTPUT_FAILED",
35
+ SealOutputReturnedNull = "SEAL_OUTPUT_RETURNED_NULL",
36
+ InvalidUtype = "INVALID_UTYPE",
37
+ DecryptFailed = "DECRYPT_FAILED",
38
+ DecryptReturnedNull = "DECRYPT_RETURNED_NULL",
39
+ ZkMocksInsertCtHashesFailed = "ZK_MOCKS_INSERT_CT_HASHES_FAILED",
40
+ ZkMocksCalcCtHashesFailed = "ZK_MOCKS_CALC_CT_HASHES_FAILED",
41
+ ZkMocksVerifySignFailed = "ZK_MOCKS_VERIFY_SIGN_FAILED",
42
+ ZkMocksCreateProofSignatureFailed = "ZK_MOCKS_CREATE_PROOF_SIGNATURE_FAILED",
43
+ ZkVerifyFailed = "ZK_VERIFY_FAILED",
44
+ ZkPackFailed = "ZK_PACK_FAILED",
45
+ ZkProveFailed = "ZK_PROVE_FAILED",
46
+ EncryptRemainingInItems = "ENCRYPT_REMAINING_IN_ITEMS",
47
+ ZkUninitialized = "ZK_UNINITIALIZED",
48
+ ZkVerifierUrlUninitialized = "ZK_VERIFIER_URL_UNINITIALIZED",
49
+ ThresholdNetworkUrlUninitialized = "THRESHOLD_NETWORK_URL_UNINITIALIZED",
50
+ MissingConfig = "MISSING_CONFIG",
51
+ UnsupportedChain = "UNSUPPORTED_CHAIN",
52
+ MissingZkBuilderAndCrsGenerator = "MISSING_ZK_BUILDER_AND_CRS_GENERATOR",
53
+ MissingTfhePublicKeyDeserializer = "MISSING_TFHE_PUBLIC_KEY_DESERIALIZER",
54
+ MissingCompactPkeCrsDeserializer = "MISSING_COMPACT_PKE_CRS_DESERIALIZER",
55
+ MissingFheKey = "MISSING_FHE_KEY",
56
+ MissingCrs = "MISSING_CRS",
57
+ FetchKeysFailed = "FETCH_KEYS_FAILED",
58
+ PublicWalletGetChainIdFailed = "PUBLIC_WALLET_GET_CHAIN_ID_FAILED",
59
+ PublicWalletGetAddressesFailed = "PUBLIC_WALLET_GET_ADDRESSES_FAILED",
60
+ RehydrateKeysStoreFailed = "REHYDRATE_KEYS_STORE_FAILED"
61
+ }
62
+ type CofhesdkErrorParams = {
63
+ code: CofhesdkErrorCode;
64
+ message: string;
65
+ cause?: Error;
66
+ hint?: string;
67
+ context?: Record<string, unknown>;
68
+ };
69
+ /**
70
+ * CofhesdkError class
71
+ * This class is used to create errors that are specific to the CoFHE SDK
72
+ * It extends the Error class and adds a code, cause, hint, and context
73
+ * The code is used to identify the type of error
74
+ * The cause is used to indicate the inner error that caused the CofhesdkError
75
+ * The hint is used to provide a hint about how to fix the error
76
+ * The context is used to provide additional context about the state that caused the error
77
+ * The serialize method is used to serialize the error to a JSON string
78
+ * The toString method is used to provide a human-readable string representation of the error
79
+ */
80
+ declare class CofhesdkError extends Error {
81
+ readonly code: CofhesdkErrorCode;
82
+ readonly cause?: Error;
83
+ readonly hint?: string;
84
+ readonly context?: Record<string, unknown>;
85
+ constructor({ code, message, cause, hint, context }: CofhesdkErrorParams);
86
+ /**
87
+ * Creates a CofhesdkError from an unknown error
88
+ * If the error is a CofhesdkError, it is returned unchanged, else a new CofhesdkError is created
89
+ * If a wrapperError is provided, it is used to create the new CofhesdkError, else a default is used
90
+ */
91
+ static fromError(error: unknown, wrapperError?: CofhesdkErrorParams): CofhesdkError;
92
+ /**
93
+ * Serializes the error to JSON string with proper handling of Error objects
94
+ */
95
+ serialize(): string;
96
+ /**
97
+ * Returns a human-readable string representation of the error
98
+ */
99
+ toString(): string;
100
+ }
101
+ declare const isCofhesdkError: (error: unknown) => error is CofhesdkError;
102
+
103
+ /** Main Task Manager contract address */
104
+ declare const TASK_MANAGER_ADDRESS: "0xeA30c4B8b44078Bbf8a6ef5b9f1eC1626C7848D9";
105
+ /** Mock ZK Verifier contract address (used for testing) */
106
+ declare const MOCKS_ZK_VERIFIER_ADDRESS: "0x0000000000000000000000000000000000005001";
107
+ /** Mock Query Decrypter contract address (used for testing) */
108
+ declare const MOCKS_QUERY_DECRYPTER_ADDRESS: "0x0000000000000000000000000000000000005002";
109
+ /** Test Bed contract address (used for testing) */
110
+ declare const TEST_BED_ADDRESS: "0x0000000000000000000000000000000000005003";
111
+ /** Private key for the Mock ZK Verifier signer account */
112
+ declare const MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY: "0x6C8D7F768A6BB4AAFE85E8A2F5A9680355239C7E14646ED62B044E39DE154512";
113
+ /** Address for the Mock ZK Verifier signer account */
114
+ declare const MOCKS_ZK_VERIFIER_SIGNER_ADDRESS: "0x6E12D8C87503D4287c294f2Fdef96ACd9DFf6bd2";
115
+
116
+ /**
117
+ * Converts FheTypes enum to string representation for serialization
118
+ * Used when passing data to Web Workers or other serialization contexts
119
+ */
120
+ declare function fheTypeToString(utype: FheTypes): string;
15
121
 
16
- export { CofhesdkClient, CofhesdkClientParams, createCofhesdkClientBase };
122
+ export { InitialConnectStore as CONNECT_STORE_DEFAULTS, CofhesdkClient, CofhesdkClientConnectionState, CofhesdkClientParams, CofhesdkConfig, CofhesdkError, CofhesdkErrorCode, type CofhesdkErrorParams, FheTypes, MOCKS_QUERY_DECRYPTER_ADDRESS, MOCKS_ZK_VERIFIER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY, TASK_MANAGER_ADDRESS, TEST_BED_ADDRESS, createCofhesdkClientBase, fheTypeToString, isCofhesdkError };
package/dist/core.d.ts CHANGED
@@ -1,16 +1,122 @@
1
- import { C as CofhesdkClientParams, a as CofhesdkClient } from './types-PhwGgQvs.js';
2
- export { f as CofhesdkClientConnectionState, h as CofhesdkClientPermits, b as CofhesdkConfig, M as CofhesdkError, N as CofhesdkErrorCode, Q as CofhesdkErrorParams, d as CofhesdkInputConfig, e as CofhesdkInternalConfig, a5 as DecryptHandlesBuilder, a4 as EncryptInputsBuilder, B as EncryptSetStateFn, K as EncryptStep, H as Encryptable, o as EncryptableAddress, i as EncryptableBool, E as EncryptableItem, A as EncryptableToEncryptedItemInputMap, n as EncryptableUint128, k as EncryptableUint16, l as EncryptableUint32, m as EncryptableUint64, j as EncryptableUint8, y as EncryptedAddressInput, r as EncryptedBoolInput, q as EncryptedItemInput, z as EncryptedItemInputs, p as EncryptedNumber, w as EncryptedUint128Input, t as EncryptedUint16Input, x as EncryptedUint256Input, u as EncryptedUint32Input, v as EncryptedUint64Input, s as EncryptedUint8Input, G as FheAllUTypes, a0 as FheKeyDeserializer, F as FheTypes, D as FheUintUTypes, I as IStorage, a2 as KeysStorage, a3 as KeysStore, L as LiteralToPrimitive, P as Primitive, Z as Result, R as ResultErr, T as ResultErrOrInternal, V as ResultHttpError, S as ResultOk, W as ResultValidationError, U as UnsealedItem, a6 as ZkBuilderAndCrsGenerator, c as createCofhesdkConfigBase, a1 as createKeysStore, _ as fetchKeys, $ as fetchMultichainKeys, g as getCofhesdkConfigItem, O as isCofhesdkError, J as isEncryptableItem, X as resultWrapper, Y as resultWrapperSync } from './types-PhwGgQvs.js';
3
- import './permit-S9CnI6MF.js';
4
- import 'zod';
1
+ import { c as CofhesdkClientConnectionState, a as CofhesdkConfig, d as CofhesdkClientParams, b as CofhesdkClient, F as FheTypes } from './clientTypes-RqkgkV2i.js';
2
+ export { h as CofhesdkClientPermits, C as CofhesdkInputConfig, f as CofhesdkInternalConfig, X as DecryptHandlesBuilder, W as EncryptInputsBuilder, B as EncryptSetStateFn, M as EncryptStep, D as EncryptStepCallbackContext, J as Encryptable, o as EncryptableAddress, i as EncryptableBool, E as EncryptableItem, z as EncryptableToEncryptedItemInputMap, n as EncryptableUint128, k as EncryptableUint16, l as EncryptableUint32, m as EncryptableUint64, j as EncryptableUint8, x as EncryptedAddressInput, r as EncryptedBoolInput, q as EncryptedItemInput, y as EncryptedItemInputs, p as EncryptedNumber, w as EncryptedUint128Input, t as EncryptedUint16Input, u as EncryptedUint32Input, v as EncryptedUint64Input, s as EncryptedUint8Input, H as FheAllUTypes, R as FheKeyDeserializer, A as FheTypeValue, G as FheUintUTypes, I as IStorage, T as KeysStorage, V as KeysStore, L as LiteralToPrimitive, P as Primitive, U as UnsealedItem, Z as ZkBuilderAndCrsGenerator, Y as ZkProveWorkerFunction, _ as ZkProveWorkerRequest, $ as ZkProveWorkerResponse, O as assertCorrectEncryptedItemInput, e as createCofhesdkConfigBase, S as createKeysStore, Q as fetchKeys, g as getCofhesdkConfigItem, K as isEncryptableItem, N as isLastEncryptionStep, a0 as zkProveWithWorker } from './clientTypes-RqkgkV2i.js';
5
3
  import 'viem';
6
- import './types-KImPrEIe.js';
4
+ import './types-YiAC4gig.js';
5
+ import 'zod';
6
+ import './permit-MZ502UBl.js';
7
7
  import 'zustand/vanilla';
8
8
 
9
+ declare const InitialConnectStore: CofhesdkClientConnectionState;
9
10
  /**
10
11
  * Creates a CoFHE SDK client instance (base implementation)
11
12
  * @param {CofhesdkClientParams} opts - Initialization options including config and platform-specific serializers
12
13
  * @returns {CofhesdkClient} - The CoFHE SDK client instance
13
14
  */
14
- declare function createCofhesdkClientBase(opts: CofhesdkClientParams): CofhesdkClient;
15
+ declare function createCofhesdkClientBase<TConfig extends CofhesdkConfig>(opts: CofhesdkClientParams<TConfig>): CofhesdkClient<TConfig>;
16
+
17
+ declare enum CofhesdkErrorCode {
18
+ InternalError = "INTERNAL_ERROR",
19
+ UnknownEnvironment = "UNKNOWN_ENVIRONMENT",
20
+ InitTfheFailed = "INIT_TFHE_FAILED",
21
+ InitViemFailed = "INIT_VIEM_FAILED",
22
+ InitEthersFailed = "INIT_ETHERS_FAILED",
23
+ NotConnected = "NOT_CONNECTED",
24
+ MissingPublicClient = "MISSING_PUBLIC_CLIENT",
25
+ MissingWalletClient = "MISSING_WALLET_CLIENT",
26
+ MissingProviderParam = "MISSING_PROVIDER_PARAM",
27
+ EmptySecurityZonesParam = "EMPTY_SECURITY_ZONES_PARAM",
28
+ InvalidPermitData = "INVALID_PERMIT_DATA",
29
+ InvalidPermitDomain = "INVALID_PERMIT_DOMAIN",
30
+ PermitNotFound = "PERMIT_NOT_FOUND",
31
+ CannotRemoveLastPermit = "CANNOT_REMOVE_LAST_PERMIT",
32
+ AccountUninitialized = "ACCOUNT_UNINITIALIZED",
33
+ ChainIdUninitialized = "CHAIN_ID_UNINITIALIZED",
34
+ SealOutputFailed = "SEAL_OUTPUT_FAILED",
35
+ SealOutputReturnedNull = "SEAL_OUTPUT_RETURNED_NULL",
36
+ InvalidUtype = "INVALID_UTYPE",
37
+ DecryptFailed = "DECRYPT_FAILED",
38
+ DecryptReturnedNull = "DECRYPT_RETURNED_NULL",
39
+ ZkMocksInsertCtHashesFailed = "ZK_MOCKS_INSERT_CT_HASHES_FAILED",
40
+ ZkMocksCalcCtHashesFailed = "ZK_MOCKS_CALC_CT_HASHES_FAILED",
41
+ ZkMocksVerifySignFailed = "ZK_MOCKS_VERIFY_SIGN_FAILED",
42
+ ZkMocksCreateProofSignatureFailed = "ZK_MOCKS_CREATE_PROOF_SIGNATURE_FAILED",
43
+ ZkVerifyFailed = "ZK_VERIFY_FAILED",
44
+ ZkPackFailed = "ZK_PACK_FAILED",
45
+ ZkProveFailed = "ZK_PROVE_FAILED",
46
+ EncryptRemainingInItems = "ENCRYPT_REMAINING_IN_ITEMS",
47
+ ZkUninitialized = "ZK_UNINITIALIZED",
48
+ ZkVerifierUrlUninitialized = "ZK_VERIFIER_URL_UNINITIALIZED",
49
+ ThresholdNetworkUrlUninitialized = "THRESHOLD_NETWORK_URL_UNINITIALIZED",
50
+ MissingConfig = "MISSING_CONFIG",
51
+ UnsupportedChain = "UNSUPPORTED_CHAIN",
52
+ MissingZkBuilderAndCrsGenerator = "MISSING_ZK_BUILDER_AND_CRS_GENERATOR",
53
+ MissingTfhePublicKeyDeserializer = "MISSING_TFHE_PUBLIC_KEY_DESERIALIZER",
54
+ MissingCompactPkeCrsDeserializer = "MISSING_COMPACT_PKE_CRS_DESERIALIZER",
55
+ MissingFheKey = "MISSING_FHE_KEY",
56
+ MissingCrs = "MISSING_CRS",
57
+ FetchKeysFailed = "FETCH_KEYS_FAILED",
58
+ PublicWalletGetChainIdFailed = "PUBLIC_WALLET_GET_CHAIN_ID_FAILED",
59
+ PublicWalletGetAddressesFailed = "PUBLIC_WALLET_GET_ADDRESSES_FAILED",
60
+ RehydrateKeysStoreFailed = "REHYDRATE_KEYS_STORE_FAILED"
61
+ }
62
+ type CofhesdkErrorParams = {
63
+ code: CofhesdkErrorCode;
64
+ message: string;
65
+ cause?: Error;
66
+ hint?: string;
67
+ context?: Record<string, unknown>;
68
+ };
69
+ /**
70
+ * CofhesdkError class
71
+ * This class is used to create errors that are specific to the CoFHE SDK
72
+ * It extends the Error class and adds a code, cause, hint, and context
73
+ * The code is used to identify the type of error
74
+ * The cause is used to indicate the inner error that caused the CofhesdkError
75
+ * The hint is used to provide a hint about how to fix the error
76
+ * The context is used to provide additional context about the state that caused the error
77
+ * The serialize method is used to serialize the error to a JSON string
78
+ * The toString method is used to provide a human-readable string representation of the error
79
+ */
80
+ declare class CofhesdkError extends Error {
81
+ readonly code: CofhesdkErrorCode;
82
+ readonly cause?: Error;
83
+ readonly hint?: string;
84
+ readonly context?: Record<string, unknown>;
85
+ constructor({ code, message, cause, hint, context }: CofhesdkErrorParams);
86
+ /**
87
+ * Creates a CofhesdkError from an unknown error
88
+ * If the error is a CofhesdkError, it is returned unchanged, else a new CofhesdkError is created
89
+ * If a wrapperError is provided, it is used to create the new CofhesdkError, else a default is used
90
+ */
91
+ static fromError(error: unknown, wrapperError?: CofhesdkErrorParams): CofhesdkError;
92
+ /**
93
+ * Serializes the error to JSON string with proper handling of Error objects
94
+ */
95
+ serialize(): string;
96
+ /**
97
+ * Returns a human-readable string representation of the error
98
+ */
99
+ toString(): string;
100
+ }
101
+ declare const isCofhesdkError: (error: unknown) => error is CofhesdkError;
102
+
103
+ /** Main Task Manager contract address */
104
+ declare const TASK_MANAGER_ADDRESS: "0xeA30c4B8b44078Bbf8a6ef5b9f1eC1626C7848D9";
105
+ /** Mock ZK Verifier contract address (used for testing) */
106
+ declare const MOCKS_ZK_VERIFIER_ADDRESS: "0x0000000000000000000000000000000000005001";
107
+ /** Mock Query Decrypter contract address (used for testing) */
108
+ declare const MOCKS_QUERY_DECRYPTER_ADDRESS: "0x0000000000000000000000000000000000005002";
109
+ /** Test Bed contract address (used for testing) */
110
+ declare const TEST_BED_ADDRESS: "0x0000000000000000000000000000000000005003";
111
+ /** Private key for the Mock ZK Verifier signer account */
112
+ declare const MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY: "0x6C8D7F768A6BB4AAFE85E8A2F5A9680355239C7E14646ED62B044E39DE154512";
113
+ /** Address for the Mock ZK Verifier signer account */
114
+ declare const MOCKS_ZK_VERIFIER_SIGNER_ADDRESS: "0x6E12D8C87503D4287c294f2Fdef96ACd9DFf6bd2";
115
+
116
+ /**
117
+ * Converts FheTypes enum to string representation for serialization
118
+ * Used when passing data to Web Workers or other serialization contexts
119
+ */
120
+ declare function fheTypeToString(utype: FheTypes): string;
15
121
 
16
- export { CofhesdkClient, CofhesdkClientParams, createCofhesdkClientBase };
122
+ export { InitialConnectStore as CONNECT_STORE_DEFAULTS, CofhesdkClient, CofhesdkClientConnectionState, CofhesdkClientParams, CofhesdkConfig, CofhesdkError, CofhesdkErrorCode, type CofhesdkErrorParams, FheTypes, MOCKS_QUERY_DECRYPTER_ADDRESS, MOCKS_ZK_VERIFIER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY, TASK_MANAGER_ADDRESS, TEST_BED_ADDRESS, createCofhesdkClientBase, fheTypeToString, isCofhesdkError };
package/dist/core.js CHANGED
@@ -1,3 +1,3 @@
1
- export { CofhesdkError, CofhesdkErrorCode, DecryptHandlesBuilder, EncryptInputsBuilder, EncryptStep, Encryptable, FheAllUTypes, FheTypes, FheUintUTypes, ResultErr, ResultErrOrInternal, ResultHttpError, ResultOk, ResultValidationError, createCofhesdkClientBase, createCofhesdkConfigBase, createKeysStore, fetchKeys, fetchMultichainKeys, getCofhesdkConfigItem, isCofhesdkError, isEncryptableItem, resultWrapper, resultWrapperSync } from './chunk-KFGPTJ6X.js';
2
- import './chunk-GZCQQYVI.js';
3
- import './chunk-LU7BMUUT.js';
1
+ export { InitialConnectStore as CONNECT_STORE_DEFAULTS, CofhesdkError, CofhesdkErrorCode, DecryptHandlesBuilder, EncryptInputsBuilder, EncryptStep, Encryptable, FheAllUTypes, FheTypes, FheUintUTypes, assertCorrectEncryptedItemInput, createCofhesdkClientBase, createCofhesdkConfigBase, createKeysStore, fetchKeys, fheTypeToString, getCofhesdkConfigItem, isCofhesdkError, isEncryptableItem, isLastEncryptionStep, zkProveWithWorker } from './chunk-I5WFEYXX.js';
2
+ import './chunk-TBLR7NNE.js';
3
+ export { MOCKS_QUERY_DECRYPTER_ADDRESS, MOCKS_ZK_VERIFIER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY, TASK_MANAGER_ADDRESS, TEST_BED_ADDRESS } from './chunk-R3B5TMVX.js';