UNPKG

onfido-sdk-ui

Version:

JavaScript SDK view layer for Onfido identity verification

264 lines (263 loc) 7.71 kB
import type { CrossDeviceMethod } from './CrossDeviceConnect.types'; import type { FeatureFlags } from './FeatureFlags'; export type ModuleError = { type: 'no_camera'; message?: string; }; export type ModuleFinish = { type: 'finish'; output: Output; options?: ModuleFinishOptions; }; export type ModuleUnsupported = { type: 'unsupported'; data?: unknown; }; export type Outputs = ModuleFinish | ModuleUnsupported; export type Output = object | object[]; export type ModuleFinishOptions = { complete?: boolean; }; export type ExecutorMethod = 'bootstrap' | 'ping' | 'start'; export type CrossDeviceExecutorMethod = 'crossDevice.update' | 'crossDevice.abort'; export type RunnerMethod = 'captureModule.finish' | 'captureModule.error' | 'captureModule.unsupported' | 'crossDevice.start' | 'crossDevice.preload' | 'crossDevice.verify' | 'crossDevice.abort' | 'crossDevice.regenerate' | 'analytics.send' | 'analyticsV2.send' | 'analytics.userAnalytics' | 'navigation.back' | 'navigation.exit' | 'navigation.externalLink' | 'navigation.closeExternalLink' | 'customCallback.invoke' | 'passkey.create' | 'passkey.get' | 'crossDevice.browserReload'; export type Configuration<T = unknown> = { translations?: T; theme?: Theme; language?: string; workflowRunId?: string; }; export type Input = Record<string, unknown>; export type Empty = Record<string, never>; export type LocaleDirection = 'ltr' | 'rtl'; export type TranslationData<T> = T & { meta?: { legacy: Record<string, unknown>; fallback?: Record<string, unknown>; direction?: LocaleDirection; convertLegacyTranslations?: boolean; }; }; export type TranslationItem<T> = T | (() => Promise<T>); export type Translations<T = unknown> = Record<string, TranslationItem<T>>; export type ThemeConfig = Record<string, any>; export type Theme = { name: 'light' | 'dark'; config?: ThemeConfig; }; export type Optional<T> = undefined | T; export type RecursivePartial<T> = { [P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object | undefined ? RecursivePartial<T[P]> : T[P]; }; export declare enum Platform { WEB = "web", IOS = "ios", ANDROID = "android" } type ExecutionContextConfiguration = { crossDevicePolicy?: CrossDevicePolicy; supportsCrossDevice?: boolean; supportsBack?: boolean; supportsExit?: boolean; supportsExternalLink?: boolean; globalKit?: boolean; }; export type CustomCallbacks = { names: string[]; }; export type Permission = { alwaysRequestPermissions?: boolean; }; export type ExecutionContext = { platform: Platform; version: string; module?: CaptureModule; os?: { name?: string; version?: string; }; configuration?: ExecutionContextConfiguration; permission?: Permission; customCallbacks?: CustomCallbacks; currentScriptHostname?: string; }; export type UserDetails = { smsNumber?: string; }; export type ClientConfiguration = { token: string; sdkToken: SdkToken; featureFlags: FeatureFlags & Partial<Record<string, unknown>>; theme?: Theme; language?: string; translations?: Translations; analytics?: { enabled: boolean; anonymousUuid: string; sessionUuid: string; workflowRunId: string | undefined; steps: LegacyStepDefinition[]; referrer?: string; domain?: string; }; source: { platform: string; version: string; sdk_environment: string; distribution_source: string; pinned_version?: string; }; logger: { enabled: boolean; levels: string[]; }; crossDevice?: { verification?: boolean; confirmation?: boolean; desktopInfo: TrackedEnvironmentData; linkMethods: CrossDeviceMethod[]; }; enterpriseFeatures?: EnterpriseFeatures; crossDeviceClientIntroProductName?: string; crossDeviceClientIntroProductLogoSrc?: string; smsNumberCountryCode?: string; userDetails?: UserDetails; }; export type SdkToken = { exp: number; sub?: UUID; payload: Payload; enterpriseFeatures?: TokenEnterpriseFeatures; urls: { detectDocumentUrl: URL; /** * @deprecated */ syncUrl: URL; hostedSdkUrl: URL; authUrl: URL; onfidoApiUrl: URL; telephonyUrl: URL; crossDeviceUrl?: URL; }; type: 'studio' | 'sdk'; }; export type UUID = string; export type URL = string; export type Payload = { applicantUuid: UUID; applicationId?: string; clientUuid: UUID; isSandbox: boolean; isTrial: boolean; }; export type EnterpriseFeatures = { hideOnfidoLogo?: boolean; cobrand?: { text?: string; }; logoCobrand?: { lightLogoSrc?: string; darkLogoSrc?: string; }; }; type TokenEnterpriseFeatures = { cobrand: boolean; logoCobrand: boolean; hideOnfidoLogo: boolean; useCustomizedApiRequests: boolean; }; export type JWT = { iss?: string; exp: number; payload: { app: UUID; application_id?: string; client_uuid: UUID; is_sandbox: boolean; is_trial: boolean; ref: string; sardine_session: UUID; }; enterprise_features: TokenEnterpriseFeatures; urls: { detect_document_url: URL; sync_url: URL; hosted_sdk_url: URL; auth_url: URL; onfido_api_url: URL; telephony_url: URL; cross_device_url?: URL; }; }; export type TrackedEventTypes = 'screen' | 'action' | 'flow' | 'view'; export type AnalyticsEvent = { eventName: string; eventType: TrackedEventTypes; }; export type UserAnalyticsEvent<N extends string = string, P extends Record<string, unknown> = Record<string, unknown>> = { eventName: N; properties: P; }; export type DeviceTypes = 'desktop' | 'mobile'; export type TrackedEnvironmentData = { device?: DeviceTypes; os?: string; os_version?: string; browser?: string; browser_version?: string; brand?: string; model?: string; }; export declare enum CrossDeviceVerificationStatus { VALID = "VALID", INVALID = "INVALID", PENDING = "PENDING", ABORT = "ABORT" } export type CrossDeviceInitialState = unknown; export type ConnectResult = { roomId: string; }; export type CrossDeviceDetails = ConnectResult & { connected: boolean; link: string; code?: string; verificationStatus?: CrossDeviceVerificationStatus; }; export type CrossDeviceInput = { backActionType?: 'module' | 'cross-module'; details: CrossDeviceDetails; }; export declare enum CaptureModuleType { HOSTED = "hosted", EXTERNAL = "external" } export type ModuleType<T extends CaptureModuleType> = { type: T; }; export type HostedModule = { version?: string; module: string; } & ModuleType<CaptureModuleType.HOSTED>; export type ExternalModule = { url: string; } & ModuleType<CaptureModuleType.EXTERNAL>; export type CaptureModule = HostedModule | ExternalModule; export type CrossDevicePolicy = 'enable' | 'force' | 'disable'; export type LegacyStepType = 'welcome' | 'complete' | 'face' | 'consent' | 'document' | 'poa'; export type LegacyStepDefinition = LegacyStepType | StepDefinition; export type StepDefinition = { type: LegacyStepType | string; options?: Record<string, unknown>; module?: CaptureModule; /** * the key used to serialize the output for onComplete */ key?: string; }; export type ExternalLinkTarget = 'overlay' | 'browser'; export type ExternalLinkHandle = { window?: Window; }; export {};