How to use buttercup - 10 common examples

To help you get started, we’ve selected a few buttercup examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github himynameisdave / git-labelmaker / bin / modules / fetch-token.js View on Github external
.then(ans => {
                    const datasource = new Buttercup.FileDatasource(bcupPath);
                    datasource.load(ans.master_password).then((archive) => {
                    // This is only guaranteed to work on buttercup 0.14.0, awaiting PR in buttercup
                        const groups = archive.getGroups();
                        const group = groups.filter((g) => g._remoteObject.title === 'git-labelmaker')[0];
                        const token = group.getAttribute('token');
                        res(token);
                    })
                  .catch(e => {
                      if (e.message === 'Failed opening archive: Error: Encrypted content has been tampered with') {
                          return rej({
                              id: 'PASSWORD',
                          });
                      }
                      return rej(err(e.message));
                  });
                })
github buttercup / buttercup-desktop / src / renderer / index.js View on Github external
setIsArchiveSearchVisible
} from '../shared/actions/ui-state';
import { setupShortcuts } from './system/shortcuts';
import { setSetting } from '../shared/actions/settings';
import { changeMode } from '../shared/actions/entries';
import { addGroup } from '../shared/actions/groups';
import { getSetting, getUIState } from '../shared/selectors';
import Root from './containers/root';
import { getQueue } from './system/queue';

// Unhandled rejections
const unhandled = require('electron-unhandled');
unhandled();

// Alter some Buttercup internals
Buttercup.Web.HashingTools.patchCorePBKDF();
Buttercup.vendor.webdav.setFetchMethod(window.fetch);

// Create store
const store = configureStore({}, 'renderer');

i18n.changeLanguage(getSetting(store.getState(), 'locale'));
linkArchiveManagerToStore(store);
setupShortcuts(store);

// Reset current archive
store.dispatch(setSetting('archivesLoading', true));
store.dispatch(setCurrentArchive(null));
store.dispatch(resetArchivesInStore([]));

ipc.on('import-history', (e, payload) => {
  store.dispatch(importHistoryIntoArchive(payload));
github buttercup / buttercup-desktop / src / renderer / index.js View on Github external
} from '../shared/actions/ui-state';
import { setupShortcuts } from './system/shortcuts';
import { setSetting } from '../shared/actions/settings';
import { changeMode } from '../shared/actions/entries';
import { addGroup } from '../shared/actions/groups';
import { getSetting, getUIState } from '../shared/selectors';
import Root from './containers/root';
import { getQueue } from './system/queue';

// Unhandled rejections
const unhandled = require('electron-unhandled');
unhandled();

// Alter some Buttercup internals
Buttercup.Web.HashingTools.patchCorePBKDF();
Buttercup.vendor.webdav.setFetchMethod(window.fetch);

// Create store
const store = configureStore({}, 'renderer');

i18n.changeLanguage(getSetting(store.getState(), 'locale'));
linkArchiveManagerToStore(store);
setupShortcuts(store);

// Reset current archive
store.dispatch(setSetting('archivesLoading', true));
store.dispatch(setCurrentArchive(null));
store.dispatch(resetArchivesInStore([]));

ipc.on('import-history', (e, payload) => {
  store.dispatch(importHistoryIntoArchive(payload));
});
github buttercup / buttercup-desktop / src / main / workspace.js View on Github external
save: function(datasourcePath, password) {
            var archive = Buttercup.Archive.createWithDefaults(),
                datasource = new Buttercup.FileDatasource(datasourcePath);

            return datasource.save(archive, password);
        }
    };
github himynameisdave / git-labelmaker / bin / modules / set-token.js View on Github external
const writeToken = (password, token) => new Promise((res, rej) => {
    const datasource = new Buttercup.FileDatasource(bcupPath);
    if (!datasource) return rej('No datasource');
    const archive = Buttercup.Archive.createWithDefaults();
    const group = archive.createGroup('git-labelmaker');
    group.setAttribute('token', token);
    datasource.save(archive, password);
    return res(token);
});
github buttercup / buttercup-desktop / src / main / workspace.js View on Github external
load: function(datasourcePath, password) {
            var workspace = new Buttercup.Workspace(),
                datasource = new Buttercup.FileDatasource(datasourcePath);

            return datasource.load(password).then(function(archive) {
                workspace
                    .setArchive(archive)
                    .setDatasource(datasource)
                    .setPassword(password);

                return workspace;
            });
        },
github buttercup / buttercup-desktop / src / main / workspace.js View on Github external
save: function(datasourcePath, password) {
            var archive = Buttercup.Archive.createWithDefaults(),
                datasource = new Buttercup.FileDatasource(datasourcePath);

            return datasource.save(archive, password);
        }
    };
github himynameisdave / git-labelmaker / bin / modules / set-token.js View on Github external
const writeToken = (password, token) => new Promise((res, rej) => {
    const datasource = new Buttercup.FileDatasource(bcupPath);
    if (!datasource) return rej('No datasource');
    const archive = Buttercup.Archive.createWithDefaults();
    const group = archive.createGroup('git-labelmaker');
    group.setAttribute('token', token);
    datasource.save(archive, password);
    return res(token);
});
github buttercup / buttercup-desktop / src / main / workspace.js View on Github external
load: function(datasourcePath, password) {
            var workspace = new Buttercup.Workspace(),
                datasource = new Buttercup.FileDatasource(datasourcePath);

            return datasource.load(password).then(function(archive) {
                workspace
                    .setArchive(archive)
                    .setDatasource(datasource)
                    .setPassword(password);

                return workspace;
            });
        },
github buttercup / buttercup-desktop / src / shared / buttercup / ipc-datasource.js View on Github external
import fs from 'fs';
import {
  TextDatasource,
  DatasourceAdapter
} from 'buttercup/dist/buttercup-web.min';

const registerDatasource = DatasourceAdapter.registerDatasource;

/**
 * Datasource for Ipc archives
 * @augments TextDatasource
 */
export class IpcDatasource extends TextDatasource {
  constructor(filePath) {
    super('');
    this.path = filePath;
  }

  load(password) {
    return Promise.resolve(fs.readFileSync(this.path, 'utf8')).then(content => {
      this.setContent(content);
      return super.load(password);
    });