UNPKG

@zkpass/zkfetch

Version:

zkFetch using zkTLS is a system that enables verifiable fetching of HTTPS data using zero-knowledge proofs (ZKPs). It ensures that the response from a remote TLS server (like a Web2 API) is authentic, integrity-preserved, and can be publicly verified—with

111 lines (106 loc) • 2.69 kB
interface DataPattern{ regex: string order: string [key: string]: { regexMatchIndex: number prefix: string suffix: string map?: string[] mapCircuit?: { circuitId: number outputSize: number } } } interface RequestOptions { url: string; method: "GET" | "POST"; headers?: { [key: string]: any; }; body?: { [key: string]: any; }; requestAsserts?: {}; } interface FetchParams { request: RequestOptions; asserts: { request?: { query?: Array<FetchAssert>; headers?: Array<FetchAssert>; body?: Array<FetchAssert>; }; response: Array<FetchAssert>; }; } interface FetchAssert { key: string; value?: string; operation?: string; dataPattern?: DataPattern; isPublic?: boolean; tips?: string; } interface CircuitDependency { id: number; currentStartWire: number; dependencyInputWire: number; offset: number; } interface CircuitLine { id: number; circuitName: string; out: boolean; dependency: CircuitDependency[]; } declare class FetchHelper { static verifyById(taskId: string): Promise<{ verify_result: any; data: any; url: string; method: any; asserts: any; }>; static verify(params: FetchParams, requestCipher: Uint8Array, responseInfo: any, proof: Uint8Array): Promise<{ verify_result: any; data: any; }>; static recoverVerifyAddress(params: { taskId: string; data?: string; url: string; method: string; asserts: { request?: { query?: FetchAssert[]; headers?: FetchAssert[]; body?: FetchAssert[]; }; response: FetchAssert[]; }; verify_result: boolean; signature: string; task_signature: string; address: string; }): string; } declare class zkFetchClient extends FetchHelper { private appId; private wallet; constructor({ appId }: { appId: string; }); fetchData(params: FetchParams): Promise<any>; assert(response: any, asserts: FetchAssert[]): boolean; prepareProofData(requestInfo: any, responseInfo: any, responseAsserts: FetchAssert[]): Promise<{ inputBits: number[]; circuitList: CircuitLine[]; baseCircuits: { [key: string]: string; }; }>; connectNode(node: string, taskInfo: any, ephemeralAddress: string): Promise<Uint8Array>; requestVerifyInfo(taskId: string, counter?: number): Promise<any>; } export { zkFetchClient as default };