New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cognito-local

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cognito-local

![CI](https://github.com/jagregory/cognito-local/workflows/CI/badge.svg)

  • 1.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13K
increased by0.43%
Maintainers
1
Weekly downloads
 
Created
Source

Cognito Local

CI

An offline emulator for Amazon Cognito.

The goal for this project is to be Good Enough for local development use, and that's it. Don't expect it to be perfect, because it won't be.

Features

  • Sign Up
  • Confirm Sign Up
  • Initiate Auth (Login)
  • Forgot Password
  • Confirm Forgot Password
  • User Migration lambda trigger (Authentication)
  • User Migration lambda trigger (Forgot Password)

Installation

yarn add --dev cognito-local
# OR
npm install --dev cognito-local

Usage

# if node_modules/.bin is in your $PATH
cognito-local
# OR
yarn cognito-local
# OR
npx cognito-local

Cognito Local will now be listening on http://localhost:9229.

You can now update your AWS code to use the local address for Cognito's endpoint. For example, if you're using amazon-cognito-identity-js you can update your CognitoUserPool usage to override the endpoint:

new CognitoUserPool({
  /* ... normal options ... */
  endpoint: "http://localhost:9229/",
});

You likely only want to do this when you're running locally on your development machine.

Configuration

You do not need to supply a config unless you need to customise the behaviour of Congito Local. If you are using Lambda triggers, you will definitely need to override LambdaClient.endpoint at a minimum.

Before starting Cognito Local, create a config file:

mkdir .cognito && echo '{}' > .cognito/config.json

You can edit that .cognito/config.json and add any of the following settings:

SettingTypeDefaultDescription
LambdaClientobjectAny setting you would pass to the AWS.Lambda Node.js client
LambdaClient.credentials.accessKeyIdstringlocal
LambdaClient.credentials.secretAccessKeystringlocal
LambdaClient.endpointstringlocal
LambdaClient.regionstringlocal
TriggerFunctionsobject{}Trigger name to Function name mapping
TriggerFunctions.UserMigrationstringUser Migration lambda name
UserPoolDefaultsobjectDefault behaviour to use for the User Pool
UserPoolDefaults.UserPoolIdstringlocalDefault User Pool Id
UserPoolDefaults.UsernameAttributesstring[]["email"]Username alias attributes

The default config is:

{
  "LambdaClient": {
    "credentials": {
      "accessKeyId": "local",
      "secretAccessKey": "local"
    },
    "region": "local"
  },
  "TriggerFunctions": {},
  "UserPoolDefaults": {
    "UserPoolId": "local",
    "UsernameAttributes": ["email"]
  }
}

Known Limitations

Many. Cognito Local only works for my exact use-case.

Issues I know about:

  • The database is shared for all User Pools, if you use different User Pool IDs they will all access the same database.
  • Client IDs are ignored and all connect to the same User Pool.
  • Users can't be disabled
  • Only USER_PASSWORD_AUTH flow is supported
  • You can't reset your password
  • Not all Lambda triggers (yet, watch this space)

Confirmation codes

If you register a new user and they need to confirm their account, Cognito Local will write a message to the console with their confirmation code instead of emailing it to the user.

For example:

╭───────────────────────────────────────────────────────╮
│                                                       │
│   Confirmation Code Delivery                          │
│                                                       │
│   Username:    c63651ae-59c6-4ede-ae7d-a8400ff65e8d   │
│   Destination: example@example.com                    │
│   Code:        3520                                   │
│                                                       │
╰───────────────────────────────────────────────────────╯

FAQs

Package last updated on 12 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc