Skip to content

Commit 199f3d8

Browse files
committed
fix: types
1 parent 866e2cc commit 199f3d8

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/http/auth.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export abstract class CognitoAuthorizer {
129129

130130
export class ApiGatewayv2CognitoAuthorizer extends CognitoAuthorizer {
131131

132-
constructor(protected event: AWSLambda.APIGatewayProxyEventV2, private _logger: logger.LambdaLog) {
132+
constructor(protected event: AWSLambda.APIGatewayProxyEventV2WithJWTAuthorizer, private _logger: logger.LambdaLog) {
133133
super();
134134
}
135135

@@ -143,7 +143,7 @@ export class ApiGatewayv2CognitoAuthorizer extends CognitoAuthorizer {
143143
if (!authHeader || !authHeader.startsWith('Bearer ')) {
144144
return;
145145
}
146-
const token = authHeader.substr('Bearer '.length);
146+
const token = authHeader.substring('Bearer '.length);
147147
try {
148148
const claims: { [name: string]: string } = await promisedVerify(token);
149149
this._logger.debug(JSON.stringify(claims));
@@ -153,6 +153,8 @@ export class ApiGatewayv2CognitoAuthorizer extends CognitoAuthorizer {
153153
claims,
154154
scopes: ['openid', 'email'],
155155
},
156+
integrationLatency: 0,
157+
principalId: 'toolbox',
156158
};
157159
this.claims = claims;
158160
} catch (err: any) {

src/http/handler.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ export interface Operation {
3636
};
3737
}
3838

39-
export type APIGatewayv2Handler = AWSLambda.Handler<AWSLambda.APIGatewayProxyEventV2, AWSLambda.APIGatewayProxyStructuredResultV2 | undefined>;
39+
export type APIGatewayv2Handler =
40+
AWSLambda.Handler<AWSLambda.APIGatewayProxyEventV2WithJWTAuthorizer, AWSLambda.APIGatewayProxyStructuredResultV2 | undefined>;
4041

4142
export interface OperationWithRequestBody extends Operation {
4243
requestBody: { content: { 'application/json': any } };

test/boom.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Boom from '@hapi/boom';
2-
import { createHttpHandler } from '../src/http/handler';
2+
import { createHttpHandler } from '../src/http/handler';
33

44
test('Boom error support for createHttpHandler', async () => {
55
const boomErr = Boom.notImplemented();
@@ -14,9 +14,9 @@ test('Boom error support for createHttpHandler', async () => {
1414
rawPath: '/raw/path',
1515
rawQueryString: '',
1616
isBase64Encoded: false,
17-
} as AWSLambda.APIGatewayProxyEventV2;
17+
} as AWSLambda.APIGatewayProxyEventV2WithJWTAuthorizer;
1818
const context = {} as AWSLambda.Context;
19-
const result = await handler(event, context, () => {});
19+
const result = await handler(event, context, () => { });
2020

2121
if (!result) {
2222
throw new Error('handler is expected to return a result!');

0 commit comments

Comments
 (0)