changed way to get encrypted data to make cross server requests possible
This commit is contained in:
1 parent
d1c01b6bf9
commit
18938a77d0
4 files changed
+23
-8
No files matched your search
+8
-5
@@ -42,7 +42,7 @@ gulp.task('compile-results', function(){
|
||||
|
||||
var encryptFile = function(message){
|
||||
var keyLengthInBytes = 128;
|
||||
var salt = process.env.SALT || '';
|
||||
var salt = process.env.SALT || 'salt';
|
||||
var stringKey = salt + (process.env.KEY || 'qwerty');
|
||||
var key = spritz.hash(stringKey, keyLengthInBytes);
|
||||
var byteArrMessage = spritz.stringToUtf8ByteArray(message);
|
||||
@@ -50,16 +50,20 @@ var encryptFile = function(message){
|
||||
return JSON.stringify(cypher);
|
||||
};
|
||||
|
||||
var wrapEncryptedData = function(encryptedData){
|
||||
return 'window.encryptedPlayerList = ' + encryptedData + ';';
|
||||
};
|
||||
|
||||
gulp.task('encrypt-results', ['compile-results'], function(){
|
||||
return gulp.src('api/*.clear.json')
|
||||
.pipe(modify({
|
||||
fileModifier: function(file, content) {
|
||||
return encryptFile(content);
|
||||
return wrapEncryptedData(encryptFile(content));
|
||||
}
|
||||
}))
|
||||
.pipe(rename(function(path){
|
||||
path.basename = path.basename.replace(/\.clear$/i, '');
|
||||
path.extname = '.json.spritz';
|
||||
path.extname = '.spritz.js';
|
||||
return path;
|
||||
}))
|
||||
.pipe(gulp.dest('./api'));
|
||||
@@ -75,7 +79,7 @@ gulp.task('template-prod', function () {
|
||||
gulp.task('template-dev', function () {
|
||||
return gulp.src('index.tmpl.html')
|
||||
.pipe(rename("index.html"))
|
||||
.pipe(template({production: false, salt: '', playerListLocation: 'api/players.json.spritz'}))
|
||||
.pipe(template({production: false, salt: 'salt', playerListLocation: 'api/players.spritz.js'}))
|
||||
.pipe(gulp.dest('.'));
|
||||
});
|
||||
|
||||
@@ -122,7 +126,6 @@ gulp.task('webserver', function(){
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
gulp.task('dev', ['default', 'webserver', 'template-dev', 'bower'], function(){
|
||||
gulp.watch('./scss/*.scss', ['sass']);
|
||||
gulp.watch('*.tmpl.html', ['template-dev']);
|
||||
|
||||
Reference in new issue
Block a user