@edgedev/firebase 2.0.6 → 2.0.7

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.
Files changed (2) hide show
  1. package/edgeFirebase.ts +14 -2
  2. package/package.json +1 -1
package/edgeFirebase.ts CHANGED
@@ -400,9 +400,14 @@ export const EdgeFirebase = class {
400
400
  this.unsubscibe['collection-data'] = unsubscribe
401
401
  }
402
402
 
403
-
403
+ private ruleHelperReset = async (): Promise<void> => {
404
+ const initRoleHelper = { uid: this.user.uid, 'edge-assignment-helper': {permissionType: "roles"} }
405
+ this.state.ruleHelpers['edge-assignment-helper'] = {permissionType: "roles"}
406
+ await setDoc(doc(this.db, "rule-helpers", this.user.uid), initRoleHelper);
407
+ }
404
408
 
405
409
  private startUserMetaSync = async (docSnap): Promise<void> => {
410
+ await this.ruleHelperReset();
406
411
  await this.startCollectionPermissionsSync()
407
412
  await this.initUserMetaPermissions(docSnap);
408
413
  this.user.loggedIn = true;
@@ -977,7 +982,12 @@ export const EdgeFirebase = class {
977
982
  }
978
983
  let index = collection.length;
979
984
  const ruleCheck: RuleCheck = { permissionType: "", permissionCheckPath: "", fullPath: collectionPath.replaceAll("/", "-"), action };
980
-
985
+ if (this.state.ruleHelpers[ruleKey]) {
986
+ const existingRuleHelper = this.state.ruleHelpers[ruleKey];
987
+ if (existingRuleHelper.fullPath === ruleCheck.fullPath && existingRuleHelper.action === ruleCheck.action) {
988
+ return;
989
+ }
990
+ }
981
991
  while (index > 0) {
982
992
  const collectionArray = JSON.parse(JSON.stringify(collection));
983
993
  const permissionCheck = collectionArray.splice(0, index).join("-");
@@ -1017,6 +1027,7 @@ export const EdgeFirebase = class {
1017
1027
  }
1018
1028
  const check = {[ruleKey]: ruleCheck, uid: this.user.uid };
1019
1029
  await setDoc(doc(this.db, "rule-helpers", this.user.uid), check, { merge: true });
1030
+ this.state.ruleHelpers[ruleKey] = ruleCheck;
1020
1031
  }
1021
1032
 
1022
1033
  public permissionCheckOnly = (action: action, collectionPath: string): boolean => {
@@ -1240,6 +1251,7 @@ export const EdgeFirebase = class {
1240
1251
  users: {},
1241
1252
  registrationCode: "",
1242
1253
  registrationMeta: {},
1254
+ ruleHelpers: {},
1243
1255
  });
1244
1256
 
1245
1257
  public getDocData = async (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgedev/firebase",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "description": "Vue 3 / Nuxt 3 Plugin or Nuxt 3 plugin for firebase authentication and firestore.",
5
5
  "main": "index.ts",
6
6
  "scripts": {