backend-manager 5.0.74 → 5.0.76

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backend-manager",
3
- "version": "5.0.74",
3
+ "version": "5.0.76",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -74,7 +74,6 @@
74
74
  "npm-api": "^1.0.1",
75
75
  "paypal-server-api": "^2.0.14",
76
76
  "pushid": "^1.0.0",
77
- "resolve-account": "^1.0.26",
78
77
  "shortid": "^2.2.17",
79
78
  "uid-generator": "^2.0.0",
80
79
  "uuid": "^9.0.1",
@@ -221,7 +221,8 @@ BackendAssistant.prototype.init = function (ref, options) {
221
221
  }
222
222
  self.request.url = tryUrl(self);
223
223
  self.request.path = self.ref.req.path || '';
224
- self.request.user = self.resolveAccount({authenticated: false});
224
+ self.request.user = self.Manager.User({}).properties;
225
+ self.request.user.authenticated = false;
225
226
 
226
227
  // Set body and query
227
228
  if (options.accept === 'json') {
@@ -656,7 +657,8 @@ BackendAssistant.prototype.authenticate = async function (options) {
656
657
 
657
658
  // Resolve the user
658
659
  if (options.resolve) {
659
- self.request.user = self.resolveAccount(user);
660
+ self.request.user = self.Manager.User(user).properties;
661
+ self.request.user.authenticated = user.authenticated || false;
660
662
  return self.request.user;
661
663
  } else {
662
664
  return user;
@@ -763,11 +765,6 @@ BackendAssistant.prototype.authenticate = async function (options) {
763
765
  }
764
766
  };
765
767
 
766
- BackendAssistant.prototype.resolveAccount = function (user) {
767
- const ResolveAccount = new (require('resolve-account'))();
768
-
769
- return ResolveAccount.resolve(undefined, user)
770
- }
771
768
 
772
769
  BackendAssistant.prototype.parseRepo = function (repo) {
773
770
  let repoSplit = repo.split('/');
@@ -2,7 +2,7 @@ const uuid = require('uuid');
2
2
 
3
3
  /**
4
4
  * Helper to create a future expiration date for premium subscriptions
5
- * resolve-account checks subscription.expires to determine if subscription is active
5
+ * User() checks subscription.expires to determine if subscription is active
6
6
  * If expires is in the past (or default 1970), subscription gets downgraded to basic
7
7
  */
8
8
  function getFutureExpires(years = 10) {
@@ -38,7 +38,7 @@ function getPastExpires(years = 1) {
38
38
  * - properties: Object to merge into user doc after auth:on-create
39
39
  *
40
40
  * IMPORTANT: Premium accounts MUST have subscription.expires set to a future date
41
- * or resolve-account will downgrade them to basic
41
+ * and subscription.status set to 'active'
42
42
  */
43
43
  const STATIC_ACCOUNTS = {
44
44
  admin: {
@@ -51,7 +51,7 @@
51
51
  {
52
52
  id: 'basic',
53
53
  name: 'Basic',
54
- type: 'free',
54
+ type: 'subscription',
55
55
  limits: {
56
56
  requests: 100,
57
57
  },
@@ -68,10 +68,12 @@
68
68
  },
69
69
  prices: {
70
70
  monthly: {
71
+ amount: 4.99,
71
72
  stripe: 'price_xxx',
72
73
  paypal: 'P-xxx',
73
74
  },
74
75
  annually: {
76
+ amount: 49.99,
75
77
  stripe: 'price_yyy',
76
78
  paypal: 'P-yyy',
77
79
  },
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Test: GET /user
3
3
  * Tests the user resolve endpoint
4
- * Returns RESOLVED user account info for authenticated users
5
- * Validates that resolve-account correctly processes user data
4
+ * Returns user account info for authenticated users
5
+ * Validates that User() correctly structures user data
6
6
  */
7
7
  module.exports = {
8
8
  description: 'User resolve (account info)',
@@ -129,9 +129,9 @@ module.exports = {
129
129
  },
130
130
  },
131
131
 
132
- // Test 6: Premium expired user - verify subscription is downgraded to basic
132
+ // Test 6: Premium expired user - verify subscription retains product but shows cancelled status
133
133
  {
134
- name: 'premium-expired-user-downgraded',
134
+ name: 'premium-expired-user-cancelled',
135
135
  auth: 'premium-expired',
136
136
  timeout: 15000,
137
137
 
@@ -145,8 +145,9 @@ module.exports = {
145
145
  // Verify auth properties
146
146
  assert.equal(user.auth.uid, accounts['premium-expired'].uid, 'UID should match expired premium test account');
147
147
 
148
- // Verify subscription - expired premium should be downgraded to basic by resolve-account
149
- assert.equal(user.subscription.product.id, 'basic', 'Expired premium subscription should be downgraded to basic');
148
+ // Verify subscription - product.id stays premium, status reflects cancellation
149
+ assert.equal(user.subscription.product.id, 'premium', 'Product ID should remain premium');
150
+ assert.equal(user.subscription.status, 'cancelled', 'Status should be cancelled');
150
151
  },
151
152
  },
152
153
  ],