native-update 1.4.9 → 3.1.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 (265) hide show
  1. package/Readme.md +35 -9
  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/BackgroundUpdatePlugin.kt +15 -0
  6. package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateWorker.kt +23 -7
  7. package/android/src/main/java/com/aoneahsan/nativeupdate/LiveUpdatePlugin.kt +346 -31
  8. package/android/src/main/java/com/aoneahsan/nativeupdate/NativeUpdatePlugin.kt +32 -34
  9. package/android/src/main/java/com/aoneahsan/nativeupdate/NotificationActionReceiver.kt +10 -1
  10. package/android/src/main/java/com/aoneahsan/nativeupdate/SecurityManager.kt +18 -18
  11. package/cli/AGENTS.md +43 -0
  12. package/cli/CLAUDE.md +65 -0
  13. package/cli/commands/backend-create.js +56 -15
  14. package/cli/commands/bundle-create.js +39 -7
  15. package/cli/commands/monitor.js +72 -51
  16. package/cli/index.js +10 -24
  17. package/cli/package.json +11 -3
  18. package/dist/esm/app-review/app-review-manager.js +0 -1
  19. package/dist/esm/app-review/index.js +0 -1
  20. package/dist/esm/app-review/platform-review-handler.js +0 -1
  21. package/dist/esm/app-review/review-conditions-checker.js +0 -1
  22. package/dist/esm/app-review/review-rate-limiter.js +0 -1
  23. package/dist/esm/app-review/types.js +0 -1
  24. package/dist/esm/app-update/app-update-checker.js +0 -1
  25. package/dist/esm/app-update/app-update-installer.d.ts +1 -0
  26. package/dist/esm/app-update/app-update-installer.js +19 -8
  27. package/dist/esm/app-update/app-update-manager.js +0 -1
  28. package/dist/esm/app-update/app-update-notifier.js +0 -1
  29. package/dist/esm/app-update/index.js +0 -1
  30. package/dist/esm/app-update/platform-app-update.js +12 -3
  31. package/dist/esm/app-update/types.js +0 -1
  32. package/dist/esm/background-update/background-scheduler.js +0 -1
  33. package/dist/esm/background-update/index.js +0 -1
  34. package/dist/esm/background-update/notification-manager.js +0 -1
  35. package/dist/esm/config/support.js +0 -1
  36. package/dist/esm/core/analytics.d.ts +13 -0
  37. package/dist/esm/core/analytics.js +15 -1
  38. package/dist/esm/core/cache-manager.js +0 -1
  39. package/dist/esm/core/config.d.ts +6 -30
  40. package/dist/esm/core/config.js +1 -8
  41. package/dist/esm/core/errors.d.ts +1 -0
  42. package/dist/esm/core/errors.js +1 -1
  43. package/dist/esm/core/event-emitter.d.ts +0 -3
  44. package/dist/esm/core/event-emitter.js +8 -3
  45. package/dist/esm/core/logger.js +0 -1
  46. package/dist/esm/core/performance.js +0 -1
  47. package/dist/esm/core/plugin-manager.js +3 -1
  48. package/dist/esm/core/security.d.ts +22 -3
  49. package/dist/esm/core/security.js +46 -7
  50. package/dist/esm/definitions.d.ts +13 -40
  51. package/dist/esm/definitions.js +0 -1
  52. package/dist/esm/index.d.ts +3 -4
  53. package/dist/esm/index.js +3 -3
  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.d.ts +36 -5
  60. package/dist/esm/live-update/download-manager.js +70 -24
  61. package/dist/esm/live-update/rollout-checker.d.ts +1 -1
  62. package/dist/esm/live-update/rollout-checker.js +5 -6
  63. package/dist/esm/live-update/update-manager.d.ts +12 -1
  64. package/dist/esm/live-update/update-manager.js +38 -11
  65. package/dist/esm/live-update/version-manager.d.ts +9 -12
  66. package/dist/esm/live-update/version-manager.js +40 -68
  67. package/dist/esm/plugin.js +82 -89
  68. package/dist/esm/security/crypto.js +11 -7
  69. package/dist/esm/security/validator.js +0 -1
  70. package/dist/esm/types/rollout.d.ts +85 -0
  71. package/dist/esm/types/rollout.js +25 -0
  72. package/dist/esm/web.d.ts +26 -1
  73. package/dist/esm/web.js +214 -75
  74. package/dist/plugin.cjs.js +1 -2
  75. package/dist/plugin.esm.js +1 -2
  76. package/dist/plugin.js +2 -3
  77. package/docs/AGENTS.md +38 -0
  78. package/docs/CHANGELOG.md +275 -0
  79. package/docs/CLAUDE.md +101 -0
  80. package/docs/MANUAL-TASKS.md +17 -0
  81. package/docs/MARKETING_WEBSITE_TRACKER.md +18 -2
  82. package/docs/MIGRATION.md +170 -0
  83. package/docs/PACKAGES.md +167 -0
  84. package/docs/PERFORMANCE.md +110 -0
  85. package/docs/PROJECT_COMPLETION_TRACKER.md +4 -35
  86. package/docs/README.md +12 -2
  87. package/docs/REMAINING_FEATURES.md +123 -76
  88. package/docs/ROADMAP.md +200 -120
  89. package/docs/SECURITY-IF-REPO-PUBLIC.md +232 -0
  90. package/docs/TESTING_REQUIREMENTS.md +1 -112
  91. package/docs/ai-knowledge-base/00-project-profile.md +38 -0
  92. package/docs/ai-knowledge-base/01-features.md +46 -0
  93. package/docs/ai-knowledge-base/02-routes.md +72 -0
  94. package/docs/ai-knowledge-base/03-tech-stack.md +57 -0
  95. package/docs/ai-knowledge-base/README.md +23 -0
  96. package/docs/analytics-tracking.md +37 -0
  97. package/docs/capacitor-official-plugins.md +46 -0
  98. package/docs/capawesome-plugins.md +29 -0
  99. package/docs/deployment/HOSTINGER_DEPLOY.md +370 -0
  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/laravel-nova-backend/ASSESSMENT-SUMMARY.md +96 -0
  106. package/docs/features/laravel-nova-backend/IMPLEMENTATION-PLAN.md +504 -0
  107. package/docs/features/laravel-nova-backend/progress-tracker.json +184 -0
  108. package/docs/guides/testing-guide.md +15 -41
  109. package/docs/package-audit.md +41 -0
  110. package/docs/play-store/ASO-METADATA.md +5 -0
  111. package/docs/play-store/DATA-SAFETY.md +5 -0
  112. package/docs/play-store/DECLARATIONS.md +5 -0
  113. package/docs/play-store/README.md +27 -0
  114. package/docs/play-store/RELEASE-NOTES.md +99 -0
  115. package/docs/play-store/RELEASE-STEPS.md +6 -0
  116. package/docs/play-store/STORE-LISTING.md +7 -0
  117. package/docs/play-store/SUBMISSION-CHECKLIST.md +5 -0
  118. package/docs/production-readiness.md +1 -1
  119. package/docs/project-audit/2026-05-16/00-FINALIZATION-PLAN.md +123 -0
  120. package/docs/project-audit/2026-05-16/01-BATCH-PLAN.md +227 -0
  121. package/docs/project-audit/2026-05-16/02-AUDIT-FINDINGS.md +144 -0
  122. package/docs/project-audit/2026-05-16/sessions/batch-01.md +42 -0
  123. package/docs/project-audit/2026-05-16/sessions/batch-02.md +74 -0
  124. package/docs/project-audit/2026-05-16/sessions/batch-03.md +71 -0
  125. package/docs/project-audit/2026-05-16/sessions/batch-04.md +88 -0
  126. package/docs/project-audit/2026-05-16/sessions/batch-05.md +63 -0
  127. package/docs/project-audit/2026-05-16/sessions/batch-06.md +103 -0
  128. package/docs/project-audit/2026-05-16/sessions/batch-07.md +61 -0
  129. package/docs/project-audit/2026-05-16/sessions/batch-08.md +101 -0
  130. package/docs/project-audit/2026-05-16/sessions/batch-09.md +105 -0
  131. package/docs/project-audit/2026-05-16/sessions/batch-10.md +102 -0
  132. package/docs/project-audit/AUDIT-HISTORY.md +74 -0
  133. package/docs/project-audit/BATCH-PLAN.md +168 -0
  134. package/docs/project-audit/MARKETING-WEBSITE-FINDINGS-2026-05-11.md +73 -0
  135. package/docs/project-audit/PRODUCTION-READINESS-AUDIT-2026-05-08.md +275 -0
  136. package/docs/project-finalization/00-tracker.json +60 -0
  137. package/docs/project-knowledge-base/01-system-overview.md +227 -0
  138. package/docs/project-knowledge-base/02-routes-pages-forms-users.md +352 -0
  139. package/docs/project-knowledge-base/03-tech-stack-modules-services.md +379 -0
  140. package/docs/project-knowledge-base/04-data-models-integrations.md +244 -0
  141. package/docs/project-knowledge-base/05-docs-corpus-inventory.md +256 -0
  142. package/docs/project-knowledge-base/06-operations-testing-legal-content.md +208 -0
  143. package/docs/project-knowledge-base/README.md +103 -0
  144. package/docs/project-profiles/native-update-capacitor-update-platform-project-profile-last-updated-2026-05-19.md +81 -0
  145. package/docs/rules-tracker.md +102 -0
  146. package/docs/security/PRE-LAUNCH-PENTEST-CHECKLIST.md +116 -0
  147. package/docs/seo-aeo-rules.json +3043 -0
  148. package/docs/social-media-marketing/README.md +81 -0
  149. package/docs/social-media-marketing/posts-batch-01.md +613 -0
  150. package/docs/social-media-marketing/posts-batch-02.md +528 -0
  151. package/docs/social-media-marketing/whatsapp-messages-batch-01.md +458 -0
  152. package/docs/social-media-marketing/whatsapp-status-batch-01.md +355 -0
  153. package/docs/tracking/finalization-2026-05-16-tracker.json +346 -0
  154. package/docs/tracking/full-audit-tracker.json +121 -0
  155. package/docs/tracking/production-readiness-audit-tracker.json +429 -0
  156. package/docs/tracking/seo-checklist-tracker.json +333 -0
  157. package/ios/Plugin/BackgroundUpdate/BackgroundUpdatePlugin.swift +66 -9
  158. package/ios/Plugin/LiveUpdate/LiveUpdatePlugin.swift +306 -52
  159. package/ios/Plugin/NativeUpdatePlugin.swift +22 -9
  160. package/ios/Plugin/Security/SecurityManager.swift +13 -14
  161. package/package.json +37 -38
  162. package/cli/node_modules/.yarn-integrity +0 -16
  163. package/cli/node_modules/commander/LICENSE +0 -22
  164. package/cli/node_modules/commander/Readme.md +0 -1148
  165. package/cli/node_modules/commander/esm.mjs +0 -16
  166. package/cli/node_modules/commander/index.js +0 -26
  167. package/cli/node_modules/commander/lib/argument.js +0 -145
  168. package/cli/node_modules/commander/lib/command.js +0 -2179
  169. package/cli/node_modules/commander/lib/error.js +0 -43
  170. package/cli/node_modules/commander/lib/help.js +0 -462
  171. package/cli/node_modules/commander/lib/option.js +0 -329
  172. package/cli/node_modules/commander/lib/suggestSimilar.js +0 -100
  173. package/cli/node_modules/commander/package-support.json +0 -16
  174. package/cli/node_modules/commander/package.json +0 -80
  175. package/cli/node_modules/commander/typings/esm.d.mts +0 -3
  176. package/cli/node_modules/commander/typings/index.d.ts +0 -884
  177. package/cli/yarn.lock +0 -8
  178. package/dist/esm/__tests__/bundle-manager.test.d.ts +0 -1
  179. package/dist/esm/__tests__/bundle-manager.test.js +0 -151
  180. package/dist/esm/__tests__/bundle-manager.test.js.map +0 -1
  181. package/dist/esm/__tests__/config.test.d.ts +0 -1
  182. package/dist/esm/__tests__/config.test.js +0 -70
  183. package/dist/esm/__tests__/config.test.js.map +0 -1
  184. package/dist/esm/__tests__/delta-processor.test.d.ts +0 -1
  185. package/dist/esm/__tests__/delta-processor.test.js +0 -77
  186. package/dist/esm/__tests__/delta-processor.test.js.map +0 -1
  187. package/dist/esm/__tests__/firestore-schema.test.d.ts +0 -1
  188. package/dist/esm/__tests__/firestore-schema.test.js +0 -74
  189. package/dist/esm/__tests__/firestore-schema.test.js.map +0 -1
  190. package/dist/esm/__tests__/integration.test.d.ts +0 -1
  191. package/dist/esm/__tests__/integration.test.js +0 -78
  192. package/dist/esm/__tests__/integration.test.js.map +0 -1
  193. package/dist/esm/__tests__/manifest-reader.test.d.ts +0 -1
  194. package/dist/esm/__tests__/manifest-reader.test.js +0 -271
  195. package/dist/esm/__tests__/manifest-reader.test.js.map +0 -1
  196. package/dist/esm/__tests__/rollout-checker.test.d.ts +0 -1
  197. package/dist/esm/__tests__/rollout-checker.test.js +0 -210
  198. package/dist/esm/__tests__/rollout-checker.test.js.map +0 -1
  199. package/dist/esm/__tests__/security.test.d.ts +0 -1
  200. package/dist/esm/__tests__/security.test.js +0 -54
  201. package/dist/esm/__tests__/security.test.js.map +0 -1
  202. package/dist/esm/__tests__/version-manager.test.d.ts +0 -1
  203. package/dist/esm/__tests__/version-manager.test.js +0 -45
  204. package/dist/esm/__tests__/version-manager.test.js.map +0 -1
  205. package/dist/esm/app-review/app-review-manager.js.map +0 -1
  206. package/dist/esm/app-review/index.js.map +0 -1
  207. package/dist/esm/app-review/platform-review-handler.js.map +0 -1
  208. package/dist/esm/app-review/review-conditions-checker.js.map +0 -1
  209. package/dist/esm/app-review/review-rate-limiter.js.map +0 -1
  210. package/dist/esm/app-review/types.js.map +0 -1
  211. package/dist/esm/app-update/app-update-checker.js.map +0 -1
  212. package/dist/esm/app-update/app-update-installer.js.map +0 -1
  213. package/dist/esm/app-update/app-update-manager.js.map +0 -1
  214. package/dist/esm/app-update/app-update-notifier.js.map +0 -1
  215. package/dist/esm/app-update/index.js.map +0 -1
  216. package/dist/esm/app-update/platform-app-update.js.map +0 -1
  217. package/dist/esm/app-update/types.js.map +0 -1
  218. package/dist/esm/background-update/background-scheduler.js.map +0 -1
  219. package/dist/esm/background-update/index.js.map +0 -1
  220. package/dist/esm/background-update/notification-manager.js.map +0 -1
  221. package/dist/esm/config/support.js.map +0 -1
  222. package/dist/esm/core/analytics.js.map +0 -1
  223. package/dist/esm/core/cache-manager.js.map +0 -1
  224. package/dist/esm/core/config.js.map +0 -1
  225. package/dist/esm/core/errors.js.map +0 -1
  226. package/dist/esm/core/event-emitter.js.map +0 -1
  227. package/dist/esm/core/logger.js.map +0 -1
  228. package/dist/esm/core/performance.js.map +0 -1
  229. package/dist/esm/core/plugin-manager.js.map +0 -1
  230. package/dist/esm/core/security.js.map +0 -1
  231. package/dist/esm/definitions.js.map +0 -1
  232. package/dist/esm/firestore/firestore-client.d.ts +0 -109
  233. package/dist/esm/firestore/firestore-client.js +0 -264
  234. package/dist/esm/firestore/firestore-client.js.map +0 -1
  235. package/dist/esm/firestore/index.d.ts +0 -11
  236. package/dist/esm/firestore/index.js +0 -11
  237. package/dist/esm/firestore/index.js.map +0 -1
  238. package/dist/esm/firestore/manifest-reader.d.ts +0 -87
  239. package/dist/esm/firestore/manifest-reader.js +0 -294
  240. package/dist/esm/firestore/manifest-reader.js.map +0 -1
  241. package/dist/esm/firestore/schema.d.ts +0 -507
  242. package/dist/esm/firestore/schema.js +0 -73
  243. package/dist/esm/firestore/schema.js.map +0 -1
  244. package/dist/esm/index.js.map +0 -1
  245. package/dist/esm/live-update/bundle-manager.js.map +0 -1
  246. package/dist/esm/live-update/certificate-pinning.js.map +0 -1
  247. package/dist/esm/live-update/delta-processor.js.map +0 -1
  248. package/dist/esm/live-update/download-manager.js.map +0 -1
  249. package/dist/esm/live-update/rollout-checker.js.map +0 -1
  250. package/dist/esm/live-update/update-manager.js.map +0 -1
  251. package/dist/esm/live-update/version-manager.js.map +0 -1
  252. package/dist/esm/plugin.js.map +0 -1
  253. package/dist/esm/security/crypto.js.map +0 -1
  254. package/dist/esm/security/validator.js.map +0 -1
  255. package/dist/esm/web.js.map +0 -1
  256. package/dist/plugin.cjs.js.map +0 -1
  257. package/dist/plugin.esm.js.map +0 -1
  258. package/dist/plugin.js.map +0 -1
  259. package/docs/FIREBASE_INTEGRATION_TRACKER.md +0 -321
  260. package/docs/FIREBASE_QUERIES_AND_INDEXES_AUDIT.md +0 -221
  261. package/docs/examples/firebase-backend-example.md +0 -27
  262. package/docs/guides/no-cost-backend-implementation-plan.md +0 -77
  263. package/docs/guides/no-cost-firestore-google-drive-backend.md +0 -60
  264. package/docs/play-console-rejection-rules.json +0 -428
  265. /package/docs/{MARKETING_WEBSITE_PLAN.md → archive/MARKETING_WEBSITE_PLAN.md} +0 -0
@@ -0,0 +1,379 @@
1
+ # Native Update Tech Stack, Modules, and Services
2
+
3
+ ## Metadata
4
+
5
+ - **Reference Date:** 2026-05-18
6
+ - **Last Updated:** 2026-05-18
7
+
8
+ ## Monorepo Structure
9
+
10
+ | Path | Purpose |
11
+ |------|---------|
12
+ | `src/` | Main TypeScript plugin implementation |
13
+ | `android/` | Android native plugin implementation in Kotlin |
14
+ | `ios/` | iOS native plugin implementation in Swift |
15
+ | `cli/` | CLI package and commands |
16
+ | `website/` | Marketing site and dashboard application (React 19 + Vite + Capacitor wrapper) |
17
+ | `backend/` | Laravel 11 + Nova 5 SaaS backend (only backend; canonical persistence layer) |
18
+ | `example-apps/` | Example frontend (`react-capacitor/`) and backend (`node-express/`) projects |
19
+ | `docs/` | Public docs, planning, reports, and knowledge artifacts |
20
+
21
+ ## Root Package Tech Stack
22
+
23
+ - Node.js `>=24.13.0`
24
+ - TypeScript
25
+ - Rollup
26
+ - Capacitor 8 ecosystem packages
27
+ - ESLint (`@typescript-eslint/*` flat config; `@eslint/js` is BANNED)
28
+ - Prettier
29
+ - Commander
30
+ - Express
31
+ - Archiver
32
+ - Chalk
33
+ - Ora
34
+ - Prompts
35
+
36
+ ## Website Tech Stack
37
+
38
+ - React 19 + TypeScript
39
+ - Vite 7
40
+ - Tailwind CSS v4
41
+ - Google OAuth via Laravel Socialite (backend-driven; no Firebase Auth in the SPA)
42
+ - Sanctum bearer tokens persisted via `@capacitor/preferences` (native) / `localStorage` (web)
43
+ - TanStack Query (data plane with hierarchical keys + URL-state pagination + keepPreviousData)
44
+ - Axios (`src/lib/api.ts` with 401-clear-and-redirect interceptor)
45
+ - Zustand (local UI state)
46
+ - Framer Motion (animations)
47
+ - Radix UI primitives (Dialog, Tooltip, etc.)
48
+ - D3 (charts)
49
+ - React Router
50
+ - React Markdown
51
+ - Capacitor 8 (mobile wrapper for the dashboard)
52
+
53
+ ## Backend Tech Stack
54
+
55
+ - Laravel 11
56
+ - Laravel Nova 5 (admin UI at `/nova`)
57
+ - Laravel Socialite (Google OAuth)
58
+ - Laravel Sanctum (personal access tokens for the SPA)
59
+ - `spatie/laravel-permission` (RBAC; `sanctum` guard; roles `super-admin`, `admin`, `user`)
60
+ - MySQL (single source of persistence — no Firestore branch)
61
+ - PHP 8.2+
62
+ - Composer
63
+ - Pest / PHPUnit (~136 tests at last finalization audit)
64
+ - Google Drive PHP SDK (server-side OAuth; tokens encrypted via Laravel's encrypter)
65
+
66
+ ## CLI Package
67
+
68
+ ### Entry
69
+
70
+ - `cli/index.js`
71
+
72
+ ### Commands
73
+
74
+ - `init`
75
+ - `bundle-create`
76
+ - `bundle-sign`
77
+ - `bundle-verify`
78
+ - `keys-generate`
79
+ - `backend-create` (emits scaffolds with `TODO[SCAFFOLD-IMPLEMENT-BEFORE-DEPLOY]` markers)
80
+ - `server-start`
81
+ - `monitor`
82
+
83
+ ### CLI Value
84
+
85
+ - scaffolds projects
86
+ - generates bundles
87
+ - signs and verifies release artifacts (RSA-2048 / RSA-4096 / EC P-256 / EC P-384)
88
+ - generates keypairs
89
+ - starts local server flow
90
+ - supports deployment monitoring (interval+spinner cleanup, signal handlers, failure bail)
91
+
92
+ ## Core Plugin Module Inventory
93
+
94
+ ### `src/live-update/`
95
+
96
+ - `bundle-manager.ts`
97
+ - `certificate-pinning.ts`
98
+ - `delta-processor.ts`
99
+ - `download-manager.ts`
100
+ - `rollout-checker.ts`
101
+ - `update-manager.ts`
102
+ - `version-manager.ts`
103
+
104
+ **Purpose:** runtime live update logic, version checks, download/install handling, delta support, and rollout-aware decisions.
105
+
106
+ ### `src/app-update/`
107
+
108
+ - `app-update-checker.ts`
109
+ - `app-update-installer.ts`
110
+ - `app-update-manager.ts`
111
+ - `app-update-notifier.ts`
112
+ - `platform-app-update.ts`
113
+ - `types.ts`
114
+ - `index.ts`
115
+
116
+ **Purpose:** native binary update checks, install flows, platform-specific update behavior, and notifications.
117
+
118
+ ### `src/app-review/`
119
+
120
+ - `app-review-manager.ts`
121
+ - `platform-review-handler.ts`
122
+ - `review-conditions-checker.ts`
123
+ - `review-rate-limiter.ts`
124
+ - `types.ts`
125
+ - `index.ts`
126
+
127
+ **Purpose:** smart in-app review prompting, timing/eligibility checks, platform-specific review invocation.
128
+
129
+ ### `src/background-update/`
130
+
131
+ - `background-scheduler.ts`
132
+ - `notification-manager.ts`
133
+ - `index.ts`
134
+
135
+ **Purpose:** scheduling, notifications, and background update orchestration.
136
+
137
+ ### `src/core/`
138
+
139
+ - `analytics.ts`
140
+ - `cache-manager.ts`
141
+ - `config.ts`
142
+ - `errors.ts`
143
+ - `event-emitter.ts`
144
+ - `logger.ts`
145
+ - `performance.ts`
146
+ - `plugin-manager.ts`
147
+ - `security.ts`
148
+
149
+ **Purpose:** shared foundations for config, events, logging, analytics, errors, caching, and general plugin behavior.
150
+
151
+ ### `src/security/`
152
+
153
+ - `crypto.ts`
154
+ - `validator.ts`
155
+
156
+ **Purpose:** cryptographic helpers and validation utilities (SHA-256, RSA-SHA256 verify).
157
+
158
+ ### Root Entry Files
159
+
160
+ - `src/index.ts`
161
+ - `src/plugin.ts`
162
+ - `src/definitions.ts`
163
+ - `src/web.ts`
164
+
165
+ **Purpose:** export surface, Capacitor plugin bindings, typings, and web fallback behavior.
166
+
167
+ Note: `src/firestore/` was removed in v3.0.0 (2026-05-04). The plugin no longer carries any Firestore code; manifest reads happen over plain HTTPS against any user-controlled endpoint.
168
+
169
+ ## Native Android Modules
170
+
171
+ | File | Role |
172
+ |------|------|
173
+ | `NativeUpdatePlugin.kt` | Main Android plugin entry |
174
+ | `LiveUpdatePlugin.kt` | OTA/live update Android implementation |
175
+ | `AppUpdatePlugin.kt` | App update Android integration (Play Core) |
176
+ | `AppReviewPlugin.kt` | In-app review Android integration (Play Review) |
177
+ | `BackgroundUpdatePlugin.kt` | Background update orchestration |
178
+ | `BackgroundUpdateManager.kt` | Background scheduling/management logic |
179
+ | `BackgroundUpdateWorker.kt` | WorkManager-based background task execution |
180
+ | `BackgroundNotificationManager.kt` | Notification support |
181
+ | `NotificationActionReceiver.kt` | Notification action handling |
182
+ | `SecurityManager.kt` | Android security helpers |
183
+
184
+ ## Native iOS Modules
185
+
186
+ | File | Role |
187
+ |------|------|
188
+ | `NativeUpdatePlugin.swift` | Main iOS plugin entry |
189
+ | `NativeUpdatePlugin.m` | Objective-C bridge/registration layer |
190
+ | `LiveUpdatePlugin.swift` | OTA/live update implementation |
191
+ | `WebViewConfiguration.swift` | web view config support for live updates |
192
+ | `AppUpdatePlugin.swift` | App update iOS behavior |
193
+ | `AppReviewPlugin.swift` | StoreKit `SKStoreReviewController` handling |
194
+ | `BackgroundUpdatePlugin.swift` | BGTaskScheduler background update behavior |
195
+ | `BackgroundNotificationManager.swift` | notification support |
196
+ | `SecurityManager.swift` | iOS security helpers |
197
+
198
+ ## Frontend Services (`website/src/services/`)
199
+
200
+ ### `auth-service.ts`
201
+
202
+ - Initiates Laravel Socialite redirect for Google sign-in
203
+ - handles `/auth/callback` token persistence via `lib/auth-token.ts`
204
+ - logout flow (deletes Sanctum token, broadcasts event, clears Drive cache)
205
+
206
+ ### `apps-api-service.ts`
207
+
208
+ - TanStack Query hooks for App CRUD against `/api/dashboard/apps/*`
209
+
210
+ ### `google-drive-service.ts`
211
+
212
+ - starts the server-side Drive OAuth flow (no browser SDK)
213
+ - requests Drive auth URL from the backend
214
+ - posts callback code back to the backend
215
+ - reads Drive connection status from `/api/dashboard/me`
216
+ - lists files via backend proxy endpoints
217
+
218
+ ### `bundle-upload-service.ts`
219
+
220
+ - validates ZIP file (size, type)
221
+ - multipart POST to `/api/dashboard/apps/{app}/builds` with progress tracking
222
+ - triggers TanStack Query cache invalidation on success
223
+
224
+ ### `manifest-generator.ts`
225
+
226
+ - derives per-file manifest from ZIP (client-side, for delta hints)
227
+ - compares old/new manifests
228
+ - estimates delta size
229
+ - decides if delta is worthwhile
230
+
231
+ ### `themeSync.ts`
232
+
233
+ - syncs theme preferences to `users.preferences` JSON via `/api/dashboard/preferences`
234
+
235
+ ### Other Frontend Services
236
+
237
+ - capacitor service wrappers under `website/src/services/capacitor/`
238
+
239
+ ## Frontend State Stores
240
+
241
+ ### `appsStore`
242
+
243
+ - TanStack-Query-backed cache for user apps (hierarchical keys)
244
+ - selected-app tracking + error surface
245
+
246
+ ### `buildsStore`
247
+
248
+ - TanStack-Query-backed cache for builds per app/user/channel
249
+ - pagination + filter state encoded in URL search params
250
+
251
+ ### `rolloutsStore`
252
+
253
+ - fetches rollout state from Build rows
254
+ - pause/resume/percentage mutations
255
+
256
+ ### `analyticsStore`
257
+
258
+ - fetches aggregated events from `/api/dashboard/analytics`
259
+ - builds platform/version summaries
260
+ - manages date range
261
+
262
+ ## Backend Source Tree (`backend/`)
263
+
264
+ ### Controllers (`app/Http/Controllers/`)
265
+
266
+ - `Auth/OAuthController` (Socialite redirect + callback + Sanctum token issuance)
267
+ - `Dashboard/AnalyticsDashboardController`
268
+ - `Dashboard/ApiKeyController`
269
+ - `Dashboard/AppController`
270
+ - `Dashboard/BuildController`
271
+ - `Dashboard/GoogleDriveController`
272
+ - `Dashboard/MeController`
273
+ - `Dashboard/PreferencesController`
274
+ - `Dashboard/RolloutController`
275
+ - `Dashboard/SigningKeyController`
276
+ - `Dashboard/SubscriptionController`
277
+ - `Api/UpdateController` (mobile `/api/v1/updates/check`)
278
+ - `Api/BundleController` (signed `/api/v1/bundles/{build}/download`)
279
+ - `Api/AnalyticsController` (mobile `/api/v1/analytics/*`)
280
+
281
+ ### Eloquent Models (`app/Models/`)
282
+
283
+ - `User`
284
+ - `App`
285
+ - `ApiKey`
286
+ - `SigningKey`
287
+ - `Build`
288
+ - `Subscription`
289
+ - `DeviceActivity`
290
+ - `AnalyticsEvent`
291
+
292
+ ### FormRequest Validators (`app/Http/Requests/`)
293
+
294
+ - `UpdateBuildRequest` and related Create/Update FormRequests for App, ApiKey, SigningKey
295
+
296
+ ### Routes
297
+
298
+ - `routes/api.php` (all `/api/*` routes)
299
+ - `routes/web.php` (Nova mounts + OAuth callback HTML stubs)
300
+ - `routes/console.php` (Artisan commands including `native-update:role-assign`)
301
+
302
+ ### Policies + Gates
303
+
304
+ - `User`, `App`, `Build`, `ApiKey`, `SigningKey` policies registered in `AuthServiceProvider`
305
+ - `Gate::before` returns `true` for `super-admin` (full bypass)
306
+ - `Nova/User.php` carries `canSee` guards for admin-only resources
307
+
308
+ ## Example Apps
309
+
310
+ ### `example-apps/react-capacitor/`
311
+
312
+ - frontend example demonstrating plugin use in a Capacitor app
313
+ - React 18 (stable downstream target; explained in its README "React 18 vs React 19" section)
314
+ - capability cards: OTA basic, app-update (`getAppUpdateInfo`/`openAppStore`), app-review (`canRequestReview`/`requestReview`), background-update (toggle with `allowMeteredConnection`/`nextCheckTime`)
315
+
316
+ ### `example-apps/node-express/`
317
+
318
+ - minimal Node.js + Express backend example
319
+ - ~160 lines, dissected in `docs/backend/node-express-minimal.md`
320
+ - demonstrates the manifest-endpoint contract without a full SaaS
321
+
322
+ Note: `example-apps/firebase-backend/` was removed in v3.0.0 (2026-05-04).
323
+
324
+ ## Testing Modules Present
325
+
326
+ ### TypeScript Tests (root plugin)
327
+
328
+ - bundle manager
329
+ - config
330
+ - delta processor
331
+ - integration (live-update flow)
332
+ - manifest reader
333
+ - rollout checker
334
+ - security
335
+ - version manager
336
+ - 62/62 passing at last verification
337
+
338
+ ### Backend Tests (`backend/tests/`)
339
+
340
+ - OAuth + Sanctum + Spatie + UpdateBuildRequest FormRequest + PayPal webhook + BundleUpload + UserLicense
341
+ - ~136 tests passing (`php artisan test`)
342
+
343
+ ### iOS Tests
344
+
345
+ - app update tests
346
+ - app review tests
347
+ - background update tests
348
+ - live update tests
349
+ - security tests
350
+
351
+ ### Android Tests
352
+
353
+ - app review plugin tests
354
+ - app update plugin tests
355
+ - background notification manager tests
356
+ - background worker tests
357
+ - live update plugin tests
358
+ - security manager tests
359
+
360
+ ### E2E (`e2e/`)
361
+
362
+ - OTA update flow
363
+ - download progress
364
+ - channel switching
365
+ - error handling
366
+
367
+ ### Microbenchmarks (`tools/bench/`)
368
+
369
+ - `verify-checksum.bench.ts` (SHA-256 over 1/5/20 MB)
370
+ - `verify-signature.bench.ts` (RSA-2048 + RSA-4096 SHA-256 verify over 5 MB)
371
+
372
+ ## Important Architectural Direction
373
+
374
+ - Treat the plugin as runtime infrastructure.
375
+ - Treat the website as management and distribution tooling.
376
+ - Treat Laravel + MySQL as the single source of truth for App, Build, and User data.
377
+ - Treat Sanctum personal access tokens as the only credential the SPA holds; the dashboard reads its identity from `/api/dashboard/me`.
378
+ - Treat Google Drive as the canonical storage destination for uploaded bundle ZIPs (server-side OAuth tokens, encrypted at rest).
379
+ - Treat the mobile API plane (`/api/v1/*`) as a separate auth surface (per-app API keys, not Sanctum).
@@ -0,0 +1,244 @@
1
+ # Native Update Data Models and Integrations
2
+
3
+ ## Metadata
4
+
5
+ - **Reference Date:** 2026-05-18
6
+ - **Last Updated:** 2026-05-18
7
+
8
+ ## Main Integration Surfaces
9
+
10
+ - Google OAuth via Laravel Socialite (auth provider)
11
+ - Laravel Sanctum (token plane for the SPA)
12
+ - `spatie/laravel-permission` (RBAC inside MySQL)
13
+ - Google Drive API (server-side OAuth; bundle storage)
14
+ - FilesHub (`https://fileshub.zaions.com`) for miscellaneous user-uploaded assets
15
+ - PayPal (webhook for subscription events)
16
+ - Capacitor runtime APIs
17
+ - Android native APIs (Play Core update, Play Review, WorkManager)
18
+ - iOS native APIs (StoreKit SKStoreReviewController, BGTaskScheduler)
19
+
20
+ ## Authentication Model
21
+
22
+ ### Sign-In Method
23
+
24
+ - Only auth flow is Google OAuth via Laravel Socialite
25
+ - SPA navigates to `${VITE_API_URL}/auth/google/redirect`
26
+ - Laravel's `OAuthController` redirects to Google, receives the callback, exchanges the code, and creates/updates the `users` row keyed by `google_id`
27
+ - On success, Laravel issues a Sanctum personal access token and redirects to `${FRONTEND_URL}/auth/callback?token=…`
28
+ - SPA's `CallbackPage` stores the plain-text token (shown once) via `setAuthToken()` and navigates to `/dashboard`
29
+
30
+ ### Role Assignment
31
+
32
+ - First sign-in → assigns the `user` role (default)
33
+ - Emails in `ADMIN_EMAILS` env → auto-assigned `super-admin`
34
+ - Manual: `php artisan native-update:role-assign <email> <role>` (revokes existing tokens to force re-login with new role)
35
+ - Seeder: `php artisan db:seed --class=RolesPermissionsSeeder` (idempotent)
36
+
37
+ ### Token Lifecycle
38
+
39
+ - Default TTL: 7 days (configurable via `SANCTUM_TOKEN_EXPIRATION`)
40
+ - Stored as `Bearer` header on every `/api/dashboard/*` and `/api/admin/*` request
41
+ - 401 from any endpoint → axios interceptor clears the token, broadcasts a logout event, redirects to `/login`
42
+ - Logout: `DELETE /api/dashboard/me/token` revokes the current token; on multi-device logout, all of the user's tokens are revoked
43
+
44
+ ## MySQL Schema (Laravel migrations)
45
+
46
+ Migrations live in `backend/database/migrations/`. The following tables exist:
47
+
48
+ ### `users`
49
+
50
+ - Standard Laravel fields plus:
51
+ - `google_id` (unique; primary identity key)
52
+ - `name`, `email`, `avatar_url`
53
+ - `google_drive_access_token`, `google_drive_refresh_token`, `google_drive_token_expires_at` (encrypted via Laravel encrypter)
54
+ - `google_drive_email`, `google_drive_connected_at`
55
+ - `preferences` (JSON: email notifications, update notifications, theme, language, accent color, etc.)
56
+ - admin-control flags (block, suspend, notes)
57
+ - `apps_count`, `builds_count`, `storage_used` (denormalized counters)
58
+ - standard timestamps + soft-delete
59
+
60
+ ### `apps`
61
+
62
+ - `user_id` (foreign key to `users`)
63
+ - `name`, `package_id` (unique per user), `description`, `icon_url`
64
+ - `platforms` (JSON array: android/ios/web)
65
+ - `channels` (JSON config)
66
+ - `total_builds`, `active_users`, `last_build_at`
67
+ - standard timestamps + soft-delete
68
+
69
+ ### `api_keys`
70
+
71
+ - `app_id` (foreign key)
72
+ - `key` (random token; used for mobile `/api/v1/*` plane)
73
+ - `name`, `is_active`, `last_used_at`
74
+ - standard timestamps
75
+
76
+ ### `signing_keys`
77
+
78
+ - `app_id` (foreign key)
79
+ - `name`
80
+ - `algorithm` (RSA-2048 / RSA-4096 / EC P-256 / EC P-384)
81
+ - `public_key` (PEM)
82
+ - `private_key` (encrypted; backend-side only — never sent to the SPA)
83
+ - `is_active`, `rotated_at`
84
+ - standard timestamps
85
+
86
+ ### `builds`
87
+
88
+ - `id`
89
+ - `user_id`, `app_id`
90
+ - `version`, `build_number`
91
+ - `channel`, `platform`
92
+ - `file_name`, `file_size`, `mime_type`
93
+ - `checksum` (SHA-256)
94
+ - `signature` (RSA-SHA256 base64)
95
+ - `drive_file_id`, `drive_file_url`, `drive_folder_id`
96
+ - `fileshub_object_id` (when FilesHub used instead of Drive)
97
+ - `file_manifest` (JSON: per-entry checksums for delta hints)
98
+ - `release_notes`, `release_type`, `is_pre_release`
99
+ - `min_native_version`
100
+ - `uploaded_at`, `uploaded_by`, `upload_duration`
101
+ - `status` (uploading / processing / active / archived / failed)
102
+ - `processing_steps` (JSON; multi-step state)
103
+ - `analytics` (JSON snapshot)
104
+ - rollout config inline:
105
+ - `rollout_enabled`
106
+ - `rollout_percentage`
107
+ - `rollout_start_time`, `rollout_end_time`
108
+ - `target_segments` (JSON; optional)
109
+ - standard timestamps + soft-delete
110
+
111
+ ### `subscriptions` + `subscription_items`
112
+
113
+ - billing model (Stripe-style + PayPal provider added 2026-04-18)
114
+ - `provider` (stripe / paypal), `provider_id`
115
+ - `status`, `current_period_start`, `current_period_end`
116
+ - per-item quantities + plan refs
117
+
118
+ ### `device_activities`
119
+
120
+ - mobile-side telemetry (one row per active device)
121
+ - last-seen, version installed, channel, platform metadata
122
+
123
+ ### `analytics_events`
124
+
125
+ - per-event analytics (update checks, downloads, installs, rollbacks, errors)
126
+ - `app_id`, `channel`, `platform`, `event_type`, `payload` (JSON)
127
+ - aggregated by `AnalyticsDashboardController` for the dashboard
128
+
129
+ ### `personal_access_tokens` (Sanctum)
130
+
131
+ - Sanctum's default token table
132
+ - `tokenable_type`, `tokenable_id`, `name`, `token` (hashed), `abilities`, `last_used_at`, `expires_at`
133
+
134
+ ### Spatie permission tables
135
+
136
+ - `roles`, `permissions`, `model_has_roles`, `model_has_permissions`, `role_has_permissions`
137
+ - guard name: `sanctum`
138
+
139
+ ## Build Status Values
140
+
141
+ - `uploading`
142
+ - `processing`
143
+ - `active`
144
+ - `archived`
145
+ - `failed`
146
+
147
+ ## Manifest Shape (returned by `/api/v1/updates/check`)
148
+
149
+ Returned for each `appId + channel` combination, derived from the active Build row:
150
+
151
+ ```jsonc
152
+ {
153
+ "appId": "com.example.myapp",
154
+ "channel": "production",
155
+ "current": {
156
+ "version": "1.2.0",
157
+ "bundleId": "<build uuid>",
158
+ "bundleUrl": "https://<signed-drive-or-fileshub-url>",
159
+ "manifestUrl": "<self-link>",
160
+ "checksum": "sha256-…",
161
+ "signature": "<base64 RSA-SHA256>",
162
+ "size": 1234567,
163
+ "releaseNotes": "…",
164
+ "releaseDate": "ISO-8601",
165
+ "mandatory": false,
166
+ "minNativeVersion": "1.0.0"
167
+ },
168
+ "deltas": [],
169
+ "rollout": {
170
+ "enabled": true,
171
+ "percentage": 25,
172
+ "startTime": "ISO-8601",
173
+ "endTime": null,
174
+ "targetSegments": null
175
+ },
176
+ "previousVersions": [],
177
+ "updatedAt": "ISO-8601",
178
+ "updatedBy": "<user id>"
179
+ }
180
+ ```
181
+
182
+ ## Rollout Config
183
+
184
+ - `enabled` (boolean)
185
+ - `percentage` (0–100)
186
+ - `startTime` / `endTime` (ISO-8601; optional bounds)
187
+ - `targetSegments` (optional JSON; reserved for future segmentation)
188
+ - `schedule` strategy (immediate / gradual / scheduled)
189
+
190
+ ## Delta Shape
191
+
192
+ Used when the plugin asks for an incremental patch between two known versions:
193
+
194
+ - `appId`
195
+ - `fromVersion`, `toVersion`
196
+ - `channel`
197
+ - `patchUrl`, `patchSize`, `patchChecksum`
198
+ - `sourceChecksum`, `targetChecksum`
199
+ - `algorithm`, `compressionRatio`
200
+ - `status`
201
+
202
+ ## Google Drive Integration Flow (server-side)
203
+
204
+ ### Connect Flow
205
+
206
+ 1. User clicks "Connect Google Drive" on `/dashboard/drive`
207
+ 2. SPA calls `GET /api/dashboard/google-drive/auth-url` → backend returns Google OAuth URL with Drive scope
208
+ 3. Browser does full-window redirect to Google
209
+ 4. Google redirects to `${FRONTEND_URL}/oauth/google-drive/callback?code=…`
210
+ 5. SPA `DriveCallbackPage` POSTs the code to `POST /api/dashboard/google-drive/callback`
211
+ 6. Backend exchanges the code, encrypts access + refresh tokens, persists on the `users` row
212
+ 7. Backend writes `google_drive_email` + `google_drive_connected_at` for UI display
213
+
214
+ ### Upload Flow (Laravel-driven)
215
+
216
+ 1. User selects ZIP on `/dashboard/upload`
217
+ 2. SPA multipart-POSTs to `POST /api/dashboard/apps/{app}/builds`
218
+ 3. `UpdateBuildRequest` FormRequest validates app ownership, version, build_number, file presence, file size, Drive-connected precondition
219
+ 4. Laravel computes SHA-256 of the uploaded ZIP
220
+ 5. Laravel signs the checksum with the app's active signing key (RSA-SHA256)
221
+ 6. Laravel uploads the ZIP to the user's Drive folder via encrypted tokens
222
+ 7. Laravel inserts the Build row in MySQL with `status='active'`
223
+ 8. Laravel returns the Build resource to the SPA
224
+ 9. TanStack Query invalidates the relevant cache keys → UploadPage navigates to app detail
225
+
226
+ ## App-Facing Manifest Paths
227
+
228
+ - `GET /api/v1/updates/check?appId=…&channel=…&apiKey=…` → returns the active manifest
229
+ - `GET /api/v1/bundles/{build}/download` → returns a short-lived signed URL to the bundle (default 30 min)
230
+
231
+ ## Security-Relevant Data Points
232
+
233
+ - SHA-256 checksums are stored on every Build and verified on every download
234
+ - RSA-SHA256 signatures are stored alongside checksums; plugin verifies against the configured public key (or array of public keys during a key rotation window)
235
+ - Signing-key private keys never leave the Laravel host
236
+ - Drive OAuth tokens are encrypted at rest using Laravel's encrypter (per-row, not per-app)
237
+ - Sanctum token strings are hashed in the DB; the plain-text token is shown to the SPA exactly once at issuance
238
+
239
+ ## Data Ownership Notes
240
+
241
+ - The website messaging emphasizes that user build files are stored in the user's Google Drive
242
+ - All other data (account, app metadata, builds, analytics, signing keys, subscriptions) lives in the Laravel MySQL database
243
+ - Account deletion soft-deletes the User row, revokes all Sanctum tokens, clears encrypted Drive tokens, cascades to apps/builds, and surfaces a confirmation page documenting what was removed
244
+ - Privacy policy + data-deletion page reflect this exact architecture