@cofhe/sdk 0.6.1 → 0.7.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 +43 -0
- package/acps/acp.ts +411 -0
- package/acps/index.ts +70 -0
- package/{permits → acps}/onchain-utils.ts +49 -24
- package/acps/sealing.ts +90 -0
- package/acps/signature.ts +89 -0
- package/acps/store.ts +172 -0
- package/acps/test/acp.test.ts +615 -0
- package/acps/test/localstorage.test.ts +105 -0
- package/acps/test/sealing.test.ts +77 -0
- package/acps/test/store.test.ts +88 -0
- package/acps/test/validation.test.ts +361 -0
- package/acps/test-utils.ts +32 -0
- package/acps/types.ts +252 -0
- package/acps/validation.ts +392 -0
- package/adapters/test/ethers5.test.ts +4 -1
- package/adapters/test/ethers6.test.ts +4 -1
- package/adapters/test/wagmi.test.ts +5 -2
- package/chains/chains/stagingCofhe.ts +21 -0
- package/chains/index.ts +3 -1
- package/chains/test/chains.test.ts +2 -1
- package/core/acps.ts +625 -0
- package/core/client.ts +136 -39
- package/core/clientTypes.ts +52 -41
- package/core/config.ts +66 -5
- package/core/decrypt/MockThresholdNetworkAbi.ts +20 -11
- package/core/decrypt/apiError.ts +104 -0
- package/core/decrypt/cofheMocksDecryptForTx.ts +11 -11
- package/core/decrypt/cofheMocksDecryptForView.ts +7 -7
- package/core/decrypt/decryptForTxBuilder.ts +102 -102
- package/core/decrypt/decryptForViewBuilder.ts +90 -90
- package/core/decrypt/submitRetry.ts +38 -30
- package/core/decrypt/tnDecryptV1.ts +5 -5
- package/core/decrypt/tnDecryptV2.ts +25 -21
- package/core/decrypt/tnSealOutputV1.ts +4 -3
- package/core/decrypt/tnSealOutputV2.ts +24 -18
- package/core/encrypt/cofheMocksZkVerifySign.ts +59 -74
- package/core/encrypt/encryptInputsBuilder.ts +86 -52
- package/core/encrypt/zkPackProveVerify.ts +25 -18
- package/core/error.ts +34 -6
- package/core/index.ts +4 -14
- package/core/test/acpDefaults.test.ts +52 -0
- package/core/test/acps.test.ts +596 -0
- package/core/test/apiError.test.ts +130 -0
- package/core/test/client.test.ts +22 -19
- package/core/test/config.test.ts +25 -5
- package/core/test/decrypt.test.ts +40 -35
- package/core/test/decryptBuilders.test.ts +68 -68
- package/core/test/decryptErrorCodes.test.ts +217 -0
- package/core/test/encryptInputsBuilder.test.ts +72 -41
- package/core/test/pollCallbacks.test.ts +89 -18
- package/core/test/stagingRedirect.ts +18 -0
- package/core/test/submitRetry.test.ts +182 -0
- package/core/types.ts +9 -69
- package/dist/acp-Wi6isVQI.d.cts +407 -0
- package/dist/acp-Wi6isVQI.d.ts +407 -0
- package/dist/acps.cjs +1081 -0
- package/dist/acps.d.cts +480 -0
- package/dist/acps.d.ts +480 -0
- package/dist/acps.js +2 -0
- package/dist/chains.cjs +14 -1
- package/dist/chains.d.cts +30 -1
- package/dist/chains.d.ts +30 -1
- package/dist/chains.js +1 -1
- package/dist/{chunk-NOC3PYB7.js → chunk-43USWPEH.js} +930 -580
- package/dist/{chunk-MTRAXQXC.js → chunk-N6IDQRRU.js} +14 -2
- package/dist/chunk-Q7CBWGQX.js +1029 -0
- package/dist/{clientTypes-CyUvRRzA.d.ts → clientTypes-BN3nbzYM.d.ts} +342 -165
- package/dist/{clientTypes-BDy1qIBu.d.cts → clientTypes-CYZjFznO.d.cts} +342 -165
- package/dist/core.cjs +1358 -1002
- package/dist/core.d.cts +31 -9
- package/dist/core.d.ts +31 -9
- package/dist/core.js +3 -3
- package/dist/node.cjs +1293 -952
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +3 -3
- package/dist/web.cjs +1293 -952
- package/dist/web.d.cts +2 -2
- package/dist/web.d.ts +2 -2
- package/dist/web.js +3 -3
- package/node/test/inherited.test.ts +75 -65
- package/node/test/tfheinit.test.ts +23 -8
- package/package.json +6 -6
- package/web/test/client.web.test.ts +5 -1
- package/web/test/inherited.web.test.ts +75 -65
- package/web/test/tfheinit.web.test.ts +14 -5
- package/web/test/worker.config.web.test.ts +38 -23
- package/web/test/worker.output.web.test.ts +25 -24
- package/core/encrypt/encryptUtils.ts +0 -67
- package/core/permits.ts +0 -216
- package/core/test/permits.test.ts +0 -596
- package/dist/chunk-VB62WYPL.js +0 -978
- package/dist/permit-DnVMDT5h.d.cts +0 -376
- package/dist/permit-DnVMDT5h.d.ts +0 -376
- package/dist/permits.cjs +0 -1026
- package/dist/permits.d.cts +0 -353
- package/dist/permits.d.ts +0 -353
- package/dist/permits.js +0 -2
- package/permits/index.ts +0 -68
- package/permits/permit.ts +0 -385
- package/permits/sealing.ts +0 -131
- package/permits/signature.ts +0 -79
- package/permits/store.ts +0 -157
- package/permits/test/localstorage.test.ts +0 -113
- package/permits/test/permit.test.ts +0 -557
- package/permits/test/sealing.test.ts +0 -84
- package/permits/test/store.test.ts +0 -88
- package/permits/test/validation.test.ts +0 -361
- package/permits/test-utils.ts +0 -28
- package/permits/types.ts +0 -204
- package/permits/validation.ts +0 -327
- /package/{permits → acps}/utils.ts +0 -0
package/dist/core.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { a as CofheConfig, c as CofheClientParams, b as CofheClient, d as CofheClientConnectionState, F as FheTypes } from './clientTypes-
|
|
2
|
-
export {
|
|
1
|
+
import { a as CofheConfig, c as CofheClientParams, b as CofheClient, d as CofheClientConnectionState, F as FheTypes } from './clientTypes-CYZjFznO.cjs';
|
|
2
|
+
export { A as AnyExternalHash, i as CofheClientACPs, C as CofheInputConfig, h as CofheInternalConfig, K as DecryptEndpoint, a2 as DecryptForTxBuilder, a3 as DecryptForTxResult, a1 as DecryptForViewBuilder, J as DecryptPollCallbackContext, G as DecryptPollCallbackFunction, $ as EncryptInputsBuilder, a0 as EncryptInputsBuilderUnset, M as EncryptSetStateFn, T as EncryptStep, N as EncryptStepCallbackContext, R as Encryptable, p as EncryptableAddress, j as EncryptableBool, E as EncryptableItem, B as EncryptableToExternalHashMap, o as EncryptableUint128, l as EncryptableUint16, m as EncryptableUint32, n as EncryptableUint64, k as EncryptableUint8, q as EncryptedNumber, y as ExternalAddressHash, s as ExternalBoolHash, z as ExternalHashProof, D as ExternalItemHashes, x as ExternalUint128Hash, u as ExternalUint16Hash, v as ExternalUint32Hash, w as ExternalUint64Hash, t as ExternalUint8Hash, Q as FheAllUTypes, X as FheKeyDeserializer, r as FheTypeValue, O as FheUintUTypes, H as HashPlusProofResult, I as IStorage, Z as KeysStorage, _ as KeysStore, L as LiteralToPrimitive, P as Primitive, U as UnsealedItem, a4 as ZkBuilderAndCrsGenerator, a5 as ZkProveWorkerFunction, a6 as ZkProveWorkerRequest, a7 as ZkProveWorkerResponse, f as assertNoRenamedConfigKeys, e as createCofheConfigBase, Y as createKeysStore, W as fetchKeys, g as getCofheConfigItem, S as isEncryptableItem, V as isLastEncryptionStep, a8 as zkProveWithWorker } from './clientTypes-CYZjFznO.cjs';
|
|
3
3
|
import { Hex, PublicClient } from 'viem';
|
|
4
4
|
import './types-C07FK-cL.cjs';
|
|
5
5
|
import 'zod';
|
|
6
|
-
import './
|
|
6
|
+
import './acp-Wi6isVQI.cjs';
|
|
7
7
|
import 'zustand/vanilla';
|
|
8
8
|
|
|
9
9
|
declare const InitialConnectStore: CofheClientConnectionState;
|
|
@@ -48,12 +48,13 @@ declare enum CofheErrorCode {
|
|
|
48
48
|
MissingWalletClient = "MISSING_WALLET_CLIENT",
|
|
49
49
|
MissingProviderParam = "MISSING_PROVIDER_PARAM",
|
|
50
50
|
EmptySecurityZonesParam = "EMPTY_SECURITY_ZONES_PARAM",
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
InvalidACPData = "INVALID_ACP_DATA",
|
|
52
|
+
InvalidACPDomain = "INVALID_ACP_DOMAIN",
|
|
53
|
+
ACPNotFound = "ACP_NOT_FOUND",
|
|
54
|
+
CannotRemoveLastACP = "CANNOT_REMOVE_LAST_ACP",
|
|
55
55
|
AccountUninitialized = "ACCOUNT_UNINITIALIZED",
|
|
56
56
|
ChainIdUninitialized = "CHAIN_ID_UNINITIALIZED",
|
|
57
|
+
ConsumingContractUninitialized = "CONSUMING_CONTRACT_UNINITIALIZED",
|
|
57
58
|
SealOutputFailed = "SEAL_OUTPUT_FAILED",
|
|
58
59
|
SealOutputReturnedNull = "SEAL_OUTPUT_RETURNED_NULL",
|
|
59
60
|
InvalidUtype = "INVALID_UTYPE",
|
|
@@ -80,7 +81,25 @@ declare enum CofheErrorCode {
|
|
|
80
81
|
FetchKeysFailed = "FETCH_KEYS_FAILED",
|
|
81
82
|
PublicWalletGetChainIdFailed = "PUBLIC_WALLET_GET_CHAIN_ID_FAILED",
|
|
82
83
|
PublicWalletGetAddressesFailed = "PUBLIC_WALLET_GET_ADDRESSES_FAILED",
|
|
83
|
-
RehydrateKeysStoreFailed = "REHYDRATE_KEYS_STORE_FAILED"
|
|
84
|
+
RehydrateKeysStoreFailed = "REHYDRATE_KEYS_STORE_FAILED",
|
|
85
|
+
BadRequest = "BAD_REQUEST",
|
|
86
|
+
UnknownChain = "UNKNOWN_CHAIN",
|
|
87
|
+
ACPMalformed = "ACP_MALFORMED",
|
|
88
|
+
ACPDenied = "ACP_DENIED",
|
|
89
|
+
ACPExpired = "ACP_EXPIRED",
|
|
90
|
+
ACPInvalid = "ACP_INVALID",
|
|
91
|
+
ACPRevoked = "ACP_REVOKED",
|
|
92
|
+
NotPubliclyAllowed = "NOT_PUBLICLY_ALLOWED",
|
|
93
|
+
CtNotFound = "CT_NOT_FOUND",
|
|
94
|
+
UnsupportedSecurityZone = "UNSUPPORTED_SECURITY_ZONE",
|
|
95
|
+
UnsupportedType = "UNSUPPORTED_TYPE",
|
|
96
|
+
SigningFailed = "SIGNING_FAILED",
|
|
97
|
+
CtSourceError = "CT_SOURCE_ERROR",
|
|
98
|
+
ACPVerifierError = "ACP_VERIFIER_ERROR",
|
|
99
|
+
CtSourceTimeout = "CT_SOURCE_TIMEOUT",
|
|
100
|
+
ACPVerifierTimeout = "ACP_VERIFIER_TIMEOUT",
|
|
101
|
+
ACPRequired = "ACP_REQUIRED",
|
|
102
|
+
SealFailed = "SEAL_FAILED"
|
|
84
103
|
}
|
|
85
104
|
type CofheErrorParams = {
|
|
86
105
|
code: CofheErrorCode;
|
|
@@ -88,6 +107,8 @@ type CofheErrorParams = {
|
|
|
88
107
|
cause?: Error;
|
|
89
108
|
hint?: string;
|
|
90
109
|
context?: Record<string, unknown>;
|
|
110
|
+
/** Raw backend `error` string, when this error originated from a threshold-network response. */
|
|
111
|
+
apiErrorCode?: string;
|
|
91
112
|
};
|
|
92
113
|
/**
|
|
93
114
|
* CofheError class
|
|
@@ -105,7 +126,8 @@ declare class CofheError extends Error {
|
|
|
105
126
|
readonly cause?: Error;
|
|
106
127
|
readonly hint?: string;
|
|
107
128
|
readonly context?: Record<string, unknown>;
|
|
108
|
-
|
|
129
|
+
readonly apiErrorCode?: string;
|
|
130
|
+
constructor({ code, message, cause, hint, context, apiErrorCode }: CofheErrorParams);
|
|
109
131
|
/**
|
|
110
132
|
* Creates a CofheError from an unknown error
|
|
111
133
|
* If the error is a CofheError, it is returned unchanged, else a new CofheError is created
|
package/dist/core.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { a as CofheConfig, c as CofheClientParams, b as CofheClient, d as CofheClientConnectionState, F as FheTypes } from './clientTypes-
|
|
2
|
-
export {
|
|
1
|
+
import { a as CofheConfig, c as CofheClientParams, b as CofheClient, d as CofheClientConnectionState, F as FheTypes } from './clientTypes-BN3nbzYM.js';
|
|
2
|
+
export { A as AnyExternalHash, i as CofheClientACPs, C as CofheInputConfig, h as CofheInternalConfig, K as DecryptEndpoint, a2 as DecryptForTxBuilder, a3 as DecryptForTxResult, a1 as DecryptForViewBuilder, J as DecryptPollCallbackContext, G as DecryptPollCallbackFunction, $ as EncryptInputsBuilder, a0 as EncryptInputsBuilderUnset, M as EncryptSetStateFn, T as EncryptStep, N as EncryptStepCallbackContext, R as Encryptable, p as EncryptableAddress, j as EncryptableBool, E as EncryptableItem, B as EncryptableToExternalHashMap, o as EncryptableUint128, l as EncryptableUint16, m as EncryptableUint32, n as EncryptableUint64, k as EncryptableUint8, q as EncryptedNumber, y as ExternalAddressHash, s as ExternalBoolHash, z as ExternalHashProof, D as ExternalItemHashes, x as ExternalUint128Hash, u as ExternalUint16Hash, v as ExternalUint32Hash, w as ExternalUint64Hash, t as ExternalUint8Hash, Q as FheAllUTypes, X as FheKeyDeserializer, r as FheTypeValue, O as FheUintUTypes, H as HashPlusProofResult, I as IStorage, Z as KeysStorage, _ as KeysStore, L as LiteralToPrimitive, P as Primitive, U as UnsealedItem, a4 as ZkBuilderAndCrsGenerator, a5 as ZkProveWorkerFunction, a6 as ZkProveWorkerRequest, a7 as ZkProveWorkerResponse, f as assertNoRenamedConfigKeys, e as createCofheConfigBase, Y as createKeysStore, W as fetchKeys, g as getCofheConfigItem, S as isEncryptableItem, V as isLastEncryptionStep, a8 as zkProveWithWorker } from './clientTypes-BN3nbzYM.js';
|
|
3
3
|
import { Hex, PublicClient } from 'viem';
|
|
4
4
|
import './types-C07FK-cL.js';
|
|
5
5
|
import 'zod';
|
|
6
|
-
import './
|
|
6
|
+
import './acp-Wi6isVQI.js';
|
|
7
7
|
import 'zustand/vanilla';
|
|
8
8
|
|
|
9
9
|
declare const InitialConnectStore: CofheClientConnectionState;
|
|
@@ -48,12 +48,13 @@ declare enum CofheErrorCode {
|
|
|
48
48
|
MissingWalletClient = "MISSING_WALLET_CLIENT",
|
|
49
49
|
MissingProviderParam = "MISSING_PROVIDER_PARAM",
|
|
50
50
|
EmptySecurityZonesParam = "EMPTY_SECURITY_ZONES_PARAM",
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
InvalidACPData = "INVALID_ACP_DATA",
|
|
52
|
+
InvalidACPDomain = "INVALID_ACP_DOMAIN",
|
|
53
|
+
ACPNotFound = "ACP_NOT_FOUND",
|
|
54
|
+
CannotRemoveLastACP = "CANNOT_REMOVE_LAST_ACP",
|
|
55
55
|
AccountUninitialized = "ACCOUNT_UNINITIALIZED",
|
|
56
56
|
ChainIdUninitialized = "CHAIN_ID_UNINITIALIZED",
|
|
57
|
+
ConsumingContractUninitialized = "CONSUMING_CONTRACT_UNINITIALIZED",
|
|
57
58
|
SealOutputFailed = "SEAL_OUTPUT_FAILED",
|
|
58
59
|
SealOutputReturnedNull = "SEAL_OUTPUT_RETURNED_NULL",
|
|
59
60
|
InvalidUtype = "INVALID_UTYPE",
|
|
@@ -80,7 +81,25 @@ declare enum CofheErrorCode {
|
|
|
80
81
|
FetchKeysFailed = "FETCH_KEYS_FAILED",
|
|
81
82
|
PublicWalletGetChainIdFailed = "PUBLIC_WALLET_GET_CHAIN_ID_FAILED",
|
|
82
83
|
PublicWalletGetAddressesFailed = "PUBLIC_WALLET_GET_ADDRESSES_FAILED",
|
|
83
|
-
RehydrateKeysStoreFailed = "REHYDRATE_KEYS_STORE_FAILED"
|
|
84
|
+
RehydrateKeysStoreFailed = "REHYDRATE_KEYS_STORE_FAILED",
|
|
85
|
+
BadRequest = "BAD_REQUEST",
|
|
86
|
+
UnknownChain = "UNKNOWN_CHAIN",
|
|
87
|
+
ACPMalformed = "ACP_MALFORMED",
|
|
88
|
+
ACPDenied = "ACP_DENIED",
|
|
89
|
+
ACPExpired = "ACP_EXPIRED",
|
|
90
|
+
ACPInvalid = "ACP_INVALID",
|
|
91
|
+
ACPRevoked = "ACP_REVOKED",
|
|
92
|
+
NotPubliclyAllowed = "NOT_PUBLICLY_ALLOWED",
|
|
93
|
+
CtNotFound = "CT_NOT_FOUND",
|
|
94
|
+
UnsupportedSecurityZone = "UNSUPPORTED_SECURITY_ZONE",
|
|
95
|
+
UnsupportedType = "UNSUPPORTED_TYPE",
|
|
96
|
+
SigningFailed = "SIGNING_FAILED",
|
|
97
|
+
CtSourceError = "CT_SOURCE_ERROR",
|
|
98
|
+
ACPVerifierError = "ACP_VERIFIER_ERROR",
|
|
99
|
+
CtSourceTimeout = "CT_SOURCE_TIMEOUT",
|
|
100
|
+
ACPVerifierTimeout = "ACP_VERIFIER_TIMEOUT",
|
|
101
|
+
ACPRequired = "ACP_REQUIRED",
|
|
102
|
+
SealFailed = "SEAL_FAILED"
|
|
84
103
|
}
|
|
85
104
|
type CofheErrorParams = {
|
|
86
105
|
code: CofheErrorCode;
|
|
@@ -88,6 +107,8 @@ type CofheErrorParams = {
|
|
|
88
107
|
cause?: Error;
|
|
89
108
|
hint?: string;
|
|
90
109
|
context?: Record<string, unknown>;
|
|
110
|
+
/** Raw backend `error` string, when this error originated from a threshold-network response. */
|
|
111
|
+
apiErrorCode?: string;
|
|
91
112
|
};
|
|
92
113
|
/**
|
|
93
114
|
* CofheError class
|
|
@@ -105,7 +126,8 @@ declare class CofheError extends Error {
|
|
|
105
126
|
readonly cause?: Error;
|
|
106
127
|
readonly hint?: string;
|
|
107
128
|
readonly context?: Record<string, unknown>;
|
|
108
|
-
|
|
129
|
+
readonly apiErrorCode?: string;
|
|
130
|
+
constructor({ code, message, cause, hint, context, apiErrorCode }: CofheErrorParams);
|
|
109
131
|
/**
|
|
110
132
|
* Creates a CofheError from an unknown error
|
|
111
133
|
* If the error is a CofheError, it is returned unchanged, else a new CofheError is created
|
package/dist/core.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { InitialConnectStore as CONNECT_STORE_DEFAULTS, CofheError, CofheErrorCode, DecryptForTxBuilder, DecryptForViewBuilder, EncryptInputsBuilder, EncryptStep, Encryptable, FheAllUTypes, FheTypes, FheUintUTypes,
|
|
2
|
-
import './chunk-
|
|
3
|
-
import './chunk-
|
|
1
|
+
export { InitialConnectStore as CONNECT_STORE_DEFAULTS, CofheError, CofheErrorCode, DecryptForTxBuilder, DecryptForViewBuilder, EncryptInputsBuilder, EncryptStep, Encryptable, FheAllUTypes, FheTypes, FheUintUTypes, assertNoRenamedConfigKeys, cofheFetch, createCofheClientBase, createCofheConfigBase, createKeysStore, fetchKeys, fheTypeToString, getCofheConfigItem, getCofheDebugInterceptors, isCofheError, isEncryptableItem, isLastEncryptionStep, setCofheDebugInterceptors, verifyDecryptResult, zkProveWithWorker } from './chunk-43USWPEH.js';
|
|
2
|
+
import './chunk-N6IDQRRU.js';
|
|
3
|
+
import './chunk-Q7CBWGQX.js';
|
|
4
4
|
export { MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY, MOCKS_THRESHOLD_NETWORK_ADDRESS, MOCKS_ZK_VERIFIER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY, TASK_MANAGER_ADDRESS, TFHE_RS_SAFE_SERIALIZATION_SIZE_LIMIT, TFHE_RS_ZK_MAX_BITS } from './chunk-ESMZCFJY.js';
|