@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.
- package/CHANGELOG.md +14 -0
- package/adapters/ethers6.ts +28 -28
- package/adapters/hardhat.ts +0 -1
- package/adapters/index.test.ts +14 -19
- package/adapters/smartWallet.ts +81 -73
- package/adapters/test-utils.ts +45 -45
- package/adapters/types.ts +3 -3
- package/chains/chains/localcofhe.ts +14 -0
- package/chains/chains.test.ts +2 -1
- package/chains/index.ts +3 -1
- package/core/baseBuilder.ts +30 -49
- package/core/client.test.ts +94 -77
- package/core/client.ts +133 -149
- package/core/clientTypes.ts +108 -0
- package/core/config.test.ts +22 -11
- package/core/config.ts +16 -9
- package/core/decrypt/decryptHandleBuilder.ts +51 -45
- package/core/decrypt/{tnSealOutput.ts → tnSealOutputV1.ts} +1 -1
- package/core/decrypt/tnSealOutputV2.ts +298 -0
- package/core/encrypt/cofheMocksZkVerifySign.ts +16 -10
- package/core/encrypt/encryptInputsBuilder.test.ts +132 -116
- package/core/encrypt/encryptInputsBuilder.ts +159 -111
- package/core/encrypt/encryptUtils.ts +6 -3
- package/core/encrypt/zkPackProveVerify.ts +70 -8
- package/core/error.ts +0 -2
- package/core/fetchKeys.test.ts +1 -18
- package/core/fetchKeys.ts +0 -26
- package/core/index.ts +29 -17
- package/core/keyStore.ts +65 -38
- package/core/permits.test.ts +253 -1
- package/core/permits.ts +80 -16
- package/core/types.ts +198 -152
- package/core/utils.ts +43 -1
- package/dist/adapters.d.cts +38 -20
- package/dist/adapters.d.ts +38 -20
- package/dist/chains.cjs +14 -1
- package/dist/chains.d.cts +23 -1
- package/dist/chains.d.ts +23 -1
- package/dist/chains.js +1 -1
- package/dist/{chunk-LU7BMUUT.js → chunk-UGBVZNRT.js} +39 -25
- package/dist/{chunk-GZCQQYVI.js → chunk-WEAZ25JO.js} +14 -2
- package/dist/{chunk-KFGPTJ6X.js → chunk-WGCRJCBR.js} +1920 -1692
- package/dist/{types-bB7wLj0q.d.cts → clientTypes-5_1nwtUe.d.cts} +308 -347
- package/dist/{types-PhwGgQvs.d.ts → clientTypes-Es7fyi65.d.ts} +308 -347
- package/dist/core.cjs +2872 -2632
- package/dist/core.d.cts +101 -6
- package/dist/core.d.ts +101 -6
- package/dist/core.js +3 -3
- package/dist/node.cjs +2716 -2520
- package/dist/node.d.cts +3 -3
- package/dist/node.d.ts +3 -3
- package/dist/node.js +4 -3
- package/dist/{permit-S9CnI6MF.d.cts → permit-fUSe6KKq.d.cts} +31 -15
- package/dist/{permit-S9CnI6MF.d.ts → permit-fUSe6KKq.d.ts} +31 -15
- package/dist/permits.cjs +39 -24
- package/dist/permits.d.cts +137 -148
- package/dist/permits.d.ts +137 -148
- package/dist/permits.js +1 -1
- package/dist/web.cjs +2929 -2518
- package/dist/web.d.cts +21 -5
- package/dist/web.d.ts +21 -5
- package/dist/web.js +185 -9
- package/dist/zkProve.worker.cjs +93 -0
- package/dist/zkProve.worker.d.cts +2 -0
- package/dist/zkProve.worker.d.ts +2 -0
- package/dist/zkProve.worker.js +91 -0
- package/node/client.test.ts +20 -25
- package/node/encryptInputs.test.ts +18 -38
- package/node/index.ts +1 -0
- package/package.json +14 -14
- package/permits/index.ts +1 -0
- package/permits/localstorage.test.ts +0 -1
- package/permits/permit.test.ts +25 -22
- package/permits/permit.ts +30 -21
- package/permits/sealing.test.ts +3 -3
- package/permits/sealing.ts +2 -2
- package/permits/store.ts +5 -7
- package/permits/test-utils.ts +1 -1
- package/permits/types.ts +17 -0
- package/permits/utils.ts +0 -1
- package/permits/validation.ts +24 -4
- package/web/client.web.test.ts +20 -25
- package/web/config.web.test.ts +0 -2
- package/web/encryptInputs.web.test.ts +31 -54
- package/web/index.ts +65 -1
- package/web/storage.ts +19 -5
- package/web/worker.builder.web.test.ts +148 -0
- package/web/worker.config.web.test.ts +329 -0
- package/web/worker.output.web.test.ts +84 -0
- package/web/workerManager.test.ts +80 -0
- package/web/workerManager.ts +214 -0
- package/web/workerManager.web.test.ts +114 -0
- package/web/zkProve.worker.ts +133 -0
- package/core/result.test.ts +0 -180
- package/core/result.ts +0 -67
- package/core/test-utils.ts +0 -45
package/dist/core.d.cts
CHANGED
|
@@ -1,16 +1,111 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
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 {
|
|
2
|
-
export {
|
|
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,
|
|
2
|
-
import './chunk-
|
|
3
|
-
import './chunk-
|
|
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';
|