backend-manager 2.3.9 → 2.3.12

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.3.9",
3
+ "version": "2.3.12",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
package/src/cli/cli.js CHANGED
@@ -895,7 +895,7 @@ function fix_firestoreRulesFile(self) {
895
895
 
896
896
  if (!hasTemplate) {
897
897
  log(chalk.red(`Could not find rules template. Please edit ${name} file and add`), chalk.red(`{{backend-manager}}`), chalk.red(`to it.`));
898
- reject()
898
+ return resolve()
899
899
  }
900
900
 
901
901
  let matchesVersion = contents.match(self.default.rulesVersionRegex);
@@ -927,7 +927,7 @@ function fix_realtimeRulesFile(self) {
927
927
 
928
928
  if (!hasTemplate) {
929
929
  log(chalk.red(`Could not find rules template. Please edit ${name} file and add`), chalk.red(`{{backend-manager}}`), chalk.red(`to it.`));
930
- reject()
930
+ return resolve()
931
931
  }
932
932
 
933
933
  let matchesVersion = contents.match(self.default.rulesVersionRegex);
@@ -25,7 +25,7 @@ Module.prototype.main = function () {
25
25
  .equalTo(uid)
26
26
  .once('value')
27
27
  .then(async (snap) => {
28
- const data = snap.val();
28
+ const data = (snap.val() || []).filter(i => i);
29
29
  return resolve({data: data});
30
30
  })
31
31
  .catch(e => {
@@ -3,7 +3,44 @@
3
3
  ///---backend-manager---///
4
4
  ///---version=0.0.0---///
5
5
 
6
- // Gathering rules
6
+ // Sessions rules
7
+ "sessions": {
8
+ ".read": false,
9
+ ".write": false,
10
+ "$room": {
11
+ ".read": "
12
+ (auth.uid != null && query.equalTo == auth.uid)
13
+ ",
14
+ ".write": false,
15
+ ".indexOn": ["uid"],
16
+ "$id": {
17
+ ".read": "
18
+ // Allowed if user is authenticated AND is the owner of the doc
19
+ (auth != null && auth.uid == data.child('uid').val())
20
+ // Allowed if uid is equal to the doc id [LEGACY FOR SOMIIBO]
21
+ || (auth != null && auth.uid == $id)
22
+ // Allowed if user is not authenticated AND is the doc has no owner
23
+ || (auth == null && (data.child('uid').val() == ''))
24
+ ",
25
+ ".write": "
26
+ // Allowed if the user is authenticated AND is the owner of the existing doc
27
+ (auth != null && auth.uid == data.child('uid').val())
28
+ // Allowed if the user is authenticated AND is the owner of the new doc
29
+ || (auth != null && auth.uid == newData.child('uid').val())
30
+ // Allowed if the user is authenticated AND is the owner of the existing doc
31
+ || (auth != null && auth.uid == data.child('uid').val())
32
+ // Allowed if uid is equal to the doc id [LEGACY FOR SOMIIBO]
33
+ || (auth != null && auth.uid == $id)
34
+ // Allowed if the existing doc has no owner
35
+ || (data.child('uid').val() == '')
36
+ // Allowed if the new doc has no owner
37
+ || (newData.child('uid').val() == '')
38
+ // Allowed if it's a delete
39
+ || (!newData.exists())
40
+ ",
41
+ }
42
+ }
43
+ },
7
44
  "gatherings": {
8
45
  ".read": false,
9
46
  ".write": false,