npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cognito-gateway

v0.8.1

Published

A gateway lambda for dealing with cognito apis

Downloads

8

Readme

Cognito Gateway API

cognito-gateway npm cognito-gateway circle

Usage

import cognitoGateway from 'cognito-gateway';

export const {
    signIn,
    signUp,
    signOutGlobal,
    signUpConfirm,
    signUpConfirmResend,
    refreshToken,
    changePassword,
    forgotPasswordRequest,
    forgotPasswordConfirm,
    userGet,
    userDelete
} from cognitoGateway({
    headers: {
        'Access-Control-Allow-Origin': '*'
    },
    preSignIn: (requestBody) => requestBody, // custom pre auth logic
    postSignIn: (responseBody) => responseBody, // custom post auth logic
    // more hooks
});

Config

headers: Object<string, string>

An object containing any headers to be added to the http response.

Hooks

Hooks are called at various points throughout the signup and authentication process. They can be used to add custom authentication or perform additional actions in response to authentication or signup. All hooks are async so you can return a promise. The promise should resolve to an object in the same structure as the request or response body. If the promise is rejected or an error is thrown during the hook execution then cognitoGateway will create a http response from the err.statusCode and err.message properies of the promise rejection payload or thrown error.

The available hooks are:

preSignIn(
    requestBody: {
        username: string,
        password: string
    },
    httpEvent: AWSLambdaEvent,
    lambdaContext: AWSLambdaContext
) => Promise<requestBody>

postSignIn(
    error: ?GromitError,
    responseBody: ?{
        accessToken: string,
        refreshToken: string,
        idToken: string,
        time: number
    },
    httpEvent: AWSLambdaEvent,
    lambdaContext: AWSLambdaContext
) => Promise<responseBody>

preSignUp(
    requestBody: {
        username: string,
        password: string,
        attributes: Object
    },
    httpEvent: AWSLambdaEvent,
    lambdaContext: AWSLambdaContext
) => Promise<requestBody>

postSignUp(
    error: ?GromitError,
    responseBody: ?{
        user: {
            username: string,
            attributes: Object
        }
    },
    httpEvent: AWSLambdaEvent,
    lambdaContext: AWSLambdaContext
) => Promise<responseBody>

preSignOutGlobal(
    requestBody: {},
    httpEvent: AWSLambdaEvent,
    lambdaContext: AWSLambdaContext
) => Promise<requestBody>

postSignOutGlobal(
    error: ?GromitError,
    responseBody: ?{status: 'success'},
    httpEvent: AWSLambdaEvent,
    lambdaContext: AWSLambdaContext
) => Promise<responseBody>

preSignUpConfirm(
    requestBody: {
        username: string,
        verificationCode: string
    },
    httpEvent: AWSLambdaEvent,
    lambdaContext: AWSLambdaContext
) => Promise<requestBody>

postSignUpConfirm(
    error: ?GromitError,
    responseBody: ?{status: 'success'},
    httpEvent: AWSLambdaEvent,
    lambdaContext: AWSLambdaContext
) => Promise<responseBody>

preSignUpConfirmResend(
    requestBody: {
        username: string
    },
    httpEvent: AWSLambdaEvent,
    lambdaContext: AWSLambdaContext
) => Promise<requestBody>

postSignUpConfirmResend(
    error: ?GromitError,
    responseBody: ?{status: 'success'},
    httpEvent: AWSLambdaEvent,
    lambdaContext: AWSLambdaContext
) => Promise<responseBody>

preRefreshToken(
    requestBody: {refreshToken: string},
    httpEvent: AWSLambdaEvent,
    lambdaContext: AWSLambdaContext
) => Promise<requestBody>

postRefreshToken(
    error: ?GromitError,
    responseBody: ?{
        accessToken: string,
        idToken: string
    },
    httpEvent: AWSLambdaEvent,
    lambdaContext: AWSLambdaContext
) => Promise<responseBody>

preChangePassword(
    requestBody: {
        password: string,
        newPassword: string,
        accessToken: string
    },
    httpEvent: AWSLambdaEvent,
    lambdaContext: AWSLambdaContext
) => Promise<requestBody>

postChangePassword(
    error: ?GromitError,
    responseBody: ?{status: 'success'},
    httpEvent: AWSLambdaEvent,
    lambdaContext: AWSLambdaContext
) => Promise<responseBody>

preForgotPasswordRequest(
    requestBody: {
        username: string
    },
    httpEvent: AWSLambdaEvent,
    lambdaContext: AWSLambdaContext
) => Promise<requestBody>

postForgotPasswordRequest(
    error: ?GromitError,
    responseBody: ?{status: 'success'},
    httpEvent: AWSLambdaEvent,
    lambdaContext: AWSLambdaContext
) => Promise<responseBody>

preForgotPasswordConfirm(
    requestBody: {
        username: string,
        confirmationCode: string,
        password: string
    },
    httpEvent: AWSLambdaEvent,
    lambdaContext: AWSLambdaContext
) => Promise<requestBody>

postForgotPasswordConfirm(
    error: ?GromitError,
    responseBody: ?{status: 'success'},
    httpEvent: AWSLambdaEvent,
    lambdaContext: AWSLambdaContext
) => Promise<responseBody>

preUserGet(
    requestBody: {},
    httpEvent: AWSLambdaEvent,
    lambdaContext: AWSLambdaContext
) => Promise<requestBody>

postUserGet(
    error: ?GromitError,
    responseBody: ?{status: 'success'},
    httpEvent: AWSLambdaEvent,
    lambdaContext: AWSLambdaContext
) => Promise<responseBody>

preUserDelete(
    requestBody: {},
    httpEvent: AWSLambdaEvent,
    lambdaContext: AWSLambdaContext
) => Promise<requestBody>

postUserDelete(
    error: ?GromitError,
    responseBody: ?{status: 'success'},
    httpEvent: AWSLambdaEvent,
    lambdaContext: AWSLambdaContext
) => Promise<responseBody>

Auth

/signIn [post]

Request a set of tokens via a username and password

path: /signIn
method: post
requestBody:
    username: string
    password: string
responseBody:
    accessToken: string
    refreshToken: string
    idToken: string
    time: int

/refreshToken [post]

Request a new access and id token via a refresh token

path: /refreshToken
method: post
requestBody:
    refreshToken: string
responseBody:
    accessToken: string
    idToken: string

/signOutGlobal [post]

Sign a user out from all services.

path: /signOutGlobal
method: post
headers:
    Authorization: 'Bearer {accessToken}'
responseBody:
    status: string

/signUp [post]

Request the creation of a new user

path: /signUp
method: post
requestBody:
    username: string
    password: string
    attributes: array
responseBody: 
    user: cognitoUser
    verificationAttribute: string
    verificationMedium: string
    verificationValue: string

/signUpConfirm [post]

Confirm a user via a verification code

path: /signUpConfirm
method: post
requestBody:
    username: string
    verificationCode: string
responseBody:
    status: string

/signUpConfirmResend [post]

Request a new verification code via username

path: /signUpConfirmResend
method: post
requestBody:
    username: string
responseBody:
    verificationAttribute: string
    verificationMedium: string
    verificationValue: string

Users

/user [get]

Request user information via a token

path: /user
method: get
headers:
    Authorization: 'Bearer {accessToken}'
responseBody: CognitoUser

/user [delete]

Delete a user via a token

path: /user
method: delete
headers:
    Authorization: 'Bearer {accessToken}'
responseBody:
    status: string