Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

20 changes: 7 additions & 13 deletions builds/browser/es5/jsonrpc.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion builds/browser/es5/jsonrpc.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const objExports = {};
// Do not use const here, webpack/babel issues.
var objExports = {};

objExports.Client = require("./src/Client");
objExports.ClientPluginBase = require("./src/ClientPluginBase");
Expand Down
3 changes: 2 additions & 1 deletion index_webpack.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const objExports = {
// Do not use const here, webpack/babel issues.
var objExports = {
JSONRPC: require("./index")
};

Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
},
"dependencies": {
"crypto-js": "^3.1.9-1",
"jssha": "^2.2.0",
"node-fetch": "^1.6.3",
"sleep-promise": "2.0.0",
"ws": "^2.2.3"
},
"devDependencies": {
Expand All @@ -47,14 +47,15 @@
"babel-eslint": "*",
"babel-loader": "*",
"babel-plugin-async-to-promises": "*",
"babel-plugin-transform-runtime": "*",
"babel-plugin-remove-comments": "*",
"babel-polyfill": "*",
"babel-preset-es2015": "*",
"babel-preset-stage-3": "*",
"babel-runtime": "*",
"eslint": "*",
"eslint-plugin-jsdoc": "*",
"phantom": "^4.0.2",
"webpack": "*"
"webpack": "*",
"sleep-promise": "*"
}
}
6 changes: 5 additions & 1 deletion src/Plugins/Client/SignatureAdd.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const JSONRPC = {};
JSONRPC.ClientPluginBase = require("../../ClientPluginBase");

// const JSSHA = require("jssha");
const HMAC_SHA256 = require("crypto-js/hmac-sha256");


/**
* This has purpose at Bigstep (the company which originally created this project).
* It is intended to be used only together with Bigstep extending API clients.
Expand Down Expand Up @@ -58,6 +58,10 @@ class SignatureAdd extends JSONRPC.ClientPluginBase
*/
async afterJSONEncode(outgoingRequest)
{
/*const sha = new JSSHA("SHA-256", "TEXT");
sha.setHMACKey(this.strAPIKey, "TEXT");
sha.update(outgoingRequest.requestBody);
let strVerifyHash = sha.getHMAC("HEX");*/
let strVerifyHash = HMAC_SHA256(outgoingRequest.requestBody, this.strAPIKey);

if(this.strKeyMetaData !== null)
Expand Down
3 changes: 2 additions & 1 deletion src/Plugins/Client/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const objExports = {};
// Do not use const here, webpack/babel issues.
var objExports = {};

objExports.DebugLogger = require("./DebugLogger");
objExports.PrettyBrowserConsoleErrors = require("./PrettyBrowserConsoleErrors");
Expand Down
3 changes: 2 additions & 1 deletion src/Plugins/Server/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const objExports = {};
// Do not use const here, webpack/babel issues.
var objExports = {};

objExports.DebugLogger = require("./DebugLogger");
objExports.AuthenticationSkip = require("./AuthenticationSkip");
Expand Down
9 changes: 6 additions & 3 deletions tests/AllTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const url = require("url");
const path = require("path");
const fs = require("fs");

const sleep = require("sleep-promise");
//const sleep = require("sleep-promise");

const Phantom = require("phantom");

Expand Down Expand Up @@ -222,6 +222,7 @@ class AllTests
(
objParsedURL.pathname.substr(0, "/tests/".length) === "/tests/"
|| objParsedURL.pathname.substr(0, "/builds/".length) === "/builds/"
|| objParsedURL.pathname.substr(0, "/node_modules/".length) === "/node_modules/"
)
&& incomingRequest.method === "GET"
&& !objParsedURL.pathname.includes("..")
Expand All @@ -236,6 +237,8 @@ class AllTests
}
else if(url.parse(incomingRequest.url).pathname.substr(0, 4) !== "/api")
{
console.error("[" + process.pid + "] Could not find static HTTP file: " + strFilePath);

serverResponse.statusCode = 404;
serverResponse.end();
}
Expand Down Expand Up @@ -901,7 +904,7 @@ class AllTests

console.log(
await phantomPage.evaluate(
function () {
function() {
return window.arrErrors;
}
)
Expand All @@ -923,7 +926,7 @@ class AllTests
//phantom.process.stdout.pipe(process.stdout);
//phantom.process.stderr.pipe(process.stderr);

const strContent = await phantomPage.property("content");
//const strContent = await phantomPage.property("content");
//console.log(strContent);


Expand Down
2 changes: 1 addition & 1 deletion tests/Browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

client.rpc("ping", ["Calling from html es5 client."])
.then(function(result){arrErrors.push(result)})
.catch(function(error){arrErrors.psuh(error)})
.catch(function(error){arrErrors.push(error)})
;
}
);
Expand Down
133 changes: 97 additions & 36 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,102 @@
const path = require("path");
const fs = require("fs");
const webpack = require("webpack");

module.exports = {
entry: [
"babel-polyfill",
"./index_webpack"
],
output: {
path: path.join(__dirname, "builds", "browser", "es5"),
filename: "jsonrpc.js",
libraryTarget: "umd"
},
devtool: "source-map",
module: {
loaders: [
{
test: /\.js$/,
include: [
path.resolve(__dirname, "src")
],
exclude: [
path.resolve(__dirname, "node_modules"),
path.resolve(__dirname, "tests")
],
loader: "babel-loader",
options: {
presets: ["es2015", "stage-3"],
plugins: ["async-to-promises"]
const objPackageJSON = JSON.parse(fs.readFileSync("package.json"));

module.exports = [
{
target: "web",
externals: {
// Map require("something) to global variable Something.
// "something": "Something"
//"node-fetch": "fetch",
//"es6-promise": "Promise"
},
entry: [
"babel-polyfill",
"./index_webpack"
],
output: {
path: path.join(__dirname, "builds", "browser", "es5"),
filename: "jsonrpc.js",
libraryTarget: "umd"
},
devtool: "source-map",
module: {
loaders: [
{
test: /\.js$/,
include: [
path.resolve(__dirname, "src")
],
exclude: [
path.resolve(__dirname, "node_modules"),
path.resolve(__dirname, "tests")
],
loader: "babel-loader",
options: {
presets: ["es2015", "stage-3"],
plugins: [
"async-to-promises",
"remove-comments"
],
babelrc: false
}
}
]
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
minimize: true,
sourceMap: true,
compress: { screw_ie8: true },
mangle: { screw_ie8: true },
output: {
screw_ie8: true,
comments: false,
preamble: `/**
${objPackageJSON.name} v${objPackageJSON.version}
${objPackageJSON.description}
${objPackageJSON.homepage}
${objPackageJSON.homepage}/blob/master/LICENSE
*/`.replace(/\t+/g, "\t")
}
}
})
]
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
minimize: true,
sourceMap: true
})
]
};
//test
}/*,
{
target: "web",
entry: [
"./index_webpack"
],
output: {
path: path.join(__dirname, "builds", "browser", "es7"),
filename: "jsonrpc.js",
libraryTarget: "umd"
},
devtool: "source-map",
module: {
loaders: [
{
test: /\.js$/,
include: [
path.resolve(__dirname, "src")
],
exclude: [
path.resolve(__dirname, "node_modules") + "/",
path.resolve(__dirname, "tests")
],
loader: "babel-loader",
options: {
plugins: ["remove-comments"],
babelrc: false
}
}
]
},
plugins: [
]
}*/
];