@moneybar.online/moneybar 4.1.0 → 4.2.2

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/src/index.ts CHANGED
@@ -226,6 +226,19 @@ export class MoneyBar {
226
226
  if (forceRefresh || !this.cachedStatus) {
227
227
  // Get download count only if we don't have it cached
228
228
  count = await this.getDownloadCount();
229
+
230
+ // CRITICAL: Check if security key validation failed
231
+ // Don't proceed with normal status if there's a security error
232
+ if (this.securityKeyFailed) {
233
+ // Return a minimal error status
234
+ return {
235
+ currentCount: 0,
236
+ limit: this.config.freeAttemptLimit,
237
+ isPremium: false,
238
+ isAuthenticated: false,
239
+ remaining: 0
240
+ };
241
+ }
229
242
  } else {
230
243
  // Use cached count if available to avoid unnecessary API call
231
244
  count = this.cachedStatus.currentCount;
@@ -2801,6 +2814,18 @@ User Agent: ${feedbackData.userAgent}
2801
2814
  }
2802
2815
 
2803
2816
  const status = await this.getDownloadStatus();
2817
+
2818
+ // CRITICAL: Check again AFTER API call - flag may have been set during getDownloadStatus
2819
+ if (this.securityKeyFailed) {
2820
+ this.disableDownloadButtons('security_key');
2821
+ return;
2822
+ }
2823
+
2824
+ if (this.supabaseConnectionFailed) {
2825
+ this.disableDownloadButtons('connection');
2826
+ return;
2827
+ }
2828
+
2804
2829
  this.updateUserSection(status);
2805
2830
  }
2806
2831
 
@@ -3181,12 +3206,13 @@ User Agent: ${feedbackData.userAgent}
3181
3206
 
3182
3207
  // Check if it's a security key validation error
3183
3208
  if (errorMsg.toLowerCase().includes('security key')) {
3184
- console.error(`❌ Security Key Validation Failed: ${errorMsg}`);
3209
+ console.error(`❌ Security Key Validation Failed [check-download-limit]: ${errorMsg}`);
3210
+ console.error(`💡 Backend Function: check-download-limit`);
3185
3211
  console.error(`💡 Please check your security_key in the MoneyBar configuration`);
3186
3212
  this.securityKeyFailed = true; // Set security key error flag
3187
3213
  this.supabaseConnectionFailed = true; // Also mark connection as failed to disable downloads
3188
3214
  } else {
3189
- console.warn(`Supabase authentication failed: ${response.status} - ${errorMsg}`);
3215
+ console.warn(`Supabase authentication failed [check-download-limit]: ${response.status} - ${errorMsg}`);
3190
3216
  this.supabaseConnectionFailed = true;
3191
3217
  }
3192
3218
  } catch (e) {
@@ -3256,12 +3282,13 @@ User Agent: ${feedbackData.userAgent}
3256
3282
 
3257
3283
  // Check if it's a security key validation error
3258
3284
  if (errorMsg.toLowerCase().includes('security key')) {
3259
- console.error(`❌ Security Key Validation Failed: ${errorMsg}`);
3285
+ console.error(`❌ Security Key Validation Failed [check-download-limit]: ${errorMsg}`);
3286
+ console.error(`💡 Backend Function: check-download-limit`);
3260
3287
  console.error(`💡 Please check your security_key in the MoneyBar configuration`);
3261
3288
  this.securityKeyFailed = true; // Set security key error flag
3262
3289
  this.supabaseConnectionFailed = true; // Also mark connection as failed to disable downloads
3263
3290
  } else {
3264
- console.warn(`Supabase authentication failed: ${response.status} - ${errorMsg}`);
3291
+ console.warn(`Supabase authentication failed [check-download-limit]: ${response.status} - ${errorMsg}`);
3265
3292
  this.supabaseConnectionFailed = true;
3266
3293
  }
3267
3294
  } catch (e) {