Skip to content

Commit a2ad8f8

Browse files
committed
fixed import and use precise versions
1 parent 47167e3 commit a2ad8f8

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

lib/message.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const prepareTransfers = require('@iota/core').createPrepareTransfers()
22

33
const converter = require('@iota/converter')
4-
const add = require('@iota/signing/out/signing/src/add').default
4+
const add = require('@iota/signing').add
55
const Kerl = require('@iota/kerl').default
66
const {intToTrytes, trytesToInt, concat, padTritsMultipleOf, padTrytesMultipleOf, alphabet} = require('./helpers')
77
const {encrypt, decrypt} = require("./encrypt")
@@ -12,7 +12,8 @@ const SECURITY_TRYTES = 1
1212
const HEIGHT_TRYTES = 1
1313
const PREFIX_LENGTH = INDEX_TRYTES + MESSAGE_LENGTH_TRYTES + SECURITY_TRYTES + HEIGHT_TRYTES
1414

15-
const MESSAGE_FRAGMENT_TRYTES = 2187
15+
const MESSAGE_FRAGMENT_TRYTES = 2187;
16+
const SIGNATURE_TRYTES_PER_SECURITY = 2187;
1617

1718
const Errors = {
1819
INVALID_LENGTH: `The message cannot be longer than ${Math.pow(27, MESSAGE_LENGTH_TRYTES)} trytes.`,
@@ -113,7 +114,7 @@ async function sendMessage(iota, merkleRoot, message, sig, index, verifyingKey,
113114
async function sendTransfers(iota, transfers, {message, depth = 3, mwm = 14} = {}) {
114115
const trytes = await prepareTransfers("9".repeat(81), transfers)
115116
const bundle = await iota.sendTrytes(trytes, depth, mwm)
116-
return {bundle, message}
117+
return {bundle, message}
117118
}
118119

119120
function getKey(merkleRoot, channelPassword, indexTrits, messagePassword) {
@@ -253,10 +254,13 @@ function processBundle(index, txs, key, {height, security} = {}) {
253254
result.nextRoot = converter.trits(decrypted.slice(endHashes, endHashes + nextRootLength))
254255

255256
// extract signature
256-
result.signature = new Int8Array(result.security * MESSAGE_FRAGMENT_TRYTES * 3)
257+
result.signature = new Int8Array(result.security * SIGNATURE_TRYTES_PER_SECURITY * 3)
258+
let remaining = result.signature.length
257259
for (let i = payloadTransactions; i < txs.length; i++) {
258-
result.signature.set(converter.trits(txs[i].signatureMessageFragment),
260+
const frag = converter.trits(txs[i].signatureMessageFragment)
261+
result.signature.set(remaining >= MESSAGE_FRAGMENT_TRYTES * 3 ? frag : frag.slice(0, remaining),
259262
(txs[i].currentIndex - payloadTransactions) * MESSAGE_FRAGMENT_TRYTES * 3)
263+
remaining -= MESSAGE_FRAGMENT_TRYTES * 3
260264
}
261265

262266
return result

package.json

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "raam.client.js",
3-
"version": "0.7.3",
3+
"version": "0.7.4",
44
"description": "A messaging protocol for the IOTA tangle allowing access of arbitrary messages in O(1)",
55
"keywords": [
66
"iota",
@@ -29,13 +29,24 @@
2929
"docs": "jsdoc2md -t jsdoc2md/api.hbs lib/raam.js lib/raamReader.js > docs/api.md"
3030
},
3131
"dependencies": {
32-
"@iota/core": "^1.0.0-beta.11",
33-
"@iota/signing": "^1.0.0-beta.11",
34-
"@iota/validators": "^1.0.0-beta.11",
32+
"@iota/core": "1.0.0-beta.11",
33+
"@iota/validators": "1.0.0-beta.11",
34+
"@iota/bundle": "1.0.0-beta.11",
35+
"@iota/bundle-validator": "1.0.0-beta.11",
36+
"@iota/checksum": "1.0.0-beta.11",
37+
"@iota/converter": "1.0.0-beta.11",
38+
"@iota/curl": "1.0.0-beta.11",
39+
"@iota/http-client": "1.0.0-beta.11",
40+
"@iota/kerl": "1.0.0-beta.11",
41+
"@iota/pad": "1.0.0-beta.11",
42+
"@iota/signing": "1.0.0-beta.11",
43+
"@iota/transaction": "1.0.0-beta.11",
44+
"@iota/transaction-converter": "1.0.0-beta.11",
3545
"zeromq": "^5.1.0"
3646
},
3747
"devDependencies": {
38-
"mocha": "^5.2.0",
39-
"jsdoc-to-markdown": "^4.0.1"
48+
"jsdoc-to-markdown": "^4.0.1",
49+
"marked": "^0.6.2",
50+
"mocha": "^5.2.0"
4051
}
4152
}

0 commit comments

Comments
 (0)