react-native-bspatch 1.1.3 → 2.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.
Files changed (89) hide show
  1. package/README.md +47 -52
  2. package/android/src/main/java/vn/reactnativebspatch/BsPatchModule.kt +15 -102
  3. package/android/src/main/java/vn/reactnativebspatch/OtaBundleResolver.kt +21 -1
  4. package/cpp/bsdiff/bspatch.c +1 -0
  5. package/ios/OtaBundleResolver.swift +16 -1
  6. package/ios/RNBsPatch.mm +61 -154
  7. package/lib/commonjs/NativeBsPatch.js.map +1 -1
  8. package/lib/commonjs/index.js +4 -4
  9. package/lib/commonjs/index.js.map +1 -1
  10. package/lib/commonjs/ota/OtaProvider.js +26 -22
  11. package/lib/commonjs/ota/OtaProvider.js.map +1 -1
  12. package/lib/commonjs/ota/otaAssetResolver.js +8 -2
  13. package/lib/commonjs/ota/otaAssetResolver.js.map +1 -1
  14. package/lib/commonjs/ota/otaCore.js +89 -141
  15. package/lib/commonjs/ota/otaCore.js.map +1 -1
  16. package/lib/commonjs/ota/otaLogger.js +0 -2
  17. package/lib/commonjs/ota/otaLogger.js.map +1 -1
  18. package/lib/commonjs/ota/otaMetadata.js +18 -7
  19. package/lib/commonjs/ota/otaMetadata.js.map +1 -1
  20. package/lib/commonjs/ota/storage/GitHubRawStorage.js +3 -1
  21. package/lib/commonjs/ota/storage/GitHubRawStorage.js.map +1 -1
  22. package/lib/commonjs/ota/types.js +1 -10
  23. package/lib/commonjs/ota/types.js.map +1 -1
  24. package/lib/module/NativeBsPatch.js.map +1 -1
  25. package/lib/module/index.js +1 -1
  26. package/lib/module/index.js.map +1 -1
  27. package/lib/module/ota/OtaProvider.js +26 -22
  28. package/lib/module/ota/OtaProvider.js.map +1 -1
  29. package/lib/module/ota/otaAssetResolver.js +8 -2
  30. package/lib/module/ota/otaAssetResolver.js.map +1 -1
  31. package/lib/module/ota/otaCore.js +88 -139
  32. package/lib/module/ota/otaCore.js.map +1 -1
  33. package/lib/module/ota/otaLogger.js +0 -2
  34. package/lib/module/ota/otaLogger.js.map +1 -1
  35. package/lib/module/ota/otaMetadata.js +18 -7
  36. package/lib/module/ota/otaMetadata.js.map +1 -1
  37. package/lib/module/ota/storage/GitHubRawStorage.js +3 -1
  38. package/lib/module/ota/storage/GitHubRawStorage.js.map +1 -1
  39. package/lib/module/ota/types.js +0 -9
  40. package/lib/module/ota/types.js.map +1 -1
  41. package/lib/typescript/NativeBsPatch.d.ts +3 -15
  42. package/lib/typescript/NativeBsPatch.d.ts.map +1 -1
  43. package/lib/typescript/index.d.ts +1 -1
  44. package/lib/typescript/index.d.ts.map +1 -1
  45. package/lib/typescript/ota/OtaProvider.d.ts.map +1 -1
  46. package/lib/typescript/ota/otaAssetResolver.d.ts.map +1 -1
  47. package/lib/typescript/ota/otaCore.d.ts +5 -42
  48. package/lib/typescript/ota/otaCore.d.ts.map +1 -1
  49. package/lib/typescript/ota/otaLogger.d.ts +1 -3
  50. package/lib/typescript/ota/otaLogger.d.ts.map +1 -1
  51. package/lib/typescript/ota/otaMetadata.d.ts +2 -2
  52. package/lib/typescript/ota/otaMetadata.d.ts.map +1 -1
  53. package/lib/typescript/ota/types.d.ts +18 -54
  54. package/lib/typescript/ota/types.d.ts.map +1 -1
  55. package/package.json +3 -6
  56. package/react-native-bspatch.podspec +0 -1
  57. package/src/NativeBsPatch.ts +3 -16
  58. package/src/index.ts +1 -1
  59. package/src/ota/OtaProvider.tsx +24 -23
  60. package/src/ota/otaAssetResolver.ts +5 -2
  61. package/src/ota/otaCore.ts +118 -176
  62. package/src/ota/otaLogger.ts +0 -2
  63. package/src/ota/otaMetadata.ts +18 -8
  64. package/src/ota/storage/GitHubRawStorage.ts +1 -1
  65. package/src/ota/types.ts +18 -57
  66. package/tools/build_ota.sh +356 -177
  67. package/tools/setup_project.js +95 -11
  68. package/tools/update_registry.js +24 -28
  69. package/tools/{upload_ota_custom.sh → upload_ota.sh} +33 -114
  70. package/lib/commonjs/crypto-js.d.js +0 -2
  71. package/lib/commonjs/crypto-js.d.js.map +0 -1
  72. package/lib/commonjs/ota/storage/CustomStorage.js +0 -160
  73. package/lib/commonjs/ota/storage/CustomStorage.js.map +0 -1
  74. package/lib/commonjs/ota/storage/GitHubReleaseStorage.js +0 -99
  75. package/lib/commonjs/ota/storage/GitHubReleaseStorage.js.map +0 -1
  76. package/lib/module/crypto-js.d.js +0 -2
  77. package/lib/module/crypto-js.d.js.map +0 -1
  78. package/lib/module/ota/storage/CustomStorage.js +0 -154
  79. package/lib/module/ota/storage/CustomStorage.js.map +0 -1
  80. package/lib/module/ota/storage/GitHubReleaseStorage.js +0 -93
  81. package/lib/module/ota/storage/GitHubReleaseStorage.js.map +0 -1
  82. package/lib/typescript/ota/storage/CustomStorage.d.ts +0 -12
  83. package/lib/typescript/ota/storage/CustomStorage.d.ts.map +0 -1
  84. package/lib/typescript/ota/storage/GitHubReleaseStorage.d.ts +0 -20
  85. package/lib/typescript/ota/storage/GitHubReleaseStorage.d.ts.map +0 -1
  86. package/src/crypto-js.d.ts +0 -1
  87. package/src/ota/storage/CustomStorage.ts +0 -166
  88. package/src/ota/storage/GitHubReleaseStorage.ts +0 -103
  89. package/tools/bsdiff +0 -0
package/src/ota/types.ts CHANGED
@@ -28,15 +28,6 @@ export enum OtaUpdateMode {
28
28
  BACKGROUND_DOWNLOAD = 'BACKGROUND_DOWNLOAD',
29
29
  }
30
30
 
31
- export enum OtaStorageType {
32
- /** Custom storage server (primary) */
33
- CUSTOM = 'CUSTOM',
34
- /** GitHub Releases — public or token-authenticated */
35
- GITHUB = 'GITHUB',
36
- /** GitHub Raw repository storage */
37
- GITHUB_RAW = 'GITHUB_RAW',
38
- }
39
-
40
31
  export type OtaPatch = {
41
32
  /** Unique ID: `v{from}-to-v{to}` */
42
33
  id: string;
@@ -60,10 +51,10 @@ export type OtaPatch = {
60
51
  minAppVersion?: string;
61
52
  /** URL for full bundle download (fallback when patch fails) */
62
53
  fullBundleUrl?: string;
63
- /** Whether the patch/bundle is gzip compressed */
64
- compressed?: boolean;
65
- /** HMAC-SHA256 signature for security verification */
54
+ /** RSA/ECDSA SHA-256 signature (base64) of the patch file */
66
55
  signature?: string;
56
+ /** RSA/ECDSA SHA-256 signature (base64) of the resulting bundle */
57
+ bundleSignature?: string;
67
58
  /** Whether this update is mandatory */
68
59
  mandatory?: boolean;
69
60
  /** URL to the asset manifest JSON for this version */
@@ -100,6 +91,10 @@ export type OtaMetadata = {
100
91
  previousVersions: number[];
101
92
  rollbackCount: number;
102
93
  lastLaunchSuccessful: boolean;
94
+ /** Native app version the OTA bundles were built for; native resolver drops OTA state when it changes */
95
+ appVersion?: string;
96
+ /** Versions that crashed on boot and were rolled back; never re-applied */
97
+ failedVersions?: number[];
103
98
  };
104
99
 
105
100
  export type OtaMetrics = {
@@ -136,59 +131,25 @@ export type OtaConfig = {
136
131
 
137
132
  /** Telemetry: structured event callback for analytics */
138
133
  onEvent?: OtaEventCallback;
139
- /** Public key for signature verification (base64) */
134
+ /**
135
+ * SPKI public key (PEM or base64) for RSA/ECDSA signature verification.
136
+ * When set, patches and bundles without a valid signature are rejected.
137
+ */
140
138
  publicKey?: string;
141
- /** Base URL for the shared hashed asset store (e.g. a GitHub release URL) */
142
- assetBaseUrl?: string;
143
-
144
- /** Storage strategy */
145
- storageType?: OtaStorageType;
146
-
147
- /** GitHub Releases configuration (used when storageType === GITHUB) */
148
- githubRelease?: {
149
- /** Owner / repo in the format "owner/repo" */
150
- repo: string;
151
- /** Tag name of the release to fetch updates from */
152
- tag: string;
153
- /**
154
- * Path inside the release where ota_registry.json lives.
155
- * If your release contains the file at root, set to "ota_registry.json".
156
- * If it's inside a folder "ota/", set to "ota/ota_registry.json".
157
- */
158
- registryPath?: string;
159
- /**
160
- * Optional GitHub personal access token for private repos or higher rate limits.
161
- * For public repos this is optional.
162
- */
163
- token?: string;
164
- /**
165
- * Asset base URL for content-addressed assets.
166
- * Supports CDN URLs (jsDelivr, GitHub raw) or a custom base.
167
- * Example: "https://cdn.jsdelivr.net/gh/owner/repo@tag/assets"
168
- */
169
- assetBaseUrl?: string;
170
- };
171
139
 
172
- /** Custom storage server configuration */
140
+ /**
141
+ * Static storage layout read by the default provider: `${baseUrl}/${baseFolder}/...`.
142
+ * Any static host/CDN serving the same layout works (e.g. a public bucket).
143
+ * Read-only and public: never put upload credentials here, they ship inside the app.
144
+ */
173
145
  customServer?: {
146
+ /** e.g. https://raw.githubusercontent.com/<owner>/<repo>/<branch> */
174
147
  baseUrl: string;
175
- username: string;
176
- password: string;
177
148
  channel: string;
178
149
  baseFolder?: string;
179
- useMinio?: boolean;
180
- /** Override default API endpoints for non-standard servers */
181
- endpoints?: {
182
- /** Auth login endpoint (default: /public/authen/login) */
183
- login?: string;
184
- /** Generate download link endpoint (default: /api/minio/gen-download-link) */
185
- genDownloadLink?: string;
186
- /** Direct file download endpoint (default: /files/downloadStreamFile) */
187
- downloadFile?: string;
188
- };
189
150
  };
190
151
 
191
- /** Storage provider instance (optional, defaults to CustomStorageProvider) */
152
+ /** Storage provider instance (optional, defaults to GitHubRawStorageProvider) */
192
153
  storage?: OtaStorageProvider;
193
154
  };
194
155