@meacore/tauri-easy-updater 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,237 @@
1
+ /**
2
+ * Supported release channels.
3
+ */
4
+ type UpdateChannel = 'stable' | 'beta' | 'alpha' | (string & {});
5
+ /**
6
+ * Supported native installer / package formats.
7
+ */
8
+ type InstallerFormat = 'nsis' | 'msi' | 'dmg' | 'pkg' | 'appimage' | 'deb' | 'rpm';
9
+ /**
10
+ * Structured error codes returned by the Rust plugin or frontend validator.
11
+ */
12
+ type UpdaterErrorCode = 'INVALID_URL' | 'INSECURE_SCHEME' | 'DISALLOWED_HOST' | 'SSRF_BLOCKED' | 'INVALID_INPUT' | 'CONFIG_LOCKED' | 'NETWORK_ERROR' | 'TIMEOUT' | 'RESPONSE_TOO_LARGE' | 'INVALID_MANIFEST' | 'INVALID_VERSION' | 'INVALID_SIGNATURE' | 'MISSING_CHECKSUM' | 'CHECKSUM_MISMATCH' | 'SIZE_MISMATCH' | 'DOWNGRADE_BLOCKED' | 'PLATFORM_NOT_FOUND' | 'DOWNLOAD_CANCELLED' | 'DOWNLOAD_NOT_FOUND' | 'TAMPERING_DETECTED' | 'INSTALL_FAILED' | 'OPEN_URL_FAILED' | 'IO_ERROR' | 'UNKNOWN_ERROR';
13
+ /**
14
+ * Typed Error preserving the structured `code` emitted by the Rust plugin.
15
+ */
16
+ declare class UpdaterError extends Error {
17
+ readonly code: UpdaterErrorCode;
18
+ constructor(code: UpdaterErrorCode, message: string);
19
+ static fromUnknown(err: unknown): UpdaterError;
20
+ }
21
+ /**
22
+ * Individual artifact entry inside a platform section (Manifest v2).
23
+ */
24
+ interface ManifestArtifact {
25
+ format: InstallerFormat;
26
+ url: string;
27
+ sha256?: string;
28
+ size?: number;
29
+ signature?: string;
30
+ }
31
+ /**
32
+ * Platform entry in an update manifest (compatible with v1 and v2).
33
+ */
34
+ interface PlatformManifestEntry {
35
+ url: string;
36
+ sha256?: string;
37
+ size?: number;
38
+ format?: InstallerFormat;
39
+ signature?: string;
40
+ artifacts?: ManifestArtifact[];
41
+ }
42
+ /**
43
+ * Manifest JSON structure supporting both v1 (legacy) and v2 (hardened).
44
+ */
45
+ interface UpdateManifest {
46
+ schema_version?: number;
47
+ version: string;
48
+ channel?: UpdateChannel;
49
+ pub_date?: string;
50
+ notes?: string;
51
+ mandatory?: boolean;
52
+ min_version?: string;
53
+ signature?: string;
54
+ platforms: Record<string, PlatformManifestEntry>;
55
+ }
56
+ /**
57
+ * Artifact metadata returned over IPC (camelCase).
58
+ */
59
+ interface ArtifactInfo {
60
+ format: InstallerFormat | null;
61
+ url: string;
62
+ sha256: string | null;
63
+ size: number | null;
64
+ signature: string | null;
65
+ }
66
+ /**
67
+ * Update check result returned by the Rust plugin or JS fallback (camelCase).
68
+ */
69
+ interface UpdateInfo {
70
+ hasUpdate: boolean;
71
+ currentVersion: string;
72
+ latestVersion: string;
73
+ channel: UpdateChannel;
74
+ mandatory: boolean;
75
+ minVersion: string | null;
76
+ platform: string;
77
+ downloadUrl: string | null;
78
+ sha256: string | null;
79
+ size: number | null;
80
+ format: InstallerFormat | null;
81
+ signature: string | null;
82
+ verifiedManifest: boolean;
83
+ artifacts: ArtifactInfo[];
84
+ releaseNotes: string;
85
+ pubDate: string;
86
+ }
87
+ /**
88
+ * Stage reported during an in-app streaming download.
89
+ */
90
+ type DownloadStage = 'started' | 'downloading' | 'verifying' | 'completed' | 'cancelled' | 'failed';
91
+ /**
92
+ * Real-time download progress event (`easy-updater://download-progress`).
93
+ */
94
+ interface DownloadProgress {
95
+ downloadId: string;
96
+ downloadedBytes: number;
97
+ totalBytes: number | null;
98
+ percent: number | null;
99
+ stage: DownloadStage;
100
+ }
101
+ /**
102
+ * Result of a completed, integrity-verified in-app download.
103
+ */
104
+ interface DownloadResult {
105
+ downloadId: string;
106
+ fileName: string;
107
+ sha256: string;
108
+ size: number;
109
+ format: InstallerFormat;
110
+ verifiedSignature: boolean;
111
+ }
112
+ /**
113
+ * Current host platform details returned by `get_platform`.
114
+ */
115
+ interface PlatformSummary {
116
+ os: string;
117
+ arch: string;
118
+ key: string;
119
+ supportedFormats: InstallerFormat[];
120
+ }
121
+ /**
122
+ * IPC parameters sent to `plugin:easy-updater|check_update`.
123
+ */
124
+ interface CheckUpdateIpcParams {
125
+ currentVersion?: string;
126
+ manifestUrl?: string;
127
+ githubOwner?: string;
128
+ githubRepo?: string;
129
+ manifestAssetName?: string;
130
+ fallbackToReleaseApi?: boolean;
131
+ s3BucketUrl?: string;
132
+ s3ManifestPath?: string;
133
+ headers?: Record<string, string>;
134
+ channel?: UpdateChannel;
135
+ preferredFormat?: InstallerFormat;
136
+ }
137
+ /**
138
+ * Provider interface implemented by GitHub, HTTP, S3, or custom providers.
139
+ */
140
+ interface UpdateProvider {
141
+ readonly type: 'github' | 'http' | 's3' | 'custom';
142
+ /**
143
+ * Stable fingerprint used by hooks to avoid unnecessary re-checks on re-render.
144
+ */
145
+ readonly fingerprint: string;
146
+ /**
147
+ * Optional parameters forwarded to the Rust plugin IPC when not locked in Rust.
148
+ */
149
+ readonly tauriParams?: Omit<CheckUpdateIpcParams, 'currentVersion'>;
150
+ /**
151
+ * Pure JS fallback manifest fetcher (used outside Tauri or by custom providers).
152
+ */
153
+ fetchManifest(): Promise<UpdateManifest>;
154
+ }
155
+ /**
156
+ * High-level lifecycle status of the `UpdaterClient` state machine.
157
+ */
158
+ type UpdaterStatus = 'idle' | 'checking' | 'up-to-date' | 'available' | 'downloading' | 'verifying' | 'ready' | 'installing' | 'error';
159
+ /**
160
+ * Delivery mode for applying updates:
161
+ * - `hybrid` (default): download + verify in-app when checksum/Tauri is available, otherwise open browser URL safely.
162
+ * - `download`: always use in-app verified download + native installer launch.
163
+ * - `browser`: lightweight mode that opens the verified HTTPS URL in the user's browser.
164
+ */
165
+ type UpdateMode = 'hybrid' | 'download' | 'browser';
166
+ /**
167
+ * Immutable snapshot emitted by `UpdaterClient`.
168
+ */
169
+ interface UpdaterState {
170
+ status: UpdaterStatus;
171
+ updateInfo: UpdateInfo | null;
172
+ progress: DownloadProgress | null;
173
+ downloadResult: DownloadResult | null;
174
+ error: UpdaterError | null;
175
+ isDismissed: boolean;
176
+ lastCheckedAt: number | null;
177
+ }
178
+ /**
179
+ * Optional storage adapter for tracking dismissed versions.
180
+ */
181
+ interface DismissStorage {
182
+ getItem(key: string): string | null;
183
+ setItem(key: string, value: string): void;
184
+ removeItem?(key: string): void;
185
+ }
186
+ /**
187
+ * Configuration options for `UpdaterClient` and React hooks.
188
+ */
189
+ interface UpdaterConfig {
190
+ /**
191
+ * Current running app version. Optional in Tauri v2 (auto-detected from Cargo/tauri.conf.json).
192
+ */
193
+ currentVersion?: string;
194
+ /**
195
+ * Update provider. Optional when configured and locked on the Rust side via `Builder`.
196
+ */
197
+ provider?: UpdateProvider;
198
+ /**
199
+ * Preferred release channel (`stable`, `beta`, `alpha`, or custom).
200
+ */
201
+ channel?: UpdateChannel;
202
+ /**
203
+ * Preferred installer format when multiple formats exist for the current OS.
204
+ */
205
+ preferredFormat?: InstallerFormat;
206
+ /**
207
+ * Delivery strategy (`hybrid` | `download` | `browser`).
208
+ * @default 'hybrid'
209
+ */
210
+ mode?: UpdateMode;
211
+ /**
212
+ * Whether to check automatically on startup/mount.
213
+ * @default true
214
+ */
215
+ checkOnStartup?: boolean;
216
+ /**
217
+ * Interval in milliseconds between automatic checks (`0` disables polling).
218
+ * @default 0
219
+ */
220
+ checkIntervalMs?: number;
221
+ /**
222
+ * When true, suppresses storing non-critical check errors in UI state.
223
+ * @default false
224
+ */
225
+ silent?: boolean;
226
+ /**
227
+ * Allow `http://` URLs in pure web fallback mode (local development only).
228
+ * @default false
229
+ */
230
+ allowInsecureHttp?: boolean;
231
+ /**
232
+ * Custom storage for dismissed versions (defaults to `window.sessionStorage`).
233
+ */
234
+ storage?: DismissStorage;
235
+ }
236
+
237
+ export { type ArtifactInfo as A, type CheckUpdateIpcParams as C, type DownloadResult as D, type InstallerFormat as I, type ManifestArtifact as M, type PlatformSummary as P, type UpdaterConfig as U, type UpdaterState as a, type UpdateInfo as b, type UpdateMode as c, type PlatformManifestEntry as d, type UpdateManifest as e, type UpdateChannel as f, type UpdateProvider as g, type DismissStorage as h, type DownloadProgress as i, type DownloadStage as j, UpdaterError as k, type UpdaterErrorCode as l, type UpdaterStatus as m };
package/package.json CHANGED
@@ -1,14 +1,26 @@
1
1
  {
2
2
  "name": "@meacore/tauri-easy-updater",
3
- "version": "0.1.0",
4
- "description": "Hassle-free auto-updates for Tauri apps. No signing keys required.",
3
+ "version": "1.0.0",
4
+ "description": "Secure, hassle-free auto-updates for Tauri v2 apps. Framework-agnostic TypeScript core + optional React hooks and accessible UI.",
5
5
  "author": "Keyler Tamayo <keylertamayo@gmail.com>",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/MeaCore-Enterprise/tauri-easy-updater.git",
9
+ "directory": "packages/core"
10
+ },
11
+ "homepage": "https://github.com/MeaCore-Enterprise/tauri-easy-updater#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/MeaCore-Enterprise/tauri-easy-updater/issues"
14
+ },
6
15
  "keywords": [
7
16
  "tauri",
17
+ "tauri-v2",
8
18
  "updater",
9
19
  "auto-update",
10
20
  "rust",
11
- "electron-alternative"
21
+ "react",
22
+ "ed25519",
23
+ "security"
12
24
  ],
13
25
  "files": [
14
26
  "dist",
@@ -21,23 +33,49 @@
21
33
  "main": "./dist/index.js",
22
34
  "module": "./dist/index.mjs",
23
35
  "types": "./dist/index.d.ts",
36
+ "exports": {
37
+ ".": {
38
+ "types": "./dist/index.d.ts",
39
+ "import": "./dist/index.mjs",
40
+ "require": "./dist/index.js"
41
+ },
42
+ "./react": {
43
+ "types": "./dist/react/index.d.ts",
44
+ "import": "./dist/react/index.mjs",
45
+ "require": "./dist/react/index.js"
46
+ }
47
+ },
24
48
  "sideEffects": false,
25
49
  "license": "MIT",
26
50
  "peerDependencies": {
27
- "react": ">=16.8.0",
28
- "@tauri-apps/api": ">=1.0.0"
51
+ "@tauri-apps/api": "^2.0.0",
52
+ "react": ">=18.0.0"
53
+ },
54
+ "peerDependenciesMeta": {
55
+ "@tauri-apps/api": {
56
+ "optional": true
57
+ },
58
+ "react": {
59
+ "optional": true
60
+ }
29
61
  },
30
62
  "dependencies": {},
31
63
  "devDependencies": {
32
- "@tauri-apps/api": "^1.0.0",
33
- "@types/react": "^18.3.0",
64
+ "@tauri-apps/api": "^2.2.0",
65
+ "@testing-library/react": "^16.1.0",
66
+ "@types/react": "^18.3.12",
67
+ "@types/react-dom": "^18.3.1",
68
+ "jsdom": "^25.0.1",
34
69
  "react": "^18.3.1",
35
- "tsup": "^8.0.0",
36
- "typescript": "^5.6.0"
70
+ "react-dom": "^18.3.1",
71
+ "tsup": "^8.3.5",
72
+ "typescript": "^5.7.2",
73
+ "vitest": "^5.1.2"
37
74
  },
38
75
  "scripts": {
39
76
  "build": "tsup",
40
77
  "typecheck": "tsc --noEmit",
41
- "lint": "eslint \"src/**/*.{ts,tsx}\""
78
+ "lint": "eslint \"src/**/*.{ts,tsx}\"",
79
+ "test": "vitest run"
42
80
  }
43
81
  }