@spytecgps/lambda-utils 0.0.9 → 0.9.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/dist/types.d.ts CHANGED
@@ -4,20 +4,22 @@ import { APIGatewayProxyEventBase } from 'aws-lambda/trigger/api-gateway-proxy';
4
4
  export interface SpytecAuthorizedResources {
5
5
  devices: string[];
6
6
  }
7
+ export declare type AuthClass = 'user' | 'client' | 'system';
7
8
  export interface SpytecAuthContext {
8
- type: 'user' | 'client';
9
+ type: AuthClass;
9
10
  userId?: string;
10
11
  clientId: number;
11
12
  resources: SpytecAuthorizedResources;
12
13
  principalId: string;
13
14
  scope?: string;
14
15
  }
15
- export declare type BaseEvent = Omit<APIGatewayProxyEventBase<SpytecAuthContext>, 'pathParameters' | 'queryStringParameters'>;
16
+ export declare type BaseAPIGatewayEvent = Omit<APIGatewayProxyEventBase<SpytecAuthContext>, 'pathParameters' | 'queryStringParameters' | 'body'>;
16
17
  export interface WrapperArgs<E, R> {
17
18
  event: APIGatewayProxyWithLambdaAuthorizerEvent<SpytecAuthContext>;
18
19
  schema?: ObjectSchema<E>;
19
- handler: (event: E) => Promise<HandlerResponse<R>>;
20
+ handler: Handler<E, R>;
20
21
  }
22
+ export declare type Handler<E, R> = (event: E) => Promise<HandlerResponse<R>>;
21
23
  export interface HandlerResponse<R> {
22
24
  statusCode?: number;
23
25
  headers?: {
@@ -1,10 +1,11 @@
1
1
  import * as Joi from 'joi';
2
- import { SpytecAuthContext } from '../types';
2
+ import { AuthClass, SpytecAuthContext } from '../types';
3
3
  import { APIGatewayEventRequestContextWithAuthorizer } from 'aws-lambda/common/api-gateway';
4
4
  interface GetAuthorizerValidatorParams {
5
5
  scope?: string;
6
+ type?: AuthClass;
6
7
  }
7
- export declare const getAuthorizerValidator: ({ scope }?: GetAuthorizerValidatorParams) => Joi.ObjectSchema<SpytecAuthContext>;
8
+ export declare const getAuthorizerValidator: ({ scope, type }?: GetAuthorizerValidatorParams) => Joi.ObjectSchema<SpytecAuthContext>;
8
9
  /**
9
10
  * @deprecated
10
11
  */
@@ -0,0 +1,4 @@
1
+ import { APIGatewayProxyResult } from 'aws-lambda';
2
+ import { WrapperArgs } from '../types';
3
+ declare const apiGatewayEventWrapper: <E, R>({ event, schema, handler, }: WrapperArgs<E, R>) => Promise<APIGatewayProxyResult>;
4
+ export default apiGatewayEventWrapper;
@@ -1,3 +1,3 @@
1
- import apiGwWrapper from './apiGwWrapper';
2
- export { apiGwWrapper };
1
+ import apiGatewayEventWrapper from './apiGatewayEventWrapper';
2
+ export { apiGatewayEventWrapper };
3
3
  export * from './response';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spytecgps/lambda-utils",
3
- "version": "0.0.9",
3
+ "version": "0.9.1",
4
4
  "description": "Lambda Utils",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",