Skip to content

Commit

Permalink
v.1.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
AnPaKo committed Jan 21, 2018
0 parents commit 77b20a9
Show file tree
Hide file tree
Showing 114 changed files with 36,460 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Safe.ad

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Safe.ad client application
============

Decentralized Email Service and Cloud Storage with End-To-End Encryption

Quick Start
-----------

* Download & Install GIT (https://git-scm.com/downloads) & Node.js (https://nodejs.org) for your platform.

* Clone the repo
> ```
> git clone https://github.com/safead/client.git
> ```
* Install project dependencies, run from the project root
> ```
> npm install
> ```
* [optional] Install **ssl/localhost.crt** as a trusted certificate into your browser.
* Now start dev server, run from the project root
> ```
> npm start
> ```
* Navigate to (http://localhost:8888) or https if cert is installed.
* Enjoy...
Project floder structure
------------------------
* **dist/** - project build, intended for deployment onto public web server;
* **ssl/localhost.crt** - dev server certificate;
* **ssl/localhost.key** - dev server certificate key;
* **pub/** - public files to be copied into **dist/** as is;
* **src/** - files to be compiled/preprocessed prior to deployment;
* **src/css** - style sources (less/sass/whatever);
* **src/js** - client-side codebase;
* **LICENSE** - license;
* **gulpfile.js** - project build & config;
* **package.json** - project meta for `npm`;
* **README.md** - this file.
233 changes: 233 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
"use strict";

var pjson = require('./package.json'),
minFilename = 'safe.min.js',
isUgly = true,
isMini = true,

gulp = require('gulp'),
del = require('del'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
manifest = require('gulp-manifest'),
connect = require('gulp-connect'),
fs = require('fs'),
extend = require('extend'),
runSequence = require('run-sequence'),
gulpif = require('gulp-if'),
change = require('gulp-change'),

feedbackPath = 'js/feedback/',
workersPath = 'js/workers/',
tinyPath = 'js/tinymce/',
feedbackSrc = 'src/' + feedbackPath + '**',
workersSrc = 'src/' + workersPath + '**',
tinySrc = 'pub/' + tinyPath + '**/**',

src = {

pub: ['pub/**'],
boot: ['src/js/boot.js'],
scripts: ['src/js/**/*.js', '!src/js/boot*', '!' + workersSrc, '!' + feedbackSrc],
assets: ['src/**', '!src/js/**', '!src/css/*'],
styles: ['src/css/*'],

},

dest = {

dist: 'dist/',

},

serverConfig = {

host: process.env.HOST || 'localhost',
port: process.env.PORT || '8888',
root: dest.dist.substr(0, dest.dist.length - 1),

headers: {

'Access-Control-Allow-Origin': "*",
'Access-Control-Allow-Methods': "GET, POST",
'Access-Control-Expose-Headers': "Content-Range",
'Content-Security-Policy': "default-src 'self';connect-src 'self' api.safe.ad files.safe.ad localhost;script-src 'self'; img-src 'self' data: blob: http: https:;style-src safe.ad 'self' 'unsafe-inline' blob:; object-src 'none';frame-src safe.ad 'self' order.safe.ad safe: data: blob:; child-src 'self' ; media-src blob:; font-src 'self';",

},

/*https: {
cert: dest.dist + 'ssl/localhost.crt',
key: dest.dist + 'ssl/localhost.key',
},*/

};

gulp.task('clean:dest', function(){

return del([dest.dist + '**/*']);

});

gulp.task('build:pub', function(){

gulp
.src(tinySrc, {base: 'pub'})
.pipe(gulp.dest(dest.dist));

return gulp
.src(src.pub.concat(['!' + tinySrc, dest.dist + 'js/' + minFilename]), {base: 'pub/'})
.pipe(gulpif(isMini, concat(minFilename)))
.pipe(gulpif(isUgly, uglify()))
.pipe(gulp.dest(dest.dist + 'js'));

});

gulp.task('build:assets', function(){

gulp
.src(src.styles, {base: 'src/'})
.pipe(change(changeCSS))
.pipe(gulp.dest(dest.dist));

return gulp
.src(src.assets, {base: 'src/'})
.pipe(gulp.dest(dest.dist));

});

gulp.task('build:scripts', function(cb){

runSequence('scripts:immutable', 'scripts:build', cb);

});

gulp.task('scripts:immutable', function(){

//feedback

gulp
.src(feedbackSrc)
.pipe(gulpif(isUgly, uglify()))
.pipe(gulp.dest(dest.dist + feedbackPath));

//boot.js

gulp
.src(src.boot)
.pipe(gulpif(isUgly, uglify()))
.pipe(gulp.dest(dest.dist + 'js'));

//workers dir

return gulp
.src(workersSrc)
.pipe(gulpif(isUgly, uglify()))
.pipe(gulp.dest(dest.dist + workersPath));

});

gulp.task('scripts:build', function(){

return gulp
.src(src.scripts.concat(dest.dist + 'js/' + minFilename))
.pipe(gulpif(isMini, concat(minFilename)))
.pipe(gulpif(isUgly, uglify()))
.pipe(gulp.dest(dest.dist + 'js'));

});

gulp.task('build:manifest', function(){

var files = [

dest.dist + '*',
dest.dist + '*/*',
dest.dist + '*/*/*',
'!' + dest.dist + 'fonts/*',
'!' + dest.dist + 'js/feedback/embedded.js'

];

gulp
.src(files, {base: dest.dist})
.pipe(manifest({

base: dest.dist,
filename: 'manifest.appcache',
exclude: 'manifest.appcache',
prefix: '/',
hash: true,
timestamp: true,
network: ['*'],

}))
.pipe(gulp.dest(dest.dist))

});

gulp.task('build', function(cb){

runSequence('build:scripts', 'build:pub', 'build:assets', 'build:manifest', cb);

});

gulp.task('watch', function(){

gulp.watch(['src/**'], ['build']);

});

gulp.task('default', function(){

return runSequence('clean:dest', 'build', 'connect', 'watch');

});

gulp.task('connect', function(){

if(serverConfig.https){

serverConfig.https.cert = fs.readFileSync(serverConfig.https.cert);
serverConfig.https.key = fs.readFileSync(serverConfig.https.key);

}

connect.server(extend(serverConfig, {

middleware: function(){

return [ function(req, res, cb){

for(var h in serverConfig.headers) res.setHeader(h, serverConfig.headers[h]);

if(req.method.toUpperCase() === 'OPTIONS'){ //CORS

var reqHeaders = req.headers['access-control-request-headers'], reqMethod = req.headers['access-control-request-method'];;
if(reqHeaders) res.setHeader('Access-Control-Allow-Headers', reqHeaders);
if(reqMethod) res.setHeader( 'Access-Control-Allow-Method', reqMethod);
res.statusCode = 204;
res.end();
return;

}

res.setHeader('Cache-Control', 'no-cache');
if(req.url.indexOf('?') >= 0) req.url = req.url.substr(0, req.url.indexOf('?'));
if(!fs.existsSync(serverConfig.root + req.url)) req.url = '/';
cb();

}];

}

}));

});

function changeCSS(content){

return content.replace(/url\([^\w\/]*\//g, 'url(http' + (serverConfig.https ? 's' : '') + '://' + serverConfig.host + (serverConfig.port ? ':' + serverConfig.port + '/' : '/'));

}
36 changes: 36 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "safe-frontend",
"license": "MIT",
"private": false,
"dependencies": {
"del": "latest"
},
"scripts": {
"start": "gulp"
},
"devDependencies": {
"gulp": "3.9.1",
"gulp-change": "^1.0.0",
"gulp-concat": "latest",
"gulp-connect": "latest",
"gulp-if": "^2.0.2",
"gulp-manifest": "latest",
"gulp-uglify": "latest",
"run-sequence": "^2.2.1"
},
"description": "Safe.ad Frontend",
"version": "1.7.1",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/safead/front.git"
},
"keywords": [
"safe.ad mail, email, secure, encrypted, file, storage, free, safe, p2p, end-to-end, cloud, new, decentralized"
],
"author": "Safe Communications S.L.",
"bugs": {
"url": "https://github.com/safead/front/issues"
},
"homepage": "https://github.com/safead/front#readme"
}
Loading

0 comments on commit 77b20a9

Please sign in to comment.