@nitra/cf-security 3.4.0 → 4.0.1

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/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@nitra/cf-security",
3
- "version": "3.4.0",
4
- "description": "check header in cloud functions",
5
- "main": "src/index.js",
3
+ "version": "4.0.1",
4
+ "description": "check header in serverless",
6
5
  "type": "module",
7
6
  "exports": {
8
7
  ".": "./src/index.js",
package/src/index.js CHANGED
@@ -7,7 +7,7 @@ checkEnv(['X_NITRA_CF_KEY'])
7
7
  * @param {object} req - ApolloServer or Express Request for check
8
8
  * @return {boolean} if check passed
9
9
  */
10
- export const cfSecurity = req => {
10
+ export default function (req) {
11
11
  if (typeof req.headers === 'undefined') {
12
12
  req.log.info('Request without headers')
13
13
  return false
package/src/jwt.js CHANGED
@@ -5,7 +5,8 @@ import { isDev } from '@nitra/isenv'
5
5
  * Check request for Nitra security rules WI
6
6
  *
7
7
  * @param {object} req - Fastify Request for check
8
- * @return {string} token if check passed
8
+ * @param {Array} allowedRoles - Allowed roles
9
+ * @return {Promise<string>} token if check passed
9
10
  */
10
11
  export default async (req, allowedRoles) => {
11
12
  // Для дева можна й не передавати токен