web-manager 4.1.36 → 4.1.37

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/CHANGELOG.md CHANGED
@@ -15,6 +15,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
15
15
  - `Security` in case of vulnerabilities.
16
16
 
17
17
  ---
18
+ ## [4.1.37] - 2026-04-05
19
+ ### Added
20
+ - Added `_resolveUsage()` to auth module that merges account usage data with plan limits from config, exposed as a top-level `usage` binding context.
21
+ - Added `payment.processors` and `payment.plans` defaults to configuration.
22
+
18
23
  ## [4.1.36] - 2026-04-02
19
24
  ### Fixed
20
25
  - Fixed mocha binary path preventing `npm test` from running.
package/dist/index.js CHANGED
@@ -296,6 +296,10 @@ class Manager {
296
296
  FIREBASE_EMULATOR_CONNECT: false,
297
297
  },
298
298
  validRedirectHosts: [],
299
+ payment: {
300
+ processors: {},
301
+ plans: [],
302
+ },
299
303
 
300
304
  // Non-configurable defaults
301
305
  refreshNewVersion: {
@@ -164,8 +164,12 @@ class Auth {
164
164
 
165
165
  // Update bindings and storage once per auth state change
166
166
  if (!this._hasProcessedStateChange) {
167
- this.manager.bindings().update({ auth: state });
167
+ this.manager.bindings().update({
168
+ auth: state,
169
+ usage: this._resolveUsage(state),
170
+ });
168
171
  this.manager.storage().set('auth', state);
172
+
169
173
  this._hasProcessedStateChange = true;
170
174
  }
171
175
 
@@ -252,6 +256,29 @@ class Auth {
252
256
  };
253
257
  }
254
258
 
259
+ // Resolve usage bindings from account data + plan limits from config.
260
+ // Returns: { credits: { monthly: 5, limit: 100 }, ... }
261
+ _resolveUsage(state) {
262
+ const accountUsage = state.account?.usage || {};
263
+ const plan = state.resolved?.plan || 'basic';
264
+ const plans = this.manager.config.payment?.plans || [];
265
+ const planConfig = plans.find(p => p.id === plan) || {};
266
+ const limits = planConfig.limits || {};
267
+
268
+ // Merge current usage with limits for each feature
269
+ const usage = {};
270
+ const keys = new Set([...Object.keys(accountUsage), ...Object.keys(limits)]);
271
+
272
+ for (const key of keys) {
273
+ usage[key] = {
274
+ ...(accountUsage[key] || {}),
275
+ limit: limits[key] || 0,
276
+ };
277
+ }
278
+
279
+ return usage;
280
+ }
281
+
255
282
  // Get ID token for the current user
256
283
  async getIdToken(forceRefresh = false) {
257
284
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "4.1.36",
3
+ "version": "4.1.37",
4
4
  "description": "Easily access important variables such as the query string, current domain, and current page in a single object.",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.js",