Crates.io | tauri-plugin-ota-updater |
lib.rs | tauri-plugin-ota-updater |
version | 2.0.0 |
source | src |
created_at | 2024-08-28 14:28:45.645958 |
updated_at | 2024-10-06 01:29:13.739555 |
description | Over-the-air updates for the Web assets in a Tauri app. |
homepage | |
repository | https://github.com/crabnebula-dev/tauri-plugin-ota-updater |
max_upload_size | |
id | 1354734 |
size | 40,056 |
This plugin provides over-the-air (OTA) updates for the Web assets of a Tauri app.
It leverages the CrabNebula Cloud to ship the assets.
This plugin requires a Rust version of at least 1.75
There are three general methods of installation that we can recommend.
Install the Core plugin by adding the following to your Cargo.toml
file:
src-tauri/Cargo.toml
[dependencies]
tauri-plugin-ota-updater = "2.0.0-rc"
You can install the JavaScript Guest bindings using your preferred JavaScript package manager:
pnpm add @crabnebula/plugin-ota-updater
# or
npm add @crabnebula/plugin-ota-updater
# or
yarn add @crabnebula/plugin-ota-updater
You need a signing key to sign the update bundle. This ensures the integrity of your code can be checked at runtime.
To generate a new signing key run the generate-keypair
command:
npx @crabnebula/ota-updater generate-keypair
Safely store the private key and DO NOT share it with anyone. It will be required to distribute updates later.
The plugin must be configured with the signing public key and CrabNebula Cloud org/app slug pair:
{
"plugins": {
"ota-updater": {
"orgSlug": "my-org",
"appSlug": "my-app",
"pubkey": "<insert-public-key-here>"
}
}
}
To be able to use the updater from the frontend of your application you need to enable the default permission of the plugin in your capability ( e.g. capabilities/default.json
):
{
...
"permissions": [
"ota-updater:default"
]
...
}
To distribute updates, build your frontend assets and then run the upload
command
providing the private key and a CrabNebula Cloud API key as environment variables:
export PRIVATE_KEY=<insert-private-key-here>
export CN_API_KEY=<insert api-key-here>
npx @crabnebula/ota-updater upload
First you need to register the core plugin with Tauri:
src-tauri/src/main.rs
fn main() {
let context = tauri::generate_context!();
let (ota_plugin, context) = tauri_plugin_ota_updater::init(context);
tauri::Builder::default()
.plugin(ota_plugin)
.run(context)
.expect("error while running tauri application");
}
Afterwards all the plugin's APIs are available through the JavaScript guest bindings:
import { check } from "@crabnebula/plugin-ota-updater";
const update = await check()
if (update) {
await update.apply()
location.reload()
}
Code: (c) 2023 - Present - CrabNebula Ltd.
PolyForm-Noncommercial-1.0.0