@kravc/dos 1.4.4 → 1.4.6

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@kravc/dos",
3
- "version": "1.4.4",
3
+ "version": "1.4.6",
4
4
  "description": "Convention-based, easy-to-use library for building API-driven serverless services.",
5
5
  "keywords": [
6
6
  "Service",
@@ -25,7 +25,7 @@
25
25
  "author": "Alexander Kravets <a@kra.vc>",
26
26
  "license": "ISC",
27
27
  "dependencies": {
28
- "@kravc/schema": "^2.2.2",
28
+ "@kravc/schema": "^2.3.1",
29
29
  "cookie": "^0.4.1",
30
30
  "js-yaml": "^4.1.0",
31
31
  "jsonwebtoken": "^8.5.1",
@@ -45,12 +45,12 @@
45
45
  "pluralize": "^8.0.0",
46
46
  "ulid": "^2.3.0",
47
47
  "uuid": "^8.3.2",
48
- "z-schema": "^5.0.0"
48
+ "z-schema": "^5.0.2"
49
49
  },
50
50
  "devDependencies": {
51
51
  "chai": "^4.3.4",
52
52
  "eslint": "^7.25.0",
53
- "mocha": "^8.3.2",
53
+ "mocha": "^10.1.0",
54
54
  "nyc": "^15.1.0"
55
55
  },
56
56
  "nyc": {
@@ -16,7 +16,9 @@ class JwtAuthorization {
16
16
  ' "publicKey" to be defined')
17
17
  }
18
18
 
19
- const name = get(options, 'name', 'authorization')
19
+ const name = get(options, 'name', 'authorization')
20
+ const cookieName = get(options, 'cookieName', name)
21
+
20
22
  const requirementName = capitalize(name)
21
23
 
22
24
  return {
@@ -28,6 +30,7 @@ class JwtAuthorization {
28
30
  },
29
31
  klass: this,
30
32
  name,
33
+ cookieName,
31
34
  ...options
32
35
  }
33
36
  }
@@ -49,13 +52,15 @@ class JwtAuthorization {
49
52
  constructor({
50
53
  name,
51
54
  publicKey,
55
+ cookieName,
52
56
  algorithm = 'RS256',
53
57
  tokenVerificationMethod = verifyToken,
54
58
  accessVerificationMethod = () => [ true ]
55
59
  }) {
56
- this._name = name
57
- this._publicKey = publicKey
58
- this._algorithm = algorithm
60
+ this._name = name
61
+ this._publicKey = publicKey
62
+ this._algorithm = algorithm
63
+ this._cookieName = cookieName
59
64
 
60
65
  this._verifyToken = tokenVerificationMethod
61
66
  this._verifyAccess = accessVerificationMethod
@@ -70,7 +75,7 @@ class JwtAuthorization {
70
75
 
71
76
  if (hasCookie) {
72
77
  const cookies = cookie.parse(headers['cookie'])
73
- token = cookies[this._name]
78
+ token = cookies[this._cookieName]
74
79
  }
75
80
 
76
81
  if (!token) {