or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

auto-updater.mdconfiguration.mdcore-updaters.mdevents.mdindex.mdplatform-updaters.mdproviders.mdtypes.md
tile.json

types.mddocs/

Types and Interfaces

Core types and interfaces for update information, configuration, and event handling in the electron-updater library.

Capabilities

Core Update Types

Essential types re-exported from builder-util-runtime and defined within electron-updater.

/**
 * Information about an available update
 */
interface UpdateInfo {
  version: string;                      // Semantic version string
  files: UpdateFileInfo[];              // Array of available update files
  releaseName?: string;                 // Human-readable release name
  releaseNotes?: string;                // Release notes in markdown format
  releaseDate: string;                  // ISO date string
  stagingPercentage?: number;           // Rollout percentage (0-100)
  minimumSystemVersion?: string;        // Minimum OS version required
}

/**
 * Information about a specific update file
 */
interface UpdateFileInfo {
  url: string;                          // Download URL (relative or absolute)
  sha512: string;                       // SHA-512 checksum for verification
  sha2?: string;                        // SHA-256 checksum (deprecated)
  size?: number;                        // File size in bytes
  isAdminRightsRequired?: boolean;      // Whether installation requires admin rights
}

/**
 * Package file information for web installers
 */
interface PackageFileInfo {
  file: string;                         // Package file name
  path: string;                         // Package file path
  sha512: string;                       // Package SHA-512 checksum
  size: number;                         // Package file size
}

/**
 * Download progress information
 */
interface ProgressInfo {
  total: number;                        // Total bytes to download
  delta: number;                        // Bytes downloaded in this chunk
  transferred: number;                  // Total bytes transferred
  percent: number;                      // Download percentage (0-100)
  bytesPerSecond: number;               // Current download speed
}

/**
 * Resolved update file with complete URL information
 */
interface ResolvedUpdateFileInfo {
  readonly url: URL;                    // Complete download URL
  readonly info: UpdateFileInfo;        // Original file information
  packageInfo?: PackageFileInfo;        // Optional package information
}

Update Check Types

Types related to checking for and handling available updates.

/**
 * Result of checking for updates
 */
interface UpdateCheckResult {
  readonly isUpdateAvailable: boolean;  // Whether an update is available
  readonly updateInfo: UpdateInfo;      // Information about the update
  readonly downloadPromise?: Promise<Array<string>> | null; // Download promise if auto-download enabled
  readonly cancellationToken?: CancellationToken; // Token for cancelling operations
  readonly versionInfo: UpdateInfo;     // @deprecated - use updateInfo instead
}

/**
 * Event data when update is downloaded
 */
interface UpdateDownloadedEvent extends UpdateInfo {
  downloadedFile: string;               // Path to the downloaded update file
}

/**
 * Notification options for update downloads
 */
interface DownloadNotification {
  title: string;                        // Notification title
  body: string;                         // Notification body text
}

Logger Interface

Interface for logging functionality with support for popular logging libraries.

/**
 * Logger interface compatible with console, electron-log, winston, etc.
 */
interface Logger {
  info(message?: any): void;            // Info level logging
  warn(message?: any): void;            // Warning level logging  
  error(message?: any): void;           // Error level logging
  debug?(message: string): void;        // Optional debug level logging
}

Usage Examples:

import { autoUpdater } from "electron-updater";

// Console logging (default)
autoUpdater.logger = console;

// Electron-log integration
const log = require("electron-log");
autoUpdater.logger = log;

// Winston integration
const winston = require("winston");
autoUpdater.logger = winston;

// Custom logger
autoUpdater.logger = {
  info: (msg) => myLogger.info("Updater:", msg),
  warn: (msg) => myLogger.warn("Updater:", msg),
  error: (msg) => myLogger.error("Updater:", msg),
  debug: (msg) => myLogger.debug("Updater:", msg)
};

// Disable logging
autoUpdater.logger = null;

Event Types

Type definitions for the comprehensive event system.

/**
 * Union type of all updater event names
 */
type UpdaterEvents = 
  | "login" 
  | "checking-for-update" 
  | "update-available" 
  | "update-not-available" 
  | "update-cancelled" 
  | "download-progress" 
  | "update-downloaded" 
  | "error";

/**
 * Typed event map for AppUpdater events
 * Note: AuthInfo type comes from the 'electron' package, not electron-updater
 */
type AppUpdaterEvents = {
  error: (error: Error, message?: string) => void;
  login: (info: any /* AuthInfo from 'electron' */, callback: LoginCallback) => void;
  "checking-for-update": () => void;
  "update-not-available": (info: UpdateInfo) => void;
  "update-available": (info: UpdateInfo) => void;
  "update-downloaded": (event: UpdateDownloadedEvent) => void;
  "download-progress": (info: ProgressInfo) => void;
  "update-cancelled": (info: UpdateInfo) => void;
  "appimage-filename-updated": (path: string) => void;
}

/**
 * Login handler function type for proxy authentication
 * @param authInfo Authentication info from Electron (type from 'electron' package)
 * @param callback Function to call with credentials
 */
type LoginHandler = (authInfo: any, callback: LoginCallback) => void;

/**
 * Login callback function from Electron
 */
type LoginCallback = (username?: string, password?: string) => void;

Verification Function Types

Types for custom verification and validation functions.

/**
 * Function type for verifying update code signatures (Windows)
 * @param publisherName Array of expected publisher names
 * @param path Path to executable to verify
 * @returns Promise resolving to null if valid, error message if invalid
 */
type VerifyUpdateCodeSignature = (
  publisherName: string[], 
  path: string
) => Promise<string | null>;

/**
 * Function type for determining if an update is supported
 * @param updateInfo Information about the available update
 * @returns Boolean or promise resolving to boolean indicating support
 */
type VerifyUpdateSupport = (
  updateInfo: UpdateInfo
) => boolean | Promise<boolean>;

Usage Examples:

import { autoUpdater, VerifyUpdateCodeSignature, VerifyUpdateSupport } from "electron-updater";

// Custom code signature verification
const verifySignature: VerifyUpdateCodeSignature = async (publisherNames, execPath) => {
  try {
    const signature = await getExecutableSignature(execPath);
    if (publisherNames.includes(signature.publisher)) {
      return null; // Valid
    }
    return `Invalid publisher: ${signature.publisher}`;
  } catch (error) {
    return `Signature verification failed: ${error.message}`;
  }
};

// Custom update support verification
const verifySupport: VerifyUpdateSupport = async (updateInfo) => {
  const osVersion = require("os").release();
  const minVersion = updateInfo.minimumSystemVersion;
  
  if (minVersion && semver.lt(osVersion, minVersion)) {
    console.log(`OS version ${osVersion} below minimum ${minVersion}`);
    return false;
  }
  
  return true;
};

// Apply custom verification
if (process.platform === "win32") {
  (autoUpdater as any).verifyUpdateCodeSignature = verifySignature;
}
autoUpdater.isUpdateSupported = verifySupport;

Provider Configuration Types

Types for configuring different update providers.

/**
 * Base configuration for all providers
 */
interface PublishConfiguration {
  provider: string;                     // Provider type identifier
  publishAutoUpdate?: boolean;          // Whether to publish auto-update files
}

/**
 * Configuration for generic HTTP server provider  
 */
interface GenericServerOptions extends PublishConfiguration {
  provider: "generic";
  url: string;                          // Base server URL
  channel?: string;                     // Update channel name
  useMultipleRangeRequest?: boolean;    // Enable multi-range requests
}

/**
 * Configuration for GitHub provider
 */
interface GithubOptions extends PublishConfiguration {
  provider: "github";
  owner: string;                        // Repository owner
  repo: string;                         // Repository name
  token?: string;                       // GitHub access token
  private?: boolean;                    // Private repository flag
  releaseType?: "draft" | "prerelease" | "release"; // Release type filter
}

/**
 * Configuration for Bitbucket provider
 */
interface BitbucketOptions extends PublishConfiguration {
  provider: "bitbucket";
  owner: string;                        // Repository owner
  slug: string;                         // Repository slug (name)
  channel?: string;                     // Update channel
  token?: string;                       // Bitbucket access token
}

/**
 * Configuration for GitLab provider
 */
interface GitlabOptions extends PublishConfiguration {
  provider: "gitlab";
  owner: string;                        // Project owner/namespace
  slug: string;                         // Repository name
  host?: string;                        // GitLab instance URL
  token?: string;                       // GitLab access token
  channel?: string;                     // Update channel
}

/**
 * Union type of all provider options
 */
type AllPublishOptions = 
  | GenericServerOptions 
  | GithubOptions 
  | BitbucketOptions 
  | GitlabOptions
  | string; // Simple URL string

Internal Operation Types

Types used internally for download operations and provider runtime.

/**
 * Options for download operations
 */
interface DownloadUpdateOptions {
  readonly updateInfoAndProvider: UpdateInfoAndProvider;
  readonly requestHeaders: OutgoingHttpHeaders;
  readonly cancellationToken: CancellationToken;
  readonly disableWebInstaller?: boolean;
  readonly disableDifferentialDownload?: boolean;
}

/**
 * Update information paired with its provider
 */
interface UpdateInfoAndProvider {
  info: UpdateInfo;                     // Update information
  provider: Provider<any>;              // Provider instance
}

/**
 * Installation options for platform-specific installers
 */
interface InstallOptions {
  readonly isSilent: boolean;           // Install without user interaction
  readonly isForceRunAfter: boolean;   // Force run app after installation
  readonly isAdminRightsRequired: boolean; // Requires administrator privileges
}

/**
 * Runtime options for providers
 */
interface ProviderRuntimeOptions {
  isUseMultipleRangeRequest: boolean;   // Multi-range request support
  platform: ProviderPlatform;          // Target platform
  executor: ElectronHttpExecutor;       // HTTP executor instance
}

/**
 * Platform identifier type
 */
type ProviderPlatform = "darwin" | "linux" | "win32";

Cancellation Types

Types for cancelling long-running operations.

/**
 * Token for cancelling async operations
 */
interface CancellationToken {
  readonly isCancellationRequested: boolean;
  cancel(): void;
  createPromise(): Promise<any>;
}

/**
 * Error thrown when operation is cancelled
 */
class CancellationError extends Error {
  constructor();
}

Usage Examples:

import { autoUpdater, CancellationToken, CancellationError } from "electron-updater";

const cancellationToken = new CancellationToken();

// Start download with cancellation support
const downloadPromise = autoUpdater.downloadUpdate(cancellationToken);

// Cancel after 30 seconds
setTimeout(() => {
  cancellationToken.cancel();
}, 30000);

// Handle cancellation
downloadPromise.catch((error) => {
  if (error instanceof CancellationError) {
    console.log("Download was cancelled");
  } else {
    console.error("Download failed:", error);
  }
});

Platform-Specific Types

Types specific to certain platforms or providers.

/**
 * Windows-specific update information with package details
 */
interface WindowsUpdateInfo extends UpdateInfo {
  packages?: { [arch: string]: PackageFileInfo }; // Architecture-specific packages
}

/**
 * GitHub-specific update information  
 */
interface GithubUpdateInfo extends UpdateInfo {
  tag: string;                          // Git tag name
  releaseJsonUrl: string;               // GitHub API URL
}

Constants

Important constants used throughout the library.

/**
 * Event name constants
 */
const DOWNLOAD_PROGRESS: "download-progress";
const UPDATE_DOWNLOADED: "update-downloaded";

Usage Examples:

import { autoUpdater, DOWNLOAD_PROGRESS, UPDATE_DOWNLOADED } from "electron-updater";

// Use constants instead of string literals
autoUpdater.on(DOWNLOAD_PROGRESS, (info) => {
  console.log(`Progress: ${info.percent}%`);
});

autoUpdater.on(UPDATE_DOWNLOADED, (info) => {
  console.log("Update ready for installation");
});