@dereekb/firebase 7.5.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 +9 -0
- package/package.json +5 -5
- package/src/lib/common/model/permission/index.d.ts +1 -0
- package/src/lib/common/model/permission/index.js +1 -0
- package/src/lib/common/model/permission/index.js.map +1 -1
- package/src/lib/common/model/permission/permission.service.d.ts +1 -51
- package/src/lib/common/model/permission/permission.service.grant.d.ts +81 -0
- package/src/lib/common/model/permission/permission.service.grant.js +88 -0
- package/src/lib/common/model/permission/permission.service.grant.js.map +1 -0
- package/src/lib/common/model/permission/permission.service.js +1 -56
- package/src/lib/common/model/permission/permission.service.js.map +1 -1
- package/test/CHANGELOG.md +4 -0
- package/test/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
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
|
+
|
|
5
14
|
# [7.5.0](https://github.com/dereekb/dbx-components/compare/v7.4.0-dev...v7.5.0) (2022-06-08)
|
|
6
15
|
|
|
7
16
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase",
|
|
3
|
-
"version": "7.
|
|
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.
|
|
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.
|
|
29
|
+
"@dereekb/rxjs": "7.6.0",
|
|
30
30
|
"ms": "^3.0.0-canary.1",
|
|
31
|
-
"@dereekb/model": "7.
|
|
31
|
+
"@dereekb/model": "7.6.0",
|
|
32
32
|
"class-transformer": "^0.5.1",
|
|
33
33
|
"class-validator": "^0.13.2",
|
|
34
|
-
"@dereekb/date": "7.
|
|
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",
|
|
@@ -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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FirestoreDocument } from './../../firestore';
|
|
2
2
|
import { AbstractModelPermissionService, GrantedRoleMap, InContextModelPermissionService, InModelContextModelPermissionService, ModelPermissionService } from '@dereekb/model';
|
|
3
|
-
import {
|
|
3
|
+
import { Maybe, PromiseOrValue } from '@dereekb/util';
|
|
4
4
|
import { FirebaseModelLoader, InModelContextFirebaseModelLoader } from '../model/model.loader';
|
|
5
5
|
import { FirebaseModelContext } from '../context';
|
|
6
6
|
import { FirebasePermissionServiceModel } from './permission';
|
|
@@ -21,53 +21,3 @@ export declare class FirebaseModelPermissionServiceInstance<C extends FirebaseMo
|
|
|
21
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>;
|
|
22
22
|
export declare type InContextFirebaseModelPermissionService<C, T, D extends FirestoreDocument<T> = FirestoreDocument<T>, R extends string = string> = InContextModelPermissionService<C, D, R, FirebasePermissionServiceModel<T, D>>;
|
|
23
23
|
export declare type InModelContextFirebaseModelPermissionService<C, T, D extends FirestoreDocument<T> = FirestoreDocument<T>, R extends string = string> = InModelContextModelPermissionService<C, D, R, FirebasePermissionServiceModel<T, D>> & InModelContextFirebaseModelLoader<T, D>;
|
|
24
|
-
export declare const grantFullAccessIfAdmin: GeneralGrantRolesIfFunction;
|
|
25
|
-
export declare function grantModelRolesIfAdmin<R extends string = string>(context: FirebaseModelContext, rolesToGrantToAdmin: GetterOrValue<GrantedRoleMap<R>>, otherwise?: GrantRolesOtherwiseFunction<R>): GrantedRoleMap<R>;
|
|
26
|
-
/**
|
|
27
|
-
* Convenience function that checks the input context if the user is an admin or not and grants pre-set admin roles if they are.
|
|
28
|
-
*
|
|
29
|
-
* @param context
|
|
30
|
-
* @param rolesToGrantToAdmin
|
|
31
|
-
* @param otherwise
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
export declare function grantModelRolesIfAdminFunction<R extends string = string>(rolesToGrantToAdmin: GetterOrValue<GrantedRoleMap<R>>): GrantRolesIfFunction<R>;
|
|
35
|
-
/**
|
|
36
|
-
* DecisionFunction for a FirebaseModelContext that checks if the current user is an admin.
|
|
37
|
-
*
|
|
38
|
-
* @param context
|
|
39
|
-
* @returns
|
|
40
|
-
*/
|
|
41
|
-
export declare const isAdminInFirebaseModelContext: DecisionFunction<FirebaseModelContext>;
|
|
42
|
-
/**
|
|
43
|
-
* Grants the configured roles if the decision is made about the context. Otherwise, returns a NoAccessRoleMap.
|
|
44
|
-
*/
|
|
45
|
-
export declare type GrantRolesOnlyIfFunction<R extends string = string, C extends FirebaseModelContext = FirebaseModelContext> = (context: C) => GrantedRoleMap<R>;
|
|
46
|
-
export declare type GeneralGrantRolesOnlyIfFunction = <R extends string = string, C extends FirebaseModelContext = FirebaseModelContext>(context: C) => GrantedRoleMap<R>;
|
|
47
|
-
/**
|
|
48
|
-
* Creates a GrantRolesOnlyIfFunction
|
|
49
|
-
*
|
|
50
|
-
* @param grantIf
|
|
51
|
-
* @param grantedRoles
|
|
52
|
-
* @returns
|
|
53
|
-
*/
|
|
54
|
-
export declare function grantModelRolesOnlyIfFunction<C extends FirebaseModelContext, R extends string = string>(grantIf: DecisionFunction<C>, grantedRoles: GetterOrValue<GrantedRoleMap<R>>): GrantRolesOnlyIfFunction<R, C>;
|
|
55
|
-
/**
|
|
56
|
-
* Grants the configured roles if the decision is made about the context. Otherwise, invokes the otherwise function if available, or returns a NoAccessRoleMap.
|
|
57
|
-
*/
|
|
58
|
-
export declare type GrantRolesIfFunction<R extends string = string, C extends FirebaseModelContext = FirebaseModelContext> = (context: C, otherwise?: GrantRolesOtherwiseFunction<R>) => GrantedRoleMap<R>;
|
|
59
|
-
export declare type GeneralGrantRolesIfFunction = <R extends string = string, C extends FirebaseModelContext = FirebaseModelContext>(context: C, otherwise?: GrantRolesOtherwiseFunction<R>) => GrantedRoleMap<R>;
|
|
60
|
-
/**
|
|
61
|
-
* Used as the "else" statement for grantModelRolesIfFunction.
|
|
62
|
-
*
|
|
63
|
-
* If no roles are returned, the grantModelRolesIfFunction() will return a NoAccessRoleMap.
|
|
64
|
-
*/
|
|
65
|
-
export declare type GrantRolesOtherwiseFunction<R extends string = string> = Getter<Maybe<GrantedRoleMap<R>>>;
|
|
66
|
-
/**
|
|
67
|
-
* Creates a GrantRolesIfFunction.
|
|
68
|
-
*
|
|
69
|
-
* @param grantIf
|
|
70
|
-
* @param grantedRoles
|
|
71
|
-
* @returns
|
|
72
|
-
*/
|
|
73
|
-
export declare function grantModelRolesIfFunction<C extends FirebaseModelContext, R extends string = string>(grantIf: DecisionFunction<C>, grantedRoles: GetterOrValue<GrantedRoleMap<R>>): GrantRolesIfFunction<R, C>;
|
|
@@ -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;AAFD,wEAEC;AAED;;;;;GAKG;AACI,MAAM,6BAA6B,GAAgD,CAAC,OAA6B,EAAE,EAAE,eAAC,OAAA,MAAA,MAAA,OAAO,CAAC,IAAI,0CAAE,OAAO,EAAE,mCAAI,KAAK,CAAA,EAAA,CAAC;AAAjJ,QAAA,6BAA6B,iCAAoH;AAQ9J;;GAEG;AACU,QAAA,gCAAgC,GAAgC,8BAA8B,CAAC,yBAAiB,CAAC,CAAC;AAE/H;;;;;;;GAOG;AACH,SAAgB,6CAA6C,CAAmD,YAA8C;IAC5J,OAAO,yBAAyB,CAAC,uDAA+C,EAAE,YAAY,CAAC,CAAC;AAClG,CAAC;AAFD,sGAEC;AAED;;;;;GAKG;AACI,MAAM,+CAA+C,GAA6E,CAAC,EAAE,OAAO,EAAE,KAAK,EAAwC,EAAE,EAAE,WAAC,OAAA,CAAA,MAAA,OAAO,CAAC,IAAI,0CAAE,GAAG,MAAK,KAAK,CAAC,GAAG,CAAA,EAAA,CAAC;AAA1N,QAAA,+CAA+C,mDAA2K;AASvO;;;;;;GAMG;AACH,SAAgB,6BAA6B,CAA+B,OAAiC,EAAE,YAA8C;IAC3J,MAAM,EAAE,GAAG,yBAAyB,CAAO,OAAO,EAAE,YAAY,CAAC,CAAC;IAClE,OAAO,CAAC,OAAU,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAHD,sEAGC;AAeD;;;;;;GAMG;AACH,SAAgB,yBAAyB,CAA+B,OAAiC,EAAE,YAA8C;IACvJ,OAAO,CAAO,OAAU,EAAE,YAA4C,uBAAe,EAAE,EAAE;;QACvF,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;QACxC,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,IAAA,yBAAkB,EAAC,YAAY,CAAC,CAAC,CAAC,CAAC,MAAA,CAAC,MAAM,SAAS,EAAE,CAAC,mCAAI,IAAA,uBAAe,GAAE,CAAC;QAC7G,OAAO,OAAO,CAAC;IACjB,CAAC,CAAA,CAAC;AACJ,CAAC;AAND,8DAMC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.firebaseModelPermissionService = exports.FirebaseModelPermissionServiceInstance = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const model_1 = require("@dereekb/model");
|
|
6
|
-
const util_1 = require("@dereekb/util");
|
|
7
6
|
/**
|
|
8
7
|
* Abstract AbstractModelPermissionService implementation for FirebaseModelsPermissionService.
|
|
9
8
|
*/
|
|
@@ -32,58 +31,4 @@ function firebaseModelPermissionService(delegate) {
|
|
|
32
31
|
return new FirebaseModelPermissionServiceInstance(delegate);
|
|
33
32
|
}
|
|
34
33
|
exports.firebaseModelPermissionService = firebaseModelPermissionService;
|
|
35
|
-
// MARK: Utility
|
|
36
|
-
exports.grantFullAccessIfAdmin = grantModelRolesIfAdminFunction(model_1.fullAccessRoleMap);
|
|
37
|
-
function grantModelRolesIfAdmin(context, rolesToGrantToAdmin, otherwise) {
|
|
38
|
-
return grantModelRolesIfAdminFunction(rolesToGrantToAdmin)(context, otherwise);
|
|
39
|
-
}
|
|
40
|
-
exports.grantModelRolesIfAdmin = grantModelRolesIfAdmin;
|
|
41
|
-
/**
|
|
42
|
-
* Convenience function that checks the input context if the user is an admin or not and grants pre-set admin roles if they are.
|
|
43
|
-
*
|
|
44
|
-
* @param context
|
|
45
|
-
* @param rolesToGrantToAdmin
|
|
46
|
-
* @param otherwise
|
|
47
|
-
* @returns
|
|
48
|
-
*/
|
|
49
|
-
function grantModelRolesIfAdminFunction(rolesToGrantToAdmin) {
|
|
50
|
-
return grantModelRolesIfFunction(exports.isAdminInFirebaseModelContext, rolesToGrantToAdmin);
|
|
51
|
-
}
|
|
52
|
-
exports.grantModelRolesIfAdminFunction = grantModelRolesIfAdminFunction;
|
|
53
|
-
/**
|
|
54
|
-
* DecisionFunction for a FirebaseModelContext that checks if the current user is an admin.
|
|
55
|
-
*
|
|
56
|
-
* @param context
|
|
57
|
-
* @returns
|
|
58
|
-
*/
|
|
59
|
-
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; };
|
|
60
|
-
exports.isAdminInFirebaseModelContext = isAdminInFirebaseModelContext;
|
|
61
|
-
/**
|
|
62
|
-
* Creates a GrantRolesOnlyIfFunction
|
|
63
|
-
*
|
|
64
|
-
* @param grantIf
|
|
65
|
-
* @param grantedRoles
|
|
66
|
-
* @returns
|
|
67
|
-
*/
|
|
68
|
-
function grantModelRolesOnlyIfFunction(grantIf, grantedRoles) {
|
|
69
|
-
const fn = grantModelRolesIfFunction(grantIf, grantedRoles);
|
|
70
|
-
return (context) => fn(context);
|
|
71
|
-
}
|
|
72
|
-
exports.grantModelRolesOnlyIfFunction = grantModelRolesOnlyIfFunction;
|
|
73
|
-
/**
|
|
74
|
-
* Creates a GrantRolesIfFunction.
|
|
75
|
-
*
|
|
76
|
-
* @param grantIf
|
|
77
|
-
* @param grantedRoles
|
|
78
|
-
* @returns
|
|
79
|
-
*/
|
|
80
|
-
function grantModelRolesIfFunction(grantIf, grantedRoles) {
|
|
81
|
-
return (context, otherwise = model_1.noAccessRoleMap) => {
|
|
82
|
-
var _a;
|
|
83
|
-
const decision = grantIf(context);
|
|
84
|
-
const results = decision ? (0, util_1.getValueFromGetter)(grantedRoles) : (_a = otherwise()) !== null && _a !== void 0 ? _a : (0, model_1.noAccessRoleMap)();
|
|
85
|
-
return results;
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
exports.grantModelRolesIfFunction = grantModelRolesIfFunction;
|
|
89
34
|
//# sourceMappingURL=permission.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission.service.js","sourceRoot":"","sources":["../../../../../../../../packages/firebase/src/lib/common/model/permission/permission.service.ts"],"names":[],"mappings":";;;;AACA,0CAAmN;
|
|
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,10 @@
|
|
|
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
|
+
|
|
5
9
|
# [7.5.0](https://github.com/dereekb/dbx-components/compare/v7.4.0-dev...v7.5.0) (2022-06-08)
|
|
6
10
|
|
|
7
11
|
|
package/test/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase/test",
|
|
3
|
-
"version": "7.
|
|
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.
|
|
9
|
-
"@dereekb/util": "7.
|
|
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.
|
|
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.
|
|
17
|
+
"@dereekb/rxjs": "7.6.0",
|
|
18
18
|
"ms": "^3.0.0-canary.1",
|
|
19
|
-
"@dereekb/model": "7.
|
|
19
|
+
"@dereekb/model": "7.6.0",
|
|
20
20
|
"class-transformer": "^0.5.1",
|
|
21
21
|
"class-validator": "^0.13.2",
|
|
22
|
-
"@dereekb/date": "7.
|
|
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",
|