@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
126 lines (125 loc) • 3.89 kB
TypeScript
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';
import type { Region } from '@fingerprintjs/fingerprintjs-pro';
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;
/**
* Disables automatic error reporting to Sumsub backend.
*
* We strongly recommend keeping error logging enabled.
* Disabling error logging may make it harder to investigate and support in case of any issues.
*/
disabledErrorLogging?: boolean;
}
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;
deviceBindingId?: string;
}
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'none';
export interface FpKeyResponse {
fpKey?: string;
simulation?: FpSimulation;
evRelUrl?: string;
fpUrl?: string;
fpReqRelUrl?: string;
bhvEnabled?: boolean;
logEnabled?: boolean;
logLevel?: LogLevel;
cacheTtlSeconds?: number;
fpRegion?: Region;
fpWorkerUrl?: string;
fpWorkerScript?: string;
}
export interface FpRequestPayload {
fpRequestId?: string;
fpSimulation?: FpSimulation;
deviceBindingId?: string;
}
export type FingerprintResponse = {
visitorId?: string;
};
export type Fisherman = {
isDeviceIntelligenceEnabled: boolean;
fingerprint: (options?: FingerprintOptions) => Promise<FingerprintResponse>;
};
export {};