UNPKG

@sumsub/fisherman

Version:

The Sumsub Fisherman is a powerful tool that helps developers integrate fraud detection capabilities into their applications. With Fisherman, you can easily identify and prevent fraudulent activities within your system, providing a safer and more secure e

110 lines (109 loc) 3.28 kB
import type { Battery } from './device/battery'; import type { Geolocation } from './device/geolocation'; import type { OrientationInit, OrientationInteraction } from './device/orientation'; import type { ErrorHandlerFn } from './errors'; import type { FingerprintComponent } from './init/types'; import type { MediaDevice } from './device/mediaDevices'; export interface BehavioralMetadataEvent { id: string; predecessorEventId?: string; deviceSessionId?: string; fpRequestId?: string; initData?: InitData; interactionData?: InteractionData; simulation?: FpSimulation; } export interface FishermanData { capturedAt?: string; } export type ReportData = InitData | InteractionData; export interface InitData extends FishermanData, FingerprintComponent { deviceFingerprint?: string; width?: number; height?: number; availableWidth?: number; availableHeight?: number; browser?: string; incognito?: boolean; mobile?: boolean; languages?: string[]; geolocation?: Geolocation; battery?: Battery; mediaDevices?: MediaDevice[]; orientation?: OrientationInit; oscpu?: string; productSub?: string; evalLength?: number; errFirefox?: boolean; } export interface TypingInfo { start: number; end: number; key?: string; } export interface InteractionData extends FishermanData { event: InteractionDataEvent; count?: number; el?: string; elUid?: string; trusted?: boolean; cadence?: TypingInfo[]; orientation?: OrientationInteraction; } type UpdateAccessTokenHandlerFn = () => Promise<string | undefined>; export interface InitParams { /** * Access token, generated on sumsub.com, and received from your backend */ token: string; baseUrl?: string; /** * Function to automatically refresh the access token * when a `401 Unauthorized` error is received from the server. * * This function should return a Promise that resolves to the new access token. * If it resolves to `undefined` or rejects, token will be removed * and the original request will not be retried. */ accessTokenUpdateHandler?: UpdateAccessTokenHandlerFn; /** * Error callback * @param FishermanError error */ onError?: ErrorHandlerFn; simulationConfig?: FpSimulationConf; } export type InteractionDataEvent = 'paste' | 'focusin' | 'change' | 'mousemove' | 'mousedown' | 'orientation' | 'focus' | 'urlchanged'; export interface FpSimulation { enabled: boolean; conf?: FpSimulationConf; } export type FpSimulationConf = { visitorId?: string; requestId?: string; riskLabels?: string[]; }; export interface FingerprintOptions { linkedId?: string; } export interface FpKeyResponse { fpKey?: string; simulation?: FpSimulation; evRelUrl?: string; fpUrl?: string; fpReqRelUrl?: string; bhvEnabled?: boolean; } export interface FpRequestPayload { fpRequestId?: string; fpVisitorId?: string; fpSimulation?: FpSimulation; } export type FingerprintResponse = { visitorId?: string; }; export type Fisherman = { isDeviceIntelligenceEnabled: boolean; fingerprint: (options?: FingerprintOptions) => Promise<FingerprintResponse>; }; export {};