@nitra/cf-security 2.0.50 → 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 CHANGED
@@ -1,12 +1,14 @@
1
1
  # cf-security
2
2
 
3
+ [![GitHub Super-Linter](https://github.com/nitra/cf-security/workflows/npm-publish/badge.svg)](https://github.com/marketplace/actions/super-linter)
4
+
3
5
  Check security header in Cloud Functions
4
6
 
5
- ```
7
+ ```HTTP
6
8
  X_NITRA_CF_KEY: secret
7
9
  ```
8
10
 
9
- ```
11
+ ```JavaScript
10
12
  const { cfSecurity } = require('@nitra/cf-security')
11
13
 
12
14
  exports.function = async (req, res) => {
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "@nitra/cf-security",
3
- "version": "2.0.50",
3
+ "version": "3.0.0",
4
4
  "description": "check header in cloud functions",
5
5
  "main": "src/index.js",
6
+ "type": "module",
6
7
  "scripts": {
7
- "fix": "npx standard --fix && npx prettier --write ."
8
+ "fix": "npx standard --fix && npx prettier --write .",
9
+ "test": "env $(cat ./test/.env) npx coverage-node test/index.js"
8
10
  },
9
11
  "repository": {
10
12
  "type": "git",
@@ -18,10 +20,11 @@
18
20
  "homepage": "https://github.com/nitra/cf-security#readme",
19
21
  "prettier": "prettier-config-standard",
20
22
  "devDependencies": {
21
- "prettier-config-standard": "^1.0.1"
23
+ "prettier-config-standard": "^1.0.1",
24
+ "test-director": "^7.0.0"
22
25
  },
23
26
  "dependencies": {
24
- "@47ng/check-env": "^2.0.1",
25
- "consola": "^2.15.3"
27
+ "@nitra/check-env": "^2.0.1",
28
+ "@nitra/consola": "^1.3.1"
26
29
  }
27
30
  }
package/src/index.js CHANGED
@@ -1,18 +1,6 @@
1
- /**
2
- * CF Security module
3
- *
4
- * @module @nitra/cf-security
5
- */
6
-
7
- const consola = require('consola')
8
-
9
- /**
10
- * @const {Function}
11
- */
12
- const checkEnv = require('@47ng/check-env').default
13
- checkEnv({ required: ['X_NITRA_CF_KEY'] })
14
-
15
- consola.debug('cfSecurity in DEBUG MODE')
1
+ import consola from '@nitra/consola'
2
+ import checkEnv from '@nitra/check-env'
3
+ checkEnv(['X_NITRA_CF_KEY'])
16
4
 
17
5
  /**
18
6
  * Check request for Nitra security rules
@@ -20,8 +8,7 @@ consola.debug('cfSecurity in DEBUG MODE')
20
8
  * @param {object} req - ApolloServer or Express Request for check
21
9
  * @return {boolean} if check passed
22
10
  */
23
-
24
- exports.cfSecurity = function (req) {
11
+ export const cfSecurity = req => {
25
12
  if (typeof req.headers === 'undefined') {
26
13
  consola.debug('Request without headers')
27
14
  return false