/** * Type declarations for @syncfy/authentication-widget. * The built dist/main.d.ts may be empty when generated by vite-plugin-dts; * this file is the canonical source for published types. */ export interface Params { config?: Record; element?: Element | string; enableTestMode?: boolean; refreshTokenFunction?: () => Promise<{ token: string; strict?: unknown }>; strict?: unknown; token: string; } /** Locale option. */ export type Locale = string; /** Auth argument for headless methods. */ export interface HeadlessAuth { token: string; strict?: unknown; } /** Account returned by getAccounts. */ export interface Account { account_type: string; balance: number; currency: string; dt_refresh: number; id_account_type: string; id_account: string; id_credential: string; id_currency: string; id_external: string; id_site_organization_type: string; id_site_organization: string; id_site: string; id_user: string; is_disable: number; name: string; number: string; site: { avatar: string; cover: string; id_site_organization_type: string; id_site_organization: string; id_site: string; name: string; organization: string; small_cover: string; time_zone: string; }; } /** Country returned by getCountries. */ export interface Country { code: string; id_country: string; name: string; } /** Site (API model) returned by getSite and passed to siteConnection. */ export interface SiteBase { avatar?: string; cover?: string; endpoint: string; id_site_type: string; id_site: string; is_business: number; is_personal: number; name: string; quickAnswer?: boolean; request?: unknown; site_organization?: OrganizationSite; } export interface SiteV1 extends SiteBase { version: 1; credentials: CredentialInput[]; } export interface SiteV3 extends SiteBase { version: 3; input: CredentialInputGroup[]; } export interface SiteV4 extends SiteBase { version: 4; input: V4CredentialInputGroup[]; } export type Site = SiteV1 | SiteV3 | SiteV4; /** Credential field (e.g. from getFields). */ export interface CredentialInput { accept?: Array<{ extension: string; mime_type: string }>; enabled_by?: string; enables?: string[]; error_label?: string; identifier?: boolean; label?: string; name: string; options?: SelectOption[]; required: boolean; token?: boolean; translate_error_label?: string; translate_label?: string; type: string; validation?: Validation; } export interface CredentialInputGroup { fields: CredentialInput[]; label: string; name: string; } export interface SelectOption { label?: string; value?: number | string; } export interface Validation { type?: string; value?: unknown; } export interface V4CredentialInputGroup { fields?: CredentialInput[]; label?: string; name?: string; } /** Organization site returned by getOrganizationSites. */ export interface OrganizationSite { avatar: string; cover: string; id_country: string; id_site_organization: string; id_site_organization_type: string; name: string; sites: Site[]; small_cover: string; } /** Organization type returned by getOrganizationTypes. */ export interface OrganizationType { id_site_organization_type: string; label: string; name: string; } /** Socket message payload (e.g. from site.on('socket-message', (data) => ...)). For code 410, data is TwofaMessage. */ export interface SocketMessage { address?: string; code: number; id_request?: string; id_site?: string; twofa?: TwofaCredentialInput[]; } /** Site connection returned by siteConnection (SiteV1Service | SiteV3Service | SiteV4Service). */ export interface HeadlessSiteConnection { readonly version: 1 | 3 | 4; getFields(updateMode?: boolean): CredentialInput[]; getFields(index: number, updateMode?: boolean): CredentialInput[]; getOptions(): CredentialInputGroup[]; getBackUpFields(updateMode?: boolean): CredentialInput[]; readonly twofa: HeadlessTwofa | null; on(event: string, callback: (...args: unknown[]) => void): void; connect(data: Record): Promise; connect( index: number, data: Record, isBackUp?: boolean, ): Promise; } /** Twofa message passed to headless.twofa (e.g. socket 410 data). */ export interface TwofaMessage { address: string; code: number; id_request?: string; id_site?: string; twofa: TwofaCredentialInput[]; } /** Twofa credential field (from HeadlessTwofa.getFields). */ export interface TwofaCredentialInput { disabled?: boolean; imgBase64File?: string; imgURL?: string; label: string; name: string; options?: Array<{ imgBase64File?: string; imgURL?: string; label?: string; value: number | string; }>; type: string; validation?: Validation; } /** Twofa instance returned by headless.twofa. */ export interface HeadlessTwofa { getFields(): TwofaCredentialInput[]; displaySubmitButton: boolean; data: Record; authenticate(data: Record): void | Promise; on(event: string, callback: (...args: unknown[]) => void): void; } /** Credential instance returned by syncCredential and updateCredential. */ export interface HeadlessCredential { on(event: string, callback: (...args: unknown[]) => void): void; getCredentialData(): Record; readonly twofa: HeadlessTwofa | null; status?: string; } /** Headless API: static methods for use without mounting the widget UI. */ export interface SyncfyWidgetHeadless { getAccounts( auth: HeadlessAuth, id_credential: string, config?: { locale?: Locale }, ): Promise; getCountries( auth: HeadlessAuth, config?: { locale?: Locale }, ): Promise; getOrganizationSites( auth: HeadlessAuth, params?: { is_business?: number; is_personal?: number }, config?: { locale?: Locale }, ): Promise; getOrganizationTypes( auth: HeadlessAuth, config?: { locale?: Locale }, ): Promise; getSite( auth: HeadlessAuth, id_site: string, config?: { locale?: Locale }, ): Promise; siteConnection( auth: HeadlessAuth, site: Site, config?: { locale?: Locale; quickAnswer?: boolean; socketTimeout?: number | string; }, ): Promise; syncCredential( auth: HeadlessAuth, id_credential: string, config?: { locale?: Locale; quickAnswer?: boolean; socketTimeout?: number | string; }, ): Promise; twofa( auth: HeadlessAuth, twofaMessage: TwofaMessage, id_site: string, config?: { locale?: Locale }, ): Promise; updateCredential( auth: HeadlessAuth, id_credential: string, config?: { locale?: Locale; quickAnswer?: boolean; socketTimeout?: number | string; }, ): Promise; } export interface SyncfyWidgetInstance { on(event: string, callback: (...args: unknown[]) => void): void; close: () => void; getLastRid: () => string | undefined; open: () => void; setConfig: (config: unknown) => void; setEntrypointCredential: (entrypoint: string) => void; setEntrypointSite: (entrypoint: string) => void; setEntrypointUpdateCredential: (entrypoint: string) => void; setToken: (token: string) => void; upsertConfig: (config: unknown) => void; } /** SyncfyWidget is a constructor; `new SyncfyWidget(params)` returns an instance with open(), close(), on(), etc. */ export interface SyncfyWidgetConstructor { new (params: Params | string): SyncfyWidgetInstance; getVersion(): string; headless: SyncfyWidgetHeadless; } declare const SyncfyWidget: SyncfyWidgetConstructor; export { SyncfyWidget }; export default SyncfyWidget;