@kravc/dos 1.10.1 → 1.10.2

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.10.1",
3
+ "version": "1.10.2",
4
4
  "description": "Convention-based, easy-to-use library for building API-driven serverless services.",
5
5
  "keywords": [
6
6
  "Service",
@@ -53,8 +53,9 @@ class JwtAuthorization {
53
53
  publicKey,
54
54
  cookieName,
55
55
  algorithm = 'RS256',
56
- tokenVerificationMethod = verifyToken,
57
- accessVerificationMethod = () => [ true ]
56
+ normalizePayload = payload => payload,
57
+ tokenVerificationMethod = verifyToken,
58
+ accessVerificationMethod = () => [ true ],
58
59
  }) {
59
60
  this._name = name
60
61
  this._publicKey = publicKey
@@ -63,6 +64,7 @@ class JwtAuthorization {
63
64
 
64
65
  this._verifyToken = tokenVerificationMethod
65
66
  this._verifyAccess = accessVerificationMethod
67
+ this._normalizePayload = normalizePayload
66
68
  }
67
69
 
68
70
  async verify(context) {
@@ -111,7 +113,9 @@ class JwtAuthorization {
111
113
  return { isAuthorized: false, error }
112
114
  }
113
115
 
114
- return { isAuthorized: true, ...payload }
116
+ const normalizedPayload = this._normalizePayload(payload)
117
+
118
+ return { isAuthorized: true, ...normalizedPayload }
115
119
  }
116
120
  }
117
121