
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
aws-credstash
Advanced tools
Use credstash in NodeJS
Drop-in replacement for nodecredstash, API fully compatible (largely unmodified fork of nodecredstash).
aws-sdk: is now a peer dependencySee Release Changelog for more information
$ npm install aws-credstash
Store and retrieve a secret:
import Credstash from "aws-credstash";
const credstash = new Credstash({
table: "credential-store",
awsOpts: { region: "us-west-2" },
});
(async () => {
const name = "Death Star vulnerability";
const context = { app: "db", enviroment: "production" };
const version = await credstash.incrementVersion({ name });
await credstash.putSecret({ name, secret: "Exhaust vent", version, context });
console.log("Secret updated!");
const secret = await credstash.getSecret({ name, context });
console.log(secret); // 'Exhaust vent'
})();
Returns a new credstash instance
Type: object
Type: string
Default: credential-store
The DynamoDB table to store credentials
Type: string
Default: alias/credstash
The name of the KMS key created for credstash.
Type: AWS.KMS.ClientConfiguration
Options to be passed to the aws-sdk instance for DynamoDB and KMS
Specifig configurations can be found for DynamoDB and KMS.
region can be sent in as a parameter, or you can follow other AWS conventions for setting the region
Example:
{
"region": "us-east-1"
}
Options that are specific to the DynamoDB configuration. Defaults can still be assigned in awsOpts, but they can be overridden just for dynamoDb here
Options that are specific to the KMS configuration. Defaults can still be assigned in awsOpts, but they can be overridden just for kms here
The name of the secret that will be stored in DynamoDB
Can be a string or number. If it is a number, then aws-credstash will pad it with 0s so it can be sorted.
Used to get the encryption key from KMS.
Type: object
An optional callback function when you don't want to use promises;
credstash.getSecret(
{
name: "Death Star plans",
context: { rebelShip: "true" },
},
function (err, res) {
if (err) {
throw new Error("The Death Star plans are not in the main computer.");
}
}
);
Credstash instance
Create the table in DynamoDB using the table option
Encode a secret and place it in DynamoDB.
credstash.putSecret({
name: "Death Star Vulnerability",
secret: "Exhaust vent",
context: { rebel: "true" },
});
DynamoDB will now contain a record for this entry that looks like:
{
"name": "Death Star Vulnerability", //
"key": "...", // The value sent to KMS to retrieve the decryption key
"version": "0000000000000000001", // The version string, should be sorteable
"hmac": "...", // An HMAC validation value
"contents": "..." // The AES 128 encrypted value
}
Returns the first sorted result for the given name key.
Returns the next incremented version version for the given name key.
Retrieve a decrypted secret from DynamoDB
Retrieve all decrypted secrets from DynamoDB.
The startsWith option will filter the response
credstash
.getAllSecrets({ context: { rebel: "true" } })
.then((secrets) => console.log(JSON.stringify(secrets, null, 2)));
{
"Death Star vulnerability": "Exhaust vent"
}
Retrieve all or the last N(limit) versions of a secret.
credstash
.getAllVersions({
name: "Death Star vulnerability",
limit: 2,
context: { rebel: "true" },
})
.then((secrets) => console.log(JSON.stringify(secrets, null, 2)));
[
{ version: "0000000000000000006", secret: "Exhaust vent" },
{ version: "0000000000000000005", secret: "Destroy vent" },
];
Retrieve all stored secrets and their highest version
credstash
.listSecrets()
.then((list) => console.log(JSON.stringify(list, null, 2)));
[
{
name: "Death Star",
version: "0000000000000000001",
},
{
name: "Death Star vulnerability",
version: "0000000000000000001",
},
];
Delete the desired secret by version from DynamoDB
credstash.deleteSecret({name: 'Death Star', version: 1})
// 'Deleting Death Star -- version 0000000000000000001'
.then(() => credstash.list())
.then(list => console.log(JSON.stringify(list, null, 2));
[
{
name: "Death Star vulnerability",
version: "0000000000000000001",
},
];
Deletes all of the versions of name
credstash.deleteSecrets({name: 'Death Star vulnerability'})
// 'Deleting Death Star vulnerability -- version 0000000000000000001'
.then(() => credstash.listSecrets())
.then(list => console.log(JSON.stringify(list, null, 2));
[];
FAQs
Node.js credstash using AWS DynamoDB and KMS. Fork of nodecredstash
The npm package aws-credstash receives a total of 556 weekly downloads. As such, aws-credstash popularity was classified as not popular.
We found that aws-credstash demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.