native-update 2.0.0 → 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 (258) 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 +15 -1
  8. package/cli/CLAUDE.md +15 -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.js +0 -1
  21. package/dist/esm/app-update/app-update-installer.d.ts +1 -0
  22. package/dist/esm/app-update/app-update-installer.js +19 -8
  23. package/dist/esm/app-update/app-update-manager.js +0 -1
  24. package/dist/esm/app-update/app-update-notifier.js +0 -1
  25. package/dist/esm/app-update/index.js +0 -1
  26. package/dist/esm/app-update/platform-app-update.js +12 -3
  27. package/dist/esm/app-update/types.js +0 -1
  28. package/dist/esm/background-update/background-scheduler.js +0 -1
  29. package/dist/esm/background-update/index.js +0 -1
  30. package/dist/esm/background-update/notification-manager.js +0 -1
  31. package/dist/esm/config/support.js +0 -1
  32. package/dist/esm/core/analytics.d.ts +13 -0
  33. package/dist/esm/core/analytics.js +15 -1
  34. package/dist/esm/core/cache-manager.js +0 -1
  35. package/dist/esm/core/config.d.ts +0 -15
  36. package/dist/esm/core/config.js +0 -4
  37. package/dist/esm/core/errors.d.ts +1 -0
  38. package/dist/esm/core/errors.js +1 -1
  39. package/dist/esm/core/event-emitter.d.ts +0 -3
  40. package/dist/esm/core/event-emitter.js +8 -3
  41. package/dist/esm/core/logger.js +0 -1
  42. package/dist/esm/core/performance.js +0 -1
  43. package/dist/esm/core/plugin-manager.js +3 -1
  44. package/dist/esm/core/security.d.ts +11 -0
  45. package/dist/esm/core/security.js +27 -1
  46. package/dist/esm/definitions.d.ts +0 -11
  47. package/dist/esm/definitions.js +0 -1
  48. package/dist/esm/index.d.ts +3 -2
  49. package/dist/esm/index.js +3 -1
  50. package/dist/esm/live-update/bundle-manager.d.ts +8 -0
  51. package/dist/esm/live-update/bundle-manager.js +20 -1
  52. package/dist/esm/live-update/certificate-pinning.js +0 -1
  53. package/dist/esm/live-update/delta-processor.d.ts +1 -1
  54. package/dist/esm/live-update/delta-processor.js +3 -1
  55. package/dist/esm/live-update/download-manager.js +9 -2
  56. package/dist/esm/live-update/rollout-checker.d.ts +1 -1
  57. package/dist/esm/live-update/rollout-checker.js +5 -6
  58. package/dist/esm/live-update/update-manager.js +0 -1
  59. package/dist/esm/live-update/version-manager.d.ts +0 -12
  60. package/dist/esm/live-update/version-manager.js +0 -68
  61. package/dist/esm/plugin.js +69 -43
  62. package/dist/esm/security/crypto.js +11 -7
  63. package/dist/esm/security/validator.js +0 -1
  64. package/dist/esm/types/rollout.d.ts +85 -0
  65. package/dist/esm/types/rollout.js +25 -0
  66. package/dist/esm/web.d.ts +8 -0
  67. package/dist/esm/web.js +148 -54
  68. package/dist/plugin.cjs.js +1 -2
  69. package/dist/plugin.esm.js +1 -2
  70. package/dist/plugin.js +2 -3
  71. package/docs/CHANGELOG.md +124 -0
  72. package/docs/CLAUDE.md +1 -1
  73. package/docs/MANUAL-TASKS.md +17 -0
  74. package/docs/MARKETING_WEBSITE_TRACKER.md +18 -2
  75. package/docs/MIGRATION.md +83 -0
  76. package/docs/PACKAGES.md +167 -0
  77. package/docs/PERFORMANCE.md +110 -0
  78. package/docs/PROJECT_COMPLETION_TRACKER.md +4 -35
  79. package/docs/README.md +0 -1
  80. package/docs/REMAINING_FEATURES.md +123 -76
  81. package/docs/ROADMAP.md +200 -120
  82. package/docs/SECURITY-IF-REPO-PUBLIC.md +232 -0
  83. package/docs/TESTING_REQUIREMENTS.md +1 -112
  84. package/docs/ai-knowledge-base/00-project-profile.md +38 -0
  85. package/docs/ai-knowledge-base/01-features.md +46 -0
  86. package/docs/ai-knowledge-base/02-routes.md +72 -0
  87. package/docs/ai-knowledge-base/03-tech-stack.md +57 -0
  88. package/docs/ai-knowledge-base/README.md +23 -0
  89. package/docs/analytics-tracking.md +37 -0
  90. package/docs/capacitor-official-plugins.md +46 -0
  91. package/docs/capawesome-plugins.md +29 -0
  92. package/docs/deployment/HOSTINGER_DEPLOY.md +75 -34
  93. package/docs/deployment/PRODUCTION-DEPLOY-CHECKLIST.md +184 -0
  94. package/docs/docs-site/plan.md +201 -0
  95. package/docs/docs-site/scope.md +127 -0
  96. package/docs/docs-site/tracker.json +235 -0
  97. package/docs/error-handling-tracking.md +37 -0
  98. package/docs/guides/testing-guide.md +15 -41
  99. package/docs/package-audit.md +41 -0
  100. package/docs/play-store/ASO-METADATA.md +5 -0
  101. package/docs/play-store/DATA-SAFETY.md +5 -0
  102. package/docs/play-store/DECLARATIONS.md +5 -0
  103. package/docs/play-store/README.md +27 -0
  104. package/docs/play-store/RELEASE-NOTES.md +99 -0
  105. package/docs/play-store/RELEASE-STEPS.md +6 -0
  106. package/docs/play-store/STORE-LISTING.md +7 -0
  107. package/docs/play-store/SUBMISSION-CHECKLIST.md +5 -0
  108. package/docs/production-readiness.md +1 -1
  109. package/docs/project-audit/2026-05-16/00-FINALIZATION-PLAN.md +123 -0
  110. package/docs/project-audit/2026-05-16/01-BATCH-PLAN.md +227 -0
  111. package/docs/project-audit/2026-05-16/02-AUDIT-FINDINGS.md +144 -0
  112. package/docs/project-audit/2026-05-16/sessions/batch-01.md +42 -0
  113. package/docs/project-audit/2026-05-16/sessions/batch-02.md +74 -0
  114. package/docs/project-audit/2026-05-16/sessions/batch-03.md +71 -0
  115. package/docs/project-audit/2026-05-16/sessions/batch-04.md +88 -0
  116. package/docs/project-audit/2026-05-16/sessions/batch-05.md +63 -0
  117. package/docs/project-audit/2026-05-16/sessions/batch-06.md +103 -0
  118. package/docs/project-audit/2026-05-16/sessions/batch-07.md +61 -0
  119. package/docs/project-audit/2026-05-16/sessions/batch-08.md +101 -0
  120. package/docs/project-audit/2026-05-16/sessions/batch-09.md +105 -0
  121. package/docs/project-audit/2026-05-16/sessions/batch-10.md +102 -0
  122. package/docs/project-audit/AUDIT-HISTORY.md +74 -0
  123. package/docs/project-audit/BATCH-PLAN.md +168 -0
  124. package/docs/project-audit/MARKETING-WEBSITE-FINDINGS-2026-05-11.md +73 -0
  125. package/docs/project-audit/PRODUCTION-READINESS-AUDIT-2026-05-08.md +275 -0
  126. package/docs/project-finalization/00-tracker.json +60 -0
  127. package/docs/project-knowledge-base/01-system-overview.md +39 -30
  128. package/docs/project-knowledge-base/02-routes-pages-forms-users.md +87 -81
  129. package/docs/project-knowledge-base/03-tech-stack-modules-services.md +140 -108
  130. package/docs/project-knowledge-base/04-data-models-integrations.md +191 -254
  131. package/docs/project-knowledge-base/05-docs-corpus-inventory.md +83 -20
  132. package/docs/project-knowledge-base/06-operations-testing-legal-content.md +67 -29
  133. package/docs/project-knowledge-base/README.md +27 -14
  134. package/docs/project-profiles/native-update-capacitor-update-platform-project-profile-last-updated-2026-05-19.md +81 -0
  135. package/docs/rules-tracker.md +102 -0
  136. package/docs/security/PRE-LAUNCH-PENTEST-CHECKLIST.md +116 -0
  137. package/docs/social-media-marketing/README.md +81 -0
  138. package/docs/social-media-marketing/posts-batch-01.md +613 -0
  139. package/docs/social-media-marketing/posts-batch-02.md +528 -0
  140. package/docs/social-media-marketing/whatsapp-messages-batch-01.md +458 -0
  141. package/docs/social-media-marketing/whatsapp-status-batch-01.md +355 -0
  142. package/docs/tracking/finalization-2026-05-16-tracker.json +346 -0
  143. package/docs/tracking/full-audit-tracker.json +121 -0
  144. package/docs/tracking/production-readiness-audit-tracker.json +429 -0
  145. package/ios/Plugin/BackgroundUpdate/BackgroundUpdatePlugin.swift +16 -3
  146. package/ios/Plugin/LiveUpdate/LiveUpdatePlugin.swift +71 -47
  147. package/ios/Plugin/NativeUpdatePlugin.swift +14 -9
  148. package/package.json +29 -29
  149. package/cli/node_modules/.yarn-integrity +0 -16
  150. package/cli/node_modules/commander/LICENSE +0 -22
  151. package/cli/node_modules/commander/Readme.md +0 -1148
  152. package/cli/node_modules/commander/esm.mjs +0 -16
  153. package/cli/node_modules/commander/index.js +0 -26
  154. package/cli/node_modules/commander/lib/argument.js +0 -145
  155. package/cli/node_modules/commander/lib/command.js +0 -2179
  156. package/cli/node_modules/commander/lib/error.js +0 -43
  157. package/cli/node_modules/commander/lib/help.js +0 -462
  158. package/cli/node_modules/commander/lib/option.js +0 -329
  159. package/cli/node_modules/commander/lib/suggestSimilar.js +0 -100
  160. package/cli/node_modules/commander/package-support.json +0 -16
  161. package/cli/node_modules/commander/package.json +0 -80
  162. package/cli/node_modules/commander/typings/esm.d.mts +0 -3
  163. package/cli/node_modules/commander/typings/index.d.ts +0 -884
  164. package/cli/yarn.lock +0 -8
  165. package/dist/esm/__tests__/bundle-manager.test.d.ts +0 -1
  166. package/dist/esm/__tests__/bundle-manager.test.js +0 -151
  167. package/dist/esm/__tests__/bundle-manager.test.js.map +0 -1
  168. package/dist/esm/__tests__/config.test.d.ts +0 -1
  169. package/dist/esm/__tests__/config.test.js +0 -70
  170. package/dist/esm/__tests__/config.test.js.map +0 -1
  171. package/dist/esm/__tests__/delta-processor.test.d.ts +0 -1
  172. package/dist/esm/__tests__/delta-processor.test.js +0 -77
  173. package/dist/esm/__tests__/delta-processor.test.js.map +0 -1
  174. package/dist/esm/__tests__/firestore-schema.test.d.ts +0 -1
  175. package/dist/esm/__tests__/firestore-schema.test.js +0 -74
  176. package/dist/esm/__tests__/firestore-schema.test.js.map +0 -1
  177. package/dist/esm/__tests__/integration.test.d.ts +0 -1
  178. package/dist/esm/__tests__/integration.test.js +0 -78
  179. package/dist/esm/__tests__/integration.test.js.map +0 -1
  180. package/dist/esm/__tests__/manifest-reader.test.d.ts +0 -1
  181. package/dist/esm/__tests__/manifest-reader.test.js +0 -271
  182. package/dist/esm/__tests__/manifest-reader.test.js.map +0 -1
  183. package/dist/esm/__tests__/rollout-checker.test.d.ts +0 -1
  184. package/dist/esm/__tests__/rollout-checker.test.js +0 -210
  185. package/dist/esm/__tests__/rollout-checker.test.js.map +0 -1
  186. package/dist/esm/__tests__/security-enforcement.test.d.ts +0 -1
  187. package/dist/esm/__tests__/security-enforcement.test.js +0 -95
  188. package/dist/esm/__tests__/security-enforcement.test.js.map +0 -1
  189. package/dist/esm/__tests__/security.test.d.ts +0 -1
  190. package/dist/esm/__tests__/security.test.js +0 -54
  191. package/dist/esm/__tests__/security.test.js.map +0 -1
  192. package/dist/esm/__tests__/version-manager.test.d.ts +0 -1
  193. package/dist/esm/__tests__/version-manager.test.js +0 -45
  194. package/dist/esm/__tests__/version-manager.test.js.map +0 -1
  195. package/dist/esm/app-review/app-review-manager.js.map +0 -1
  196. package/dist/esm/app-review/index.js.map +0 -1
  197. package/dist/esm/app-review/platform-review-handler.js.map +0 -1
  198. package/dist/esm/app-review/review-conditions-checker.js.map +0 -1
  199. package/dist/esm/app-review/review-rate-limiter.js.map +0 -1
  200. package/dist/esm/app-review/types.js.map +0 -1
  201. package/dist/esm/app-update/app-update-checker.js.map +0 -1
  202. package/dist/esm/app-update/app-update-installer.js.map +0 -1
  203. package/dist/esm/app-update/app-update-manager.js.map +0 -1
  204. package/dist/esm/app-update/app-update-notifier.js.map +0 -1
  205. package/dist/esm/app-update/index.js.map +0 -1
  206. package/dist/esm/app-update/platform-app-update.js.map +0 -1
  207. package/dist/esm/app-update/types.js.map +0 -1
  208. package/dist/esm/background-update/background-scheduler.js.map +0 -1
  209. package/dist/esm/background-update/index.js.map +0 -1
  210. package/dist/esm/background-update/notification-manager.js.map +0 -1
  211. package/dist/esm/config/support.js.map +0 -1
  212. package/dist/esm/core/analytics.js.map +0 -1
  213. package/dist/esm/core/cache-manager.js.map +0 -1
  214. package/dist/esm/core/config.js.map +0 -1
  215. package/dist/esm/core/errors.js.map +0 -1
  216. package/dist/esm/core/event-emitter.js.map +0 -1
  217. package/dist/esm/core/logger.js.map +0 -1
  218. package/dist/esm/core/performance.js.map +0 -1
  219. package/dist/esm/core/plugin-manager.js.map +0 -1
  220. package/dist/esm/core/security.js.map +0 -1
  221. package/dist/esm/definitions.js.map +0 -1
  222. package/dist/esm/firestore/firestore-client.d.ts +0 -109
  223. package/dist/esm/firestore/firestore-client.js +0 -264
  224. package/dist/esm/firestore/firestore-client.js.map +0 -1
  225. package/dist/esm/firestore/index.d.ts +0 -11
  226. package/dist/esm/firestore/index.js +0 -11
  227. package/dist/esm/firestore/index.js.map +0 -1
  228. package/dist/esm/firestore/manifest-reader.d.ts +0 -87
  229. package/dist/esm/firestore/manifest-reader.js +0 -294
  230. package/dist/esm/firestore/manifest-reader.js.map +0 -1
  231. package/dist/esm/firestore/schema.d.ts +0 -507
  232. package/dist/esm/firestore/schema.js +0 -73
  233. package/dist/esm/firestore/schema.js.map +0 -1
  234. package/dist/esm/index.js.map +0 -1
  235. package/dist/esm/live-update/bundle-manager.js.map +0 -1
  236. package/dist/esm/live-update/certificate-pinning.js.map +0 -1
  237. package/dist/esm/live-update/delta-processor.js.map +0 -1
  238. package/dist/esm/live-update/download-manager.js.map +0 -1
  239. package/dist/esm/live-update/rollout-checker.js.map +0 -1
  240. package/dist/esm/live-update/update-manager.js.map +0 -1
  241. package/dist/esm/live-update/version-manager.js.map +0 -1
  242. package/dist/esm/plugin.js.map +0 -1
  243. package/dist/esm/security/crypto.js.map +0 -1
  244. package/dist/esm/security/validator.js.map +0 -1
  245. package/dist/esm/web.js.map +0 -1
  246. package/dist/plugin.cjs.js.map +0 -1
  247. package/dist/plugin.esm.js.map +0 -1
  248. package/dist/plugin.js.map +0 -1
  249. package/docs/FIREBASE_INTEGRATION_TRACKER.md +0 -321
  250. package/docs/FIREBASE_QUERIES_AND_INDEXES_AUDIT.md +0 -221
  251. package/docs/examples/firebase-backend-example.md +0 -27
  252. package/docs/features/laravel-nova-backend/credentials.ignore.md +0 -34
  253. package/docs/guides/no-cost-backend-implementation-plan.md +0 -77
  254. package/docs/guides/no-cost-firestore-google-drive-backend.md +0 -60
  255. package/docs/project-profiles/native-update-capacitor-update-platform-project-profile-last-updated-2026-03-16.md +0 -454
  256. package/docs/project-profiles/native-update-capacitor-update-platform-project-profile-last-updated-2026-03-24.md +0 -66
  257. package/docs/project-profiles/native-update-capacitor-update-platform-project-profile-last-updated-2026-03-25.md +0 -67
  258. /package/docs/{MARKETING_WEBSITE_PLAN.md → archive/MARKETING_WEBSITE_PLAN.md} +0 -0
@@ -2,142 +2,141 @@
2
2
 
3
3
  ## Metadata
4
4
 
5
- - **Reference Date:** 2026-03-16
6
- - **Last Updated:** 2026-03-16
5
+ - **Reference Date:** 2026-05-18
6
+ - **Last Updated:** 2026-05-18
7
7
 
8
8
  ## Main Integration Surfaces
9
9
 
10
- - Firebase Authentication
11
- - Firestore
12
- - Google Identity Services
13
- - Google Drive API
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)
14
16
  - Capacitor runtime APIs
15
- - Android native APIs / Play-related update capabilities
16
- - iOS native APIs / StoreKit-related review and update capabilities
17
+ - Android native APIs (Play Core update, Play Review, WorkManager)
18
+ - iOS native APIs (StoreKit SKStoreReviewController, BGTaskScheduler)
17
19
 
18
20
  ## Authentication Model
19
21
 
20
22
  ### Sign-In Method
21
23
 
22
- - Primary auth flow is Google sign-in via Firebase popup
23
- - user records are created on first login
24
- - admin privilege is stored in Firestore and seeded from owner email logic
25
-
26
- ### User Document (`users/{uid}`)
27
-
28
- Key fields visible in types and auth flow:
29
-
30
- - `uid`
31
- - `email`
32
- - `displayName`
33
- - `photoURL`
34
- - `provider`
35
- - `emailVerified`
36
- - `createdAt`
37
- - `lastLogin`
38
- - `driveConnected`
39
- - `driveEmail`
40
- - `driveConnectedAt`
41
- - `plan`
42
- - `planStartDate`
43
- - `planEndDate`
44
- - `appsCount`
45
- - `buildsCount`
46
- - `storageUsed`
47
- - `preferences`
48
- - `isAdmin`
49
- - `updatedAt`
50
-
51
- ### User Preferences
52
-
53
- - `emailNotifications`
54
- - `updateNotifications`
55
- - `theme`
56
- - `language`
57
-
58
- ## App Model
59
-
60
- ### App Document (`apps/{appId}`)
61
-
62
- - `userId`
63
- - `name`
64
- - `packageId`
65
- - `icon`
66
- - `description`
67
- - `platforms`
68
- - `channels`
69
- - `apiKey`
70
- - `totalBuilds`
71
- - `activeUsers`
72
- - `lastBuildDate`
73
- - `createdAt`
74
- - `updatedAt`
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`
75
29
 
76
- ### Channel Config
30
+ ### Role Assignment
77
31
 
78
- Per channel:
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)
79
36
 
80
- - `enabled`
81
- - `autoUpdate`
82
- - `updateStrategy`
83
- - `requireUserConsent`
84
- - `minVersion`
37
+ ### Token Lifecycle
85
38
 
86
- Default observed behavior:
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
87
43
 
88
- - production enabled
89
- - staging enabled
90
- - development enabled and auto-update true
44
+ ## MySQL Schema (Laravel migrations)
91
45
 
92
- ## API Key Model
46
+ Migrations live in `backend/database/migrations/`. The following tables exist:
93
47
 
94
- ### API Key Document (`apiKeys/{apiKey}`)
48
+ ### `users`
95
49
 
96
- Used so mobile apps can query manifests using an API key rather than dashboard auth. Observed fields include:
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
97
59
 
98
- - `appId`
99
- - `packageId`
100
- - `userId`
101
- - `createdAt`
60
+ ### `apps`
102
61
 
103
- There is also an app-facing manifests subcollection under this API key path.
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
104
68
 
105
- ## Build Model
69
+ ### `api_keys`
106
70
 
107
- ### Build Document (`builds/{buildId}`)
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
108
75
 
109
- Observed/typed fields include:
76
+ ### `signing_keys`
110
77
 
111
- - `id`
112
- - `userId`
113
- - `appId`
114
- - `version`
115
- - `buildNumber`
116
- - `channel`
117
- - `platform`
118
- - `fileName`
119
- - `fileSize`
120
- - `mimeType`
121
- - `checksum`
122
- - `signature`
123
- - `driveFileId`
124
- - `driveFileUrl`
125
- - `driveFolderId`
126
- - `fileManifest`
127
- - `manifestDriveId`
128
- - `releaseNotes`
129
- - `releaseType`
130
- - `isPreRelease`
131
- - `minNativeVersion`
132
- - `uploadedAt`
133
- - `uploadedBy`
134
- - `uploadDuration`
135
- - `status`
136
- - `processingSteps`
137
- - `analytics`
138
- - `updatedAt`
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`
139
87
 
140
- ### Build Status Values
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
141
140
 
142
141
  - `uploading`
143
142
  - `processing`
@@ -145,163 +144,101 @@ Observed/typed fields include:
145
144
  - `archived`
146
145
  - `failed`
147
146
 
148
- ## Manifest Model
149
-
150
- ### Manifest Document (`manifests/{appId}_{channel}`)
151
-
152
- This is the primary document used for update checks.
153
-
154
- Fields:
155
-
156
- - `appId`
157
- - `channel`
158
- - `current`
159
- - `deltas`
160
- - `rollout`
161
- - `previousVersions`
162
- - `updatedAt`
163
- - `updatedBy`
164
-
165
- ### Current Version Block
166
-
167
- - `version`
168
- - `bundleId`
169
- - `bundleUrl`
170
- - `manifestUrl`
171
- - `checksum`
172
- - `signature`
173
- - `size`
174
- - `releaseNotes`
175
- - `releaseDate`
176
- - `mandatory`
177
- - `minNativeVersion`
178
-
179
- ### Rollout Config
180
-
181
- - `enabled`
182
- - `percentage`
183
- - `startTime`
184
- - `endTime`
185
- - optional `targetSegments`
186
- - optional `schedule`
187
-
188
- ### Rollout Schedule
189
-
190
- - `immediate`
191
- - `gradual`
192
- - `scheduled`
193
-
194
- ## Delta Model
195
-
196
- ### Delta Document
197
-
198
- Used for pre-computed patch information:
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:
199
193
 
200
194
  - `appId`
201
- - `fromVersion`
202
- - `toVersion`
195
+ - `fromVersion`, `toVersion`
203
196
  - `channel`
204
- - `patchDriveId`
205
- - `patchUrl`
206
- - `patchSize`
207
- - `patchChecksum`
208
- - `sourceChecksum`
209
- - `targetChecksum`
210
- - `generatedAt`
211
- - `generationDuration`
212
- - `algorithm`
213
- - `compressionRatio`
197
+ - `patchUrl`, `patchSize`, `patchChecksum`
198
+ - `sourceChecksum`, `targetChecksum`
199
+ - `algorithm`, `compressionRatio`
214
200
  - `status`
215
201
 
216
- ## Analytics Model
217
-
218
- ### Analytics Batch Document (`analytics_batch/{batchId}`)
219
-
220
- - `appId`
221
- - `channel`
222
- - `windowStart`
223
- - `windowEnd`
224
- - `events`
225
- - `versionStats`
226
- - `platformStats`
227
- - `errorSamples`
228
- - `createdAt`
229
-
230
- ### Events Aggregated
231
-
232
- - update checks
233
- - downloads
234
- - installs
235
- - rollbacks
236
- - errors
237
-
238
- ## Drive Token Model
239
-
240
- ### Drive Token Document (`drive_tokens/{userId}`)
241
-
242
- Observed fields include:
243
-
244
- - `userId`
245
- - `accessToken`
246
- - `refreshToken`
247
- - `tokenType`
248
- - `scope`
249
- - `expiresAt`
250
- - Google account metadata such as email/name/picture/id/locale
251
- - `encryptionMethod`
252
- - `iv`
253
- - `authTag`
254
- - `createdAt`
255
- - `updatedAt`
256
-
257
- ## Google Drive Integration Flow
202
+ ## Google Drive Integration Flow (server-side)
258
203
 
259
204
  ### Connect Flow
260
205
 
261
- 1. Load Google Identity Services script
262
- 2. Request Drive and profile scopes
263
- 3. Exchange response into usable access token
264
- 4. Fetch Google user profile info
265
- 5. Store token metadata in Firestore
266
- 6. Update `users/{uid}` Drive connection fields
267
-
268
- ### Upload Flow
269
-
270
- 1. User selects ZIP
271
- 2. Validate file
272
- 3. Calculate SHA-256 checksum
273
- 4. Generate file manifest from ZIP contents
274
- 5. Upload ZIP to Drive
275
- 6. Upload manifest JSON to Drive
276
- 7. Make Drive files publicly retrievable as needed
277
- 8. Write build record in Firestore
278
- 9. Update channel manifest document
279
-
280
- ## No-Cost Backend Operating Model
281
-
282
- The intended website publishing model is:
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
283
213
 
284
- - browser-based uploads
285
- - Google Drive for bundle storage
286
- - Firestore for metadata and app-facing manifests
287
- - no paid compute required for core publish/check/download flow
214
+ ### Upload Flow (Laravel-driven)
288
215
 
289
- This is a central strategic assumption in the repo’s website guidance.
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
290
225
 
291
- ## App-Facing Manifest Paths Mentioned In CLAUDE Guidance
226
+ ## App-Facing Manifest Paths
292
227
 
293
- - `/apiKeys/{apiKey}/manifests/{channel}`
294
- - `/manifests/{appId}_{channel}`
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)
295
230
 
296
231
  ## Security-Relevant Data Points
297
232
 
298
- - checksums are stored and used for validation
299
- - signature support exists
300
- - manifest and build docs carry release metadata
301
- - bundle file manifests support file-level integrity and delta logic
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
302
238
 
303
239
  ## Data Ownership Notes
304
240
 
305
- - The website messaging emphasizes that user build files are stored in the users Google Drive
306
- - user account data and release metadata live in Firebase/Firestore
307
- - deletion/account settings pages document data handling expectations for legal/compliance messaging
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