Skip to content

Commit

Permalink
Fixing an invalid rejection
Browse files Browse the repository at this point in the history
  • Loading branch information
jakiestfu committed Aug 3, 2016
1 parent e300cc3 commit 0513b75
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
*.log
ssl/*.pem
11 changes: 11 additions & 0 deletions Gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@
const babel = require('rollup-plugin-babel');
const eslint = require('gulp-eslint');
const gulp = require('gulp');
const header = require('gulp-header');
const minify = require('uglify-js').minify;
const rollup = require('rollup-stream');
const source = require('vinyl-source-stream');
const uglify = require('rollup-plugin-uglify');

const pkg = require('./package.json');
const banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' */',
''].join('\n');

gulp.task('build', () =>
rollup({
entry: './lib/postmate.js',
Expand All @@ -20,6 +30,7 @@ gulp.task('build', () =>
],
})
.pipe(source('postmate.min.js'))
.pipe(header(banner, { pkg }))
.pipe(gulp.dest('./build'))
);

Expand Down
8 changes: 7 additions & 1 deletion build/postmate.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lib/postmate.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ Postmate.Handshake = class Handshake {
log('Parent: Saving Child origin', this.childOrigin);
return resolve(new ComsumerAPI(this));
}

// Might need to remove since parent might be receiving different messages
// from different hosts
log('Parent: Invalid handshake reply');
return reject('Failed handshake');
};
Expand Down
15 changes: 10 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{
"name": "postmate",
"version": "0.2.2",
"version": "0.3.0",
"description": "A powerful, simple, promise-based postMessage library",
"main": "lib/postmate.js",
"devDependencies": {
"babel-preset-es2015-rollup": "^1.1.1",
"eslint-config-airbnb": "^9.0.1",
"eslint-plugin-import": "^1.12.0",
"express": "^4.14.0",
"gulp": "^3.9.1",
"gulp-eslint": "^3.0.1",
"gulp-header": "^1.8.7",
"rollup-plugin-babel": "^2.6.1",
"rollup-plugin-uglify": "^1.0.1",
"rollup-stream": "^1.11.0",
Expand All @@ -17,11 +19,14 @@
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"serve-parent": "python -m SimpleHTTPServer 4000",
"serve-child": "python -m SimpleHTTPServer 4001",
"serve-parent": "PORT=4000 node sandbox.js",
"serve-child": "PORT=4001 node sandbox.js",
"build": "gulp build",
"build-watch": "gulp build-watch",
"lint": "gulp lint"
"lint": "gulp lint",
"postpublish": "PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') && git tag $PACKAGE_VERSION && git push origin --tags",
"ssl-gen-cert": "openssl req -x509 -newkey rsa:2048 -keyout ./ssl/key.pem -out ./ssl/cert.pem -days 365",
"ssl-move-pass": "openssl rsa -in ./ssl/key.pem -out ./ssl/new-key.pem && mv ./ssl/new-key.pem ./ssl/key.pem"
},
"repository": {
"type": "git",
Expand All @@ -38,5 +43,5 @@
"bugs": {
"url": "https://github.com/dollarshaveclub/postmate/issues"
},
"homepage": "https://github.com/dollarshaveclub/postmate#readme"
"homepage": "https://github.com/dollarshaveclub/postmate"
}
24 changes: 24 additions & 0 deletions sandbox.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
const path = require('path');
const fs = require('fs');
const https = require('https');
const express = require('express');

// Options
const app = express();
const port = process.env.PORT || 4000;
const useSSL = fs.existsSync(path.join(__dirname, 'ssl', 'cert.pem'));
const staticPath = (folder) => express.static(path.join(__dirname, folder));

// Routes
app.use('/sandbox', staticPath('sandbox'));
app.use('/build', staticPath('build'));

// http://blog.mgechev.com/2014/02/19/create-https-tls-ssl-application-with-express-nodejs/
if (useSSL) {
https.createServer({
key: fs.readFileSync(path.join(__dirname, 'ssl', 'key.pem')),
cert: fs.readFileSync(path.join(__dirname, 'ssl', 'cert.pem')),
}, app).listen(port, () => console.log(`Sandbox served at https://localhost:${port}`));
} else {
app.listen(port, () => console.log(`Sandbox served at http://localhost:${port}`));
}
Empty file added ssl/.gitkeep
Empty file.

0 comments on commit 0513b75

Please sign in to comment.