import { Dispatch, Store } from 'redux'; import { InjectedIntl } from 'react-intl'; import { RewardDisplayEnum, Locale, IdCheckLoopServiceType, ThirdPartyLoopProvider } from './runtimeTypes'; import { FormFieldConfigType } from '../../components/FormFields/FormFieldCustom/FormFieldCustom'; import { TryAgainAction } from '../../components/TryAgainAction'; import { hooks } from '../hooks'; import { DeepPartial } from './helpers'; import { Flags } from '../../components/FeatureFlags/flags'; import { ViewModelUpdateOptions } from '../VerificationService/ViewModel'; export { type Locale } from './runtimeTypes'; export interface NavigatorBeta extends Navigator { globalPrivacyControl: boolean; } /** * SheerID Javascript Library types and interfaces */ /** * The interface exposed on the window object */ export interface SheerIdJsApi { getMetadata(): Metadata; setMetadata(metadata: Metadata): void; resetMetadata(): void; setOptions(options: Options): void; resetOptions(): void; VerificationForm: new (element: HTMLElement, programId: DatabaseId) => void; addHook(hook: Hook): RegisteredHooks; refreshStore(): void; hooks: typeof hooks; conversion: Conversion; setViewModel(viewModel: ViewModel | {}): void; resetViewModel(): void; overrideComponent: (componentName: OverrideableComponentName, newComponent: StepComponent) => void; resetOverriddenComponents: () => void; postVerificationSizeUpdates(options: PostMessagesOptions): void; getMessages(locale: Locale, programThemeMessages?: ProgramThemeMessages, segment?: Segment): Promise; collectDeviceProfile(verificationId: string, programId: string): void; resetStore: () => void; setProgramTheme(theme: Partial): void; } export interface FormFieldConfig { fieldId: PersonalInfoFieldId | string; disabled?: boolean; requireIfOptional?: boolean; hidden?: boolean; } export interface CustomFormFieldConfig extends FormFieldConfig { fieldType: (typeof FormFieldConfigType)[keyof typeof FormFieldConfigType]; validate: (value: string | boolean) => ErrorId | ExtendedErrorId; showPlaceholderAndHideLabel?: boolean; required?: boolean; options?: string[]; } export interface UtilsApi { determineDevice: (verificationId: DatabaseId, programId: DatabaseId) => void; setOptions(options: Options): void; } /** * @description Require only properties of type T * @private * Example: type A = { foo: string } function bar(newObject: PropertiesOf) {...} bar({ foo: 'baz' }) // valid bar({ otherProp: 'stuff' }) // invalid */ export type PropertiesOf = Pick> & { [K in Keys]-?: Required>; }[Keys]; /** * @description creates a keypath union type of all nested keys under an object. * @private */ type NestedKeyOf = { [Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object ? `${Key}` | `${Key}.${NestedKeyOf}` : `${Key}`; }[keyof ObjectType & (string | number)]; /** * @private */ export type StringMap = { [a: string]: string; }; /** * @example 5bbd127d9781852f68e14ddc * @template 24 digit hexadecimal */ export type DatabaseId = string; /** * @example { 'someKey': 'someValue' } */ export type Metadata = { [key: string]: string | boolean; }; /** * @description Configurable options that can be passed when initializing this library. */ export type Options = { restApi?: RestApiOptions; logLevel?: LogLevel; mockStep?: MockStep; mockSegment?: Segment; mockSubSegment?: SubSegment; mockErrorId?: ErrorId; mockRewardCode?: string; mockRedirectUrl?: string; mockConsumerInfoState?: ConsumerInfoState; mockIdCheckLoopServiceType?: IdCheckLoopServiceType; mockPreviousStep?: VerificationStep; mockDocSelected?: string; installPageUrl?: string; mockResponse?: VerificationResponse; doFetchTheme?: boolean; locale?: Locale; messages?: object; messagesWithLocale?: object; urlFaq?: string; /** * @deprecated since version 1.63 */ urlStudentFaq?: string; /** * @deprecated since version 1.63 */ urlSeniorFaq?: string; /** * @deprecated since version 1.63 */ urlAgeFaq?: string; /** * @deprecated since version 1.63 */ urlMilitaryFaq?: string; /** * @deprecated since version 1.63 */ urlTeacherFaq?: string; /** * @deprecated since version 1.63 */ urlMemberFaq?: string; /** * @deprecated since version 1.63 */ urlFirstResponderFaq?: string; /** * @deprecated since version 1.63 */ urlMedicalFaq?: string; /** * @deprecated since version 1.63 */ urlEmploymentFaq?: string; /** * @deprecated since version 1.63 */ urlIdentityFaq?: string; /** * @deprecated since version 1.63 */ urlLicensedProfessionalFaq?: string; urlLowIncomeFaq?: string; urlAddSchoolFaq?: string; urlAddSchoolForm?: string; customCss?: ProgramTheme["customCss"]; logoUrl?: ProgramTheme["logoUrl"]; privacyPolicyUrl?: ProgramTheme["privacyPolicyUrl"]; cookies?: CookieOptions; useFingerprinting?: boolean; marketConsent?: MarketConsentOptions; customMetadata?: MetadataConfig; verificationId?: string; minimumOrganizationSearchLength?: number; httpRequestTimeout?: number; hideTestModeFlag?: boolean; /** * @deprecated */ hideMilitaryFamilyAcceptableUploads?: boolean; customFormFields?: CustomFormFieldConfig[]; formFieldConfig?: FormFieldConfig[]; tryAgainAction?: TryAgainAction; _launchDarklyUserTargeting?: boolean; _launchDarklyFlagCb?: (flags: Flags) => void; /** * Supports backwards compatibility with consumers who render the a verification form directly on their page, preventing the landing page from rendering within their container. * This option may be removed in v2. */ renderAs?: "default" | "landingPage"; }; export type RestApiOptions = { serviceUrl: string; resources?: RestResources; }; /** * @description Control how cookies behave * @field `expires` Number of days for cookie to expire in. Use 0 to expire in same browser session. * @field `secure` Whether the cookie is set securely. */ export type CookieOptions = { expires: number; secure: boolean; enabled: boolean; path?: string; domain?: string; sameSite?: "lax" | "strict" | "none"; }; export type MarketConsentOptions = { enabled: boolean; required: boolean; message: string; }; export type MetadataConfig = { enabled: boolean; keys: string[]; requiredKeys?: string[]; }; export type RestResources = { verification: string; program: ProgramResources; conversion: ConversionResources; }; export type ProgramResources = { base: string; theme: string; organization: string; }; /** * @description Configuration for a verification being displayed on an iframe. */ export type IframeUserConfiguration = { closeButtonText?: string; mobileRedirect?: boolean; mobileThreshold?: string | number; stopPropagation?: boolean; }; export type VerificationFormLayout = "fullRight" | "center" | "splitRight"; /** * @description URL of a verification to be displayed. */ export type VerificationUrl = string; /** * @description Options for the message events send by a verification loaded on an iframe. * These event are used to resize a modal containing a verification. */ export type PostMessagesOptions = { origin: VerificationUrl; interval: number; }; export type PostMessageAction = { type: "updateHeight"; action?: "updateHeight"; height: number; } | { type: "focus"; action?: "focus"; focusOn: "firstElement" | "lastElement"; } | { type: "hook"; action?: never; hook: HookData; }; export type PostMessageData = { verificationIframeUid: string; action: PostMessageAction; }; /** * @description URLs related to conversion endpoints. */ export type ConversionResources = { base: string; }; export type LogLevel = "info" | "log" | "warn" | "error"; /** * @description Interface for individual field instances, such as BirthdateField * @example new sheerid.BirthdateField().setValue('2000-01-01'); */ export interface DiscreteField { getValue(): any; setValue(value: any): void; onChange(callback: Function): void; setIsErrored(value: boolean): void; render(): void; } /** * @todo document constraints here */ export type Email = string; /** * @example (111) 222-3333 | 1112223333 | 111-222-3333 * TODO - Update this when PhoneNumberValidator regex changes. */ export type PhoneNumber = string; /** * @example 2013-03-06 * @template ISO-8601 'YYYY-MM-DD' */ export type BirthDate = string; /** * @example 1234567 | A01205257 */ export type MemberId = string; /** * @example 2013-03-06 * @template ISO-8601 'YYYY-MM-DD' * The `day` portion of this date is not editable or displayed to the user */ export type DischargeDate = string; /** * @example 2013-03-06 * @template ISO-8601 'YYYY-MM-DD' */ export type ActiveDutyStartDate = string; /** * @description TODO */ export declare const MILITARY_STATUS: readonly ["ACTIVE_DUTY", "VETERAN", "RESERVIST", "MILITARY_RETIREE", "MILITARY_FAMILY", "GOLD_STAR_FAMILY"]; export type MilitaryStatus = (typeof MILITARY_STATUS)[number]; /** * @description TODO */ export declare const FIRST_RESPONDER_STATUS: readonly ["FIREFIGHTER", "EMT", "POLICE", "SEARCH_AND_RESCUE"]; export type FirstResponderStatus = (typeof FIRST_RESPONDER_STATUS)[number]; export declare const MEDICAL_PROFESSIONAL_STATUS: readonly ["NURSE", "DOCTOR", "DENTIST", "PHARMACIST", "OTHER_HEALTH_WORKER"]; export type MedicalProfessionalStatus = (typeof MEDICAL_PROFESSIONAL_STATUS)[number]; export declare const LICENSED_PROFESSIONAL_STATUS: readonly ["LICENSED_COSMETOLOGIST", "LICENSED_REAL_ESTATE_AGENT", "VETERINARIAN", "CHILD_CARE_WORKER", "LIBRARIAN", "INTERIOR_DESIGNER", "ARCHITECT", "GENERAL_CONTRACTOR", "NUTRITION_PROFESSIONAL"]; export type LicensedProfessionalStatus = (typeof LICENSED_PROFESSIONAL_STATUS)[number]; export declare const RECENT_MOVER_STATUS: readonly ["HOME_BUYER", "OTHER_MOVER"]; export type RecentMoverStatus = (typeof RECENT_MOVER_STATUS)[number]; export declare const LOW_INCOME_STATUS: readonly ["SNAP_BENEFITS", "OTHER_GOVERNMENT_ASSISTANCE", "COMMUNITY_ELIGIBILITY_PROVISION"]; export type LowIncomeStatus = (typeof LOW_INCOME_STATUS)[number]; /** * @description TODO */ export type OrganizationId = number; /** * @description TODO */ export type OrganizationName = string; /** * @description All possible fields which show up on the personal info steps */ export type PersonalInfoFieldId = "firstName" | "lastName" | "memberId" | "organization" | "birthDate" | "email" | "phoneNumber" | "postalCode" | "address1" | "city" | "state" | "dischargeDate" | "activeDutyStartDate" | "status" | "statuses" | "country" | "socialSecurityNumber" | "marketConsentValue" | "ebtCardNumber" | "cvecNumber" | "driverLicenseNumber"; /** * @description All possible fields */ export type FieldId = PersonalInfoFieldId | "docUpload" | "carrierConsentValue" | "overrideCode" | "organizationEmail" | "authenticationCode" | "smsCode"; export type FormValidationOptions = { minAge?: number; maxAge?: number; smsLoopEnabled?: boolean; strictMilitaryValidationEnabled?: boolean; currentStep?: VerificationStep; viewModel?: ViewModel; }; /** * @description TODO */ export type ExtendedFieldId = FieldId | string; /** * @description The object that contains all possible field ids for setting & displaying field errors, if any */ export type FieldValidationErrors = { [P in FieldId]: ErrorId; }; /** * @description TODO */ export type ExtendedFieldValidationErrors = StringMap; /** * @description TODO */ export type FieldContent = string | number | File | FormSelectChoice | Organization | boolean; /** * @private */ export type Organization = { id: OrganizationId; name: OrganizationName; country?: Country; type?: OrganizationType; idExtended?: string; source?: OrganizationRemoteSource; }; /** * @private */ export type OrganizationRemoteSource = "EMPLOYER" | "PLACE"; /** * @private */ export type OrganizationSearchResp = Organization[]; /** * @description A model to back many of this library's `