web-manager 4.1.23 → 4.1.24

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
@@ -14,6 +14,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
14
14
  - `Fixed` for any bug fixes.
15
15
  - `Security` in case of vulnerabilities.
16
16
 
17
+ ---
18
+ ## [4.1.24] - 2026-03-13
19
+ ### Added
20
+ - Added `resolveSubscription()` method to Auth module that derives calculated subscription fields (plan, active, trialing, cancelling) from raw backend data.
21
+
17
22
  ---
18
23
  ## [4.1.22] - 2026-03-11
19
24
  ### Changed
@@ -218,6 +218,37 @@ class Auth {
218
218
  });
219
219
  }
220
220
 
221
+ // Resolves calculated subscription fields that require derivation logic
222
+ // Raw data (product.id, status, trial, cancellation) is on account.subscription directly
223
+ // Returns: { plan, active, trialing, cancelling }
224
+ // - plan: the plan ID the user effectively has access to RIGHT NOW ('basic' if cancelled/suspended)
225
+ // - active: user has active access (active, trialing, or cancelling)
226
+ // - trialing: user is in an active trial (backend status is 'active' but trial hasn't expired)
227
+ // - cancelling: cancellation is pending (backend status is 'active' but cancellation.pending is true)
228
+ resolveSubscription(account) {
229
+ const subscription = (account || this.manager.storage().get('auth', {})?.account)?.subscription || {};
230
+ const productId = subscription.product?.id || 'basic';
231
+
232
+ // Derive trial and cancelling states from raw backend data
233
+ let trialing = false;
234
+ let cancelling = false;
235
+
236
+ if (productId !== 'basic' && subscription.status === 'active') {
237
+ trialing = !!(subscription.trial?.claimed
238
+ && subscription.trial?.expires?.timestampUNIX > Math.floor(Date.now() / 1000));
239
+ cancelling = !trialing && !!subscription.cancellation?.pending;
240
+ }
241
+
242
+ const active = (productId !== 'basic' && subscription.status === 'active');
243
+
244
+ return {
245
+ plan: active ? productId : 'basic',
246
+ active,
247
+ trialing,
248
+ cancelling,
249
+ };
250
+ }
251
+
221
252
  // Get ID token for the current user
222
253
  async getIdToken(forceRefresh = false) {
223
254
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "4.1.23",
3
+ "version": "4.1.24",
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",