chyz 2.0.0-rc.34 → 2.0.0-rc.37
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/BaseChyz.d.ts +1 -1
- package/BaseChyz.d.ts.map +1 -1
- package/BaseChyz.js +20 -11
- package/base/BaseError.d.ts +3 -1
- package/base/BaseError.d.ts.map +1 -1
- package/base/BaseError.js +2 -1
- package/base/DataErrorDbException.d.ts +2 -2
- package/base/DataErrorDbException.d.ts.map +1 -1
- package/base/ForbiddenHttpException.d.ts +1 -1
- package/base/ForbiddenHttpException.d.ts.map +1 -1
- package/base/InvalidArgumentException.d.ts +2 -2
- package/base/InvalidArgumentException.d.ts.map +1 -1
- package/base/InvalidConfigException.d.ts +2 -2
- package/base/InvalidConfigException.d.ts.map +1 -1
- package/base/Model.d.ts +3 -0
- package/base/Model.d.ts.map +1 -1
- package/base/Model.js +1 -0
- package/base/NotFoundHttpException.d.ts +2 -2
- package/base/NotFoundHttpException.d.ts.map +1 -1
- package/base/UnauthorizedHttpException.d.ts +2 -2
- package/base/UnauthorizedHttpException.d.ts.map +1 -1
- package/base/ValidationHttpException.d.ts +2 -2
- package/base/ValidationHttpException.d.ts.map +1 -1
- package/filters/auth/HttpBasicAuth.d.ts +1 -0
- package/filters/auth/HttpBasicAuth.d.ts.map +1 -1
- package/filters/auth/HttpBasicAuth.js +13 -7
- package/index.d.ts +8 -2
- package/index.d.ts.map +1 -1
- package/index.js +9 -0
- package/package.json +1 -1
- package/rbac/index.d.ts +5 -0
- package/rbac/index.d.ts.map +1 -0
- package/rbac/index.js +28 -0
- package/requiments/Utils.d.ts +0 -7
- package/requiments/Utils.d.ts.map +1 -1
- package/requiments/Utils.js +2 -12
- package/web/IdentityInterface.d.ts +1 -0
- package/web/IdentityInterface.d.ts.map +1 -1
package/BaseChyz.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export default class BaseChyz {
|
|
|
43
43
|
static error(...args: any[]): void;
|
|
44
44
|
static fatal(...args: any[]): void;
|
|
45
45
|
static warning(...args: any[]): void;
|
|
46
|
-
static t(text: string): string;
|
|
46
|
+
static t(text: string, params?: any): string | undefined;
|
|
47
47
|
errorLogger(error: any, req: any, res: any, next: any): void;
|
|
48
48
|
errorResponder(error: any, req: any, res: any, next: any): void;
|
|
49
49
|
errorHandler(err: any, req: any, res: any, next: any): any;
|
package/BaseChyz.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseChyz.d.ts","sourceRoot":"","sources":["../src/BaseChyz.ts"],"names":[],"mappings":"AAcA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"BaseChyz.d.ts","sourceRoot":"","sources":["../src/BaseChyz.ts"],"names":[],"mappings":"AAcA,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAC;AAkHjC,MAAM,CAAC,OAAO,OAAO,QAAQ;IACzB,OAAO,CAAC,MAAM,CAAuB;IACrC,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC;IACvB,MAAM,CAAC,SAAS,EAAE,GAAG,CAAS;IAC9B,OAAO,CAAC,KAAK,CAAgB;IAC7B,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC;IACf,MAAM,CAAC,IAAI,EAAE,GAAG,CAAS;IACzB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACnB,MAAM,CAAC,IAAI,EAAE,IAAI,CAAE;IACnB,OAAO,CAAC,MAAM,CAAC,SAAS,CAAiB;IACzC,OAAO,CAAC,eAAe,CAAwB;IAC/C,OAAO,CAAC,MAAM,CAAC,WAAW,CAA4B;IACtD,OAAc,UAAU,EAAE,GAAG,CAAK;IAClC,OAAc,WAAW,EAAE,GAAG,CAAK;IACnC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAU;IAGtC,MAAM,KAAK,YAAY,IAAI,GAAG,CAE7B;IAED,MAAM,KAAK,YAAY,CAAC,KAAK,EAAE,GAAG,EAEj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cAAc;IA4Eb,UAAU;IAwDV,KAAK;CA2Bf"}
|
package/BaseChyz.js
CHANGED
|
@@ -47,10 +47,12 @@ const fs = require("fs");
|
|
|
47
47
|
* Freamwork
|
|
48
48
|
*/
|
|
49
49
|
const base_1 = require("./base");
|
|
50
|
-
const Utils_1 =
|
|
50
|
+
const Utils_1 = require("./requiments/Utils");
|
|
51
51
|
const Logs_1 = require("./base/Logs");
|
|
52
52
|
const CEvents_1 = require("./base/CEvents");
|
|
53
|
-
const
|
|
53
|
+
const http_request = require('debug')('http:request');
|
|
54
|
+
const http_request_body = http_request.extend('body');
|
|
55
|
+
const http_request_headers = http_request.extend('headers');
|
|
54
56
|
const compression = require('compression');
|
|
55
57
|
// const fs = require('fs');
|
|
56
58
|
const ip = require('ip');
|
|
@@ -279,8 +281,15 @@ class BaseChyz {
|
|
|
279
281
|
static warning(...args) {
|
|
280
282
|
BaseChyz.logs.warn(...arguments);
|
|
281
283
|
}
|
|
282
|
-
static t(text) {
|
|
283
|
-
|
|
284
|
+
static t(text, params) {
|
|
285
|
+
if (text == "")
|
|
286
|
+
return;
|
|
287
|
+
// let lang = require("@root/locales/tr/translation.json");
|
|
288
|
+
let lang = {};
|
|
289
|
+
if (lang.hasOwnProperty(text)) {
|
|
290
|
+
text = lang[text];
|
|
291
|
+
}
|
|
292
|
+
return text.tokenReplace(params);
|
|
284
293
|
}
|
|
285
294
|
errorLogger(error, req, res, next) {
|
|
286
295
|
BaseChyz.error(error);
|
|
@@ -351,16 +360,14 @@ class BaseChyz {
|
|
|
351
360
|
controller = controller.default;
|
|
352
361
|
}
|
|
353
362
|
else {
|
|
354
|
-
throw new base_1.InvalidConfigException(
|
|
363
|
+
throw new base_1.InvalidConfigException(BaseChyz.t("Invalid Controller"));
|
|
355
364
|
}
|
|
356
365
|
// This is our instantiated class
|
|
357
366
|
const instance = new controller();
|
|
358
367
|
BaseChyz.controllers.push(instance);
|
|
359
368
|
// The prefix saved to our controller
|
|
360
|
-
// @ts-ignore
|
|
361
369
|
const prefix = Reflect.getMetadata('prefix', controller);
|
|
362
370
|
// Our `routes` array containing all our routes for this controller
|
|
363
|
-
// @ts-ignore
|
|
364
371
|
const routes = Reflect.getMetadata('routes', controller);
|
|
365
372
|
BaseChyz.debug("Controller load ", controller.name, `(${prefix})`);
|
|
366
373
|
if (routes) {
|
|
@@ -372,13 +379,15 @@ class BaseChyz {
|
|
|
372
379
|
try {
|
|
373
380
|
BaseChyz.debug(`Call Request id ${actionId}`);
|
|
374
381
|
http_request_body("Request body " + JSON.stringify(req.body));
|
|
382
|
+
http_request_headers("Request header " + JSON.stringify(req.headers));
|
|
375
383
|
yield instance.beforeAction(route, req, res);
|
|
376
384
|
next();
|
|
377
385
|
}
|
|
378
386
|
catch (e) {
|
|
379
387
|
BaseChyz.error(e);
|
|
380
388
|
res.status(e.statusCode || 500);
|
|
381
|
-
res.json({
|
|
389
|
+
// res.json({error: {code: e.statusCode || 500, name: e.name, message: e.message}})
|
|
390
|
+
res.json(e.toJSON());
|
|
382
391
|
// next(e)
|
|
383
392
|
}
|
|
384
393
|
}), (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -395,7 +404,7 @@ class BaseChyz {
|
|
|
395
404
|
// @ts-ignore
|
|
396
405
|
res.status(e.statusCode || 500);
|
|
397
406
|
// @ts-ignore
|
|
398
|
-
res.json(
|
|
407
|
+
res.json(e.toJSON());
|
|
399
408
|
}
|
|
400
409
|
else {
|
|
401
410
|
res.json(e);
|
|
@@ -408,6 +417,7 @@ class BaseChyz {
|
|
|
408
417
|
});
|
|
409
418
|
}
|
|
410
419
|
middleware() {
|
|
420
|
+
var _a;
|
|
411
421
|
BaseChyz.propvider.use(bodyParser.json({ limit: '1mb' }));
|
|
412
422
|
BaseChyz.propvider.use(bodyParser.urlencoded({ limit: '1mb', extended: true })); // support encoded bodies
|
|
413
423
|
BaseChyz.propvider.use(methodOverride());
|
|
@@ -443,7 +453,7 @@ class BaseChyz {
|
|
|
443
453
|
}
|
|
444
454
|
//Middlewares
|
|
445
455
|
for (const middleware1 of Object.keys(BaseChyz.middlewares)) {
|
|
446
|
-
if (
|
|
456
|
+
if ((_a = BaseChyz.middlewares[middleware1]) === null || _a === void 0 ? void 0 : _a.keycloak) {
|
|
447
457
|
let keycloak = BaseChyz.middlewares[middleware1].keycloak;
|
|
448
458
|
BaseChyz.propvider.use(keycloak.middleware(BaseChyz.middlewares[middleware1].config));
|
|
449
459
|
}
|
|
@@ -484,7 +494,6 @@ class BaseChyz {
|
|
|
484
494
|
}
|
|
485
495
|
BaseChyz.propvider = Server;
|
|
486
496
|
BaseChyz.date = dayjs;
|
|
487
|
-
BaseChyz.logs = new Logs_1.Logs();
|
|
488
497
|
BaseChyz._validate = validate;
|
|
489
498
|
BaseChyz.controllers = [];
|
|
490
499
|
BaseChyz.components = {};
|
package/base/BaseError.d.ts
CHANGED
|
@@ -21,9 +21,11 @@
|
|
|
21
21
|
*/
|
|
22
22
|
export declare class BaseError extends Error {
|
|
23
23
|
private statusCode;
|
|
24
|
-
|
|
24
|
+
private success;
|
|
25
|
+
constructor(message: any, statusCode?: number);
|
|
25
26
|
toString(): string;
|
|
26
27
|
toJSON(): {
|
|
28
|
+
success: boolean;
|
|
27
29
|
code: number;
|
|
28
30
|
name: string;
|
|
29
31
|
message: string;
|
package/base/BaseError.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseError.d.ts","sourceRoot":"","sources":["../../src/base/BaseError.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAChC,OAAO,CAAC,UAAU,CAAS;
|
|
1
|
+
{"version":3,"file":"BaseError.d.ts","sourceRoot":"","sources":["../../src/base/BaseError.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAChC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,OAAO,CAAU;gBAEb,OAAO,EAAE,GAAG,EAAE,UAAU,SAAM;IAS1C,QAAQ;IAIR,MAAM;;;;;;CAGT"}
|
package/base/BaseError.js
CHANGED
|
@@ -32,6 +32,7 @@ const Utils_1 = require("../requiments/Utils");
|
|
|
32
32
|
class BaseError extends Error {
|
|
33
33
|
constructor(message, statusCode = 500) {
|
|
34
34
|
super(message);
|
|
35
|
+
this.success = false;
|
|
35
36
|
this.message = Utils_1.Utils.isString(message) ? message : JSON.stringify(message);
|
|
36
37
|
this.name = this.constructor.name; // good practice
|
|
37
38
|
this.statusCode = statusCode; // error code for responding to client
|
|
@@ -41,7 +42,7 @@ class BaseError extends Error {
|
|
|
41
42
|
return `${this.name}[${this.statusCode}] ${this.message}`;
|
|
42
43
|
}
|
|
43
44
|
toJSON() {
|
|
44
|
-
return { code: this === null || this === void 0 ? void 0 : this.statusCode, name: this.name, message: this.message };
|
|
45
|
+
return { success: this.success, code: this === null || this === void 0 ? void 0 : this.statusCode, name: this.name, message: this.message };
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
exports.BaseError = BaseError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataErrorDbException.d.ts","sourceRoot":"","sources":["../../src/base/DataErrorDbException.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,qBAAa,oBAAqB,SAAQ,SAAS;IAC1B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"DataErrorDbException.d.ts","sourceRoot":"","sources":["../../src/base/DataErrorDbException.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,qBAAa,oBAAqB,SAAQ,SAAS;IAC1B,OAAO,EAAE,GAAG;gBAAZ,OAAO,EAAE,GAAG;CAGpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ForbiddenHttpException.d.ts","sourceRoot":"","sources":["../../src/base/ForbiddenHttpException.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,qBAAa,sBAAuB,SAAQ,SAAS;gBACnC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ForbiddenHttpException.d.ts","sourceRoot":"","sources":["../../src/base/ForbiddenHttpException.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,qBAAa,sBAAuB,SAAQ,SAAS;gBACnC,OAAO,EAAE,GAAG;CAG7B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvalidArgumentException.d.ts","sourceRoot":"","sources":["../../src/base/InvalidArgumentException.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,qBAAa,wBAAyB,SAAQ,SAAS;IAC9B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"InvalidArgumentException.d.ts","sourceRoot":"","sources":["../../src/base/InvalidArgumentException.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,qBAAa,wBAAyB,SAAQ,SAAS;IAC9B,OAAO,EAAE,GAAG;gBAAZ,OAAO,EAAE,GAAG;CAGpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InvalidConfigException.d.ts","sourceRoot":"","sources":["../../src/base/InvalidConfigException.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,qBAAa,sBAAuB,SAAQ,SAAS;IAC5B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"InvalidConfigException.d.ts","sourceRoot":"","sources":["../../src/base/InvalidConfigException.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,qBAAa,sBAAuB,SAAQ,SAAS;IAC5B,OAAO,EAAE,GAAG;gBAAZ,OAAO,EAAE,GAAG;CAGpC"}
|
package/base/Model.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Component } from "./Component";
|
|
|
2
2
|
import { Model as SModel } from "sequelize";
|
|
3
3
|
export { DataTypes, NOW } from "sequelize";
|
|
4
4
|
export interface Relation {
|
|
5
|
+
[key: string]: any;
|
|
5
6
|
type: "hasOne" | "hasMany" | "belongsToMany" | "belongsTo";
|
|
6
7
|
allowNull?: boolean;
|
|
7
8
|
sourceKey?: string;
|
|
@@ -11,6 +12,7 @@ export interface Relation {
|
|
|
11
12
|
through?: any;
|
|
12
13
|
as?: string;
|
|
13
14
|
on?: any;
|
|
15
|
+
scope?: any;
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
16
18
|
* ValidateMe.init({
|
|
@@ -261,6 +263,7 @@ export declare class Model extends Component {
|
|
|
261
263
|
* }
|
|
262
264
|
* );``
|
|
263
265
|
* @param query
|
|
266
|
+
* @param options
|
|
264
267
|
*/
|
|
265
268
|
rawQuery(query: string, options?: any): Promise<any>;
|
|
266
269
|
/**
|
package/base/Model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Model.d.ts","sourceRoot":"","sources":["../../src/base/Model.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAqE,KAAK,IAAI,MAAM,EAAoE,MAAM,WAAW,CAAC;AAGjL,OAAO,EAAC,SAAS,EAAE,GAAG,EAAC,MAAM,WAAW,CAAC;AAGzC,MAAM,WAAW,QAAQ;IACrB,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,eAAe,GAAG,WAAW,CAAC;IAC3D,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,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oundHttpException.d.ts","sourceRoot":"","sources":["../../src/base/NotFoundHttpException.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,qBAAa,qBAAsB,SAAQ,SAAS;IAC3B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"NotFoundHttpException.d.ts","sourceRoot":"","sources":["../../src/base/NotFoundHttpException.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,qBAAa,qBAAsB,SAAQ,SAAS;IAC3B,OAAO,EAAE,GAAG;gBAAZ,OAAO,EAAE,GAAG;CAGpC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseError } from "./BaseError";
|
|
2
2
|
export declare class UnauthorizedHttpException extends BaseError {
|
|
3
|
-
message:
|
|
4
|
-
constructor(message:
|
|
3
|
+
message: any;
|
|
4
|
+
constructor(message: any);
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=UnauthorizedHttpException.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnauthorizedHttpException.d.ts","sourceRoot":"","sources":["../../src/base/UnauthorizedHttpException.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,qBAAa,yBAA0B,SAAQ,SAAS;IAC/B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"UnauthorizedHttpException.d.ts","sourceRoot":"","sources":["../../src/base/UnauthorizedHttpException.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,qBAAa,yBAA0B,SAAQ,SAAS;IAC/B,OAAO,EAAE,GAAG;gBAAZ,OAAO,EAAE,GAAG;CAIpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationHttpException.d.ts","sourceRoot":"","sources":["../../src/base/ValidationHttpException.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,qBAAa,uBAAwB,SAAQ,SAAS;IAC7B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ValidationHttpException.d.ts","sourceRoot":"","sources":["../../src/base/ValidationHttpException.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC,qBAAa,uBAAwB,SAAQ,SAAS;IAC7B,OAAO,EAAE,GAAG;gBAAZ,OAAO,EAAE,GAAG;CAGpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpBasicAuth.d.ts","sourceRoot":"","sources":["../../../src/filters/auth/HttpBasicAuth.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAIxC,qBAAa,aAAc,SAAQ,UAAU;IAEzC;;OAEG;IACI,MAAM,SAAmB;IAGhC;;OAEG;IAEI,OAAO,SAAqB;
|
|
1
|
+
{"version":3,"file":"HttpBasicAuth.d.ts","sourceRoot":"","sources":["../../../src/filters/auth/HttpBasicAuth.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAIxC,qBAAa,aAAc,SAAQ,UAAU;IAEzC;;OAEG;IACI,MAAM,SAAmB;IAGhC;;OAEG;IAEI,OAAO,SAAqB;IAG5B,IAAI,EAAE,GAAG,CAAQ;IAExB;;OAEG;IACI,IAAI,IAAI,IAAI;IAWb,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ;IA2BtE;;OAEG;IACI,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAIxC"}
|
|
@@ -33,6 +33,7 @@ class HttpBasicAuth extends AuthMethod_1.AuthMethod {
|
|
|
33
33
|
* @var string a pattern to use to extract the HTTP authentication value
|
|
34
34
|
*/
|
|
35
35
|
this.pattern = /^Basic\s+(.*?)$/;
|
|
36
|
+
this.auth = null;
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
38
39
|
* @throws InvalidConfigException
|
|
@@ -46,19 +47,24 @@ class HttpBasicAuth extends AuthMethod_1.AuthMethod {
|
|
|
46
47
|
this.user = (_a = BaseChyz_1.default.getComponent("user")) !== null && _a !== void 0 ? _a : null;
|
|
47
48
|
}
|
|
48
49
|
authenticate(user, request, response) {
|
|
49
|
-
return __awaiter(this,
|
|
50
|
+
return __awaiter(this, arguments, void 0, function* () {
|
|
50
51
|
let autHeader = this.getHeaderByKey(request.headers, this.header);
|
|
51
52
|
if (autHeader == null || (autHeader = this.patternCheck(autHeader, this.pattern)) == null) {
|
|
52
53
|
return null;
|
|
53
54
|
}
|
|
54
|
-
let
|
|
55
|
-
let
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
let identity = null;
|
|
56
|
+
let token = null;
|
|
57
|
+
let buff = new Buffer(autHeader[1], "base64");
|
|
58
|
+
let basicauth = buff.toString().split(":");
|
|
59
|
+
if (this.auth != null) {
|
|
60
|
+
identity = yield this.auth(autHeader[1], ...arguments, basicauth);
|
|
59
61
|
}
|
|
62
|
+
else {
|
|
63
|
+
identity = yield user.loginByAccessToken(basicauth, "HttpBasicAuth");
|
|
64
|
+
}
|
|
65
|
+
if (identity == null)
|
|
66
|
+
this.fail(response);
|
|
60
67
|
return identity;
|
|
61
|
-
return null;
|
|
62
68
|
});
|
|
63
69
|
}
|
|
64
70
|
/**
|
package/index.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface String {
|
|
3
|
+
tokenReplace(obj: any): string;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
import BaseChyz from "./BaseChyz";
|
|
7
|
+
import { RestClient } from "./base";
|
|
1
8
|
declare module "express-serve-static-core" {
|
|
2
9
|
interface Request {
|
|
3
10
|
identity: any;
|
|
4
11
|
}
|
|
5
12
|
}
|
|
6
|
-
import BaseChyz from "./BaseChyz";
|
|
7
|
-
import { RestClient } from "./base";
|
|
8
13
|
/**
|
|
9
14
|
*
|
|
10
15
|
*/
|
|
@@ -16,6 +21,7 @@ export { BaseChyz, RestClient };
|
|
|
16
21
|
export { Logs, ActionFilter, BaseError, Behavior, Component, Configurable, CWebController, DbConnection, ForbiddenHttpException, InvalidConfigException, InvalidArgumentException, NotFoundHttpException, UnauthorizedHttpException, DataErrorDbException, ValidationHttpException, Model, ModelManager, CEvents } from "./base";
|
|
17
22
|
export * from "./filters";
|
|
18
23
|
export * from "./filters/auth";
|
|
24
|
+
export * from "./rbac/";
|
|
19
25
|
export * from "./decorator";
|
|
20
26
|
export * from "./requiments/Utils";
|
|
21
27
|
export default Chyz;
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAAC;KAClC;CACJ;AAQD,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,EAAC,UAAU,EAAC,MAAM,QAAQ,CAAC;AAElC,OAAO,QAAQ,2BAA2B,CAAC;IACvC,UAAU,OAAO;QACb,QAAQ,EAAE,GAAG,CAAC;KACjB;CACJ;AAYD;;GAEG;AACH,QAAA,MAAM,IAAI,UAAiB,CAAC;AAC5B,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AACtC,OAAO,EAAC,QAAQ,EAAE,UAAU,EAAC,CAAA;AAC7B,OAAO,EACH,IAAI,EACJ,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,uBAAuB,EACvB,KAAK,EACL,YAAY,EACZ,OAAO,EACV,MAAM,QAAQ,CAAC;AAChB,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,SAAS,CAAC;AAExB,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AAEnC,eAAe,IAAI,CAAC"}
|
package/index.js
CHANGED
|
@@ -30,6 +30,14 @@ const BaseChyz_1 = __importDefault(require("./BaseChyz"));
|
|
|
30
30
|
exports.BaseChyz = BaseChyz_1.default;
|
|
31
31
|
const base_1 = require("./base");
|
|
32
32
|
Object.defineProperty(exports, "RestClient", { enumerable: true, get: function () { return base_1.RestClient; } });
|
|
33
|
+
String.prototype.tokenReplace = function (obj) {
|
|
34
|
+
let retStr = this;
|
|
35
|
+
for (let x in obj) {
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
retStr = retStr.replace(new RegExp("\\:" + x, 'g'), obj[x]).toString();
|
|
38
|
+
}
|
|
39
|
+
return retStr;
|
|
40
|
+
};
|
|
33
41
|
/**
|
|
34
42
|
*
|
|
35
43
|
*/
|
|
@@ -56,6 +64,7 @@ Object.defineProperty(exports, "ModelManager", { enumerable: true, get: function
|
|
|
56
64
|
Object.defineProperty(exports, "CEvents", { enumerable: true, get: function () { return base_2.CEvents; } });
|
|
57
65
|
__exportStar(require("./filters"), exports);
|
|
58
66
|
__exportStar(require("./filters/auth"), exports);
|
|
67
|
+
__exportStar(require("./rbac/"), exports);
|
|
59
68
|
__exportStar(require("./decorator"), exports);
|
|
60
69
|
__exportStar(require("./requiments/Utils"), exports);
|
|
61
70
|
exports.default = Chyz;
|
package/package.json
CHANGED
package/rbac/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rbac/index.ts"],"names":[],"mappings":"AAQA,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
|
package/rbac/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
/*
|
|
18
|
+
*
|
|
19
|
+
* Copyright (c) 2023.. Chy Bilgisayar Bilisim
|
|
20
|
+
* Author: Cihan Ozturk
|
|
21
|
+
* E-mail: cihan@chy.com.tr
|
|
22
|
+
* Github:https://github.com/cihan53/
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
__exportStar(require("./AuthManager"), exports);
|
|
26
|
+
__exportStar(require("./AuthItem"), exports);
|
|
27
|
+
__exportStar(require("./AuthAssignment"), exports);
|
|
28
|
+
__exportStar(require("./AuthItemChild"), exports);
|
package/requiments/Utils.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../src/requiments/Utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../../src/requiments/Utils.ts"],"names":[],"mappings":"AA+GA,eAAO,MAAM,KAAK,KAQjB,CAAA"}
|
package/requiments/Utils.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
// import _ from "lodash";
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.
|
|
10
|
+
exports.Utils = void 0;
|
|
11
11
|
const _ = require('lodash');
|
|
12
12
|
/**
|
|
13
13
|
*
|
|
@@ -96,14 +96,6 @@ function wildTest(wildcard, str) {
|
|
|
96
96
|
const matchWildcard = (pattern, string, options = {}) => {
|
|
97
97
|
return wildTest(pattern, string);
|
|
98
98
|
};
|
|
99
|
-
/**
|
|
100
|
-
*
|
|
101
|
-
* @param text
|
|
102
|
-
*/
|
|
103
|
-
const t = function (text) {
|
|
104
|
-
return text;
|
|
105
|
-
};
|
|
106
|
-
exports.t = t;
|
|
107
99
|
/**
|
|
108
100
|
* random string genrate
|
|
109
101
|
* @param length
|
|
@@ -120,6 +112,4 @@ exports.Utils = Object.assign({ findKeyValue,
|
|
|
120
112
|
sleep,
|
|
121
113
|
matchWildcard,
|
|
122
114
|
toQuery,
|
|
123
|
-
generateRandomString,
|
|
124
|
-
t }, _);
|
|
125
|
-
exports.default = t;
|
|
115
|
+
generateRandomString }, _);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdentityInterface.d.ts","sourceRoot":"","sources":["../../src/web/IdentityInterface.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,iBAAiB;IAC9B;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,GAAG,CAAA;IAE7B
|
|
1
|
+
{"version":3,"file":"IdentityInterface.d.ts","sourceRoot":"","sources":["../../src/web/IdentityInterface.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,iBAAiB;IAC9B;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,GAAG,CAAA;IAE7B;;;;;;;;;OASG;IACH,yBAAyB,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC;IAEzD;;;OAGG;IACH,KAAK,IAAI,MAAM,CAAC;IAEhB;;;;;;;;;;;;;;;OAeG;IACH,UAAU,IAAI,MAAM,CAAC;IAErB;;;;;;OAMG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAGnD;;OAEG;IACH,GAAG,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,YAAY,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC;CAEhG"}
|