@spinajs/rbac-http 2.0.46 → 2.0.51
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/README.md +11 -11
- package/lib/2fa/SpeakEasy2FaToken.d.ts +2 -1
- package/lib/2fa/SpeakEasy2FaToken.d.ts.map +1 -0
- package/lib/2fa/SpeakEasy2FaToken.js +11 -37
- package/lib/2fa/SpeakEasy2FaToken.js.map +1 -1
- package/lib/config/rbac-http.d.ts +1 -0
- package/lib/config/rbac-http.d.ts.map +1 -0
- package/lib/config/rbac-http.js +2 -4
- package/lib/config/rbac-http.js.map +1 -1
- package/lib/controllers/LoginController.d.ts +7 -6
- package/lib/controllers/LoginController.d.ts.map +1 -0
- package/lib/controllers/LoginController.js +89 -92
- package/lib/controllers/LoginController.js.map +1 -1
- package/lib/controllers/TwoFactorAuthController.d.ts +4 -3
- package/lib/controllers/TwoFactorAuthController.d.ts.map +1 -0
- package/lib/controllers/TwoFactorAuthController.js +31 -34
- package/lib/controllers/TwoFactorAuthController.js.map +1 -1
- package/lib/controllers/UserAdminController.d.ts +1 -0
- package/lib/controllers/UserAdminController.d.ts.map +1 -0
- package/lib/controllers/UserAdminController.js +6 -9
- package/lib/controllers/UserAdminController.js.map +1 -1
- package/lib/controllers/UserController.d.ts +2 -1
- package/lib/controllers/UserController.d.ts.map +1 -0
- package/lib/controllers/UserController.js +30 -56
- package/lib/controllers/UserController.js.map +1 -1
- package/lib/controllers/UserMetadata.d.ts +1 -0
- package/lib/controllers/UserMetadata.d.ts.map +1 -0
- package/lib/controllers/UserMetadata.js +24 -28
- package/lib/controllers/UserMetadata.js.map +1 -1
- package/lib/decorators.d.ts +2 -1
- package/lib/decorators.d.ts.map +1 -0
- package/lib/decorators.js +16 -24
- package/lib/decorators.js.map +1 -1
- package/lib/dto/login-dto.d.ts +1 -0
- package/lib/dto/login-dto.d.ts.map +1 -0
- package/lib/dto/login-dto.js +4 -7
- package/lib/dto/login-dto.js.map +1 -1
- package/lib/dto/password-dto.d.ts +1 -0
- package/lib/dto/password-dto.d.ts.map +1 -0
- package/lib/dto/password-dto.js +4 -7
- package/lib/dto/password-dto.js.map +1 -1
- package/lib/dto/restore-password-dto.d.ts +1 -0
- package/lib/dto/restore-password-dto.d.ts.map +1 -0
- package/lib/dto/restore-password-dto.js +4 -7
- package/lib/dto/restore-password-dto.js.map +1 -1
- package/lib/dto/token-dto.d.ts +1 -0
- package/lib/dto/token-dto.d.ts.map +1 -0
- package/lib/dto/token-dto.js +4 -7
- package/lib/dto/token-dto.js.map +1 -1
- package/lib/dto/user-dto.d.ts +1 -0
- package/lib/dto/user-dto.d.ts.map +1 -0
- package/lib/dto/user-dto.js +4 -7
- package/lib/dto/user-dto.js.map +1 -1
- package/lib/dto/userLogin-dto.d.ts +1 -0
- package/lib/dto/userLogin-dto.d.ts.map +1 -0
- package/lib/dto/userLogin-dto.js +4 -7
- package/lib/dto/userLogin-dto.js.map +1 -1
- package/lib/events/UserLoginFailed.d.ts +1 -0
- package/lib/events/UserLoginFailed.d.ts.map +1 -0
- package/lib/events/UserLoginFailed.js +4 -7
- package/lib/events/UserLoginFailed.js.map +1 -1
- package/lib/events/UserLoginSuccess.d.ts +1 -0
- package/lib/events/UserLoginSuccess.d.ts.map +1 -0
- package/lib/events/UserLoginSuccess.js +4 -7
- package/lib/events/UserLoginSuccess.js.map +1 -1
- package/lib/events/UserPassordRestore.d.ts +1 -0
- package/lib/events/UserPassordRestore.d.ts.map +1 -0
- package/lib/events/UserPassordRestore.js +4 -7
- package/lib/events/UserPassordRestore.js.map +1 -1
- package/lib/fingerprint/FingerprintJs.d.ts +2 -1
- package/lib/fingerprint/FingerprintJs.d.ts.map +1 -0
- package/lib/fingerprint/FingerprintJs.js +5 -8
- package/lib/fingerprint/FingerprintJs.js.map +1 -1
- package/lib/index.d.ts +9 -8
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +8 -24
- package/lib/index.js.map +1 -1
- package/lib/interfaces.d.ts +2 -1
- package/lib/interfaces.d.ts.map +1 -0
- package/lib/interfaces.js +2 -7
- package/lib/interfaces.js.map +1 -1
- package/lib/middlewares/AttributeFilter.d.ts +1 -0
- package/lib/middlewares/AttributeFilter.d.ts.map +1 -0
- package/lib/middlewares/AttributeFilter.js +2 -6
- package/lib/middlewares/AttributeFilter.js.map +1 -1
- package/lib/middlewares.d.ts +1 -0
- package/lib/middlewares.d.ts.map +1 -0
- package/lib/middlewares.js +13 -39
- package/lib/middlewares.js.map +1 -1
- package/lib/policies/2FaPolicy.d.ts +2 -1
- package/lib/policies/2FaPolicy.d.ts.map +1 -0
- package/lib/policies/2FaPolicy.js +6 -10
- package/lib/policies/2FaPolicy.js.map +1 -1
- package/lib/policies/LoggedPolicy.d.ts +1 -0
- package/lib/policies/LoggedPolicy.d.ts.map +1 -0
- package/lib/policies/LoggedPolicy.js +4 -8
- package/lib/policies/LoggedPolicy.js.map +1 -1
- package/lib/policies/NotLoggedPolicy.d.ts +1 -0
- package/lib/policies/NotLoggedPolicy.d.ts.map +1 -0
- package/lib/policies/NotLoggedPolicy.js +4 -8
- package/lib/policies/NotLoggedPolicy.js.map +1 -1
- package/lib/policies/RbacPolicy.d.ts +1 -0
- package/lib/policies/RbacPolicy.d.ts.map +1 -0
- package/lib/policies/RbacPolicy.js +17 -25
- package/lib/policies/RbacPolicy.js.map +1 -1
- package/lib/policies/captchaPolicy.d.ts +2 -0
- package/lib/policies/captchaPolicy.d.ts.map +1 -0
- package/lib/policies/captchaPolicy.js +1 -0
- package/lib/route-args.d.ts +2 -1
- package/lib/route-args.d.ts.map +1 -0
- package/lib/route-args.js +9 -12
- package/lib/route-args.js.map +1 -1
- package/lib/transformers.d.ts +1 -0
- package/lib/transformers.d.ts.map +1 -0
- package/lib/transformers.js +7 -13
- package/lib/transformers.js.map +1 -1
- package/package.json +66 -63
- package/lib/policies/AuthPolicy.d.ts +0 -9
- package/lib/policies/AuthPolicy.js +0 -23
- package/lib/policies/AuthPolicy.js.map +0 -1
- package/lib/policies.d.ts +0 -12
- package/lib/policies.js +0 -57
- package/lib/policies.js.map +0 -1
package/lib/middlewares.js
CHANGED
|
@@ -1,45 +1,19 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
4
|
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;
|
|
22
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
6
|
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
9
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const http_1 = require("@spinajs/http");
|
|
42
|
-
let RbacMiddleware = class RbacMiddleware extends http_1.ServerMiddleware {
|
|
10
|
+
import { SessionProvider, User } from '@spinajs/rbac';
|
|
11
|
+
import { Autoinject, Injectable } from '@spinajs/di';
|
|
12
|
+
import 'reflect-metadata';
|
|
13
|
+
import { Config } from '@spinajs/configuration';
|
|
14
|
+
import * as cs from 'cookie-signature';
|
|
15
|
+
import { ServerMiddleware } from '@spinajs/http';
|
|
16
|
+
let RbacMiddleware = class RbacMiddleware extends ServerMiddleware {
|
|
43
17
|
async resolve() {
|
|
44
18
|
if (!this.CoockieSecret) {
|
|
45
19
|
throw new Error('http.cookie.secres is not set, cannot start UserFromSessionMiddleware. Set this value in configuration file !');
|
|
@@ -53,7 +27,7 @@ let RbacMiddleware = class RbacMiddleware extends http_1.ServerMiddleware {
|
|
|
53
27
|
if (ssid) {
|
|
54
28
|
const session = await this.SessionProvider.restore(ssid);
|
|
55
29
|
if (session) {
|
|
56
|
-
req.storage.user = new
|
|
30
|
+
req.storage.user = new User(session.Data.get('User'));
|
|
57
31
|
req.storage.session = session;
|
|
58
32
|
}
|
|
59
33
|
else {
|
|
@@ -76,15 +50,15 @@ let RbacMiddleware = class RbacMiddleware extends http_1.ServerMiddleware {
|
|
|
76
50
|
}
|
|
77
51
|
};
|
|
78
52
|
__decorate([
|
|
79
|
-
|
|
53
|
+
Config('http.cookie.secret'),
|
|
80
54
|
__metadata("design:type", String)
|
|
81
55
|
], RbacMiddleware.prototype, "CoockieSecret", void 0);
|
|
82
56
|
__decorate([
|
|
83
|
-
|
|
84
|
-
__metadata("design:type",
|
|
57
|
+
Autoinject(),
|
|
58
|
+
__metadata("design:type", SessionProvider)
|
|
85
59
|
], RbacMiddleware.prototype, "SessionProvider", void 0);
|
|
86
60
|
RbacMiddleware = __decorate([
|
|
87
|
-
|
|
61
|
+
Injectable(ServerMiddleware)
|
|
88
62
|
], RbacMiddleware);
|
|
89
|
-
|
|
63
|
+
export { RbacMiddleware };
|
|
90
64
|
//# sourceMappingURL=middlewares.js.map
|
package/lib/middlewares.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middlewares.js","sourceRoot":"","sources":["../src/middlewares.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"middlewares.js","sourceRoot":"","sources":["../src/middlewares.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAuB,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAG/D,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,gBAAgB;IAO3C,KAAK,CAAC,OAAO;QAClB,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE;YACvB,MAAM,IAAI,KAAK,CAAC,+GAA+G,CAAC,CAAC;SAClI;IACH,CAAC;IAEM,MAAM;QACX,OAAO,KAAK,EAAE,GAAa,EAAE,IAAsB,EAAE,IAA0B,EAAE,EAAE;YACjF,IAAI;gBACF,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE;oBACpB,MAAM,IAAI,GAAmB,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;oBAC7E,IAAI,IAAI,EAAE;wBACR,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;wBACzD,IAAI,OAAO,EAAE;4BACX,GAAG,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;4BACtD,GAAG,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;yBAC/B;6BAAM;4BACL,GAAG,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;yBACzB;qBACF;yBAAM;wBACL,GAAG,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;qBACzB;iBACF;gBACD,IAAI,EAAE,CAAC;aACR;YAAC,OAAO,GAAG,EAAE;gBACZ,IAAI,CAAC,GAAG,CAAC,CAAC;aACX;QACH,CAAC,CAAC;IACJ,CAAC;IACM,KAAK;QACV,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAtCC;IAAC,MAAM,CAAC,oBAAoB,CAAC;;qDACG;AAEhC;IAAC,UAAU,EAAE;8BACc,eAAe;uDAAC;AALhC,cAAc;IAD1B,UAAU,CAAC,gBAAgB,CAAC;GAChB,cAAc,CAuC1B;SAvCY,cAAc"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { BasePolicy } from '@spinajs/http';
|
|
2
|
-
import { TwoFactorAuthConfig } from '../interfaces';
|
|
2
|
+
import { TwoFactorAuthConfig } from '../interfaces.js';
|
|
3
3
|
export declare class TwoFacRouteEnabled extends BasePolicy {
|
|
4
4
|
protected TwoFactorConfig: TwoFactorAuthConfig;
|
|
5
5
|
isEnabled(): boolean;
|
|
6
6
|
execute(): Promise<void>;
|
|
7
7
|
}
|
|
8
|
+
//# sourceMappingURL=2FaPolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"2FaPolicy.d.ts","sourceRoot":"","sources":["../../src/policies/2FaPolicy.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD,qBAAa,kBAAmB,SAAQ,UAAU;IAEhD,SAAS,CAAC,eAAe,EAAE,mBAAmB,CAAC;IAExC,SAAS,IAAI,OAAO;IAGpB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAOhC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,25 +7,22 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const http_1 = require("@spinajs/http");
|
|
16
|
-
class TwoFacRouteEnabled extends http_1.BasePolicy {
|
|
10
|
+
import { InvalidOperation } from '../../../exceptions/lib/index.js';
|
|
11
|
+
import { Config } from '@spinajs/configuration';
|
|
12
|
+
import { BasePolicy } from '@spinajs/http';
|
|
13
|
+
export class TwoFacRouteEnabled extends BasePolicy {
|
|
17
14
|
isEnabled() {
|
|
18
15
|
return true;
|
|
19
16
|
}
|
|
20
17
|
execute() {
|
|
21
18
|
if (this.TwoFactorConfig.enabled === false) {
|
|
22
|
-
throw new
|
|
19
|
+
throw new InvalidOperation('2 factor auth is not enabled');
|
|
23
20
|
}
|
|
24
21
|
return Promise.resolve();
|
|
25
22
|
}
|
|
26
23
|
}
|
|
27
24
|
__decorate([
|
|
28
|
-
|
|
25
|
+
Config('rbac.twoFactorAuth'),
|
|
29
26
|
__metadata("design:type", Object)
|
|
30
27
|
], TwoFacRouteEnabled.prototype, "TwoFactorConfig", void 0);
|
|
31
|
-
exports.TwoFacRouteEnabled = TwoFacRouteEnabled;
|
|
32
28
|
//# sourceMappingURL=2FaPolicy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"2FaPolicy.js","sourceRoot":"","sources":["../../src/policies/2FaPolicy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"2FaPolicy.js","sourceRoot":"","sources":["../../src/policies/2FaPolicy.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,OAAO,kBAAmB,SAAQ,UAAU;IAIzC,SAAS;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IACM,OAAO;QACZ,IAAI,IAAI,CAAC,eAAe,CAAC,OAAO,KAAK,KAAK,EAAE;YAC1C,MAAM,IAAI,gBAAgB,CAAC,8BAA8B,CAAC,CAAC;SAC5D;QAED,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF;AAbC;IAAC,MAAM,CAAC,oBAAoB,CAAC;;2DACkB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoggedPolicy.d.ts","sourceRoot":"","sources":["../../src/policies/LoggedPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGrF;;;GAGG;AACH,qBAAa,YAAa,SAAQ,UAAU;IACnC,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,GAAG,OAAO;IAKrD,OAAO,CAAC,GAAG,EAAE,QAAQ;CAOnC"}
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.LoggedPolicy = void 0;
|
|
4
|
-
const http_1 = require("@spinajs/http");
|
|
5
|
-
const exceptions_1 = require("@spinajs/exceptions");
|
|
1
|
+
import { BasePolicy } from '@spinajs/http';
|
|
2
|
+
import { Forbidden } from '../../../exceptions/lib/index.js';
|
|
6
3
|
/**
|
|
7
4
|
* Simple policy to only check if user is authorized ( do not check permissions for routes)
|
|
8
5
|
* Usefull if we want to give acces for all logged users
|
|
9
6
|
*/
|
|
10
|
-
class LoggedPolicy extends
|
|
7
|
+
export class LoggedPolicy extends BasePolicy {
|
|
11
8
|
isEnabled(_action, _instance) {
|
|
12
9
|
// acl is always on if set
|
|
13
10
|
return true;
|
|
14
11
|
}
|
|
15
12
|
async execute(req) {
|
|
16
13
|
if (!req.storage || !req.storage.user || !req.storage.session.Data.get('Authorized')) {
|
|
17
|
-
throw new
|
|
14
|
+
throw new Forbidden('user not logged or session expired');
|
|
18
15
|
}
|
|
19
16
|
return Promise.resolve();
|
|
20
17
|
}
|
|
21
18
|
}
|
|
22
|
-
exports.LoggedPolicy = LoggedPolicy;
|
|
23
19
|
//# sourceMappingURL=LoggedPolicy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoggedPolicy.js","sourceRoot":"","sources":["../../src/policies/LoggedPolicy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LoggedPolicy.js","sourceRoot":"","sources":["../../src/policies/LoggedPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA4C,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,UAAU;IACnC,SAAS,CAAC,OAAe,EAAE,SAAsB;QACtD,0BAA0B;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,GAAa;QAChC,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;YACpF,MAAM,IAAI,SAAS,CAAC,oCAAoC,CAAC,CAAC;SAC3D;QAED,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotLoggedPolicy.d.ts","sourceRoot":"","sources":["../../src/policies/NotLoggedPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGrF;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,UAAU;IACtC,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,GAAG,OAAO;IAIrD,OAAO,CAAC,GAAG,EAAE,QAAQ;CAOnC"}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.NotLoggedPolicy = void 0;
|
|
4
|
-
const http_1 = require("@spinajs/http");
|
|
5
|
-
const exceptions_1 = require("@spinajs/exceptions");
|
|
1
|
+
import { BasePolicy } from '@spinajs/http';
|
|
2
|
+
import { InvalidOperation } from '../../../exceptions/lib/index.js';
|
|
6
3
|
/**
|
|
7
4
|
* Simple policy to only check if user is authorized ( do not check permissions for routes)
|
|
8
5
|
* Usefull if we want to give acces for all logged users
|
|
9
6
|
*/
|
|
10
|
-
class NotLoggedPolicy extends
|
|
7
|
+
export class NotLoggedPolicy extends BasePolicy {
|
|
11
8
|
isEnabled(_action, _instance) {
|
|
12
9
|
return true;
|
|
13
10
|
}
|
|
@@ -15,8 +12,7 @@ class NotLoggedPolicy extends http_1.BasePolicy {
|
|
|
15
12
|
if (!req.storage || !req.storage.user || !req.storage.session.Data.get('Authorized')) {
|
|
16
13
|
return Promise.resolve();
|
|
17
14
|
}
|
|
18
|
-
throw new
|
|
15
|
+
throw new InvalidOperation('Cannot perform action when user is logged.');
|
|
19
16
|
}
|
|
20
17
|
}
|
|
21
|
-
exports.NotLoggedPolicy = NotLoggedPolicy;
|
|
22
18
|
//# sourceMappingURL=NotLoggedPolicy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotLoggedPolicy.js","sourceRoot":"","sources":["../../src/policies/NotLoggedPolicy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NotLoggedPolicy.js","sourceRoot":"","sources":["../../src/policies/NotLoggedPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA4C,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ,UAAU;IACtC,SAAS,CAAC,OAAe,EAAE,SAAsB;QACtD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,GAAa;QAChC,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;YACpF,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC1B;QAED,MAAM,IAAI,gBAAgB,CAAC,4CAA4C,CAAC,CAAC;IAC3E,CAAC;CACF"}
|
|
@@ -13,3 +13,4 @@ export declare class RbacPolicy extends BasePolicy {
|
|
|
13
13
|
export declare function checkRbacPermission(role: string | string[], resource: string, permission: string): Permission;
|
|
14
14
|
export declare function checkUserPermission(user: User, resource: string, permission: string): Permission;
|
|
15
15
|
export declare function checkRoutePermission(req: sRequest, resource: string, permission: string): Permission;
|
|
16
|
+
//# sourceMappingURL=RbacPolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RbacPolicy.d.ts","sourceRoot":"","sources":["../../src/policies/RbacPolicy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AAKrF,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAErC;;GAEG;AACH,qBAAa,UAAW,SAAQ,UAAU;IACxC,SAAS,CAAC,EAAE,EAAE,aAAa,CAAC;;IAQrB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,GAAG,OAAO;IAKrD,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW;CAqB1E;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU,CAG7G;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU,CAQhG;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU,CAMpG"}
|
|
@@ -1,60 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const exceptions_1 = require("@spinajs/exceptions");
|
|
6
|
-
const decorators_1 = require("../decorators");
|
|
7
|
-
const di_1 = require("@spinajs/di");
|
|
1
|
+
import { BasePolicy } from '@spinajs/http';
|
|
2
|
+
import { Forbidden } from '@spinajs/exceptions';
|
|
3
|
+
import { ACL_CONTROLLER_DESCRIPTOR } from '../decorators.js';
|
|
4
|
+
import { DI } from '@spinajs/di';
|
|
8
5
|
/**
|
|
9
6
|
* Checks if user is logged, authorized & have proper permissions
|
|
10
7
|
*/
|
|
11
|
-
class RbacPolicy extends
|
|
8
|
+
export class RbacPolicy extends BasePolicy {
|
|
12
9
|
constructor() {
|
|
13
10
|
super();
|
|
14
|
-
this.Ac =
|
|
11
|
+
this.Ac = DI.get('AccessControl');
|
|
15
12
|
}
|
|
16
13
|
isEnabled(_action, _instance) {
|
|
17
14
|
// acl is always on if set
|
|
18
15
|
return true;
|
|
19
16
|
}
|
|
20
17
|
async execute(req, action, instance) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
let permission = (_a = descriptor.Permission) !== null && _a !== void 0 ? _a : '';
|
|
18
|
+
const descriptor = Reflect.getMetadata(ACL_CONTROLLER_DESCRIPTOR, instance);
|
|
19
|
+
let permission = descriptor.Permission ?? '';
|
|
24
20
|
// check if route has its own permission
|
|
25
21
|
if (descriptor.Routes.has(action.Method)) {
|
|
26
|
-
permission =
|
|
22
|
+
permission = descriptor.Routes.get(action.Method).Permission ?? '';
|
|
27
23
|
}
|
|
28
24
|
if (!descriptor || !descriptor.Permission) {
|
|
29
|
-
throw new
|
|
25
|
+
throw new Forbidden(`no route permission or resources assigned`);
|
|
30
26
|
}
|
|
31
27
|
if (!req.storage || !req.storage.user || !req.storage.session.Data.get('Authorized')) {
|
|
32
|
-
throw new
|
|
28
|
+
throw new Forbidden('user not logged or session expired');
|
|
33
29
|
}
|
|
34
30
|
if (!checkRoutePermission(req, descriptor.Resource, permission).granted) {
|
|
35
|
-
throw new
|
|
31
|
+
throw new Forbidden(`role(s) ${req.storage.user.Role} does not have permission ${permission} for resource ${descriptor.Resource}`);
|
|
36
32
|
}
|
|
37
33
|
}
|
|
38
34
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const ac = di_1.DI.get('AccessControl');
|
|
35
|
+
export function checkRbacPermission(role, resource, permission) {
|
|
36
|
+
const ac = DI.get('AccessControl');
|
|
42
37
|
return ac.can(role)[permission](resource);
|
|
43
38
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const ac = di_1.DI.get('AccessControl');
|
|
39
|
+
export function checkUserPermission(user, resource, permission) {
|
|
40
|
+
const ac = DI.get('AccessControl');
|
|
47
41
|
if (!user) {
|
|
48
42
|
return null;
|
|
49
43
|
}
|
|
50
44
|
return ac.can(user.Role)[permission](resource);
|
|
51
45
|
}
|
|
52
|
-
|
|
53
|
-
function checkRoutePermission(req, resource, permission) {
|
|
46
|
+
export function checkRoutePermission(req, resource, permission) {
|
|
54
47
|
if (!req.storage || !req.storage.user) {
|
|
55
48
|
return null;
|
|
56
49
|
}
|
|
57
50
|
return checkUserPermission(req.storage.user, resource, permission);
|
|
58
51
|
}
|
|
59
|
-
exports.checkRoutePermission = checkRoutePermission;
|
|
60
52
|
//# sourceMappingURL=RbacPolicy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RbacPolicy.js","sourceRoot":"","sources":["../../src/policies/RbacPolicy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RbacPolicy.js","sourceRoot":"","sources":["../../src/policies/RbacPolicy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAA4C,MAAM,eAAe,CAAC;AACrF,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAGjC;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,UAAU;IAGxC;QACE,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IACpC,CAAC;IAEM,SAAS,CAAC,OAAe,EAAE,SAAsB;QACtD,0BAA0B;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,GAAa,EAAE,MAAc,EAAE,QAAqB;QACvE,MAAM,UAAU,GAAoB,OAAO,CAAC,WAAW,CAAC,yBAAyB,EAAE,QAAQ,CAAC,CAAC;QAC7F,IAAI,UAAU,GAAG,UAAU,CAAC,UAAU,IAAI,EAAE,CAAC;QAE7C,wCAAwC;QACxC,IAAI,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;YACxC,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,IAAI,EAAE,CAAC;SACpE;QAED,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE;YACzC,MAAM,IAAI,SAAS,CAAC,2CAA2C,CAAC,CAAC;SAClE;QAED,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;YACpF,MAAM,IAAI,SAAS,CAAC,oCAAoC,CAAC,CAAC;SAC3D;QAED,IAAI,CAAC,oBAAoB,CAAC,GAAG,EAAE,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,OAAO,EAAE;YACvE,MAAM,IAAI,SAAS,CAAC,WAAW,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,6BAA6B,UAAU,iBAAiB,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;SACpI;IACH,CAAC;CACF;AAED,MAAM,UAAU,mBAAmB,CAAC,IAAuB,EAAE,QAAgB,EAAE,UAAkB;IAC/F,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAgB,eAAe,CAAC,CAAC;IAClD,OAAQ,EAAE,CAAC,GAAG,CAAC,IAAI,CAAS,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,IAAU,EAAE,QAAgB,EAAE,UAAkB;IAClF,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAgB,eAAe,CAAC,CAAC;IAElD,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,IAAI,CAAC;KACb;IAED,OAAQ,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAS,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,GAAa,EAAE,QAAgB,EAAE,UAAkB;IACtF,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE;QACrC,OAAO,IAAI,CAAC;KACb;IAED,OAAO,mBAAmB,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;AACrE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"captchaPolicy.d.ts","sourceRoot":"","sources":["../../src/policies/captchaPolicy.ts"],"names":[],"mappings":""}
|
package/lib/route-args.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare class UserArg extends RouteArgs {
|
|
|
4
4
|
get SupportedType(): ParameterType;
|
|
5
5
|
extract(callData: IRouteCall, _param: IRouteParameter, req: Request): Promise<{
|
|
6
6
|
CallData: IRouteCall;
|
|
7
|
-
Args: import("@spinajs/rbac
|
|
7
|
+
Args: import("@spinajs/rbac").User;
|
|
8
8
|
}>;
|
|
9
9
|
}
|
|
10
10
|
export declare class SessionArg extends RouteArgs {
|
|
@@ -14,3 +14,4 @@ export declare class SessionArg extends RouteArgs {
|
|
|
14
14
|
Args: unknown;
|
|
15
15
|
}>;
|
|
16
16
|
}
|
|
17
|
+
//# sourceMappingURL=route-args.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-args.d.ts","sourceRoot":"","sources":["../src/route-args.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEtF,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,qBACa,OAAQ,SAAQ,SAAS;IACpC,IAAW,aAAa,IAAI,aAAa,CAExC;IAEY,OAAO,CAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,EAAE,OAAO;;;;CAGjF;AAED,qBACa,UAAW,SAAQ,SAAS;IACvC,IAAI,aAAa,IAAI,MAAM,CAE1B;IACY,OAAO,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,OAAO;;;;CAGhF"}
|
package/lib/route-args.js
CHANGED
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
4
|
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
6
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const di_1 = require("@spinajs/di");
|
|
12
|
-
let UserArg = class UserArg extends http_1.RouteArgs {
|
|
7
|
+
import { RouteArgs, ParameterType } from '@spinajs/http';
|
|
8
|
+
import { Injectable } from '@spinajs/di';
|
|
9
|
+
let UserArg = class UserArg extends RouteArgs {
|
|
13
10
|
get SupportedType() {
|
|
14
|
-
return
|
|
11
|
+
return ParameterType.Other;
|
|
15
12
|
}
|
|
16
13
|
async extract(callData, _param, req) {
|
|
17
14
|
return { CallData: callData, Args: req.storage.user };
|
|
18
15
|
}
|
|
19
16
|
};
|
|
20
17
|
UserArg = __decorate([
|
|
21
|
-
|
|
18
|
+
Injectable()
|
|
22
19
|
], UserArg);
|
|
23
|
-
|
|
24
|
-
let SessionArg = class SessionArg extends
|
|
20
|
+
export { UserArg };
|
|
21
|
+
let SessionArg = class SessionArg extends RouteArgs {
|
|
25
22
|
get SupportedType() {
|
|
26
23
|
throw new Error('Method not implemented.');
|
|
27
24
|
}
|
|
@@ -30,7 +27,7 @@ let SessionArg = class SessionArg extends http_1.RouteArgs {
|
|
|
30
27
|
}
|
|
31
28
|
};
|
|
32
29
|
SessionArg = __decorate([
|
|
33
|
-
|
|
30
|
+
Injectable()
|
|
34
31
|
], SessionArg);
|
|
35
|
-
|
|
32
|
+
export { SessionArg };
|
|
36
33
|
//# sourceMappingURL=route-args.js.map
|
package/lib/route-args.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-args.js","sourceRoot":"","sources":["../src/route-args.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"route-args.js","sourceRoot":"","sources":["../src/route-args.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,SAAS,EAAmB,aAAa,EAAc,MAAM,eAAe,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIlC,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,SAAS;IACpC,IAAW,aAAa;QACtB,OAAO,aAAa,CAAC,KAAK,CAAC;IAC7B,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,QAAoB,EAAE,MAAuB,EAAE,GAAY;QAC9E,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IACxD,CAAC;CACF,CAAA;AARY,OAAO;IADnB,UAAU,EAAE;GACA,OAAO,CAQnB;SARY,OAAO;AAWb,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,SAAS;IACvC,IAAI,aAAa;QACf,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IACM,KAAK,CAAC,OAAO,CAAC,QAAoB,EAAE,KAAsB,EAAE,GAAY;QAC7E,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;IAClH,CAAC;CACF,CAAA;AAPY,UAAU;IADtB,UAAU,EAAE;GACA,UAAU,CAOtB;SAPY,UAAU"}
|
package/lib/transformers.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transformers.d.ts","sourceRoot":"","sources":["../src/transformers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGhD,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qBACa,mBAAmB,CAAC,CAAC,CAAE,SAAQ,eAAe,CAAC,WAAW,EAAE,WAAW,GAAG,CAAC,CAAC;IACvF,IAAI,IAAI,IAAI,MAAM,CAEjB;IAEM,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,CAAC,OAAO,GAAG,WAAW,GAAG,CAAC;CAShF"}
|
package/lib/transformers.js
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
4
|
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
6
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
exports.UserDataTransformer = void 0;
|
|
13
|
-
const http_1 = require("@spinajs/http");
|
|
14
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
15
|
-
const di_1 = require("@spinajs/di");
|
|
16
|
-
let UserDataTransformer = class UserDataTransformer extends http_1.DataTransformer {
|
|
7
|
+
import { DataTransformer } from '@spinajs/http';
|
|
8
|
+
import _ from 'lodash';
|
|
9
|
+
import { Injectable } from '@spinajs/di';
|
|
10
|
+
let UserDataTransformer = class UserDataTransformer extends DataTransformer {
|
|
17
11
|
get Type() {
|
|
18
12
|
return 'user-model-result';
|
|
19
13
|
}
|
|
20
14
|
transform(data, _request) {
|
|
21
|
-
if (
|
|
15
|
+
if (_.isArray(data.Data)) {
|
|
22
16
|
data.Data.forEach((x) => delete x.Password);
|
|
23
17
|
}
|
|
24
18
|
else {
|
|
@@ -28,7 +22,7 @@ let UserDataTransformer = class UserDataTransformer extends http_1.DataTransform
|
|
|
28
22
|
}
|
|
29
23
|
};
|
|
30
24
|
UserDataTransformer = __decorate([
|
|
31
|
-
|
|
25
|
+
Injectable()
|
|
32
26
|
], UserDataTransformer);
|
|
33
|
-
|
|
27
|
+
export { UserDataTransformer };
|
|
34
28
|
//# sourceMappingURL=transformers.js.map
|
package/lib/transformers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformers.js","sourceRoot":"","sources":["../src/transformers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transformers.js","sourceRoot":"","sources":["../src/transformers.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AASlC,IAAM,mBAAmB,GAAzB,MAAM,mBAAuB,SAAQ,eAA6C;IACvF,IAAI,IAAI;QACN,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAEM,SAAS,CAAC,IAAiB,EAAE,QAAyB;QAC3D,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACxB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC;SAC7C;aAAM;YACL,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;SAC3B;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAdY,mBAAmB;IAD/B,UAAU,EAAE;GACA,mBAAmB,CAc/B;SAdY,mBAAmB"}
|