diff --git a/.babelrc b/.babelrc index dfcc787..af15b9e 100644 --- a/.babelrc +++ b/.babelrc @@ -4,8 +4,8 @@ "env", { "targets": { - "browsers": ["last 2 versions"], - "node": "current" + "browsers": "> 5%", + "node": "4.1.1" }, "debug": true } diff --git a/README.md b/README.md index fee38c3..a45e8b5 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ Additionally, due to quirks in the `rust-wasm-loader` you will need to adjust th ```javascript // Install dependencies yarn +// Install submodules +git submodule update --init --recursive // Build for web yarn web -- --env.path=serving/path/here/ ``` @@ -30,12 +32,12 @@ The below command will build a file called `mam.node.js` in the `lib/` directory ```javascript // Install dependencies yarn +// Install submodules +git submodule update --init --recursive // Build for node yarn node ``` - - ## Concepts #### Security Levels @@ -45,3 +47,6 @@ Public - Root is equal to address and the side key is ‘999999…’ Private - WIP Restricted - WIP + + + diff --git a/example/index.js b/example/index.js index c141152..71c5844 100644 --- a/example/index.js +++ b/example/index.js @@ -1,6 +1,6 @@ -var Mam = require('../static/mam.node.js') +var Mam = require('../lib/mam.node.js') var IOTA = require('iota.lib.js') -var iota = new IOTA({ provider: `http://p101.iotaledger.net:14700/` }) +var iota = new IOTA({ provider: `http://p103.iotaledger.net:14700/` }) const example = async () => { // Init State diff --git a/lib/mam.node.js b/lib/mam.node.js index c77d557..1924180 100644 --- a/lib/mam.node.js +++ b/lib/mam.node.js @@ -9130,7 +9130,7 @@ function getMamRoot(SEED, CHANNEL) { } function createMessage(SEED, MESSAGE, SIDE_KEY, CHANNEL) { - if (!SIDE_KEY) SIDE_KEY = '999999999999999999999999999999999999999999999999999999999999999999999999999999999'; + if (!SIDE_KEY) SIDE_KEY = `999999999999999999999999999999999999999999999999999999999999999999999999999999999`; // MAM settings var SEED_trits = string_to_ctrits_trits(SEED); var MESSAGE_trits = string_to_ctrits_trits(MESSAGE); @@ -9175,7 +9175,7 @@ function createMessage(SEED, MESSAGE, SIDE_KEY, CHANNEL) { } function decodeMessage(PAYLOAD, SIDE_KEY, ROOT) { - if (!SIDE_KEY) SIDE_KEY = '999999999999999999999999999999999999999999999999999999999999999999999999999999999'; + if (!SIDE_KEY) SIDE_KEY = `999999999999999999999999999999999999999999999999999999999999999999999999999999999`; var PAYLOAD_trits = string_to_ctrits_trits(PAYLOAD); var SIDE_KEY_trits = string_to_ctrits_trits(SIDE_KEY); @@ -9302,7 +9302,7 @@ var create = function create(state, message) { channel.next_root = mam.next_root; state.channel = channel; return { - state: state, + state, payload: mam.payload, root: mam.root }; @@ -19446,10 +19446,10 @@ function decrypt(message, key, salt) { } module.exports = { - encrypt: encrypt, - decrypt: decrypt, - increment: increment, - hash: hash + encrypt, + decrypt, + increment, + hash }; /***/ }), diff --git a/lib/mam.web.js b/lib/mam.web.js index 3c4b4f2..9bb5b14 100644 --- a/lib/mam.web.js +++ b/lib/mam.web.js @@ -22152,7 +22152,7 @@ wasm.initialize({ noExitRuntime: true }).then(function (IOTA) { } function createMessage(SEED, MESSAGE, SIDE_KEY, CHANNEL) { - if (!SIDE_KEY) SIDE_KEY = '999999999999999999999999999999999999999999999999999999999999999999999999999999999'; + if (!SIDE_KEY) SIDE_KEY = `999999999999999999999999999999999999999999999999999999999999999999999999999999999`; // MAM settings var SEED_trits = string_to_ctrits_trits(SEED); var MESSAGE_trits = string_to_ctrits_trits(MESSAGE); @@ -22197,7 +22197,7 @@ wasm.initialize({ noExitRuntime: true }).then(function (IOTA) { } function decodeMessage(PAYLOAD, SIDE_KEY, ROOT) { - if (!SIDE_KEY) SIDE_KEY = '999999999999999999999999999999999999999999999999999999999999999999999999999999999'; + if (!SIDE_KEY) SIDE_KEY = `999999999999999999999999999999999999999999999999999999999999999999999999999999999`; var PAYLOAD_trits = string_to_ctrits_trits(PAYLOAD); var SIDE_KEY_trits = string_to_ctrits_trits(SIDE_KEY); @@ -22248,7 +22248,7 @@ var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var m }); } } - })({"wasmBinaryFile":"lib/iota-bindings-emscripten.wasm","ENVIRONMENT":"WEB"}) + })({"wasmBinaryFile":"/iota-bindings-emscripten.wasm","ENVIRONMENT":"WEB"}) /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(41), __webpack_require__(6).Buffer)) /***/ }), @@ -31862,7 +31862,7 @@ var create = function create(state, message) { channel.next_root = mam.next_root; state.channel = channel; return { - state: state, + state, payload: mam.payload, root: mam.root }; @@ -42008,10 +42008,10 @@ function decrypt(message, key, salt) { } module.exports = { - encrypt: encrypt, - decrypt: decrypt, - increment: increment, - hash: hash + encrypt, + decrypt, + increment, + hash }; /***/ }), diff --git a/webpack.config.js b/webpack.config.js index d892b17..7201f8b 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -5,12 +5,12 @@ const UglifyJsPlugin = webpack.optimize.UglifyJsPlugin const path = require('path') const env = require('yargs').argv.env // use --env with webpack 2 -let output = env.path !== undefined ? env.path : 'lib/' -let libraryName = 'mam.' -let entry -let target -let outputFile -let rules = [ +var output = env.path !== undefined ? env.path : 'lib/' +var libraryName = 'mam.' +var entry +var target +var outputFile +var rules = [ { test: /(\.jsx|\.js)$/, loader: 'babel-loader',