Updater
Bundle updater for managing updates from a remote server.
Bundle updater for managing updates from a remote server.
The updater coordinates between a local bundle source and remote server, handling update checks, downloads, integrity verification, and signature validation.
Constructor
new Updater(source: BundleSource, remote: Remote, options?: UpdaterOptions | null);Prop
Type
Methods
Prop
Type
Examples
import { Updater, BundleSource, Remote } from '@wvb/node';
const source = new BundleSource({
builtinDir: './bundles/builtin',
remoteDir: './bundles/remote',
});
const remote = new Remote('https://updates.example.com');
const updater = new Updater(source, remote, {
channel: 'stable',
integrityPolicy: 'strict',
signatureVerifier: {
algorithm: 'ed25519',
key: {
format: 'spkiPem',
data: publicKeyPem,
},
},
});
// Check for updates
const updateInfo = await updater.getUpdate('app');
if (updateInfo.isAvailable) {
console.log(`Update available: ${updateInfo.version}`);
await updater.download('app');
await updater.install('app', updateInfo.version);
}constructor
const updater = new Updater(source, remote, {
channel: 'stable',
integrityPolicy: 'strict',
});download
// Download latest version
const info = await updater.download('app');
console.log(`Downloaded ${info.name} v${info.version}`);// Download specific version
const info = await updater.download('app', '1.2.3');
console.log(`Downloaded ${info.name} v${info.version}`);getUpdate
const updateInfo = await updater.getUpdate('app');
if (updateInfo.isAvailable) {
console.log(`Update available: ${updateInfo.localVersion} → ${updateInfo.version}`);
} else {
console.log('Already up to date');
}install
await updater.download('app', '1.2.0');
// ...later, active the latest version:
await updater.install('app', '1.2.0');listRemotes
const remotes = await updater.listRemotes();
for (const bundle of remotes) {
console.log(`${bundle.name}: ${bundle.version}`);
}