@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
package/dist/core.d.cts CHANGED
@@ -1,16 +1,111 @@
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-5_1nwtUe.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-5_1nwtUe.cjs';
5
3
  import 'viem';
6
4
  import './types-KImPrEIe.cjs';
5
+ import 'zod';
6
+ import './permit-fUSe6KKq.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
+ declare const MOCKS_ZK_VERIFIER_SIGNER_ADDRESS = "0x6E12D8C87503D4287c294f2Fdef96ACd9DFf6bd2";
104
+
105
+ /**
106
+ * Converts FheTypes enum to string representation for serialization
107
+ * Used when passing data to Web Workers or other serialization contexts
108
+ */
109
+ declare function fheTypeToString(utype: FheTypes): string;
15
110
 
16
- export { CofhesdkClient, CofhesdkClientParams, createCofhesdkClientBase };
111
+ export { InitialConnectStore as CONNECT_STORE_DEFAULTS, CofhesdkClient, CofhesdkClientConnectionState, CofhesdkClientParams, CofhesdkConfig, CofhesdkError, CofhesdkErrorCode, type CofhesdkErrorParams, FheTypes, MOCKS_ZK_VERIFIER_SIGNER_ADDRESS, createCofhesdkClientBase, fheTypeToString, isCofhesdkError };
package/dist/core.d.ts CHANGED
@@ -1,16 +1,111 @@
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-Es7fyi65.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-Es7fyi65.js';
5
3
  import 'viem';
6
4
  import './types-KImPrEIe.js';
5
+ import 'zod';
6
+ import './permit-fUSe6KKq.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
+ declare const MOCKS_ZK_VERIFIER_SIGNER_ADDRESS = "0x6E12D8C87503D4287c294f2Fdef96ACd9DFf6bd2";
104
+
105
+ /**
106
+ * Converts FheTypes enum to string representation for serialization
107
+ * Used when passing data to Web Workers or other serialization contexts
108
+ */
109
+ declare function fheTypeToString(utype: FheTypes): string;
15
110
 
16
- export { CofhesdkClient, CofhesdkClientParams, createCofhesdkClientBase };
111
+ export { InitialConnectStore as CONNECT_STORE_DEFAULTS, CofhesdkClient, CofhesdkClientConnectionState, CofhesdkClientParams, CofhesdkConfig, CofhesdkError, CofhesdkErrorCode, type CofhesdkErrorParams, FheTypes, MOCKS_ZK_VERIFIER_SIGNER_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, MOCKS_ZK_VERIFIER_SIGNER_ADDRESS, assertCorrectEncryptedItemInput, createCofhesdkClientBase, createCofhesdkConfigBase, createKeysStore, fetchKeys, fheTypeToString, getCofhesdkConfigItem, isCofhesdkError, isEncryptableItem, isLastEncryptionStep, zkProveWithWorker } from './chunk-WGCRJCBR.js';
2
+ import './chunk-WEAZ25JO.js';
3
+ import './chunk-UGBVZNRT.js';