@nitra/cf-security 1.0.6 → 3.0.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/README.md +18 -1
- package/package.json +9 -21
- package/src/index.js +15 -26
- package/super-linter.log +2533 -0
- package/ .prettierrc +0 -2
- package/pkg/README.md +0 -2
- package/pkg/dist-node/index.js +0 -50
- package/pkg/dist-node/index.js.map +0 -1
- package/pkg/dist-src/index.js +0 -47
- package/pkg/package.json +0 -34
package/ .prettierrc
DELETED
package/pkg/README.md
DELETED
package/pkg/dist-node/index.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* CF Security module
|
|
5
|
-
* @module @nitra/cf-security
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @const {Function}
|
|
10
|
-
*/
|
|
11
|
-
const checkEnv = require('@47ng/check-env').default;
|
|
12
|
-
|
|
13
|
-
checkEnv({
|
|
14
|
-
required: ['X_NITRA_CF_KEY']
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
const log = require('loglevel-colored-level-prefix')();
|
|
18
|
-
|
|
19
|
-
log.debug('cfSecurity in DEBUG MODE');
|
|
20
|
-
/**
|
|
21
|
-
* Check request for Nitra security rules
|
|
22
|
-
*
|
|
23
|
-
* @param {object} req - ApolloServer or Express Request for check
|
|
24
|
-
* @return {boolean} if check passed
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
exports.cfSecurity = function (req) {
|
|
28
|
-
if (typeof req.headers === 'undefined') {
|
|
29
|
-
log.debug('Request without headers');
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (typeof req.headers.x_nitra_cf_key === 'undefined') {
|
|
34
|
-
log.debug('Nitra key not exist in request');
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (req.headers.x_nitra_cf_key.length === 0) {
|
|
39
|
-
log.debug('Empty Nitra key in headers request');
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (req.headers.x_nitra_cf_key !== process.env.X_NITRA_CF_KEY) {
|
|
44
|
-
log.debug('Not equal Nitra key');
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return true;
|
|
49
|
-
};
|
|
50
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../dist-src/index.js"],"sourcesContent":["/**\n * CF Security module\n * @module @nitra/cf-security\n */\n\n/**\n * @const {Function}\n */\nconst checkEnv = require('@47ng/check-env').default;\n\ncheckEnv({\n required: ['X_NITRA_CF_KEY']\n});\n\nconst log = require('loglevel-colored-level-prefix')();\n\nlog.debug('cfSecurity in DEBUG MODE');\n/**\n* Check request for Nitra security rules\n*\n* @param {object} req - ApolloServer or Express Request for check\n* @return {boolean} if check passed\n*/\n\nexports.cfSecurity = function (req) {\n if (typeof req.headers === 'undefined') {\n log.debug('Request without headers');\n return false;\n }\n\n if (typeof req.headers.x_nitra_cf_key === 'undefined') {\n log.debug('Nitra key not exist in request');\n return false;\n }\n\n if (req.headers.x_nitra_cf_key.length === 0) {\n log.debug('Empty Nitra key in headers request');\n return false;\n }\n\n if (req.headers.x_nitra_cf_key !== process.env.X_NITRA_CF_KEY) {\n log.debug('Not equal Nitra key');\n return false;\n }\n\n return true;\n};"],"names":["checkEnv","require","default","required","log","debug","exports","cfSecurity","req","headers","x_nitra_cf_key","length","process","env","X_NITRA_CF_KEY"],"mappings":";;AAAA;;;;;;;;AAQA,MAAMA,QAAQ,GAAGC,OAAO,CAAC,iBAAD,CAAP,CAA2BC,OAA5C;;AAEAF,QAAQ,CAAC;EACPG,QAAQ,EAAE,CAAC,gBAAD;CADJ,CAAR;;AAIA,MAAMC,GAAG,GAAGH,OAAO,CAAC,+BAAD,CAAP,EAAZ;;AAEAG,GAAG,CAACC,KAAJ,CAAU,0BAAV;;;;;;;;AAQAC,OAAO,CAACC,UAAR,GAAqB,UAAUC,GAAV,EAAe;MAC9B,OAAOA,GAAG,CAACC,OAAX,KAAuB,WAA3B,EAAwC;IACtCL,GAAG,CAACC,KAAJ,CAAU,yBAAV;WACO,KAAP;;;MAGE,OAAOG,GAAG,CAACC,OAAJ,CAAYC,cAAnB,KAAsC,WAA1C,EAAuD;IACrDN,GAAG,CAACC,KAAJ,CAAU,gCAAV;WACO,KAAP;;;MAGEG,GAAG,CAACC,OAAJ,CAAYC,cAAZ,CAA2BC,MAA3B,KAAsC,CAA1C,EAA6C;IAC3CP,GAAG,CAACC,KAAJ,CAAU,oCAAV;WACO,KAAP;;;MAGEG,GAAG,CAACC,OAAJ,CAAYC,cAAZ,KAA+BE,OAAO,CAACC,GAAR,CAAYC,cAA/C,EAA+D;IAC7DV,GAAG,CAACC,KAAJ,CAAU,qBAAV;WACO,KAAP;;;SAGK,IAAP;CArBF"}
|
package/pkg/dist-src/index.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CF Security module
|
|
3
|
-
* @module @nitra/cf-security
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @const {Function}
|
|
8
|
-
*/
|
|
9
|
-
const checkEnv = require('@47ng/check-env').default;
|
|
10
|
-
|
|
11
|
-
checkEnv({
|
|
12
|
-
required: ['X_NITRA_CF_KEY']
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const log = require('loglevel-colored-level-prefix')();
|
|
16
|
-
|
|
17
|
-
log.debug('cfSecurity in DEBUG MODE');
|
|
18
|
-
/**
|
|
19
|
-
* Check request for Nitra security rules
|
|
20
|
-
*
|
|
21
|
-
* @param {object} req - ApolloServer or Express Request for check
|
|
22
|
-
* @return {boolean} if check passed
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
exports.cfSecurity = function (req) {
|
|
26
|
-
if (typeof req.headers === 'undefined') {
|
|
27
|
-
log.debug('Request without headers');
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (typeof req.headers.x_nitra_cf_key === 'undefined') {
|
|
32
|
-
log.debug('Nitra key not exist in request');
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (req.headers.x_nitra_cf_key.length === 0) {
|
|
37
|
-
log.debug('Empty Nitra key in headers request');
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (req.headers.x_nitra_cf_key !== process.env.X_NITRA_CF_KEY) {
|
|
42
|
-
log.debug('Not equal Nitra key');
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return true;
|
|
47
|
-
};
|
package/pkg/package.json
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@nitra/cf-security",
|
|
3
|
-
"description": "check header in cloud functions",
|
|
4
|
-
"version": "1.0.5",
|
|
5
|
-
"license": "ISC",
|
|
6
|
-
"files": [
|
|
7
|
-
"dist-*/",
|
|
8
|
-
"bin/"
|
|
9
|
-
],
|
|
10
|
-
"pika": true,
|
|
11
|
-
"sideEffects": false,
|
|
12
|
-
"homepage": "https://github.com/nitra/cf-security#readme",
|
|
13
|
-
"bugs": {
|
|
14
|
-
"url": "https://github.com/nitra/cf-security/issues"
|
|
15
|
-
},
|
|
16
|
-
"repository": {
|
|
17
|
-
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/nitra/cf-security.git"
|
|
19
|
-
},
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"@47ng/check-env": "^1.3.1",
|
|
22
|
-
"loglevel-colored-level-prefix": "^1.0.0"
|
|
23
|
-
},
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"@pika/cli": "^0.2.0",
|
|
26
|
-
"@pika/pack": "^0.5.0",
|
|
27
|
-
"@pika/plugin-build-node": "^0.6.0",
|
|
28
|
-
"@pika/plugin-standard-pkg": "^0.6.0",
|
|
29
|
-
"@types/node": "^12.7.4",
|
|
30
|
-
"standard": "^14.1.0"
|
|
31
|
-
},
|
|
32
|
-
"esnext": "dist-src/index.js",
|
|
33
|
-
"main": "dist-node/index.js"
|
|
34
|
-
}
|