UNPKG

@better-auth-ui/core

Version:

Authentication components and data utilities for [Better Auth](https://better-auth.com), available for React and Solid.

46 lines (45 loc) 2.03 kB
import { DeepPartial } from './deep-partial'; /** * Resize and square-crop an image file for use as an avatar. * * The image is center-cropped to a square, scaled down to at most {@link size} pixels, * and converted to the specified output format. * * @param file - The source image file. * @param size - Max dimension in pixels for the output image. * @param extension - Output format. Use `"inherit"` to keep the original format. * @returns A promise that resolves to the processed `File`. */ export declare function resizeAvatar(file: File, size?: number, extension?: "png" | "jpg" | "webp" | "inherit"): Promise<File>; /** * Convert a `File` to a base64-encoded data URL string. * * @param file - The file to encode. * @returns A promise that resolves to the base64 data URL. */ export declare function fileToBase64(file: File): Promise<string>; /** * Convert an avatar to a compact data URL for the no-uploader fallback. * * Better Auth can cache the complete session user in a response cookie. Keeping * embedded avatars below a conservative byte limit prevents the image from * overflowing HTTP response headers while preserving higher-quality files for * configured upload providers. * * @param file - The resized avatar file to encode. * @returns A promise that resolves to a compact WebP data URL. */ export declare function fileToAvatarDataUrl(file: File): Promise<string>; /** * Recursively merge `source` into `target`, producing a new object. * * - Plain objects are merged key-by-key; nested objects are merged recursively. * - `undefined` values in `source` are skipped (existing `target` values are preserved). * - Non-plain values (arrays, `Date`, `RegExp`, primitives, functions) in `source` * replace the corresponding `target` value outright. * * @param target - The base object. * @param source - Partial overrides to apply on top of `target`. * @returns A new merged object of type `T`. */ export declare function deepmerge<T>(target: T, source: DeepPartial<T>): T;