import type { Properties } from 'csstype'; export type FieldType = 'boolean' | 'choices' | 'date' | 'datetime' | 'integer' | 'json' | 'multi_choices' | 'number' | 'string' | 'generic' | 'mobile_drivers_license' | 'nfc_passport' | 'government_id' | 'selfie'; export type FieldValue = string | string[] | boolean | number | { id: string; type: string; } | JSON | Field[] | { [key: string]: Field; }; interface FieldBase { type: FieldType; value: FieldValue; } export interface FieldBoolean extends FieldBase { type: 'boolean'; value: boolean; } export interface FieldChoices extends FieldBase { type: 'choices'; value: string; } export interface FieldDate extends FieldBase { type: 'date'; value: string; } export interface FieldDatetime extends FieldBase { type: 'datetime'; value: string; } export interface FieldInteger extends FieldBase { type: 'integer'; value: number; } export interface FieldJson extends FieldBase { type: 'json'; value: JSON; } export interface FieldMultiChoices extends FieldBase { type: 'multi_choices'; value: string[]; } export interface FieldNumber extends FieldBase { type: 'number'; value: number; } export interface FieldString extends FieldBase { type: 'string'; value: string; } export interface FieldDocumentGeneric extends FieldBase { type: 'generic'; value: { id: string; type: 'Document::Generic'; }; } export interface FieldGovernmentId extends FieldBase { type: 'government_id'; value: { id: string; type: 'Document::GovernmentId'; }; } export interface FieldDocumentMobileDriversLicense extends FieldBase { type: 'mobile_drivers_license'; value: { id: string; type: 'Document::MobileDriversLicense'; }; } export interface FieldDocumentNfcPassport extends FieldBase { type: 'nfc_passport'; value: { id: string; type: 'Document::NfcPassport'; }; } export interface FieldSelfie extends FieldBase { type: 'selfie'; value: { id: string; type: 'Selfie::CenterOnly' | 'Selfie::ProfileAndCenter'; }; } export type Field = FieldBoolean | FieldChoices | FieldDate | FieldDatetime | FieldInteger | FieldJson | FieldMultiChoices | FieldNumber | FieldString | FieldDocumentGeneric | FieldDocumentMobileDriversLicense | FieldDocumentNfcPassport | FieldGovernmentId | FieldSelfie; export type Fields = { [fieldKey: string]: FieldValue; }; /** * Events sent from the persona-web iframe. * * https://docs.withpersona.com/docs/embedded-flow-event-handling */ export declare enum Event { Cancel = "exit", Complete = "complete", Error = "error", Fail = "fail", Load = "load", Ready = "ready", Start = "start", Success = "success", DocumentCameraSelect = "document-camera-select", DocumentCameraCapture = "document-camera-capture", DocumentUpload = "document-upload", OneTimeLinkSent = "one-time-link-sent", OneTimeLinkStart = "one-time-link-start", OneTimeLinkExit = "one-time-link-exit", SelfieCameraSelect = "selfie-camera-select", SelfieCameraCapture = "selfie-camera-capture", SelfieRecordUpload = "selfie-record-upload", /** * Sent when the browser encounters issues loading the camera. * This may be due to permission issues, hardware issues, resource constraint issues, etc. */ LoadCameraFailed = "load-camera-failed", /** * Sent when inquiry flow page changes. * Contains page metadata: * - pathname: string * - pageHeight: number * * pageHeight can be used with the Inline integration to dynamically resize * the iframe based on the page contents. */ PageChange = "page-change", InquiryLoad = "inquiry-load", /** * @deprecated Persona will stop sending this event in the next major version */ CountrySelect = "country-select", /** * @deprecated Persona will stop sending this event in the next major version */ VerificationChange = "verification-change", StepTransitioned = "step-transitioned", Click = "click", FormUpdate = "form-update" } /** * The default set of events forwarded to `onEvent`. Includes all legacy events * that existed before granular interaction events were added. */ export declare const DEFAULT_EVENTS_ALLOW_LIST: Event[]; /** * Events sent from the persona-verify widget to persona-web. * @private */ export declare enum FromWidgetEvent { Open = "open", Exit = "exit", Destroy = "destroy" } /** * Parameters used when creating inquiries. * * https://docs.withpersona.com/docs/parameters */ export interface InquiryOptions { /** * Required when creating inquiries. * Takes both Template and InquiryTemplate IDs. * Passing the ID of an InquiryTemplate with no published versions will error. */ templateId?: string; /** * Allows locking to a specific template version. */ templateVersionId?: string; /** * Defaults to first production environment. */ environmentId?: string; /** * @deprecated use `environmentId` instead. */ environment?: 'sandbox' | 'production'; /** * Mutually exclusive with `account-id`, otherwise backend throws an error! */ referenceId?: string; /** * Mutually exclusive with `reference-id`, otherwise backend throws an error! */ accountId?: string; /** * Account type to associate with newly created account. * * No-ops if: * - account-id is passed * - reference-id is passed and reference-id corresponds to existing account */ accountTypeId?: string; language?: string; /** * Allows prepopulation of inquiry fields (and the Inquiry Flow UI). */ fields?: Fields; /** * Allows using a specific theme set. * @deprecated Preview feature. Not considered stable. */ themeSetId?: string; /** * Allows using a specific theme set variant. */ styleVariant?: 'base' | 'dark' | string; /** * Required when resuming inquiries. */ inquiryId?: string; /** * Required when resuming pending inquiries. */ sessionToken?: string; /** * Called when the iframe loads the Persona Inquiry flow, but before the Inquiry flow is ready. * If `inquiryId` is undefined, no inquiry has been created yet. */ onLoad?: () => void; /** * Called after the Inquiry flow is ready. * If `inquiryId` is undefined, no inquiry has been created yet. */ onReady?: (metadata?: { preferredDimensions?: InquiryPreferredDimensions; styles?: InquiryStyles; }) => void; /** * Called when the inquiry flow is completed. Returns the inquiry status and all fields. * Dynamic Flow inquiries send a map of field key to `Field` for `fields. */ onComplete?: ({ inquiryId, status, fields, }: { inquiryId: string; status: string; /** * Dynamic Flow templates send Record. * Legacy templates send Record. */ fields: Record | Record; }) => void; /** * Called when the user exits the widget _before_ completion. * If `inquiryId` and `sessionToken` are undefined, it means no inquiry has been created yet. * Replaces `onExit()`. */ onCancel?: ({ inquiryId, sessionToken }: { inquiryId?: string; sessionToken?: string; }) => void; /** * Catch-all handler. */ onEvent?: (name: Event, metadata?: { [key: string]: unknown; }) => void; /** * Handles network errors, configuration errors, etc. */ onError?: (error: InquiryError) => void; parent?: HTMLElement; /** * Allows specifying additional origins for CSP purposes. Values should * include both protocol and host (e.g. https://withpersona.com). * * This is REQUIRED when the page that embeds the Persona widget is itself * embedded in another page as an iframe. The value should be an array of * origins for ALL iframes that are ancestors of the Persona iframe. * * `window.target.origin` is provided by default. */ frameAncestors?: string[]; /** * Allows specifying a custom target for `window.postMessage` from the * Persona app, which defaults to the iframe origin. * * This is REQUIRED when the page that embeds the Persona widget is itself * embedded in another page as an iframe. The value should be the origin where * the Persona SDK is mounted. */ messageTargetOrigin?: string; /** * Iframe height. */ frameHeight?: Properties['maxHeight']; /** * Iframe width. Max allowed width is 768px. */ frameWidth?: Properties['maxWidth']; /** * Iframe sandbox attributes. * * The following attributes are REQUIRED for the Persona flow to function and * are not removable. * - allow-same-origin -- needed to run the Inquiry Flow at all, which is a * React single-page app. * - allow-scripts -- allows the iframed content to retain its origin * (withpersona.com), allowing communication with the Persona Inquiry Flow, * usage of LocalStorage and cookies, etc. * - allow-popups -- allows opening new windows. Needed to allow access to * Terms of Services and other consent policies. * * By default, Persona supplies the following attributes. Removing them may * impact functionality of parts of the Persona flow. * - allow-forms -- needed for form submission. Only needed for flows * including form inputs. * - allow-modals -- needed for beforeunload, which is used for error * reporting. * - allow-top-navigation-by-user-activation -- allows redirect on completion. * * https://html.spec.whatwg.org/multipage/browsers.html#sandboxing */ sandboxAttributes?: string[]; /** * Persona automatically routes requests to the best location, but the initial * request will be slower due to the need to determine the best location. * * If you know which country to route requests to directly, you can set it * here to speed up the initial request. * * Requests may be re-routed and incur additional latency if this value is * set incorrectly. */ routingCountry?: string; /** * Allows passing a title for the Persona iframe for use by screen readers. * Defaults to 'Verify your identity'. */ iframeTitle?: string; /** * Controls padding SOLELY for the inline flow. Ignored in the embedded flow. */ widgetPadding?: { top?: number; bottom?: number; left?: number; right?: number; }; /** * Controls padding SOLELY for the inline flow. Ignored in the embedded flow. */ navigationPadding?: { top?: number; bottom?: number; left?: number; right?: number; }; /** * To use the 'development' option, your organization must include localhost * as an allowed-host. * * Also accepts custom hosts (e.g., 'my-custom-subdomain.withpersona.com' * or 'verify-with-persona-customer.com') for custom domain setups. */ customHost?: 'development' | string; /** * Controls which events are forwarded to the `onEvent` callback. * * - Default: only legacy events (pre-granular) are forwarded. * - `'all'`: all events including new granular interaction events are forwarded. * - `Event[]`: only the specified events are forwarded. */ eventsAllowlist?: Event[] | 'all'; /** * @private Internal property for testing. Will do nothing. * To use the 'development' option, your organization must include localhost * as an allowed-host. * * Also accepts custom hosts (e.g., 'my-custom-subdomain.withpersona.com' * or 'verify-with-persona-customer.com') for custom domain setups. */ host?: 'development' | 'staging' | 'canary' | 'production' | string; } export declare enum BaseUrl { Development = "http://localhost:3000", Staging = "https://inquiry.withpersona-staging.com", Canary = "https://canary.withpersona.com", Production = "https://inquiry.withpersona.com" } /** * Payload sent by Persona via `postMessage`. */ interface ServerMessageDataBase { containerId: string; templateId?: string; templateVersionId?: string; name: Event; metadata?: { [key: string]: unknown; }; error?: InquiryError; } interface ServerMessageDataLoad extends ServerMessageDataBase { name: Event.Load; metadata?: never; error?: never; } interface ServerMessageDataReady extends ServerMessageDataBase { name: Event.Ready; metadata?: { preferredDimensions: InquiryPreferredDimensions; styles?: InquiryStyles; }; error?: never; } interface ServerMessageDataComplete extends ServerMessageDataBase { name: Event.Complete; metadata: { inquiryId: string; status: string; fields: Record; scopes: undefined; } | { inquiryId: string; status: string; fields: undefined; scopes: Record; }; error?: never; } interface ServerMessageDataFail extends ServerMessageDataBase { name: Event.Fail; metadata: { inquiryId: string; status: string; fields: Record; scopes: undefined; } | { inquiryId: string; status: string; fields: undefined; scopes: Record; }; error?: never; } interface ServerMessageDataCancel extends ServerMessageDataBase { name: Event.Cancel; metadata: { inquiryId?: string; sessionToken?: string; }; error?: never; } interface ServerMessageDataError extends ServerMessageDataBase { name: Event.Error; metadata?: never; error: InquiryError; } export type ServerMessageData = ServerMessageDataLoad | ServerMessageDataReady | ServerMessageDataComplete | ServerMessageDataFail | ServerMessageDataCancel | ServerMessageDataError; interface InquiryErrorBase { status: number; code: string; message?: string; } interface InquiryErrorApplication extends InquiryErrorBase { status: 0; code: 'application_error'; } interface InquiryErrorInvalidConfig extends InquiryErrorBase { status: 400; code: 'invalid_config'; } interface InquiryErrorInactiveTemplate extends InquiryErrorBase { status: 422; code: 'inactive_template'; } interface InquiryErrorUnauthenticated extends InquiryErrorBase { status: 409; code: 'unauthenticated'; } interface InquiryErrorUnknown extends InquiryErrorBase { status: number; code: 'unknown'; } export type InquiryError = InquiryErrorApplication | InquiryErrorInvalidConfig | InquiryErrorInactiveTemplate | InquiryErrorUnauthenticated | InquiryErrorUnknown; export interface InquiryPreferredDimensions { minimumWidth?: string; maximumWidth?: string; minimumHeight?: string; maximumHeight?: string; } export interface InquiryStyles { borderRadius?: string; } export {};