@mahmoud-auth/auth 0.0.0-stage → 0.1.1-beta.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/LICENSE +21 -0
- package/README.md +8 -2
- package/dist/auth-guard/authorization-context.class.d.ts +17 -0
- package/dist/auth-guard/authorization-context.class.js +51 -0
- package/dist/auth-guard/index.d.ts +18 -0
- package/dist/auth-guard/index.js +101 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +17 -0
- package/dist/core/resource.d.ts +5 -0
- package/dist/core/resource.js +15 -0
- package/dist/decorators/authorize.decorator.d.ts +8 -0
- package/dist/decorators/authorize.decorator.js +22 -0
- package/dist/decorators/index.d.ts +3 -0
- package/dist/decorators/index.js +19 -0
- package/dist/decorators/permission.decorator.d.ts +2 -0
- package/dist/decorators/permission.decorator.js +7 -0
- package/dist/decorators/policy.decorator.d.ts +3 -0
- package/dist/decorators/policy.decorator.js +7 -0
- package/dist/dsl/can.d.ts +2 -0
- package/dist/dsl/can.js +9 -0
- package/dist/dsl/condition.d.ts +2 -0
- package/dist/dsl/condition.js +9 -0
- package/dist/dsl/index.d.ts +3 -0
- package/dist/dsl/index.js +19 -0
- package/dist/dsl/trinary/and.d.ts +2 -0
- package/dist/dsl/trinary/and.js +8 -0
- package/dist/dsl/trinary/index.d.ts +3 -0
- package/dist/dsl/trinary/index.js +19 -0
- package/dist/dsl/trinary/not.d.ts +2 -0
- package/dist/dsl/trinary/not.js +8 -0
- package/dist/dsl/trinary/or.d.ts +2 -0
- package/dist/dsl/trinary/or.js +8 -0
- package/dist/errors/circular-policy.exception.d.ts +4 -0
- package/dist/errors/circular-policy.exception.js +10 -0
- package/dist/errors/duplicate-policy.exception.d.ts +4 -0
- package/dist/errors/duplicate-policy.exception.js +10 -0
- package/dist/errors/index.d.ts +4 -0
- package/dist/errors/index.js +20 -0
- package/dist/errors/missing-policy.exception.d.ts +4 -0
- package/dist/errors/missing-policy.exception.js +11 -0
- package/dist/errors/out-of-bounds-action.exception.d.ts +5 -0
- package/dist/errors/out-of-bounds-action.exception.js +13 -0
- package/dist/evaluation/index.d.ts +1 -0
- package/dist/evaluation/index.js +17 -0
- package/dist/evaluation/service.d.ts +16 -0
- package/dist/evaluation/service.js +125 -0
- package/dist/extensions/index.d.ts +1 -0
- package/dist/extensions/index.js +17 -0
- package/dist/extensions/token/index.d.ts +4 -0
- package/dist/extensions/token/index.js +10 -0
- package/dist/feature-shortcuts/index.d.ts +4 -0
- package/dist/feature-shortcuts/index.js +7 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +24 -0
- package/dist/mahmoud.module.d.ts +16 -0
- package/dist/mahmoud.module.js +46 -0
- package/dist/policy/compiler.d.ts +12 -0
- package/dist/policy/compiler.js +65 -0
- package/dist/policy/index.d.ts +4 -0
- package/dist/policy/index.js +20 -0
- package/dist/policy/module.d.ts +9 -0
- package/dist/policy/module.js +42 -0
- package/dist/policy/permission-node.type.d.ts +5 -0
- package/dist/policy/permission-node.type.js +2 -0
- package/dist/policy/registry.d.ts +17 -0
- package/dist/policy/registry.js +113 -0
- package/dist/policy/scanner.d.ts +12 -0
- package/dist/policy/scanner.js +47 -0
- package/dist/policy/validator.d.ts +8 -0
- package/dist/policy/validator.js +61 -0
- package/dist/policy/visualizer/controller.d.ts +6 -0
- package/dist/policy/visualizer/controller.js +34 -0
- package/dist/policy/visualizer/index.d.ts +1 -0
- package/dist/policy/visualizer/index.js +17 -0
- package/dist/tracing/index.d.ts +2 -0
- package/dist/tracing/index.js +18 -0
- package/dist/tracing/module.d.ts +8 -0
- package/dist/tracing/module.js +35 -0
- package/dist/tracing/service.d.ts +17 -0
- package/dist/tracing/service.js +126 -0
- package/dist/tracing/tokens/activate-trace.token.d.ts +3 -0
- package/dist/tracing/tokens/activate-trace.token.js +10 -0
- package/dist/tracing/tokens/evaluation-id.token.d.ts +4 -0
- package/dist/tracing/tokens/evaluation-id.token.js +10 -0
- package/dist/tracing/tokens/index.d.ts +2 -0
- package/dist/tracing/tokens/index.js +18 -0
- package/package.json +46 -6
- package/public/policy-ui/assets/index-BwE3sQ6i.js +149 -0
- package/public/policy-ui/assets/index-CYyoke_2.css +1 -0
- package/public/policy-ui/favicon.svg +1 -0
- package/public/policy-ui/icons.svg +24 -0
- package/public/policy-ui/index.html +13 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PolicyValidator = void 0;
|
|
13
|
+
const common_1 = require("@mahmoud-auth/common");
|
|
14
|
+
const common_2 = require("@nestjs/common");
|
|
15
|
+
const core_1 = require("../core");
|
|
16
|
+
const errors_1 = require("../errors");
|
|
17
|
+
const registry_1 = require("./registry");
|
|
18
|
+
let PolicyValidator = class PolicyValidator {
|
|
19
|
+
policies;
|
|
20
|
+
constructor(policies) {
|
|
21
|
+
this.policies = policies;
|
|
22
|
+
}
|
|
23
|
+
validatePolicies() {
|
|
24
|
+
this.policies
|
|
25
|
+
.getValues()
|
|
26
|
+
.forEach(entry => this.validateCycles(entry.resource, entry.action));
|
|
27
|
+
}
|
|
28
|
+
validateCycles(resourceToken, action, path = []) {
|
|
29
|
+
const key = (0, core_1.createResourceKey)(resourceToken, action);
|
|
30
|
+
if (path.includes(key)) {
|
|
31
|
+
throw new errors_1.CircularPolicyException(path);
|
|
32
|
+
}
|
|
33
|
+
const entry = this.policies.getEntry(resourceToken, action);
|
|
34
|
+
if (!entry) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const nextPath = [...path, key,];
|
|
38
|
+
this.getPermissionDependencies(entry.rule).forEach(permission => {
|
|
39
|
+
this.validateCycles(permission.resource, permission.action, nextPath);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
getPermissionDependencies(rule) {
|
|
43
|
+
if (!rule)
|
|
44
|
+
return [];
|
|
45
|
+
if ((0, common_1.isPermissionRule)(rule)) {
|
|
46
|
+
return [rule];
|
|
47
|
+
}
|
|
48
|
+
if ((0, common_1.isAndRule)(rule) || (0, common_1.isOrRule)(rule)) {
|
|
49
|
+
return rule.children.flatMap(child => this.getPermissionDependencies(child));
|
|
50
|
+
}
|
|
51
|
+
if ((0, common_1.isNotRule)(rule)) {
|
|
52
|
+
return this.getPermissionDependencies(rule.child);
|
|
53
|
+
}
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
exports.PolicyValidator = PolicyValidator;
|
|
58
|
+
exports.PolicyValidator = PolicyValidator = __decorate([
|
|
59
|
+
(0, common_2.Injectable)(),
|
|
60
|
+
__metadata("design:paramtypes", [registry_1.PolicyRegistry])
|
|
61
|
+
], PolicyValidator);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.VisualizerController = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const registry_1 = require("../registry");
|
|
15
|
+
let VisualizerController = class VisualizerController {
|
|
16
|
+
graph;
|
|
17
|
+
constructor(graph) {
|
|
18
|
+
this.graph = graph;
|
|
19
|
+
}
|
|
20
|
+
getGraph() {
|
|
21
|
+
return this.graph.toVisualizationDto();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.VisualizerController = VisualizerController;
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, common_1.Get)(),
|
|
27
|
+
__metadata("design:type", Function),
|
|
28
|
+
__metadata("design:paramtypes", []),
|
|
29
|
+
__metadata("design:returntype", void 0)
|
|
30
|
+
], VisualizerController.prototype, "getGraph", null);
|
|
31
|
+
exports.VisualizerController = VisualizerController = __decorate([
|
|
32
|
+
(0, common_1.Controller)('mahmoudAuth/visual'),
|
|
33
|
+
__metadata("design:paramtypes", [registry_1.PolicyRegistry])
|
|
34
|
+
], VisualizerController);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './controller';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./controller"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./service"), exports);
|
|
18
|
+
__exportStar(require("./module"), exports);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var TraceModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.TraceModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const utils_1 = require("@mahmoud-auth/utils");
|
|
13
|
+
const service_1 = require("./service");
|
|
14
|
+
const tokens_1 = require("./tokens");
|
|
15
|
+
let TraceModule = TraceModule_1 = class TraceModule {
|
|
16
|
+
static forRoot({ activateTrace = false }) {
|
|
17
|
+
return {
|
|
18
|
+
module: TraceModule_1,
|
|
19
|
+
providers: [
|
|
20
|
+
{
|
|
21
|
+
provide: common_1.Logger,
|
|
22
|
+
useFactory: () => new common_1.Logger(service_1.AuthorizationTraceService.name),
|
|
23
|
+
},
|
|
24
|
+
(0, tokens_1.useValueActivateTrace)(activateTrace),
|
|
25
|
+
(0, tokens_1.useFactoryEvaluationId)(() => (0, utils_1.nanoid)(10), { scope: common_1.Scope.REQUEST }),
|
|
26
|
+
service_1.AuthorizationTraceService
|
|
27
|
+
],
|
|
28
|
+
exports: [service_1.AuthorizationTraceService],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.TraceModule = TraceModule;
|
|
33
|
+
exports.TraceModule = TraceModule = TraceModule_1 = __decorate([
|
|
34
|
+
(0, common_1.Module)({})
|
|
35
|
+
], TraceModule);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Logger } from "@nestjs/common";
|
|
2
|
+
import { RuleType } from '@mahmoud-auth/common';
|
|
3
|
+
export declare class AuthorizationTraceService {
|
|
4
|
+
private readonly logger;
|
|
5
|
+
private readonly activateTrace;
|
|
6
|
+
private readonly evaluationId;
|
|
7
|
+
constructor(logger: Logger, activateTrace: boolean, evaluationId: string);
|
|
8
|
+
private upperCaseBoolean;
|
|
9
|
+
ruleEntered(type: RuleType, details?: (string | undefined)[]): string;
|
|
10
|
+
ruleResolved(type: RuleType, ruleId: string, result: boolean): void;
|
|
11
|
+
policyEntered(resource: string, action: string, route?: string): void;
|
|
12
|
+
policyLeft(resource: string, action: string, result: boolean, route?: string): void;
|
|
13
|
+
policyFailed(resource: string, action: string, error: unknown, route?: string): void;
|
|
14
|
+
ruleFailed(type: RuleType, ruleId: string, error: unknown): void;
|
|
15
|
+
resourceResolved(resource: string, outcome: 'skipped' | 'missing_id' | 'found' | 'not_found' | 'error', error?: unknown): void;
|
|
16
|
+
private format;
|
|
17
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.AuthorizationTraceService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const utils_1 = require("@mahmoud-auth/utils");
|
|
18
|
+
const tokens_1 = require("./tokens");
|
|
19
|
+
let AuthorizationTraceService = class AuthorizationTraceService {
|
|
20
|
+
logger;
|
|
21
|
+
activateTrace;
|
|
22
|
+
evaluationId;
|
|
23
|
+
constructor(logger, activateTrace, evaluationId) {
|
|
24
|
+
this.logger = logger;
|
|
25
|
+
this.activateTrace = activateTrace;
|
|
26
|
+
this.evaluationId = evaluationId;
|
|
27
|
+
}
|
|
28
|
+
upperCaseBoolean(result) {
|
|
29
|
+
return `${result}`.toUpperCase();
|
|
30
|
+
}
|
|
31
|
+
ruleEntered(type, details = []) {
|
|
32
|
+
const ruleId = (0, utils_1.nanoid)(8);
|
|
33
|
+
if (!this.activateTrace) {
|
|
34
|
+
return ruleId;
|
|
35
|
+
}
|
|
36
|
+
const lines = [
|
|
37
|
+
`Entering ${type.toUpperCase()} rule [${ruleId}]`,
|
|
38
|
+
...(details.filter(line => line != null))
|
|
39
|
+
].filter(Boolean);
|
|
40
|
+
this.logger.debug(this.format(lines));
|
|
41
|
+
return ruleId;
|
|
42
|
+
}
|
|
43
|
+
ruleResolved(type, ruleId, result) {
|
|
44
|
+
if (!this.activateTrace) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const lines = [
|
|
48
|
+
type !== 'condition' && 'Leaving ',
|
|
49
|
+
`${type.toUpperCase()} rule [${ruleId}]`,
|
|
50
|
+
`resolved as ${this.upperCaseBoolean(result)}`
|
|
51
|
+
];
|
|
52
|
+
this.logger.debug(this.format(lines));
|
|
53
|
+
}
|
|
54
|
+
policyEntered(resource, action, route) {
|
|
55
|
+
if (!this.activateTrace) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
this.logger.debug(this.format([
|
|
59
|
+
'event policy.enter',
|
|
60
|
+
`Entering policy ${resource} |`,
|
|
61
|
+
`action ${action}`,
|
|
62
|
+
!!route && `route ${route}`,
|
|
63
|
+
]));
|
|
64
|
+
}
|
|
65
|
+
policyLeft(resource, action, result, route) {
|
|
66
|
+
if (!this.activateTrace) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
this.logger.debug(this.format([
|
|
70
|
+
'event policy.leave',
|
|
71
|
+
`Leaving policy ${resource} |`,
|
|
72
|
+
`action ${action} |`,
|
|
73
|
+
!!route && `route ${route} |`,
|
|
74
|
+
`resolved as ${this.upperCaseBoolean(result)}`
|
|
75
|
+
]));
|
|
76
|
+
}
|
|
77
|
+
policyFailed(resource, action, error, route) {
|
|
78
|
+
if (!this.activateTrace) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
this.logger.warn(this.format([
|
|
82
|
+
'event policy.error',
|
|
83
|
+
`resource ${resource}`,
|
|
84
|
+
`action ${action}`,
|
|
85
|
+
!!route && `route ${route}`,
|
|
86
|
+
`error ${(error instanceof Error ? error.name : 'UnknownError')}`,
|
|
87
|
+
]));
|
|
88
|
+
}
|
|
89
|
+
ruleFailed(type, ruleId, error) {
|
|
90
|
+
if (!this.activateTrace) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
this.logger.warn(this.format([
|
|
94
|
+
'event rule.error',
|
|
95
|
+
`${type.toUpperCase()} rule [${ruleId}]`,
|
|
96
|
+
`error ${(error instanceof Error ? error.name : 'UnknownError')}`,
|
|
97
|
+
]));
|
|
98
|
+
}
|
|
99
|
+
resourceResolved(resource, outcome, error) {
|
|
100
|
+
if (!this.activateTrace) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
this.logger.debug(this.format([
|
|
104
|
+
'event resource.resolve',
|
|
105
|
+
`resource ${resource}`,
|
|
106
|
+
`outcome ${outcome}`,
|
|
107
|
+
outcome === 'error' && `error ${error instanceof Error ? error.name : 'UnknownError'}`,
|
|
108
|
+
]));
|
|
109
|
+
}
|
|
110
|
+
format(lines) {
|
|
111
|
+
return [
|
|
112
|
+
`[TRACE ${this.evaluationId}]:`,
|
|
113
|
+
...(lines.filter(line => line != null)),
|
|
114
|
+
]
|
|
115
|
+
.filter(Boolean)
|
|
116
|
+
.join(" ");
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
exports.AuthorizationTraceService = AuthorizationTraceService;
|
|
120
|
+
exports.AuthorizationTraceService = AuthorizationTraceService = __decorate([
|
|
121
|
+
(0, common_1.Injectable)(),
|
|
122
|
+
__param(0, (0, common_1.Inject)(common_1.Logger)),
|
|
123
|
+
__param(1, (0, tokens_1.InjectActivateTrace)()),
|
|
124
|
+
__param(2, (0, tokens_1.InjectEvaluationId)()),
|
|
125
|
+
__metadata("design:paramtypes", [common_1.Logger, Boolean, String])
|
|
126
|
+
], AuthorizationTraceService);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useValueActivateTrace = exports.InjectActivateTrace = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const utils_1 = require("@mahmoud-auth/utils");
|
|
6
|
+
const ACTIVATE_TRACE_TOKEN = Symbol('TRACE_TOKEN');
|
|
7
|
+
const InjectActivateTrace = () => (0, common_1.Inject)(ACTIVATE_TRACE_TOKEN);
|
|
8
|
+
exports.InjectActivateTrace = InjectActivateTrace;
|
|
9
|
+
const useValueActivateTrace = (activateTrace, ...rest) => (0, utils_1.useValue)(ACTIVATE_TRACE_TOKEN, activateTrace, ...rest);
|
|
10
|
+
exports.useValueActivateTrace = useValueActivateTrace;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useFactoryEvaluationId = exports.InjectEvaluationId = exports.EVALUATION_ID = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const utils_1 = require("@mahmoud-auth/utils");
|
|
6
|
+
exports.EVALUATION_ID = Symbol('EVALUATION_ID');
|
|
7
|
+
const InjectEvaluationId = () => (0, common_1.Inject)(exports.EVALUATION_ID);
|
|
8
|
+
exports.InjectEvaluationId = InjectEvaluationId;
|
|
9
|
+
const useFactoryEvaluationId = (...props) => (0, utils_1.useFactory)(exports.EVALUATION_ID, ...props);
|
|
10
|
+
exports.useFactoryEvaluationId = useFactoryEvaluationId;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./activate-trace.token"), exports);
|
|
18
|
+
__exportStar(require("./evaluation-id.token"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@mahmoud-auth/auth",
|
|
3
|
+
"version": "0.1.1-beta.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Policy-based authorization for NestJS applications.",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE",
|
|
18
|
+
"public"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"clean": "rimraf dist",
|
|
22
|
+
"build": "rimraf dist \u0026\u0026 tsc -p tsconfig.build.json",
|
|
23
|
+
"prepack": "npm run build"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@mahmoud-auth/common": "*",
|
|
27
|
+
"@mahmoud-auth/model-climbers": "*",
|
|
28
|
+
"@mahmoud-auth/utils": "*"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@nestjs/common": "^11.0.0",
|
|
32
|
+
"@nestjs/core": "^11.0.0",
|
|
33
|
+
"reflect-metadata": "^0.1.13 || ^0.2.0"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": "^22.12.0 || ^24.0.0 || \u003e=26.0.0"
|
|
37
|
+
},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public"
|
|
40
|
+
},
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "git+https://github.com/shahariko-lab/nestjs-rebac.git",
|
|
44
|
+
"directory": "packages/mahmoud/auth"
|
|
45
|
+
}
|
|
46
|
+
}
|