UNPKG

password-manager-autofill-utilities

Version:

TypeScript utilities to control password manager autofill behavior across different password managers

82 lines 3.4 kB
import { PasswordManager, PasswordManagerBehavior, PasswordManagerConfig, FormElementProps, HtmlAttributes } from '../types'; /** * Get HTML attributes for controlling password manager behavior * @param config - Configuration specifying the desired behavior * @returns HTML attributes to apply to form elements * * @example * // Prevent all password managers from autofilling * const attrs = getPasswordManagerAttributes({ * behavior: PasswordManagerBehavior.IGNORE * }); * * @example * // Prevent only specific password managers * const attrs = getPasswordManagerAttributes({ * behavior: PasswordManagerBehavior.IGNORE, * managers: [PasswordManager.ONE_PASSWORD, PasswordManager.LASTPASS] * }); */ export declare function getPasswordManagerAttributes(config: PasswordManagerConfig): FormElementProps; /** * Get attributes to prevent all password managers from autofilling * Convenience function for the most common use case * @returns HTML attributes to prevent password manager autofill * * @example * <input {...getPasswordManagerPreventionProps()} /> * <textarea {...getPasswordManagerPreventionProps()} /> */ export declare function getPasswordManagerPreventionProps(): FormElementProps; /** * Merge password manager attributes with existing props * Useful when you need to preserve existing attributes while adding password manager control * @param existingProps - Existing props object * @param config - Password manager configuration * @returns Merged props with password manager attributes * * @example * const props = mergeWithPasswordManagerAttributes( * { className: "my-input", placeholder: "Enter text" }, * { behavior: PasswordManagerBehavior.IGNORE } * ); */ export declare function mergeWithPasswordManagerAttributes<T extends HtmlAttributes>(existingProps: T, config: PasswordManagerConfig): T & FormElementProps; /** * Merge password manager prevention attributes with existing props * Convenience function for the most common use case * @param existingProps - Existing props object * @returns Merged props with password manager prevention attributes * * @example * const props = mergeWithPasswordManagerPrevention({ * className: "my-input", * placeholder: "Enter text" * }); */ export declare function mergeWithPasswordManagerPrevention<T extends HtmlAttributes>(existingProps?: T): T & FormElementProps; /** * Check if a password manager supports a specific behavior * @param manager - The password manager to check * @param behavior - The behavior to check for support * @returns true if the password manager supports the behavior * * @example * const supportsIgnore = supportsPasswordManagerBehavior( * PasswordManager.ONE_PASSWORD, * PasswordManagerBehavior.IGNORE * ); */ export declare function supportsPasswordManagerBehavior(manager: PasswordManager, behavior: PasswordManagerBehavior): boolean; /** * Get all supported password managers * @returns Array of all supported password manager identifiers */ export declare function getSupportedPasswordManagers(): PasswordManager[]; /** * Get all supported behaviors for a specific password manager * @param manager - The password manager to check * @returns Array of supported behaviors */ export declare function getSupportedBehaviors(manager: PasswordManager): PasswordManagerBehavior[]; //# sourceMappingURL=passwordManagerUtils.d.ts.map