@dodgeball/trust-sdk-client
Version:
Dodgeball Client SDK
180 lines (179 loc) • 5.13 kB
TypeScript
import { LogLevel } from "./logger";
export declare enum DodgeballApiVersion {
v1 = "v1"
}
export declare enum VerificationStatus {
PENDING = "PENDING",
BLOCKED = "BLOCKED",
COMPLETE = "COMPLETE",
FAILED = "FAILED"
}
export declare enum VerificationOutcome {
APPROVED = "APPROVED",
DENIED = "DENIED",
PENDING = "PENDING",
ERROR = "ERROR"
}
export interface IVerification {
id: string;
status: VerificationStatus;
outcome: VerificationOutcome;
stepData: IVerificationStepData;
nextSteps: IVerificationStep[];
error?: string;
}
export declare enum VerificationErrorType {
SYSTEM = "SYSTEM",
TIMEOUT = "TIMEOUT",
CANCELLED = "CANCELLED"
}
export interface IVerificationError {
errorType: VerificationErrorType;
details?: string;
}
export declare const systemError: (errorText?: string | undefined) => {
errorType: VerificationErrorType;
details: string | undefined;
};
export declare const cancelError: () => {
errorType: VerificationErrorType;
details: string;
};
export interface IVerificationContext {
onVerified: (verification: IVerification) => Promise<void>;
onApproved: (verification: IVerification) => Promise<void>;
onDenied?: (verification: IVerification) => Promise<void>;
onPending?: (verification: IVerification) => Promise<void>;
onBlocked?: (verification: IVerification) => Promise<void>;
onUndecided?: (verification: IVerification) => Promise<void>;
onError?: (error: IVerificationError) => Promise<void>;
}
export interface ILibConfig {
name: string;
url: string;
config: any;
method?: string;
content?: {
url?: string;
text?: string;
};
loadTimeout?: number;
}
export interface IVerificationStep extends ILibConfig {
id: string;
verificationStepId: string;
}
export interface IVerificationStepData {
customMessage?: string;
}
export interface IStepResponse {
pluginName: string;
methodName: string;
data?: any;
}
export interface IInitConfig {
requestId: string;
libs: ILibConfig[];
requireSrc?: string;
}
export interface IFingerprint {
source: string;
props: {
[key: string]: any;
};
hash?: string;
error?: string;
}
export declare enum IntegrationPurpose {
IDENTIFY = "IDENTIFY",
OBSERVE = "OBSERVE",
QUALIFY = "QUALIFY",
EXECUTE = "EXECUTE"
}
export interface IIntegrationConfig {
[key: string]: any;
}
export interface IReconfigureIntegrationProps {
config: IIntegrationConfig;
url: string;
purposes?: IntegrationPurpose[];
requestId: string;
}
export interface IIntegrationProps {
config: IIntegrationConfig;
url: string;
name: string;
purposes: IntegrationPurpose[];
requestId: string;
}
export interface IIdentifierIntegration {
identify(): Promise<IFingerprint>;
getMetadata(): Promise<{
name: string;
metadata: any;
}>;
}
interface IObserveParams {
sessionId: string;
userId?: string;
sourceToken?: string;
}
export interface IObserverIntegration {
observe(params: IObserveParams): void;
}
export interface IExecutionIntegration {
execute(step: IVerificationStep, context: IVerificationContext, responseCallback: (stepResponse: IStepResponse) => Promise<void>, onCancel: () => Promise<void>): Promise<any>;
cleanup(): Promise<void>;
}
export interface IQualifierIntegration {
qualify(context: IVerificationContext): Promise<any>;
}
export interface IDodgeballApiError {
code: number;
message: string;
}
export interface IDodgeballTrackResponse {
success: boolean;
errors: IDodgeballApiError[];
version: DodgeballApiVersion;
}
export interface IDodgeballVerifyResponse {
success: boolean;
errors: IDodgeballApiError[];
version: DodgeballApiVersion;
verification: IVerification;
}
export interface IDodgeballConfig {
apiVersion: DodgeballApiVersion;
apiUrl?: string;
logLevel?: LogLevel;
disableCookies?: boolean;
sessionId?: string;
userId?: string;
isEnabled?: boolean;
enableCrossDomainSession?: boolean;
integrationTimeout?: number;
}
export interface IDodgeballParentContext {
publicKey: string;
config: IDodgeballConfig;
clearScreen: () => void;
}
export interface IHandleVerificationOptions {
maxDuration: number;
}
export interface IVerificationInvocationOptions extends IHandleVerificationOptions {
pollingInterval: number;
numAtInitialPollingInterval: number;
maxPollingInterval: number;
}
export declare class DodgeballMissingConfigError extends Error {
constructor(configName: string, value: any);
}
export declare class DodgeballInvalidConfigError extends Error {
constructor(configName: string, value: any, allowedValues: any[]);
}
export declare class DodgeballMissingParameterError extends Error {
constructor(parameter: string, value: any);
}
export {};