native-update 2.0.0 → 3.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 (304) hide show
  1. package/Readme.md +28 -14
  2. package/android/manifest-additions.xml +28 -0
  3. package/android/src/main/AndroidManifest.xml +3 -7
  4. package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundNotificationManager.kt +21 -13
  5. package/android/src/main/java/com/aoneahsan/nativeupdate/LiveUpdatePlugin.kt +196 -29
  6. package/android/src/main/java/com/aoneahsan/nativeupdate/NativeUpdatePlugin.kt +21 -36
  7. package/cli/AGENTS.md +24 -1
  8. package/cli/CLAUDE.md +24 -1
  9. package/cli/commands/backend-create.js +56 -15
  10. package/cli/commands/bundle-create.js +39 -7
  11. package/cli/commands/monitor.js +72 -51
  12. package/cli/index.js +10 -24
  13. package/cli/package.json +11 -3
  14. package/dist/esm/app-review/app-review-manager.js +0 -1
  15. package/dist/esm/app-review/index.js +0 -1
  16. package/dist/esm/app-review/platform-review-handler.js +0 -1
  17. package/dist/esm/app-review/review-conditions-checker.js +0 -1
  18. package/dist/esm/app-review/review-rate-limiter.js +0 -1
  19. package/dist/esm/app-review/types.js +0 -1
  20. package/dist/esm/app-update/app-update-checker.d.ts +19 -0
  21. package/dist/esm/app-update/app-update-checker.js +19 -1
  22. package/dist/esm/app-update/app-update-installer.d.ts +1 -0
  23. package/dist/esm/app-update/app-update-installer.js +19 -8
  24. package/dist/esm/app-update/app-update-manager.js +0 -1
  25. package/dist/esm/app-update/app-update-notifier.js +0 -1
  26. package/dist/esm/app-update/index.js +0 -1
  27. package/dist/esm/app-update/platform-app-update.js +12 -3
  28. package/dist/esm/app-update/types.js +0 -1
  29. package/dist/esm/background-update/background-scheduler.d.ts +21 -0
  30. package/dist/esm/background-update/background-scheduler.js +47 -25
  31. package/dist/esm/background-update/index.js +0 -1
  32. package/dist/esm/background-update/notification-manager.js +0 -1
  33. package/dist/esm/config/support.js +0 -1
  34. package/dist/esm/core/analytics.d.ts +13 -0
  35. package/dist/esm/core/analytics.js +15 -1
  36. package/dist/esm/core/cache-manager.js +0 -1
  37. package/dist/esm/core/config.d.ts +0 -15
  38. package/dist/esm/core/config.js +0 -4
  39. package/dist/esm/core/errors.d.ts +1 -0
  40. package/dist/esm/core/errors.js +1 -1
  41. package/dist/esm/core/event-emitter.d.ts +0 -3
  42. package/dist/esm/core/event-emitter.js +8 -3
  43. package/dist/esm/core/logger.js +0 -1
  44. package/dist/esm/core/performance.js +0 -1
  45. package/dist/esm/core/plugin-manager.js +3 -1
  46. package/dist/esm/core/security.d.ts +11 -0
  47. package/dist/esm/core/security.js +27 -1
  48. package/dist/esm/core/update-check.d.ts +89 -0
  49. package/dist/esm/core/update-check.js +86 -0
  50. package/dist/esm/definitions.d.ts +11 -12
  51. package/dist/esm/definitions.js +0 -1
  52. package/dist/esm/index.d.ts +3 -2
  53. package/dist/esm/index.js +3 -1
  54. package/dist/esm/live-update/bundle-manager.d.ts +8 -0
  55. package/dist/esm/live-update/bundle-manager.js +20 -1
  56. package/dist/esm/live-update/certificate-pinning.js +0 -1
  57. package/dist/esm/live-update/delta-processor.d.ts +1 -1
  58. package/dist/esm/live-update/delta-processor.js +3 -1
  59. package/dist/esm/live-update/download-manager.js +9 -2
  60. package/dist/esm/live-update/rollout-checker.d.ts +1 -1
  61. package/dist/esm/live-update/rollout-checker.js +5 -6
  62. package/dist/esm/live-update/update-manager.js +0 -1
  63. package/dist/esm/live-update/version-manager.d.ts +0 -12
  64. package/dist/esm/live-update/version-manager.js +43 -95
  65. package/dist/esm/plugin.js +71 -51
  66. package/dist/esm/security/crypto.js +11 -7
  67. package/dist/esm/security/validator.js +0 -1
  68. package/dist/esm/types/rollout.d.ts +91 -0
  69. package/dist/esm/types/rollout.js +25 -0
  70. package/dist/esm/web.d.ts +8 -0
  71. package/dist/esm/web.js +148 -54
  72. package/dist/plugin.cjs.js +1 -2
  73. package/dist/plugin.esm.js +1 -2
  74. package/dist/plugin.js +2 -3
  75. package/docs/AGENTS.md +9 -0
  76. package/docs/CHANGELOG.md +140 -0
  77. package/docs/CLAUDE.md +10 -1
  78. package/docs/DEPLOY_NOTES.md +117 -0
  79. package/docs/MANUAL-TASKS.md +30 -0
  80. package/docs/MARKETING_WEBSITE_TRACKER.md +18 -2
  81. package/docs/MIGRATION.md +83 -0
  82. package/docs/PACKAGES.md +167 -0
  83. package/docs/PERFORMANCE.md +110 -0
  84. package/docs/PROJECT_COMPLETION_TRACKER.md +4 -35
  85. package/docs/README.md +0 -1
  86. package/docs/REMAINING_FEATURES.md +123 -76
  87. package/docs/ROADMAP.md +200 -120
  88. package/docs/SECURITY-IF-REPO-PUBLIC.md +232 -0
  89. package/docs/TESTING_REQUIREMENTS.md +1 -112
  90. package/docs/ai-knowledge-base/00-project-profile.md +38 -0
  91. package/docs/ai-knowledge-base/01-features.md +46 -0
  92. package/docs/ai-knowledge-base/02-routes.md +72 -0
  93. package/docs/ai-knowledge-base/03-tech-stack.md +57 -0
  94. package/docs/ai-knowledge-base/README.md +23 -0
  95. package/docs/analytics-tracking.md +37 -0
  96. package/docs/api/background-update-api.md +14 -1
  97. package/docs/capacitor-official-plugins.md +46 -0
  98. package/docs/capawesome-plugins.md +29 -0
  99. package/docs/deployment/HOSTINGER_DEPLOY.md +75 -34
  100. package/docs/deployment/PRODUCTION-DEPLOY-CHECKLIST.md +184 -0
  101. package/docs/docs-site/plan.md +201 -0
  102. package/docs/docs-site/scope.md +127 -0
  103. package/docs/docs-site/tracker.json +235 -0
  104. package/docs/error-handling-tracking.md +37 -0
  105. package/docs/features/e2e-full-verification/00-overview.md +99 -0
  106. package/docs/features/e2e-full-verification/00-tracker.json +284 -0
  107. package/docs/features/e2e-full-verification/phase01-backend-schema-fixes.md +183 -0
  108. package/docs/features/e2e-full-verification/phase02-test-auth.md +176 -0
  109. package/docs/features/e2e-full-verification/phase03-api-test-coverage.md +63 -0
  110. package/docs/features/e2e-full-verification/phase04-frontend-package-contract-audit.md +73 -0
  111. package/docs/features/e2e-full-verification/phase05-browser-e2e-matrix.md +69 -0
  112. package/docs/features/e2e-full-verification/phase06-deploy-prod-smoke.md +51 -0
  113. package/docs/features/e2e-full-verification/results/phase01-drift-report.md +50 -0
  114. package/docs/features/e2e-full-verification/results/phase03-coverage-matrix.md +215 -0
  115. package/docs/features/e2e-full-verification/results/phase04-frontend-contract.md +139 -0
  116. package/docs/features/e2e-full-verification/results/phase05-e2e-results.md +99 -0
  117. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-01-dashboard.png +0 -0
  118. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-02-signup.png +0 -0
  119. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-03-settings-persisted.png +0 -0
  120. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-04a-app-created.png +0 -0
  121. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-04b-duplicate-bundle-422.png +0 -0
  122. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-05-plan-limit-403.png +0 -0
  123. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-08a-upload-graceful-fail.png +0 -0
  124. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-08b-builds-list.png +0 -0
  125. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-10-rollout-25pct.png +0 -0
  126. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-11-analytics.png +0 -0
  127. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-12-drive-disconnected.png +0 -0
  128. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-13-pricing.png +0 -0
  129. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-14-isolation-403.png +0 -0
  130. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-15a-admin-overview.png +0 -0
  131. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-15b-regular-user-admin-redirect.png +0 -0
  132. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-16a-delete-dialog.png +0 -0
  133. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-17-mobile-375.png +0 -0
  134. package/docs/features/e2e-full-verification/results/route-list.json +1 -0
  135. package/docs/features/queues-and-emails/00-overview.md +41 -0
  136. package/docs/features/queues-and-emails/00-tracker.json +99 -0
  137. package/docs/features/queues-and-emails/phase01-foundation.md +15 -0
  138. package/docs/features/queues-and-emails/phase02-queued-jobs.md +19 -0
  139. package/docs/features/queues-and-emails/phase03-transactional-emails.md +16 -0
  140. package/docs/features/queues-and-emails/phase04-quota-ops.md +17 -0
  141. package/docs/features/queues-and-emails/phase05-async-build-processing-DECISION.md +16 -0
  142. package/docs/features/queues-and-emails/phase06-verify-deploy.md +17 -0
  143. package/docs/guides/testing-guide.md +15 -41
  144. package/docs/package-audit.md +41 -0
  145. package/docs/play-store/ASO-METADATA.md +5 -0
  146. package/docs/play-store/DATA-SAFETY.md +5 -0
  147. package/docs/play-store/DECLARATIONS.md +5 -0
  148. package/docs/play-store/README.md +27 -0
  149. package/docs/play-store/RELEASE-NOTES.md +99 -0
  150. package/docs/play-store/RELEASE-STEPS.md +6 -0
  151. package/docs/play-store/STORE-LISTING.md +7 -0
  152. package/docs/play-store/SUBMISSION-CHECKLIST.md +5 -0
  153. package/docs/production-readiness.md +1 -1
  154. package/docs/project-audit/2026-05-16/00-FINALIZATION-PLAN.md +123 -0
  155. package/docs/project-audit/2026-05-16/01-BATCH-PLAN.md +227 -0
  156. package/docs/project-audit/2026-05-16/02-AUDIT-FINDINGS.md +144 -0
  157. package/docs/project-audit/2026-05-16/sessions/batch-01.md +42 -0
  158. package/docs/project-audit/2026-05-16/sessions/batch-02.md +74 -0
  159. package/docs/project-audit/2026-05-16/sessions/batch-03.md +71 -0
  160. package/docs/project-audit/2026-05-16/sessions/batch-04.md +88 -0
  161. package/docs/project-audit/2026-05-16/sessions/batch-05.md +63 -0
  162. package/docs/project-audit/2026-05-16/sessions/batch-06.md +103 -0
  163. package/docs/project-audit/2026-05-16/sessions/batch-07.md +61 -0
  164. package/docs/project-audit/2026-05-16/sessions/batch-08.md +101 -0
  165. package/docs/project-audit/2026-05-16/sessions/batch-09.md +105 -0
  166. package/docs/project-audit/2026-05-16/sessions/batch-10.md +102 -0
  167. package/docs/project-audit/AUDIT-HISTORY.md +74 -0
  168. package/docs/project-audit/BATCH-PLAN.md +168 -0
  169. package/docs/project-audit/MARKETING-WEBSITE-FINDINGS-2026-05-11.md +73 -0
  170. package/docs/project-audit/PRODUCTION-READINESS-AUDIT-2026-05-08.md +275 -0
  171. package/docs/project-finalization/00-tracker.json +60 -0
  172. package/docs/project-knowledge-base/01-system-overview.md +39 -30
  173. package/docs/project-knowledge-base/02-routes-pages-forms-users.md +87 -81
  174. package/docs/project-knowledge-base/03-tech-stack-modules-services.md +140 -108
  175. package/docs/project-knowledge-base/04-data-models-integrations.md +191 -254
  176. package/docs/project-knowledge-base/05-docs-corpus-inventory.md +83 -20
  177. package/docs/project-knowledge-base/06-operations-testing-legal-content.md +67 -29
  178. package/docs/project-knowledge-base/README.md +27 -14
  179. package/docs/project-profiles/native-update-capacitor-update-platform-project-profile-last-updated-2026-05-19.md +81 -0
  180. package/docs/rules-tracker.md +102 -0
  181. package/docs/security/PRE-LAUNCH-PENTEST-CHECKLIST.md +116 -0
  182. package/docs/server-requirements.md +41 -11
  183. package/docs/social-media-marketing/README.md +81 -0
  184. package/docs/social-media-marketing/posts-batch-01.md +613 -0
  185. package/docs/social-media-marketing/posts-batch-02.md +528 -0
  186. package/docs/social-media-marketing/whatsapp-messages-batch-01.md +458 -0
  187. package/docs/social-media-marketing/whatsapp-status-batch-01.md +355 -0
  188. package/docs/tracking/finalization-2026-05-16-tracker.json +346 -0
  189. package/docs/tracking/full-audit-tracker.json +121 -0
  190. package/docs/tracking/production-readiness-audit-tracker.json +429 -0
  191. package/ios/Plugin/BackgroundUpdate/BackgroundUpdatePlugin.swift +16 -3
  192. package/ios/Plugin/LiveUpdate/LiveUpdatePlugin.swift +71 -47
  193. package/ios/Plugin/NativeUpdatePlugin.swift +14 -9
  194. package/package.json +29 -29
  195. package/cli/node_modules/.yarn-integrity +0 -16
  196. package/cli/node_modules/commander/LICENSE +0 -22
  197. package/cli/node_modules/commander/Readme.md +0 -1148
  198. package/cli/node_modules/commander/esm.mjs +0 -16
  199. package/cli/node_modules/commander/index.js +0 -26
  200. package/cli/node_modules/commander/lib/argument.js +0 -145
  201. package/cli/node_modules/commander/lib/command.js +0 -2179
  202. package/cli/node_modules/commander/lib/error.js +0 -43
  203. package/cli/node_modules/commander/lib/help.js +0 -462
  204. package/cli/node_modules/commander/lib/option.js +0 -329
  205. package/cli/node_modules/commander/lib/suggestSimilar.js +0 -100
  206. package/cli/node_modules/commander/package-support.json +0 -16
  207. package/cli/node_modules/commander/package.json +0 -80
  208. package/cli/node_modules/commander/typings/esm.d.mts +0 -3
  209. package/cli/node_modules/commander/typings/index.d.ts +0 -884
  210. package/cli/yarn.lock +0 -8
  211. package/dist/esm/__tests__/bundle-manager.test.d.ts +0 -1
  212. package/dist/esm/__tests__/bundle-manager.test.js +0 -151
  213. package/dist/esm/__tests__/bundle-manager.test.js.map +0 -1
  214. package/dist/esm/__tests__/config.test.d.ts +0 -1
  215. package/dist/esm/__tests__/config.test.js +0 -70
  216. package/dist/esm/__tests__/config.test.js.map +0 -1
  217. package/dist/esm/__tests__/delta-processor.test.d.ts +0 -1
  218. package/dist/esm/__tests__/delta-processor.test.js +0 -77
  219. package/dist/esm/__tests__/delta-processor.test.js.map +0 -1
  220. package/dist/esm/__tests__/firestore-schema.test.d.ts +0 -1
  221. package/dist/esm/__tests__/firestore-schema.test.js +0 -74
  222. package/dist/esm/__tests__/firestore-schema.test.js.map +0 -1
  223. package/dist/esm/__tests__/integration.test.d.ts +0 -1
  224. package/dist/esm/__tests__/integration.test.js +0 -78
  225. package/dist/esm/__tests__/integration.test.js.map +0 -1
  226. package/dist/esm/__tests__/manifest-reader.test.d.ts +0 -1
  227. package/dist/esm/__tests__/manifest-reader.test.js +0 -271
  228. package/dist/esm/__tests__/manifest-reader.test.js.map +0 -1
  229. package/dist/esm/__tests__/rollout-checker.test.d.ts +0 -1
  230. package/dist/esm/__tests__/rollout-checker.test.js +0 -210
  231. package/dist/esm/__tests__/rollout-checker.test.js.map +0 -1
  232. package/dist/esm/__tests__/security-enforcement.test.d.ts +0 -1
  233. package/dist/esm/__tests__/security-enforcement.test.js +0 -95
  234. package/dist/esm/__tests__/security-enforcement.test.js.map +0 -1
  235. package/dist/esm/__tests__/security.test.d.ts +0 -1
  236. package/dist/esm/__tests__/security.test.js +0 -54
  237. package/dist/esm/__tests__/security.test.js.map +0 -1
  238. package/dist/esm/__tests__/version-manager.test.d.ts +0 -1
  239. package/dist/esm/__tests__/version-manager.test.js +0 -45
  240. package/dist/esm/__tests__/version-manager.test.js.map +0 -1
  241. package/dist/esm/app-review/app-review-manager.js.map +0 -1
  242. package/dist/esm/app-review/index.js.map +0 -1
  243. package/dist/esm/app-review/platform-review-handler.js.map +0 -1
  244. package/dist/esm/app-review/review-conditions-checker.js.map +0 -1
  245. package/dist/esm/app-review/review-rate-limiter.js.map +0 -1
  246. package/dist/esm/app-review/types.js.map +0 -1
  247. package/dist/esm/app-update/app-update-checker.js.map +0 -1
  248. package/dist/esm/app-update/app-update-installer.js.map +0 -1
  249. package/dist/esm/app-update/app-update-manager.js.map +0 -1
  250. package/dist/esm/app-update/app-update-notifier.js.map +0 -1
  251. package/dist/esm/app-update/index.js.map +0 -1
  252. package/dist/esm/app-update/platform-app-update.js.map +0 -1
  253. package/dist/esm/app-update/types.js.map +0 -1
  254. package/dist/esm/background-update/background-scheduler.js.map +0 -1
  255. package/dist/esm/background-update/index.js.map +0 -1
  256. package/dist/esm/background-update/notification-manager.js.map +0 -1
  257. package/dist/esm/config/support.js.map +0 -1
  258. package/dist/esm/core/analytics.js.map +0 -1
  259. package/dist/esm/core/cache-manager.js.map +0 -1
  260. package/dist/esm/core/config.js.map +0 -1
  261. package/dist/esm/core/errors.js.map +0 -1
  262. package/dist/esm/core/event-emitter.js.map +0 -1
  263. package/dist/esm/core/logger.js.map +0 -1
  264. package/dist/esm/core/performance.js.map +0 -1
  265. package/dist/esm/core/plugin-manager.js.map +0 -1
  266. package/dist/esm/core/security.js.map +0 -1
  267. package/dist/esm/definitions.js.map +0 -1
  268. package/dist/esm/firestore/firestore-client.d.ts +0 -109
  269. package/dist/esm/firestore/firestore-client.js +0 -264
  270. package/dist/esm/firestore/firestore-client.js.map +0 -1
  271. package/dist/esm/firestore/index.d.ts +0 -11
  272. package/dist/esm/firestore/index.js +0 -11
  273. package/dist/esm/firestore/index.js.map +0 -1
  274. package/dist/esm/firestore/manifest-reader.d.ts +0 -87
  275. package/dist/esm/firestore/manifest-reader.js +0 -294
  276. package/dist/esm/firestore/manifest-reader.js.map +0 -1
  277. package/dist/esm/firestore/schema.d.ts +0 -507
  278. package/dist/esm/firestore/schema.js +0 -73
  279. package/dist/esm/firestore/schema.js.map +0 -1
  280. package/dist/esm/index.js.map +0 -1
  281. package/dist/esm/live-update/bundle-manager.js.map +0 -1
  282. package/dist/esm/live-update/certificate-pinning.js.map +0 -1
  283. package/dist/esm/live-update/delta-processor.js.map +0 -1
  284. package/dist/esm/live-update/download-manager.js.map +0 -1
  285. package/dist/esm/live-update/rollout-checker.js.map +0 -1
  286. package/dist/esm/live-update/update-manager.js.map +0 -1
  287. package/dist/esm/live-update/version-manager.js.map +0 -1
  288. package/dist/esm/plugin.js.map +0 -1
  289. package/dist/esm/security/crypto.js.map +0 -1
  290. package/dist/esm/security/validator.js.map +0 -1
  291. package/dist/esm/web.js.map +0 -1
  292. package/dist/plugin.cjs.js.map +0 -1
  293. package/dist/plugin.esm.js.map +0 -1
  294. package/dist/plugin.js.map +0 -1
  295. package/docs/FIREBASE_INTEGRATION_TRACKER.md +0 -321
  296. package/docs/FIREBASE_QUERIES_AND_INDEXES_AUDIT.md +0 -221
  297. package/docs/examples/firebase-backend-example.md +0 -27
  298. package/docs/features/laravel-nova-backend/credentials.ignore.md +0 -34
  299. package/docs/guides/no-cost-backend-implementation-plan.md +0 -77
  300. package/docs/guides/no-cost-firestore-google-drive-backend.md +0 -60
  301. package/docs/project-profiles/native-update-capacitor-update-platform-project-profile-last-updated-2026-03-16.md +0 -454
  302. package/docs/project-profiles/native-update-capacitor-update-platform-project-profile-last-updated-2026-03-24.md +0 -66
  303. package/docs/project-profiles/native-update-capacitor-update-platform-project-profile-last-updated-2026-03-25.md +0 -67
  304. /package/docs/{MARKETING_WEBSITE_PLAN.md → archive/MARKETING_WEBSITE_PLAN.md} +0 -0
@@ -2,6 +2,7 @@ import { registerPlugin } from '@capacitor/core';
2
2
  import { SyncStatus, BundleStatus, UpdateErrorCode } from './definitions';
3
3
  import { PluginManager } from './core/plugin-manager';
4
4
  import { NativeUpdateError, ErrorCode } from './core/errors';
5
+ import { checkForUpdate } from './core/update-check';
5
6
  /**
6
7
  * Web implementation of the Native Update Plugin
7
8
  */
@@ -52,8 +53,6 @@ class NativeUpdatePluginWeb {
52
53
  requireSignature: liveUpdate === null || liveUpdate === void 0 ? void 0 : liveUpdate.requireSignature,
53
54
  checksumAlgorithm: liveUpdate === null || liveUpdate === void 0 ? void 0 : liveUpdate.checksumAlgorithm,
54
55
  checkInterval: liveUpdate === null || liveUpdate === void 0 ? void 0 : liveUpdate.checkInterval,
55
- backendType: liveUpdate === null || liveUpdate === void 0 ? void 0 : liveUpdate.backendType,
56
- firestore: liveUpdate === null || liveUpdate === void 0 ? void 0 : liveUpdate.firestore,
57
56
  security: config.security,
58
57
  appStoreId: appUpdate === null || appUpdate === void 0 ? void 0 : appUpdate.appStoreId,
59
58
  packageName: appUpdate === null || appUpdate === void 0 ? void 0 : appUpdate.packageName,
@@ -127,23 +126,33 @@ class NativeUpdatePluginWeb {
127
126
  const downloadManager = this.pluginManager.getDownloadManager();
128
127
  const bundleManager = this.pluginManager.getBundleManager();
129
128
  const blob = await downloadManager.downloadWithRetry(options.url, options.version);
130
- const path = await downloadManager.saveBlob(options.version, blob);
129
+ // Verify checksum/signature against ACTUAL downloaded bytes before
130
+ // persisting. Without this, an attacker who swaps the URL or proxies
131
+ // a tampered bundle can plant arbitrary code and the next set() will
132
+ // activate it. validateBundleData throws on mismatch.
133
+ const bundleData = await blob.arrayBuffer();
134
+ await this.validateBundleData(bundleData, options.checksum, options.signature);
135
+ const validatedBlob = new Blob([bundleData], { type: blob.type });
136
+ const path = await downloadManager.saveBlob(options.version, validatedBlob);
131
137
  const bundleInfo = {
132
138
  bundleId: options.version,
133
139
  version: options.version,
134
140
  path,
135
141
  downloadTime: Date.now(),
136
- size: blob.size,
142
+ size: validatedBlob.size,
137
143
  status: BundleStatus.READY,
138
144
  checksum: options.checksum,
139
145
  signature: options.signature,
140
- verified: false,
146
+ verified: true,
141
147
  };
142
148
  await bundleManager.saveBundleInfo(bundleInfo);
143
149
  return bundleInfo;
144
150
  }
145
151
  async set(bundle) {
146
152
  const bundleManager = this.pluginManager.getBundleManager();
153
+ if (!bundle.verified) {
154
+ throw new NativeUpdateError(ErrorCode.SIGNATURE_INVALID, `Refusing to activate unverified bundle ${bundle.bundleId}`);
155
+ }
147
156
  await bundleManager.setActiveBundle(bundle.bundleId);
148
157
  }
149
158
  async reload() {
@@ -220,16 +229,35 @@ class NativeUpdatePluginWeb {
220
229
  }
221
230
  async validateUpdate(options) {
222
231
  const securityValidator = this.pluginManager.getSecurityValidator();
232
+ const downloadManager = this.pluginManager.getDownloadManager();
223
233
  try {
224
- // Validate checksum
225
- const isValid = await securityValidator.validateChecksum(new ArrayBuffer(0), // Placeholder for bundle data
226
- options.checksum);
234
+ // bundlePath may be either a stored path (`bundles/<id>/bundle.zip`)
235
+ // or a bare bundleId. Normalize to bundleId so we can read the
236
+ // persisted blob.
237
+ const pathMatch = options.bundlePath.match(/bundles\/([^/]+)\/bundle\.zip$/);
238
+ const bundleId = pathMatch ? pathMatch[1] : options.bundlePath;
239
+ const blob = await downloadManager.loadBlob(bundleId);
240
+ if (!blob) {
241
+ return {
242
+ isValid: false,
243
+ error: `Bundle not found at ${options.bundlePath}`,
244
+ };
245
+ }
246
+ const bundleData = await blob.arrayBuffer();
247
+ const checksumValid = await securityValidator.verifyChecksum(bundleData, options.checksum);
248
+ let signatureValid = true;
249
+ if (options.signature) {
250
+ signatureValid = await securityValidator.verifySignature(bundleData, options.signature);
251
+ }
252
+ const sizeValid = options.maxSize
253
+ ? bundleData.byteLength <= options.maxSize
254
+ : true;
227
255
  return {
228
- isValid,
256
+ isValid: checksumValid && signatureValid && sizeValid,
229
257
  details: {
230
- checksumValid: isValid,
231
- signatureValid: true,
232
- sizeValid: true,
258
+ checksumValid,
259
+ signatureValid,
260
+ sizeValid,
233
261
  versionValid: true,
234
262
  },
235
263
  };
@@ -248,33 +276,12 @@ class NativeUpdatePluginWeb {
248
276
  * Check for available updates (convenience wrapper around getLatest + current version)
249
277
  */
250
278
  async checkForUpdate() {
279
+ var _a, _b;
251
280
  const bundleManager = this.pluginManager.getBundleManager();
252
281
  const configManager = this.pluginManager.getConfigManager();
253
- const versionManager = this.pluginManager.getVersionManager();
254
282
  try {
255
283
  const currentBundle = await bundleManager.getActiveBundle();
256
284
  const currentVersion = (currentBundle === null || currentBundle === void 0 ? void 0 : currentBundle.version) || '1.0.0';
257
- const backendType = configManager.get('backendType');
258
- if (backendType === 'firestore') {
259
- const result = (await versionManager.checkForUpdatesAuto(currentVersion, this.getDeviceInfo(currentVersion)));
260
- if (!(result === null || result === void 0 ? void 0 : result.updateAvailable)) {
261
- return {
262
- available: false,
263
- currentVersion,
264
- };
265
- }
266
- return {
267
- available: true,
268
- currentVersion,
269
- latestVersion: result.version,
270
- url: result.bundleUrl,
271
- mandatory: result.mandatory,
272
- notes: result.releaseNotes,
273
- size: result.size,
274
- checksum: result.checksum,
275
- signature: result.signature,
276
- };
277
- }
278
285
  const baseUrl = configManager.get('baseUrl');
279
286
  if (!baseUrl) {
280
287
  return {
@@ -282,32 +289,43 @@ class NativeUpdatePluginWeb {
282
289
  currentVersion,
283
290
  };
284
291
  }
285
- const response = await fetch(`${baseUrl}/updates/latest`, {
286
- method: 'GET',
287
- headers: {
288
- 'Content-Type': 'application/json',
289
- 'X-Current-Version': currentVersion,
290
- },
292
+ // Laravel backend contract: GET /v1/updates/check with X-API-Key,
293
+ // X-Device-ID, X-Current-Version, X-Platform headers. The
294
+ // backend returns either {available: false} or {available: true,
295
+ // version, downloadUrl, checksum, signature, size, ...}.
296
+ const apiKey = configManager.get('apiKey');
297
+ if (!apiKey) {
298
+ throw new NativeUpdateError(ErrorCode.INVALID_CONFIG, 'apiKey is required when using Laravel backend');
299
+ }
300
+ const channel = configManager.get('channel') || 'production';
301
+ const deviceInfo = this.getDeviceInfo(currentVersion);
302
+ // Delegate the wire contract to the shared helper so plugin.ts,
303
+ // version-manager, and background-scheduler all hit the same
304
+ // /v1/updates/check endpoint with identical headers.
305
+ const data = await checkForUpdate(baseUrl, {
306
+ apiKey,
307
+ channel,
308
+ currentVersion,
309
+ deviceId: deviceInfo.deviceId,
310
+ platform: deviceInfo.platform,
311
+ appVersion: deviceInfo.appVersion,
291
312
  });
292
- if (!response.ok) {
313
+ if (!data.available) {
293
314
  return {
294
315
  available: false,
295
316
  currentVersion,
296
317
  };
297
318
  }
298
- const data = await response.json();
299
- const latestVersion = data.version || data.latestVersion;
300
- const isNewer = this.compareVersions(currentVersion, latestVersion) < 0;
301
319
  return {
302
- available: isNewer,
320
+ available: true,
303
321
  currentVersion,
304
- latestVersion: isNewer ? latestVersion : undefined,
305
- url: isNewer ? data.url || data.downloadUrl : undefined,
322
+ latestVersion: data.version,
323
+ url: data.downloadUrl,
306
324
  mandatory: data.mandatory,
307
- notes: data.notes || data.releaseNotes,
325
+ notes: (_a = data.releaseNotes) !== null && _a !== void 0 ? _a : undefined,
308
326
  size: data.size,
309
327
  checksum: data.checksum,
310
- signature: data.signature,
328
+ signature: (_b = data.signature) !== null && _b !== void 0 ? _b : undefined,
311
329
  };
312
330
  }
313
331
  catch (error) {
@@ -422,9 +440,12 @@ class NativeUpdatePluginWeb {
422
440
  return downloadManager.getActiveDownloadCount();
423
441
  }
424
442
  /**
425
- * Compare two semantic versions
443
+ * Compare two semantic versions. Currently unused — the Laravel
444
+ * backend decides update availability server-side. Retained as a
445
+ * helper for advanced consumers that need client-side comparison.
426
446
  * Returns: -1 if v1 < v2, 0 if equal, 1 if v1 > v2
427
447
  */
448
+ // @ts-expect-error retained as a helper for advanced consumers
428
449
  compareVersions(v1, v2) {
429
450
  const parts1 = v1.split('.').map(Number);
430
451
  const parts2 = v2.split('.').map(Number);
@@ -623,4 +644,3 @@ const NativeUpdate = registerPlugin('NativeUpdate', {
623
644
  web: () => new NativeUpdatePluginWeb(),
624
645
  });
625
646
  export { NativeUpdate };
626
- //# sourceMappingURL=plugin.js.map
@@ -26,25 +26,30 @@ export class CryptoUtils {
26
26
  */
27
27
  static async verifySignature(data, signature, publicKey) {
28
28
  try {
29
- // Convert base64 strings to ArrayBuffer
29
+ // Accept either PEM (`-----BEGIN PUBLIC KEY-----...`) or raw base64
30
+ // SPKI. Two callers existed historically and they passed different
31
+ // formats; standardize on PEM-aware parsing here so both work.
32
+ const pemBody = publicKey
33
+ .replace(/-----BEGIN PUBLIC KEY-----/g, '')
34
+ .replace(/-----END PUBLIC KEY-----/g, '')
35
+ .replace(/\s+/g, '');
30
36
  const signatureBuffer = this.base64ToArrayBuffer(signature);
31
- const publicKeyBuffer = this.base64ToArrayBuffer(publicKey);
32
- // Import public key
37
+ const publicKeyBuffer = this.base64ToArrayBuffer(pemBody);
33
38
  const key = await crypto.subtle.importKey('spki', publicKeyBuffer, {
34
39
  name: 'RSA-PSS',
35
40
  hash: 'SHA-256',
36
41
  }, false, ['verify']);
37
- // Prepare data
38
42
  const encoder = new TextEncoder();
39
43
  const dataBuffer = typeof data === 'string' ? encoder.encode(data) : data;
40
- // Verify signature
41
44
  return await crypto.subtle.verify({
42
45
  name: 'RSA-PSS',
43
46
  saltLength: 32,
44
47
  }, key, signatureBuffer, dataBuffer);
45
48
  }
46
49
  catch (error) {
47
- console.error('Signature verification failed:', error);
50
+ // Verification failure must NOT throw — we want a clean false so
51
+ // upstream code can refuse the bundle without crashing.
52
+ void error;
48
53
  return false;
49
54
  }
50
55
  }
@@ -224,4 +229,3 @@ export class CryptoUtils {
224
229
  return btoa(binary);
225
230
  }
226
231
  }
227
- //# sourceMappingURL=crypto.js.map
@@ -140,4 +140,3 @@ export class Validator {
140
140
  return { valid: true };
141
141
  }
142
142
  }
143
- //# sourceMappingURL=validator.js.map
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Rollout + update-check types.
3
+ *
4
+ * These types describe staged-rollout configuration and the response
5
+ * shape the Laravel backend returns from `GET /v1/updates/check`.
6
+ * They were previously co-located with the Firestore schema; v3 of the
7
+ * plugin dropped Firestore as a backend, so the types live here in a
8
+ * backend-neutral location.
9
+ */
10
+ /**
11
+ * A point in time in a rollout config. Accepts ISO-8601 strings (what
12
+ * the Laravel backend returns), epoch milliseconds, or a `Date` for
13
+ * convenience when constructing config in code.
14
+ */
15
+ export type RolloutTimestamp = number | string | Date;
16
+ /**
17
+ * Convert a `RolloutTimestamp` to epoch milliseconds. Throws on a
18
+ * value that doesn't parse — callers are expected to validate before
19
+ * persisting rollout config.
20
+ */
21
+ export declare function toEpochMs(value: RolloutTimestamp): number;
22
+ /**
23
+ * Staged rollout configuration returned by the backend on update checks.
24
+ */
25
+ export interface RolloutConfig {
26
+ enabled: boolean;
27
+ percentage: number;
28
+ startTime: RolloutTimestamp;
29
+ endTime: RolloutTimestamp | null;
30
+ targetSegments?: RolloutTargetSegments;
31
+ schedule?: RolloutSchedule;
32
+ }
33
+ export interface RolloutTargetSegments {
34
+ platforms?: ('ios' | 'android' | 'web')[];
35
+ minAppVersion?: string;
36
+ maxAppVersion?: string;
37
+ deviceIds?: string[];
38
+ regions?: string[];
39
+ }
40
+ export interface RolloutSchedule {
41
+ type: 'immediate' | 'gradual' | 'scheduled';
42
+ gradualSteps?: number[];
43
+ gradualInterval?: number;
44
+ scheduledTime?: RolloutTimestamp;
45
+ }
46
+ /**
47
+ * Device information used for rollout eligibility checks. Sent to the
48
+ * backend on `/v1/updates/check` via `X-Device-ID`, `X-Platform`,
49
+ * `X-App-Version` headers and used locally by `RolloutChecker` for
50
+ * deterministic percentile bucketing.
51
+ */
52
+ export interface DeviceInfo {
53
+ deviceId: string;
54
+ platform: 'ios' | 'android' | 'web';
55
+ appVersion: string;
56
+ bundleVersion: string;
57
+ osVersion: string;
58
+ region?: string;
59
+ locale: string;
60
+ }
61
+ /**
62
+ * Extended, delta-aware LOCAL model of an update check, used by the
63
+ * delta-update pipeline (`delta-processor.ts`).
64
+ *
65
+ * NOTE: this is NOT the raw wire shape. The backend `GET /v1/updates/check`
66
+ * returns `available` / `downloadUrl` / `releaseNotes` (see
67
+ * {@link BackendUpdateCheckResponse} in `core/update-check.ts`), whereas
68
+ * this interface uses `updateAvailable` / `bundleUrl` and adds the
69
+ * client-computed `delta` / `rolloutEligible` fields. Map from the wire
70
+ * response into this shape when driving a delta update.
71
+ */
72
+ export interface UpdateCheckResponse {
73
+ updateAvailable: boolean;
74
+ version?: string;
75
+ bundleUrl?: string;
76
+ minNativeVersion?: string;
77
+ releaseNotes?: string;
78
+ signature?: string;
79
+ checksum?: string;
80
+ mandatory?: boolean;
81
+ size?: number;
82
+ delta?: {
83
+ available: boolean;
84
+ patchUrl?: string;
85
+ patchSize?: number;
86
+ patchChecksum?: string;
87
+ targetChecksum?: string;
88
+ };
89
+ rolloutEligible?: boolean;
90
+ rolloutReason?: string;
91
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Rollout + update-check types.
3
+ *
4
+ * These types describe staged-rollout configuration and the response
5
+ * shape the Laravel backend returns from `GET /v1/updates/check`.
6
+ * They were previously co-located with the Firestore schema; v3 of the
7
+ * plugin dropped Firestore as a backend, so the types live here in a
8
+ * backend-neutral location.
9
+ */
10
+ /**
11
+ * Convert a `RolloutTimestamp` to epoch milliseconds. Throws on a
12
+ * value that doesn't parse — callers are expected to validate before
13
+ * persisting rollout config.
14
+ */
15
+ export function toEpochMs(value) {
16
+ if (typeof value === 'number')
17
+ return value;
18
+ if (value instanceof Date)
19
+ return value.getTime();
20
+ const parsed = new Date(value).getTime();
21
+ if (Number.isNaN(parsed)) {
22
+ throw new Error(`Invalid rollout timestamp: ${String(value)}`);
23
+ }
24
+ return parsed;
25
+ }
package/dist/esm/web.d.ts CHANGED
@@ -11,6 +11,7 @@ export declare class NativeUpdateWeb extends WebPlugin implements NativeUpdateCo
11
11
  private backgroundCheckInterval;
12
12
  private configManager;
13
13
  private isConfigured;
14
+ private downloadedBundleBytes;
14
15
  constructor();
15
16
  /**
16
17
  * Configuration and Core Methods
@@ -107,6 +108,13 @@ export declare class NativeUpdateWeb extends WebPlugin implements NativeUpdateCo
107
108
  * Import ECDSA public key from PEM format
108
109
  */
109
110
  private importPublicKeyECDSA;
111
+ /**
112
+ * Safe localStorage accessor. Returns `null` in environments where
113
+ * `localStorage` isn't available — SSR, Node-only test runners that
114
+ * stub `window` without storage, or sandboxed iframes. All callers
115
+ * MUST tolerate a `null` return and skip persistence.
116
+ */
117
+ private getLocalStorage;
110
118
  private loadStoredData;
111
119
  private saveStoredData;
112
120
  /**