added encryption to player list
This commit is contained in:
1 parent
9f113a8588
commit
2a689dd20b
9 files changed
+53
-30
No files matched your search
+30
-5
@@ -8,9 +8,10 @@ var rename = require("gulp-rename");
|
||||
var yaml = require('gulp-yaml');
|
||||
var template = require('gulp-template');
|
||||
var wrapper = require('gulp-wrapper');
|
||||
var rename = require("gulp-rename");
|
||||
var webserver = require('gulp-webserver');
|
||||
var marked = require('marked');
|
||||
var spritz = require('spritzjs');
|
||||
var modify = require('gulp-modify');
|
||||
var _ = require('lodash');
|
||||
|
||||
gulp.task('help', help);
|
||||
@@ -39,17 +40,41 @@ gulp.task('compile-results', function(){
|
||||
.pipe(gulp.dest('./api'));
|
||||
});
|
||||
|
||||
var encryptFile = function(message){
|
||||
var keyLengthInBytes = 128;
|
||||
var stringKey = process.env.KEY || 'qwerty';
|
||||
var key = spritz.hash(stringKey, keyLengthInBytes);
|
||||
var byteArrMessage = spritz.stringToUtf8ByteArray(message);
|
||||
var cypher = spritz.encrypt(key, byteArrMessage);
|
||||
return JSON.stringify(cypher);
|
||||
};
|
||||
|
||||
gulp.task('encrypt-results', ['compile-results'], function(){
|
||||
return gulp.src('api/*.clear.json')
|
||||
.pipe(modify({
|
||||
fileModifier: function(file, content) {
|
||||
return encryptFile(content);
|
||||
}
|
||||
}))
|
||||
.pipe(rename(function(path){
|
||||
path.basename = path.basename.replace(/\.clear$/i, '');
|
||||
path.extname = '.json.spritz';
|
||||
return path;
|
||||
}))
|
||||
.pipe(gulp.dest('./api'));
|
||||
});
|
||||
|
||||
gulp.task('template-prod', function () {
|
||||
return gulp.src('index.tmpl.html')
|
||||
.pipe(rename("index.html"))
|
||||
.pipe(template({production: true}))
|
||||
.pipe(template({production: true, salt: process.env.SALT, playerListLocation: process.env.PLAYER_LIST_LOCATION}))
|
||||
.pipe(gulp.dest('.'));
|
||||
});
|
||||
|
||||
gulp.task('template-dev', function () {
|
||||
return gulp.src('index.tmpl.html')
|
||||
.pipe(rename("index.html"))
|
||||
.pipe(template({production: false}))
|
||||
.pipe(template({production: false, salt: '', playerListLocation: 'api/players.json.spritz'}))
|
||||
.pipe(gulp.dest('.'));
|
||||
});
|
||||
|
||||
@@ -82,7 +107,7 @@ gulp.task('compile-articles', function(){
|
||||
|
||||
});
|
||||
|
||||
gulp.task('default', ['bower', 'sass', 'compile-results', 'compile-articles']);
|
||||
gulp.task('default', ['bower', 'sass', 'encrypt-results', 'compile-results', 'compile-articles']);
|
||||
|
||||
gulp.task('prod', ['default', 'template-prod']);
|
||||
|
||||
@@ -101,5 +126,5 @@ gulp.task('dev', ['default', 'webserver', 'template-dev', 'bower'], function(){
|
||||
gulp.watch('./scss/*.scss', ['sass']);
|
||||
gulp.watch('*.tmpl.html', ['template-dev']);
|
||||
gulp.watch('./data/articles/**/*', ['compile-articles']);
|
||||
return gulp.watch('./data/*.yaml', ['compile-results']);
|
||||
return gulp.watch('./data/*.yaml', ['encrypt-results', 'compile-results']);
|
||||
});
|
||||
Reference in new issue
Block a user