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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kkeian/aws-mfa-rotate

v0.2.0

Published

JavaScript to increase ease of rotating AWS temporary credentials used to authenticate CLI/SDK with MFA

Readme

aws-mfa-rotate

Simple CLI tool to rotate AWS CLI/SDK temporary credentials.


Installation

Pre-requisites:

  1. npm installed.
  2. node version 14.
  3. AWS CLI installed with configuration files setup see

Install command:

npm i -g @kkeian/aws-mfa-rotate

Example usage:

Rotate MFA credentials for genericprofilename. Expire credentials after 1 hour.

aws-mfa rotate -p genericprofilename -t 138239 -d 1

Rotate MFA credentials for genericprofilename. Expire credentials after default 12 hours.

aws-mfa rotate -p genericprofilename -t 138239


Expected .aws files format:

  • .aws/config file:

    Should have at least 2 entries for the account used for MFA:

[profile accountName]
aws_access_key_id = [keyId]
aws_secret_access_key = [secretKey]
region = [regionHere]

[profile accountNamemfa]
aws_access_key_id = [randomDummyValue]
aws_secret_access_key = [randomDummyValue]
aws_session_token = [randomDummyValue]
mfa_serial = [MfaArn]
region = [regionHere]
  • .aws/credentials file

    Should have at least 1 entry:

[accountNamemfa]
aws_access_key_id = [randomDummyValue]
aws_secret_access_key = [randomDummyValue]
aws_session_token = [randomDummyValue]

How it works:


  1. AWS access key pair is used to authenticate with AWS STS service.
  2. Once authenticated, the GenerateSessionToken command is sent to STS.
  3. A temporary access key id, secret access key, and session token are returned.
  4. The temporary credentials are written to .aws/credentials file.
    • The named profile configuration in this file always takes precendence over any named profile configuration in .aws/config, but we have a duplicate dummy entry in .aws/config to hold the mfa_serial used to request a new temporary credential.
  5. You're able to use the AWS CLI/SDK to connect to the AWS Account you generated temporary credentials for, along with any AWS Accounts configured with a role that can be assumed by the user you generated temporary credentials for.
    • Note: if you intend to authenticate to other AWS Accounts via role assumption, you will need to configure that in the .aws/config file. This is done by specifying the source_profile key under the named profile of the AWS Account with the role to assume. The source_profile key needs to refer to the section name for the named profile temporary credentials were written to in the .aws/credentials file.

Contributing

General project structure:

  • src: holds main logic of program.
  • bin: holds command line interface configuration.

Feel free to submit PR with improvements. This is a hobby project only managed by me so don't expect a quick turnaround.