Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type mismatch of the status code #34

Closed
piotrekwitkowski opened this issue Apr 12, 2022 · 0 comments · Fixed by #35
Closed

Type mismatch of the status code #34

piotrekwitkowski opened this issue Apr 12, 2022 · 0 comments · Fixed by #35

Comments

@piotrekwitkowski
Copy link
Contributor

piotrekwitkowski commented Apr 12, 2022

What happened:

The type of the response returned by the Authenticator doesn't match the CloudFrontRequestHandler response type from the aws-lambda package

What did you expect to have happen:

The types match

How to reproduce this (as precisely and succinctly as possible):

This should work
import { SSMClient, GetParameterCommand } from "@aws-sdk/client-ssm";
import { CloudFrontRequestHandler } from "aws-lambda";
import { Authenticator } from "cognito-at-edge";

const ssm = new SSMClient({ region: process.env.CONFIG_PARAMETER_REGION });
const authenticatorPromise = ssm
  .send(new GetParameterCommand({ Name: process.env.CONFIG_PARAMETER_NAME }))
  .then(config => new Authenticator({ ...JSON.parse(config.Parameter!.Value!), logLevel: 'info' }));

export const handler: CloudFrontRequestHandler = async event => {
  try {
    const authenticator = await authenticatorPromise;
    return await authenticator.handle(event);
  } catch (error) {
    console.error(error);
    return { body: '401 Unauthorized', status: '401' };
  }
};

Anything else you think we should know?

PR will be provided

Environment:

  • version of cognito-at-edge being used: 1.2.1
  • node version of code base which uses cognito-at-edge: n/a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant