UNPKG

basic-electron-updater

Version:

A secure, cross-platform auto-update library for Electron Forge apps using GitHub Releases.

48 lines (47 loc) 1.66 kB
import { TypedEventEmitter } from "./events"; import { UpdaterConfig, UpdateInfo, UpdateEvents } from "./types"; /** * Updater provides secure, cross-platform auto-update support for Electron Forge apps using GitHub Releases. * * @example * import Updater from 'my-auto-updater'; * const updater = new Updater({ repo: 'user/repo' }); * updater.on('update-available', info => { ... }); * updater.checkForUpdates(); */ export default class Updater extends TypedEventEmitter<UpdateEvents> { private config; private githubProvider; private downloader; private lastUpdateInfo; private lastDownloadedPath; private currentVersion; private debug; /** * Create a new Updater instance. * @param config Updater configuration options */ constructor(config: UpdaterConfig); private sendDebugLog; private detectAppVersion; /** * Checks GitHub Releases for the latest update. * Emits 'update-available' or 'update-not-available'. * @returns UpdateInfo if available, otherwise null */ checkForUpdates(): Promise<UpdateInfo | null>; /** * Downloads the update asset for the current platform. * Emits 'download-progress' and 'downloaded'. * Validates SHA256 and GPG signature if provided. * @returns Path to the downloaded file * @throws Error if download or validation fails */ downloadUpdate(): Promise<string>; /** * Applies the downloaded update by launching the installer or archive. * Handles platform-specific logic. * @throws Error if no update is downloaded or launching fails */ applyUpdate(): Promise<void>; }