UNPKG

native-update

Version:

Foundation package for building a comprehensive update system for Capacitor apps. Provides architecture and interfaces but requires backend implementation.

83 lines 2.65 kB
export class ConfigManager { constructor() { this.config = this.getDefaultConfig(); } static getInstance() { if (!ConfigManager.instance) { ConfigManager.instance = new ConfigManager(); } return ConfigManager.instance; } getDefaultConfig() { return { filesystem: null, preferences: null, baseUrl: '', allowedHosts: [], maxBundleSize: 100 * 1024 * 1024, // 100MB downloadTimeout: 30000, // 30 seconds retryAttempts: 3, retryDelay: 1000, // 1 second enableSignatureValidation: true, publicKey: '', cacheExpiration: 24 * 60 * 60 * 1000, // 24 hours enableLogging: false, serverUrl: '', channel: 'production', autoCheck: true, autoUpdate: false, updateStrategy: 'background', requireSignature: true, checksumAlgorithm: 'SHA-256', checkInterval: 24 * 60 * 60 * 1000, // 24 hours security: { enforceHttps: true, validateInputs: true, secureStorage: true, logSecurityEvents: false, }, // App review config promptAfterPositiveEvents: false, maxPromptsPerVersion: 1, minimumDaysSinceLastPrompt: 7, isPremiumUser: false, // Platform-specific config appStoreId: '', iosAppId: '', packageName: '', webReviewUrl: '', minimumVersion: '1.0.0', }; } configure(config) { this.config = Object.assign(Object.assign({}, this.config), config); this.validateConfig(); } validateConfig() { if (this.config.maxBundleSize <= 0) { throw new Error('maxBundleSize must be greater than 0'); } if (this.config.downloadTimeout <= 0) { throw new Error('downloadTimeout must be greater than 0'); } if (this.config.retryAttempts < 0) { throw new Error('retryAttempts must be non-negative'); } if (this.config.retryDelay < 0) { throw new Error('retryDelay must be non-negative'); } } get(key) { return this.config[key]; } set(key, value) { this.config[key] = value; } getAll() { return Object.assign({}, this.config); } isConfigured() { return !!(this.config.filesystem && this.config.preferences); } } //# sourceMappingURL=config.js.map