@upbudget/belvo-js
Version:
React component for Belvo
71 lines (68 loc) • 2.33 kB
TypeScript
import { ReactNode } from 'react';
interface AnalyticsAdapter {
track(event: string, properties?: Record<string, unknown>): void;
identify?(userId: string, traits?: Record<string, unknown>): void;
}
declare const BelvoEvents: {
readonly WIDGET_OPENED: "belvo_widget_opened";
readonly CONNECTION_SUCCESS: "belvo_connection_success";
readonly CONNECTION_EXIT: "belvo_connection_exit";
readonly WIDGET_EVENT: "belvo_widget_event";
readonly SCRIPT_LOADED: "belvo_script_loaded";
readonly SCRIPT_ERROR: "belvo_script_error";
readonly TOKEN_FETCH_START: "belvo_token_fetch_start";
readonly TOKEN_FETCH_SUCCESS: "belvo_token_fetch_success";
readonly TOKEN_FETCH_ERROR: "belvo_token_fetch_error";
};
type BelvoEventName = (typeof BelvoEvents)[keyof typeof BelvoEvents];
interface AccessTokenResponse {
access: string;
refresh: string;
}
type GetAccessTokenFn = () => Promise<AccessTokenResponse>;
interface BelvoWidgetCallbacks {
onSuccess?(link: string, institution: string): void;
onExit?(data: unknown): void;
onEvent?(data: unknown): void;
}
interface BelvoWidgetProviderProps {
children: ReactNode;
getAccessToken: GetAccessTokenFn;
analytics?: AnalyticsAdapter;
}
interface BelvoWidgetProps extends BelvoWidgetCallbacks {
locale?: 'pt' | 'en';
integration_type?: 'openfinance';
external_id?: string;
refresh_rate?: '6h' | '12h' | '24h';
mode?: 'webapp' | 'single';
brand?: {
logoUrl?: string;
primaryColor?: string;
};
}
interface BelvoWidgetConfig {
locale?: string;
mode?: string;
integration_type?: string;
external_id?: string;
refresh_rate?: string;
brand?: {
logoUrl?: string;
primaryColor?: string;
};
callback?(link: string, institution: string): void;
onExit?(data: unknown): void;
onEvent?(data: unknown): void;
}
interface BelvoSDK {
createWidget(access: string, config: BelvoWidgetConfig): {
build(): void;
};
}
declare global {
interface Window {
belvoSDK?: BelvoSDK;
}
}
export { type AccessTokenResponse, type AnalyticsAdapter, type BelvoEventName, BelvoEvents, type BelvoSDK, type BelvoWidgetCallbacks, type BelvoWidgetConfig, type BelvoWidgetProps, type BelvoWidgetProviderProps, type GetAccessTokenFn };