• Stars
    star
    469
  • Rank 93,595 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 9 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🎩 The mighty NodeJS password vault


Buttercup Core


Buttercup core library

A NodeJS secrets vault.

Buttercup npm npm version node min version security encryption

Tests status

NPM

About

Buttercup is a JavaScript password manager for NodeJS and the browser (though you can also see it used on platforms like React Native). It's based around the concept of a Vault and its secret Entry items (a login, credit card etc.). Entries are then separated into Group containers that make organising vaults a little easier.

Because Buttercup is designed first and foremost to be consumed by users in some application, VaultManager and VaultSource constructs are provided to allow for easy control over several vaults in a somewhat shared environment. A vault manager provides easy-to-use methods to perform dehydration and rehydration (storage in serialised form) of vaults to some secure storage (files, remote datasources etc.).

Buttercup can save and load vaults that are stored locally, in cloud service providers like Dropbox or Google Drive, or in a cloud service's WebDAV-enabled storage. It does this by providing a Datasource construct for each provider.

Because Buttercup can be consumed in some interesting and varied environments, serialisation tools called facades are provided to allow for greater flexibility when working with vault data structures. Facades provide a way to move data around without classes, converting vaults to and from JSON objects. Facades are used when attaching vaults to user interfaces like with the Buttercup UI library.

Features

The core of the system, this Buttercup Core, boasts a few awesome features:

  • Merge-able vault contents
  • History for back-tracking to previous passwords etc.
  • File attachments (encrypted)
  • AES CBC encryption
  • GZip compression
  • NodeJS and Browser support

This library also supports a variety of datasources for loading from and saving to:

Check out the changelog.

Installation

To use Buttercup in a NodeJS environment, you can simply install and require it:

npm install buttercup --save

In a Node environment, for example:

const { Vault } = require("buttercup");

Or for Typescript:

import { Vault } from "buttercup";

In a web environment, use the following:

import { Vault } from "buttercup/web";

Buttercup core is ESM - you must either import it in a project that is also ESM, or use a build tool like Webpack.

Buttercup core supports Node version 14 and up. For older Node versions use v6 and earlier.

Usage

Buttercup uses Vaults, Groups and Entrys to manipulate data in a workspace-like environment. These 3 constructs have no knowledge of encryption or storage, and simply provide interfaces for working with the data structures.

To manage vaults, their storage and their states in a higher-level manner more appropriate for building applications, check out the VaultManager and VaultSource constructs.

To get started, we should create a new Vault:

import { Vault, init } from "buttercup";

// Initialise environment
init();

// Create an empty vault
const vault1 = new Vault();

// Create aa vault with "General" and "Trash" groups
const vault2 = Vault.createWithDefaults();

The init() function call is used to initialise the environment (performs the same function as @buttercup/app-env used to). It is required for Buttercup to work. It can be called more than once without effect.

Entries can't be added directly to a Vault, but can be to Groups. Creating Groups and Entries is trivial:

const vault = Vault.createWithDefaults();
const myGroup = vault.createGroup("My Group");
const myEntry = myGroup.createEntry("My Entry");

Every command on Vaults, Groups and Entries modifies the Vault instance, but does not save it to storage. There is no command or need to commit any data - each instance links back to the original Vault. Vaults are saved and loaded using Datasources:

import { Credentials, FileDatasource, Vault, init } from "buttercup";

init();

const datasourceCredentials = Credentials.fromDatasource({
    path: "./user.bcup"
}, "masterPassword!");
const fileDatasource = new FileDatasource(datasourceCredentials);
const vault = Vault.createWithDefaults();
vault
    .createGroup("Websites")
        .createEntry("My bank")
            .setProperty("username", "user-name")
            .setProperty("password", "s3cureP4$$");

const vaultCredentials = Credentials.fromPassword("masterPassword!");
await fileDatasource.save(vault.format.history, vaultCredentials);

Later:

const datasourceCredentials = Credentials.fromDatasource({
    path: "./user.bcup"
}, "masterPassword!");
const fileDatasource = new FileDatasource(datasourceCredentials);

fileDatasource
    .load(datasourceCredentials)
    .then(Vault.createFromHistory)
    .then(vault => {
        // ...
    });

Using just a datasource is not recommended as saving and loading is quite low-level and cumbersome. Check the browser extension or desktop application for examples of how to use the VaultManager and other helpful classes.

Development

To develop Buttercup Core, clone the repository on a Linux or Mac OS machine. Ensure that you're running NodeJS version 16/18. Install all dependencies by running npm install in the project directory. Run the tests to ensure everything is functioning correctly: npm test.

Vault Formats

Buttercup currently supports 2 concurrent vault formats, as it is in the process of transitioning from Format A (legacy) to Format B. You can switch the operational format by doing the following:

const { VaultFormatB, init, setDefaultFormat } = require("buttercup");

init();

setDefaultFormat(VaultFormatB);

Buttercup will automatically transition to using Format B as the default in some weeks or months (since v5 was released).

Compatibility

Buttercup's compatibility is defined as the following:

  • NodeJS version 12 and up
  • Current versions of the following browsers:
    • Google Chrome
    • Mozilla Firefox
    • Safari
  • React Native 0.60+

NB: React Native support is not guaranteed under all circumstances as the platform's stability for low-level operations like cryptography is questionable. Use the mobile app as a guideline for implementation.

Browser support is strictly dependent on:

  • Popularity
  • The availability of required crypto libaries such as SubtleCrypto

More Repositories

1

buttercup-desktop

πŸ”‘ Cross-Platform Passwords & Secrets Vault
TypeScript
4,298
star
2

buttercup-mobile

πŸ“± React-Native mobile application for Buttercup
TypeScript
396
star
3

buttercup-browser-extension

🌏 Buttercup browser extension
TypeScript
233
star
4

dossier

πŸ“ˆ Project overview and feature planning for Buttercup
48
star
5

buttercup-importer

🎣 3rd-party archive importer for Buttercup
JavaScript
43
star
6

rust-crypto-wasm

Rust
38
star
7

ui

React UI Components used in Buttercup products
JavaScript
31
star
8

react-formatted-input

An input component that abides by configurable formatting and constraint rules
JavaScript
29
star
9

buttercup-cli

Buttercup password manager for the command line
TypeScript
27
star
10

locust

Login form location & automation utility
TypeScript
20
star
11

buttercup-website

Buttercup's Homepage
JavaScript
12
star
12

buttercup-exporter

Export Buttercup vaults
JavaScript
9
star
13

google-oauth2-client

Google OAuth2 authentication client
TypeScript
9
star
14

secure-file-host

Secure filesystem host toolkit for Browser-Desktop datasource connection
JavaScript
8
star
15

buttercup-generator

Simple Javascript Password Generator for Buttercup Products
JavaScript
8
star
16

buttercup-core-web

Web-based build of the Buttercup core library.
JavaScript
7
star
17

channel-queue

A queue management library with channels
JavaScript
6
star
18

dropbox-client

Dropbox client library
JavaScript
6
star
19

crypto

πŸ”’ Buttercup's native encryption tools written in Rust
Rust
6
star
20

buttercup-server

Archive server for Buttercup
JavaScript
6
star
21

googledrive-client

Client for making basic Google Drive requests
TypeScript
6
star
22

credentials

Encrypted credentials handler for Buttercup
JavaScript
5
star
23

signing

Signing and verification tools for Buttercup archives
JavaScript
4
star
24

datasources

Buttercup archive datasources
JavaScript
4
star
25

file-interface

Client request library interface and explorer
TypeScript
4
star
26

buttercup-mobile-compat

Compiled library bundle for Buttercup's mobile platform
JavaScript
3
star
27

config

Configuration utility
JavaScript
3
star
28

desktop-v2-beta

Buttercup desktop application
TypeScript
3
star
29

app-env

Buttercup application environment configuration manager
JavaScript
3
star
30

bcupfs

Buttercup FileSystem for in-vault file storage and encryption
JavaScript
3
star
31

wasmcane

WASM Cryptography tools for iocane
Rust
2
star
32

account-rescue

Account reset/rescue framework for NodeJS
JavaScript
2
star
33

search

Vault searching components
JavaScript
2
star
34

iconographer

Icon queuing, fetching and caching library
JavaScript
2
star
35

archive-sharing

Share archive configurations between applications
JavaScript
1
star
36

icon-proxy

Self-hosted website icon proxy for Buttercup
TypeScript
1
star
37

fetch

Fetch adapter for cross-platform use.
JavaScript
1
star
38

download-count

JavaScript
1
star
39

daemon

Browser extension helper daemon
Rust
1
star
40

facades

Editing facades for Buttercup vaults and content
JavaScript
1
star
41

buttercup-native-bindings

OS-specific bindings and daemons.
JavaScript
1
star
42

attachments

Manage vault attachments and media
1
star