Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
bump version, update all deps, cleanup and fix #39
Browse files Browse the repository at this point in the history
  • Loading branch information
HR committed Jun 29, 2019
1 parent 1fd5eaa commit 0618ddc
Show file tree
Hide file tree
Showing 24 changed files with 13,789 additions and 162 deletions.
11 changes: 11 additions & 0 deletions app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ module.exports = {
DOCS: 'https://github.com/HR/Crypter/blob/master/readme.md',
REPORT_ISSUE: 'https://github.com/HR/Crypter/issues/new'
},
WINDOW_OPTS: {
center: true,
show: true,
titleBarStyle: 'hidden',
resizable: false,
maximizable: false,
movable: true,
webPreferences: {
nodeIntegration: true
}
},
VIEWS: {
BASE_URI: VIEWS_BASE_URI,
MASTERPASSPROMPT: `${VIEWS_BASE_URI}/masterpassprompt.html`,
Expand Down
2 changes: 1 addition & 1 deletion app/core/Db.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
******************************/

const _ = require('lodash')
const logger = require('winston')
const logger = require('../script/logger')
const fs = require('fs-extra')

/**
Expand Down
16 changes: 8 additions & 8 deletions app/core/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
const fs = require('fs-extra')
const path = require('path')
const scrypto = require('crypto')
const logger = require('winston')
const logger = require('../script/logger')
const Readable = require('stream').Readable
const tar = require('tar-fs')
const {CRYPTO, REGEX, ERRORS} = require('../config')
Expand Down Expand Up @@ -182,9 +182,9 @@ exports.decrypt = (origpath, mpkey) => {
let creds = credsLine[0].split('#')
logger.verbose(`creds: ${creds}, credsLine: ${credsLine}`)

const iv = new Buffer(creds[1], 'hex')
const authTag = new Buffer(creds[2], 'hex')
const salt = new Buffer(creds[3], 'hex')
const iv = Buffer.from(creds[1], 'hex')
const authTag = Buffer.from(creds[2], 'hex')
const salt = Buffer.from(creds[3], 'hex')
logger.verbose(`Extracted data, iv: ${iv}, authTag: ${authTag}, salt: ${salt}`)
// Read encrypted data stream
const dataOrig = fs.createReadStream(dataOrigPath)
Expand Down Expand Up @@ -254,7 +254,7 @@ exports.deriveKey = (pass, psalt) => {
const salt = (psalt)
? ((Buffer.isBuffer(psalt))
? psalt
: new Buffer(psalt))
: Buffer.from(psalt))
: scrypto.randomBytes(CRYPTO.DEFAULTS.KEYLENGTH)

// derive the key using the salt, password and default crypto setup
Expand Down Expand Up @@ -293,15 +293,15 @@ exports.genPassHash = (masterpass, salt) => {

// Converts a buffer array to a hex string
exports.buf2hex = (arr) => {
const buf = new Buffer(arr)
const buf = Buffer.from(arr)
return buf.toString('hex')
}

// Compares vars in a constant time (protects against timing attacks)
exports.timingSafeEqual = (a, b) => {
// convert args to buffers if not already
a = (Buffer.isBuffer(a)) ? a : new Buffer(a)
b = (Buffer.isBuffer(b)) ? b : new Buffer(b)
a = (Buffer.isBuffer(a)) ? a : Buffer.from(a)
b = (Buffer.isBuffer(b)) ? b : Buffer.from(b)
var result = 0
var l = a.length
while (l--) {
Expand Down
24 changes: 13 additions & 11 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,8 @@
* Entry point for app execution
******************************/
// Electron
const {app, dialog} = require('electron')
// Core
const Db = require('./core/Db')
// Windows
const crypter = require('./src/crypter')
const masterPassPrompt = require('./src/masterPassPrompt')
const setup = require('./src/setup')
const settings = require('./src/settings')
const {ERRORS} = require('./config')
// adds debug features like hotkeys for triggering dev tools and reload
require('electron-debug')()

const {app, dialog} = require('electron')
// declare global constants
// MasterPass credentials global
global.creds = {}
Expand All @@ -28,8 +18,20 @@ global.paths = {
home: app.getPath('home'),
documents: app.getPath('documents')
}

const logger = require('./script/logger')

// Core
const Db = require('./core/Db')
// Windows
const crypter = require('./src/crypter')
const masterPassPrompt = require('./src/masterPassPrompt')
const setup = require('./src/setup')
const settings = require('./src/settings')
const {ERRORS} = require('./config')
// adds debug features like hotkeys for triggering dev tools and reload
require('electron-debug')()

// change exec path
logger.info(`AppPath: ${app.getAppPath()}`)
logger.info(`UseData Path: ${app.getPath('userData')}`)
Expand Down
Loading

0 comments on commit 0618ddc

Please sign in to comment.