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