blixify-server 0.1.2 → 0.1.3

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.
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Security for our server
3
+ * 1. Add Admin Token
4
+ * 2. Add CORS Policy - Protect web browser
5
+ * 3. Basic helmet security configurations
6
+ * 4. Prevent DDOS from rate limiting
7
+ */
8
+ export default class SecurityMiddleware {
9
+ checkAuthentication: (token: string) => string;
10
+ checkRole: (userId: string) => string;
11
+ checkAPIToken: (apiToken: string) => boolean;
12
+ constructor(checkAuthentication: (token: string) => string, checkRole: (userId: string) => string, checkAPIToken: (apiToken: string) => boolean);
13
+ /**
14
+ * 1. Check User Authentication
15
+ * 2. Check User Role
16
+ * 3. Check API Token
17
+ */
18
+ init(): (req: any, res: any, next: any) => Promise<void>;
19
+ }
20
+ //# sourceMappingURL=security.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"security.d.ts","sourceRoot":"","sources":["../../src/apis/security.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,kBAAkB;IAErC,mBAAmB,UAAW,MAAM,YAElC;IACF,SAAS,WAAY,MAAM,YAEzB;IACF,aAAa,aAAc,MAAM,aAE/B;gBAIA,mBAAmB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,EAC9C,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,EACrC,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO;IAO9C;;;;OAIG;IACH,IAAI,UAG8C,GAAG,OAAO,GAAG,QAAQ,GAAG;CA2B3E"}
@@ -0,0 +1 @@
1
+ "use strict";var __awaiter=this&&this.__awaiter||function(e,r,u,a){return new(u=u||Promise)(function(o,t){function n(e){try{c(a.next(e))}catch(e){t(e)}}function i(e){try{c(a.throw(e))}catch(e){t(e)}}function c(e){var t;e.done?o(e.value):((t=e.value)instanceof u?t:new u(function(e){e(t)})).then(n,i)}c((a=a.apply(e,r||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0});class SecurityMiddleware{constructor(e,t,o){this.checkAuthentication=e=>"",this.checkRole=e=>"",this.checkAPIToken=e=>!1,this.checkAuthentication=e,this.checkRole=t,this.checkAPIToken=o}init(){const n=this;return function(t,e,o){return __awaiter(this,void 0,void 0,function*(){var e;delete t.body.bm_userId,delete t.body.bm_userRole,delete t.body.bm_apiToken,t.body.userToken&&(e=n.checkAuthentication(t.body.userToken))&&(t.body.bm_userId=e,e=n.checkRole(e))&&(t.body.bm_userRole=e),t.body.apiToken&&(e=t.body.apiToken,e=n.checkAPIToken(e),t.body.bm_apiToken=e),o()})}}}exports.default=SecurityMiddleware;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blixify-server",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "license": "MIT",
5
5
  "main": "dist/apis/index.js",
6
6
  "private": false,