@cofhe/sdk 0.2.0 → 0.3.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 +36 -0
- package/chains/defineChain.ts +2 -2
- package/chains/types.ts +3 -3
- package/core/baseBuilder.ts +18 -18
- package/core/client.test.ts +155 -41
- package/core/client.ts +72 -32
- package/core/clientTypes.ts +28 -18
- package/core/config.test.ts +40 -33
- package/core/config.ts +56 -51
- package/core/consts.ts +22 -0
- package/core/decrypt/{MockQueryDecrypterAbi.ts → MockThresholdNetworkAbi.ts} +71 -21
- package/core/decrypt/cofheMocksDecryptForTx.ts +142 -0
- package/core/decrypt/{cofheMocksSealOutput.ts → cofheMocksDecryptForView.ts} +12 -14
- package/core/decrypt/decryptForTxBuilder.ts +340 -0
- package/core/decrypt/{decryptHandleBuilder.ts → decryptForViewBuilder.ts} +75 -42
- package/core/decrypt/tnDecrypt.ts +232 -0
- package/core/decrypt/tnSealOutputV1.ts +5 -5
- package/core/decrypt/tnSealOutputV2.ts +27 -27
- package/core/encrypt/cofheMocksZkVerifySign.ts +19 -26
- package/core/encrypt/encryptInputsBuilder.test.ts +57 -61
- package/core/encrypt/encryptInputsBuilder.ts +65 -42
- package/core/encrypt/zkPackProveVerify.ts +11 -11
- package/core/error.ts +18 -18
- package/core/fetchKeys.test.ts +3 -3
- package/core/fetchKeys.ts +3 -3
- package/core/index.ts +22 -11
- package/core/permits.test.ts +5 -6
- package/core/permits.ts +5 -4
- package/core/utils.ts +10 -10
- package/dist/chains.cjs +4 -7
- package/dist/chains.d.cts +12 -12
- package/dist/chains.d.ts +12 -12
- package/dist/chains.js +1 -1
- package/dist/{chunk-WGCRJCBR.js → chunk-2TPSCOW3.js} +820 -224
- package/dist/{chunk-UGBVZNRT.js → chunk-NWDKXBIP.js} +309 -189
- package/dist/{chunk-WEAZ25JO.js → chunk-TBLR7NNE.js} +4 -7
- package/dist/{clientTypes-5_1nwtUe.d.cts → clientTypes-6aTZPQ_4.d.ts} +233 -173
- package/dist/{clientTypes-Es7fyi65.d.ts → clientTypes-Bhq7pCSA.d.cts} +233 -173
- package/dist/core.cjs +1138 -418
- package/dist/core.d.cts +37 -24
- package/dist/core.d.ts +37 -24
- package/dist/core.js +3 -3
- package/dist/node.cjs +1082 -370
- package/dist/node.d.cts +12 -12
- package/dist/node.d.ts +12 -12
- package/dist/node.js +8 -8
- package/dist/{permit-fUSe6KKq.d.cts → permit-MZ502UBl.d.cts} +30 -33
- package/dist/{permit-fUSe6KKq.d.ts → permit-MZ502UBl.d.ts} +30 -33
- package/dist/permits.cjs +305 -187
- package/dist/permits.d.cts +111 -812
- package/dist/permits.d.ts +111 -812
- package/dist/permits.js +1 -1
- package/dist/types-YiAC4gig.d.cts +33 -0
- package/dist/types-YiAC4gig.d.ts +33 -0
- package/dist/web.cjs +1085 -373
- package/dist/web.d.cts +13 -13
- package/dist/web.d.ts +13 -13
- package/dist/web.js +10 -10
- package/node/client.test.ts +34 -34
- package/node/config.test.ts +11 -11
- package/node/encryptInputs.test.ts +29 -29
- package/node/index.ts +15 -15
- package/package.json +3 -3
- package/permits/localstorage.test.ts +9 -13
- package/permits/onchain-utils.ts +221 -0
- package/permits/permit.test.ts +51 -5
- package/permits/permit.ts +28 -74
- package/permits/store.test.ts +10 -50
- package/permits/store.ts +4 -14
- package/permits/test-utils.ts +10 -2
- package/permits/types.ts +22 -9
- package/permits/utils.ts +0 -4
- package/permits/validation.test.ts +29 -32
- package/permits/validation.ts +112 -194
- package/web/client.web.test.ts +34 -34
- package/web/config.web.test.ts +11 -11
- package/web/encryptInputs.web.test.ts +29 -29
- package/web/index.ts +19 -19
- package/web/worker.builder.web.test.ts +28 -28
- package/web/worker.config.web.test.ts +47 -47
- package/web/worker.output.web.test.ts +10 -10
- package/dist/types-KImPrEIe.d.cts +0 -48
- package/dist/types-KImPrEIe.d.ts +0 -48
package/dist/node.d.cts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as CofheInputConfig, a as CofheConfig, b as CofheClient } from './clientTypes-Bhq7pCSA.cjs';
|
|
2
2
|
import 'viem';
|
|
3
|
-
import './types-
|
|
3
|
+
import './types-YiAC4gig.cjs';
|
|
4
4
|
import 'zod';
|
|
5
|
-
import './permit-
|
|
5
|
+
import './permit-MZ502UBl.cjs';
|
|
6
6
|
import 'zustand/vanilla';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Creates a CoFHE
|
|
10
|
-
* @param config - The CoFHE
|
|
11
|
-
* @returns The CoFHE
|
|
9
|
+
* Creates a CoFHE configuration for Node.js with filesystem storage as default
|
|
10
|
+
* @param config - The CoFHE input configuration (fheKeyStorage will default to filesystem if not provided)
|
|
11
|
+
* @returns The CoFHE configuration with Node.js defaults applied
|
|
12
12
|
*/
|
|
13
|
-
declare function
|
|
13
|
+
declare function createCofheConfig(config: CofheInputConfig): CofheConfig;
|
|
14
14
|
/**
|
|
15
|
-
* Creates a CoFHE
|
|
15
|
+
* Creates a CoFHE client instance for Node.js with node-tfhe automatically configured
|
|
16
16
|
* TFHE will be initialized automatically on first encryption - no manual setup required
|
|
17
|
-
* @param config - The CoFHE
|
|
18
|
-
* @returns The CoFHE
|
|
17
|
+
* @param config - The CoFHE configuration (use createCofheConfig to create with Node.js defaults)
|
|
18
|
+
* @returns The CoFHE client instance
|
|
19
19
|
*/
|
|
20
|
-
declare function
|
|
20
|
+
declare function createCofheClient(config: CofheConfig): CofheClient;
|
|
21
21
|
|
|
22
|
-
export {
|
|
22
|
+
export { createCofheClient, createCofheConfig };
|
package/dist/node.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as CofheInputConfig, a as CofheConfig, b as CofheClient } from './clientTypes-6aTZPQ_4.js';
|
|
2
2
|
import 'viem';
|
|
3
|
-
import './types-
|
|
3
|
+
import './types-YiAC4gig.js';
|
|
4
4
|
import 'zod';
|
|
5
|
-
import './permit-
|
|
5
|
+
import './permit-MZ502UBl.js';
|
|
6
6
|
import 'zustand/vanilla';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Creates a CoFHE
|
|
10
|
-
* @param config - The CoFHE
|
|
11
|
-
* @returns The CoFHE
|
|
9
|
+
* Creates a CoFHE configuration for Node.js with filesystem storage as default
|
|
10
|
+
* @param config - The CoFHE input configuration (fheKeyStorage will default to filesystem if not provided)
|
|
11
|
+
* @returns The CoFHE configuration with Node.js defaults applied
|
|
12
12
|
*/
|
|
13
|
-
declare function
|
|
13
|
+
declare function createCofheConfig(config: CofheInputConfig): CofheConfig;
|
|
14
14
|
/**
|
|
15
|
-
* Creates a CoFHE
|
|
15
|
+
* Creates a CoFHE client instance for Node.js with node-tfhe automatically configured
|
|
16
16
|
* TFHE will be initialized automatically on first encryption - no manual setup required
|
|
17
|
-
* @param config - The CoFHE
|
|
18
|
-
* @returns The CoFHE
|
|
17
|
+
* @param config - The CoFHE configuration (use createCofheConfig to create with Node.js defaults)
|
|
18
|
+
* @returns The CoFHE client instance
|
|
19
19
|
*/
|
|
20
|
-
declare function
|
|
20
|
+
declare function createCofheClient(config: CofheConfig): CofheClient;
|
|
21
21
|
|
|
22
|
-
export {
|
|
22
|
+
export { createCofheClient, createCofheConfig };
|
package/dist/node.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import './chunk-
|
|
3
|
-
import './chunk-
|
|
1
|
+
import { createCofheConfigBase, createCofheClientBase } from './chunk-2TPSCOW3.js';
|
|
2
|
+
import './chunk-TBLR7NNE.js';
|
|
3
|
+
import './chunk-NWDKXBIP.js';
|
|
4
4
|
import { promises } from 'fs';
|
|
5
5
|
import { join } from 'path';
|
|
6
6
|
import { init_panic_hook, TfheCompactPublicKey, CompactPkeCrs, ProvenCompactCiphertextList } from 'node-tfhe';
|
|
@@ -71,15 +71,15 @@ var zkBuilderAndCrsGenerator = (fhe, crs) => {
|
|
|
71
71
|
const zkCrs = CompactPkeCrs.deserialize(fromHexString(crs));
|
|
72
72
|
return { zkBuilder, zkCrs };
|
|
73
73
|
};
|
|
74
|
-
function
|
|
75
|
-
return
|
|
74
|
+
function createCofheConfig(config) {
|
|
75
|
+
return createCofheConfigBase({
|
|
76
76
|
environment: "node",
|
|
77
77
|
...config,
|
|
78
78
|
fheKeyStorage: config.fheKeyStorage === null ? null : config.fheKeyStorage ?? createNodeStorage()
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
return
|
|
81
|
+
function createCofheClient(config) {
|
|
82
|
+
return createCofheClientBase({
|
|
83
83
|
config,
|
|
84
84
|
zkBuilderAndCrsGenerator,
|
|
85
85
|
tfhePublicKeyDeserializer,
|
|
@@ -88,4 +88,4 @@ function createCofhesdkClient(config) {
|
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
export {
|
|
91
|
+
export { createCofheClient, createCofheConfig };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { PublicClient, WalletClient } from 'viem';
|
|
1
|
+
import { Hex, PublicClient, WalletClient } from 'viem';
|
|
3
2
|
|
|
4
3
|
type EthEncryptedData = {
|
|
5
4
|
data: Uint8Array;
|
|
@@ -71,7 +70,7 @@ type EIP712Message = Record<string, string>;
|
|
|
71
70
|
type EIP712Domain = {
|
|
72
71
|
chainId: number;
|
|
73
72
|
name: string;
|
|
74
|
-
verifyingContract:
|
|
73
|
+
verifyingContract: Hex;
|
|
75
74
|
version: string;
|
|
76
75
|
};
|
|
77
76
|
/**
|
|
@@ -83,6 +82,10 @@ type SealingKey = SealingKey$1;
|
|
|
83
82
|
* Core Permit interface - immutable design for React compatibility
|
|
84
83
|
*/
|
|
85
84
|
interface Permit {
|
|
85
|
+
/**
|
|
86
|
+
* Stable hash of relevant permit data, used as key in storage
|
|
87
|
+
*/
|
|
88
|
+
hash: string;
|
|
86
89
|
/**
|
|
87
90
|
* Name for this permit, for organization and UI usage, not included in signature.
|
|
88
91
|
*/
|
|
@@ -97,7 +100,7 @@ interface Permit {
|
|
|
97
100
|
/**
|
|
98
101
|
* (base) User that initially created the permission, target of data fetching
|
|
99
102
|
*/
|
|
100
|
-
issuer:
|
|
103
|
+
issuer: Hex;
|
|
101
104
|
/**
|
|
102
105
|
* (base) Expiration timestamp
|
|
103
106
|
*/
|
|
@@ -106,7 +109,7 @@ interface Permit {
|
|
|
106
109
|
* (sharing) The user that this permission will be shared with
|
|
107
110
|
* ** optional, use `address(0)` to disable **
|
|
108
111
|
*/
|
|
109
|
-
recipient:
|
|
112
|
+
recipient: Hex;
|
|
110
113
|
/**
|
|
111
114
|
* (issuer defined validation) An id used to query a contract to check this permissions validity
|
|
112
115
|
* ** optional, use `0` to disable **
|
|
@@ -116,7 +119,7 @@ interface Permit {
|
|
|
116
119
|
* (issuer defined validation) The contract to query to determine permission validity
|
|
117
120
|
* ** optional, user `address(0)` to disable **
|
|
118
121
|
*/
|
|
119
|
-
validatorContract:
|
|
122
|
+
validatorContract: Hex;
|
|
120
123
|
/**
|
|
121
124
|
* (base) The publicKey of a sealingPair used to re-encrypt `issuer`s confidential data
|
|
122
125
|
* (non-sharing) Populated by `issuer`
|
|
@@ -129,13 +132,13 @@ interface Permit {
|
|
|
129
132
|
* (non-sharing) < issuer, expiration, recipient, validatorId, validatorContract, sealingKey >
|
|
130
133
|
* (sharing) < issuer, expiration, recipient, validatorId, validatorContract >
|
|
131
134
|
*/
|
|
132
|
-
issuerSignature:
|
|
135
|
+
issuerSignature: Hex;
|
|
133
136
|
/**
|
|
134
137
|
* (sharing) `signTypedData` signature created by `recipient` with format:
|
|
135
138
|
* (sharing) < sealingKey, issuerSignature>
|
|
136
139
|
* ** required for shared permits **
|
|
137
140
|
*/
|
|
138
|
-
recipientSignature:
|
|
141
|
+
recipientSignature: Hex;
|
|
139
142
|
/**
|
|
140
143
|
* EIP712 domain used to sign this permit.
|
|
141
144
|
* Should not be set manually, included in metadata as part of serialization flows.
|
|
@@ -196,7 +199,7 @@ type ImportSharedPermitOptions = {
|
|
|
196
199
|
recipient: string;
|
|
197
200
|
issuerSignature: string;
|
|
198
201
|
name?: string;
|
|
199
|
-
expiration
|
|
202
|
+
expiration: number;
|
|
200
203
|
validatorId?: number;
|
|
201
204
|
validatorContract?: string;
|
|
202
205
|
};
|
|
@@ -210,9 +213,13 @@ type SerializedPermit = Omit<Permit, 'sealingPair'> & {
|
|
|
210
213
|
/**
|
|
211
214
|
* A type representing the Permission struct that is passed to Permissioned.sol to grant encrypted data access.
|
|
212
215
|
*/
|
|
213
|
-
type Permission = Expand<Omit<Permit, 'name' | 'type' | 'sealingPair'> & {
|
|
214
|
-
sealingKey:
|
|
216
|
+
type Permission = Expand<Omit<Permit, 'name' | 'type' | 'sealingPair' | 'hash'> & {
|
|
217
|
+
sealingKey: Hex;
|
|
215
218
|
}>;
|
|
219
|
+
/**
|
|
220
|
+
* A type representing the permit fields that are used to generate the hash
|
|
221
|
+
*/
|
|
222
|
+
type PermitHashFields = Pick<Permit, 'type' | 'issuer' | 'expiration' | 'recipient' | 'validatorId' | 'validatorContract'>;
|
|
216
223
|
/**
|
|
217
224
|
* Validation result type
|
|
218
225
|
*/
|
|
@@ -271,35 +278,21 @@ declare const PermitUtils: {
|
|
|
271
278
|
/**
|
|
272
279
|
* Validate a permit
|
|
273
280
|
*/
|
|
274
|
-
validate: (permit: Permit) =>
|
|
275
|
-
type: "self" | "sharing" | "recipient";
|
|
276
|
-
issuer: string;
|
|
277
|
-
recipient?: string | undefined;
|
|
278
|
-
name?: string | undefined;
|
|
279
|
-
expiration?: number | undefined;
|
|
280
|
-
validatorId?: number | undefined;
|
|
281
|
-
validatorContract?: string | undefined;
|
|
282
|
-
sealingPair?: {
|
|
283
|
-
privateKey: string;
|
|
284
|
-
publicKey: string;
|
|
285
|
-
} | undefined;
|
|
286
|
-
issuerSignature?: string | undefined;
|
|
287
|
-
recipientSignature?: string | undefined;
|
|
288
|
-
}, {
|
|
289
|
-
recipient: `0x${string}`;
|
|
290
|
-
type: "self" | "sharing" | "recipient";
|
|
281
|
+
validate: (permit: Permit) => {
|
|
291
282
|
name: string;
|
|
283
|
+
type: "self" | "sharing" | "recipient";
|
|
292
284
|
issuer: `0x${string}`;
|
|
293
285
|
expiration: number;
|
|
286
|
+
recipient: `0x${string}`;
|
|
294
287
|
validatorId: number;
|
|
295
288
|
validatorContract: `0x${string}`;
|
|
296
|
-
issuerSignature: string
|
|
297
|
-
recipientSignature: string
|
|
289
|
+
issuerSignature: `0x${string}`;
|
|
290
|
+
recipientSignature: `0x${string}`;
|
|
298
291
|
sealingPair?: {
|
|
299
292
|
privateKey: string;
|
|
300
293
|
publicKey: string;
|
|
301
294
|
} | undefined;
|
|
302
|
-
}
|
|
295
|
+
};
|
|
303
296
|
/**
|
|
304
297
|
* Get the permission object from a permit (for use in contracts)
|
|
305
298
|
*/
|
|
@@ -307,7 +300,7 @@ declare const PermitUtils: {
|
|
|
307
300
|
/**
|
|
308
301
|
* Get a stable hash for the permit (used as key in storage)
|
|
309
302
|
*/
|
|
310
|
-
getHash: (permit:
|
|
303
|
+
getHash: (permit: PermitHashFields) => string;
|
|
311
304
|
/**
|
|
312
305
|
* Export permit data for sharing (removes sensitive fields)
|
|
313
306
|
*/
|
|
@@ -344,6 +337,10 @@ declare const PermitUtils: {
|
|
|
344
337
|
* Check if permit's signed domain is valid for the current chain
|
|
345
338
|
*/
|
|
346
339
|
checkSignedDomainValid: (permit: Permit, publicClient: PublicClient) => Promise<boolean>;
|
|
340
|
+
/**
|
|
341
|
+
* Check if permit passes the on-chain validation
|
|
342
|
+
*/
|
|
343
|
+
checkValidityOnChain: (permit: Permit, publicClient: PublicClient) => Promise<boolean>;
|
|
347
344
|
};
|
|
348
345
|
|
|
349
|
-
export { type CreateSelfPermitOptions as C, type EIP712Types as E, GenerateSealingKey as G, type ImportSharedPermitOptions as I, type Permit as P, type RecipientPermit as R, type SerializedPermit as S, type ValidationResult as V, type PermitSignaturePrimaryType as a, type Permission as b, type EIP712Message as c, type CreateSharingPermitOptions as d, type PermitMetadata as e, type EIP712Domain as f, PermitUtils as g, SealingKey$1 as h, type EthEncryptedData as i, type EIP712Type as j, type PermitType as k, type PermitOf as l, type SelfPermit as m, type SharingPermit as n, type
|
|
346
|
+
export { type CreateSelfPermitOptions as C, type EIP712Types as E, GenerateSealingKey as G, type ImportSharedPermitOptions as I, type Permit as P, type RecipientPermit as R, type SerializedPermit as S, type ValidationResult as V, type PermitSignaturePrimaryType as a, type Permission as b, type EIP712Message as c, type CreateSharingPermitOptions as d, type PermitMetadata as e, type EIP712Domain as f, PermitUtils as g, SealingKey$1 as h, type EthEncryptedData as i, type EIP712Type as j, type PermitType as k, type PermitOf as l, type SelfPermit as m, type SharingPermit as n, type PermitHashFields as o, type Expand as p };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { PublicClient, WalletClient } from 'viem';
|
|
1
|
+
import { Hex, PublicClient, WalletClient } from 'viem';
|
|
3
2
|
|
|
4
3
|
type EthEncryptedData = {
|
|
5
4
|
data: Uint8Array;
|
|
@@ -71,7 +70,7 @@ type EIP712Message = Record<string, string>;
|
|
|
71
70
|
type EIP712Domain = {
|
|
72
71
|
chainId: number;
|
|
73
72
|
name: string;
|
|
74
|
-
verifyingContract:
|
|
73
|
+
verifyingContract: Hex;
|
|
75
74
|
version: string;
|
|
76
75
|
};
|
|
77
76
|
/**
|
|
@@ -83,6 +82,10 @@ type SealingKey = SealingKey$1;
|
|
|
83
82
|
* Core Permit interface - immutable design for React compatibility
|
|
84
83
|
*/
|
|
85
84
|
interface Permit {
|
|
85
|
+
/**
|
|
86
|
+
* Stable hash of relevant permit data, used as key in storage
|
|
87
|
+
*/
|
|
88
|
+
hash: string;
|
|
86
89
|
/**
|
|
87
90
|
* Name for this permit, for organization and UI usage, not included in signature.
|
|
88
91
|
*/
|
|
@@ -97,7 +100,7 @@ interface Permit {
|
|
|
97
100
|
/**
|
|
98
101
|
* (base) User that initially created the permission, target of data fetching
|
|
99
102
|
*/
|
|
100
|
-
issuer:
|
|
103
|
+
issuer: Hex;
|
|
101
104
|
/**
|
|
102
105
|
* (base) Expiration timestamp
|
|
103
106
|
*/
|
|
@@ -106,7 +109,7 @@ interface Permit {
|
|
|
106
109
|
* (sharing) The user that this permission will be shared with
|
|
107
110
|
* ** optional, use `address(0)` to disable **
|
|
108
111
|
*/
|
|
109
|
-
recipient:
|
|
112
|
+
recipient: Hex;
|
|
110
113
|
/**
|
|
111
114
|
* (issuer defined validation) An id used to query a contract to check this permissions validity
|
|
112
115
|
* ** optional, use `0` to disable **
|
|
@@ -116,7 +119,7 @@ interface Permit {
|
|
|
116
119
|
* (issuer defined validation) The contract to query to determine permission validity
|
|
117
120
|
* ** optional, user `address(0)` to disable **
|
|
118
121
|
*/
|
|
119
|
-
validatorContract:
|
|
122
|
+
validatorContract: Hex;
|
|
120
123
|
/**
|
|
121
124
|
* (base) The publicKey of a sealingPair used to re-encrypt `issuer`s confidential data
|
|
122
125
|
* (non-sharing) Populated by `issuer`
|
|
@@ -129,13 +132,13 @@ interface Permit {
|
|
|
129
132
|
* (non-sharing) < issuer, expiration, recipient, validatorId, validatorContract, sealingKey >
|
|
130
133
|
* (sharing) < issuer, expiration, recipient, validatorId, validatorContract >
|
|
131
134
|
*/
|
|
132
|
-
issuerSignature:
|
|
135
|
+
issuerSignature: Hex;
|
|
133
136
|
/**
|
|
134
137
|
* (sharing) `signTypedData` signature created by `recipient` with format:
|
|
135
138
|
* (sharing) < sealingKey, issuerSignature>
|
|
136
139
|
* ** required for shared permits **
|
|
137
140
|
*/
|
|
138
|
-
recipientSignature:
|
|
141
|
+
recipientSignature: Hex;
|
|
139
142
|
/**
|
|
140
143
|
* EIP712 domain used to sign this permit.
|
|
141
144
|
* Should not be set manually, included in metadata as part of serialization flows.
|
|
@@ -196,7 +199,7 @@ type ImportSharedPermitOptions = {
|
|
|
196
199
|
recipient: string;
|
|
197
200
|
issuerSignature: string;
|
|
198
201
|
name?: string;
|
|
199
|
-
expiration
|
|
202
|
+
expiration: number;
|
|
200
203
|
validatorId?: number;
|
|
201
204
|
validatorContract?: string;
|
|
202
205
|
};
|
|
@@ -210,9 +213,13 @@ type SerializedPermit = Omit<Permit, 'sealingPair'> & {
|
|
|
210
213
|
/**
|
|
211
214
|
* A type representing the Permission struct that is passed to Permissioned.sol to grant encrypted data access.
|
|
212
215
|
*/
|
|
213
|
-
type Permission = Expand<Omit<Permit, 'name' | 'type' | 'sealingPair'> & {
|
|
214
|
-
sealingKey:
|
|
216
|
+
type Permission = Expand<Omit<Permit, 'name' | 'type' | 'sealingPair' | 'hash'> & {
|
|
217
|
+
sealingKey: Hex;
|
|
215
218
|
}>;
|
|
219
|
+
/**
|
|
220
|
+
* A type representing the permit fields that are used to generate the hash
|
|
221
|
+
*/
|
|
222
|
+
type PermitHashFields = Pick<Permit, 'type' | 'issuer' | 'expiration' | 'recipient' | 'validatorId' | 'validatorContract'>;
|
|
216
223
|
/**
|
|
217
224
|
* Validation result type
|
|
218
225
|
*/
|
|
@@ -271,35 +278,21 @@ declare const PermitUtils: {
|
|
|
271
278
|
/**
|
|
272
279
|
* Validate a permit
|
|
273
280
|
*/
|
|
274
|
-
validate: (permit: Permit) =>
|
|
275
|
-
type: "self" | "sharing" | "recipient";
|
|
276
|
-
issuer: string;
|
|
277
|
-
recipient?: string | undefined;
|
|
278
|
-
name?: string | undefined;
|
|
279
|
-
expiration?: number | undefined;
|
|
280
|
-
validatorId?: number | undefined;
|
|
281
|
-
validatorContract?: string | undefined;
|
|
282
|
-
sealingPair?: {
|
|
283
|
-
privateKey: string;
|
|
284
|
-
publicKey: string;
|
|
285
|
-
} | undefined;
|
|
286
|
-
issuerSignature?: string | undefined;
|
|
287
|
-
recipientSignature?: string | undefined;
|
|
288
|
-
}, {
|
|
289
|
-
recipient: `0x${string}`;
|
|
290
|
-
type: "self" | "sharing" | "recipient";
|
|
281
|
+
validate: (permit: Permit) => {
|
|
291
282
|
name: string;
|
|
283
|
+
type: "self" | "sharing" | "recipient";
|
|
292
284
|
issuer: `0x${string}`;
|
|
293
285
|
expiration: number;
|
|
286
|
+
recipient: `0x${string}`;
|
|
294
287
|
validatorId: number;
|
|
295
288
|
validatorContract: `0x${string}`;
|
|
296
|
-
issuerSignature: string
|
|
297
|
-
recipientSignature: string
|
|
289
|
+
issuerSignature: `0x${string}`;
|
|
290
|
+
recipientSignature: `0x${string}`;
|
|
298
291
|
sealingPair?: {
|
|
299
292
|
privateKey: string;
|
|
300
293
|
publicKey: string;
|
|
301
294
|
} | undefined;
|
|
302
|
-
}
|
|
295
|
+
};
|
|
303
296
|
/**
|
|
304
297
|
* Get the permission object from a permit (for use in contracts)
|
|
305
298
|
*/
|
|
@@ -307,7 +300,7 @@ declare const PermitUtils: {
|
|
|
307
300
|
/**
|
|
308
301
|
* Get a stable hash for the permit (used as key in storage)
|
|
309
302
|
*/
|
|
310
|
-
getHash: (permit:
|
|
303
|
+
getHash: (permit: PermitHashFields) => string;
|
|
311
304
|
/**
|
|
312
305
|
* Export permit data for sharing (removes sensitive fields)
|
|
313
306
|
*/
|
|
@@ -344,6 +337,10 @@ declare const PermitUtils: {
|
|
|
344
337
|
* Check if permit's signed domain is valid for the current chain
|
|
345
338
|
*/
|
|
346
339
|
checkSignedDomainValid: (permit: Permit, publicClient: PublicClient) => Promise<boolean>;
|
|
340
|
+
/**
|
|
341
|
+
* Check if permit passes the on-chain validation
|
|
342
|
+
*/
|
|
343
|
+
checkValidityOnChain: (permit: Permit, publicClient: PublicClient) => Promise<boolean>;
|
|
347
344
|
};
|
|
348
345
|
|
|
349
|
-
export { type CreateSelfPermitOptions as C, type EIP712Types as E, GenerateSealingKey as G, type ImportSharedPermitOptions as I, type Permit as P, type RecipientPermit as R, type SerializedPermit as S, type ValidationResult as V, type PermitSignaturePrimaryType as a, type Permission as b, type EIP712Message as c, type CreateSharingPermitOptions as d, type PermitMetadata as e, type EIP712Domain as f, PermitUtils as g, SealingKey$1 as h, type EthEncryptedData as i, type EIP712Type as j, type PermitType as k, type PermitOf as l, type SelfPermit as m, type SharingPermit as n, type
|
|
346
|
+
export { type CreateSelfPermitOptions as C, type EIP712Types as E, GenerateSealingKey as G, type ImportSharedPermitOptions as I, type Permit as P, type RecipientPermit as R, type SerializedPermit as S, type ValidationResult as V, type PermitSignaturePrimaryType as a, type Permission as b, type EIP712Message as c, type CreateSharingPermitOptions as d, type PermitMetadata as e, type EIP712Domain as f, PermitUtils as g, SealingKey$1 as h, type EthEncryptedData as i, type EIP712Type as j, type PermitType as k, type PermitOf as l, type SelfPermit as m, type SharingPermit as n, type PermitHashFields as o, type Expand as p };
|