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

providers.mddocs/

Update Providers

Provider classes for different hosting solutions and update servers. Each provider handles the specifics of retrieving update information and resolving download URLs for its respective platform.

Capabilities

Provider Abstract Base Class

The abstract base class that all update providers extend.

/**
 * Abstract base class for all update providers
 * @template T The type of UpdateInfo this provider handles
 */
abstract class Provider<T extends UpdateInfo> {
  // Runtime configuration
  readonly isUseMultipleRangeRequest: boolean;
  readonly fileExtraDownloadHeaders: OutgoingHttpHeaders | null;
  
  // Request configuration
  setRequestHeaders(value: OutgoingHttpHeaders | null): void;
  
  // Abstract methods (implemented by specific providers)
  abstract getLatestVersion(): Promise<T>;
  abstract resolveFiles(updateInfo: T): Array<ResolvedUpdateFileInfo>;
  
  // Protected utility methods
  protected httpRequest(url: URL, headers?: OutgoingHttpHeaders | null, cancellationToken?: CancellationToken): Promise<string | null>;
  protected createRequestOptions(url: URL, headers?: OutgoingHttpHeaders | null): RequestOptions;
  protected getDefaultChannelName(): string;
  protected getCustomChannelName(channel: string): string;
}

interface ProviderRuntimeOptions {
  isUseMultipleRangeRequest: boolean;
  platform: ProviderPlatform;
  executor: ElectronHttpExecutor;
}

type ProviderPlatform = "darwin" | "linux" | "win32";

GenericProvider

Generic HTTP server provider for custom update servers and static file hosting.

/**
 * Generic HTTP server provider
 * Works with any HTTP server serving update manifest files
 */
class GenericProvider extends Provider<UpdateInfo> {
  constructor(
    configuration: GenericServerOptions,
    updater: AppUpdater,
    runtimeOptions: ProviderRuntimeOptions
  );
}

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

Usage Examples:

import { autoUpdater } from "electron-updater";
import { GenericProvider } from "electron-updater/out/providers/GenericProvider";

// Simple URL setup
autoUpdater.setFeedURL("https://updates.myapp.com");

// Advanced configuration
autoUpdater.setFeedURL({
  provider: "generic",
  url: "https://updates.myapp.com",
  channel: "beta",
  useMultipleRangeRequest: true
});

// Custom generic provider instance
const provider = new GenericProvider(
  {
    provider: "generic",
    url: "https://updates.myapp.com"
  },
  autoUpdater,
  {
    isUseMultipleRangeRequest: true,
    platform: process.platform as ProviderPlatform,
    executor: autoUpdater.httpExecutor
  }
);

// Expected server structure:
// https://updates.myapp.com/
//   ├── latest.yml              (Windows/Linux)
//   ├── latest-mac.yml          (macOS)
//   ├── beta.yml                (Windows/Linux beta)
//   ├── beta-mac.yml            (macOS beta) 
//   └── releases/
//       ├── myapp-1.0.0.exe
//       ├── myapp-1.0.0.dmg
//       └── myapp-1.0.0.AppImage

GitHubProvider

GitHub releases provider for public repositories.

/**
 * GitHub releases provider for public repositories
 */
class GitHubProvider extends Provider<GithubUpdateInfo> {
  constructor(
    options: GithubOptions,
    updater: AppUpdater,
    runtimeOptions: ProviderRuntimeOptions
  );
}

interface GithubOptions extends PublishConfiguration {
  provider: "github";
  owner: string;                        // Repository owner
  repo: string;                         // Repository name
  token?: string;                       // GitHub access token (optional for public repos)
  private?: boolean;                    // Whether repository is private
  releaseType?: "draft" | "prerelease" | "release"; // Type of releases to include
  publishAutoUpdate?: boolean;          // Whether to publish auto-update files
}

interface GithubUpdateInfo extends UpdateInfo {
  tag: string;                          // Git tag name
  releaseJsonUrl: string;               // GitHub API URL for release
}

Usage Examples:

import { GitHubProvider, autoUpdater } from "electron-updater";

// Simple GitHub setup
autoUpdater.setFeedURL({
  provider: "github",
  owner: "myorg",
  repo: "myapp"
});

// With authentication for private repo
autoUpdater.setFeedURL({
  provider: "github", 
  owner: "myorg",
  repo: "private-app",
  token: process.env.GITHUB_TOKEN,
  private: true
});

// Include pre-release versions
autoUpdater.setFeedURL({
  provider: "github",
  owner: "myorg", 
  repo: "myapp",
  releaseType: "prerelease"
});

autoUpdater.allowPrerelease = true;
autoUpdater.fullChangelog = true; // Get all release notes

// Custom provider instance
const provider = new GitHubProvider(
  {
    provider: "github",
    owner: "myorg",
    repo: "myapp",
    token: "ghp_xxxxxxxxxxxx"
  },
  autoUpdater,
  runtimeOptions
);

PrivateGitHubProvider

Enhanced GitHub provider for private repositories with token authentication.

/**
 * Private GitHub repository provider with token authentication
 * Extends GitHubProvider with enhanced private repo support
 */
class PrivateGitHubProvider extends GitHubProvider {
  constructor(
    options: GithubOptions,
    updater: AppUpdater,
    token: string,
    runtimeOptions: ProviderRuntimeOptions
  );
}

Usage Examples:

import { PrivateGitHubProvider } from "electron-updater";

// Use for private repositories requiring authentication
const provider = new PrivateGitHubProvider(
  {
    provider: "github",
    owner: "myorg",
    repo: "private-app",
    private: true
  },
  autoUpdater,
  process.env.GITHUB_TOKEN!,
  runtimeOptions
);

// Automatically handles authentication headers
// and private repository access

BitbucketProvider

Bitbucket downloads provider for Atlassian Bitbucket repositories.

/**
 * Bitbucket downloads provider
 * Uses Bitbucket's download API for release files
 */
class BitbucketProvider extends Provider<UpdateInfo> {
  constructor(
    configuration: BitbucketOptions,
    updater: AppUpdater,
    runtimeOptions: ProviderRuntimeOptions
  );
}

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

Usage Examples:

import { BitbucketProvider, autoUpdater } from "electron-updater";

// Public Bitbucket repository
autoUpdater.setFeedURL({
  provider: "bitbucket",
  owner: "myteam",
  slug: "myapp"
});

// Private repository with authentication
autoUpdater.setFeedURL({
  provider: "bitbucket",
  owner: "myteam", 
  slug: "private-app",
  token: process.env.BITBUCKET_TOKEN
});

// Expected structure in Bitbucket downloads:
// - latest.yml (update manifest)
// - myapp-1.0.0-setup.exe (Windows installer)
// - myapp-1.0.0.dmg (macOS disk image)
// - myapp-1.0.0.AppImage (Linux AppImage)

GitLabProvider

GitLab releases provider for GitLab.com and self-hosted GitLab instances.

/**
 * GitLab releases provider
 * Supports both GitLab.com and self-hosted instances
 */
class GitLabProvider extends Provider<UpdateInfo> {
  constructor(
    configuration: GitlabOptions,
    updater: AppUpdater,
    runtimeOptions: ProviderRuntimeOptions
  );
}

interface GitlabOptions extends PublishConfiguration {
  provider: "gitlab";
  owner: string;                        // Project owner/namespace
  slug: string;                         // Repository name
  host?: string;                        // GitLab instance URL (default: gitlab.com)
  token?: string;                       // GitLab access token
  channel?: string;                     // Update channel
}

Usage Examples:

import { GitLabProvider, autoUpdater } from "electron-updater";

// GitLab.com public repository
autoUpdater.setFeedURL({
  provider: "gitlab",
  owner: "mygroup",
  slug: "myapp"
});

// Self-hosted GitLab instance
autoUpdater.setFeedURL({
  provider: "gitlab",
  owner: "mygroup",
  slug: "myapp", 
  host: "gitlab.mycompany.com",
  token: process.env.GITLAB_TOKEN
});

// Private GitLab.com repository
autoUpdater.setFeedURL({
  provider: "gitlab",
  owner: "mygroup",
  slug: "private-app",
  token: process.env.GITLAB_TOKEN
});

KeygenProvider

Keygen.sh software licensing provider for licensed software distribution.

/**
 * Keygen.sh software licensing provider
 * Integrates with Keygen licensing platform for secure software distribution
 */
class KeygenProvider extends Provider<UpdateInfo> {
  constructor(
    configuration: KeygenOptions,
    updater: AppUpdater,
    runtimeOptions: ProviderRuntimeOptions
  );
}

interface KeygenOptions extends PublishConfiguration {
  provider: "keygen";
  account: string;                      // Keygen account identifier
  product: string;                      // Product identifier
  channel?: string;                     // Release channel
  platform?: string;                   // Target platform
}

Usage Examples:

import { KeygenProvider, autoUpdater } from "electron-updater";

// Keygen-hosted updates with licensing
autoUpdater.setFeedURL({
  provider: "keygen",
  account: "my-software-company",
  product: "my-premium-app",
  channel: "stable"
});

// Keygen handles license verification and secure distribution
// Requires valid license key for download access

Utility Functions

Provider Factory

/**
 * Create a provider instance based on configuration
 * @param data Provider configuration
 * @param updater AppUpdater instance
 * @param runtimeOptions Runtime configuration
 * @returns Configured provider instance
 */
function createClient(
  data: PublishConfiguration | AllPublishOptions,
  updater: AppUpdater,
  runtimeOptions: ProviderRuntimeOptions
): Provider<any>;

/**
 * Check if a URL probably supports multi-range requests
 * @param url URL to check
 * @returns true if URL likely supports multi-range requests
 */
function isUrlProbablySupportMultiRangeRequests(url: string): boolean;

Provider Helper Functions

/**
 * Find a file in the resolved file list by extension
 * @param files Array of resolved update files
 * @param extension File extension to search for
 * @param not Optional array of extensions to exclude
 * @returns Matching file or null
 */
function findFile(
  files: Array<ResolvedUpdateFileInfo>,
  extension: string,
  not?: Array<string>
): ResolvedUpdateFileInfo | null | undefined;

/**
 * Parse update information from YAML data
 * @param rawData Raw YAML string data
 * @param channelFile Channel file name for error reporting
 * @param channelFileUrl Channel file URL for error reporting
 * @returns Parsed UpdateInfo object
 */
function parseUpdateInfo(
  rawData: string | null,
  channelFile: string,
  channelFileUrl: URL
): UpdateInfo;

/**
 * Get file list from update information
 * @param updateInfo Update information object
 * @returns Array of update files
 */
function getFileList(updateInfo: UpdateInfo): Array<UpdateFileInfo>;

/**
 * Resolve file URLs from update information
 * @param updateInfo Update information
 * @param baseUrl Base URL for resolving relative paths
 * @param pathTransformer Optional path transformation function
 * @returns Array of resolved file information
 */
function resolveFiles(
  updateInfo: UpdateInfo,
  baseUrl: URL,
  pathTransformer?: (p: string) => string
): Array<ResolvedUpdateFileInfo>;

Advanced Provider Configuration

Custom Request Headers

// Set custom headers for all providers
autoUpdater.requestHeaders = {
  "User-Agent": "MyApp/1.0.0",
  "X-API-Version": "v2",
  "Authorization": `Bearer ${apiToken}`
};

// Provider-specific headers
const provider = new GenericProvider(config, updater, runtimeOptions);
provider.setRequestHeaders({
  "X-Custom-Auth": "secret-key"
});

Multi-Range Request Configuration

// Enable multi-range requests for faster downloads
autoUpdater.setFeedURL({
  provider: "generic",
  url: "https://updates.myapp.com",
  useMultipleRangeRequest: true
});

// Check if URL supports multi-range requests
import { isUrlProbablySupportMultiRangeRequests } from "electron-updater";

const url = "https://github.com/myorg/myapp/releases";
if (isUrlProbablySupportMultiRangeRequests(url)) {
  console.log("Server likely supports efficient differential downloads");
}

Custom Channel Handling

// Channel-specific configurations
autoUpdater.setFeedURL({
  provider: "github",
  owner: "myorg",
  repo: "myapp"
});

// Set channel after configuration
autoUpdater.channel = "beta";  // Will look for beta.yml instead of latest.yml

// Multiple channel support
const channels = ["stable", "beta", "alpha"];
const currentChannel = getUserPreferredChannel();

autoUpdater.channel = currentChannel;
autoUpdater.allowPrerelease = currentChannel !== "stable";