@onekeyfe/react-native-app-update 6.7.0-alpha.466 → 6.8.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.
Files changed (2) hide show
  1. package/README.md +125 -44
  2. package/package.json +4 -1
package/README.md CHANGED
@@ -1,9 +1,38 @@
1
+ <div align="center">
2
+
1
3
  # @onekeyfe/react-native-app-update
2
4
 
3
- Android APK download, signature verification and installation support for OneKey.
4
- The Nitro interface also exposes download progress and downloaded-artifact
5
- cleanup. The application owns update selection, user interaction and deciding
6
- when an installation should proceed.
5
+ **Android APK download, signature verification and installation for OneKey apps.**
6
+
7
+ [![npm](https://img.shields.io/npm/v/%40onekeyfe%2Freact-native-app-update?label=npm&color=4D6BFE)](https://www.npmjs.com/package/@onekeyfe/react-native-app-update)
8
+ [![license](https://img.shields.io/npm/l/%40onekeyfe%2Freact-native-app-update?label=license&color=4D6BFE)](LICENSE)
9
+ ![iOS](https://img.shields.io/badge/iOS-000000?logo=apple&logoColor=white)
10
+ ![Android](https://img.shields.io/badge/Android-3DDC84?logo=android&logoColor=white)
11
+ ![Nitro Modules](https://img.shields.io/badge/Nitro_Modules-4D6BFE)
12
+
13
+ </div>
14
+
15
+ Downloads an Android update APK with progress notifications, verifies its detached
16
+ ASC signature and package identity, and launches the system installer. The module
17
+ owns the APK, partial segments, ASC sidecar, verified-hash state, notifications and
18
+ download cancellation; the application owns release selection and user-facing
19
+ retry decisions. iOS exposes the same API as no-op stubs, so shared code runs on
20
+ both platforms but only Android performs real work.
21
+
22
+ ## Features
23
+
24
+ - **Complete update pipeline** — `downloadAPK`, `downloadASC`, `verifyASC`,
25
+ `verifyAPK`, `installAPK`, each a separate awaited step.
26
+ - **Progress and terminal events** — a numeric listener ID subscribes to
27
+ download progress and completion events; remove it when the owner unmounts.
28
+ - **Signed-release checks** — the ASC signature is bound to the APK bytes, and the
29
+ package's identity, downgrade state and signing certificate are rechecked.
30
+ - **Sanitized failures** — rejected promises and `update/error` events carry only
31
+ `ONEKEY_UPDATE_ERROR:` plus `{ code, step, httpStatus? }`, never URLs or paths.
32
+ - **Bounded artifacts** — a reported APK size above 512 MiB is rejected with
33
+ `SECURITY_REJECTED` before concurrent download workers start.
34
+ - **Lifecycle cleanup** — `clearCache()` waits for an active writer before
35
+ deleting; `clearApkCache()` wipes downloaded `.apk`/`.partial`/ASC artifacts.
7
36
 
8
37
  ## Installation
9
38
 
@@ -11,60 +40,112 @@ when an installation should proceed.
11
40
  yarn add @onekeyfe/react-native-app-update react-native-nitro-modules
12
41
  ```
13
42
 
14
- Rebuild the native application after installation. On iOS, install the application
15
- pods as part of its usual native dependency workflow.
43
+ Install the native peer packages this package links as well:
44
+
45
+ ```sh
46
+ yarn add @onekeyfe/react-native-bundle-crypto @onekeyfe/react-native-native-logger @onekeyfe/react-native-range-downloader
47
+ ```
48
+
49
+ Install the application's iOS pods and rebuild the native application; the
50
+ JavaScript package alone does not register the Nitro hybrid object. The package
51
+ manifest merges Android's `REQUEST_INSTALL_PACKAGES` permission and a
52
+ `FileProvider`, so no manual manifest entry is needed. On iOS the pod also depends
53
+ on `ReactNativeNativeLogger`, so include `@onekeyfe/react-native-native-logger` in
54
+ the application's pods. No `Info.plist` key is required because iOS methods are
55
+ inert.
16
56
 
17
57
  ## Usage
18
58
 
19
59
  ```ts
20
- import { ReactNativeAppUpdate } from '@onekeyfe/react-native-app-update';
60
+ import {
61
+ ReactNativeAppUpdate,
62
+ type DownloadEvent,
63
+ } from '@onekeyfe/react-native-app-update';
64
+
65
+ const listenerId = ReactNativeAppUpdate.addDownloadListener(
66
+ (event: DownloadEvent) => {
67
+ if (event.type === 'update/downloading') {
68
+ console.log(event.progress); // 0–100
69
+ }
70
+ },
71
+ );
21
72
 
22
- const listenerId = ReactNativeAppUpdate.addDownloadListener((event) => {
23
- console.log(event.type, event.progress);
24
- });
73
+ const downloadUrl = 'https://updates.example.com/app.apk';
25
74
 
26
75
  try {
27
76
  await ReactNativeAppUpdate.downloadAPK({
28
- downloadUrl: 'https://updates.example.com/app.apk',
29
- notificationTitle: 'Application update',
30
- fileSize: 123456,
77
+ downloadUrl,
78
+ notificationTitle: 'Downloading update',
79
+ fileSize: 183670673,
31
80
  });
81
+ await ReactNativeAppUpdate.downloadASC({ downloadUrl });
82
+ await ReactNativeAppUpdate.verifyASC({ downloadUrl });
83
+ await ReactNativeAppUpdate.verifyAPK({ downloadUrl });
84
+ await ReactNativeAppUpdate.installAPK({ downloadUrl });
32
85
  } finally {
33
86
  ReactNativeAppUpdate.removeDownloadListener(listenerId);
34
87
  }
35
88
  ```
36
89
 
37
- ## API and platform limits
38
-
39
- - `downloadAPK` downloads an Android update; `downloadASC`, `verifyASC` and
40
- `verifyAPK` provide the signature and verification operations.
41
- - `installAPK` requests Android installation. A completed download is not proof
42
- of verification or installation; callers must perform those separate steps.
43
- - `clearCache` and `clearApkCache` clean cached update artifacts.
44
- - Download listeners return a numeric ID; remove each listener when its owner
45
- finishes or unmounts.
46
-
47
- APK operations on iOS are no-op stubs. This package does not implement App Store
48
- updates. `clearApkCache` does not cancel an in-flight Android download, so callers
49
- must coordinate cleanup with update state.
50
-
51
- For complete parameter and event types, see
52
- [src/ReactNativeAppUpdate.nitro.ts](src/ReactNativeAppUpdate.nitro.ts). Verification
53
- test helpers are also exposed there; applications should keep the production
54
- download and verification flow enabled.
55
-
56
- ## Listener and artifact types
57
-
58
- `AppUpdateDownloadParams` requires `downloadUrl`, `notificationTitle` and
59
- `fileSize`; `AppUpdateFileParams` contains `downloadUrl`. Download callbacks
60
- receive a `DownloadEvent` with string `type`/`message` and numeric `progress`.
61
- These types are exported for application adapters.
62
-
63
- A listener ID belongs to the registration that returned it; retain that exact
64
- ID for `removeDownloadListener`. `clearApkCache()` removes cached APK artifacts
65
- without cancelling an active download. Invoke it through the application's
66
- update-state coordinator, after active work is finished.
90
+ Each step is independent and rejects on its own; the application decides when a
91
+ failed step is retried and keeps the user informed.
92
+
93
+ ## API
94
+
95
+ | Method | Result | Platforms | Description |
96
+ | --- | --- | :-: | --- |
97
+ | `downloadAPK(params)` | `Promise<void>` | Android (iOS no-op) | Downloads an APK. `params` requires `downloadUrl`, `notificationTitle`, `fileSize`. |
98
+ | `downloadASC(params)` | `Promise<void>` | Android (iOS no-op) | Downloads the detached ASC signature next to the APK. |
99
+ | `verifyASC(params)` | `Promise<void>` | Android (iOS no-op) | Binds the signature to the downloaded APK bytes. |
100
+ | `verifyAPK(params)` | `Promise<void>` | Android (iOS no-op) | Checks package identity, downgrade state and signing certificate. |
101
+ | `installAPK(params)` | `Promise<void>` | Android (iOS no-op) | Rechecks the file hash, then launches the Android installer. |
102
+ | `clearCache()` | `Promise<void>` | Android (iOS no-op) | Clears the update cache; can cancel an in-flight download. |
103
+ | `clearApkCache()` | `Promise<void>` | Android (iOS no-op) | Removes cached APK artifacts; does not cancel a download. |
104
+ | `addDownloadListener(callback)` | `number` | Android (iOS no-op) | Subscribes to `DownloadEvent`; returns the listener ID. |
105
+ | `removeDownloadListener(id)` | `void` | Android (iOS no-op) | Removes the listener registered under `id`. |
106
+ | `testVerification()` / `testSkipVerification()` | `Promise<boolean>` | Android | Debug helpers for the verification gate. |
107
+ | `isSkipGpgVerificationAllowed()` | `boolean` | Android | Whether the build allows skipping GPG verification. |
108
+
109
+ `AppUpdateDownloadParams`, `AppUpdateFileParams` and `DownloadEvent` are exported
110
+ for adapters. See [`src/ReactNativeAppUpdate.nitro.ts`](src/ReactNativeAppUpdate.nitro.ts)
111
+ for the full interface and [`docs/SPEC.md`](docs/SPEC.md) for the failure contract.
112
+
113
+ ## Platform support
114
+
115
+ | Capability | iOS | Android | Web |
116
+ | --- | :-: | :-: | :-: |
117
+ | Download APK / ASC | — | ✅ | — |
118
+ | Verify ASC / APK | — | ✅ | — |
119
+ | Install APK | — | ✅ | — |
120
+ | Download progress events | — | ✅ | — |
121
+ | Cache and artifact cleanup | — | ✅ | — |
122
+ | App Store / in-app update | — | — | — |
123
+
124
+ ## Caveats
125
+
126
+ > [!WARNING]
127
+ > The verification steps are not optional in a production flow: a completed
128
+ > download is not proof of verification or installation. Run `verifyASC`,
129
+ > `verifyAPK` and `installAPK` as distinct steps and surface each failure.
130
+
131
+ > [!IMPORTANT]
132
+ > On iOS every method is a no-op stub, including listener registration. Do not use
133
+ > a `downloadAPK` call as an update mechanism on iOS; this package does not
134
+ > implement App Store updates. Only builds installed with
135
+ > `ONEKEY_ALLOW_SKIP_GPG_VERIFICATION` set allow the skip-verification test
136
+ > helpers — never ship a production build that enables them.
137
+
138
+ > [!NOTE]
139
+ > `clearCache()` may cancel an active download, while `clearApkCache()` only wipes
140
+ > artifacts and leaves an in-flight writer running. Coordinate both through the
141
+ > application's update state so a stale writer cannot race a new download.
142
+
143
+ ## References
144
+
145
+ - [Package spec](docs/SPEC.md)
146
+ - [Example page](../../example/react-native/pages/AppUpdateTestPage.tsx)
147
+ - [Changelog](../../CHANGELOG.md)
67
148
 
68
149
  ## License
69
150
 
70
- MIT.
151
+ MIT. See [LICENSE](LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-app-update",
3
- "version": "6.7.0-alpha.466",
3
+ "version": "6.8.0-2",
4
4
  "description": "Android APK download, signature verification and installation for OneKey",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -90,6 +90,9 @@
90
90
  "typescript": "^5.9.2"
91
91
  },
92
92
  "peerDependencies": {
93
+ "@onekeyfe/react-native-bundle-crypto": "*",
94
+ "@onekeyfe/react-native-native-logger": "*",
95
+ "@onekeyfe/react-native-range-downloader": "*",
93
96
  "react": "*",
94
97
  "react-native": "*",
95
98
  "react-native-nitro-modules": "0.37.0"