trustlabs-sdk
Version:
Easy-to-use SDK for displaying trust verification badges on websites. Supports React, Vue, vanilla JS, and CDN usage.
66 lines (65 loc) • 2.06 kB
TypeScript
import { type TrustStatus } from './getTrustStatus';
import { type TrustStatusProxy } from './proxy';
import { type RenderTrustBadgeOptions } from './renderTrustBadge';
export interface TrustLabsConfig {
/** Your server endpoint that handles trust status requests */
endpoint?: string;
/** Custom proxy function for handling API requests */
proxy?: TrustStatusProxy;
/** API key (only for server-side usage) */
apiKey?: string;
/** Auto-inject styles into the page */
autoInjectStyles?: boolean;
/** Default options for all badge renders */
defaultOptions?: Partial<RenderTrustBadgeOptions>;
}
/**
* Main TrustLabs SDK class providing a simplified API for third-party developers
*/
export declare class TrustLabsSDK {
private config;
private initialized;
/**
* Initialize the SDK with configuration
*/
init(config: TrustLabsConfig): void;
/**
* Check if SDK is initialized
*/
isInitialized(): boolean;
/**
* Get trust status for emails
*/
getTrustStatus(emails: string[]): Promise<TrustStatus[]>;
/**
* Render trust badge with existing data
*/
renderBadge(options: RenderTrustBadgeOptions): void;
/**
* Render trust badge with automatic data fetching
*/
renderBadgeWithFetch(options: {
targetEl: HTMLElement;
emails: string[];
}): Promise<void>;
/**
* Auto-detect and render badges for all email addresses on the page
*/
autoRender(selector?: string): Promise<void>;
/**
* Utility to validate email format
*/
private isValidEmail;
/**
* Update configuration after initialization
*/
configure(config: Partial<TrustLabsConfig>): void;
/**
* Get current configuration
*/
getConfig(): TrustLabsConfig;
}
export declare const trustLabsSDK: TrustLabsSDK;
export declare const init: (config: TrustLabsConfig) => void;
export declare const isInitialized: () => boolean;
export declare const autoRender: (selector?: string) => Promise<void>;