Skip to content

Commit

Permalink
Fix type mismatch of the status code (#35)
Browse files Browse the repository at this point in the history
* Fix type mismatch of the status code
* Adjust tests

Co-authored-by: Piotrek Witkowski <[email protected]>
  • Loading branch information
piotrekwitkowski and Piotrek Witkowski authored Apr 12, 2022
1 parent 0eca9ac commit 6dc95af
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion __tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ describe('handle', () => {
authenticator._jwtVerifier.verify.mockImplementationOnce(async () => { throw new Error();});
return expect(authenticator.handle(getCloudfrontRequest())).resolves.toEqual(
{
status: 302,
status: '302',
headers: {
'location': [{
key: 'Location',
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios from 'axios';
import { parse, stringify } from 'querystring';
import pino from 'pino';
import { CognitoJwtVerifier } from 'aws-jwt-verify';
import { CloudFrontRequestEvent } from 'aws-lambda';
import { CloudFrontRequestEvent, CloudFrontRequestResult } from 'aws-lambda';

interface AuthenticatorParams {
region: string;
Expand Down Expand Up @@ -193,7 +193,7 @@ export class Authenticator {
* @param {Object} event Lambda@Edge event.
* @return {Promise} CloudFront response.
*/
async handle(event: CloudFrontRequestEvent) {
async handle(event: CloudFrontRequestEvent): Promise<CloudFrontRequestResult> {
this._logger.debug({ msg: 'Handling Lambda@Edge event', event });

const { request } = event.Records[0].cf;
Expand All @@ -220,7 +220,7 @@ export class Authenticator {
const userPoolUrl = `https://${this._userPoolDomain}/authorize?redirect_uri=${redirectURI}&response_type=code&client_id=${this._userPoolAppId}&state=${redirectPath}`;
this._logger.debug(`Redirecting user to Cognito User Pool URL ${userPoolUrl}`);
return {
status: 302,
status: '302',
headers: {
'location': [{
key: 'Location',
Expand Down

0 comments on commit 6dc95af

Please sign in to comment.