native-update 5.0.1 → 5.0.2

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.
package/README.md CHANGED
@@ -38,7 +38,7 @@ are available as an HTTP API for CI and coding agents.
38
38
 
39
39
  | | |
40
40
  |---|---|
41
- | **Version** | `5.0.1` |
41
+ | **Version** | `5.0.2` |
42
42
  | **License** | Proprietary — free to use in your apps ([Native Update License](https://unpkg.com/native-update@latest/LICENSE)) |
43
43
  | **Node** | `>=24.16.0` (install + CLI toolchain) |
44
44
  | **Platforms** | iOS 16+ (implementation pending device proof) · Android 8.0+ (API 26) · Web |
@@ -543,7 +543,7 @@ indexed at [`/raw/manifest.json`](https://nativeupdate-docs.aoneahsan.com/raw/ma
543
543
  <a id="changelog"></a>
544
544
  ## 🔄 Changelog&nbsp;[#](#changelog)
545
545
 
546
- Current release: **`5.0.1`**. Android now reads packaged Capacitor configuration, and flexible Play updates wait for a user-confirmed restart. The Capacitor 9 migration landed in v5; see the [migration guide](https://unpkg.com/native-update@latest/docs/MIGRATION.md). In 4.4.5, `set()` gained `applyOn: 'next-start'`, which stages a bundle for the next cold start instead of reloading the running app. Before that, 4.4.4: `--ota-tag` reads `versionName` only from a real statement in `build.gradle`
546
+ Current release: **`5.0.2`**. CLI ZIP creation no longer depends on the vulnerable archive chain. Android now reads packaged Capacitor configuration, and flexible Play updates wait for a user-confirmed restart. The Capacitor 9 migration landed in v5; see the [migration guide](https://unpkg.com/native-update@latest/docs/MIGRATION.md). In 4.4.5, `set()` gained `applyOn: 'next-start'`, which stages a bundle for the next cold start instead of reloading the running app. Before that, 4.4.4: `--ota-tag` reads `versionName` only from a real statement in `build.gradle`
547
547
  (comments and message strings are skipped, `versionName appVersionName` is followed to its value). **`4.4.3`**: Android logs `Built <id> from a N-byte patch` when an update arrives as a `NUDELTA/1`
548
548
  patch, so you can see deltas working on a device. No API change.
549
549
 
@@ -30,7 +30,7 @@ android {
30
30
  defaultConfig {
31
31
  minSdkVersion project.minSdkVersion
32
32
  versionCode 1
33
- versionName "5.0.1"
33
+ versionName "5.0.2"
34
34
  testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
35
35
  // Shipped to every consuming app's R8 run (ISSUE-09).
36
36
  consumerProguardFiles 'consumer-rules.pro'
@@ -62,7 +62,7 @@ class LiveUpdatePlugin(
62
62
 
63
63
  companion object {
64
64
  /** This plugin's version, sent as X-Sdk-Version. Kept equal to package.json by tests/sdk-version.test.ts. */
65
- const val SDK_VERSION = "5.0.1"
65
+ const val SDK_VERSION = "5.0.2"
66
66
 
67
67
  // SharedPreferences keys. Kept as constants so A2 (boot-time
68
68
  // re-verification) and A3 (crash-loop auto-rollback) stay in sync
@@ -2,8 +2,8 @@ import chalk from 'chalk';
2
2
  import fs from 'fs/promises';
3
3
  import path from 'path';
4
4
  import crypto from 'crypto';
5
- import { ZipArchive } from 'archiver';
6
- import { createWriteStream, createReadStream } from 'fs';
5
+ import { createReadStream } from 'fs';
6
+ import { archiveDirectory } from '../lib/archive-directory.js';
7
7
  import { fileURLToPath } from 'url';
8
8
  import { dirname, join } from 'path';
9
9
 
@@ -87,24 +87,7 @@ export async function createBundle(webDir, options) {
87
87
  console.log(chalk.gray(` Channel: ${options.channel}`));
88
88
  console.log(chalk.gray(` Output: ${bundlePath}`));
89
89
 
90
- // Create zip archive
91
- const output = createWriteStream(bundlePath);
92
- const archive = new ZipArchive({
93
- zlib: { level: 9 }
94
- });
95
-
96
- const archivePromise = new Promise((resolve, reject) => {
97
- output.on('close', resolve);
98
- archive.on('error', reject);
99
- });
100
-
101
- archive.pipe(output);
102
-
103
- // Add all files from web directory
104
- archive.directory(webDir, false);
105
-
106
- await archive.finalize();
107
- await archivePromise;
90
+ await archiveDirectory(webDir, bundlePath);
108
91
 
109
92
  // Stream the bundle through the SHA-256 hasher so a 100MB+ bundle
110
93
  // doesn't get slurped into RAM all at once. Size comes from fs.stat.
@@ -142,4 +125,4 @@ export async function createBundle(webDir, options) {
142
125
  console.error(chalk.red('❌ Failed to create bundle:'), error.message);
143
126
  process.exit(1);
144
127
  }
145
- }
128
+ }
@@ -3,8 +3,7 @@ import crypto from 'crypto';
3
3
  import fs from 'fs/promises';
4
4
  import path from 'path';
5
5
  import zlib from 'zlib';
6
- import { ZipArchive } from 'archiver';
7
- import { createWriteStream } from 'fs';
6
+ import { archiveDirectory } from '../lib/archive-directory.js';
8
7
 
9
8
  /**
10
9
  * Reads the entries of a ZIP (an APK) from its central directory. Handles stored and deflated entries, which is
@@ -85,15 +84,7 @@ export async function createFlutterPatch(apkPath, options) {
85
84
  await fs.cp(path.resolve(options.assets), stage, { recursive: true, filter: (src) => !src.includes(`${path.sep}lib${path.sep}`) });
86
85
  }
87
86
 
88
- await new Promise((resolve, reject) => {
89
- const output = createWriteStream(out);
90
- const zip = new ZipArchive({ zlib: { level: 9 } });
91
- output.on('close', resolve);
92
- zip.on('error', reject);
93
- zip.pipe(output);
94
- zip.directory(stage, false);
95
- zip.finalize();
96
- });
87
+ await archiveDirectory(stage, out);
97
88
  } finally {
98
89
  await fs.rm(stage, { recursive: true, force: true });
99
90
  }
@@ -2,8 +2,8 @@ import chalk from 'chalk';
2
2
  import fs from 'fs/promises';
3
3
  import path from 'path';
4
4
  import os from 'os';
5
- import { ZipArchive } from 'archiver';
6
- import { createWriteStream, createReadStream } from 'fs';
5
+ import { createReadStream } from 'fs';
6
+ import { archiveDirectory } from '../lib/archive-directory.js';
7
7
 
8
8
  /** Where the hosted backend lives unless told otherwise. */
9
9
  export const DEFAULT_SERVER = 'https://nativeupdatebe.aoneahsan.com';
@@ -223,17 +223,12 @@ export async function resolveBundle(target) {
223
223
 
224
224
  console.log(chalk.gray(` Zipping ${target}…`));
225
225
 
226
- const output = createWriteStream(zipPath);
227
- const archive = new ZipArchive({ zlib: { level: 9 } });
228
- const done = new Promise((resolve, reject) => {
229
- output.on('close', resolve);
230
- archive.on('error', reject);
231
- });
232
-
233
- archive.pipe(output);
234
- archive.directory(target, false);
235
- await archive.finalize();
236
- await done;
226
+ try {
227
+ await archiveDirectory(target, zipPath);
228
+ } catch (error) {
229
+ await fs.rm(tempDir, { recursive: true, force: true });
230
+ throw error;
231
+ }
237
232
 
238
233
  return {
239
234
  path: zipPath,
@@ -0,0 +1,54 @@
1
+ import fs from 'node:fs/promises';
2
+ import { createWriteStream } from 'node:fs';
3
+ import path from 'node:path';
4
+ import yazl from 'yazl';
5
+
6
+ /** Write a directory as a ZIP without following links outside the selected build. */
7
+ export async function archiveDirectory(source, destination) {
8
+ const root = path.resolve(source);
9
+ const files = [];
10
+ const emptyDirectories = [];
11
+
12
+ async function collect(directory) {
13
+ const entries = (await fs.readdir(directory, { withFileTypes: true }))
14
+ .sort((a, b) => a.name.localeCompare(b.name));
15
+ if (entries.length === 0 && directory !== root) {
16
+ emptyDirectories.push(path.relative(root, directory).split(path.sep).join('/'));
17
+ }
18
+ for (const entry of entries) {
19
+ const fullPath = path.join(directory, entry.name);
20
+ if (entry.isSymbolicLink()) {
21
+ throw new Error(`Refusing to archive a symbolic link: ${path.relative(root, fullPath)}`);
22
+ }
23
+ if (entry.isDirectory()) {
24
+ await collect(fullPath);
25
+ } else if (entry.isFile()) {
26
+ files.push({ fullPath, name: path.relative(root, fullPath).split(path.sep).join('/') });
27
+ } else {
28
+ throw new Error(`Unsupported archive entry: ${path.relative(root, fullPath)}`);
29
+ }
30
+ }
31
+ }
32
+
33
+ await collect(root);
34
+ const zip = new yazl.ZipFile();
35
+ for (const name of emptyDirectories) zip.addEmptyDirectory(name);
36
+ for (const { fullPath, name } of files) zip.addFile(fullPath, name, { compressionLevel: 9 });
37
+
38
+ try {
39
+ await new Promise((resolve, reject) => {
40
+ const output = createWriteStream(destination);
41
+ zip.outputStream.on('error', (error) => {
42
+ output.destroy();
43
+ reject(error);
44
+ });
45
+ output.on('error', reject);
46
+ output.on('close', resolve);
47
+ zip.outputStream.pipe(output);
48
+ zip.end();
49
+ });
50
+ } catch (error) {
51
+ await fs.rm(destination, { force: true });
52
+ throw error;
53
+ }
54
+ }
package/cli/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "native-update": "./index.js"
12
12
  },
13
13
  "dependencies": {
14
- "archiver": "^8.0.0",
14
+ "yazl": "^3.3.1",
15
15
  "chalk": "^6.0.1",
16
16
  "commander": "^15.1.0",
17
17
  "express": "^5.3.0",
@@ -61,7 +61,7 @@ import type { AppIdentity } from '../types/app-identity';
61
61
  * This plugin's version, sent as `X-Sdk-Version`. Kept equal to package.json (and to the Kotlin and Swift
62
62
  * constants) by tests/sdk-version.test.ts.
63
63
  */
64
- export declare const SDK_VERSION = "5.0.1";
64
+ export declare const SDK_VERSION = "5.0.2";
65
65
  /** Request inputs for a single backend update check. */
66
66
  export interface UpdateCheckRequest {
67
67
  /** API key issued by the dashboard; sent as `X-API-Key`. Required. */
@@ -60,7 +60,7 @@
60
60
  * This plugin's version, sent as `X-Sdk-Version`. Kept equal to package.json (and to the Kotlin and Swift
61
61
  * constants) by tests/sdk-version.test.ts.
62
62
  */
63
- export const SDK_VERSION = '5.0.1';
63
+ export const SDK_VERSION = '5.0.2';
64
64
  /**
65
65
  * Perform one update check against the Native Update backend.
66
66
  *