UNPKG

@reclaimprotocol/js-sdk

Version:

Designed to request proofs from the Reclaim protocol and manage the flow of claims and witness interactions.

94 lines (90 loc) 2.7 kB
interface Proof { identifier: string; claimData: ProviderClaimData; signatures: string[]; witnesses: WitnessData[]; extractedParameterValues: any; publicData?: { [key: string]: string; }; } interface WitnessData { id: string; url: string; } interface ProviderClaimData { provider: string; parameters: string; owner: string; timestampS: number; context: string; identifier: string; epoch: number; } interface Context { contextAddress: string; contextMessage: string; } interface Beacon { getState(epoch?: number): Promise<BeaconState>; close?(): Promise<void>; } type BeaconState = { witnesses: WitnessData[]; epoch: number; witnessesRequiredForClaim: number; nextEpochTimestampS: number; }; type StartSessionParams = { onSuccess: OnSuccess; onError: OnError; }; type OnSuccess = (proof?: Proof | Proof[] | string) => void; type OnError = (error: Error) => void; type ProofRequestOptions = { log?: boolean; acceptAiProviders?: boolean; useAppClip?: boolean; device?: string; envUrl?: string; }; declare function verifyProof(proofOrProofs: Proof | Proof[]): Promise<boolean>; declare function transformForOnchain(proof: Proof): { claimInfo: any; signedClaim: any; }; declare class ReclaimProofRequest { private applicationId; private signature?; private appCallbackUrl?; private sessionId; private options?; private context; private providerId; private parameters; private redirectUrl?; private intervals; private timeStamp; private sdkVersion; private jsonProofResponse; private lastFailureTime?; private readonly FAILURE_TIMEOUT; private constructor(); static init(applicationId: string, appSecret: string, providerId: string, options?: ProofRequestOptions): Promise<ReclaimProofRequest>; static fromJsonString(jsonString: string): Promise<ReclaimProofRequest>; setAppCallbackUrl(url: string, jsonProofResponse?: boolean): void; setRedirectUrl(url: string): void; addContext(address: string, message: string): void; setParams(params: { [key: string]: string; }): void; getAppCallbackUrl(): string; getStatusUrl(): string; private setSignature; private generateSignature; private clearInterval; toJsonString(options?: ProofRequestOptions): string; getRequestUrl(): Promise<string>; startSession({ onSuccess, onError }: StartSessionParams): Promise<void>; } export { type Beacon, type BeaconState, type Context, type Proof, type ProviderClaimData, ReclaimProofRequest, type WitnessData, transformForOnchain, verifyProof };