@kravc/dos 1.12.4 → 1.12.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.12.4",
3
+ "version": "1.12.6",
4
4
  "description": "Convention-based, easy-to-use library for building API-driven serverless services.",
5
5
  "keywords": [
6
6
  "Service",
package/src/index.d.ts CHANGED
@@ -169,6 +169,8 @@ export declare class JwtAuthorization {
169
169
  name?: string;
170
170
  algorithm?: string;
171
171
  cookieName?: string;
172
+ description?: string;
173
+ requirementName?: string;
172
174
  normalizePayload?: Function;
173
175
  tokenVerificationMethod?: Function;
174
176
  accessVerificationMethod?: (context: Context, payload: Record<string, unknown>) => [boolean, string?];
@@ -178,6 +180,8 @@ export declare class JwtAuthorization {
178
180
  export declare class SystemAuthorization {
179
181
  static createRequirement(options?: {
180
182
  name?: string;
183
+ description?: string;
184
+ requirementName?: string;
181
185
  accessVerificationMethod?: (context: Context) => [boolean, string?];
182
186
  }): Record<string, any>
183
187
  }
@@ -17,15 +17,16 @@ class JwtAuthorization {
17
17
 
18
18
  const name = get(options, 'name', 'authorization')
19
19
  const cookieName = get(options, 'cookieName', name)
20
-
21
- const requirementName = capitalize(name)
20
+ const description = get(options, 'description')
21
+ const requirementName = get(options, 'requirementName', capitalize(name))
22
22
 
23
23
  return {
24
24
  [requirementName]: {
25
25
  definition: {
26
26
  in: 'header',
27
27
  type: 'apiKey',
28
- name
28
+ name,
29
+ description,
29
30
  },
30
31
  klass: this,
31
32
  name,
@@ -4,6 +4,11 @@ const { get } = require('lodash')
4
4
  const AccessDeniedError = require('../errors/AccessDeniedError')
5
5
 
6
6
  const SYSTEM_NAME = 'System'
7
+ const DESCRIPTION = 'This security definition and a header for system' +
8
+ ' operations should be ignored. The verification method of system' +
9
+ ' operations relies on a gateway that adds headers for all' +
10
+ ' external requests. Request without headers considered to be' +
11
+ ' internal.'
7
12
 
8
13
  const verifySystemAccess = (context) => {
9
14
  const { headers } = context
@@ -20,19 +25,16 @@ class SystemAuthorization {
20
25
  static createRequirement(options = {}) {
21
26
  const name = get(options, 'name', 'authorization')
22
27
 
23
- const requirementName = SYSTEM_NAME
28
+ const description = get(options, 'description', DESCRIPTION)
29
+ const requirementName = get(options, 'requirementName', SYSTEM_NAME)
24
30
 
25
31
  return {
26
32
  [requirementName]: {
27
33
  definition: {
28
- description: 'This security definition and a header for system' +
29
- ' operations should be ignored. The verification method of system' +
30
- ' operations relies on a gateway that adds headers for all' +
31
- ' external requests. Request without headers considered to be' +
32
- ' internal.',
33
34
  in: 'header',
34
35
  type: 'apiKey',
35
- name
36
+ name,
37
+ description,
36
38
  },
37
39
  klass: this,
38
40
  ...options