backend-manager 2.5.59 → 2.5.61

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": "2.5.59",
3
+ "version": "2.5.61",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -31,7 +31,7 @@
31
31
  "@google-cloud/storage": "^5.20.5",
32
32
  "@sendgrid/mail": "^7.7.0",
33
33
  "@sentry/node": "^6.19.7",
34
- "backend-assistant": "^0.0.74",
34
+ "backend-assistant": "^1.0.0",
35
35
  "busboy": "^1.6.0",
36
36
  "chalk": "^4.1.2",
37
37
  "cors": "^2.8.5",
@@ -62,4 +62,4 @@
62
62
  "wonderful-fetch": "^0.0.17",
63
63
  "yargs": "^17.7.1"
64
64
  }
65
- }
65
+ }
@@ -4,7 +4,6 @@ function Utilities(Manager) {
4
4
  const self = this;
5
5
 
6
6
  self.cache = null;
7
- self._deleteThis = Math.random();
8
7
 
9
8
  self.Manager = Manager;
10
9
  }
@@ -157,50 +156,6 @@ Utilities.prototype.randomId = function (options) {
157
156
  return nanoId();
158
157
  };
159
158
 
160
- // Utilities.prototype.get = function (doc, options) {
161
- // const self = this;
162
-
163
- // return new Promise(function(resolve, reject) {
164
-
165
- // options = options || {};
166
- // options.maxAge = options.maxAge || (1000 * 60 * 5); // 5 minutes
167
-
168
- // self.cache = self.cache || self.Manager.storage({name: 'cache', temporary: true, clear: false});
169
-
170
- // const item = self.cache.get(doc).value();
171
- // const age = item ? Date.now() - item.time : null;
172
-
173
- // console.log('+++++ 111', doc, age, item);
174
-
175
- // if (item && age < options.maxAge) {
176
- // console.log('---GOT FROM CACHE---');
177
-
178
- // return resolve(self.cache.map.get(doc).data);
179
- // } else {
180
- // console.log('---GOT FROM FIRESTORE---');
181
-
182
- // self.Manager.libraries.admin.firestore().doc(doc)
183
- // .get()
184
- // .then(async (doc) => {
185
- // const data = doc.data();
186
-
187
- // if (!data) {
188
- // throw new Error(`Document with ID ${doc} not found`);
189
- // }
190
-
191
- // self.cache.set(doc, {
192
- // data: data,
193
- // time: Date.now(),
194
- // })
195
- // .write();
196
-
197
- // return resolve(data);
198
- // })
199
- // }
200
- // });
201
- // };
202
-
203
-
204
159
  Utilities.prototype.get = function (docPath, options) {
205
160
  const self = this;
206
161
 
@@ -1,27 +1,29 @@
1
1
  rules_version = '2';
2
2
  service cloud.firestore {
3
3
  match /databases/{database}/documents {
4
+ // Custom rules
5
+ // ...
4
6
 
7
+ ///---default-rules---///
5
8
  // Lock by default
6
9
  match /{document=**} {
7
10
  allow read, write: if isAdmin();
8
11
  }
9
-
10
- // Custom rules
11
- ///---default-rules---///
12
+
13
+ // Protect user account data
12
14
  match /users/{uid} {
13
15
  allow read: if belongsTo(uid);
14
- allow write: if ((belongsTo(uid) && !isWritingProtectedUserField()));
15
- // might also want to include a check for email verified?
16
+ allow write: if belongsTo(uid) && !isWritingProtectedUserField();
16
17
  }
18
+
19
+ // Protect notification data
17
20
  match /notifications/subscriptions/all/{token} {
18
- allow read: if (existingData().token == token) || belongsTo(existingData().link.user.pk);
19
- allow update: if (existingData().token == token);
21
+ allow read: if existingData().token == token || belongsTo(existingData().link.user.pk);
22
+ allow update: if existingData().token == token;
20
23
  allow create: if true;
21
24
  }
22
25
  ///---------end---------///
23
26
 
24
-
25
27
  ///---backend-manager---///
26
28
  ///---version=0.0.0---///
27
29
  // Basic rules
@@ -34,10 +36,10 @@ service cloud.firestore {
34
36
  return request.auth.uid;
35
37
  }
36
38
  function isAuthenticated() {
37
- return request.auth.uid != null;
39
+ return request.auth != null;
38
40
  }
39
41
  function belongsTo(identity) {
40
- return (isAuthenticated() && (authUid() == identity || authEmail() == identity));
42
+ return isAuthenticated() && (authUid() == identity || authEmail() == identity);
41
43
  // eventually include a check for (existingData().link.email == identity)...(in case its a doc owned by a user that's not actually user doc)
42
44
  }
43
45
 
@@ -58,13 +60,12 @@ service cloud.firestore {
58
60
 
59
61
  function isWritingProtectedUserField() {
60
62
  return isWritingField('auth')
61
- || isWritingField('roles')
62
- || isWritingField('plan')
63
- || isWritingField('affiliate')
64
- || isWritingField('api')
65
- || isWritingField('link')
66
- || isWritingField('usage')
67
- || isWritingField('view');
63
+ || isWritingField('roles')
64
+ || isWritingField('plan')
65
+ || isWritingField('affiliate')
66
+ || isWritingField('api')
67
+ || isWritingField('link')
68
+ || isWritingField('usage');
68
69
  }
69
70
 
70
71
  function isCreatingField(field) {