@udene/react-native-sdk
Version:
Udene Fraud Detection SDK for React Native
188 lines (187 loc) • 4.21 kB
TypeScript
/**
* Configuration options for the UdeneClient
*/
export interface UdeneClientConfig {
/**
* Your Udene API key (required)
*/
apiKey: string;
/**
* Custom API base URL (optional)
* @default "https://api.udene.net/v1"
*/
baseURL?: string;
/**
* Device platform (optional, auto-detected if not provided)
* @default auto-detected from React Native
*/
platform?: string;
/**
* Maximum number of retries for failed requests
* @default 3
*/
maxRetries?: number;
/**
* Disable logging of API requests and responses
* @default false
*/
disableLogging?: boolean;
/**
* Custom logger function
* @default console.warn
*/
logger?: (message: string, error?: any) => void;
}
/**
* Interaction data for tracking user behaviors
*/
export interface InteractionData {
/**
* User identifier
*/
userId?: string;
/**
* Type of action performed
*/
action: string;
/**
* Additional data about the interaction
*/
metadata?: Record<string, any>;
}
/**
* Transaction data for fraud analysis
*/
export interface TransactionData {
/**
* Unique transaction identifier
*/
transactionId: string;
/**
* User identifier
*/
userId: string;
/**
* Transaction amount
*/
amount: number;
/**
* Currency code (e.g., 'USD')
*/
currency: string;
/**
* Payment method used
*/
paymentMethod: string;
/**
* Transaction timestamp
*/
timestamp: string;
/**
* Additional transaction metadata
*/
metadata?: {
productIds?: string[];
shippingAddress?: string;
billingAddress?: string;
isRecurring?: boolean;
[key: string]: any;
};
}
/**
* Email data for BEC analysis
*/
export interface EmailData {
/**
* Email sender address
*/
sender: string;
/**
* Email subject
*/
subject: string;
/**
* Email body content
*/
body: string;
/**
* Email recipient(s)
*/
recipients: string[];
/**
* Additional email metadata
*/
metadata?: Record<string, any>;
}
/**
* Main client for Udene fraud detection services
*/
export declare class UdeneClient {
private client;
private platform;
private maxRetries;
private logger;
private disableLogging;
private readonly SDK_VERSION;
private readonly STORAGE_KEY;
/**
* Creates a new UdeneClient instance
*
* @param config - Configuration options or API key string
*/
constructor(configOrApiKey: UdeneClientConfig | string);
/**
* Sanitize data by removing sensitive fields and validating inputs
*
* @param data - Data to sanitize
* @returns Sanitized data
* @private
*/
private sanitizeData;
/**
* Get fraud metrics
*
* @returns Promise with metrics data
*/
getMetrics(): Promise<any>;
/**
* Analyze email for Business Email Compromise (BEC) threats
*
* @param emailData - Email data to analyze
* @returns Promise with analysis results
*/
analyzeBEC(emailData: EmailData): Promise<any>;
/**
* Track user interaction for fraud analysis
*
* @param data - Interaction data to track
* @returns Promise with tracking results
*/
trackInteraction(data: InteractionData): Promise<any>;
/**
* Get user activity data
*
* @returns Promise with activity data
*/
getActivity(): Promise<any>;
/**
* Analyze a transaction for fraud detection
*
* @param transactionData - Transaction data to analyze
* @returns Promise with analysis results including recommendation
*/
analyzeTransaction(transactionData: TransactionData): Promise<any>;
/**
* Get device fingerprint information
*
* @returns Promise with device fingerprint data
*/
getDeviceFingerprint(): Promise<any>;
/**
* Handle API errors
*
* @param error - Error object from API request
* @private
*/
private handleError;
}