react-native-persona
Version:
Launch a mobile native implementation of the Persona inquiry flow from React Native.
230 lines (229 loc) • 8.77 kB
TypeScript
import { Fields } from './fields';
import PersonaInquiryView from './PersonaInquiryView';
import { Versions } from './versions';
import type { CollectedData, ExtraData, OnCanceledCallback, OnCompleteCallback, OnErrorCallback, OnEventCallback } from './callbacks';
import { StepData, Document, UiStepData, SelfieCaptureMethod, SelfieCapture, SelfieStepData, GovernmentIdCaptureFrames, GovernmentIdCaptureSide, GovernmentIdCaptureMethod, GovernmentIdCapture, GovernmentIdStepData, DocumentStepData } from './StepData';
export { Fields };
export { PersonaInquiryView };
export { Versions };
export { CollectedData, ExtraData, OnCanceledCallback, OnCompleteCallback, OnErrorCallback, OnEventCallback, };
export { StepData, Document, UiStepData, SelfieCaptureMethod, SelfieCapture, SelfieStepData, GovernmentIdCaptureFrames, GovernmentIdCaptureSide, GovernmentIdCaptureMethod, GovernmentIdCapture, GovernmentIdStepData, DocumentStepData, };
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;
disablePresentationAnimation?: boolean;
fields?: Fields;
onComplete?: OnCompleteCallback;
onCanceled?: OnCanceledCallback;
onError?: OnErrorCallback;
iosThemeObject?: Object | null;
themeSource?: ThemeSource | null;
}
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;
disablePresentationAnimation?: Boolean;
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;
static onEvent(callback: OnEventCallback): void;
toOptionsJson(): {
templateId: TemplateId | undefined;
templateVersion: TemplateVersion | undefined;
inquiryId: InquiryId | undefined;
referenceId: string | undefined;
accountId: AccountId | undefined;
environment: Environment | undefined;
environmentId: string | undefined;
themeSetId: string | undefined;
sessionToken: string | undefined;
fields: Fields | null | undefined;
returnCollectedData: boolean | undefined;
themeSource: ThemeSource | null | undefined;
iosTheme: {
[key: string]: string;
};
locale: String | undefined;
disablePresentationAnimation: Boolean | undefined;
};
/**
* 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?;
private _disablePresentationAnimation?;
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;
disablePresentationAnimation(disablePresentationAnimation: boolean): 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 _disablePresentationAnimation?;
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;
disablePresentationAnimation(disablePresentationAnimation: boolean): 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;