@provex/extension-react 1.11.0 → 2.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/README.md +23 -123
- package/dist/ZKTLSContext.cjs +7 -75
- package/dist/ZKTLSContext.cjs.map +1 -1
- package/dist/ZKTLSContext.d.cts +1 -15
- package/dist/ZKTLSContext.d.ts +1 -15
- package/dist/ZKTLSContext.js +2 -2
- package/dist/adapters/extensionEnclave.cjs.map +1 -1
- package/dist/adapters/extensionEnclave.js +1 -1
- package/dist/capability.cjs +50 -0
- package/dist/capability.cjs.map +1 -0
- package/dist/capability.d.cts +95 -0
- package/dist/capability.d.ts +95 -0
- package/dist/capability.js +3 -0
- package/dist/capability.js.map +1 -0
- package/dist/{chunk-T42E7EM7.js → chunk-B7RU2WKQ.js} +3 -3
- package/dist/{chunk-T42E7EM7.js.map → chunk-B7RU2WKQ.js.map} +1 -1
- package/dist/chunk-JMVW4H4H.js +44 -0
- package/dist/chunk-JMVW4H4H.js.map +1 -0
- package/dist/chunk-JU2T2TGY.js +123 -0
- package/dist/chunk-JU2T2TGY.js.map +1 -0
- package/dist/chunk-VQFWUZNJ.js +59 -0
- package/dist/chunk-VQFWUZNJ.js.map +1 -0
- package/dist/{chunk-AMJXMSDV.js → chunk-WSLUOLBW.js} +2 -2
- package/dist/chunk-WSLUOLBW.js.map +1 -0
- package/dist/index.cjs +101 -187
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +5 -3
- package/dist/useProofCapability.cjs +104 -0
- package/dist/useProofCapability.cjs.map +1 -0
- package/dist/useProofCapability.d.cts +27 -0
- package/dist/useProofCapability.d.ts +27 -0
- package/dist/useProofCapability.js +4 -0
- package/dist/useProofCapability.js.map +1 -0
- package/dist/useZKTLS.cjs +7 -195
- package/dist/useZKTLS.cjs.map +1 -1
- package/dist/useZKTLS.d.cts +10 -230
- package/dist/useZKTLS.d.ts +10 -230
- package/dist/useZKTLS.js +1 -1
- package/dist/useZKTLSContext.cjs +0 -5
- package/dist/useZKTLSContext.cjs.map +1 -1
- package/dist/useZKTLSContext.d.cts +0 -2
- package/dist/useZKTLSContext.d.ts +0 -2
- package/dist/useZKTLSContext.js +2 -2
- package/package.json +15 -4
- package/skills/extension-react-integration/SKILL.md +16 -73
- package/dist/chunk-AMJXMSDV.js.map +0 -1
- package/dist/chunk-TAS2MB4S.js +0 -301
- package/dist/chunk-TAS2MB4S.js.map +0 -1
package/dist/useZKTLS.d.cts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { Hex } from 'viem';
|
|
2
|
-
import { IntentStruct } from '@provex/utils/intent';
|
|
3
|
-
import { TokenInfo } from '@provex/utils/tokens';
|
|
4
2
|
import { ActionType, PlatformKey, ProviderKey } from '@provex/utils/payment';
|
|
5
3
|
|
|
6
4
|
/**
|
|
@@ -11,15 +9,17 @@ import { ActionType, PlatformKey, ProviderKey } from '@provex/utils/payment';
|
|
|
11
9
|
*
|
|
12
10
|
* 1. Type definitions for extension API (window.peer)
|
|
13
11
|
* 2. useZKTLS hook for React components
|
|
14
|
-
* 3.
|
|
12
|
+
* 3. The trusted-execution on-ramp helpers
|
|
15
13
|
*
|
|
16
14
|
* @remarks
|
|
17
15
|
* The extension exposes `window.peer` (or deprecated `window.zktls`) for:
|
|
18
16
|
* - Requesting connection (OAuth-like flow)
|
|
19
|
-
* - Authenticating with payment providers
|
|
20
|
-
* - Generating notarized proofs
|
|
17
|
+
* - Authenticating with payment providers (buyer trusted-execution capture)
|
|
21
18
|
* - Fetching transaction metadata
|
|
22
19
|
*
|
|
20
|
+
* The Reclaim proof path (generateProof, proof encoding, proof types) was
|
|
21
|
+
* removed in the next major version.
|
|
22
|
+
*
|
|
23
23
|
* @see {@link ZKTLSContext} for the React context provider
|
|
24
24
|
*/
|
|
25
25
|
|
|
@@ -29,9 +29,6 @@ declare global {
|
|
|
29
29
|
checkConnectionStatus(): Promise<Status>;
|
|
30
30
|
getVersion(): Promise<string>;
|
|
31
31
|
authenticate(inputs: AuthenticationInputs): Promise<void>;
|
|
32
|
-
generateProof(inputs: GenerateProofInputs): Promise<GenerateProofResponse>;
|
|
33
|
-
fetchProofById(proofId: string): Promise<ProofResponse>;
|
|
34
|
-
fetchProofs(): Promise<FetchProofsResponse>;
|
|
35
32
|
openSidebar(route: string): Promise<void>;
|
|
36
33
|
onMetadataMessage(fn: (data: MetadataMessageResponse) => void): () => void;
|
|
37
34
|
/**
|
|
@@ -39,7 +36,7 @@ declare global {
|
|
|
39
36
|
* buyer's bank in a new tab, intercepts the authenticated session, calls
|
|
40
37
|
* the zkp2p trusted-execution attestation service, and returns
|
|
41
38
|
* ready-to-send `fulfillIntent` calldata through the callback. Replaces
|
|
42
|
-
* the retired
|
|
39
|
+
* the retired Reclaim proof path.
|
|
43
40
|
*
|
|
44
41
|
* Optional: older extension builds predate the on-ramp API, so guard
|
|
45
42
|
* with a runtime presence check (`supportsOnramp`) before calling.
|
|
@@ -86,7 +83,7 @@ interface MetadataMessageResponse {
|
|
|
86
83
|
* Present only when `authenticate` was called with `captureMode: 'buyerTee'`.
|
|
87
84
|
* Carries the bank session already encrypted toward the enclave — feed
|
|
88
85
|
* `encryptedSessionMaterial` (plus the matched transaction's index) to the
|
|
89
|
-
* trusted-execution verify endpoint.
|
|
86
|
+
* trusted-execution verify endpoint.
|
|
90
87
|
*/
|
|
91
88
|
buyerTeeCapture?: {
|
|
92
89
|
encryptedSessionMaterial: string;
|
|
@@ -94,36 +91,6 @@ interface MetadataMessageResponse {
|
|
|
94
91
|
/** Error surfaced by the extension during capture (e.g. missing platform). */
|
|
95
92
|
errorMessage?: string;
|
|
96
93
|
}
|
|
97
|
-
/** the response from the PeerAuth extension when fetching proofs */
|
|
98
|
-
interface FetchProofsResponse {
|
|
99
|
-
notaryRequests: NotaryRequest[];
|
|
100
|
-
}
|
|
101
|
-
/** the inputs for the generateProof function */
|
|
102
|
-
type GenerateProofInputsAbstracted = {
|
|
103
|
-
platform: PlatformKey;
|
|
104
|
-
provider: ProviderKey;
|
|
105
|
-
intentHash: Hex;
|
|
106
|
-
originalIndex: number;
|
|
107
|
-
};
|
|
108
|
-
/** the inputs for the generateProof function */
|
|
109
|
-
type GenerateProofInputs = {
|
|
110
|
-
platform: ProviderKey;
|
|
111
|
-
originalIndex: number;
|
|
112
|
-
proofIndex?: number;
|
|
113
|
-
intentHash: string;
|
|
114
|
-
};
|
|
115
|
-
/**
|
|
116
|
-
* inputs for the generate proof function that requires the intent hash
|
|
117
|
-
* as hex to ensure it can be converted to a bigint string accurately
|
|
118
|
-
*/
|
|
119
|
-
type HexIntentGenerateProofInputs = Exclude<GenerateProofInputs, 'intentHash'> & {
|
|
120
|
-
intentHash: Hex;
|
|
121
|
-
};
|
|
122
|
-
/** the response from the PeerAuth extension when generating a proof */
|
|
123
|
-
type GenerateProofResponse = {
|
|
124
|
-
proofId: string;
|
|
125
|
-
platform: ProviderKey;
|
|
126
|
-
};
|
|
127
94
|
/** the inputs for the authenticate function */
|
|
128
95
|
type AuthenticationInputs = {
|
|
129
96
|
actionType: ActionType;
|
|
@@ -131,9 +98,8 @@ type AuthenticationInputs = {
|
|
|
131
98
|
/**
|
|
132
99
|
* Session capture mode. `'buyerTee'` makes the extension intercept the bank
|
|
133
100
|
* session and return it encrypted toward the trusted-execution enclave in
|
|
134
|
-
* `MetadataMessageResponse.buyerTeeCapture
|
|
135
|
-
*
|
|
136
|
-
* extension defaults the attestation service URL when this is set.
|
|
101
|
+
* `MetadataMessageResponse.buyerTeeCapture`. The extension defaults the
|
|
102
|
+
* attestation service URL when this is set.
|
|
137
103
|
*/
|
|
138
104
|
captureMode?: 'buyerTee' | 'sellerCredential';
|
|
139
105
|
/**
|
|
@@ -146,67 +112,6 @@ type AuthenticationInputs = {
|
|
|
146
112
|
/** Attestation action type; defaults to `actionType` when omitted (spec §2). */
|
|
147
113
|
attestationActionType?: ActionType;
|
|
148
114
|
};
|
|
149
|
-
/** the response from the PeerAuth extension when fetching a proof */
|
|
150
|
-
interface Proof {
|
|
151
|
-
claimInfo: ClaimInfo;
|
|
152
|
-
signedClaim: SignedClaim;
|
|
153
|
-
isAppclipProof: boolean;
|
|
154
|
-
status: string;
|
|
155
|
-
}
|
|
156
|
-
/** the response from the PeerAuth extension when fetching a proof */
|
|
157
|
-
interface NotarizedProof {
|
|
158
|
-
claim: {
|
|
159
|
-
context: string;
|
|
160
|
-
epoch: number;
|
|
161
|
-
identifier: Hex;
|
|
162
|
-
owner: Hex;
|
|
163
|
-
parameters: string;
|
|
164
|
-
provider: string;
|
|
165
|
-
timestampS: number;
|
|
166
|
-
};
|
|
167
|
-
signatures: {
|
|
168
|
-
attestorAddress: Hex;
|
|
169
|
-
claimSignature: Record<number, number>;
|
|
170
|
-
resultSignature: Record<number, number>;
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
/** the claim info for a proof */
|
|
174
|
-
interface ClaimInfo {
|
|
175
|
-
provider: string;
|
|
176
|
-
parameters: string;
|
|
177
|
-
context: string;
|
|
178
|
-
}
|
|
179
|
-
/** the complete claim data for a proof */
|
|
180
|
-
interface CompleteClaimData {
|
|
181
|
-
identifier: Hex;
|
|
182
|
-
owner: Hex;
|
|
183
|
-
timestampS: number;
|
|
184
|
-
epoch: number;
|
|
185
|
-
}
|
|
186
|
-
/** the signed claim for a proof */
|
|
187
|
-
interface SignedClaim {
|
|
188
|
-
claim: CompleteClaimData;
|
|
189
|
-
signatures: Hex[];
|
|
190
|
-
}
|
|
191
|
-
/** the reclaim proof for a proof */
|
|
192
|
-
type ReclaimProof = {
|
|
193
|
-
claimInfo: ClaimInfo;
|
|
194
|
-
signedClaim: SignedClaim;
|
|
195
|
-
isAppclipProof: boolean;
|
|
196
|
-
};
|
|
197
|
-
/** the notary request for a proof */
|
|
198
|
-
interface NotaryRequest {
|
|
199
|
-
metadata: (string | number)[];
|
|
200
|
-
actionType: ActionType;
|
|
201
|
-
id: string;
|
|
202
|
-
status: string;
|
|
203
|
-
timestamp: number;
|
|
204
|
-
proof: NotarizedProof;
|
|
205
|
-
}
|
|
206
|
-
/** the response from the PeerAuth extension when fetching a proof */
|
|
207
|
-
interface ProofResponse {
|
|
208
|
-
notaryRequest: NotaryRequest;
|
|
209
|
-
}
|
|
210
115
|
/**
|
|
211
116
|
* Ready-to-send transaction the PeerAuth extension hands back once the
|
|
212
117
|
* trusted-execution attestation service has signed the payment. The `data`
|
|
@@ -249,105 +154,7 @@ type PeerExtensionOnrampParams = {
|
|
|
249
154
|
* stringified.
|
|
250
155
|
*/
|
|
251
156
|
declare const buildOnrampQuery: (params: PeerExtensionOnrampParams) => string;
|
|
252
|
-
/**
|
|
253
|
-
* Wrap a buyerTee capture (from {@link MetadataMessageResponse.buyerTeeCapture})
|
|
254
|
-
* as a `NotaryRequest` so it flows through the existing submit step, which
|
|
255
|
-
* narrows `proof` to a buyerTee proof and routes it to the enclave verify
|
|
256
|
-
* endpoint. The `index` is the matched transaction's `originalIndex` — the
|
|
257
|
-
* extension keys the captured payment on it.
|
|
258
|
-
*
|
|
259
|
-
* This replaces `generateProof` entirely for migrated providers: the session
|
|
260
|
-
* was already captured + encrypted during `authenticate({ captureMode: 'buyerTee' })`.
|
|
261
|
-
*/
|
|
262
|
-
declare const buildBuyerTeeNotaryRequest: ({ encryptedSessionMaterial, index, actionType, }: {
|
|
263
|
-
encryptedSessionMaterial: string;
|
|
264
|
-
index: number;
|
|
265
|
-
actionType: ActionType;
|
|
266
|
-
}) => NotaryRequest;
|
|
267
157
|
declare const extensionUrl = "https://chromewebstore.google.com/detail/ijpgccednehjpeclfcllnjjcmiohdjih";
|
|
268
|
-
/** convert a byte array to a hex string */
|
|
269
|
-
declare const byteArrayToHexString: (byteArray: number[]) => Hex;
|
|
270
|
-
/** parse a proof object from the PeerAuth extension */
|
|
271
|
-
declare const parseExtensionProof: (proofObject: NotarizedProof) => ReclaimProof;
|
|
272
|
-
/** the abi encoding for a proof */
|
|
273
|
-
declare const PROOF_ENCODING: {
|
|
274
|
-
readonly type: "tuple";
|
|
275
|
-
readonly components: readonly [{
|
|
276
|
-
readonly type: "tuple";
|
|
277
|
-
readonly components: readonly [{
|
|
278
|
-
readonly type: "string";
|
|
279
|
-
readonly name: "provider";
|
|
280
|
-
}, {
|
|
281
|
-
readonly type: "string";
|
|
282
|
-
readonly name: "parameters";
|
|
283
|
-
}, {
|
|
284
|
-
readonly type: "string";
|
|
285
|
-
readonly name: "context";
|
|
286
|
-
}];
|
|
287
|
-
readonly name: "claimInfo";
|
|
288
|
-
}, {
|
|
289
|
-
readonly type: "tuple";
|
|
290
|
-
readonly components: readonly [{
|
|
291
|
-
readonly type: "tuple";
|
|
292
|
-
readonly components: readonly [{
|
|
293
|
-
readonly type: "bytes32";
|
|
294
|
-
readonly name: "identifier";
|
|
295
|
-
}, {
|
|
296
|
-
readonly type: "address";
|
|
297
|
-
readonly name: "owner";
|
|
298
|
-
}, {
|
|
299
|
-
readonly type: "uint32";
|
|
300
|
-
readonly name: "timestampS";
|
|
301
|
-
}, {
|
|
302
|
-
readonly type: "uint32";
|
|
303
|
-
readonly name: "epoch";
|
|
304
|
-
}];
|
|
305
|
-
readonly name: "claim";
|
|
306
|
-
}, {
|
|
307
|
-
readonly type: "bytes[]";
|
|
308
|
-
readonly name: "signatures";
|
|
309
|
-
}];
|
|
310
|
-
readonly name: "signedClaim";
|
|
311
|
-
}, {
|
|
312
|
-
readonly type: "bool";
|
|
313
|
-
readonly name: "isAppclipProof";
|
|
314
|
-
}];
|
|
315
|
-
};
|
|
316
|
-
/** encode a single proof as a bytes array */
|
|
317
|
-
declare function encodeProofAsBytes(proof: ReclaimProof): Hex;
|
|
318
|
-
/** encode two proofs to be passed to the underlying sub-provider */
|
|
319
|
-
declare const encodeTwoProofs: (proof1: ReclaimProof, proof2: ReclaimProof) => `0x${string}`;
|
|
320
|
-
/** a high level function to encode a proof for a given provider and sub-provider */
|
|
321
|
-
declare const encodeProof: ({ extensionProofs, subProvider, provider }: {
|
|
322
|
-
extensionProofs: NotarizedProof[];
|
|
323
|
-
subProvider: PlatformKey | null;
|
|
324
|
-
provider: ProviderKey;
|
|
325
|
-
}) => `0x${string}`;
|
|
326
|
-
/**
|
|
327
|
-
* wrap a proof with a payment method and proof
|
|
328
|
-
* this allows us to use a single verifier as an entry point for multiple underlying sub-providers
|
|
329
|
-
*/
|
|
330
|
-
declare const encodeProofWithPaymentMethod: ({ proof, paymentMethod }: {
|
|
331
|
-
proof: Hex;
|
|
332
|
-
paymentMethod: number;
|
|
333
|
-
}) => Hex;
|
|
334
|
-
/** the progress of a proof series */
|
|
335
|
-
declare enum SeriesProgress {
|
|
336
|
-
Generating = 0,
|
|
337
|
-
Polling = 1,
|
|
338
|
-
Complete = 2
|
|
339
|
-
}
|
|
340
|
-
type ProgressInfo = {
|
|
341
|
-
progress: SeriesProgress;
|
|
342
|
-
total: number;
|
|
343
|
-
step: number | null;
|
|
344
|
-
id: string | null;
|
|
345
|
-
};
|
|
346
|
-
/** the mutations for the generate proof series function */
|
|
347
|
-
type GenerateProofSeriesMutations = {
|
|
348
|
-
progress?: ({ progress, step, id }: ProgressInfo) => void;
|
|
349
|
-
setOwnerName?: (name: string) => void;
|
|
350
|
-
};
|
|
351
158
|
/** React hook to interact with the PeerAuth extension */
|
|
352
159
|
declare const useZKTLS: () => {
|
|
353
160
|
/** check if the PeerAuth extension is initialized */
|
|
@@ -363,20 +170,8 @@ declare const useZKTLS: () => {
|
|
|
363
170
|
getVersion: () => Promise<string | undefined>;
|
|
364
171
|
/** authenticate with the PeerAuth extension */
|
|
365
172
|
authenticate: (inputs: AuthenticationInputs) => Promise<MetadataMessageResponse>;
|
|
366
|
-
/** generate a proof */
|
|
367
|
-
generateProof: (inputs: HexIntentGenerateProofInputs) => Promise<GenerateProofResponse>;
|
|
368
|
-
/** wait for a proof to be generated */
|
|
369
|
-
waitForProof: (proofId: string, onCurrent?: (notaryRequest: NotaryRequest | null) => void) => Promise<NotaryRequest>;
|
|
370
|
-
/** generate a proof series */
|
|
371
|
-
generateProofSeries: (inputs: GenerateProofInputsAbstracted, { progress: progressCallback }?: GenerateProofSeriesMutations) => Promise<NotaryRequest[]>;
|
|
372
173
|
/** subscribe to metadata messages */
|
|
373
174
|
onMetadataMessage: (fn: (data: any) => void) => () => void;
|
|
374
|
-
/** fetch a proof by its id */
|
|
375
|
-
fetchProofById: (proofId: string) => Promise<NotaryRequest | null>;
|
|
376
|
-
/** fetch generated proofs */
|
|
377
|
-
fetchGeneratedProofs: (genProofResponses: GenerateProofResponse[]) => Promise<(NotaryRequest | null)[]>;
|
|
378
|
-
/** fetch all proofs */
|
|
379
|
-
fetchProofs: () => Promise<FetchProofsResponse>;
|
|
380
175
|
/** open the PeerAuth sidebar */
|
|
381
176
|
openSidebar: (route: string) => Promise<void>;
|
|
382
177
|
/** Whether the connected extension exposes the trusted-execution on-ramp. */
|
|
@@ -403,20 +198,5 @@ declare const useZKTLS: () => {
|
|
|
403
198
|
*/
|
|
404
199
|
getOnrampTransaction: (intentHash: string) => Promise<PeerOnrampPreparedTransaction | null>;
|
|
405
200
|
};
|
|
406
|
-
/**
|
|
407
|
-
* Find the metadata message that matches the intent by amount.
|
|
408
|
-
* Returns the first (most recent) transaction in the metadata array that matches the expected amount.
|
|
409
|
-
*
|
|
410
|
-
* Simplified matching: just find transactions with the correct amount.
|
|
411
|
-
* The user can manually select if multiple matches exist.
|
|
412
|
-
*/
|
|
413
|
-
declare const findMetadataMessage: ({ metadata, intent, token, centIsInt }: {
|
|
414
|
-
metadata: MetadataMessage[];
|
|
415
|
-
intent: IntentStruct;
|
|
416
|
-
token: TokenInfo;
|
|
417
|
-
/** @deprecated No longer used - kept for API compatibility */
|
|
418
|
-
recipient?: string;
|
|
419
|
-
centIsInt?: boolean;
|
|
420
|
-
}) => MetadataMessage | null;
|
|
421
201
|
|
|
422
|
-
export { type AuthenticationInputs, type
|
|
202
|
+
export { type AuthenticationInputs, type MetadataMessage, type MetadataMessageResponse, type PeerExtensionOnrampParams, type PeerOnrampPreparedTransaction, type Status, buildOnrampQuery, extensionUrl, useZKTLS };
|
package/dist/useZKTLS.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { Hex } from 'viem';
|
|
2
|
-
import { IntentStruct } from '@provex/utils/intent';
|
|
3
|
-
import { TokenInfo } from '@provex/utils/tokens';
|
|
4
2
|
import { ActionType, PlatformKey, ProviderKey } from '@provex/utils/payment';
|
|
5
3
|
|
|
6
4
|
/**
|
|
@@ -11,15 +9,17 @@ import { ActionType, PlatformKey, ProviderKey } from '@provex/utils/payment';
|
|
|
11
9
|
*
|
|
12
10
|
* 1. Type definitions for extension API (window.peer)
|
|
13
11
|
* 2. useZKTLS hook for React components
|
|
14
|
-
* 3.
|
|
12
|
+
* 3. The trusted-execution on-ramp helpers
|
|
15
13
|
*
|
|
16
14
|
* @remarks
|
|
17
15
|
* The extension exposes `window.peer` (or deprecated `window.zktls`) for:
|
|
18
16
|
* - Requesting connection (OAuth-like flow)
|
|
19
|
-
* - Authenticating with payment providers
|
|
20
|
-
* - Generating notarized proofs
|
|
17
|
+
* - Authenticating with payment providers (buyer trusted-execution capture)
|
|
21
18
|
* - Fetching transaction metadata
|
|
22
19
|
*
|
|
20
|
+
* The Reclaim proof path (generateProof, proof encoding, proof types) was
|
|
21
|
+
* removed in the next major version.
|
|
22
|
+
*
|
|
23
23
|
* @see {@link ZKTLSContext} for the React context provider
|
|
24
24
|
*/
|
|
25
25
|
|
|
@@ -29,9 +29,6 @@ declare global {
|
|
|
29
29
|
checkConnectionStatus(): Promise<Status>;
|
|
30
30
|
getVersion(): Promise<string>;
|
|
31
31
|
authenticate(inputs: AuthenticationInputs): Promise<void>;
|
|
32
|
-
generateProof(inputs: GenerateProofInputs): Promise<GenerateProofResponse>;
|
|
33
|
-
fetchProofById(proofId: string): Promise<ProofResponse>;
|
|
34
|
-
fetchProofs(): Promise<FetchProofsResponse>;
|
|
35
32
|
openSidebar(route: string): Promise<void>;
|
|
36
33
|
onMetadataMessage(fn: (data: MetadataMessageResponse) => void): () => void;
|
|
37
34
|
/**
|
|
@@ -39,7 +36,7 @@ declare global {
|
|
|
39
36
|
* buyer's bank in a new tab, intercepts the authenticated session, calls
|
|
40
37
|
* the zkp2p trusted-execution attestation service, and returns
|
|
41
38
|
* ready-to-send `fulfillIntent` calldata through the callback. Replaces
|
|
42
|
-
* the retired
|
|
39
|
+
* the retired Reclaim proof path.
|
|
43
40
|
*
|
|
44
41
|
* Optional: older extension builds predate the on-ramp API, so guard
|
|
45
42
|
* with a runtime presence check (`supportsOnramp`) before calling.
|
|
@@ -86,7 +83,7 @@ interface MetadataMessageResponse {
|
|
|
86
83
|
* Present only when `authenticate` was called with `captureMode: 'buyerTee'`.
|
|
87
84
|
* Carries the bank session already encrypted toward the enclave — feed
|
|
88
85
|
* `encryptedSessionMaterial` (plus the matched transaction's index) to the
|
|
89
|
-
* trusted-execution verify endpoint.
|
|
86
|
+
* trusted-execution verify endpoint.
|
|
90
87
|
*/
|
|
91
88
|
buyerTeeCapture?: {
|
|
92
89
|
encryptedSessionMaterial: string;
|
|
@@ -94,36 +91,6 @@ interface MetadataMessageResponse {
|
|
|
94
91
|
/** Error surfaced by the extension during capture (e.g. missing platform). */
|
|
95
92
|
errorMessage?: string;
|
|
96
93
|
}
|
|
97
|
-
/** the response from the PeerAuth extension when fetching proofs */
|
|
98
|
-
interface FetchProofsResponse {
|
|
99
|
-
notaryRequests: NotaryRequest[];
|
|
100
|
-
}
|
|
101
|
-
/** the inputs for the generateProof function */
|
|
102
|
-
type GenerateProofInputsAbstracted = {
|
|
103
|
-
platform: PlatformKey;
|
|
104
|
-
provider: ProviderKey;
|
|
105
|
-
intentHash: Hex;
|
|
106
|
-
originalIndex: number;
|
|
107
|
-
};
|
|
108
|
-
/** the inputs for the generateProof function */
|
|
109
|
-
type GenerateProofInputs = {
|
|
110
|
-
platform: ProviderKey;
|
|
111
|
-
originalIndex: number;
|
|
112
|
-
proofIndex?: number;
|
|
113
|
-
intentHash: string;
|
|
114
|
-
};
|
|
115
|
-
/**
|
|
116
|
-
* inputs for the generate proof function that requires the intent hash
|
|
117
|
-
* as hex to ensure it can be converted to a bigint string accurately
|
|
118
|
-
*/
|
|
119
|
-
type HexIntentGenerateProofInputs = Exclude<GenerateProofInputs, 'intentHash'> & {
|
|
120
|
-
intentHash: Hex;
|
|
121
|
-
};
|
|
122
|
-
/** the response from the PeerAuth extension when generating a proof */
|
|
123
|
-
type GenerateProofResponse = {
|
|
124
|
-
proofId: string;
|
|
125
|
-
platform: ProviderKey;
|
|
126
|
-
};
|
|
127
94
|
/** the inputs for the authenticate function */
|
|
128
95
|
type AuthenticationInputs = {
|
|
129
96
|
actionType: ActionType;
|
|
@@ -131,9 +98,8 @@ type AuthenticationInputs = {
|
|
|
131
98
|
/**
|
|
132
99
|
* Session capture mode. `'buyerTee'` makes the extension intercept the bank
|
|
133
100
|
* session and return it encrypted toward the trusted-execution enclave in
|
|
134
|
-
* `MetadataMessageResponse.buyerTeeCapture
|
|
135
|
-
*
|
|
136
|
-
* extension defaults the attestation service URL when this is set.
|
|
101
|
+
* `MetadataMessageResponse.buyerTeeCapture`. The extension defaults the
|
|
102
|
+
* attestation service URL when this is set.
|
|
137
103
|
*/
|
|
138
104
|
captureMode?: 'buyerTee' | 'sellerCredential';
|
|
139
105
|
/**
|
|
@@ -146,67 +112,6 @@ type AuthenticationInputs = {
|
|
|
146
112
|
/** Attestation action type; defaults to `actionType` when omitted (spec §2). */
|
|
147
113
|
attestationActionType?: ActionType;
|
|
148
114
|
};
|
|
149
|
-
/** the response from the PeerAuth extension when fetching a proof */
|
|
150
|
-
interface Proof {
|
|
151
|
-
claimInfo: ClaimInfo;
|
|
152
|
-
signedClaim: SignedClaim;
|
|
153
|
-
isAppclipProof: boolean;
|
|
154
|
-
status: string;
|
|
155
|
-
}
|
|
156
|
-
/** the response from the PeerAuth extension when fetching a proof */
|
|
157
|
-
interface NotarizedProof {
|
|
158
|
-
claim: {
|
|
159
|
-
context: string;
|
|
160
|
-
epoch: number;
|
|
161
|
-
identifier: Hex;
|
|
162
|
-
owner: Hex;
|
|
163
|
-
parameters: string;
|
|
164
|
-
provider: string;
|
|
165
|
-
timestampS: number;
|
|
166
|
-
};
|
|
167
|
-
signatures: {
|
|
168
|
-
attestorAddress: Hex;
|
|
169
|
-
claimSignature: Record<number, number>;
|
|
170
|
-
resultSignature: Record<number, number>;
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
/** the claim info for a proof */
|
|
174
|
-
interface ClaimInfo {
|
|
175
|
-
provider: string;
|
|
176
|
-
parameters: string;
|
|
177
|
-
context: string;
|
|
178
|
-
}
|
|
179
|
-
/** the complete claim data for a proof */
|
|
180
|
-
interface CompleteClaimData {
|
|
181
|
-
identifier: Hex;
|
|
182
|
-
owner: Hex;
|
|
183
|
-
timestampS: number;
|
|
184
|
-
epoch: number;
|
|
185
|
-
}
|
|
186
|
-
/** the signed claim for a proof */
|
|
187
|
-
interface SignedClaim {
|
|
188
|
-
claim: CompleteClaimData;
|
|
189
|
-
signatures: Hex[];
|
|
190
|
-
}
|
|
191
|
-
/** the reclaim proof for a proof */
|
|
192
|
-
type ReclaimProof = {
|
|
193
|
-
claimInfo: ClaimInfo;
|
|
194
|
-
signedClaim: SignedClaim;
|
|
195
|
-
isAppclipProof: boolean;
|
|
196
|
-
};
|
|
197
|
-
/** the notary request for a proof */
|
|
198
|
-
interface NotaryRequest {
|
|
199
|
-
metadata: (string | number)[];
|
|
200
|
-
actionType: ActionType;
|
|
201
|
-
id: string;
|
|
202
|
-
status: string;
|
|
203
|
-
timestamp: number;
|
|
204
|
-
proof: NotarizedProof;
|
|
205
|
-
}
|
|
206
|
-
/** the response from the PeerAuth extension when fetching a proof */
|
|
207
|
-
interface ProofResponse {
|
|
208
|
-
notaryRequest: NotaryRequest;
|
|
209
|
-
}
|
|
210
115
|
/**
|
|
211
116
|
* Ready-to-send transaction the PeerAuth extension hands back once the
|
|
212
117
|
* trusted-execution attestation service has signed the payment. The `data`
|
|
@@ -249,105 +154,7 @@ type PeerExtensionOnrampParams = {
|
|
|
249
154
|
* stringified.
|
|
250
155
|
*/
|
|
251
156
|
declare const buildOnrampQuery: (params: PeerExtensionOnrampParams) => string;
|
|
252
|
-
/**
|
|
253
|
-
* Wrap a buyerTee capture (from {@link MetadataMessageResponse.buyerTeeCapture})
|
|
254
|
-
* as a `NotaryRequest` so it flows through the existing submit step, which
|
|
255
|
-
* narrows `proof` to a buyerTee proof and routes it to the enclave verify
|
|
256
|
-
* endpoint. The `index` is the matched transaction's `originalIndex` — the
|
|
257
|
-
* extension keys the captured payment on it.
|
|
258
|
-
*
|
|
259
|
-
* This replaces `generateProof` entirely for migrated providers: the session
|
|
260
|
-
* was already captured + encrypted during `authenticate({ captureMode: 'buyerTee' })`.
|
|
261
|
-
*/
|
|
262
|
-
declare const buildBuyerTeeNotaryRequest: ({ encryptedSessionMaterial, index, actionType, }: {
|
|
263
|
-
encryptedSessionMaterial: string;
|
|
264
|
-
index: number;
|
|
265
|
-
actionType: ActionType;
|
|
266
|
-
}) => NotaryRequest;
|
|
267
157
|
declare const extensionUrl = "https://chromewebstore.google.com/detail/ijpgccednehjpeclfcllnjjcmiohdjih";
|
|
268
|
-
/** convert a byte array to a hex string */
|
|
269
|
-
declare const byteArrayToHexString: (byteArray: number[]) => Hex;
|
|
270
|
-
/** parse a proof object from the PeerAuth extension */
|
|
271
|
-
declare const parseExtensionProof: (proofObject: NotarizedProof) => ReclaimProof;
|
|
272
|
-
/** the abi encoding for a proof */
|
|
273
|
-
declare const PROOF_ENCODING: {
|
|
274
|
-
readonly type: "tuple";
|
|
275
|
-
readonly components: readonly [{
|
|
276
|
-
readonly type: "tuple";
|
|
277
|
-
readonly components: readonly [{
|
|
278
|
-
readonly type: "string";
|
|
279
|
-
readonly name: "provider";
|
|
280
|
-
}, {
|
|
281
|
-
readonly type: "string";
|
|
282
|
-
readonly name: "parameters";
|
|
283
|
-
}, {
|
|
284
|
-
readonly type: "string";
|
|
285
|
-
readonly name: "context";
|
|
286
|
-
}];
|
|
287
|
-
readonly name: "claimInfo";
|
|
288
|
-
}, {
|
|
289
|
-
readonly type: "tuple";
|
|
290
|
-
readonly components: readonly [{
|
|
291
|
-
readonly type: "tuple";
|
|
292
|
-
readonly components: readonly [{
|
|
293
|
-
readonly type: "bytes32";
|
|
294
|
-
readonly name: "identifier";
|
|
295
|
-
}, {
|
|
296
|
-
readonly type: "address";
|
|
297
|
-
readonly name: "owner";
|
|
298
|
-
}, {
|
|
299
|
-
readonly type: "uint32";
|
|
300
|
-
readonly name: "timestampS";
|
|
301
|
-
}, {
|
|
302
|
-
readonly type: "uint32";
|
|
303
|
-
readonly name: "epoch";
|
|
304
|
-
}];
|
|
305
|
-
readonly name: "claim";
|
|
306
|
-
}, {
|
|
307
|
-
readonly type: "bytes[]";
|
|
308
|
-
readonly name: "signatures";
|
|
309
|
-
}];
|
|
310
|
-
readonly name: "signedClaim";
|
|
311
|
-
}, {
|
|
312
|
-
readonly type: "bool";
|
|
313
|
-
readonly name: "isAppclipProof";
|
|
314
|
-
}];
|
|
315
|
-
};
|
|
316
|
-
/** encode a single proof as a bytes array */
|
|
317
|
-
declare function encodeProofAsBytes(proof: ReclaimProof): Hex;
|
|
318
|
-
/** encode two proofs to be passed to the underlying sub-provider */
|
|
319
|
-
declare const encodeTwoProofs: (proof1: ReclaimProof, proof2: ReclaimProof) => `0x${string}`;
|
|
320
|
-
/** a high level function to encode a proof for a given provider and sub-provider */
|
|
321
|
-
declare const encodeProof: ({ extensionProofs, subProvider, provider }: {
|
|
322
|
-
extensionProofs: NotarizedProof[];
|
|
323
|
-
subProvider: PlatformKey | null;
|
|
324
|
-
provider: ProviderKey;
|
|
325
|
-
}) => `0x${string}`;
|
|
326
|
-
/**
|
|
327
|
-
* wrap a proof with a payment method and proof
|
|
328
|
-
* this allows us to use a single verifier as an entry point for multiple underlying sub-providers
|
|
329
|
-
*/
|
|
330
|
-
declare const encodeProofWithPaymentMethod: ({ proof, paymentMethod }: {
|
|
331
|
-
proof: Hex;
|
|
332
|
-
paymentMethod: number;
|
|
333
|
-
}) => Hex;
|
|
334
|
-
/** the progress of a proof series */
|
|
335
|
-
declare enum SeriesProgress {
|
|
336
|
-
Generating = 0,
|
|
337
|
-
Polling = 1,
|
|
338
|
-
Complete = 2
|
|
339
|
-
}
|
|
340
|
-
type ProgressInfo = {
|
|
341
|
-
progress: SeriesProgress;
|
|
342
|
-
total: number;
|
|
343
|
-
step: number | null;
|
|
344
|
-
id: string | null;
|
|
345
|
-
};
|
|
346
|
-
/** the mutations for the generate proof series function */
|
|
347
|
-
type GenerateProofSeriesMutations = {
|
|
348
|
-
progress?: ({ progress, step, id }: ProgressInfo) => void;
|
|
349
|
-
setOwnerName?: (name: string) => void;
|
|
350
|
-
};
|
|
351
158
|
/** React hook to interact with the PeerAuth extension */
|
|
352
159
|
declare const useZKTLS: () => {
|
|
353
160
|
/** check if the PeerAuth extension is initialized */
|
|
@@ -363,20 +170,8 @@ declare const useZKTLS: () => {
|
|
|
363
170
|
getVersion: () => Promise<string | undefined>;
|
|
364
171
|
/** authenticate with the PeerAuth extension */
|
|
365
172
|
authenticate: (inputs: AuthenticationInputs) => Promise<MetadataMessageResponse>;
|
|
366
|
-
/** generate a proof */
|
|
367
|
-
generateProof: (inputs: HexIntentGenerateProofInputs) => Promise<GenerateProofResponse>;
|
|
368
|
-
/** wait for a proof to be generated */
|
|
369
|
-
waitForProof: (proofId: string, onCurrent?: (notaryRequest: NotaryRequest | null) => void) => Promise<NotaryRequest>;
|
|
370
|
-
/** generate a proof series */
|
|
371
|
-
generateProofSeries: (inputs: GenerateProofInputsAbstracted, { progress: progressCallback }?: GenerateProofSeriesMutations) => Promise<NotaryRequest[]>;
|
|
372
173
|
/** subscribe to metadata messages */
|
|
373
174
|
onMetadataMessage: (fn: (data: any) => void) => () => void;
|
|
374
|
-
/** fetch a proof by its id */
|
|
375
|
-
fetchProofById: (proofId: string) => Promise<NotaryRequest | null>;
|
|
376
|
-
/** fetch generated proofs */
|
|
377
|
-
fetchGeneratedProofs: (genProofResponses: GenerateProofResponse[]) => Promise<(NotaryRequest | null)[]>;
|
|
378
|
-
/** fetch all proofs */
|
|
379
|
-
fetchProofs: () => Promise<FetchProofsResponse>;
|
|
380
175
|
/** open the PeerAuth sidebar */
|
|
381
176
|
openSidebar: (route: string) => Promise<void>;
|
|
382
177
|
/** Whether the connected extension exposes the trusted-execution on-ramp. */
|
|
@@ -403,20 +198,5 @@ declare const useZKTLS: () => {
|
|
|
403
198
|
*/
|
|
404
199
|
getOnrampTransaction: (intentHash: string) => Promise<PeerOnrampPreparedTransaction | null>;
|
|
405
200
|
};
|
|
406
|
-
/**
|
|
407
|
-
* Find the metadata message that matches the intent by amount.
|
|
408
|
-
* Returns the first (most recent) transaction in the metadata array that matches the expected amount.
|
|
409
|
-
*
|
|
410
|
-
* Simplified matching: just find transactions with the correct amount.
|
|
411
|
-
* The user can manually select if multiple matches exist.
|
|
412
|
-
*/
|
|
413
|
-
declare const findMetadataMessage: ({ metadata, intent, token, centIsInt }: {
|
|
414
|
-
metadata: MetadataMessage[];
|
|
415
|
-
intent: IntentStruct;
|
|
416
|
-
token: TokenInfo;
|
|
417
|
-
/** @deprecated No longer used - kept for API compatibility */
|
|
418
|
-
recipient?: string;
|
|
419
|
-
centIsInt?: boolean;
|
|
420
|
-
}) => MetadataMessage | null;
|
|
421
201
|
|
|
422
|
-
export { type AuthenticationInputs, type
|
|
202
|
+
export { type AuthenticationInputs, type MetadataMessage, type MetadataMessageResponse, type PeerExtensionOnrampParams, type PeerOnrampPreparedTransaction, type Status, buildOnrampQuery, extensionUrl, useZKTLS };
|
package/dist/useZKTLS.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { buildOnrampQuery, extensionUrl, useZKTLS } from './chunk-JU2T2TGY.js';
|
|
2
2
|
//# sourceMappingURL=useZKTLS.js.map
|
|
3
3
|
//# sourceMappingURL=useZKTLS.js.map
|
package/dist/useZKTLSContext.cjs
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var react = require('react');
|
|
4
|
-
var viem = require('viem');
|
|
5
|
-
require('@provex/utils/time');
|
|
6
|
-
require('@provex/utils/payment');
|
|
7
|
-
require('@provex/utils/conversionRates');
|
|
8
4
|
require('react/jsx-runtime');
|
|
9
5
|
|
|
10
6
|
// src/ZKTLSContext.tsx
|
|
11
|
-
viem.parseAbiParameter("((string provider, string parameters, string context) claimInfo, ((bytes32 identifier, address owner, uint32 timestampS, uint32 epoch) claim, bytes[] signatures) signedClaim, bool isAppclipProof)");
|
|
12
7
|
var ZKTLSContext = react.createContext(void 0);
|
|
13
8
|
function useZKTLSContext() {
|
|
14
9
|
const context = react.useContext(ZKTLSContext);
|