@dereekb/firebase 7.3.0 → 7.6.0

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
@@ -2,6 +2,39 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ # [7.6.0](https://github.com/dereekb/dbx-components/compare/v7.5.0-dev...v7.6.0) (2022-06-09)
6
+
7
+
8
+ ### Features
9
+
10
+ * added grantFullAccessIfAuthUserRelated() ([be05e09](https://github.com/dereekb/dbx-components/commit/be05e0939939e9e0d1c8d1d8afbcab1fb15e060b))
11
+
12
+
13
+
14
+ # [7.5.0](https://github.com/dereekb/dbx-components/compare/v7.4.0-dev...v7.5.0) (2022-06-08)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * updated GrantRolesOtherwiseFunction to allow returning Maybe ([552bb9c](https://github.com/dereekb/dbx-components/commit/552bb9c488c0f11aa1aca885d00c5a7c2a199591))
20
+
21
+
22
+ ### Features
23
+
24
+ * added UseFunction, MappedUseFunction ([84b6cbe](https://github.com/dereekb/dbx-components/commit/84b6cbe23b7e020ad7de49633642429d7e32f7d4))
25
+
26
+
27
+
28
+ # [7.4.0](https://github.com/dereekb/dbx-components/compare/v7.3.0-dev...v7.4.0) (2022-06-08)
29
+
30
+
31
+ ### Features
32
+
33
+ * added grantModelRolesIfFunction and related types ([5432fab](https://github.com/dereekb/dbx-components/commit/5432fab1677c29e24eac4015c35821aba2d64e10))
34
+ * updated FirebaseServerAuthUserContext to be synchronous ([92bfd84](https://github.com/dereekb/dbx-components/commit/92bfd849b4a6d6773c616069c3085b686938ef4d))
35
+
36
+
37
+
5
38
  # [7.3.0](https://github.com/dereekb/dbx-components/compare/v7.2.0-dev...v7.3.0) (2022-06-08)
6
39
 
7
40
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/firebase",
3
- "version": "7.3.0",
3
+ "version": "7.6.0",
4
4
  "devDependencies": {
5
5
  "@firebase/rules-unit-testing": "^2.0.0"
6
6
  },
@@ -22,16 +22,16 @@
22
22
  "rxjs": "^7.0.0",
23
23
  "rxfire": "^6.0.3",
24
24
  "firebase": "^9.8.0",
25
- "@dereekb/util": "7.3.0",
25
+ "@dereekb/util": "7.6.0",
26
26
  "make-error": "^1.3.0",
27
27
  "ts-essentials": "^9.1.2",
28
28
  "extra-set": "^2.2.11",
29
- "@dereekb/rxjs": "7.3.0",
29
+ "@dereekb/rxjs": "7.6.0",
30
30
  "ms": "^3.0.0-canary.1",
31
- "@dereekb/model": "7.3.0",
31
+ "@dereekb/model": "7.6.0",
32
32
  "class-transformer": "^0.5.1",
33
33
  "class-validator": "^0.13.2",
34
- "@dereekb/date": "7.3.0",
34
+ "@dereekb/date": "7.6.0",
35
35
  "date-fns": "^2.28.0",
36
36
  "date-fns-tz": "^1.3.0",
37
37
  "rrule": "git+https://git@github.com/dereekb/rrule.git#17adf5708d6567b4d01a3a8afd106261421ea492",
@@ -1,4 +1,4 @@
1
- import { AuthClaims, AuthRoleSet, Maybe } from '@dereekb/util';
1
+ import { AuthClaims, AuthClaimsObject, AuthRoleSet, MappedUseFunction, Maybe, UseValue } from '@dereekb/util';
2
2
  import { FirebaseAuthToken } from './auth';
3
3
  /**
4
4
  * Provides a context containing FirebaseAuthContextInfo
@@ -17,17 +17,31 @@ export interface FirebaseAuthContextInfo {
17
17
  /**
18
18
  * Returns true if the user is considered a system admin.
19
19
  */
20
- isAdmin?(): boolean;
20
+ isAdmin(): boolean;
21
21
  /**
22
22
  * Retrieves the claims in the context.
23
23
  */
24
- loadClaims(): Promise<AuthClaims>;
24
+ getClaims<T extends AuthClaimsObject = AuthClaimsObject>(): AuthClaims<T>;
25
25
  /**
26
26
  * The auth roles provided by the token in this context.
27
27
  */
28
+ getAuthRoles(): AuthRoleSet;
29
+ /**
30
+ * Retrieves the claims in the context.
31
+ *
32
+ * @deprecated Claims are now available synchronously.
33
+ */
34
+ loadClaims<T extends AuthClaimsObject = AuthClaimsObject>(): Promise<AuthClaims<T>>;
35
+ /**
36
+ * The auth roles provided by the token in this context.
37
+ *
38
+ * @deprecated Auth role set is now available synchronously.
39
+ */
28
40
  loadAuthRoles(): Promise<AuthRoleSet>;
29
41
  /**
30
42
  * The token in the context.
31
43
  */
32
44
  readonly token: FirebaseAuthToken;
33
45
  }
46
+ export declare type UseFirebaseAuthContextInfo<I extends FirebaseAuthContextInfo = FirebaseAuthContextInfo> = UseValue<I>;
47
+ export declare const useContextAuth: MappedUseFunction<FirebaseAuthContext, FirebaseAuthContextInfo>;
@@ -1,3 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useContextAuth = void 0;
4
+ const util_1 = require("@dereekb/util");
5
+ exports.useContextAuth = (0, util_1.mappedUseFunction)((x) => x.auth);
3
6
  //# sourceMappingURL=auth.context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.context.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/common/auth/auth.context.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"auth.context.js","sourceRoot":"","sources":["../../../../../../../packages/firebase/src/lib/common/auth/auth.context.ts"],"names":[],"mappings":";;;AAAA,wCAAiI;AAwDpH,QAAA,cAAc,GAAoE,IAAA,wBAAiB,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC"}
@@ -1,4 +1,5 @@
1
- import { ModelFieldMapFunctionsConfig, GetterOrValue, Maybe, ModelFieldMapConvertFunction, PrimativeKey, ReadKeyFunction, ModelFieldMapFunctionsWithDefaultsConfig, FindUniqueFunction, FindUniqueStringsTransformConfig, MapFunction, FilterKeyValueTuplesInput } from '@dereekb/util';
1
+ import { GrantedRole } from '@dereekb/model';
2
+ import { ModelFieldMapFunctionsConfig, GetterOrValue, Maybe, ModelFieldMapConvertFunction, PrimativeKey, ReadKeyFunction, ModelFieldMapFunctionsWithDefaultsConfig, FindUniqueFunction, FindUniqueStringsTransformConfig, MapFunction, FilterKeyValueTuplesInput, ModelKey } from '@dereekb/util';
2
3
  export interface BaseFirestoreFieldConfig<V, D = unknown> {
3
4
  fromData: ModelFieldMapConvertFunction<D, V>;
4
5
  toData: ModelFieldMapConvertFunction<V, D>;
@@ -33,6 +34,8 @@ export declare function firestoreString(config?: FirestoreStringConfig): Firesto
33
34
  export declare function optionalFirestoreString(): ModelFieldMapFunctionsConfig<Maybe<string>, Maybe<string>>;
34
35
  export declare function firestoreUID(): FirestoreModelFieldMapFunctionsConfig<string, string>;
35
36
  export declare function optionalFirestoreUID(): ModelFieldMapFunctionsConfig<Maybe<string>, Maybe<string>>;
37
+ export declare const firestoreModelKey: FirestoreModelFieldMapFunctionsConfig<string, string>;
38
+ export declare const firestoreModelId: FirestoreModelFieldMapFunctionsConfig<string, string>;
36
39
  export declare type FirestoreDateFieldConfig = DefaultMapConfiguredFirestoreFieldConfig<Date, string> & {
37
40
  saveDefaultAsNow?: boolean;
38
41
  };
@@ -112,13 +115,13 @@ export declare function firestoreMap<T, K extends string = string>(config?: Fire
112
115
  *
113
116
  * Filters out models with no/null roles by default.
114
117
  */
115
- export declare function firestoreModelKeyGrantedRoleMap(): FirestoreModelFieldMapFunctionsConfig<FirestoreMapFieldType<string, string>, FirestoreMapFieldType<string, string>>;
118
+ export declare function firestoreModelKeyGrantedRoleMap<R extends GrantedRole>(): FirestoreModelFieldMapFunctionsConfig<FirestoreMapFieldType<R, string>, FirestoreMapFieldType<R, string>>;
116
119
  /**
117
120
  * FirestoreField configuration for a map of granted roles, keyed by model ids.
118
121
  *
119
122
  * Filters out models with no/null roles by default.
120
123
  */
121
- export declare const firestoreModelIdGrantedRoleMap: typeof firestoreModelKeyGrantedRoleMap;
124
+ export declare const firestoreModelIdGrantedRoleMap: () => FirestoreModelFieldMapFunctionsConfig<FirestoreMapFieldType<ModelKey, string>, FirestoreMapFieldType<ModelKey, string>>;
122
125
  /**
123
126
  * FirestoreField configuration for a map-type object with array values.
124
127
  *
@@ -133,13 +136,13 @@ export declare function firestoreArrayMap<T, K extends string = string>(config?:
133
136
  *
134
137
  * Filters empty roles/arrays by default.
135
138
  */
136
- export declare function firestoreModelKeyGrantedRoleArrayMap(): FirestoreModelFieldMapFunctionsConfig<FirestoreMapFieldType<string[], string>, FirestoreMapFieldType<string[], string>>;
139
+ export declare function firestoreModelKeyGrantedRoleArrayMap<R extends GrantedRole>(): FirestoreModelFieldMapFunctionsConfig<FirestoreMapFieldType<R[], string>, FirestoreMapFieldType<R[], string>>;
137
140
  /**
138
141
  * FirestoreField configuration for a map of granted roles, keyed by models ids.
139
142
  *
140
143
  * Filters empty roles/arrays by default.
141
144
  */
142
- export declare const firestoreModelIdGrantedRoleArrayMap: typeof firestoreModelKeyGrantedRoleArrayMap;
145
+ export declare const firestoreModelIdGrantedRoleArrayMap: () => FirestoreModelFieldMapFunctionsConfig<FirestoreMapFieldType<ModelKey[], string>, FirestoreMapFieldType<ModelKey[], string>>;
143
146
  export declare type FirestoreSetFieldConfig<T extends string | number> = DefaultMapConfiguredFirestoreFieldConfig<Set<T>, T[]>;
144
147
  /**
145
148
  * Do not use.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.firestoreSet = exports.firestoreModelIdGrantedRoleArrayMap = exports.firestoreModelKeyGrantedRoleArrayMap = exports.firestoreArrayMap = exports.firestoreModelIdGrantedRoleMap = exports.firestoreModelKeyGrantedRoleMap = exports.firestoreMap = exports.firestoreEncodedArray = exports.firestoreModelIdArray = exports.firestoreModelKeyArray = exports.firestoreUniqueStringArray = exports.firestoreUniqueKeyedArray = exports.firestoreUniqueArray = exports.optionalFirestoreArray = exports.firestoreArray = exports.optionalFirestoreNumber = exports.firestoreNumber = exports.optionalFirestoreBoolean = exports.firestoreBoolean = exports.optionalFirestoreDate = exports.firestoreDate = exports.optionalFirestoreUID = exports.firestoreUID = exports.optionalFirestoreString = exports.firestoreString = exports.firestorePassThroughField = exports.FIRESTORE_PASSTHROUGH_FIELD = exports.firestoreField = void 0;
3
+ exports.firestoreSet = exports.firestoreModelIdGrantedRoleArrayMap = exports.firestoreModelKeyGrantedRoleArrayMap = exports.firestoreArrayMap = exports.firestoreModelIdGrantedRoleMap = exports.firestoreModelKeyGrantedRoleMap = exports.firestoreMap = exports.firestoreEncodedArray = exports.firestoreModelIdArray = exports.firestoreModelKeyArray = exports.firestoreUniqueStringArray = exports.firestoreUniqueKeyedArray = exports.firestoreUniqueArray = exports.optionalFirestoreArray = exports.firestoreArray = exports.optionalFirestoreNumber = exports.firestoreNumber = exports.optionalFirestoreBoolean = exports.firestoreBoolean = exports.optionalFirestoreDate = exports.firestoreDate = exports.firestoreModelId = exports.firestoreModelKey = exports.optionalFirestoreUID = exports.firestoreUID = exports.optionalFirestoreString = exports.firestoreString = exports.firestorePassThroughField = exports.FIRESTORE_PASSTHROUGH_FIELD = exports.firestoreField = void 0;
4
4
  const date_1 = require("@dereekb/date");
5
5
  const util_1 = require("@dereekb/util");
6
6
  const snapshot_1 = require("./snapshot");
@@ -50,6 +50,8 @@ function optionalFirestoreUID() {
50
50
  return optionalFirestoreString();
51
51
  }
52
52
  exports.optionalFirestoreUID = optionalFirestoreUID;
53
+ exports.firestoreModelKey = firestoreString();
54
+ exports.firestoreModelId = firestoreString();
53
55
  function firestoreDate(config = {}) {
54
56
  var _a, _b;
55
57
  return firestoreField({
@@ -1 +1 @@
1
- {"version":3,"file":"snapshot.field.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/snapshot/snapshot.field.ts"],"names":[],"mappings":";;;AAEA,wCAA4E;AAC5E,wCAAye;AACze,yCAAmD;AA4BnD,SAAgB,cAAc,CAAiB,MAAkC;;IAC/E,OAAO;QACL,IAAI,EAAG,MAAgD,CAAC,OAAO;YAC7D,CAAC,CAAC;gBACE,OAAO,EAAG,MAAgD,CAAC,OAAO;gBAClE,OAAO,E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AClC,CAAC,CAAC;AACL,CAAC;AAJD,oFAIC;AAED;;;;GAIG;AACU,QAAA,mCAAmC,GAAG,oCAAoC,CAAC;AAKxF;;;;;;;GAOG;AACH,SAAgB,YAAY,CAA4B,MAAkC;;IACxF,OAAO,cAAc,CAAc;QACjC,OAAO,EAAE,MAAA,MAAM,CAAC,OAAO,mCAAI,CAAC,GAAG,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC;QAC5C,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC;QACjC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;KACjC,CAAC,CAAC;AACL,CAAC;AAND,oCAMC"}
1
+ {"version":3,"file":"snapshot.field.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/firestore/snapshot/snapshot.field.ts"],"names":[],"mappings":";;;AAEA,wCAA4E;AAC5E,wCAAmf;AACnf,yCAAmD;AA4BnD,SAAgB,cAAc,CAAiB,MAAkC;;IAC/E,OAAO;QACL,IAAI,EAAG,MAAgD,CAAC,OAAO;YAC7D,CAAC,CAAC;gBACE,OAAO,EAAG,MAAgD,CAAC,OAAO;gBAClE,OAAO,EAAE,MAAM,CAAC,QAAQ;aACzB;YACH,CAAC,CAAC;gBACE,YAAY,EAAG,MAAoD,CAAC,WAAW;gBAC/E,OAAO,EAAE,MAAM,CAAC,QAAQ;aACzB;QACL,EAAE,EAAE;YACF,OAAO,EAAE,CAAC,MAAA,MAAM,CAAC,iBAAiB,mCAAI,gCAAqB,CAAqB;YAChF,OAAO,EAAE,MAAM,CAAC,MAAM;SACvB;KAC6C,CAAC;AACnD,CAAC;AAhBD,wCAgBC;AAEY,QAAA,2BAA2B,GAAG,cAAc,CAAmB;IAC1E,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE,kBAAW;IACrB,MAAM,EAAE,kBAAW;CACpB,CAAC,CAAC;AAEH,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AC;QACjC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC;KACjC,CAAC,CAAC;AACL,CAAC;AAND,oCAMC"}
@@ -4,12 +4,6 @@ import { FirebasePermissionContext, FirebasePermissionErrorContext } from './per
4
4
  * A base model context that contains info about what is current occuring.
5
5
  */
6
6
  export interface FirebaseModelContext extends FirebasePermissionContext, FirebasePermissionErrorContext, FirebaseAuthContext {
7
- /**
8
- * Whether or not to return all role checks for models as true if the auth context shows the current user as an admin.
9
- *
10
- * Is false by default.
11
- */
12
- readonly adminGetsAllowAllRoles?: boolean;
13
7
  }
14
8
  export interface FirebaseAppModelContext<C> extends FirebaseModelContext {
15
9
  readonly app: C;
@@ -2,3 +2,4 @@ export * from './permission';
2
2
  export * from './permission.context';
3
3
  export * from './permission.service';
4
4
  export * from './permission.service.role';
5
+ export * from './permission.service.grant';
@@ -5,4 +5,5 @@ tslib_1.__exportStar(require("./permission"), exports);
5
5
  tslib_1.__exportStar(require("./permission.context"), exports);
6
6
  tslib_1.__exportStar(require("./permission.service"), exports);
7
7
  tslib_1.__exportStar(require("./permission.service.role"), exports);
8
+ tslib_1.__exportStar(require("./permission.service.grant"), exports);
8
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/model/permission/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B;AAC7B,+DAAqC;AACrC,+DAAqC;AACrC,oEAA0C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/model/permission/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B;AAC7B,+DAAqC;AACrC,+DAAqC;AACrC,oEAA0C;AAC1C,qEAA2C"}
@@ -16,7 +16,6 @@ export declare class FirebaseModelPermissionServiceInstance<C extends FirebaseMo
16
16
  constructor(delegate: FirebasePermissionServiceInstanceDelegate<C, T, D, R>);
17
17
  roleMapForModel(output: FirebasePermissionServiceModel<T, D>, context: C, model: D): PromiseOrValue<GrantedRoleMap<R>>;
18
18
  protected outputForModel(document: D): Promise<Maybe<FirebasePermissionServiceModel<T, D>>>;
19
- protected getRoleMapForOutput(output: FirebasePermissionServiceModel<T, D>, context: C, model: D): Promise<import("@dereekb/model").ContextGrantedModelRoles<FirebasePermissionServiceModel<T, D>, C, R>>;
20
19
  protected isUsableOutputForRoles(output: FirebasePermissionServiceModel<T, D>): boolean;
21
20
  }
22
21
  export declare function firebaseModelPermissionService<C extends FirebaseModelContext, T, D extends FirestoreDocument<T> = FirestoreDocument<T>, R extends string = string>(delegate: FirebasePermissionServiceInstanceDelegate<C, T, D, R>): FirebaseModelPermissionServiceInstance<C, T, D, R>;
@@ -0,0 +1,81 @@
1
+ import { GrantedRoleMap } from '@dereekb/model';
2
+ import { AsyncDecisionFunction, Getter, GetterOrValue, Maybe, PromiseOrValue } from '@dereekb/util';
3
+ import { FirebaseModelContext } from '../context';
4
+ import { UserRelated } from '../../../model/user';
5
+ /**
6
+ * Convenience function that checks the input context if the user is an admin or grants all roles.
7
+ */
8
+ export declare const grantFullAccessIfAdmin: GeneralGrantRolesIfFunction;
9
+ export declare function grantModelRolesIfAdmin<R extends string = string>(context: FirebaseModelContext, rolesToGrantToAdmin: GetterOrValue<GrantedRoleMap<R>>, otherwise?: GrantRolesOtherwiseFunction<R>): PromiseOrValue<GrantedRoleMap<R>>;
10
+ /**
11
+ * Convenience function that checks the input context if the user is an admin or not and grants pre-set admin roles if they are.
12
+ *
13
+ * @param context
14
+ * @param rolesToGrantToAdmin
15
+ * @param otherwise
16
+ * @returns
17
+ */
18
+ export declare function grantModelRolesIfAdminFunction<R extends string = string>(rolesToGrantToAdmin: GetterOrValue<GrantedRoleMap<R>>): GrantRolesIfFunction<FirebaseModelContext, R>;
19
+ /**
20
+ * DecisionFunction for a FirebaseModelContext that checks if the current user is an admin.
21
+ *
22
+ * @param context
23
+ * @returns
24
+ */
25
+ export declare const isAdminInFirebaseModelContext: AsyncDecisionFunction<FirebaseModelContext>;
26
+ export declare type UserRelatedModelFirebaseModelContext<T extends UserRelated = UserRelated> = {
27
+ model: T;
28
+ context: FirebaseModelContext;
29
+ };
30
+ /**
31
+ * Convenience function that checks the input context if the user is related to the model by uid.
32
+ */
33
+ export declare const grantFullAccessIfAuthUserRelated: GeneralGrantRolesIfFunction;
34
+ /**
35
+ * Creates a GrantRolesIfFunction that grants roles if the user is related to the model by uid.
36
+ *
37
+ * @param context
38
+ * @param rolesToGrant
39
+ * @param otherwise
40
+ * @returns
41
+ */
42
+ export declare function grantModelRolesIfAuthUserRelatedModelFunction<T extends UserRelated, R extends string = string>(rolesToGrant: GetterOrValue<GrantedRoleMap<R>>): GrantRolesIfFunction<UserRelatedModelFirebaseModelContext<T>, R>;
43
+ /**
44
+ * DecisionFunction for a FirebaseModelContext that checks if the user is related to the model by uid.
45
+ *
46
+ * @param context
47
+ * @returns
48
+ */
49
+ export declare const isOwnerOfUserRelatedModelInFirebaseModelContext: AsyncDecisionFunction<UserRelatedModelFirebaseModelContext<UserRelated>>;
50
+ /**
51
+ * Grants the configured roles if the decision is made about the context. Otherwise, returns a NoAccessRoleMap.
52
+ */
53
+ export declare type GrantRolesOnlyIfFunction<C, R extends string = string> = (context: C) => Promise<GrantedRoleMap<R>>;
54
+ export declare type GeneralGrantRolesOnlyIfFunction = <C, R extends string = string>(context: C) => Promise<GrantedRoleMap<R>>;
55
+ /**
56
+ * Creates a GrantRolesOnlyIfFunction
57
+ *
58
+ * @param grantIf
59
+ * @param grantedRoles
60
+ * @returns
61
+ */
62
+ export declare function grantModelRolesOnlyIfFunction<C, R extends string = string>(grantIf: AsyncDecisionFunction<C>, grantedRoles: GetterOrValue<GrantedRoleMap<R>>): GrantRolesOnlyIfFunction<C, R>;
63
+ /**
64
+ * Grants the configured roles if the decision is made about the context. Otherwise, invokes the otherwise function if available, or returns a NoAccessRoleMap.
65
+ */
66
+ export declare type GrantRolesIfFunction<C, R extends string = string> = (context: C, otherwise?: GrantRolesOtherwiseFunction<R>) => Promise<GrantedRoleMap<R>>;
67
+ export declare type GeneralGrantRolesIfFunction = <C, R extends string = string>(context: C, otherwise?: GrantRolesOtherwiseFunction<R>) => Promise<GrantedRoleMap<R>>;
68
+ /**
69
+ * Used as the "else" statement for grantModelRolesIfFunction.
70
+ *
71
+ * If no roles are returned, the grantModelRolesIfFunction() will return a NoAccessRoleMap.
72
+ */
73
+ export declare type GrantRolesOtherwiseFunction<R extends string = string> = Getter<Maybe<PromiseOrValue<GrantedRoleMap<R>>>>;
74
+ /**
75
+ * Creates a GrantRolesIfFunction.
76
+ *
77
+ * @param grantIf
78
+ * @param grantedRoles
79
+ * @returns
80
+ */
81
+ export declare function grantModelRolesIfFunction<C, R extends string = string>(grantIf: AsyncDecisionFunction<C>, grantedRoles: GetterOrValue<GrantedRoleMap<R>>): GrantRolesIfFunction<C, R>;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.grantModelRolesIfFunction = exports.grantModelRolesOnlyIfFunction = exports.isOwnerOfUserRelatedModelInFirebaseModelContext = exports.grantModelRolesIfAuthUserRelatedModelFunction = exports.grantFullAccessIfAuthUserRelated = exports.isAdminInFirebaseModelContext = exports.grantModelRolesIfAdminFunction = exports.grantModelRolesIfAdmin = exports.grantFullAccessIfAdmin = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const model_1 = require("@dereekb/model");
6
+ const util_1 = require("@dereekb/util");
7
+ // MARK: Admin
8
+ /**
9
+ * Convenience function that checks the input context if the user is an admin or grants all roles.
10
+ */
11
+ exports.grantFullAccessIfAdmin = grantModelRolesIfAdminFunction(model_1.fullAccessRoleMap);
12
+ function grantModelRolesIfAdmin(context, rolesToGrantToAdmin, otherwise) {
13
+ return grantModelRolesIfAdminFunction(rolesToGrantToAdmin)(context, otherwise);
14
+ }
15
+ exports.grantModelRolesIfAdmin = grantModelRolesIfAdmin;
16
+ /**
17
+ * Convenience function that checks the input context if the user is an admin or not and grants pre-set admin roles if they are.
18
+ *
19
+ * @param context
20
+ * @param rolesToGrantToAdmin
21
+ * @param otherwise
22
+ * @returns
23
+ */
24
+ function grantModelRolesIfAdminFunction(rolesToGrantToAdmin) {
25
+ return grantModelRolesIfFunction(exports.isAdminInFirebaseModelContext, rolesToGrantToAdmin);
26
+ }
27
+ exports.grantModelRolesIfAdminFunction = grantModelRolesIfAdminFunction;
28
+ /**
29
+ * DecisionFunction for a FirebaseModelContext that checks if the current user is an admin.
30
+ *
31
+ * @param context
32
+ * @returns
33
+ */
34
+ const isAdminInFirebaseModelContext = (context) => { var _a, _b; return (_b = (_a = context.auth) === null || _a === void 0 ? void 0 : _a.isAdmin()) !== null && _b !== void 0 ? _b : false; };
35
+ exports.isAdminInFirebaseModelContext = isAdminInFirebaseModelContext;
36
+ /**
37
+ * Convenience function that checks the input context if the user is related to the model by uid.
38
+ */
39
+ exports.grantFullAccessIfAuthUserRelated = grantModelRolesIfAdminFunction(model_1.fullAccessRoleMap);
40
+ /**
41
+ * Creates a GrantRolesIfFunction that grants roles if the user is related to the model by uid.
42
+ *
43
+ * @param context
44
+ * @param rolesToGrant
45
+ * @param otherwise
46
+ * @returns
47
+ */
48
+ function grantModelRolesIfAuthUserRelatedModelFunction(rolesToGrant) {
49
+ return grantModelRolesIfFunction(exports.isOwnerOfUserRelatedModelInFirebaseModelContext, rolesToGrant);
50
+ }
51
+ exports.grantModelRolesIfAuthUserRelatedModelFunction = grantModelRolesIfAuthUserRelatedModelFunction;
52
+ /**
53
+ * DecisionFunction for a FirebaseModelContext that checks if the user is related to the model by uid.
54
+ *
55
+ * @param context
56
+ * @returns
57
+ */
58
+ const isOwnerOfUserRelatedModelInFirebaseModelContext = ({ context, model }) => { var _a; return ((_a = context.auth) === null || _a === void 0 ? void 0 : _a.uid) === model.uid; };
59
+ exports.isOwnerOfUserRelatedModelInFirebaseModelContext = isOwnerOfUserRelatedModelInFirebaseModelContext;
60
+ /**
61
+ * Creates a GrantRolesOnlyIfFunction
62
+ *
63
+ * @param grantIf
64
+ * @param grantedRoles
65
+ * @returns
66
+ */
67
+ function grantModelRolesOnlyIfFunction(grantIf, grantedRoles) {
68
+ const fn = grantModelRolesIfFunction(grantIf, grantedRoles);
69
+ return (context) => fn(context);
70
+ }
71
+ exports.grantModelRolesOnlyIfFunction = grantModelRolesOnlyIfFunction;
72
+ /**
73
+ * Creates a GrantRolesIfFunction.
74
+ *
75
+ * @param grantIf
76
+ * @param grantedRoles
77
+ * @returns
78
+ */
79
+ function grantModelRolesIfFunction(grantIf, grantedRoles) {
80
+ return (context, otherwise = model_1.noAccessRoleMap) => tslib_1.__awaiter(this, void 0, void 0, function* () {
81
+ var _a;
82
+ const decision = yield grantIf(context);
83
+ const results = decision ? yield (0, util_1.getValueFromGetter)(grantedRoles) : (_a = (yield otherwise())) !== null && _a !== void 0 ? _a : (0, model_1.noAccessRoleMap)();
84
+ return results;
85
+ });
86
+ }
87
+ exports.grantModelRolesIfFunction = grantModelRolesIfFunction;
88
+ //# sourceMappingURL=permission.service.grant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission.service.grant.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/model/permission/permission.service.grant.ts"],"names":[],"mappings":";;;;AAAA,0CAAoF;AACpF,wCAAwH;AAIxH,cAAc;AACd;;GAEG;AACU,QAAA,sBAAsB,GAAgC,8BAA8B,CAAC,yBAAiB,CAAC,CAAC;AAErH,SAAgB,sBAAsB,CAA4B,OAA6B,EAAE,mBAAqD,EAAE,SAA0C;IAChM,OAAO,8BAA8B,CAAC,mBAAmB,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AACjF,CAAC;AAFD,wDAEC;AAED;;;;;;;GAOG;AACH,SAAgB,8BAA8B,CAA4B,mBAAqD;IAC7H,OAAO,yBAAyB,CAAC,qCAA6B,EAAE,mBAAmB,CAAC,CAAC;AACvF,CAAC;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AC;QAC7G,OAAO,OAAO,CAAC;IACjB,CAAC,CAAA,CAAC;AACJ,CAAC;AAND,8DAMC"}
@@ -22,20 +22,6 @@ class FirebaseModelPermissionServiceInstance extends model_1.AbstractModelPermis
22
22
  return model;
23
23
  });
24
24
  }
25
- getRoleMapForOutput(output, context, model) {
26
- const _super = Object.create(null, {
27
- getRoleMapForOutput: { get: () => super.getRoleMapForOutput }
28
- });
29
- var _a, _b;
30
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
31
- if (context.adminGetsAllowAllRoles && ((_b = (_a = context.auth) === null || _a === void 0 ? void 0 : _a.isAdmin) === null || _b === void 0 ? void 0 : _b.call(_a))) {
32
- return (0, model_1.fullAccessGrantedModelRoles)(context, output);
33
- }
34
- else {
35
- return _super.getRoleMapForOutput.call(this, output, context, model);
36
- }
37
- });
38
- }
39
25
  isUsableOutputForRoles(output) {
40
26
  return output.exists;
41
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"permission.service.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/model/permission/permission.service.ts"],"names":[],"mappings":";;;;AACA,0CAA4M;AAY5M;;GAEG;AACH,MAAa,sCAA4J,SAAQ,sCAA6E;IAC5P,YAAqB,QAA+D;QAClF,KAAK,CAAC,QAAQ,CAAC,CAAC;QADG,aAAQ,GAAR,QAAQ,CAAuD;IAEpF,CAAC;IAED,eAAe,CAAC,MAA4C,EAAE,OAAU,EAAE,KAAQ;QAChF,OAAO,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC/D,CAAC;IAEe,cAAc,CAAC,QAAW;;YACxC,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;YAC/C,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;YAE7B,MAAM,KAAK,GAAgD,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC;YAC9G,OAAO,KAAK,CAAC;QACf,CAAC;KAAA;IAEwB,mBAAmB,CAAC,MAA4C,EAAE,OAAU,EAAE,KAAQ;;;;;;YAC7G,IAAI,OAAO,CAAC,sBAAsB,KAAI,MAAA,MAAA,OAAO,CAAC,IAAI,0CAAE,OAAO,kDAAI,CAAA,EAAE;gBAC/D,OAAO,IAAA,mCAA2B,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;aACrD;iBAAM;gBACL,OAAO,OAAM,mBAAmB,YAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE;aAC1D;;KACF;IAEkB,sBAAsB,CAAC,MAA4C;QACpF,OAAO,MAAM,CAAC,MAAM,CAAC;IACvB,CAAC;CACF;AA5BD,wFA4BC;AAED,SAAgB,8BAA8B,CAAsH,QAA+D;IACjO,OAAO,IAAI,sCAAsC,CAAC,QAAQ,CAAC,CAAC;AAC9D,CAAC;AAFD,wEAEC"}
1
+ {"version":3,"file":"permission.service.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/model/permission/permission.service.ts"],"names":[],"mappings":";;;;AACA,0CAAmN;AAanN;;GAEG;AACH,MAAa,sCAA4J,SAAQ,sCAA6E;IAC5P,YAAqB,QAA+D;QAClF,KAAK,CAAC,QAAQ,CAAC,CAAC;QADG,aAAQ,GAAR,QAAQ,CAAuD;IAEpF,CAAC;IAED,eAAe,CAAC,MAA4C,EAAE,OAAU,EAAE,KAAQ;QAChF,OAAO,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC/D,CAAC;IAEe,cAAc,CAAC,QAAW;;YACxC,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;YAC/C,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;YAE7B,MAAM,KAAK,GAAgD,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC;YAC9G,OAAO,KAAK,CAAC;QACf,CAAC;KAAA;IAEkB,sBAAsB,CAAC,MAA4C;QACpF,OAAO,MAAM,CAAC,MAAM,CAAC;IACvB,CAAC;CACF;AApBD,wFAoBC;AAED,SAAgB,8BAA8B,CAAsH,QAA+D;IACjO,OAAO,IAAI,sCAAsC,CAAC,QAAQ,CAAC,CAAC;AAC9D,CAAC;AAFD,wEAEC"}
package/test/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ # [7.6.0](https://github.com/dereekb/dbx-components/compare/v7.5.0-dev...v7.6.0) (2022-06-09)
6
+
7
+
8
+
9
+ # [7.5.0](https://github.com/dereekb/dbx-components/compare/v7.4.0-dev...v7.5.0) (2022-06-08)
10
+
11
+
12
+
13
+ # [7.4.0](https://github.com/dereekb/dbx-components/compare/v7.3.0-dev...v7.4.0) (2022-06-08)
14
+
15
+
16
+
5
17
  # [7.3.0](https://github.com/dereekb/dbx-components/compare/v7.2.0-dev...v7.3.0) (2022-06-08)
6
18
 
7
19
 
package/test/package.json CHANGED
@@ -1,25 +1,25 @@
1
1
  {
2
2
  "name": "@dereekb/firebase/test",
3
- "version": "7.3.0",
3
+ "version": "7.6.0",
4
4
  "main": "./src/index.js",
5
5
  "typings": "./src/index.d.ts",
6
6
  "dependencies": {},
7
7
  "peerDependencies": {
8
- "@dereekb/util/test": "7.3.0",
9
- "@dereekb/util": "7.3.0",
8
+ "@dereekb/util/test": "7.6.0",
9
+ "@dereekb/util": "7.6.0",
10
10
  "make-error": "^1.3.0",
11
11
  "ts-essentials": "^9.1.2",
12
12
  "extra-set": "^2.2.11",
13
- "@dereekb/firebase": "7.3.0",
13
+ "@dereekb/firebase": "7.6.0",
14
14
  "rxjs": "^7.0.0",
15
15
  "rxfire": "^6.0.3",
16
16
  "firebase": "^9.8.0",
17
- "@dereekb/rxjs": "7.3.0",
17
+ "@dereekb/rxjs": "7.6.0",
18
18
  "ms": "^3.0.0-canary.1",
19
- "@dereekb/model": "7.3.0",
19
+ "@dereekb/model": "7.6.0",
20
20
  "class-transformer": "^0.5.1",
21
21
  "class-validator": "^0.13.2",
22
- "@dereekb/date": "7.3.0",
22
+ "@dereekb/date": "7.6.0",
23
23
  "date-fns": "^2.28.0",
24
24
  "date-fns-tz": "^1.3.0",
25
25
  "rrule": "git+https://git@github.com/dereekb/rrule.git#17adf5708d6567b4d01a3a8afd106261421ea492",