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
@@ -4,4 +4,3 @@ export { AppUpdateInstaller } from './app-update-installer';
4
4
  export { AppUpdateNotifier } from './app-update-notifier';
5
5
  export { PlatformAppUpdate } from './platform-app-update';
6
6
  export * from './types';
7
- //# sourceMappingURL=index.js.map
@@ -1,5 +1,6 @@
1
1
  import { Logger } from '../core/logger';
2
2
  import { Capacitor } from '@capacitor/core';
3
+ import { SecurityValidator } from '../core/security';
3
4
  export class PlatformAppUpdate {
4
5
  constructor(config) {
5
6
  this.config = config;
@@ -31,13 +32,19 @@ export class PlatformAppUpdate {
31
32
  // Web platform - check configured update URL
32
33
  if (this.config.webUpdateUrl) {
33
34
  try {
35
+ SecurityValidator.validateDownloadUrl(this.config.webUpdateUrl);
34
36
  const response = await fetch(this.config.webUpdateUrl);
35
37
  const data = await response.json();
36
38
  if (data.version && data.version !== versionInfo.currentVersion) {
37
39
  updateInfo.updateAvailable = true;
38
40
  updateInfo.availableVersion = data.version;
39
41
  updateInfo.releaseNotes = data.releaseNotes;
40
- updateInfo.updateURL = data.downloadUrl;
42
+ // Validate downloadUrl scheme — server-controlled value, must
43
+ // not be allowed to smuggle javascript: into a later openUrl.
44
+ if (data.downloadUrl) {
45
+ SecurityValidator.validateStoreUrl(data.downloadUrl);
46
+ updateInfo.updateURL = data.downloadUrl;
47
+ }
41
48
  }
42
49
  }
43
50
  catch (error) {
@@ -85,8 +92,11 @@ export class PlatformAppUpdate {
85
92
  return { url, platform: platform };
86
93
  }
87
94
  async openUrl(url) {
95
+ // Reject any non-HTTPS / non-store URL — protects against
96
+ // `javascript:` payloads handed back from a compromised server.
97
+ SecurityValidator.validateStoreUrl(url);
88
98
  if (typeof window !== 'undefined' && window.open) {
89
- window.open(url, '_blank');
99
+ window.open(url, '_blank', 'noopener,noreferrer');
90
100
  }
91
101
  else {
92
102
  throw new Error('Cannot open URL on this platform');
@@ -126,4 +136,3 @@ export class PlatformAppUpdate {
126
136
  return capabilities;
127
137
  }
128
138
  }
129
- //# sourceMappingURL=platform-app-update.js.map
@@ -9,4 +9,3 @@ export var AppUpdateInstallStatus;
9
9
  AppUpdateInstallStatus[AppUpdateInstallStatus["CANCELED"] = 6] = "CANCELED";
10
10
  AppUpdateInstallStatus[AppUpdateInstallStatus["DOWNLOADED"] = 11] = "DOWNLOADED";
11
11
  })(AppUpdateInstallStatus || (AppUpdateInstallStatus = {}));
12
- //# sourceMappingURL=types.js.map
@@ -22,6 +22,27 @@ export declare class BackgroundScheduler {
22
22
  getStatus(): BackgroundUpdateStatus;
23
23
  performCheck(): Promise<BackgroundCheckResult>;
24
24
  private checkForUpdates;
25
+ /**
26
+ * Check whether a newer NATIVE app-store binary is available.
27
+ *
28
+ * Primary path: the platform `AppUpdateManager` (Play Core / App Store).
29
+ *
30
+ * Fallback path: a GET to `{serverUrl}/app-version`. This is a
31
+ * deliberate **custom-backend extension point**, NOT part of the Native
32
+ * Update (Laravel) backend — that backend ships OTA bundles, it has no
33
+ * concept of the store binary version. A self-hoster who wants
34
+ * server-driven native-update prompts implements this endpoint:
35
+ *
36
+ * ```
37
+ * GET {serverUrl}/app-version
38
+ * X-Current-Version: <installed app version>
39
+ * X-Platform: ios | android | web
40
+ * → 200 { "version": "2.1.0", "priority": 3 } // or { "latestVersion": … }
41
+ * ```
42
+ *
43
+ * If the endpoint is absent the fallback just fails closed
44
+ * (updateAvailable=false). See `docs/api/background-update-api.md`.
45
+ */
25
46
  private checkAppUpdate;
26
47
  private checkLiveUpdate;
27
48
  private sendNotification;
@@ -1,6 +1,7 @@
1
1
  import { BackgroundUpdateType, UpdateErrorCode } from '../definitions';
2
2
  import { Logger } from '../core/logger';
3
3
  import { ConfigManager } from '../core/config';
4
+ import { checkForUpdate } from '../core/update-check';
4
5
  export class BackgroundScheduler {
5
6
  constructor() {
6
7
  this.config = null;
@@ -97,6 +98,27 @@ export class BackgroundScheduler {
97
98
  notificationSent,
98
99
  };
99
100
  }
101
+ /**
102
+ * Check whether a newer NATIVE app-store binary is available.
103
+ *
104
+ * Primary path: the platform `AppUpdateManager` (Play Core / App Store).
105
+ *
106
+ * Fallback path: a GET to `{serverUrl}/app-version`. This is a
107
+ * deliberate **custom-backend extension point**, NOT part of the Native
108
+ * Update (Laravel) backend — that backend ships OTA bundles, it has no
109
+ * concept of the store binary version. A self-hoster who wants
110
+ * server-driven native-update prompts implements this endpoint:
111
+ *
112
+ * ```
113
+ * GET {serverUrl}/app-version
114
+ * X-Current-Version: <installed app version>
115
+ * X-Platform: ios | android | web
116
+ * → 200 { "version": "2.1.0", "priority": 3 } // or { "latestVersion": … }
117
+ * ```
118
+ *
119
+ * If the endpoint is absent the fallback just fails closed
120
+ * (updateAvailable=false). See `docs/api/background-update-api.md`.
121
+ */
100
122
  async checkAppUpdate() {
101
123
  // Use AppUpdateManager if available
102
124
  if (this.deps.appUpdateManager) {
@@ -107,7 +129,7 @@ export class BackgroundScheduler {
107
129
  this.logger.error('Failed to check app update via manager', error);
108
130
  }
109
131
  }
110
- // Fallback: Check via server if configured
132
+ // Fallback: optional custom `/app-version` endpoint (see method JSDoc).
111
133
  const serverUrl = this.configManager.get('baseUrl') || this.configManager.get('serverUrl');
112
134
  if (serverUrl) {
113
135
  try {
@@ -145,6 +167,7 @@ export class BackgroundScheduler {
145
167
  };
146
168
  }
147
169
  async checkLiveUpdate() {
170
+ var _a;
148
171
  // Get current bundle version
149
172
  let currentVersion = '1.0.0';
150
173
  if (this.deps.bundleManager) {
@@ -154,7 +177,7 @@ export class BackgroundScheduler {
154
177
  currentVersion = activeBundle.version;
155
178
  }
156
179
  }
157
- catch (_a) {
180
+ catch (_b) {
158
181
  // Use default version
159
182
  }
160
183
  }
@@ -175,31 +198,31 @@ export class BackgroundScheduler {
175
198
  this.logger.error('Failed to check live update via VersionManager', error);
176
199
  }
177
200
  }
178
- // Fallback: Check via server if configured
201
+ // Fallback: check the Native Update backend directly via the shared
202
+ // /v1/updates/check contract (same endpoint plugin.checkForUpdate() and
203
+ // VersionManager use). The old `/updates/latest` path was never served
204
+ // by the backend, so this fallback previously always failed silently.
179
205
  const serverUrl = this.configManager.get('baseUrl') || this.configManager.get('serverUrl');
180
- if (serverUrl) {
206
+ const apiKey = this.configManager.get('apiKey');
207
+ if (serverUrl && apiKey) {
181
208
  try {
182
- const response = await fetch(`${serverUrl}/updates/latest`, {
183
- method: 'GET',
184
- headers: {
185
- 'Content-Type': 'application/json',
186
- 'X-Current-Version': currentVersion,
187
- },
209
+ const channel = this.configManager.get('channel') || 'production';
210
+ const data = await checkForUpdate(serverUrl, {
211
+ apiKey,
212
+ channel,
213
+ currentVersion,
214
+ deviceId: 'web-client',
215
+ platform: this.getPlatform(),
216
+ appVersion: currentVersion,
188
217
  });
189
- if (response.ok) {
190
- const data = await response.json();
191
- const latestVersion = data.version || data.latestVersion;
192
- const updateAvailable = latestVersion &&
193
- this.compareVersions(currentVersion, latestVersion) < 0;
194
- return {
195
- available: updateAvailable,
196
- version: latestVersion,
197
- url: updateAvailable ? data.url : undefined,
198
- notes: data.notes || data.releaseNotes,
199
- size: data.size,
200
- checksum: data.checksum,
201
- };
202
- }
218
+ return {
219
+ available: data.available,
220
+ version: data.version,
221
+ url: data.available ? data.downloadUrl : undefined,
222
+ notes: (_a = data.releaseNotes) !== null && _a !== void 0 ? _a : undefined,
223
+ size: data.size,
224
+ checksum: data.checksum,
225
+ };
203
226
  }
204
227
  catch (error) {
205
228
  this.logger.error('Failed to check live update via server', error);
@@ -307,4 +330,3 @@ export class BackgroundScheduler {
307
330
  return 0;
308
331
  }
309
332
  }
310
- //# sourceMappingURL=background-scheduler.js.map
@@ -1,3 +1,2 @@
1
1
  export { BackgroundScheduler } from './background-scheduler';
2
2
  export { NotificationManager } from './notification-manager';
3
- //# sourceMappingURL=index.js.map
@@ -86,4 +86,3 @@ export class NotificationManager {
86
86
  return (_a = this.preferences.vibrationEnabled) !== null && _a !== void 0 ? _a : true;
87
87
  }
88
88
  }
89
- //# sourceMappingURL=notification-manager.js.map
@@ -7,4 +7,3 @@ export const SUPPORT_CONFIG = {
7
7
  label: 'Support the Project',
8
8
  description: 'Help us keep native-update free and improving',
9
9
  };
10
- //# sourceMappingURL=support.js.map
@@ -60,6 +60,19 @@ export declare class Analytics {
60
60
  /**
61
61
  * Console analytics provider for development
62
62
  */
63
+ /**
64
+ * Default analytics provider that writes events directly to the
65
+ * browser/native console. Production apps should swap this for a real
66
+ * provider (Firebase Analytics, Amplitude, Sentry, …) via
67
+ * `setAnalyticsProvider()`.
68
+ *
69
+ * The two `console.*` calls below are intentional and on-brand for this
70
+ * class — `ConsoleAnalyticsProvider` IS the "send to console" sink. They
71
+ * are NOT a violation of the centralized-logger rule (which targets
72
+ * incidental logging, not analytics dispatch). Do not replace with the
73
+ * Logger — it would create a circular relationship between analytics
74
+ * and logging surfaces.
75
+ */
63
76
  export declare class ConsoleAnalyticsProvider implements AnalyticsProvider {
64
77
  private userId?;
65
78
  private properties;
@@ -111,14 +111,29 @@ export class Analytics {
111
111
  /**
112
112
  * Console analytics provider for development
113
113
  */
114
+ /**
115
+ * Default analytics provider that writes events directly to the
116
+ * browser/native console. Production apps should swap this for a real
117
+ * provider (Firebase Analytics, Amplitude, Sentry, …) via
118
+ * `setAnalyticsProvider()`.
119
+ *
120
+ * The two `console.*` calls below are intentional and on-brand for this
121
+ * class — `ConsoleAnalyticsProvider` IS the "send to console" sink. They
122
+ * are NOT a violation of the centralized-logger rule (which targets
123
+ * incidental logging, not analytics dispatch). Do not replace with the
124
+ * Logger — it would create a circular relationship between analytics
125
+ * and logging surfaces.
126
+ */
114
127
  export class ConsoleAnalyticsProvider {
115
128
  constructor() {
116
129
  this.properties = {};
117
130
  }
118
131
  async trackEvent(event) {
132
+ // ConsoleAnalyticsProvider intentionally writes to console — see class header.
119
133
  console.log('[Analytics]', event.type, Object.assign(Object.assign({}, event), { userId: this.userId, properties: this.properties }));
120
134
  }
121
135
  async trackError(error, context) {
136
+ // ConsoleAnalyticsProvider intentionally writes to console — see class header.
122
137
  console.error('[Analytics Error]', {
123
138
  error: error.message,
124
139
  stack: error.stack,
@@ -134,4 +149,3 @@ export class ConsoleAnalyticsProvider {
134
149
  this.properties = Object.assign(Object.assign({}, this.properties), properties);
135
150
  }
136
151
  }
137
- //# sourceMappingURL=analytics.js.map
@@ -272,4 +272,3 @@ export class CacheManager {
272
272
  }
273
273
  }
274
274
  }
275
- //# sourceMappingURL=cache-manager.js.map
@@ -1,11 +1,6 @@
1
1
  import type { Filesystem } from '@capacitor/filesystem';
2
2
  import type { Preferences } from '@capacitor/preferences';
3
3
  import type { UpdateStrategy, ChecksumAlgorithm, SecurityConfig } from '../definitions';
4
- import type { FirestoreConfig } from '../firestore/schema';
5
- /**
6
- * Backend type for update checking
7
- */
8
- export type BackendType = 'http' | 'firestore';
9
4
  export interface PluginConfig {
10
5
  filesystem?: typeof Filesystem;
11
6
  preferences?: typeof Preferences;
@@ -44,16 +39,6 @@ export interface PluginConfig {
44
39
  packageName?: string;
45
40
  webReviewUrl?: string;
46
41
  minimumVersion?: string;
47
- /**
48
- * Backend type for update checking
49
- * - 'http': Traditional HTTP server (default)
50
- * - 'firestore': Google Firestore (free tier)
51
- */
52
- backendType?: BackendType;
53
- /**
54
- * Firestore configuration (required if backendType is 'firestore')
55
- */
56
- firestore?: FirestoreConfig;
57
42
  /**
58
43
  * Enable delta updates (binary patching)
59
44
  * Reduces download size by 50-90%
@@ -49,9 +49,6 @@ export class ConfigManager {
49
49
  packageName: '',
50
50
  webReviewUrl: '',
51
51
  minimumVersion: '1.0.0',
52
- // Firestore backend configuration
53
- backendType: 'http',
54
- firestore: null,
55
52
  enableDeltaUpdates: true,
56
53
  enableStagedRollouts: true,
57
54
  };
@@ -91,4 +88,3 @@ export class ConfigManager {
91
88
  return !!(this.config.filesystem && this.config.preferences);
92
89
  }
93
90
  }
94
- //# sourceMappingURL=config.js.map
@@ -7,6 +7,7 @@ export declare enum ErrorCode {
7
7
  DOWNLOAD_FAILED = "DOWNLOAD_FAILED",
8
8
  DOWNLOAD_TIMEOUT = "DOWNLOAD_TIMEOUT",
9
9
  INVALID_URL = "INVALID_URL",
10
+ INSECURE_URL = "INSECURE_URL",
10
11
  UNAUTHORIZED_HOST = "UNAUTHORIZED_HOST",
11
12
  BUNDLE_TOO_LARGE = "BUNDLE_TOO_LARGE",
12
13
  CHECKSUM_MISMATCH = "CHECKSUM_MISMATCH",
@@ -11,6 +11,7 @@ export var ErrorCode;
11
11
  ErrorCode["DOWNLOAD_FAILED"] = "DOWNLOAD_FAILED";
12
12
  ErrorCode["DOWNLOAD_TIMEOUT"] = "DOWNLOAD_TIMEOUT";
13
13
  ErrorCode["INVALID_URL"] = "INVALID_URL";
14
+ ErrorCode["INSECURE_URL"] = "INSECURE_URL";
14
15
  ErrorCode["UNAUTHORIZED_HOST"] = "UNAUTHORIZED_HOST";
15
16
  ErrorCode["BUNDLE_TOO_LARGE"] = "BUNDLE_TOO_LARGE";
16
17
  // Validation errors
@@ -82,4 +83,3 @@ export class UpdateError extends NativeUpdateError {
82
83
  this.name = 'UpdateError';
83
84
  }
84
85
  }
85
- //# sourceMappingURL=errors.js.map
@@ -1,6 +1,3 @@
1
- /**
2
- * Centralized event emitter for the Native Update plugin
3
- */
4
1
  export declare class EventEmitter {
5
2
  private static instance;
6
3
  private listeners;
@@ -1,6 +1,12 @@
1
1
  /**
2
- * Centralized event emitter for the Native Update plugin
2
+ * Centralized event emitter for the Native Update plugin.
3
+ *
4
+ * Listener errors are sent to the plugin Logger so they respect the
5
+ * runtime log-level switch and the secret-redaction filter — never raw
6
+ * console.* calls. See src/core/logger.ts.
3
7
  */
8
+ import { Logger } from './logger';
9
+ const logger = new Logger('NativeUpdate.EventEmitter');
4
10
  export class EventEmitter {
5
11
  constructor() {
6
12
  this.listeners = new Map();
@@ -41,7 +47,7 @@ export class EventEmitter {
41
47
  listener(data);
42
48
  }
43
49
  catch (error) {
44
- console.error(`Error in event listener for ${eventName}:`, error);
50
+ logger.error(`Error in event listener for ${eventName}`, error);
45
51
  }
46
52
  });
47
53
  }
@@ -72,4 +78,3 @@ export class EventEmitter {
72
78
  return Array.from(this.listeners.keys());
73
79
  }
74
80
  }
75
- //# sourceMappingURL=event-emitter.js.map
@@ -106,4 +106,3 @@ export class Logger {
106
106
  this.logWithLevel(LogLevel.ERROR, message, errorData);
107
107
  }
108
108
  }
109
- //# sourceMappingURL=logger.js.map
@@ -151,4 +151,3 @@ export class PerformanceMonitor {
151
151
  };
152
152
  }
153
153
  }
154
- //# sourceMappingURL=performance.js.map
@@ -56,6 +56,9 @@ export class PluginManager {
56
56
  await this.bundleManager.initialize();
57
57
  this.downloadManager = new DownloadManager();
58
58
  await this.downloadManager.initialize();
59
+ // Bundle manager needs the download manager so deleteBundle can
60
+ // also remove the on-disk blob (otherwise old bundles leak forever).
61
+ this.bundleManager.setDownloadManager(this.downloadManager);
59
62
  this.versionManager = new VersionManager();
60
63
  await this.versionManager.initialize();
61
64
  this.appUpdateManager = new AppUpdateManager({
@@ -217,4 +220,3 @@ export class PluginManager {
217
220
  });
218
221
  }
219
222
  }
220
- //# sourceMappingURL=plugin-manager.js.map
@@ -8,6 +8,17 @@ export declare class SecurityValidator {
8
8
  * Validate URL is HTTPS
9
9
  */
10
10
  static validateUrl(url: string): boolean;
11
+ /**
12
+ * Reject any URL that is not HTTPS (or known native-app schemes
13
+ * `market:` / `itms-apps:` for opening the app store). Throws so
14
+ * callers can't silently fall through to a `javascript:` payload.
15
+ */
16
+ static validateDownloadUrl(url: string): void;
17
+ /**
18
+ * Validate URL whose only acceptable schemes are HTTPS, `market:` (Play
19
+ * Store), or `itms-apps:` (App Store). Used by `openAppStore`.
20
+ */
21
+ static validateStoreUrl(url: string): void;
11
22
  /**
12
23
  * Validate checksum format
13
24
  */
@@ -24,6 +24,33 @@ export class SecurityValidator {
24
24
  return false;
25
25
  }
26
26
  }
27
+ /**
28
+ * Reject any URL that is not HTTPS (or known native-app schemes
29
+ * `market:` / `itms-apps:` for opening the app store). Throws so
30
+ * callers can't silently fall through to a `javascript:` payload.
31
+ */
32
+ static validateDownloadUrl(url) {
33
+ if (!this.validateUrl(url)) {
34
+ throw new ValidationError(ErrorCode.INSECURE_URL, `Refusing non-HTTPS URL: ${url}`);
35
+ }
36
+ }
37
+ /**
38
+ * Validate URL whose only acceptable schemes are HTTPS, `market:` (Play
39
+ * Store), or `itms-apps:` (App Store). Used by `openAppStore`.
40
+ */
41
+ static validateStoreUrl(url) {
42
+ let parsed;
43
+ try {
44
+ parsed = new URL(url);
45
+ }
46
+ catch (_a) {
47
+ throw new ValidationError(ErrorCode.INSECURE_URL, `Invalid URL: ${url}`);
48
+ }
49
+ const allowed = ['https:', 'market:', 'itms-apps:'];
50
+ if (!allowed.includes(parsed.protocol)) {
51
+ throw new ValidationError(ErrorCode.INSECURE_URL, `Refusing URL scheme ${parsed.protocol}`);
52
+ }
53
+ }
27
54
  /**
28
55
  * Validate checksum format
29
56
  */
@@ -335,4 +362,3 @@ export class SecurityValidator {
335
362
  }
336
363
  }
337
364
  }
338
- //# sourceMappingURL=security.js.map
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Single source of truth for the Native Update backend update-check
3
+ * contract.
4
+ *
5
+ * Every "does the Laravel backend have a newer bundle for me?" call in the
6
+ * plugin funnels through {@link checkForUpdate} so the wire shape — path,
7
+ * headers, query, and response fields — is defined in exactly one place.
8
+ * Before this helper existed, three modules each rolled their own request
9
+ * against paths the backend does not serve (`/check`, `/updates/latest`),
10
+ * so background + version-manager update checks silently never worked.
11
+ *
12
+ * ## Wire contract (implemented by `UpdateController@check` in the backend)
13
+ *
14
+ * ```
15
+ * GET {baseUrl}/v1/updates/check?channel={channel}
16
+ * X-API-Key: nu_app_… (required; ValidateApiKey middleware → 401 without it)
17
+ * X-Device-ID: stable per-device hash (required; 400 without it)
18
+ * X-Current-Version: the currently-installed bundle version
19
+ * X-Platform: ios | android | web
20
+ * X-App-Version: native app version (optional)
21
+ * ```
22
+ *
23
+ * Response (200):
24
+ * ```jsonc
25
+ * // no update:
26
+ * { "available": false, "message": "…" }
27
+ * // update available:
28
+ * {
29
+ * "available": true,
30
+ * "version": "1.2.3",
31
+ * "bundleId": "…uuid…",
32
+ * "downloadUrl": "https://…signed…",
33
+ * "checksum": "…sha256…",
34
+ * "signature": "…|null",
35
+ * "size": 123456,
36
+ * "mandatory": false,
37
+ * "releaseNotes": "…|null",
38
+ * "minNativeVersion": "…|null",
39
+ * "expiresAt": "ISO-8601"
40
+ * }
41
+ * ```
42
+ *
43
+ * Custom backends must return these exact field names — see
44
+ * `docs/server-requirements.md`.
45
+ */
46
+ /** Request inputs for a single backend update check. */
47
+ export interface UpdateCheckRequest {
48
+ /** API key issued by the dashboard; sent as `X-API-Key`. Required. */
49
+ apiKey: string;
50
+ /** Release channel (`production` | `staging` | `development`). */
51
+ channel: string;
52
+ /** Currently-installed bundle version; sent as `X-Current-Version`. */
53
+ currentVersion: string;
54
+ /** Stable device identifier; sent as `X-Device-ID`. Required by the backend. */
55
+ deviceId: string;
56
+ /** Device platform (`ios` | `android` | `web`); sent as `X-Platform`. */
57
+ platform: string;
58
+ /** Native app version; sent as `X-App-Version` when present. */
59
+ appVersion?: string;
60
+ /** Optional abort signal so callers can time the request out. */
61
+ signal?: AbortSignal;
62
+ }
63
+ /**
64
+ * Normalized response from `GET {baseUrl}/v1/updates/check`. Field names
65
+ * mirror the backend JSON verbatim (already camelCase on the wire).
66
+ */
67
+ export interface BackendUpdateCheckResponse {
68
+ available: boolean;
69
+ version?: string;
70
+ bundleId?: string;
71
+ downloadUrl?: string;
72
+ checksum?: string;
73
+ signature?: string | null;
74
+ size?: number;
75
+ mandatory?: boolean;
76
+ releaseNotes?: string | null;
77
+ minNativeVersion?: string | null;
78
+ expiresAt?: string;
79
+ message?: string;
80
+ }
81
+ /**
82
+ * Perform one update check against the Native Update backend.
83
+ *
84
+ * Returns `{ available: false }` for any non-2xx response (the backend
85
+ * uses 200 for "no update" and reserves 4xx for auth/validation failures,
86
+ * which are non-actionable for an update check). Network failures reject —
87
+ * callers decide whether to swallow or surface them.
88
+ */
89
+ export declare function checkForUpdate(baseUrl: string, req: UpdateCheckRequest): Promise<BackendUpdateCheckResponse>;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Single source of truth for the Native Update backend update-check
3
+ * contract.
4
+ *
5
+ * Every "does the Laravel backend have a newer bundle for me?" call in the
6
+ * plugin funnels through {@link checkForUpdate} so the wire shape — path,
7
+ * headers, query, and response fields — is defined in exactly one place.
8
+ * Before this helper existed, three modules each rolled their own request
9
+ * against paths the backend does not serve (`/check`, `/updates/latest`),
10
+ * so background + version-manager update checks silently never worked.
11
+ *
12
+ * ## Wire contract (implemented by `UpdateController@check` in the backend)
13
+ *
14
+ * ```
15
+ * GET {baseUrl}/v1/updates/check?channel={channel}
16
+ * X-API-Key: nu_app_… (required; ValidateApiKey middleware → 401 without it)
17
+ * X-Device-ID: stable per-device hash (required; 400 without it)
18
+ * X-Current-Version: the currently-installed bundle version
19
+ * X-Platform: ios | android | web
20
+ * X-App-Version: native app version (optional)
21
+ * ```
22
+ *
23
+ * Response (200):
24
+ * ```jsonc
25
+ * // no update:
26
+ * { "available": false, "message": "…" }
27
+ * // update available:
28
+ * {
29
+ * "available": true,
30
+ * "version": "1.2.3",
31
+ * "bundleId": "…uuid…",
32
+ * "downloadUrl": "https://…signed…",
33
+ * "checksum": "…sha256…",
34
+ * "signature": "…|null",
35
+ * "size": 123456,
36
+ * "mandatory": false,
37
+ * "releaseNotes": "…|null",
38
+ * "minNativeVersion": "…|null",
39
+ * "expiresAt": "ISO-8601"
40
+ * }
41
+ * ```
42
+ *
43
+ * Custom backends must return these exact field names — see
44
+ * `docs/server-requirements.md`.
45
+ */
46
+ /**
47
+ * Perform one update check against the Native Update backend.
48
+ *
49
+ * Returns `{ available: false }` for any non-2xx response (the backend
50
+ * uses 200 for "no update" and reserves 4xx for auth/validation failures,
51
+ * which are non-actionable for an update check). Network failures reject —
52
+ * callers decide whether to swallow or surface them.
53
+ */
54
+ export async function checkForUpdate(baseUrl, req) {
55
+ var _a, _b, _c;
56
+ const url = `${baseUrl.replace(/\/$/, '')}/v1/updates/check?channel=${encodeURIComponent(req.channel)}`;
57
+ const headers = {
58
+ 'Content-Type': 'application/json',
59
+ 'X-API-Key': req.apiKey,
60
+ 'X-Device-ID': req.deviceId,
61
+ 'X-Current-Version': req.currentVersion,
62
+ 'X-Platform': req.platform,
63
+ };
64
+ if (req.appVersion) {
65
+ headers['X-App-Version'] = req.appVersion;
66
+ }
67
+ const response = await fetch(url, { method: 'GET', headers, signal: req.signal });
68
+ if (!response.ok) {
69
+ return { available: false };
70
+ }
71
+ const data = (await response.json());
72
+ return {
73
+ available: Boolean(data.available),
74
+ version: data.version,
75
+ bundleId: data.bundleId,
76
+ downloadUrl: data.downloadUrl,
77
+ checksum: data.checksum,
78
+ signature: (_a = data.signature) !== null && _a !== void 0 ? _a : undefined,
79
+ size: data.size,
80
+ mandatory: data.mandatory,
81
+ releaseNotes: (_b = data.releaseNotes) !== null && _b !== void 0 ? _b : undefined,
82
+ minNativeVersion: (_c = data.minNativeVersion) !== null && _c !== void 0 ? _c : undefined,
83
+ expiresAt: data.expiresAt,
84
+ message: data.message,
85
+ };
86
+ }