@spytecgps/lambda-utils 2.3.26 → 2.3.28
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/index.js +16 -0
- package/dist/types.d.ts +9 -0
- package/dist/validation/requestContext.d.ts +4 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -184,6 +184,15 @@ const getAuthorizerValidator = (params = {}) => {
|
|
|
184
184
|
...params,
|
|
185
185
|
});
|
|
186
186
|
};
|
|
187
|
+
const getAuthorizerValidatorV4 = (params = {}) => {
|
|
188
|
+
return Joi__namespace.object({
|
|
189
|
+
clientId: Joi__namespace.number().greater(0).required(),
|
|
190
|
+
userId: Joi__namespace.string().guid( /*{ version: 'uuidv4' }*/).required(),
|
|
191
|
+
scope: Joi__namespace.string().optional(),
|
|
192
|
+
type: Joi__namespace.string().optional(),
|
|
193
|
+
...params,
|
|
194
|
+
});
|
|
195
|
+
};
|
|
187
196
|
/**
|
|
188
197
|
* @deprecated
|
|
189
198
|
*/
|
|
@@ -195,6 +204,11 @@ const getRequestContextValidator = (params = {}) => {
|
|
|
195
204
|
authorizer: getAuthorizerValidator(params),
|
|
196
205
|
});
|
|
197
206
|
};
|
|
207
|
+
const getRequestContextValidatorV4 = (params = {}) => {
|
|
208
|
+
return Joi__namespace.object({
|
|
209
|
+
authorizer: getAuthorizerValidatorV4(params),
|
|
210
|
+
});
|
|
211
|
+
};
|
|
198
212
|
|
|
199
213
|
class HttpError extends Error {
|
|
200
214
|
}
|
|
@@ -715,8 +729,10 @@ exports.buildProxyResult = buildProxyResult;
|
|
|
715
729
|
exports.buildResponseBody = buildResponseBody;
|
|
716
730
|
exports.defaultApiSchema = defaultApiSchema;
|
|
717
731
|
exports.getAuthorizerValidator = getAuthorizerValidator;
|
|
732
|
+
exports.getAuthorizerValidatorV4 = getAuthorizerValidatorV4;
|
|
718
733
|
exports.getEnvKey = getEnvKey;
|
|
719
734
|
exports.getRequestContextValidator = getRequestContextValidator;
|
|
735
|
+
exports.getRequestContextValidatorV4 = getRequestContextValidatorV4;
|
|
720
736
|
exports.iccidSchema = iccidSchema;
|
|
721
737
|
exports.imeiSchema = imeiSchema;
|
|
722
738
|
exports.isDev = isDev;
|
package/dist/types.d.ts
CHANGED
|
@@ -75,3 +75,12 @@ export type SQSWrapperArgsWithReturn<RecordType extends BaseRecord, T> = {
|
|
|
75
75
|
singleHandler?: (record: RecordType) => T | Promise<T>;
|
|
76
76
|
mode?: 'serial' | 'parallel';
|
|
77
77
|
};
|
|
78
|
+
export interface SpytecAuthContextV4 {
|
|
79
|
+
type: AuthClass;
|
|
80
|
+
userId?: string;
|
|
81
|
+
clientId: number;
|
|
82
|
+
principalId: string;
|
|
83
|
+
scope?: string;
|
|
84
|
+
}
|
|
85
|
+
export type BaseAPIGatewayEventV4 = Omit<APIGatewayProxyEventBase<SpytecAuthContextV4>, 'pathParameters' | 'queryStringParameters' | 'body'>;
|
|
86
|
+
export type UserAPIHandlerV4<TEvent = APIGatewayProxyWithLambdaAuthorizerEvent<SpytecAuthContextV4>, TResult = any> = (event: TEvent, context: APIGatewayEventRequestContext, callback: Callback<TResult>) => void | Promise<TResult>;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { APIGatewayEventRequestContextWithAuthorizer } from 'aws-lambda/common/api-gateway';
|
|
2
2
|
import * as Joi from 'joi';
|
|
3
|
-
import { SpytecAuthContext } from '../types';
|
|
3
|
+
import { SpytecAuthContext, SpytecAuthContextV4 } from '../types';
|
|
4
4
|
type GetAuthorizerValidatorParams = Partial<Record<keyof SpytecAuthContext, Joi.AnySchema>>;
|
|
5
|
+
type GetAuthorizerValidatorParamsV4 = Partial<Record<keyof SpytecAuthContextV4, Joi.AnySchema>>;
|
|
5
6
|
export declare const getAuthorizerValidator: (params?: GetAuthorizerValidatorParams) => Joi.ObjectSchema<SpytecAuthContext>;
|
|
7
|
+
export declare const getAuthorizerValidatorV4: (params?: GetAuthorizerValidatorParamsV4) => Joi.ObjectSchema<SpytecAuthContext>;
|
|
6
8
|
/**
|
|
7
9
|
* @deprecated
|
|
8
10
|
*/
|
|
9
11
|
export declare const requestContextValidator: Joi.ObjectSchema<any>;
|
|
10
12
|
export declare const getRequestContextValidator: (params?: GetAuthorizerValidatorParams) => Joi.ObjectSchema<APIGatewayEventRequestContextWithAuthorizer<SpytecAuthContext>>;
|
|
13
|
+
export declare const getRequestContextValidatorV4: (params?: GetAuthorizerValidatorParamsV4) => Joi.ObjectSchema<APIGatewayEventRequestContextWithAuthorizer<SpytecAuthContextV4>>;
|
|
11
14
|
export {};
|