native-update 1.0.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.
- package/CapacitorNativeUpdate.podspec +18 -0
- package/LICENSE +21 -0
- package/Readme.md +451 -0
- package/android/build.gradle +92 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/android/gradle.properties +17 -0
- package/android/proguard-rules.pro +29 -0
- package/android/settings.gradle +2 -0
- package/android/src/main/AndroidManifest.xml +34 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/AppReviewPlugin.kt +153 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/AppUpdatePlugin.kt +275 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundNotificationManager.kt +390 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateManager.kt +46 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdatePlugin.kt +333 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/BackgroundUpdateWorker.kt +251 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/CapacitorNativeUpdatePlugin.kt +265 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/LiveUpdatePlugin.kt +526 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/NotificationActionReceiver.kt +99 -0
- package/android/src/main/java/com/aoneahsan/nativeupdate/SecurityManager.kt +249 -0
- package/dist/esm/__tests__/bundle-manager.test.d.ts +1 -0
- package/dist/esm/__tests__/bundle-manager.test.js +123 -0
- package/dist/esm/__tests__/bundle-manager.test.js.map +1 -0
- package/dist/esm/__tests__/config.test.d.ts +1 -0
- package/dist/esm/__tests__/config.test.js +69 -0
- package/dist/esm/__tests__/config.test.js.map +1 -0
- package/dist/esm/__tests__/integration.test.d.ts +1 -0
- package/dist/esm/__tests__/integration.test.js +78 -0
- package/dist/esm/__tests__/integration.test.js.map +1 -0
- package/dist/esm/__tests__/security.test.d.ts +1 -0
- package/dist/esm/__tests__/security.test.js +54 -0
- package/dist/esm/__tests__/security.test.js.map +1 -0
- package/dist/esm/__tests__/version-manager.test.d.ts +1 -0
- package/dist/esm/__tests__/version-manager.test.js +45 -0
- package/dist/esm/__tests__/version-manager.test.js.map +1 -0
- package/dist/esm/app-review/app-review-manager.d.ts +24 -0
- package/dist/esm/app-review/app-review-manager.js +195 -0
- package/dist/esm/app-review/app-review-manager.js.map +1 -0
- package/dist/esm/app-review/index.d.ts +5 -0
- package/dist/esm/app-review/index.js +6 -0
- package/dist/esm/app-review/index.js.map +1 -0
- package/dist/esm/app-review/platform-review-handler.d.ts +20 -0
- package/dist/esm/app-review/platform-review-handler.js +138 -0
- package/dist/esm/app-review/platform-review-handler.js.map +1 -0
- package/dist/esm/app-review/review-conditions-checker.d.ts +22 -0
- package/dist/esm/app-review/review-conditions-checker.js +155 -0
- package/dist/esm/app-review/review-conditions-checker.js.map +1 -0
- package/dist/esm/app-review/review-rate-limiter.d.ts +23 -0
- package/dist/esm/app-review/review-rate-limiter.js +164 -0
- package/dist/esm/app-review/review-rate-limiter.js.map +1 -0
- package/dist/esm/app-review/types.d.ts +41 -0
- package/dist/esm/app-review/types.js +2 -0
- package/dist/esm/app-review/types.js.map +1 -0
- package/dist/esm/app-update/app-update-checker.d.ts +13 -0
- package/dist/esm/app-update/app-update-checker.js +104 -0
- package/dist/esm/app-update/app-update-checker.js.map +1 -0
- package/dist/esm/app-update/app-update-installer.d.ts +19 -0
- package/dist/esm/app-update/app-update-installer.js +123 -0
- package/dist/esm/app-update/app-update-installer.js.map +1 -0
- package/dist/esm/app-update/app-update-manager.d.ts +28 -0
- package/dist/esm/app-update/app-update-manager.js +199 -0
- package/dist/esm/app-update/app-update-manager.js.map +1 -0
- package/dist/esm/app-update/app-update-notifier.d.ts +14 -0
- package/dist/esm/app-update/app-update-notifier.js +100 -0
- package/dist/esm/app-update/app-update-notifier.js.map +1 -0
- package/dist/esm/app-update/index.d.ts +6 -0
- package/dist/esm/app-update/index.js +7 -0
- package/dist/esm/app-update/index.js.map +1 -0
- package/dist/esm/app-update/platform-app-update.d.ts +19 -0
- package/dist/esm/app-update/platform-app-update.js +129 -0
- package/dist/esm/app-update/platform-app-update.js.map +1 -0
- package/dist/esm/app-update/types.d.ts +58 -0
- package/dist/esm/app-update/types.js +12 -0
- package/dist/esm/app-update/types.js.map +1 -0
- package/dist/esm/background-update/background-scheduler.d.ts +17 -0
- package/dist/esm/background-update/background-scheduler.js +195 -0
- package/dist/esm/background-update/background-scheduler.js.map +1 -0
- package/dist/esm/background-update/index.d.ts +3 -0
- package/dist/esm/background-update/index.js +3 -0
- package/dist/esm/background-update/index.js.map +1 -0
- package/dist/esm/background-update/notification-manager.d.ts +29 -0
- package/dist/esm/background-update/notification-manager.js +89 -0
- package/dist/esm/background-update/notification-manager.js.map +1 -0
- package/dist/esm/core/analytics.d.ts +70 -0
- package/dist/esm/core/analytics.js +137 -0
- package/dist/esm/core/analytics.js.map +1 -0
- package/dist/esm/core/cache-manager.d.ts +72 -0
- package/dist/esm/core/cache-manager.js +275 -0
- package/dist/esm/core/cache-manager.js.map +1 -0
- package/dist/esm/core/config.d.ts +48 -0
- package/dist/esm/core/config.js +83 -0
- package/dist/esm/core/config.js.map +1 -0
- package/dist/esm/core/errors.d.ts +51 -0
- package/dist/esm/core/errors.js +80 -0
- package/dist/esm/core/errors.js.map +1 -0
- package/dist/esm/core/logger.d.ts +21 -0
- package/dist/esm/core/logger.js +109 -0
- package/dist/esm/core/logger.js.map +1 -0
- package/dist/esm/core/performance.d.ts +53 -0
- package/dist/esm/core/performance.js +140 -0
- package/dist/esm/core/performance.js.map +1 -0
- package/dist/esm/core/plugin-manager.d.ts +66 -0
- package/dist/esm/core/plugin-manager.js +148 -0
- package/dist/esm/core/plugin-manager.js.map +1 -0
- package/dist/esm/core/security.d.ts +93 -0
- package/dist/esm/core/security.js +315 -0
- package/dist/esm/core/security.js.map +1 -0
- package/dist/esm/definitions.d.ts +639 -0
- package/dist/esm/definitions.js +103 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +12 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/live-update/bundle-manager.d.ts +94 -0
- package/dist/esm/live-update/bundle-manager.js +310 -0
- package/dist/esm/live-update/bundle-manager.js.map +1 -0
- package/dist/esm/live-update/certificate-pinning.d.ts +38 -0
- package/dist/esm/live-update/certificate-pinning.js +78 -0
- package/dist/esm/live-update/certificate-pinning.js.map +1 -0
- package/dist/esm/live-update/download-manager.d.ts +67 -0
- package/dist/esm/live-update/download-manager.js +319 -0
- package/dist/esm/live-update/download-manager.js.map +1 -0
- package/dist/esm/live-update/update-manager.d.ts +52 -0
- package/dist/esm/live-update/update-manager.js +294 -0
- package/dist/esm/live-update/update-manager.js.map +1 -0
- package/dist/esm/live-update/version-manager.d.ts +84 -0
- package/dist/esm/live-update/version-manager.js +335 -0
- package/dist/esm/live-update/version-manager.js.map +1 -0
- package/dist/esm/plugin.d.ts +6 -0
- package/dist/esm/plugin.js +283 -0
- package/dist/esm/plugin.js.map +1 -0
- package/dist/esm/security/crypto.d.ts +25 -0
- package/dist/esm/security/crypto.js +70 -0
- package/dist/esm/security/crypto.js.map +1 -0
- package/dist/esm/security/validator.d.ts +60 -0
- package/dist/esm/security/validator.js +143 -0
- package/dist/esm/security/validator.js.map +1 -0
- package/dist/esm/web.d.ts +74 -0
- package/dist/esm/web.js +595 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +2 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.esm.js +2 -0
- package/dist/plugin.esm.js.map +1 -0
- package/dist/plugin.js +3 -0
- package/dist/plugin.js.map +1 -0
- package/docs/APP_REVIEW_GUIDE.md +768 -0
- package/docs/BUNDLE_SIGNING.md +264 -0
- package/docs/LIVE_UPDATES_GUIDE.md +650 -0
- package/docs/MIGRATION.md +192 -0
- package/docs/NATIVE_UPDATES_GUIDE.md +694 -0
- package/docs/QUICK_START.md +606 -0
- package/docs/README.md +111 -0
- package/docs/REMAINING_FEATURES.md +139 -0
- package/docs/api/app-review-api.md +259 -0
- package/docs/api/app-update-api.md +238 -0
- package/docs/api/events-api.md +451 -0
- package/docs/api/live-update-api.md +265 -0
- package/docs/background-updates.md +392 -0
- package/docs/examples/advanced-scenarios.md +410 -0
- package/docs/examples/basic-usage.md +185 -0
- package/docs/features/app-reviews.md +975 -0
- package/docs/features/app-updates.md +785 -0
- package/docs/features/live-updates.md +633 -0
- package/docs/getting-started/configuration.md +468 -0
- package/docs/getting-started/installation.md +209 -0
- package/docs/getting-started/quick-start.md +379 -0
- package/docs/guides/deployment-guide.md +333 -0
- package/docs/guides/migration-from-codepush.md +142 -0
- package/docs/guides/security-best-practices.md +1057 -0
- package/docs/guides/testing-guide.md +373 -0
- package/docs/production-readiness.md +478 -0
- package/docs/security/certificate-pinning.md +122 -0
- package/docs/server-requirements.md +147 -0
- package/ios/Plugin/AppReview/AppReviewPlugin.swift +158 -0
- package/ios/Plugin/AppUpdate/AppUpdatePlugin.swift +234 -0
- package/ios/Plugin/BackgroundUpdate/BackgroundNotificationManager.swift +329 -0
- package/ios/Plugin/BackgroundUpdate/BackgroundUpdatePlugin.swift +396 -0
- package/ios/Plugin/CapacitorNativeUpdatePlugin.m +45 -0
- package/ios/Plugin/CapacitorNativeUpdatePlugin.swift +190 -0
- package/ios/Plugin/Info.plist +43 -0
- package/ios/Plugin/LiveUpdate/LiveUpdatePlugin.swift +689 -0
- package/ios/Plugin/LiveUpdate/WebViewConfiguration.swift +45 -0
- package/ios/Plugin/Security/SecurityManager.swift +289 -0
- package/package.json +90 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enums
|
|
3
|
+
*/
|
|
4
|
+
export var BackgroundUpdateType;
|
|
5
|
+
(function (BackgroundUpdateType) {
|
|
6
|
+
BackgroundUpdateType["APP_UPDATE"] = "app_update";
|
|
7
|
+
BackgroundUpdateType["LIVE_UPDATE"] = "live_update";
|
|
8
|
+
BackgroundUpdateType["BOTH"] = "both";
|
|
9
|
+
})(BackgroundUpdateType || (BackgroundUpdateType = {}));
|
|
10
|
+
export var NotificationPriority;
|
|
11
|
+
(function (NotificationPriority) {
|
|
12
|
+
NotificationPriority["MIN"] = "min";
|
|
13
|
+
NotificationPriority["LOW"] = "low";
|
|
14
|
+
NotificationPriority["DEFAULT"] = "default";
|
|
15
|
+
NotificationPriority["HIGH"] = "high";
|
|
16
|
+
NotificationPriority["MAX"] = "max";
|
|
17
|
+
})(NotificationPriority || (NotificationPriority = {}));
|
|
18
|
+
export var UpdateStrategy;
|
|
19
|
+
(function (UpdateStrategy) {
|
|
20
|
+
UpdateStrategy["IMMEDIATE"] = "immediate";
|
|
21
|
+
UpdateStrategy["BACKGROUND"] = "background";
|
|
22
|
+
UpdateStrategy["MANUAL"] = "manual";
|
|
23
|
+
})(UpdateStrategy || (UpdateStrategy = {}));
|
|
24
|
+
export var UpdateMode;
|
|
25
|
+
(function (UpdateMode) {
|
|
26
|
+
UpdateMode["IMMEDIATE"] = "immediate";
|
|
27
|
+
UpdateMode["ON_NEXT_RESTART"] = "on_next_restart";
|
|
28
|
+
UpdateMode["ON_NEXT_RESUME"] = "on_next_resume";
|
|
29
|
+
})(UpdateMode || (UpdateMode = {}));
|
|
30
|
+
export var InstallMode;
|
|
31
|
+
(function (InstallMode) {
|
|
32
|
+
InstallMode["IMMEDIATE"] = "immediate";
|
|
33
|
+
InstallMode["ON_NEXT_RESTART"] = "on_next_restart";
|
|
34
|
+
InstallMode["ON_NEXT_RESUME"] = "on_next_resume";
|
|
35
|
+
})(InstallMode || (InstallMode = {}));
|
|
36
|
+
export var ChecksumAlgorithm;
|
|
37
|
+
(function (ChecksumAlgorithm) {
|
|
38
|
+
ChecksumAlgorithm["SHA256"] = "SHA-256";
|
|
39
|
+
ChecksumAlgorithm["SHA512"] = "SHA-512";
|
|
40
|
+
})(ChecksumAlgorithm || (ChecksumAlgorithm = {}));
|
|
41
|
+
export var SyncStatus;
|
|
42
|
+
(function (SyncStatus) {
|
|
43
|
+
SyncStatus["UP_TO_DATE"] = "UP_TO_DATE";
|
|
44
|
+
SyncStatus["UPDATE_AVAILABLE"] = "UPDATE_AVAILABLE";
|
|
45
|
+
SyncStatus["UPDATE_INSTALLED"] = "UPDATE_INSTALLED";
|
|
46
|
+
SyncStatus["ERROR"] = "ERROR";
|
|
47
|
+
})(SyncStatus || (SyncStatus = {}));
|
|
48
|
+
export var BundleStatus;
|
|
49
|
+
(function (BundleStatus) {
|
|
50
|
+
BundleStatus["PENDING"] = "PENDING";
|
|
51
|
+
BundleStatus["DOWNLOADING"] = "DOWNLOADING";
|
|
52
|
+
BundleStatus["READY"] = "READY";
|
|
53
|
+
BundleStatus["ACTIVE"] = "ACTIVE";
|
|
54
|
+
BundleStatus["FAILED"] = "FAILED";
|
|
55
|
+
})(BundleStatus || (BundleStatus = {}));
|
|
56
|
+
export var InstallStatus;
|
|
57
|
+
(function (InstallStatus) {
|
|
58
|
+
InstallStatus["UNKNOWN"] = "UNKNOWN";
|
|
59
|
+
InstallStatus["PENDING"] = "PENDING";
|
|
60
|
+
InstallStatus["DOWNLOADING"] = "DOWNLOADING";
|
|
61
|
+
InstallStatus["DOWNLOADED"] = "DOWNLOADED";
|
|
62
|
+
InstallStatus["INSTALLING"] = "INSTALLING";
|
|
63
|
+
InstallStatus["INSTALLED"] = "INSTALLED";
|
|
64
|
+
InstallStatus["FAILED"] = "FAILED";
|
|
65
|
+
InstallStatus["CANCELED"] = "CANCELED";
|
|
66
|
+
})(InstallStatus || (InstallStatus = {}));
|
|
67
|
+
export var UpdateErrorCode;
|
|
68
|
+
(function (UpdateErrorCode) {
|
|
69
|
+
// Network errors
|
|
70
|
+
UpdateErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
|
|
71
|
+
UpdateErrorCode["SERVER_ERROR"] = "SERVER_ERROR";
|
|
72
|
+
UpdateErrorCode["TIMEOUT_ERROR"] = "TIMEOUT_ERROR";
|
|
73
|
+
// Download errors
|
|
74
|
+
UpdateErrorCode["DOWNLOAD_ERROR"] = "DOWNLOAD_ERROR";
|
|
75
|
+
UpdateErrorCode["STORAGE_ERROR"] = "STORAGE_ERROR";
|
|
76
|
+
UpdateErrorCode["SIZE_LIMIT_EXCEEDED"] = "SIZE_LIMIT_EXCEEDED";
|
|
77
|
+
// Security errors
|
|
78
|
+
UpdateErrorCode["VERIFICATION_ERROR"] = "VERIFICATION_ERROR";
|
|
79
|
+
UpdateErrorCode["CHECKSUM_ERROR"] = "CHECKSUM_ERROR";
|
|
80
|
+
UpdateErrorCode["SIGNATURE_ERROR"] = "SIGNATURE_ERROR";
|
|
81
|
+
UpdateErrorCode["INSECURE_URL"] = "INSECURE_URL";
|
|
82
|
+
UpdateErrorCode["INVALID_CERTIFICATE"] = "INVALID_CERTIFICATE";
|
|
83
|
+
UpdateErrorCode["PATH_TRAVERSAL"] = "PATH_TRAVERSAL";
|
|
84
|
+
// Installation errors
|
|
85
|
+
UpdateErrorCode["INSTALL_ERROR"] = "INSTALL_ERROR";
|
|
86
|
+
UpdateErrorCode["ROLLBACK_ERROR"] = "ROLLBACK_ERROR";
|
|
87
|
+
UpdateErrorCode["VERSION_MISMATCH"] = "VERSION_MISMATCH";
|
|
88
|
+
// Permission errors
|
|
89
|
+
UpdateErrorCode["PERMISSION_DENIED"] = "PERMISSION_DENIED";
|
|
90
|
+
// App update errors
|
|
91
|
+
UpdateErrorCode["UPDATE_NOT_AVAILABLE"] = "UPDATE_NOT_AVAILABLE";
|
|
92
|
+
UpdateErrorCode["UPDATE_IN_PROGRESS"] = "UPDATE_IN_PROGRESS";
|
|
93
|
+
UpdateErrorCode["UPDATE_CANCELLED"] = "UPDATE_CANCELLED";
|
|
94
|
+
UpdateErrorCode["PLATFORM_NOT_SUPPORTED"] = "PLATFORM_NOT_SUPPORTED";
|
|
95
|
+
// Review errors
|
|
96
|
+
UpdateErrorCode["REVIEW_NOT_SUPPORTED"] = "REVIEW_NOT_SUPPORTED";
|
|
97
|
+
UpdateErrorCode["QUOTA_EXCEEDED"] = "QUOTA_EXCEEDED";
|
|
98
|
+
UpdateErrorCode["CONDITIONS_NOT_MET"] = "CONDITIONS_NOT_MET";
|
|
99
|
+
// General errors
|
|
100
|
+
UpdateErrorCode["INVALID_CONFIG"] = "INVALID_CONFIG";
|
|
101
|
+
UpdateErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
102
|
+
})(UpdateErrorCode || (UpdateErrorCode = {}));
|
|
103
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAscA;;GAEG;AACH,MAAM,CAAN,IAAY,oBAIX;AAJD,WAAY,oBAAoB;IAC9B,iDAAyB,CAAA;IACzB,mDAA2B,CAAA;IAC3B,qCAAa,CAAA;AACf,CAAC,EAJW,oBAAoB,KAApB,oBAAoB,QAI/B;AAED,MAAM,CAAN,IAAY,oBAMX;AAND,WAAY,oBAAoB;IAC9B,mCAAW,CAAA;IACX,mCAAW,CAAA;IACX,2CAAmB,CAAA;IACnB,qCAAa,CAAA;IACb,mCAAW,CAAA;AACb,CAAC,EANW,oBAAoB,KAApB,oBAAoB,QAM/B;AAED,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,yCAAuB,CAAA;IACvB,2CAAyB,CAAA;IACzB,mCAAiB,CAAA;AACnB,CAAC,EAJW,cAAc,KAAd,cAAc,QAIzB;AAED,MAAM,CAAN,IAAY,UAIX;AAJD,WAAY,UAAU;IACpB,qCAAuB,CAAA;IACvB,iDAAmC,CAAA;IACnC,+CAAiC,CAAA;AACnC,CAAC,EAJW,UAAU,KAAV,UAAU,QAIrB;AAED,MAAM,CAAN,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,sCAAuB,CAAA;IACvB,kDAAmC,CAAA;IACnC,gDAAiC,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AAoB;IACpB,0DAAuC,CAAA;IAEvC,oBAAoB;IACpB,gEAA6C,CAAA;IAC7C,4DAAyC,CAAA;IACzC,wDAAqC,CAAA;IACrC,oEAAiD,CAAA;IAEjD,gBAAgB;IAChB,gEAA6C,CAAA;IAC7C,oDAAiC,CAAA;IACjC,4DAAyC,CAAA;IAEzC,iBAAiB;IACjB,oDAAiC,CAAA;IACjC,kDAA+B,CAAA;AACjC,CAAC,EAzCW,eAAe,KAAf,eAAe,QAyC1B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { CapacitorNativeUpdate } from './plugin';
|
|
2
|
+
export type { CapacitorNativeUpdatePlugin, NativeUpdateCombinedPlugin, NativeUpdateListeners, LiveUpdatePlugin, AppUpdatePlugin, AppReviewPlugin, PluginConfig, UpdateConfig, LiveUpdateConfig, AppUpdateConfig, AppReviewConfig, BundleInfo, BundleStatus, UpdateStrategy, InstallMode, DownloadOptions, DownloadProgressEvent, SyncOptions, SyncResult, DeleteOptions, LatestVersion, ValidateOptions, ValidationResult, AppUpdateInfo, OpenAppStoreOptions, ReviewResult, CanRequestReviewResult, UpdateStateChangedEvent, UpdateError, UpdateErrorCode, } from './definitions';
|
|
3
|
+
export { ErrorCode, CapacitorNativeUpdateError, ConfigurationError, DownloadError, ValidationError, StorageError, UpdateError as UpdateErrorClass, } from './core/errors';
|
|
4
|
+
export { ConfigManager } from './core/config';
|
|
5
|
+
export { Logger, LogLevel } from './core/logger';
|
|
6
|
+
export { SecurityValidator } from './core/security';
|
|
7
|
+
export { PluginManager } from './core/plugin-manager';
|
|
8
|
+
export { CacheManager } from './core/cache-manager';
|
|
9
|
+
export { BundleManager } from './live-update/bundle-manager';
|
|
10
|
+
export { DownloadManager } from './live-update/download-manager';
|
|
11
|
+
export { VersionManager } from './live-update/version-manager';
|
|
12
|
+
export { UpdateManager } from './live-update/update-manager';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Main plugin export
|
|
2
|
+
export { CapacitorNativeUpdate } from './plugin';
|
|
3
|
+
// Error exports
|
|
4
|
+
export { ErrorCode, CapacitorNativeUpdateError, ConfigurationError, DownloadError, ValidationError, StorageError, UpdateError as UpdateErrorClass, } from './core/errors';
|
|
5
|
+
// Core exports for advanced users
|
|
6
|
+
export { ConfigManager } from './core/config';
|
|
7
|
+
export { Logger, LogLevel } from './core/logger';
|
|
8
|
+
export { SecurityValidator } from './core/security';
|
|
9
|
+
export { PluginManager } from './core/plugin-manager';
|
|
10
|
+
export { CacheManager } from './core/cache-manager';
|
|
11
|
+
// Manager exports for advanced users
|
|
12
|
+
export { BundleManager } from './live-update/bundle-manager';
|
|
13
|
+
export { DownloadManager } from './live-update/download-manager';
|
|
14
|
+
export { VersionManager } from './live-update/version-manager';
|
|
15
|
+
export { UpdateManager } from './live-update/update-manager';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAiDjD,gBAAgB;AAChB,OAAO,EACL,SAAS,EACT,0BAA0B,EAC1B,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,YAAY,EACZ,WAAW,IAAI,gBAAgB,GAChC,MAAM,eAAe,CAAC;AAEvB,kCAAkC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,qCAAqC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { BundleInfo } from '../definitions';
|
|
2
|
+
/**
|
|
3
|
+
* Manages bundle storage and lifecycle
|
|
4
|
+
*/
|
|
5
|
+
export declare class BundleManager {
|
|
6
|
+
private readonly STORAGE_KEY;
|
|
7
|
+
private readonly ACTIVE_BUNDLE_KEY;
|
|
8
|
+
private preferences;
|
|
9
|
+
private readonly logger;
|
|
10
|
+
private readonly configManager;
|
|
11
|
+
private cache;
|
|
12
|
+
private cacheExpiry;
|
|
13
|
+
constructor();
|
|
14
|
+
/**
|
|
15
|
+
* Initialize the bundle manager with preferences
|
|
16
|
+
*/
|
|
17
|
+
initialize(): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Load cache from preferences
|
|
20
|
+
*/
|
|
21
|
+
private loadCache;
|
|
22
|
+
/**
|
|
23
|
+
* Save cache to preferences
|
|
24
|
+
*/
|
|
25
|
+
private saveCache;
|
|
26
|
+
/**
|
|
27
|
+
* Save bundle information
|
|
28
|
+
*/
|
|
29
|
+
saveBundleInfo(bundle: BundleInfo): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Validate bundle information
|
|
32
|
+
*/
|
|
33
|
+
private validateBundleInfo;
|
|
34
|
+
/**
|
|
35
|
+
* Get all bundles
|
|
36
|
+
*/
|
|
37
|
+
getAllBundles(): Promise<BundleInfo[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Get bundle by ID
|
|
40
|
+
*/
|
|
41
|
+
getBundle(bundleId: string): Promise<BundleInfo | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Delete bundle
|
|
44
|
+
*/
|
|
45
|
+
deleteBundle(bundleId: string): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Get active bundle
|
|
48
|
+
*/
|
|
49
|
+
getActiveBundle(): Promise<BundleInfo | null>;
|
|
50
|
+
/**
|
|
51
|
+
* Set active bundle
|
|
52
|
+
*/
|
|
53
|
+
setActiveBundle(bundleId: string): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Get active bundle ID
|
|
56
|
+
*/
|
|
57
|
+
getActiveBundleId(): Promise<string | null>;
|
|
58
|
+
/**
|
|
59
|
+
* Clear active bundle
|
|
60
|
+
*/
|
|
61
|
+
clearActiveBundle(): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Clear all bundles
|
|
64
|
+
*/
|
|
65
|
+
clearAllBundles(): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Clean up old bundles
|
|
68
|
+
*/
|
|
69
|
+
cleanupOldBundles(keepCount: number): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Get bundles older than specified time
|
|
72
|
+
*/
|
|
73
|
+
getBundlesOlderThan(timestamp: number): Promise<BundleInfo[]>;
|
|
74
|
+
/**
|
|
75
|
+
* Mark bundle as verified
|
|
76
|
+
*/
|
|
77
|
+
markBundleAsVerified(bundleId: string): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Get total storage used by bundles
|
|
80
|
+
*/
|
|
81
|
+
getTotalStorageUsed(): Promise<number>;
|
|
82
|
+
/**
|
|
83
|
+
* Check if storage limit is exceeded
|
|
84
|
+
*/
|
|
85
|
+
isStorageLimitExceeded(additionalSize?: number): Promise<boolean>;
|
|
86
|
+
/**
|
|
87
|
+
* Create default bundle
|
|
88
|
+
*/
|
|
89
|
+
createDefaultBundle(): BundleInfo;
|
|
90
|
+
/**
|
|
91
|
+
* Clean expired cache entries
|
|
92
|
+
*/
|
|
93
|
+
cleanExpiredBundles(): Promise<void>;
|
|
94
|
+
}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { ConfigManager } from '../core/config';
|
|
2
|
+
import { Logger } from '../core/logger';
|
|
3
|
+
import { StorageError, ErrorCode } from '../core/errors';
|
|
4
|
+
/**
|
|
5
|
+
* Manages bundle storage and lifecycle
|
|
6
|
+
*/
|
|
7
|
+
export class BundleManager {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.STORAGE_KEY = 'capacitor_native_update_bundles';
|
|
10
|
+
this.ACTIVE_BUNDLE_KEY = 'capacitor_native_update_active';
|
|
11
|
+
this.preferences = null;
|
|
12
|
+
this.cache = new Map();
|
|
13
|
+
this.cacheExpiry = 0;
|
|
14
|
+
this.logger = Logger.getInstance();
|
|
15
|
+
this.configManager = ConfigManager.getInstance();
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Initialize the bundle manager with preferences
|
|
19
|
+
*/
|
|
20
|
+
async initialize() {
|
|
21
|
+
this.preferences = this.configManager.get('preferences');
|
|
22
|
+
if (!this.preferences) {
|
|
23
|
+
throw new StorageError(ErrorCode.MISSING_DEPENDENCY, 'Preferences not configured. Please configure the plugin first.');
|
|
24
|
+
}
|
|
25
|
+
await this.loadCache();
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Load cache from preferences
|
|
29
|
+
*/
|
|
30
|
+
async loadCache() {
|
|
31
|
+
if (Date.now() < this.cacheExpiry) {
|
|
32
|
+
return; // Cache still valid
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const { value } = await this.preferences.get({ key: this.STORAGE_KEY });
|
|
36
|
+
if (value) {
|
|
37
|
+
const bundles = JSON.parse(value);
|
|
38
|
+
this.cache.clear();
|
|
39
|
+
bundles.forEach((bundle) => this.cache.set(bundle.bundleId, bundle));
|
|
40
|
+
}
|
|
41
|
+
this.cacheExpiry = Date.now() + 5000; // 5 second cache
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
this.logger.error('Failed to load bundles from storage', error);
|
|
45
|
+
this.cache.clear();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Save cache to preferences
|
|
50
|
+
*/
|
|
51
|
+
async saveCache() {
|
|
52
|
+
try {
|
|
53
|
+
const bundles = Array.from(this.cache.values());
|
|
54
|
+
await this.preferences.set({
|
|
55
|
+
key: this.STORAGE_KEY,
|
|
56
|
+
value: JSON.stringify(bundles),
|
|
57
|
+
});
|
|
58
|
+
this.logger.debug('Saved bundles to storage', { count: bundles.length });
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
throw new StorageError(ErrorCode.STORAGE_FULL, 'Failed to save bundles to storage', undefined, error);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Save bundle information
|
|
66
|
+
*/
|
|
67
|
+
async saveBundleInfo(bundle) {
|
|
68
|
+
this.validateBundleInfo(bundle);
|
|
69
|
+
this.cache.set(bundle.bundleId, bundle);
|
|
70
|
+
await this.saveCache();
|
|
71
|
+
this.logger.info('Bundle saved', {
|
|
72
|
+
bundleId: bundle.bundleId,
|
|
73
|
+
version: bundle.version,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Validate bundle information
|
|
78
|
+
*/
|
|
79
|
+
validateBundleInfo(bundle) {
|
|
80
|
+
if (!bundle.bundleId || typeof bundle.bundleId !== 'string') {
|
|
81
|
+
throw new StorageError(ErrorCode.INVALID_BUNDLE_FORMAT, 'Invalid bundle ID');
|
|
82
|
+
}
|
|
83
|
+
if (!bundle.version || typeof bundle.version !== 'string') {
|
|
84
|
+
throw new StorageError(ErrorCode.INVALID_BUNDLE_FORMAT, 'Invalid bundle version');
|
|
85
|
+
}
|
|
86
|
+
if (!bundle.path || typeof bundle.path !== 'string') {
|
|
87
|
+
throw new StorageError(ErrorCode.INVALID_BUNDLE_FORMAT, 'Invalid bundle path');
|
|
88
|
+
}
|
|
89
|
+
if (typeof bundle.size !== 'number' || bundle.size < 0) {
|
|
90
|
+
throw new StorageError(ErrorCode.INVALID_BUNDLE_FORMAT, 'Invalid bundle size');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Get all bundles
|
|
95
|
+
*/
|
|
96
|
+
async getAllBundles() {
|
|
97
|
+
await this.loadCache();
|
|
98
|
+
return Array.from(this.cache.values());
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get bundle by ID
|
|
102
|
+
*/
|
|
103
|
+
async getBundle(bundleId) {
|
|
104
|
+
if (!bundleId) {
|
|
105
|
+
throw new StorageError(ErrorCode.INVALID_BUNDLE_FORMAT, 'Bundle ID is required');
|
|
106
|
+
}
|
|
107
|
+
await this.loadCache();
|
|
108
|
+
return this.cache.get(bundleId) || null;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Delete bundle
|
|
112
|
+
*/
|
|
113
|
+
async deleteBundle(bundleId) {
|
|
114
|
+
if (!bundleId) {
|
|
115
|
+
throw new StorageError(ErrorCode.INVALID_BUNDLE_FORMAT, 'Bundle ID is required');
|
|
116
|
+
}
|
|
117
|
+
await this.loadCache();
|
|
118
|
+
const bundle = this.cache.get(bundleId);
|
|
119
|
+
if (!bundle) {
|
|
120
|
+
this.logger.warn('Attempted to delete non-existent bundle', { bundleId });
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
this.cache.delete(bundleId);
|
|
124
|
+
await this.saveCache();
|
|
125
|
+
// If this was the active bundle, clear it
|
|
126
|
+
const activeBundleId = await this.getActiveBundleId();
|
|
127
|
+
if (activeBundleId === bundleId) {
|
|
128
|
+
await this.clearActiveBundle();
|
|
129
|
+
}
|
|
130
|
+
this.logger.info('Bundle deleted', { bundleId });
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Get active bundle
|
|
134
|
+
*/
|
|
135
|
+
async getActiveBundle() {
|
|
136
|
+
const activeBundleId = await this.getActiveBundleId();
|
|
137
|
+
if (!activeBundleId)
|
|
138
|
+
return null;
|
|
139
|
+
return this.getBundle(activeBundleId);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Set active bundle
|
|
143
|
+
*/
|
|
144
|
+
async setActiveBundle(bundleId) {
|
|
145
|
+
if (!bundleId) {
|
|
146
|
+
throw new StorageError(ErrorCode.INVALID_BUNDLE_FORMAT, 'Bundle ID is required');
|
|
147
|
+
}
|
|
148
|
+
const bundle = await this.getBundle(bundleId);
|
|
149
|
+
if (!bundle) {
|
|
150
|
+
throw new StorageError(ErrorCode.FILE_NOT_FOUND, `Bundle ${bundleId} not found`);
|
|
151
|
+
}
|
|
152
|
+
// Update previous active bundle status
|
|
153
|
+
const previousActive = await this.getActiveBundle();
|
|
154
|
+
if (previousActive && previousActive.bundleId !== bundleId) {
|
|
155
|
+
previousActive.status = 'READY';
|
|
156
|
+
await this.saveBundleInfo(previousActive);
|
|
157
|
+
}
|
|
158
|
+
// Set new active bundle
|
|
159
|
+
bundle.status = 'ACTIVE';
|
|
160
|
+
await this.saveBundleInfo(bundle);
|
|
161
|
+
await this.preferences.set({
|
|
162
|
+
key: this.ACTIVE_BUNDLE_KEY,
|
|
163
|
+
value: bundleId,
|
|
164
|
+
});
|
|
165
|
+
this.logger.info('Active bundle set', {
|
|
166
|
+
bundleId,
|
|
167
|
+
version: bundle.version,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Get active bundle ID
|
|
172
|
+
*/
|
|
173
|
+
async getActiveBundleId() {
|
|
174
|
+
try {
|
|
175
|
+
const { value } = await this.preferences.get({
|
|
176
|
+
key: this.ACTIVE_BUNDLE_KEY,
|
|
177
|
+
});
|
|
178
|
+
return value;
|
|
179
|
+
}
|
|
180
|
+
catch (error) {
|
|
181
|
+
this.logger.error('Failed to get active bundle ID', error);
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Clear active bundle
|
|
187
|
+
*/
|
|
188
|
+
async clearActiveBundle() {
|
|
189
|
+
await this.preferences.remove({ key: this.ACTIVE_BUNDLE_KEY });
|
|
190
|
+
this.logger.info('Active bundle cleared');
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Clear all bundles
|
|
194
|
+
*/
|
|
195
|
+
async clearAllBundles() {
|
|
196
|
+
await this.preferences.remove({ key: this.STORAGE_KEY });
|
|
197
|
+
await this.preferences.remove({ key: this.ACTIVE_BUNDLE_KEY });
|
|
198
|
+
this.cache.clear();
|
|
199
|
+
this.cacheExpiry = 0;
|
|
200
|
+
this.logger.info('All bundles cleared');
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Clean up old bundles
|
|
204
|
+
*/
|
|
205
|
+
async cleanupOldBundles(keepCount) {
|
|
206
|
+
if (keepCount < 1) {
|
|
207
|
+
throw new StorageError(ErrorCode.INVALID_CONFIG, 'Keep count must be at least 1');
|
|
208
|
+
}
|
|
209
|
+
const bundles = await this.getAllBundles();
|
|
210
|
+
const activeBundleId = await this.getActiveBundleId();
|
|
211
|
+
// Sort by download time (newest first)
|
|
212
|
+
const sorted = bundles.sort((a, b) => b.downloadTime - a.downloadTime);
|
|
213
|
+
// Keep the active bundle and the most recent ones
|
|
214
|
+
const toKeep = new Set();
|
|
215
|
+
if (activeBundleId) {
|
|
216
|
+
toKeep.add(activeBundleId);
|
|
217
|
+
}
|
|
218
|
+
let kept = toKeep.size;
|
|
219
|
+
for (const bundle of sorted) {
|
|
220
|
+
if (kept >= keepCount)
|
|
221
|
+
break;
|
|
222
|
+
if (!toKeep.has(bundle.bundleId)) {
|
|
223
|
+
toKeep.add(bundle.bundleId);
|
|
224
|
+
kept++;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
// Delete bundles not in the keep set
|
|
228
|
+
let deletedCount = 0;
|
|
229
|
+
for (const bundle of bundles) {
|
|
230
|
+
if (!toKeep.has(bundle.bundleId)) {
|
|
231
|
+
await this.deleteBundle(bundle.bundleId);
|
|
232
|
+
deletedCount++;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (deletedCount > 0) {
|
|
236
|
+
this.logger.info('Cleaned up old bundles', {
|
|
237
|
+
deleted: deletedCount,
|
|
238
|
+
kept,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Get bundles older than specified time
|
|
244
|
+
*/
|
|
245
|
+
async getBundlesOlderThan(timestamp) {
|
|
246
|
+
if (timestamp < 0) {
|
|
247
|
+
throw new StorageError(ErrorCode.INVALID_CONFIG, 'Timestamp must be non-negative');
|
|
248
|
+
}
|
|
249
|
+
const bundles = await this.getAllBundles();
|
|
250
|
+
return bundles.filter((b) => b.downloadTime < timestamp);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Mark bundle as verified
|
|
254
|
+
*/
|
|
255
|
+
async markBundleAsVerified(bundleId) {
|
|
256
|
+
const bundle = await this.getBundle(bundleId);
|
|
257
|
+
if (!bundle) {
|
|
258
|
+
throw new StorageError(ErrorCode.FILE_NOT_FOUND, `Bundle ${bundleId} not found`);
|
|
259
|
+
}
|
|
260
|
+
bundle.verified = true;
|
|
261
|
+
await this.saveBundleInfo(bundle);
|
|
262
|
+
this.logger.info('Bundle marked as verified', { bundleId });
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Get total storage used by bundles
|
|
266
|
+
*/
|
|
267
|
+
async getTotalStorageUsed() {
|
|
268
|
+
const bundles = await this.getAllBundles();
|
|
269
|
+
return bundles.reduce((total, bundle) => total + bundle.size, 0);
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Check if storage limit is exceeded
|
|
273
|
+
*/
|
|
274
|
+
async isStorageLimitExceeded(additionalSize = 0) {
|
|
275
|
+
const totalUsed = await this.getTotalStorageUsed();
|
|
276
|
+
const maxStorage = this.configManager.get('maxBundleSize') * 3; // Allow 3x max bundle size
|
|
277
|
+
return totalUsed + additionalSize > maxStorage;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Create default bundle
|
|
281
|
+
*/
|
|
282
|
+
createDefaultBundle() {
|
|
283
|
+
return {
|
|
284
|
+
bundleId: 'default',
|
|
285
|
+
version: '1.0.0',
|
|
286
|
+
path: '/',
|
|
287
|
+
downloadTime: Date.now(),
|
|
288
|
+
size: 0,
|
|
289
|
+
status: 'ACTIVE',
|
|
290
|
+
checksum: '',
|
|
291
|
+
verified: true,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Clean expired cache entries
|
|
296
|
+
*/
|
|
297
|
+
async cleanExpiredBundles() {
|
|
298
|
+
const expirationTime = this.configManager.get('cacheExpiration');
|
|
299
|
+
const cutoffTime = Date.now() - expirationTime;
|
|
300
|
+
const expiredBundles = await this.getBundlesOlderThan(cutoffTime);
|
|
301
|
+
for (const bundle of expiredBundles) {
|
|
302
|
+
// Don't delete active bundle
|
|
303
|
+
const activeBundleId = await this.getActiveBundleId();
|
|
304
|
+
if (bundle.bundleId !== activeBundleId) {
|
|
305
|
+
await this.deleteBundle(bundle.bundleId);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
//# sourceMappingURL=bundle-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle-manager.js","sourceRoot":"","sources":["../../../src/live-update/bundle-manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGzD;;GAEG;AACH,MAAM,OAAO,aAAa;IASxB;QARiB,gBAAW,GAAG,iCAAiC,CAAC;QAChD,sBAAiB,GAAG,gCAAgC,CAAC;QAC9D,gBAAW,GAA8B,IAAI,CAAC;QAG9C,UAAK,GAA4B,IAAI,GAAG,EAAE,CAAC;QAC3C,gBAAW,GAAW,CAAC,CAAC;QAG9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;QACnC,IAAI,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Ac,EAAE,CAAC;YACpC,6BAA6B;YAC7B,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACtD,IAAI,MAAM,CAAC,QAAQ,KAAK,cAAc,EAAE,CAAC;gBACvC,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export interface CertificatePin {
|
|
2
|
+
/**
|
|
3
|
+
* Hostname to pin certificates for (e.g., "api.example.com")
|
|
4
|
+
*/
|
|
5
|
+
hostname: string;
|
|
6
|
+
/**
|
|
7
|
+
* Array of SHA-256 certificate fingerprints in the format "sha256/base64hash"
|
|
8
|
+
*/
|
|
9
|
+
sha256: string[];
|
|
10
|
+
}
|
|
11
|
+
export interface CertificatePinningConfig {
|
|
12
|
+
/**
|
|
13
|
+
* Enable certificate pinning
|
|
14
|
+
*/
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Array of certificate pins
|
|
18
|
+
*/
|
|
19
|
+
pins: CertificatePin[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Certificate pinning utilities
|
|
23
|
+
*/
|
|
24
|
+
export declare class CertificatePinning {
|
|
25
|
+
/**
|
|
26
|
+
* Generate SHA-256 fingerprint from certificate
|
|
27
|
+
* Note: This is a utility for generating pins, not for runtime validation
|
|
28
|
+
*/
|
|
29
|
+
static generateFingerprint(certificatePem: string): Promise<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Validate certificate pinning configuration
|
|
32
|
+
*/
|
|
33
|
+
static validateConfig(config: CertificatePinningConfig): void;
|
|
34
|
+
/**
|
|
35
|
+
* Example configuration
|
|
36
|
+
*/
|
|
37
|
+
static example(): CertificatePinningConfig;
|
|
38
|
+
}
|