react-native-ota-client 0.1.0 → 0.1.1

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 +61 -24
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -9,7 +9,7 @@ OTA can update JavaScript and bundled assets. Native code, permissions, React Na
9
9
  - Android only; iOS OTA support is not implemented.
10
10
  - React Native 0.88.x, Android New Architecture, and Hermes.
11
11
  - Android min SDK 24.
12
- - A host application with a release-signing/public-key setup and a compatible OTA service.
12
+ - A host application with a release-signing setup and a public verification key.
13
13
 
14
14
  ## Installation
15
15
 
@@ -38,33 +38,68 @@ The package also retains the generated-template `multiply()` example; it is not
38
38
 
39
39
  ## Android configuration
40
40
 
41
- Each host application owns its flavors, IDs, runtime versions, channels, server URL, base version, public verification key, and build-type debug state. Before starting React Native, construct `OtaSdkConfig` with values from the selected app flavor and initialize the SDK:
41
+ Configure the SDK once in the host application's `Application` class. Initialize it in `onCreate()` before calling `loadReactNative()`, and provide the selected bundle path to React Native's host configuration. The SDK's own `BuildConfig.DEBUG` is not the consumer app's build type.
42
42
 
43
43
  ```kotlin
44
- val publicKeyPem = resources.openRawResource(R.raw.ota_publisher_public).use { it.readBytes() }
45
- OtaSdkUpdates.initialize(
46
- this,
47
- OtaSdkConfig(
48
- serverUrl = BuildConfig.OTA_SERVER_URL,
49
- runtimeVersion = BuildConfig.OTA_RUNTIME_VERSION,
50
- channel = BuildConfig.OTA_CHANNEL,
51
- baseVersion = BuildConfig.OTA_BASE_VERSION,
52
- publicKeyPem = publicKeyPem,
53
- allowInsecureHttp = BuildConfig.OTA_ALLOW_INSECURE_HTTP,
54
- isDebugBuild = BuildConfig.DEBUG,
55
- appId = BuildConfig.APPLICATION_ID,
56
- ),
57
- )
58
- OtaSdkUpdates.beginProcess()
44
+ import android.app.Application
45
+ import com.facebook.react.PackageList
46
+ import com.facebook.react.ReactApplication
47
+ import com.facebook.react.ReactHost
48
+ import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative
49
+ import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
50
+ import com.otasdk.OtaSdkUpdates
51
+
52
+ class MainApplication : Application(), ReactApplication {
53
+ override val reactHost: ReactHost by lazy {
54
+ getDefaultReactHost(
55
+ context = applicationContext,
56
+ packageList = PackageList(this).packages,
57
+ jsBundleFilePath = OtaSdkUpdates.bundlePathForReactHost(),
58
+ )
59
+ }
60
+
61
+ override fun onCreate() {
62
+ super.onCreate()
63
+ val publicKeyPem = resources.openRawResource(R.raw.ota_publisher_public).use { it.readBytes() }
64
+ val config = otaSdkConfigForCurrentVariant(publicKeyPem)
65
+ OtaSdkUpdates.initialize(this, config)
66
+ OtaSdkUpdates.beginProcess()
67
+ loadReactNative(this)
68
+ }
69
+ }
59
70
  ```
60
71
 
61
- Do this in the host app's `Application.onCreate()` before `loadReactNative()`. Pass `OtaSdkUpdates.bundlePathForReactHost()` to React Native's host configuration so an activated OTA bundle is selected before the JS runtime starts. The SDK's own `BuildConfig.DEBUG` is not the consumer app's build type.
62
-
63
- The public key resource contains only the verification key. Never package the publisher's signing private key in the app or SDK.
64
-
65
- ### Transport security
72
+ Call `beginProcess()` before `loadReactNative()` so the selected bundle is ready when the JS runtime starts. `bundlePathForReactHost()` returns `null` when the APK bundle should be used.
73
+
74
+ The `ota_publisher_public` Android raw resource contains only the verification key. It may be placed in `src/main/res/raw/` when shared by all variants, or in a flavor-specific source set such as `src/development/res/raw/` when variants use different keys. Never package the publisher's signing private key in the app or SDK.
75
+
76
+ ### Flavor-specific configuration
77
+
78
+ Define each environment as an Android `productFlavor` and provide the SDK values as flavor-specific `BuildConfig` fields. The flavor controls the app ID, runtime version, channel, base version, and public key source set; use distinct runtime versions and channels when environments must receive separate updates. For example:
79
+
80
+ ```groovy
81
+ android {
82
+ flavorDimensions "environment"
83
+ productFlavors {
84
+ development {
85
+ dimension "environment"
86
+ applicationIdSuffix ".dev"
87
+ buildConfigField "String", "OTA_RUNTIME_VERSION", '"rn-0.88-android-dev"'
88
+ buildConfigField "String", "OTA_CHANNEL", '"development"'
89
+ buildConfigField "int", "OTA_BASE_VERSION", "0"
90
+ }
91
+ staging {
92
+ dimension "environment"
93
+ applicationIdSuffix ".staging"
94
+ buildConfigField "String", "OTA_RUNTIME_VERSION", '"rn-0.88-android-staging"'
95
+ buildConfigField "String", "OTA_CHANNEL", '"staging"'
96
+ buildConfigField "int", "OTA_BASE_VERSION", "0"
97
+ }
98
+ }
99
+ }
100
+ ```
66
101
 
67
- Use HTTPS for staging and production, with `allowInsecureHttp = false`. Local development may opt in to HTTP only when the URL host is a local development host supported by the SDK (`localhost`, `127.0.0.1`, `::1`, or Android emulator host `10.0.2.2`). The setting is not a general HTTP override. OTA download URLs must also match the configured server origin.
102
+ The host application's configuration helper should import `com.otasdk.OtaSdkConfig` and build a fully populated config for the selected variant. The `OTA_*` field names and types must match those read by that helper. Set `react.debuggableVariants` for every flavor's debug variants (for example, `developmentDebug` and `stagingDebug`) so React Native uses Metro for those builds. `BuildConfig.DEBUG` is supplied by the selected build type, while `BuildConfig.APPLICATION_ID` includes any flavor suffix.
68
103
 
69
104
  ## Native startup operations
70
105
 
@@ -79,6 +114,8 @@ The SDK autolinks a single `OtaSdkPackage` containing both the sample `OtaSdk` T
79
114
 
80
115
  ## Development and verification
81
116
 
117
+ For implementation architecture, behavioral invariants, suggested change workflow, and verification commands, see the [coding-agent implementation guide](agent.md).
118
+
82
119
  From the SDK package directory, install the locked Yarn dependencies with the bundled Yarn executable and build its example:
83
120
 
84
121
  ```sh
@@ -93,7 +130,7 @@ cd example/android
93
130
  ./gradlew :react-native-ota-client:testDebugUnitTest
94
131
  ```
95
132
 
96
- Build a development debug app to verify native linking and Metro. OTA activation requires a development release APK. The compatible FastAPI service and its deployment instructions are maintained in the standalone [`react-native-ota-server`](https://github.com/arjunnarangali/react-native-ota-server) repository. Configure the host app with its API origin, Android app ID, runtime version, channel, and public verification key; see that repository's README and API docs for the server contract.
133
+ Build a development debug app to verify native linking and Metro. OTA activation requires a release APK; debug builds use Metro and report activation as disabled.
97
134
 
98
135
  ## License
99
136
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ota-client",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Android over-the-air JavaScript updates for React Native applications",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",