UNPKG

react-native-persona

Version:

Launch a mobile native implementation of the Persona inquiry flow from React Native.

263 lines (262 loc) 8.61 kB
import { Fields } from './fields'; export { Fields }; import { Versions } from './versions'; export { Versions }; declare const Unique: unique symbol; export type Opaque<T, Tag> = T & { [Unique]: Tag; }; type TemplateId = Opaque<string, 'TemplateId'>; type TemplateVersion = Opaque<string, 'TemplateVersion'>; type InquiryId = Opaque<string, 'InquiryId'>; type AccountId = Opaque<string, 'AccountId'>; export declare class InvalidTemplateId extends Error { } export declare class InvalidTemplateVersion extends Error { } export declare class InvalidInquiryId extends Error { } export declare class InvalidAccountId extends Error { } /** * String enum for environments. These strings will be parsed * on the native side bridge into Kotlin / Swift enums. */ export declare enum Environment { SANDBOX = "sandbox", PRODUCTION = "production" } /** * An enum value which determines whether this sdk should use the theme values sent from the server. */ export declare enum ThemeSource { SERVER = "server", /** * @deprecated Client side theming is deprecated, please configure your theme inside * the Persona Dashboard and use SERVER as the theme source. */ CLIENT = "client" } export interface InquiryOptions { templateId?: TemplateId; templateVersion?: TemplateVersion; inquiryId?: InquiryId; referenceId?: string; accountId?: AccountId; environment?: Environment; environmentId?: string; themeSetId?: string; sessionToken?: string; returnCollectedData?: boolean; locale?: String; fields?: Fields; onComplete?: OnCompleteCallback; onCanceled?: OnCanceledCallback; onError?: OnErrorCallback; iosThemeObject?: Object | null; themeSource?: ThemeSource | null; } type OnCompleteCallback = (inquiryId: string, status: string, fields: Fields, extraData: ExtraData) => void; export interface ExtraData { collectedData: CollectedData | null; } export interface CollectedData { stepData: StepData[]; } export interface StepData { stepName: string; } export declare class DocumentStepData implements StepData { stepName: string; documents: Document[]; constructor(); } export interface Document { absoluteFilePath: string; } export declare class GovernmentIdStepData implements StepData { stepName: string; captures: GovernmentIdCapture[]; constructor(); } export interface GovernmentIdCapture { idClass: string; captureMethod: GovernmentIdCaptureMethod; side: GovernmentIdCaptureSide; frames: GovernmentIdCaptureFrames[]; } export declare enum GovernmentIdCaptureMethod { Manual = "Manual", Auto = "Auto", Upload = "Upload" } export declare enum GovernmentIdCaptureSide { Front = "Front", Back = "Back" } export interface GovernmentIdCaptureFrames { absoluteFilePath: string; } export declare class SelfieStepData implements StepData { stepName: string; centerCapture: SelfieCapture | null; leftCapture: SelfieCapture | null; rightCapture: SelfieCapture | null; constructor(); } export interface SelfieCapture { captureMethod: SelfieCaptureMethod; absoluteFilePath: string; } export declare enum SelfieCaptureMethod { Manual = "Manual", Auto = "Auto" } export declare class UiStepData implements StepData { stepName: string; componentParams: { [key: string]: any; }; constructor(); } type OnCanceledCallback = (inquiryId?: string, sessionToken?: string) => void; type OnErrorCallback = (error: Error, errorCode?: string) => void; export declare class Inquiry { templateId?: TemplateId; templateVersion?: TemplateVersion; inquiryId?: InquiryId; referenceId?: string; accountId?: AccountId; environment?: Environment; environmentId?: string; themeSetId?: string; sessionToken?: string; returnCollectedData?: boolean; locale?: String; iosThemeObject?: Object | null; themeSource?: ThemeSource | null; fields?: Fields | null; private readonly onComplete?; private readonly onCanceled?; private readonly onError?; private onCompleteListener?; private onCanceledListener?; private onErrorListener?; constructor(options: InquiryOptions); private clearListeners; /** * Create an Inquiry flow builder based on a template ID. * * You can find your template ID on the Dashboard under Inquiries > Templates. * {@link https://app.withpersona.com/dashboard/inquiry-templates} * * @param templateId template ID from your Persona Dashboard * @return builder for the Inquiry flow */ static fromTemplate(templateId: string): TemplateBuilder; /** * Create an Inquiry flow builder based on a template ID version. * * You can find your template ID version on the Dashboard under the * settings view of a specific template. * {@link https://app.withpersona.com/dashboard/inquiry-templates} * * @param templateVersion template version from your Persona Dashboard * @return builder for the Inquiry flow */ static fromTemplateVersion(templateVersion: string): TemplateBuilder; /** * Create an Inquiry flow builder based on an inquiry ID. * * You will need to generate the inquiry ID on the server. To try it out, you can create an * inquiry from the Persona Dashboard under "Inquiries". Click on the "Create Inquiry" button * and copy the inquiry ID from the URL. * {@link https://app.withpersona.com/dashboard/inquiries} * * @param inquiryId inquiry ID from your server * @return builder for the Inquiry flow */ static fromInquiry(inquiryId: string): InquiryBuilder; /** * Launch the Persona Inquiry. */ start(): void; } declare class InquiryBuilder { private _inquiryId; private _sessionToken?; private _onComplete?; private _onCanceled?; private _onError?; private _iosThemeObject?; private _themeSource; private _fields?; private _locale?; constructor(inquiryId: InquiryId); sessionToken(sessionToken: string): InquiryBuilder; onComplete(callback: OnCompleteCallback): InquiryBuilder; onCanceled(callback: OnCanceledCallback): InquiryBuilder; onError(callback: OnErrorCallback): InquiryBuilder; /** * @deprecated Use iosThemeToUse */ iosTheme(themeObject: Object): InquiryBuilder; iosThemeToUse(themeObject: Object, themeSource: ThemeSource): InquiryBuilder; locale(locale: string): InquiryBuilder; build(): Inquiry; } declare class TemplateBuilder { private readonly _templateId?; private readonly _templateVersion?; private _accountId?; private _referenceId?; private _environment?; private _environmentId?; private _themeSetId?; private _fields?; private _sessionToken?; private _returnCollectedData?; private _locale?; private _onComplete?; private _onCanceled?; private _onError?; private _iosThemeObject?; private _themeSource; constructor(templateId?: TemplateId | null, templateVersion?: TemplateVersion | null); returnCollectedData(returnCollectedData: boolean): this; referenceId(referenceId: string): TemplateBuilder; accountId(accountId: string): TemplateBuilder; environment(environment: Environment): TemplateBuilder; environmentId(environmentId: string): TemplateBuilder; themeSetId(themeSetId: string): TemplateBuilder; sessionToken(sessionToken: string): TemplateBuilder; fields(fields: Fields): TemplateBuilder; locale(locale: string): TemplateBuilder; onComplete(callback: OnCompleteCallback): TemplateBuilder; onCanceled(callback: OnCanceledCallback): TemplateBuilder; onError(callback: OnErrorCallback): TemplateBuilder; /** * @deprecated Use iosThemeToUse */ iosTheme(themeObject: Object): TemplateBuilder; iosThemeToUse(themeObject: Object, themeSource: ThemeSource): TemplateBuilder; build(): Inquiry; } /** * @deprecated Use the `Inquiry` static methods instead */ declare namespace InquiryBuilders { /** * @deprecated Use {@link Inquiry#fromInquiry} instead */ function fromInquiry(inquiryId: string): InquiryBuilder; /** * @deprecated Use {@link Inquiry#fromTemplate} instead */ function fromTemplate(templateId: string): TemplateBuilder; /** * @deprecated Use {@link Inquiry#fromTemplateVersion} instead */ function fromTemplateVersion(templateVersion: string): TemplateBuilder; } export default InquiryBuilders;