@onekeyfe/react-native-app-update 6.7.0-alpha.475 → 6.8.0-3
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 +125 -44
- 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
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
**Android APK download, signature verification and installation for OneKey apps.**
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@onekeyfe/react-native-app-update)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+

|
|
10
|
+

|
|
11
|
+

|
|
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
|
-
|
|
15
|
-
|
|
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 {
|
|
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
|
|
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
|
|
29
|
-
notificationTitle: '
|
|
30
|
-
fileSize:
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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.
|
|
3
|
+
"version": "6.8.0-3",
|
|
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"
|