@cofhe/sdk 1.0.0-alpha.0 → 1.0.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 +51 -0
- package/acps/onchain-utils.ts +15 -10
- package/acps/sealing.ts +22 -2
- package/acps/test/aclServedAddresses.test.ts +65 -0
- package/acps/test/sealing.test.ts +51 -0
- package/dist/acps.cjs +122 -99
- package/dist/acps.d.cts +2 -2
- package/dist/acps.d.ts +2 -2
- package/dist/acps.js +2 -2
- package/dist/{chunk-BQWHPIYU.js → chunk-3L2IVPMI.js} +29 -6
- package/dist/{chunk-OL3DZN7A.js → chunk-O2ITEUEU.js} +3 -3
- package/dist/{chunk-6ZW76ZKB.js → chunk-WJGTPW7K.js} +1 -1
- package/dist/{clientTypes-C0A9ji5O.d.cts → clientTypes-IO6b5Um8.d.cts} +1 -1
- package/dist/{clientTypes-CcU5WvdV.d.ts → clientTypes-b1pOxOUE.d.ts} +1 -1
- package/dist/core.cjs +188 -165
- package/dist/core.d.cts +3 -3
- package/dist/core.d.ts +3 -3
- package/dist/core.js +4 -4
- package/dist/node.cjs +122 -99
- package/dist/node.d.cts +2 -2
- package/dist/node.d.ts +2 -2
- package/dist/node.js +4 -4
- package/dist/{onchain-utils-D9Z33IP7.d.cts → onchain-utils-CgOslubH.d.cts} +3 -3
- package/dist/{onchain-utils-D9Z33IP7.d.ts → onchain-utils-CgOslubH.d.ts} +3 -3
- package/dist/web.cjs +122 -99
- package/dist/web.d.cts +2 -2
- package/dist/web.d.ts +2 -2
- package/dist/web.js +4 -4
- package/dist/zkProve.worker.js +2 -2
- package/package.json +3 -3
- package/dist/{chunk-XQ32JG3T.js → chunk-J23FYAI2.js} +13 -13
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WalletClient, PublicClient, Hex } from 'viem';
|
|
2
2
|
import { C as CofheChain } from './types-C07FK-cL.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { A as ACP, k as EIP712Domain, C as CreateSelfACPOptions, J as SelfACP, g as CreateSharingACPOptions, K as SharingACP, I as ImportSharedACPOptions, R as RecipientACP, P as ACPHashFields, f as SerializedACP, O as ACPAccessStatus, S as ShareLabel, j as IncomingShare, p as AclServedAddresses, L as LabelledShare, w as ShareLabelVerifyMode, x as ShareLabelCheck, l as ACPUtils } from './onchain-utils-
|
|
4
|
+
import { A as ACP, k as EIP712Domain, C as CreateSelfACPOptions, J as SelfACP, g as CreateSharingACPOptions, K as SharingACP, I as ImportSharedACPOptions, R as RecipientACP, P as ACPHashFields, f as SerializedACP, O as ACPAccessStatus, S as ShareLabel, j as IncomingShare, p as AclServedAddresses, L as LabelledShare, w as ShareLabelVerifyMode, x as ShareLabelCheck, l as ACPUtils } from './onchain-utils-CgOslubH.js';
|
|
5
5
|
import { StoreApi } from 'zustand/vanilla';
|
|
6
6
|
|
|
7
7
|
type TfheInitializer = () => Promise<boolean>;
|
package/dist/core.cjs
CHANGED
|
@@ -41,6 +41,166 @@ function toBigInt(value) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
// core/error.ts
|
|
45
|
+
var CofheErrorCode = /* @__PURE__ */ ((CofheErrorCode2) => {
|
|
46
|
+
CofheErrorCode2["InternalError"] = "INTERNAL_ERROR";
|
|
47
|
+
CofheErrorCode2["UnknownEnvironment"] = "UNKNOWN_ENVIRONMENT";
|
|
48
|
+
CofheErrorCode2["InitTfheFailed"] = "INIT_TFHE_FAILED";
|
|
49
|
+
CofheErrorCode2["InitViemFailed"] = "INIT_VIEM_FAILED";
|
|
50
|
+
CofheErrorCode2["InitEthersFailed"] = "INIT_ETHERS_FAILED";
|
|
51
|
+
CofheErrorCode2["NotConnected"] = "NOT_CONNECTED";
|
|
52
|
+
CofheErrorCode2["MissingPublicClient"] = "MISSING_PUBLIC_CLIENT";
|
|
53
|
+
CofheErrorCode2["MissingWalletClient"] = "MISSING_WALLET_CLIENT";
|
|
54
|
+
CofheErrorCode2["MissingProviderParam"] = "MISSING_PROVIDER_PARAM";
|
|
55
|
+
CofheErrorCode2["EmptySecurityZonesParam"] = "EMPTY_SECURITY_ZONES_PARAM";
|
|
56
|
+
CofheErrorCode2["InvalidACPData"] = "INVALID_ACP_DATA";
|
|
57
|
+
CofheErrorCode2["InvalidACPDomain"] = "INVALID_ACP_DOMAIN";
|
|
58
|
+
CofheErrorCode2["ACPNotFound"] = "ACP_NOT_FOUND";
|
|
59
|
+
CofheErrorCode2["CannotRemoveLastACP"] = "CANNOT_REMOVE_LAST_ACP";
|
|
60
|
+
CofheErrorCode2["AccountUninitialized"] = "ACCOUNT_UNINITIALIZED";
|
|
61
|
+
CofheErrorCode2["ChainIdUninitialized"] = "CHAIN_ID_UNINITIALIZED";
|
|
62
|
+
CofheErrorCode2["ConsumingContractUninitialized"] = "CONSUMING_CONTRACT_UNINITIALIZED";
|
|
63
|
+
CofheErrorCode2["SealOutputFailed"] = "SEAL_OUTPUT_FAILED";
|
|
64
|
+
CofheErrorCode2["SealOutputReturnedNull"] = "SEAL_OUTPUT_RETURNED_NULL";
|
|
65
|
+
CofheErrorCode2["InvalidUtype"] = "INVALID_UTYPE";
|
|
66
|
+
CofheErrorCode2["DecryptFailed"] = "DECRYPT_FAILED";
|
|
67
|
+
CofheErrorCode2["DecryptReturnedNull"] = "DECRYPT_RETURNED_NULL";
|
|
68
|
+
CofheErrorCode2["ZkMocksInsertCtHashesFailed"] = "ZK_MOCKS_INSERT_CT_HASHES_FAILED";
|
|
69
|
+
CofheErrorCode2["ZkMocksCalcCtHashesFailed"] = "ZK_MOCKS_CALC_CT_HASHES_FAILED";
|
|
70
|
+
CofheErrorCode2["ZkMocksVerifySignFailed"] = "ZK_MOCKS_VERIFY_SIGN_FAILED";
|
|
71
|
+
CofheErrorCode2["ZkMocksCreateProofSignatureFailed"] = "ZK_MOCKS_CREATE_PROOF_SIGNATURE_FAILED";
|
|
72
|
+
CofheErrorCode2["ZkVerifyFailed"] = "ZK_VERIFY_FAILED";
|
|
73
|
+
CofheErrorCode2["ZkPackFailed"] = "ZK_PACK_FAILED";
|
|
74
|
+
CofheErrorCode2["ZkProveFailed"] = "ZK_PROVE_FAILED";
|
|
75
|
+
CofheErrorCode2["EncryptRemainingInItems"] = "ENCRYPT_REMAINING_IN_ITEMS";
|
|
76
|
+
CofheErrorCode2["ZkUninitialized"] = "ZK_UNINITIALIZED";
|
|
77
|
+
CofheErrorCode2["ZkVerifierUrlUninitialized"] = "ZK_VERIFIER_URL_UNINITIALIZED";
|
|
78
|
+
CofheErrorCode2["ThresholdNetworkUrlUninitialized"] = "THRESHOLD_NETWORK_URL_UNINITIALIZED";
|
|
79
|
+
CofheErrorCode2["MissingConfig"] = "MISSING_CONFIG";
|
|
80
|
+
CofheErrorCode2["UnsupportedChain"] = "UNSUPPORTED_CHAIN";
|
|
81
|
+
CofheErrorCode2["MissingZkBuilderAndCrsGenerator"] = "MISSING_ZK_BUILDER_AND_CRS_GENERATOR";
|
|
82
|
+
CofheErrorCode2["MissingTfhePublicKeyDeserializer"] = "MISSING_TFHE_PUBLIC_KEY_DESERIALIZER";
|
|
83
|
+
CofheErrorCode2["MissingCompactPkeCrsDeserializer"] = "MISSING_COMPACT_PKE_CRS_DESERIALIZER";
|
|
84
|
+
CofheErrorCode2["MissingFheKey"] = "MISSING_FHE_KEY";
|
|
85
|
+
CofheErrorCode2["MissingCrs"] = "MISSING_CRS";
|
|
86
|
+
CofheErrorCode2["FetchKeysFailed"] = "FETCH_KEYS_FAILED";
|
|
87
|
+
CofheErrorCode2["PublicWalletGetChainIdFailed"] = "PUBLIC_WALLET_GET_CHAIN_ID_FAILED";
|
|
88
|
+
CofheErrorCode2["PublicWalletGetAddressesFailed"] = "PUBLIC_WALLET_GET_ADDRESSES_FAILED";
|
|
89
|
+
CofheErrorCode2["RehydrateKeysStoreFailed"] = "REHYDRATE_KEYS_STORE_FAILED";
|
|
90
|
+
CofheErrorCode2["TaskManagerUnresolved"] = "TASK_MANAGER_UNRESOLVED";
|
|
91
|
+
CofheErrorCode2["BadRequest"] = "BAD_REQUEST";
|
|
92
|
+
CofheErrorCode2["UnknownChain"] = "UNKNOWN_CHAIN";
|
|
93
|
+
CofheErrorCode2["ACPMalformed"] = "ACP_MALFORMED";
|
|
94
|
+
CofheErrorCode2["ACPDenied"] = "ACP_DENIED";
|
|
95
|
+
CofheErrorCode2["ACPExpired"] = "ACP_EXPIRED";
|
|
96
|
+
CofheErrorCode2["ACPInvalid"] = "ACP_INVALID";
|
|
97
|
+
CofheErrorCode2["ACPRevoked"] = "ACP_REVOKED";
|
|
98
|
+
CofheErrorCode2["NotPubliclyAllowed"] = "NOT_PUBLICLY_ALLOWED";
|
|
99
|
+
CofheErrorCode2["CtNotFound"] = "CT_NOT_FOUND";
|
|
100
|
+
CofheErrorCode2["UnsupportedSecurityZone"] = "UNSUPPORTED_SECURITY_ZONE";
|
|
101
|
+
CofheErrorCode2["UnsupportedType"] = "UNSUPPORTED_TYPE";
|
|
102
|
+
CofheErrorCode2["SigningFailed"] = "SIGNING_FAILED";
|
|
103
|
+
CofheErrorCode2["CtSourceError"] = "CT_SOURCE_ERROR";
|
|
104
|
+
CofheErrorCode2["ACPVerifierError"] = "ACP_VERIFIER_ERROR";
|
|
105
|
+
CofheErrorCode2["CtSourceTimeout"] = "CT_SOURCE_TIMEOUT";
|
|
106
|
+
CofheErrorCode2["ACPVerifierTimeout"] = "ACP_VERIFIER_TIMEOUT";
|
|
107
|
+
CofheErrorCode2["ACPRequired"] = "ACP_REQUIRED";
|
|
108
|
+
CofheErrorCode2["SealFailed"] = "SEAL_FAILED";
|
|
109
|
+
return CofheErrorCode2;
|
|
110
|
+
})(CofheErrorCode || {});
|
|
111
|
+
var CofheError = class _CofheError extends Error {
|
|
112
|
+
code;
|
|
113
|
+
cause;
|
|
114
|
+
hint;
|
|
115
|
+
context;
|
|
116
|
+
apiErrorCode;
|
|
117
|
+
constructor({ code, message, cause, hint, context, apiErrorCode }) {
|
|
118
|
+
const fullMessage = cause ? `${message} | Caused by: ${cause.message}` : message;
|
|
119
|
+
super(fullMessage);
|
|
120
|
+
this.name = "CofheError";
|
|
121
|
+
this.code = code;
|
|
122
|
+
this.cause = cause;
|
|
123
|
+
this.hint = hint;
|
|
124
|
+
this.context = context;
|
|
125
|
+
this.apiErrorCode = apiErrorCode;
|
|
126
|
+
if (Error.captureStackTrace) {
|
|
127
|
+
Error.captureStackTrace(this, _CofheError);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Creates a CofheError from an unknown error
|
|
132
|
+
* If the error is a CofheError, it is returned unchanged, else a new CofheError is created
|
|
133
|
+
* If a wrapperError is provided, it is used to create the new CofheError, else a default is used
|
|
134
|
+
*/
|
|
135
|
+
static fromError(error, wrapperError) {
|
|
136
|
+
if (isCofheError(error))
|
|
137
|
+
return error;
|
|
138
|
+
const cause = error instanceof Error ? error : new Error(`${error}`);
|
|
139
|
+
return new _CofheError({
|
|
140
|
+
code: wrapperError?.code ?? "INTERNAL_ERROR" /* InternalError */,
|
|
141
|
+
message: wrapperError?.message ?? "An internal error occurred",
|
|
142
|
+
hint: wrapperError?.hint,
|
|
143
|
+
context: wrapperError?.context,
|
|
144
|
+
apiErrorCode: wrapperError?.apiErrorCode,
|
|
145
|
+
cause
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Serializes the error to JSON string with proper handling of Error objects
|
|
150
|
+
*/
|
|
151
|
+
serialize() {
|
|
152
|
+
return bigintSafeJsonStringify({
|
|
153
|
+
name: this.name,
|
|
154
|
+
code: this.code,
|
|
155
|
+
message: this.message,
|
|
156
|
+
hint: this.hint,
|
|
157
|
+
context: this.context,
|
|
158
|
+
apiErrorCode: this.apiErrorCode,
|
|
159
|
+
cause: this.cause ? {
|
|
160
|
+
name: this.cause.name,
|
|
161
|
+
message: this.cause.message,
|
|
162
|
+
stack: this.cause.stack
|
|
163
|
+
} : void 0,
|
|
164
|
+
stack: this.stack
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Returns a human-readable string representation of the error
|
|
169
|
+
*/
|
|
170
|
+
toString() {
|
|
171
|
+
const codeSuffix = this.apiErrorCode ? ` (api: ${this.apiErrorCode})` : "";
|
|
172
|
+
const parts = [`${this.name} [${this.code}]${codeSuffix}: ${this.message}`];
|
|
173
|
+
if (this.hint) {
|
|
174
|
+
parts.push(`Hint: ${this.hint}`);
|
|
175
|
+
}
|
|
176
|
+
if (this.context && Object.keys(this.context).length > 0) {
|
|
177
|
+
parts.push(`Context: ${bigintSafeJsonStringify(this.context)}`);
|
|
178
|
+
}
|
|
179
|
+
if (this.stack) {
|
|
180
|
+
parts.push(`
|
|
181
|
+
Stack trace:`);
|
|
182
|
+
parts.push(this.stack);
|
|
183
|
+
}
|
|
184
|
+
if (this.cause) {
|
|
185
|
+
parts.push(`
|
|
186
|
+
Caused by: ${this.cause.name}: ${this.cause.message}`);
|
|
187
|
+
if (this.cause.stack) {
|
|
188
|
+
parts.push(this.cause.stack);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return parts.join("\n");
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
var bigintSafeJsonStringify = (value) => {
|
|
195
|
+
return JSON.stringify(value, (key, value2) => {
|
|
196
|
+
if (typeof value2 === "bigint") {
|
|
197
|
+
return `${value2}n`;
|
|
198
|
+
}
|
|
199
|
+
return value2;
|
|
200
|
+
});
|
|
201
|
+
};
|
|
202
|
+
var isCofheError = (error) => error instanceof CofheError;
|
|
203
|
+
|
|
44
204
|
// acps/sealing.ts
|
|
45
205
|
var KEY_HEX_LENGTH = 64;
|
|
46
206
|
var GenerateSealingKey = () => {
|
|
@@ -55,9 +215,25 @@ var unsealWithPrivateKey = (privateKey, parsedData) => {
|
|
|
55
215
|
const nonce = parsedData.nonce instanceof Uint8Array ? parsedData.nonce : new Uint8Array(parsedData.nonce);
|
|
56
216
|
const ephemPublicKey = parsedData.public_key instanceof Uint8Array ? parsedData.public_key : new Uint8Array(parsedData.public_key);
|
|
57
217
|
const dataToDecrypt = parsedData.data instanceof Uint8Array ? parsedData.data : new Uint8Array(parsedData.data);
|
|
58
|
-
|
|
218
|
+
let decryptedMessage;
|
|
219
|
+
let cause;
|
|
220
|
+
try {
|
|
221
|
+
decryptedMessage = nacl__default.default.box.open(dataToDecrypt, nonce, ephemPublicKey, fromHexString(privateKey));
|
|
222
|
+
} catch (e) {
|
|
223
|
+
decryptedMessage = null;
|
|
224
|
+
cause = e instanceof Error ? e : void 0;
|
|
225
|
+
}
|
|
59
226
|
if (!decryptedMessage) {
|
|
60
|
-
throw new
|
|
227
|
+
throw new CofheError({
|
|
228
|
+
code: "SEAL_OUTPUT_FAILED" /* SealOutputFailed */,
|
|
229
|
+
message: "Failed to unseal decrypt response",
|
|
230
|
+
cause,
|
|
231
|
+
context: {
|
|
232
|
+
dataLength: dataToDecrypt.length,
|
|
233
|
+
nonceLength: nonce.length,
|
|
234
|
+
publicKeyLength: ephemPublicKey.length
|
|
235
|
+
}
|
|
236
|
+
});
|
|
61
237
|
}
|
|
62
238
|
return toBigInt(decryptedMessage);
|
|
63
239
|
};
|
|
@@ -377,166 +553,6 @@ var TFHE_RS_ZK_MAX_BITS = 2048;
|
|
|
377
553
|
var TFHE_RS_SAFE_SERIALIZATION_SIZE_LIMIT = BigInt(1 << 30);
|
|
378
554
|
var TFHE_RS_KEY_VERSION = 2;
|
|
379
555
|
|
|
380
|
-
// core/error.ts
|
|
381
|
-
var CofheErrorCode = /* @__PURE__ */ ((CofheErrorCode2) => {
|
|
382
|
-
CofheErrorCode2["InternalError"] = "INTERNAL_ERROR";
|
|
383
|
-
CofheErrorCode2["UnknownEnvironment"] = "UNKNOWN_ENVIRONMENT";
|
|
384
|
-
CofheErrorCode2["InitTfheFailed"] = "INIT_TFHE_FAILED";
|
|
385
|
-
CofheErrorCode2["InitViemFailed"] = "INIT_VIEM_FAILED";
|
|
386
|
-
CofheErrorCode2["InitEthersFailed"] = "INIT_ETHERS_FAILED";
|
|
387
|
-
CofheErrorCode2["NotConnected"] = "NOT_CONNECTED";
|
|
388
|
-
CofheErrorCode2["MissingPublicClient"] = "MISSING_PUBLIC_CLIENT";
|
|
389
|
-
CofheErrorCode2["MissingWalletClient"] = "MISSING_WALLET_CLIENT";
|
|
390
|
-
CofheErrorCode2["MissingProviderParam"] = "MISSING_PROVIDER_PARAM";
|
|
391
|
-
CofheErrorCode2["EmptySecurityZonesParam"] = "EMPTY_SECURITY_ZONES_PARAM";
|
|
392
|
-
CofheErrorCode2["InvalidACPData"] = "INVALID_ACP_DATA";
|
|
393
|
-
CofheErrorCode2["InvalidACPDomain"] = "INVALID_ACP_DOMAIN";
|
|
394
|
-
CofheErrorCode2["ACPNotFound"] = "ACP_NOT_FOUND";
|
|
395
|
-
CofheErrorCode2["CannotRemoveLastACP"] = "CANNOT_REMOVE_LAST_ACP";
|
|
396
|
-
CofheErrorCode2["AccountUninitialized"] = "ACCOUNT_UNINITIALIZED";
|
|
397
|
-
CofheErrorCode2["ChainIdUninitialized"] = "CHAIN_ID_UNINITIALIZED";
|
|
398
|
-
CofheErrorCode2["ConsumingContractUninitialized"] = "CONSUMING_CONTRACT_UNINITIALIZED";
|
|
399
|
-
CofheErrorCode2["SealOutputFailed"] = "SEAL_OUTPUT_FAILED";
|
|
400
|
-
CofheErrorCode2["SealOutputReturnedNull"] = "SEAL_OUTPUT_RETURNED_NULL";
|
|
401
|
-
CofheErrorCode2["InvalidUtype"] = "INVALID_UTYPE";
|
|
402
|
-
CofheErrorCode2["DecryptFailed"] = "DECRYPT_FAILED";
|
|
403
|
-
CofheErrorCode2["DecryptReturnedNull"] = "DECRYPT_RETURNED_NULL";
|
|
404
|
-
CofheErrorCode2["ZkMocksInsertCtHashesFailed"] = "ZK_MOCKS_INSERT_CT_HASHES_FAILED";
|
|
405
|
-
CofheErrorCode2["ZkMocksCalcCtHashesFailed"] = "ZK_MOCKS_CALC_CT_HASHES_FAILED";
|
|
406
|
-
CofheErrorCode2["ZkMocksVerifySignFailed"] = "ZK_MOCKS_VERIFY_SIGN_FAILED";
|
|
407
|
-
CofheErrorCode2["ZkMocksCreateProofSignatureFailed"] = "ZK_MOCKS_CREATE_PROOF_SIGNATURE_FAILED";
|
|
408
|
-
CofheErrorCode2["ZkVerifyFailed"] = "ZK_VERIFY_FAILED";
|
|
409
|
-
CofheErrorCode2["ZkPackFailed"] = "ZK_PACK_FAILED";
|
|
410
|
-
CofheErrorCode2["ZkProveFailed"] = "ZK_PROVE_FAILED";
|
|
411
|
-
CofheErrorCode2["EncryptRemainingInItems"] = "ENCRYPT_REMAINING_IN_ITEMS";
|
|
412
|
-
CofheErrorCode2["ZkUninitialized"] = "ZK_UNINITIALIZED";
|
|
413
|
-
CofheErrorCode2["ZkVerifierUrlUninitialized"] = "ZK_VERIFIER_URL_UNINITIALIZED";
|
|
414
|
-
CofheErrorCode2["ThresholdNetworkUrlUninitialized"] = "THRESHOLD_NETWORK_URL_UNINITIALIZED";
|
|
415
|
-
CofheErrorCode2["MissingConfig"] = "MISSING_CONFIG";
|
|
416
|
-
CofheErrorCode2["UnsupportedChain"] = "UNSUPPORTED_CHAIN";
|
|
417
|
-
CofheErrorCode2["MissingZkBuilderAndCrsGenerator"] = "MISSING_ZK_BUILDER_AND_CRS_GENERATOR";
|
|
418
|
-
CofheErrorCode2["MissingTfhePublicKeyDeserializer"] = "MISSING_TFHE_PUBLIC_KEY_DESERIALIZER";
|
|
419
|
-
CofheErrorCode2["MissingCompactPkeCrsDeserializer"] = "MISSING_COMPACT_PKE_CRS_DESERIALIZER";
|
|
420
|
-
CofheErrorCode2["MissingFheKey"] = "MISSING_FHE_KEY";
|
|
421
|
-
CofheErrorCode2["MissingCrs"] = "MISSING_CRS";
|
|
422
|
-
CofheErrorCode2["FetchKeysFailed"] = "FETCH_KEYS_FAILED";
|
|
423
|
-
CofheErrorCode2["PublicWalletGetChainIdFailed"] = "PUBLIC_WALLET_GET_CHAIN_ID_FAILED";
|
|
424
|
-
CofheErrorCode2["PublicWalletGetAddressesFailed"] = "PUBLIC_WALLET_GET_ADDRESSES_FAILED";
|
|
425
|
-
CofheErrorCode2["RehydrateKeysStoreFailed"] = "REHYDRATE_KEYS_STORE_FAILED";
|
|
426
|
-
CofheErrorCode2["TaskManagerUnresolved"] = "TASK_MANAGER_UNRESOLVED";
|
|
427
|
-
CofheErrorCode2["BadRequest"] = "BAD_REQUEST";
|
|
428
|
-
CofheErrorCode2["UnknownChain"] = "UNKNOWN_CHAIN";
|
|
429
|
-
CofheErrorCode2["ACPMalformed"] = "ACP_MALFORMED";
|
|
430
|
-
CofheErrorCode2["ACPDenied"] = "ACP_DENIED";
|
|
431
|
-
CofheErrorCode2["ACPExpired"] = "ACP_EXPIRED";
|
|
432
|
-
CofheErrorCode2["ACPInvalid"] = "ACP_INVALID";
|
|
433
|
-
CofheErrorCode2["ACPRevoked"] = "ACP_REVOKED";
|
|
434
|
-
CofheErrorCode2["NotPubliclyAllowed"] = "NOT_PUBLICLY_ALLOWED";
|
|
435
|
-
CofheErrorCode2["CtNotFound"] = "CT_NOT_FOUND";
|
|
436
|
-
CofheErrorCode2["UnsupportedSecurityZone"] = "UNSUPPORTED_SECURITY_ZONE";
|
|
437
|
-
CofheErrorCode2["UnsupportedType"] = "UNSUPPORTED_TYPE";
|
|
438
|
-
CofheErrorCode2["SigningFailed"] = "SIGNING_FAILED";
|
|
439
|
-
CofheErrorCode2["CtSourceError"] = "CT_SOURCE_ERROR";
|
|
440
|
-
CofheErrorCode2["ACPVerifierError"] = "ACP_VERIFIER_ERROR";
|
|
441
|
-
CofheErrorCode2["CtSourceTimeout"] = "CT_SOURCE_TIMEOUT";
|
|
442
|
-
CofheErrorCode2["ACPVerifierTimeout"] = "ACP_VERIFIER_TIMEOUT";
|
|
443
|
-
CofheErrorCode2["ACPRequired"] = "ACP_REQUIRED";
|
|
444
|
-
CofheErrorCode2["SealFailed"] = "SEAL_FAILED";
|
|
445
|
-
return CofheErrorCode2;
|
|
446
|
-
})(CofheErrorCode || {});
|
|
447
|
-
var CofheError = class _CofheError extends Error {
|
|
448
|
-
code;
|
|
449
|
-
cause;
|
|
450
|
-
hint;
|
|
451
|
-
context;
|
|
452
|
-
apiErrorCode;
|
|
453
|
-
constructor({ code, message, cause, hint, context, apiErrorCode }) {
|
|
454
|
-
const fullMessage = cause ? `${message} | Caused by: ${cause.message}` : message;
|
|
455
|
-
super(fullMessage);
|
|
456
|
-
this.name = "CofheError";
|
|
457
|
-
this.code = code;
|
|
458
|
-
this.cause = cause;
|
|
459
|
-
this.hint = hint;
|
|
460
|
-
this.context = context;
|
|
461
|
-
this.apiErrorCode = apiErrorCode;
|
|
462
|
-
if (Error.captureStackTrace) {
|
|
463
|
-
Error.captureStackTrace(this, _CofheError);
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
/**
|
|
467
|
-
* Creates a CofheError from an unknown error
|
|
468
|
-
* If the error is a CofheError, it is returned unchanged, else a new CofheError is created
|
|
469
|
-
* If a wrapperError is provided, it is used to create the new CofheError, else a default is used
|
|
470
|
-
*/
|
|
471
|
-
static fromError(error, wrapperError) {
|
|
472
|
-
if (isCofheError(error))
|
|
473
|
-
return error;
|
|
474
|
-
const cause = error instanceof Error ? error : new Error(`${error}`);
|
|
475
|
-
return new _CofheError({
|
|
476
|
-
code: wrapperError?.code ?? "INTERNAL_ERROR" /* InternalError */,
|
|
477
|
-
message: wrapperError?.message ?? "An internal error occurred",
|
|
478
|
-
hint: wrapperError?.hint,
|
|
479
|
-
context: wrapperError?.context,
|
|
480
|
-
apiErrorCode: wrapperError?.apiErrorCode,
|
|
481
|
-
cause
|
|
482
|
-
});
|
|
483
|
-
}
|
|
484
|
-
/**
|
|
485
|
-
* Serializes the error to JSON string with proper handling of Error objects
|
|
486
|
-
*/
|
|
487
|
-
serialize() {
|
|
488
|
-
return bigintSafeJsonStringify({
|
|
489
|
-
name: this.name,
|
|
490
|
-
code: this.code,
|
|
491
|
-
message: this.message,
|
|
492
|
-
hint: this.hint,
|
|
493
|
-
context: this.context,
|
|
494
|
-
apiErrorCode: this.apiErrorCode,
|
|
495
|
-
cause: this.cause ? {
|
|
496
|
-
name: this.cause.name,
|
|
497
|
-
message: this.cause.message,
|
|
498
|
-
stack: this.cause.stack
|
|
499
|
-
} : void 0,
|
|
500
|
-
stack: this.stack
|
|
501
|
-
});
|
|
502
|
-
}
|
|
503
|
-
/**
|
|
504
|
-
* Returns a human-readable string representation of the error
|
|
505
|
-
*/
|
|
506
|
-
toString() {
|
|
507
|
-
const codeSuffix = this.apiErrorCode ? ` (api: ${this.apiErrorCode})` : "";
|
|
508
|
-
const parts = [`${this.name} [${this.code}]${codeSuffix}: ${this.message}`];
|
|
509
|
-
if (this.hint) {
|
|
510
|
-
parts.push(`Hint: ${this.hint}`);
|
|
511
|
-
}
|
|
512
|
-
if (this.context && Object.keys(this.context).length > 0) {
|
|
513
|
-
parts.push(`Context: ${bigintSafeJsonStringify(this.context)}`);
|
|
514
|
-
}
|
|
515
|
-
if (this.stack) {
|
|
516
|
-
parts.push(`
|
|
517
|
-
Stack trace:`);
|
|
518
|
-
parts.push(this.stack);
|
|
519
|
-
}
|
|
520
|
-
if (this.cause) {
|
|
521
|
-
parts.push(`
|
|
522
|
-
Caused by: ${this.cause.name}: ${this.cause.message}`);
|
|
523
|
-
if (this.cause.stack) {
|
|
524
|
-
parts.push(this.cause.stack);
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
return parts.join("\n");
|
|
528
|
-
}
|
|
529
|
-
};
|
|
530
|
-
var bigintSafeJsonStringify = (value) => {
|
|
531
|
-
return JSON.stringify(value, (key, value2) => {
|
|
532
|
-
if (typeof value2 === "bigint") {
|
|
533
|
-
return `${value2}n`;
|
|
534
|
-
}
|
|
535
|
-
return value2;
|
|
536
|
-
});
|
|
537
|
-
};
|
|
538
|
-
var isCofheError = (error) => error instanceof CofheError;
|
|
539
|
-
|
|
540
556
|
// core/taskManager.ts
|
|
541
557
|
var ADDRESS_BOOK_ABI = viem.parseAbi([
|
|
542
558
|
"function getTm(uint256 id) view returns (address)",
|
|
@@ -844,15 +860,22 @@ var getAclServedAddresses = async (publicClient, chainId) => {
|
|
|
844
860
|
} catch {
|
|
845
861
|
return {};
|
|
846
862
|
}
|
|
863
|
+
let transient = false;
|
|
864
|
+
const readServedAddress = (functionName) => publicClient.readContract({ address: aclAddress, abi: ACL_SERVED_ADDRESSES_ABI, functionName }).catch((err) => {
|
|
865
|
+
if (revertErrorName(err, ACL_SERVED_ADDRESSES_ABI) === void 0)
|
|
866
|
+
transient = true;
|
|
867
|
+
return void 0;
|
|
868
|
+
});
|
|
847
869
|
const [defaultRevoker, shareRegistry] = await Promise.all([
|
|
848
|
-
|
|
849
|
-
|
|
870
|
+
readServedAddress("defaultRevokerContract"),
|
|
871
|
+
readServedAddress("shareRegistry")
|
|
850
872
|
]);
|
|
851
873
|
const resolved = {
|
|
852
874
|
defaultRevoker: defaultRevoker != null && defaultRevoker !== viem.zeroAddress ? defaultRevoker : void 0,
|
|
853
875
|
shareRegistry: shareRegistry != null && shareRegistry !== viem.zeroAddress ? shareRegistry : void 0
|
|
854
876
|
};
|
|
855
|
-
|
|
877
|
+
if (!transient)
|
|
878
|
+
aclServedAddressesCache.set(chainId, resolved);
|
|
856
879
|
return resolved;
|
|
857
880
|
};
|
|
858
881
|
|
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 { A as AnyExternalHash, i as CofheClientACPs, C as CofheInputConfig, h as CofheInternalConfig, K as DecryptEndpoint, a4 as DecryptForTxBuilder, a5 as DecryptForTxResult, a3 as DecryptForViewBuilder, J as DecryptPollCallbackContext, G as DecryptPollCallbackFunction, a1 as EncryptInputsBuilder, a2 as EncryptInputsBuilderUnset, M as EncryptSetStateFn, W as EncryptStep, N as EncryptStepCallbackContext, S 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, R as FheAllUTypes, Z as FheKeyDeserializer, r as FheTypeValue, Q as FheUintUTypes, H as HashPlusProofResult, I as IStorage, $ as KeysStorage, a0 as KeysStore, L as LiteralToPrimitive, P as Primitive, T as TfheInitializer, O as TfheThreadsSetting, U as UnsealedItem, a6 as ZkBuilderAndCrsGenerator, a7 as ZkProveWorkerFunction, a8 as ZkProveWorkerRequest, a9 as ZkProveWorkerResponse, f as assertNoRenamedConfigKeys, e as createCofheConfigBase, _ as createKeysStore, Y as fetchKeys, g as getCofheConfigItem, V as isEncryptableItem, X as isLastEncryptionStep, aa as zkProveWithWorker } from './clientTypes-
|
|
1
|
+
import { a as CofheConfig, c as CofheClientParams, b as CofheClient, d as CofheClientConnectionState, F as FheTypes } from './clientTypes-IO6b5Um8.cjs';
|
|
2
|
+
export { A as AnyExternalHash, i as CofheClientACPs, C as CofheInputConfig, h as CofheInternalConfig, K as DecryptEndpoint, a4 as DecryptForTxBuilder, a5 as DecryptForTxResult, a3 as DecryptForViewBuilder, J as DecryptPollCallbackContext, G as DecryptPollCallbackFunction, a1 as EncryptInputsBuilder, a2 as EncryptInputsBuilderUnset, M as EncryptSetStateFn, W as EncryptStep, N as EncryptStepCallbackContext, S 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, R as FheAllUTypes, Z as FheKeyDeserializer, r as FheTypeValue, Q as FheUintUTypes, H as HashPlusProofResult, I as IStorage, $ as KeysStorage, a0 as KeysStore, L as LiteralToPrimitive, P as Primitive, T as TfheInitializer, O as TfheThreadsSetting, U as UnsealedItem, a6 as ZkBuilderAndCrsGenerator, a7 as ZkProveWorkerFunction, a8 as ZkProveWorkerRequest, a9 as ZkProveWorkerResponse, f as assertNoRenamedConfigKeys, e as createCofheConfigBase, _ as createKeysStore, Y as fetchKeys, g as getCofheConfigItem, V as isEncryptableItem, X as isLastEncryptionStep, aa as zkProveWithWorker } from './clientTypes-IO6b5Um8.cjs';
|
|
3
3
|
import { PublicClient, Address, Hex } from 'viem';
|
|
4
4
|
import './types-C07FK-cL.cjs';
|
|
5
5
|
import 'zod';
|
|
6
|
-
import './onchain-utils-
|
|
6
|
+
import './onchain-utils-CgOslubH.cjs';
|
|
7
7
|
import 'zustand/vanilla';
|
|
8
8
|
|
|
9
9
|
declare const InitialConnectStore: CofheClientConnectionState;
|
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 { A as AnyExternalHash, i as CofheClientACPs, C as CofheInputConfig, h as CofheInternalConfig, K as DecryptEndpoint, a4 as DecryptForTxBuilder, a5 as DecryptForTxResult, a3 as DecryptForViewBuilder, J as DecryptPollCallbackContext, G as DecryptPollCallbackFunction, a1 as EncryptInputsBuilder, a2 as EncryptInputsBuilderUnset, M as EncryptSetStateFn, W as EncryptStep, N as EncryptStepCallbackContext, S 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, R as FheAllUTypes, Z as FheKeyDeserializer, r as FheTypeValue, Q as FheUintUTypes, H as HashPlusProofResult, I as IStorage, $ as KeysStorage, a0 as KeysStore, L as LiteralToPrimitive, P as Primitive, T as TfheInitializer, O as TfheThreadsSetting, U as UnsealedItem, a6 as ZkBuilderAndCrsGenerator, a7 as ZkProveWorkerFunction, a8 as ZkProveWorkerRequest, a9 as ZkProveWorkerResponse, f as assertNoRenamedConfigKeys, e as createCofheConfigBase, _ as createKeysStore, Y as fetchKeys, g as getCofheConfigItem, V as isEncryptableItem, X as isLastEncryptionStep, aa as zkProveWithWorker } from './clientTypes-
|
|
1
|
+
import { a as CofheConfig, c as CofheClientParams, b as CofheClient, d as CofheClientConnectionState, F as FheTypes } from './clientTypes-b1pOxOUE.js';
|
|
2
|
+
export { A as AnyExternalHash, i as CofheClientACPs, C as CofheInputConfig, h as CofheInternalConfig, K as DecryptEndpoint, a4 as DecryptForTxBuilder, a5 as DecryptForTxResult, a3 as DecryptForViewBuilder, J as DecryptPollCallbackContext, G as DecryptPollCallbackFunction, a1 as EncryptInputsBuilder, a2 as EncryptInputsBuilderUnset, M as EncryptSetStateFn, W as EncryptStep, N as EncryptStepCallbackContext, S 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, R as FheAllUTypes, Z as FheKeyDeserializer, r as FheTypeValue, Q as FheUintUTypes, H as HashPlusProofResult, I as IStorage, $ as KeysStorage, a0 as KeysStore, L as LiteralToPrimitive, P as Primitive, T as TfheInitializer, O as TfheThreadsSetting, U as UnsealedItem, a6 as ZkBuilderAndCrsGenerator, a7 as ZkProveWorkerFunction, a8 as ZkProveWorkerRequest, a9 as ZkProveWorkerResponse, f as assertNoRenamedConfigKeys, e as createCofheConfigBase, _ as createKeysStore, Y as fetchKeys, g as getCofheConfigItem, V as isEncryptableItem, X as isLastEncryptionStep, aa as zkProveWithWorker } from './clientTypes-b1pOxOUE.js';
|
|
3
3
|
import { PublicClient, Address, Hex } from 'viem';
|
|
4
4
|
import './types-C07FK-cL.js';
|
|
5
5
|
import 'zod';
|
|
6
|
-
import './onchain-utils-
|
|
6
|
+
import './onchain-utils-CgOslubH.js';
|
|
7
7
|
import 'zustand/vanilla';
|
|
8
8
|
|
|
9
9
|
declare const InitialConnectStore: CofheClientConnectionState;
|
package/dist/core.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { InitialConnectStore as CONNECT_STORE_DEFAULTS, DecryptForTxBuilder, DecryptForViewBuilder, EncryptInputsBuilder, assertNoRenamedConfigKeys, cofheFetch, createCofheClientBase, createCofheConfigBase, createKeysStore, fetchKeys, getCofheConfigItem, getCofheDebugInterceptors, setCofheDebugInterceptors, verifyDecryptResult, zkProveWithWorker } from './chunk-
|
|
1
|
+
export { InitialConnectStore as CONNECT_STORE_DEFAULTS, DecryptForTxBuilder, DecryptForViewBuilder, EncryptInputsBuilder, assertNoRenamedConfigKeys, cofheFetch, createCofheClientBase, createCofheConfigBase, createKeysStore, fetchKeys, getCofheConfigItem, getCofheDebugInterceptors, setCofheDebugInterceptors, verifyDecryptResult, zkProveWithWorker } from './chunk-O2ITEUEU.js';
|
|
2
2
|
import './chunk-UKQAJK4N.js';
|
|
3
|
-
export { getTaskManagerAddress } from './chunk-
|
|
4
|
-
export { EncryptStep, Encryptable, FheAllUTypes, FheTypes, FheUintUTypes, fheTypeToString, isEncryptableItem, isLastEncryptionStep } from './chunk-
|
|
5
|
-
export { COFHE_ADDRESS_BOOK_ADDRESS, CofheError, CofheErrorCode, MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY, MOCKS_TASK_MANAGER_ADDRESS, MOCKS_THRESHOLD_NETWORK_ADDRESS, MOCKS_ZK_VERIFIER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY, TASK_MANAGER_ID, TFHE_RS_SAFE_SERIALIZATION_SIZE_LIMIT, TFHE_RS_ZK_MAX_BITS, isCofheError } from './chunk-
|
|
3
|
+
export { getTaskManagerAddress } from './chunk-3L2IVPMI.js';
|
|
4
|
+
export { EncryptStep, Encryptable, FheAllUTypes, FheTypes, FheUintUTypes, fheTypeToString, isEncryptableItem, isLastEncryptionStep } from './chunk-WJGTPW7K.js';
|
|
5
|
+
export { COFHE_ADDRESS_BOOK_ADDRESS, CofheError, CofheErrorCode, MOCKS_DECRYPT_RESULT_SIGNER_PRIVATE_KEY, MOCKS_TASK_MANAGER_ADDRESS, MOCKS_THRESHOLD_NETWORK_ADDRESS, MOCKS_ZK_VERIFIER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_ADDRESS, MOCKS_ZK_VERIFIER_SIGNER_PRIVATE_KEY, TASK_MANAGER_ID, TFHE_RS_SAFE_SERIALIZATION_SIZE_LIMIT, TFHE_RS_ZK_MAX_BITS, isCofheError } from './chunk-J23FYAI2.js';
|