@cofhe/sdk 1.0.0-alpha.0 → 1.1.0-alpha.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/core/acps.ts +64 -23
- package/core/client.ts +32 -1
- package/core/clientTypes.ts +22 -1
- package/core/test/acpsPrepare.test.ts +77 -0
- package/dist/acps.cjs +122 -99
- package/dist/acps.d.cts +4 -358
- package/dist/acps.d.ts +4 -358
- package/dist/acps.js +2 -2
- package/dist/{chunk-OL3DZN7A.js → chunk-2EO4JSR7.js} +65 -23
- package/dist/{chunk-BQWHPIYU.js → chunk-3L2IVPMI.js} +29 -6
- package/dist/{chunk-6ZW76ZKB.js → chunk-WJGTPW7K.js} +1 -1
- package/dist/{clientTypes-CcU5WvdV.d.ts → clientTypes-CnslFzxB.d.ts} +38 -2
- package/dist/{clientTypes-C0A9ji5O.d.cts → clientTypes-RXwLVWou.d.cts} +38 -2
- package/dist/core.cjs +250 -185
- package/dist/core.d.cts +3 -3
- package/dist/core.d.ts +3 -3
- package/dist/core.js +4 -4
- package/dist/node.cjs +184 -119
- 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.ts → onchain-utils-Ns56cBm0.d.cts} +359 -5
- package/dist/{onchain-utils-D9Z33IP7.d.cts → onchain-utils-Ns56cBm0.d.ts} +359 -5
- package/dist/web.cjs +184 -119
- 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 +1 -1
- package/dist/{chunk-XQ32JG3T.js → chunk-J23FYAI2.js} +13 -13
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { WalletClient, PublicClient, Hex } from 'viem';
|
|
1
|
+
import { WalletClient, PublicClient, Hex, ContractFunctionParameters } 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,
|
|
4
|
+
import { A as ACP, k as EIP712Domain, C as CreateSelfACPOptions, $ as SelfACP, g as CreateSharingACPOptions, a0 as SharingACP, I as ImportSharedACPOptions, a1 as RecipientACP, a5 as ACPHashFields, f as SerializedACP, t as ACP_REVOKER_ABI, a4 as ACPAccessStatus, S as ShareLabel, v as ACP_SHARE_REGISTRY_ABI, j as IncomingShare, p as AclServedAddresses, L as LabelledShare, Q as ShareLabelVerifyMode, R as ShareLabelCheck, l as ACPUtils } from './onchain-utils-Ns56cBm0.js';
|
|
5
5
|
import { StoreApi } from 'zustand/vanilla';
|
|
6
6
|
|
|
7
7
|
type TfheInitializer = () => Promise<boolean>;
|
|
@@ -1031,6 +1031,21 @@ type ImportSharedOptions = ImportActivationOptions & {
|
|
|
1031
1031
|
*/
|
|
1032
1032
|
name?: string;
|
|
1033
1033
|
};
|
|
1034
|
+
/**
|
|
1035
|
+
* Revoke a single acp on-chain via its revoker contract.
|
|
1036
|
+
* Only the acp's issuer can revoke it (enforced by the revoker: revocations
|
|
1037
|
+
* are keyed by msg.sender). The acp stays in local storage — on-chain
|
|
1038
|
+
* validation will reject it from the next block onwards.
|
|
1039
|
+
*
|
|
1040
|
+
* @returns the revocation transaction hash
|
|
1041
|
+
*/
|
|
1042
|
+
/**
|
|
1043
|
+
* A registry or revoker write built but not sent: what a simulation or `writeContract` takes,
|
|
1044
|
+
* minus the sender. For a caller that sends through its own path (simulate first, record the
|
|
1045
|
+
* transaction) instead of the plain `writeContract` the senders below do.
|
|
1046
|
+
*/
|
|
1047
|
+
type ShareRegistryWrite<functionName extends 'share' | 'removeShare'> = ContractFunctionParameters<typeof ACP_SHARE_REGISTRY_ABI, 'nonpayable', functionName>;
|
|
1048
|
+
type RevokerWrite = ContractFunctionParameters<typeof ACP_REVOKER_ABI, 'nonpayable', 'revokeSingle'>;
|
|
1034
1049
|
/**
|
|
1035
1050
|
* What `shareOnChain` posts with a share: the labels of its handles (one per handle, in order;
|
|
1036
1051
|
* encoded with `encodeShareMetadata`), or an already encoded metadata blob. Written once, with the
|
|
@@ -1191,6 +1206,7 @@ declare const acps: {
|
|
|
1191
1206
|
selectActiveACP: (chainId: number, account: string, hash: string) => void;
|
|
1192
1207
|
removeActiveACP: (chainId: number, account: string) => Promise<void>;
|
|
1193
1208
|
revokeACP: (acp: ACP, walletClient: WalletClient) => Promise<Hex>;
|
|
1209
|
+
prepareRevokeACP: (acp: ACP) => RevokerWrite;
|
|
1194
1210
|
revokeAllACPs: (walletClient: WalletClient, publicClient: PublicClient, revokerContract?: Hex) => Promise<Hex>;
|
|
1195
1211
|
isACPRevoked: (acp: ACP, publicClient: PublicClient) => Promise<boolean>;
|
|
1196
1212
|
checkAccess: (acp: ACP, publicClient: PublicClient, handle?: bigint | Hex) => Promise<ACPAccessStatus>;
|
|
@@ -1198,12 +1214,17 @@ declare const acps: {
|
|
|
1198
1214
|
txHash: Hex;
|
|
1199
1215
|
shareId: Hex;
|
|
1200
1216
|
}>;
|
|
1217
|
+
prepareShareOnChain: (acp: ACP, registry: Hex, options?: ShareOnChainOptions) => {
|
|
1218
|
+
write: ShareRegistryWrite<"share">;
|
|
1219
|
+
shareId: Hex;
|
|
1220
|
+
};
|
|
1201
1221
|
getIncomingShares: (publicClient: PublicClient, registry: Hex, recipient: Hex, { appKey }?: {
|
|
1202
1222
|
appKey?: Hex;
|
|
1203
1223
|
}) => Promise<IncomingShare[]>;
|
|
1204
1224
|
getShareFromChain: (publicClient: PublicClient, registry: Hex, shareId: Hex) => Promise<IncomingShare | null>;
|
|
1205
1225
|
importFromChain: (share: IncomingShare, publicClient: PublicClient, walletClient: WalletClient, importOptions?: ImportSharedOptions) => Promise<RecipientACP>;
|
|
1206
1226
|
removeShareOnChain: (shareId: Hex, walletClient: WalletClient, registry: Hex) => Promise<Hex>;
|
|
1227
|
+
prepareRemoveShare: (shareId: Hex, registry: Hex) => ShareRegistryWrite<"removeShare">;
|
|
1207
1228
|
computeShareId: (acp: ACP) => Hex;
|
|
1208
1229
|
applyACPDefaultsFromChain: <T extends {
|
|
1209
1230
|
revokerData?: number;
|
|
@@ -1286,6 +1307,11 @@ type CofheClientACPs = {
|
|
|
1286
1307
|
removeACP: (hash: string, chainId?: number, account?: string) => void;
|
|
1287
1308
|
removeActiveACP: (chainId?: number, account?: string) => void;
|
|
1288
1309
|
revokeACP: (acp: ACP) => Promise<`0x${string}`>;
|
|
1310
|
+
/**
|
|
1311
|
+
* The revoker write `revokeACP` sends, built but not sent — for an app that sends through its own
|
|
1312
|
+
* path (a simulation first, a transaction store). Issuer only; throws for an acp without a revoker.
|
|
1313
|
+
*/
|
|
1314
|
+
prepareRevokeACP: (acp: ACP) => RevokerWrite;
|
|
1289
1315
|
revokeAllACPs: (revokerContract?: `0x${string}`) => Promise<`0x${string}`>;
|
|
1290
1316
|
isACPRevoked: (acp: ACP) => Promise<boolean>;
|
|
1291
1317
|
/**
|
|
@@ -1303,6 +1329,16 @@ type CofheClientACPs = {
|
|
|
1303
1329
|
txHash: `0x${string}`;
|
|
1304
1330
|
shareId: `0x${string}`;
|
|
1305
1331
|
}>;
|
|
1332
|
+
/**
|
|
1333
|
+
* The registry write `shareOnChain` sends and the share id it gets, built but not sent — for an
|
|
1334
|
+
* app that sends through its own path (a simulation first, a transaction store). Issuer only.
|
|
1335
|
+
*/
|
|
1336
|
+
prepareShareOnChain: (acp: ACP, options?: ShareOnChainOptions) => Promise<{
|
|
1337
|
+
write: ShareRegistryWrite<'share'>;
|
|
1338
|
+
shareId: `0x${string}`;
|
|
1339
|
+
}>;
|
|
1340
|
+
/** The registry write `dismissShare` / `cancelShare` sends, built but not sent. */
|
|
1341
|
+
prepareRemoveShare: (shareId: `0x${string}`) => Promise<ShareRegistryWrite<'removeShare'>>;
|
|
1306
1342
|
/** Importable shares addressed to the connected account (unexpired, not revoked), with their metadata. */
|
|
1307
1343
|
getIncomingShares: () => Promise<IncomingShare[]>;
|
|
1308
1344
|
/** One share by id, as posted; null when unknown or removed. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { WalletClient, PublicClient, Hex } from 'viem';
|
|
1
|
+
import { WalletClient, PublicClient, Hex, ContractFunctionParameters } from 'viem';
|
|
2
2
|
import { C as CofheChain } from './types-C07FK-cL.cjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import { A as ACP, k as EIP712Domain, C as CreateSelfACPOptions,
|
|
4
|
+
import { A as ACP, k as EIP712Domain, C as CreateSelfACPOptions, $ as SelfACP, g as CreateSharingACPOptions, a0 as SharingACP, I as ImportSharedACPOptions, a1 as RecipientACP, a5 as ACPHashFields, f as SerializedACP, t as ACP_REVOKER_ABI, a4 as ACPAccessStatus, S as ShareLabel, v as ACP_SHARE_REGISTRY_ABI, j as IncomingShare, p as AclServedAddresses, L as LabelledShare, Q as ShareLabelVerifyMode, R as ShareLabelCheck, l as ACPUtils } from './onchain-utils-Ns56cBm0.cjs';
|
|
5
5
|
import { StoreApi } from 'zustand/vanilla';
|
|
6
6
|
|
|
7
7
|
type TfheInitializer = () => Promise<boolean>;
|
|
@@ -1031,6 +1031,21 @@ type ImportSharedOptions = ImportActivationOptions & {
|
|
|
1031
1031
|
*/
|
|
1032
1032
|
name?: string;
|
|
1033
1033
|
};
|
|
1034
|
+
/**
|
|
1035
|
+
* Revoke a single acp on-chain via its revoker contract.
|
|
1036
|
+
* Only the acp's issuer can revoke it (enforced by the revoker: revocations
|
|
1037
|
+
* are keyed by msg.sender). The acp stays in local storage — on-chain
|
|
1038
|
+
* validation will reject it from the next block onwards.
|
|
1039
|
+
*
|
|
1040
|
+
* @returns the revocation transaction hash
|
|
1041
|
+
*/
|
|
1042
|
+
/**
|
|
1043
|
+
* A registry or revoker write built but not sent: what a simulation or `writeContract` takes,
|
|
1044
|
+
* minus the sender. For a caller that sends through its own path (simulate first, record the
|
|
1045
|
+
* transaction) instead of the plain `writeContract` the senders below do.
|
|
1046
|
+
*/
|
|
1047
|
+
type ShareRegistryWrite<functionName extends 'share' | 'removeShare'> = ContractFunctionParameters<typeof ACP_SHARE_REGISTRY_ABI, 'nonpayable', functionName>;
|
|
1048
|
+
type RevokerWrite = ContractFunctionParameters<typeof ACP_REVOKER_ABI, 'nonpayable', 'revokeSingle'>;
|
|
1034
1049
|
/**
|
|
1035
1050
|
* What `shareOnChain` posts with a share: the labels of its handles (one per handle, in order;
|
|
1036
1051
|
* encoded with `encodeShareMetadata`), or an already encoded metadata blob. Written once, with the
|
|
@@ -1191,6 +1206,7 @@ declare const acps: {
|
|
|
1191
1206
|
selectActiveACP: (chainId: number, account: string, hash: string) => void;
|
|
1192
1207
|
removeActiveACP: (chainId: number, account: string) => Promise<void>;
|
|
1193
1208
|
revokeACP: (acp: ACP, walletClient: WalletClient) => Promise<Hex>;
|
|
1209
|
+
prepareRevokeACP: (acp: ACP) => RevokerWrite;
|
|
1194
1210
|
revokeAllACPs: (walletClient: WalletClient, publicClient: PublicClient, revokerContract?: Hex) => Promise<Hex>;
|
|
1195
1211
|
isACPRevoked: (acp: ACP, publicClient: PublicClient) => Promise<boolean>;
|
|
1196
1212
|
checkAccess: (acp: ACP, publicClient: PublicClient, handle?: bigint | Hex) => Promise<ACPAccessStatus>;
|
|
@@ -1198,12 +1214,17 @@ declare const acps: {
|
|
|
1198
1214
|
txHash: Hex;
|
|
1199
1215
|
shareId: Hex;
|
|
1200
1216
|
}>;
|
|
1217
|
+
prepareShareOnChain: (acp: ACP, registry: Hex, options?: ShareOnChainOptions) => {
|
|
1218
|
+
write: ShareRegistryWrite<"share">;
|
|
1219
|
+
shareId: Hex;
|
|
1220
|
+
};
|
|
1201
1221
|
getIncomingShares: (publicClient: PublicClient, registry: Hex, recipient: Hex, { appKey }?: {
|
|
1202
1222
|
appKey?: Hex;
|
|
1203
1223
|
}) => Promise<IncomingShare[]>;
|
|
1204
1224
|
getShareFromChain: (publicClient: PublicClient, registry: Hex, shareId: Hex) => Promise<IncomingShare | null>;
|
|
1205
1225
|
importFromChain: (share: IncomingShare, publicClient: PublicClient, walletClient: WalletClient, importOptions?: ImportSharedOptions) => Promise<RecipientACP>;
|
|
1206
1226
|
removeShareOnChain: (shareId: Hex, walletClient: WalletClient, registry: Hex) => Promise<Hex>;
|
|
1227
|
+
prepareRemoveShare: (shareId: Hex, registry: Hex) => ShareRegistryWrite<"removeShare">;
|
|
1207
1228
|
computeShareId: (acp: ACP) => Hex;
|
|
1208
1229
|
applyACPDefaultsFromChain: <T extends {
|
|
1209
1230
|
revokerData?: number;
|
|
@@ -1286,6 +1307,11 @@ type CofheClientACPs = {
|
|
|
1286
1307
|
removeACP: (hash: string, chainId?: number, account?: string) => void;
|
|
1287
1308
|
removeActiveACP: (chainId?: number, account?: string) => void;
|
|
1288
1309
|
revokeACP: (acp: ACP) => Promise<`0x${string}`>;
|
|
1310
|
+
/**
|
|
1311
|
+
* The revoker write `revokeACP` sends, built but not sent — for an app that sends through its own
|
|
1312
|
+
* path (a simulation first, a transaction store). Issuer only; throws for an acp without a revoker.
|
|
1313
|
+
*/
|
|
1314
|
+
prepareRevokeACP: (acp: ACP) => RevokerWrite;
|
|
1289
1315
|
revokeAllACPs: (revokerContract?: `0x${string}`) => Promise<`0x${string}`>;
|
|
1290
1316
|
isACPRevoked: (acp: ACP) => Promise<boolean>;
|
|
1291
1317
|
/**
|
|
@@ -1303,6 +1329,16 @@ type CofheClientACPs = {
|
|
|
1303
1329
|
txHash: `0x${string}`;
|
|
1304
1330
|
shareId: `0x${string}`;
|
|
1305
1331
|
}>;
|
|
1332
|
+
/**
|
|
1333
|
+
* The registry write `shareOnChain` sends and the share id it gets, built but not sent — for an
|
|
1334
|
+
* app that sends through its own path (a simulation first, a transaction store). Issuer only.
|
|
1335
|
+
*/
|
|
1336
|
+
prepareShareOnChain: (acp: ACP, options?: ShareOnChainOptions) => Promise<{
|
|
1337
|
+
write: ShareRegistryWrite<'share'>;
|
|
1338
|
+
shareId: `0x${string}`;
|
|
1339
|
+
}>;
|
|
1340
|
+
/** The registry write `dismissShare` / `cancelShare` sends, built but not sent. */
|
|
1341
|
+
prepareRemoveShare: (shareId: `0x${string}`) => Promise<ShareRegistryWrite<'removeShare'>>;
|
|
1306
1342
|
/** Importable shares addressed to the connected account (unexpired, not revoked), with their metadata. */
|
|
1307
1343
|
getIncomingShares: () => Promise<IncomingShare[]>;
|
|
1308
1344
|
/** One share by id, as posted; null when unknown or removed. */
|