@plutoxyz/frame-js
Version:
SDK for integrating with Pluto Frame
88 lines (87 loc) • 2.06 kB
TypeScript
/**
* Options for initializing the SDK in the parent application
*/
export type InitializationOptions = {
/**
* Whether to use a popup window for OAuth flows instead of redirecting the entire page
* @default true
*/
preferOauthPopup?: boolean;
/**
* The brand to use for the frame
*/
brand: Brand;
/**
* The endpoints to use for the frame
*/
endpoints?: Endpoints;
/**
* Optional pixel key – when present the SDK will
* collect a browser fingerprint and forward it to /metadata.
*/
pixelKey?: string;
};
export type Brand = {
logo: string;
name: string;
};
export type Endpoints = {
frame?: string;
notary?: string;
socket?: string;
};
/**
* Event handlers for the parent application
*/
export type PageHooks = {
/**
* Called when the automation script logs a message
* @param log The log message from the automation script
*/
onScriptLog?: (log: string) => void;
/**
* Called when the proof generation is successful
* @param data The proof payload containing data and signature
*/
onSuccess?: (data: ProofPayload) => void;
/**
* Called when an error occurs
* @param error The error payload
*/
onError?: (error: ErrorPayload) => void;
/**
* Called when the cdp url is available
* @param url The cdp url
*/
onCdpUrl?: (url: string) => void;
};
/**
* Structure of error payloads returned by the SDK
*/
export type ErrorPayload = {
/**
* Error code for programmatic handling
*/
code: string;
/**
* User-friendly error message suitable for displaying to end users
*/
display_message: string;
/**
* Error message for debugging
*/
message: string;
};
/**
* Structure of successful proof results
*/
export type ProofPayload = {
/**
* Retrieved data from the automation script
*/
data: Record<string, string>;
/**
* The cryptographic signature
*/
signature: string;
};