@pointblankdev/lambda-auth

0.2.9 • Public • Published

lambda-auth

Usage

Use lambda-auth to verify() RS256 JWTs and decode their accessToken.

const { verify } = require('@pointblankdev/lambda-auth');

const server = new ApolloServer({
  schema: buildFederatedSchema([{ typeDefs, resolvers }]),
  context: async ({ event, context }) => {
    return {
      headers: event.headers,
      functionName: context.functionName,
      event,
      context,
      user: await verify(event),
    };
  },
  playground: {
    endpoint: `/${process.env.ENV}/graphql`,
  },
  introspection: true,
});

Notes

The verify function is asynchronous so you can either await the function like it's been done above or await context.user whenever you want to access it

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.2.9
    1
    • latest

Version History

Package Sidebar

Install

npm i @pointblankdev/lambda-auth

Weekly Downloads

1

Version

0.2.9

License

ISC

Unpacked Size

3.81 kB

Total Files

5

Last publish

Collaborators