@kravc/dos 1.10.1 → 1.10.3

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.3",
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
@@ -4,6 +4,7 @@ export declare type Context = Record<string, any>;
4
4
  export declare type QueryMap = Record<string, any>;
5
5
  export declare type CreateMutationMap = Record<string, any>;
6
6
  export declare type UpdateMutationMap = Record<string, any>;
7
+ export declare type AttributesMap = Record<string, any>;
7
8
 
8
9
  export declare interface IndexOptions {
9
10
  sort?: SortOrder;
@@ -29,6 +30,10 @@ export declare class Document<T> {
29
30
  static get idKeyPrefix(): string;
30
31
  static get documentName(): string;
31
32
 
33
+ static _read(query: QueryMap): Promise<AttributesMap>;
34
+ static _create(attributes: AttributesMap): Promise<Boolean>;
35
+ static _update(query: QueryMap, mutation: UpdateMutationMap): Promise<AttributesMap>;
36
+
32
37
  static getPartition(
33
38
  context: Context,
34
39
  parameters: Record<string, any>
@@ -45,6 +50,16 @@ export declare class Document<T> {
45
50
  lastEvaluatedKey: string;
46
51
  }>;
47
52
 
53
+ static indexAll<T, D extends Document<T> = Document<T>>(
54
+ this: DocumentConstructor<T, D>,
55
+ context: Context,
56
+ query?: QueryMap,
57
+ options?: IndexOptions,
58
+ ): Promise<{
59
+ count: number;
60
+ objects: D[];
61
+ }>;
62
+
48
63
  static read<T, D extends Document<T> = Document<T>>(
49
64
  this: DocumentConstructor<T, D>,
50
65
  context: Context,
@@ -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