@drifted/raven 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +6 -5
- package/package.json +1 -1
- package/test/cli.test.js +3 -3
- package/test/raven.test.js +3 -3
package/index.js
CHANGED
|
@@ -4,7 +4,7 @@ const fs = require('fs');
|
|
|
4
4
|
|
|
5
5
|
const ivLength = 16;
|
|
6
6
|
|
|
7
|
-
class
|
|
7
|
+
class RavenDataFile {
|
|
8
8
|
constructor(options={}) {
|
|
9
9
|
Object.assign(this, options)
|
|
10
10
|
if (this.data != undefined && typeof this.data == 'string') {
|
|
@@ -19,7 +19,7 @@ class JSONDataFile {
|
|
|
19
19
|
this.algorithm = 'aes-256-gcm';
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
if (this.secret == undefined &&
|
|
22
|
+
if (this.secret == undefined && RavenDataFile.hasFile()) {
|
|
23
23
|
this.populateSecretFromFile();
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -29,7 +29,7 @@ class JSONDataFile {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
populateSecretFromFile() {
|
|
32
|
-
var data = fs.readFileSync(
|
|
32
|
+
var data = fs.readFileSync(RavenDataFile.secretFile()).toString();
|
|
33
33
|
var json = JSON.parse(data);
|
|
34
34
|
this.secret = json.secret;
|
|
35
35
|
}
|
|
@@ -47,7 +47,7 @@ class JSONDataFile {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
return new Promise(async(resolve) => {
|
|
50
|
-
var file = new
|
|
50
|
+
var file = new RavenDataFile(options);
|
|
51
51
|
var times = 0;
|
|
52
52
|
|
|
53
53
|
await file.read();
|
|
@@ -58,6 +58,7 @@ class JSONDataFile {
|
|
|
58
58
|
} catch(error) {
|
|
59
59
|
//console.log(error);
|
|
60
60
|
}
|
|
61
|
+
|
|
61
62
|
times = times + 1;
|
|
62
63
|
}
|
|
63
64
|
|
|
@@ -215,7 +216,7 @@ class JSONDataFile {
|
|
|
215
216
|
}
|
|
216
217
|
|
|
217
218
|
|
|
218
|
-
module.exports =
|
|
219
|
+
module.exports = RavenDataFile;
|
|
219
220
|
|
|
220
221
|
|
|
221
222
|
|
package/package.json
CHANGED
package/test/cli.test.js
CHANGED
|
@@ -2,7 +2,7 @@ const path = require('path');
|
|
|
2
2
|
const assert = require('assert');
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const RavenDataFile = require(path.join(__dirname, '..'));
|
|
6
6
|
var { exec } = require('child_process');
|
|
7
7
|
|
|
8
8
|
const {
|
|
@@ -82,7 +82,7 @@ describe('raven', function() {
|
|
|
82
82
|
|
|
83
83
|
describe('files', function() {
|
|
84
84
|
it('conceal/expose', function(done) {
|
|
85
|
-
var secret =
|
|
85
|
+
var secret = RavenDataFile.secret();
|
|
86
86
|
var file = path.join(__dirname, 'theraven.txt');
|
|
87
87
|
var initial = fs.readFileSync(file).toString();
|
|
88
88
|
|
|
@@ -101,7 +101,7 @@ describe('raven', function() {
|
|
|
101
101
|
})
|
|
102
102
|
|
|
103
103
|
it('repeatedly concealing/exposing', function(done) {
|
|
104
|
-
var secret =
|
|
104
|
+
var secret = RavenDataFile.secret();
|
|
105
105
|
var file = path.join(__dirname, 'theraven.txt');
|
|
106
106
|
var initial = fs.readFileSync(file).toString();
|
|
107
107
|
run('conceal', '-f', file, '-s', secret).then(() => {
|
package/test/raven.test.js
CHANGED
|
@@ -2,7 +2,7 @@ const path = require('path');
|
|
|
2
2
|
const assert = require('assert');
|
|
3
3
|
process.env.NODE_ENV = 'test';
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const RavenDataFile = require(path.join(__dirname, '..'));
|
|
6
6
|
|
|
7
7
|
var defaults = {
|
|
8
8
|
secret: 'ffdnZY17Fw+sup2+lhOOt6PW++/RkLTXRaLL3RJsjzE='
|
|
@@ -30,7 +30,7 @@ describe('raven', function() {
|
|
|
30
30
|
it('eval', function(done) {
|
|
31
31
|
|
|
32
32
|
// this seems to work. i should write a test to make sure that it works
|
|
33
|
-
|
|
33
|
+
RavenDataFile.eval({
|
|
34
34
|
secret: defaults.secret,
|
|
35
35
|
iterations: 2,
|
|
36
36
|
file: path.join(__dirname, 'workspace', 'example.json.encrypted')
|
|
@@ -45,7 +45,7 @@ describe('raven', function() {
|
|
|
45
45
|
})
|
|
46
46
|
|
|
47
47
|
it('encrypt/decrypt', function(done) {
|
|
48
|
-
var jdf = new
|
|
48
|
+
var jdf = new RavenDataFile({secret: defaults.secret, data: {test: true}});
|
|
49
49
|
var result = jdf.encrypt(JSON.stringify(jdf.data));
|
|
50
50
|
result = JSON.parse(jdf.decrypt(result));
|
|
51
51
|
assert.equal(result.test, true);
|