{"_id":"mesg-js","_rev":"84-58e00425c046e03c0848b6dab00477da","name":"mesg-js","dist-tags":{"latest":"5.0.0","beta":"5.0.0-beta.1"},"versions":{"1.0.0":{"name":"mesg-js","version":"1.0.0","description":"## Services","main":"lib/index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"grpc":"^1.12.2","js-yaml":"^3.12.0"},"gitHead":"f72e2d0bc736db11c5a8865c647be491dd1031b7","_id":"mesg-js@1.0.0","_npmVersion":"5.4.1","_nodeVersion":"8.4.0","_npmUser":{"name":"anthony-mesg","email":"anthony@mesg.tech"},"dist":{"integrity":"sha512-Lt0n0H8OXqRqMngc8LKqCB5NJ9XNJfR0G+tA0eZVpPNHpbP4o7jXpBdMTnU6VFNyhkvaVZopOOSfK33gvd6FPQ==","shasum":"5ac55dd091e2cfd52a36597552c8a35efe5f111c","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-1.0.0.tgz","fileCount":8,"unpackedSize":5015,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbGCWbCRA9TVsSAnZWagAAbN0QAJPaBwT0lhMK3TEcc2Zk\nbxUCzyPslyblHKjGCmdyU/BHid1FaOKConv7szvjN66LwlQGBmyFPbR0IlAU\nhIpNyg35ylKwQLcKwdS/8gBfDl6Me4+SwX26XqHRfk1ZzMGTmWK+emIfmjTy\nu48gNiZrAdVnOCLkLIybMURHANhOA2EF/+XXDqdhs4gVJpk0VvzMkN/oKQqH\nBBCwYRjdlXI3ENP0hG4LRxOD4IMlGMWrlOIioPwqXJdLSMBqETQRvxv9VWwh\n8wKzgYYO4HvfnYpMtxysFwbGky8UrtvnEJ9ttn90FQoc36eZfQBdJPKOUmlm\nw7VJDjUurt+71Qf319NJsi3lOMazbYyt+qCAWxYfSMvp9sBlnHdNWXnvnb+f\nOmhsuQDDs+l7otkHAlOn4uEQirvg5ssGzeTOn98zYfZn2R91EaCW3iaXUk8Z\nDvS0RyI1xcntLwqEQzC3SPuXBot+7TXAxaMtXoL5HZxh2rkjmDdCX9dSwc+M\nQMmhYM3tghI+8ayRdTxnpgA7qBrz0pvozhnmDwrMO1ljxRcuzmYnWI4u87zJ\niOXjHbGcy1Ss4lrT98EPap9WI0pExgUVPbBtHu6aNB3HEGOssyv/958nPgHT\n9VP0/hV9aZ75JGpN4MkUTbeQDyiZAgeEdGIz6RB4qsq/FkhZPO7sQNGc7RaM\nXwIN\r\n=l615\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDuRIs+OWkeUwHlktF1kMX6EErpGR2t4UFOxoEMrea9dwIhAI8/S3v4SaynCb8dUqR0AAW/MaAL06D8nborHxDkVKBN"}]},"maintainers":[{"name":"anthony-mesg","email":"anthony@mesg.tech"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_1.0.0_1528309146857_0.5944649742390968"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"},"1.1.0":{"name":"mesg-js","version":"1.1.0","description":"## Services","main":"lib/index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"grpc":"^1.12.2","js-yaml":"^3.12.0"},"gitHead":"3a04d5592e732b2dad13f3c31ec8b8300f845ea2","_id":"mesg-js@1.1.0","_npmVersion":"5.4.1","_nodeVersion":"8.4.0","_npmUser":{"name":"anthony-mesg","email":"anthony@mesg.tech"},"dist":{"integrity":"sha512-GIhgu4iuGUJL8Vb2orsrMFvtI+T79WHLxXMBkZuPbjpUWMBjM9QbmV4OMzWka17IfYCKlSQiXhEgAHitkQxDjQ==","shasum":"7d9eaa01a762b362a211d915b0f35541b4a14c86","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-1.1.0.tgz","fileCount":16,"unpackedSize":9204,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbGGsKCRA9TVsSAnZWagAABJoP/j05smzSVmn6DDgdX6E0\n7XptPzpMHAzcu3V8JAPAotmVsQeUadIgf4PCX8/WDAZi1kVr8fSpoct/djE5\neHjQWm0kmQ05KApWfXrJOxlnym6OqjjOMrpScW9bWxEuzuvRzgDS3thjONQ7\noMbfg6XgdR0+UnCHEe+QEYSv2d0WElvaq3GDRivD4RW2/BT0McsLW/c2d9kn\nVssScnvG1buBi/YyH2LuykPZJJNrYeM1JHI806L5LYq05Fn0QYqcg7Pjjxxj\n9fEBl+rhPwBWqaTbzoQdbLoPbiFhXo9DtT/noinx0SxYFz9u9XmDRnFucon6\nReTiWS41oK8KnaLSNmZS+pdDnzKHT6uUGCsU3cLKitV7ecWoJjKUUmYmooq/\n9XkCykgTXLigbw8TRP1vQFXNP898Qgk3vMPJqos9xSi5ehwguaYMuwexHb1V\nl+2O5r4dgZTHoSewMq5n+b/dgvq0ZpUtJd06y0iD8TKqrRDzLFZOMto3eA9T\nN04GY6E90nAzolBYN+so3YrBlx8QCqj9v2Ga4Ryoo8FXFbqML8QzOHPt/kdi\neIYdj7AW37EsHpF0A1QzMjJ9m5gCOL7jT5SlLbHmsh/APhZONCES+CH0fhs+\nbBgZVESjAUMf+teWbp5Fy7be0HymWEc3QzKlg5b+lOaR+CSfGyV9ortT9Eo1\nvZxS\r\n=Bvl6\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDwGAeCkneZ6Ca4HYaugcpEhDb13vYZLX4ZO0DaMlu0jwIhAPhSLNIxc/dSLgcr/x+5/DXQImkZIYIWS1kSJzD0JM85"}]},"maintainers":[{"name":"anthony-mesg","email":"anthony@mesg.tech"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_1.1.0_1528326921641_0.9135674585915603"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"},"1.1.1":{"name":"mesg-js","version":"1.1.1","description":"## Installation","main":"lib/index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"grpc":"^1.12.2","js-yaml":"^3.12.0"},"gitHead":"29a38ce83b8674258b5df6102d1c99f556c5c4fd","_id":"mesg-js@1.1.1","_npmVersion":"5.4.1","_nodeVersion":"8.4.0","_npmUser":{"name":"anthony-mesg","email":"anthony@mesg.tech"},"dist":{"integrity":"sha512-71OPxURZNDz9vpcKUCCWdhgXfaAkkXTKP/n58rsaoxLyU+rsW2DqafCnNZgSVei7crg/hf2xc6e4T4INQzMZ0Q==","shasum":"bbee4a9fad6bcaf95035ddbf0c7ba3c340868498","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-1.1.1.tgz","fileCount":16,"unpackedSize":10243,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbHIHQCRA9TVsSAnZWagAAq0QP/Rt6V4mo59SwC1h8SEnf\n/vYqy7+UlDymor1PLrXuSRVKzL7FcfZWK+DjZvCpW/f561Pkw8N1enMMLGDk\nGXj4Dkz6mVh1HFmXmEsQsVNQ9igndMV/opWKdwzC4ditwzWvvRJfdDHoKuCE\nsGC9/tAO1PuIo4+y41VGxhtQtiR95uN42nB5xsuNOAohA3v0zYEN20wh/0kY\neyoV28rB7gICqc/ZxJMA2OM2M8Bwyj8dUmfZx2hdzG9/XluNDsmSU65mr9vK\nhYY5JgRsDovEaGTrGt4FVdGz0mgQ8t8m5xQD/c8oTeHxoz6o38I7kTRXwRBj\nFnJtcVpJYfszjaJHkIMmpBEz0zeRSBOSmy9Vp1qN83wurV+cDWzzKJ+9YGnd\nic1eYpMVnxc1DOLTB4rUZYCBjdTQ3i5fklmMxWJoCnkZJGtu1wclwY+XCfk2\n3Nckw/Gpo75hcomblQ6mKHDEow9yD8gmgobqjRVuWvpnGqXRKNttQIoH8y1q\nruKO+DA4qvru8hcb/FLfmGLwuOd+wBpATiDnBmeJ6vc7gMOdwmPJ0BYW6Z9q\nSqp2B3AQIxi4BBy51FzjOwS9OGc3JusUZ2Bzf/xBvbwv6VNLN4E2PpA53xjA\nqbmRQnyaZWV8oUydaiiRwYRdXJASKLUbp5+Rh/Gh2S2gy/9HvEJCVsQGYLlA\niymo\r\n=0rLW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCLyEDVVdILJEtymkb2YgV+WkZW0bCwUkR/MAansBHzyAIgFWO4DiTaH/9yr/2XeEW4WcteIql/ROXfyoL5jbIAS9I="}]},"maintainers":[{"name":"anthony-mesg","email":"anthony@mesg.tech"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_1.1.1_1528594895790_0.7578009163387169"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"},"1.1.2":{"name":"mesg-js","version":"1.1.2","description":"## Installation","main":"lib/index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"grpc":"^1.12.2","js-yaml":"^3.12.0"},"gitHead":"b81a1740dbf66550e16c8cf1382f0fd930481133","_id":"mesg-js@1.1.2","_npmVersion":"5.4.1","_nodeVersion":"8.4.0","_npmUser":{"name":"anthony-mesg","email":"anthony@mesg.tech"},"dist":{"integrity":"sha512-ueWhpbJRi7NDdBOxXd87cxKXy5fSEhpoxnoENLcvGzSg9gpvf3ziOGr0V6zSCPpK3mjIjZ9KJr0iW8dGOBSKHg==","shasum":"206807375779f4c73af83a8e1c9f4f40e1ea33b0","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-1.1.2.tgz","fileCount":16,"unpackedSize":10325,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbIUSdCRA9TVsSAnZWagAACzQP+QBhX/UA/+IEtmjRuVuX\n7bKihU5GBXxfhAEMaANeA4BwzLFe/19YYJ0GucKFMZolr7yUMNvRmXCMgaPr\nexdqgUPLi+gCdoihO5vokDZtCOb2+hEI4v089DkLOor3b+YiMyCJSd0TmCJz\nngGmumg+BKBMM3ZviB/OcR0kiKMb8dZf3J5hKa/tZYm8D+m8ho3pWQzMX4K/\nTIl0IM+Fg6JpMUwhP8er3H1Z7fMWtSg60LfxX6ZpD3YNXqmzaSRjRx1L9812\nFWxYB8Zen95wpiPkkSyswWLaPMOEld8Kyn234WS/xiieufnMUbuIrZOw03/2\nHrzquto65WUROnbN4kmnMq3Rfd0c7huskxJZdbYH+x7lSVkBLZ+CzvmTVCib\n/qikUCD/exuAJ6yQ8+fh5ZFUl2HGj5sUpyRSBpEwUo3H+Lzd8O8ItyjQctLs\nEpeZNRrKHpA41fQqhRfi6p2edCaXMcyG3onhg53CD3PZoEb+zpbOtT5zS4JG\no84Xw9Ji1J8d/hrH180+SqIL3Kx9XuFb3vuXOiB/+MrlPly+mXma5RxP34K9\n/1iTE+Us7Nt1IVZy0WOEcdTpzzBEu/wG/MJk7R+/V4KOwhZmtNgXyNeVWmgm\nBGFkyCZQib8gukX3jSeYQoy0a/CnDJlJxxoVGEAyKZ5IPSEo6l33dN5Bykhk\nnZNU\r\n=/o9b\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD25JCHxXxb92oXMMnFZHRdc3HQI+LWfOjat2ORyswE/wIgKSlq9KulDwHRaegyfSXEeSHqxjHQ3IRuP/h6WqmINDE="}]},"maintainers":[{"name":"anthony-mesg","email":"anthony@mesg.tech"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_1.1.2_1528906908993_0.6378370096276158"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"},"1.2.0":{"name":"mesg-js","version":"1.2.0","description":"## Installation","main":"lib/index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"grpc":"^1.12.2","js-yaml":"^3.12.0"},"gitHead":"eddc147d7289bb604b8ad850843721c6d4113c63","_id":"mesg-js@1.2.0","_npmVersion":"5.4.1","_nodeVersion":"8.4.0","_npmUser":{"name":"anthony-mesg","email":"anthony@mesg.tech"},"dist":{"integrity":"sha512-qi5YPcXsGugyVRDymBBgcGsWYinRzjjGQl6PTQLW6g8wAu8GVeUPIkby+afYMrRAT8Yr1DueQJoSu+S9HclvSw==","shasum":"b189b2aa31e3eddecef362c3ec97a193804c680e","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-1.2.0.tgz","fileCount":16,"unpackedSize":10418,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbJiIBCRA9TVsSAnZWagAAKrwQAJdjP11lfYqmOKG0pMP2\nv/ShtKWMkgsoINfkajplDilRLTBlxMPLB1VJXybnsER12DVpIyH8Yi5N3LB5\n4HQSp0MJWxiP4q0IkvfeJ274wxlLKUNRdDVdpU1XiKkoP8mEmUw3Ypfqvn1r\narqHKE1AYNY383PU2nM6D+loC5B1oekr/WtbslV5g2WBzVM007qLsYh8XLNC\nHYW3WRvDPhJf0roixUOuAvtIwq3T7ytnMslyhuOFyVifMw+cL2oD2DdO7MpD\nK3Ow+o5+Fwzj+H0aUZFroHKjEYrMUiObNdZogu15uC96iY+onpixwnxSfqy1\n7o0cX9DhJqRTT0zOEQ3Y/JcVsrpQqzp5i+6GLMG+k5P2iZ4Y2x+GKurfmDIw\nvtGqAv+Pguophl6MbgRJlHZJJS3lcrJTSS5y2tEtLIRJFkzE1TLLF8idHIQ/\n27pz4oG3NxZZIAc+Eng/0XbV43bLZFjkzXkh9brAOyzkB5m/UIPlvwWn1LJ8\nIhpxo2Jt2ZyhQMJRmsZlwlomKNuZYbPK6JN+Y3E2Qd0xjI/hvlvVaLj2ndKA\nJ2IUz/KRc+fq+tyqHxTaTNDCcLbE7tl9A1BiBm7dlyA+TaGCy1Anfm1j1W9L\nkqLmEg6hi8ivrsILcmKv1KmrHOXz5kMG5Cud4kdgZZfdXzlkaIsLPFdE7cjx\nnOdk\r\n=Ko6A\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDlm6rWYVRE0DS+saRQHpf74HG0cZYlxn8KZ/dmZDPo1AiEAqmxESjv1Xgz9OrnfDnOKRifF6KcaIo3DEWp0AsGOA7M="}]},"maintainers":[{"name":"anthony-mesg","email":"anthony@mesg.tech"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_1.2.0_1529225728271_0.6935415567173937"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"},"1.2.1":{"name":"mesg-js","version":"1.2.1","description":"## Installation","main":"lib/index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"grpc":"^1.12.2","js-yaml":"^3.12.0"},"gitHead":"8a8d5d37fefbbe6ad5e4b190b95cc45958bcb516","_id":"mesg-js@1.2.1","_npmVersion":"6.1.0","_nodeVersion":"8.4.0","_npmUser":{"name":"anthony-mesg","email":"anthony@mesg.tech"},"dist":{"integrity":"sha512-WU1R+5cebY+Rt8aMEqrzR7dZHFDNY1kGEgfze2xcwJ5zhJlU3mv8P13ALpZay3znjnT2Qn27dsBTW2JeInkz0A==","shasum":"df67ac395ba3f08e0f870eb49c7ba9af69405140","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-1.2.1.tgz","fileCount":16,"unpackedSize":10653,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbKes3CRA9TVsSAnZWagAAYrkP/0lok0gA4k+L4PnCSDv4\nflUhxirsJACHs+EGf4ABVHHAWlpAev/Wlw+sBr15LSMVyPNFBkQQEE2tqfVE\nFtrrcBALpWq3BDqX1XRRD7ZibRi5qBmmBp9FpI/WPh2x1/Rs832DJAwYEvtb\nfwQyuOaW/RNVmW8OjwBr1bd4nHBwzgryKDsAFS2SdYL6DOAsaU6KVDVnpd0E\n1FHw8XXKh5OQyAygtB4/tQgqq7i1kQAjiaX/uJbBg1/p3GuHldpNSxNY7qRC\nxYaI0iCIMC6FKnFn5JWK9lP0ni8sJAS7Gbraa4wdk1vdHkL5Iqasmt1+ffNz\nvhChnmrHNqoKisaR4gslDwx9CNGI6mBMO9Qv68IoSaJswjbYwKsPt0ZOIj32\nTnii6G+hlGdcRREMldFFwn8PcHfQIocCZA1bDVlylixWwdrQDM5qdU9+6HYN\nC6Mpjvk6p5LfUzbrtEVGw5hpL8XE/aJNa5Fl7D2RGp/X1jE/4BmMH8exnTu1\npIlyBF/y3wuavhOiOa2Q1mDXIjZQHjB+HvLlpXD1lC0Slyeviom7j5wGn9Vn\nxIFzB9UZerLOqfJ6sHHsVBI4ingxhVyBvKDYDfFI4ByAxGzrUEeRgZ7wCGKm\nG6fqxyQEH5BHCXS2l6a3eRsGPSDd5krFPLwCdNLZGa1u524yWIHdI8uAhTQW\nLvZV\r\n=lvI/\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFSbiQtP8iQ39KOvu9ap4w8csm4y7neGeFpwGkNLaVphAiAgkPnMrzup/w7YelBrFeS+pfhXpvwYszwMGfUuwmGDrg=="}]},"maintainers":[{"name":"anthony-mesg","email":"anthony@mesg.tech"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_1.2.1_1529473847394_0.14083797317408897"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"},"1.2.2":{"name":"mesg-js","version":"1.2.2","description":"## Installation","main":"lib/index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"grpc":"^1.12.2","js-yaml":"^3.12.0"},"gitHead":"2d3bc3255c215b6f36bec5b8bc119746c231c63d","_id":"mesg-js@1.2.2","_npmVersion":"6.1.0","_nodeVersion":"8.4.0","_npmUser":{"name":"anthony-mesg","email":"anthony@mesg.tech"},"dist":{"integrity":"sha512-vaN1V0TuBZkHOvIdIi+HT7Bl2QYLD2KaXqVmUeaEeG8vfvXH8B51Z7PHBF994oIhpS4F+FMc4yU2HIRPNtq5FA==","shasum":"28c9c50de7430266e94f26bb8ad3c59feafced1e","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-1.2.2.tgz","fileCount":16,"unpackedSize":10718,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbNF6ECRA9TVsSAnZWagAA6nkP/3vUqnlDPxnDg3U6f7sW\nDI3jd6+PF9NbnveKcXHu9Ip6+UMUs1/1EWSSQmAlPZxDpx2YtXMLEZV38KYL\nr3P16ZzoE3Z2a++cjGqox5V5uz5dCJOMWHzcT7rqcMP0Nhj9XFendl1fjpXr\nxT4ZIw7kIrbGcdAASq+VnJUlLx9OqCx2T0rTckrnsyIPrJ4MKJJUrYUkjet9\nEaK0eCdBiXge0HqHNYlVBuGyF2oqvpi6b7t1yihMp2LwsT5yeWiFjGVHdKHj\n3oR27VRREtJ1aTDs/hWYAHM0fkdcUfRpchzs2UCvw4fsZLAzgFtFvt84zhwn\nuAdQgaYN/bmFdMSkXAe6Lp3wkJn/knfGfPl82Yl8PvfPd+EkJ9U3vtwA9uA0\neHm7qB0ZEcq2uAfLdgCgcfhsipDILHiwWk+El4fR0PUG5xQ5UD9Bp9ALgkd9\nVxEsjYFsTMoH5H63E6tsCwN6iQaSnwCQgqZolpp3SKRUHkYcVmvi5zEvzTF9\nWAT4/ycgx/kdruHA94pfWfK9XA7Yv1Lrxmg3Q+TUs5ziSYBlwAysrxecZDYM\nDe0RK1LwN0mkfk/gPW6TFKzpPyGHydCY49qPn3cIW9dQCXZRS5XyaNKQphET\nt5q4ED20rzGqu7LZEPCjqW3pDkgqzhztP0BZ7nPCe5E8KXwGCaWSQyURSpwa\nO9WK\r\n=z0wb\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCu4+K7c/6v2GUuyzh42UChrt1CJ6uQbhmRAUJxGuETTQIhAP8XUPDsDl7ACdbn9X3sCFsZFXgsldj3vVt2YBPE/yCt"}]},"maintainers":[{"name":"anthony-mesg","email":"anthony@mesg.tech"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_1.2.2_1530158724800_0.26187528140547145"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"},"1.2.3":{"name":"mesg-js","version":"1.2.3","description":"<p align=\"center\">   <img src=\"https://cdn.rawgit.com/mesg-foundation/mesg-js/873333a6/logo.svg\" alt=\"MESG.js\" height=\"120\">   <br/><br/> </p>","main":"lib/index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"grpc":"^1.12.2","js-yaml":"^3.12.0"},"gitHead":"cd5e6159a8a91e15d5e633a628731e64407311c2","_id":"mesg-js@1.2.3","_npmVersion":"6.1.0","_nodeVersion":"9.11.1","_npmUser":{"name":"nicolas-mesg","email":"nicolas@mesg.tech"},"dist":{"integrity":"sha512-YHFoSL6v5biZ39UZf0MPlfWGW9244L7HEYc87SyP3+DKLtTQ2iKK78ONJbq3xRwL+x95a8/0j15jqF0vrLbgSQ==","shasum":"f99413df33641f3191e567b78c8fe1a6cf8a851f","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-1.2.3.tgz","fileCount":17,"unpackedSize":29385,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbPHqNCRA9TVsSAnZWagAAcDEP/01726nkfkK3a3SubOWb\nc3cQtW0N/v6IeV7DfxaWUfu1B2RIZYwDuawK4mVb3nr0FHszL/MIclq9aS+j\n1or+yPoP1hT4IjU0Pe+J2LWAw1TEfgZo/nbHTB5Prd41cndbCeXoo6fR5Tm9\nhKsAByTw8DzZN0dIwpFrXUOUMOInCAETGM9hu08YYd20Fv4oLSWwby7t9Rk3\nNkwWlTeZbmNYTsXDnRtX6sv2XMx2CuKoSff7f9YoDsyvLJzvvXWk2Da7+qWO\nxcdfltO1Tx7XF0m/RkcCu3lBEavaYhtFzvcx7MNzE6TLaUkzKcOjk5vsm/ll\nW4xpfjpB3XPQr7zpYGUBERn8PzIaQctVuS33AIo6YYoa/eUxat3+I85N4JqC\nYChmuOnWjUXqM4aO32LBjLn/1wrQv13lpozdhdYXeykFNJj8qnpct5wq00A4\noDssf0j/CorR8tPxsfOnJyxy45pY3xh9g8Hpu1OCr82mdozmymuGEZfcJxfH\niJGFpehgZ0mI9vmQEKsElDE9wTKZrnAbjVLUJVPZFP2AH6tPzrexSBVIrqF0\nYxPXp+7Y9KHLwU6x5JLbTPf1gNVeHkFPtfYF5VH26FEsWT3nixTR5p4u1+Sz\nWkp+AAiEiyFtRAy+7A3GBfEmQnL2oBM8BY0TpdLIpmsIBj59d6r/77llpO5T\nJ5Hp\r\n=5P2Y\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCBCEP+gaTys9zvPrZmpA0QJpj3YnPs7aWN96RVzJ34QwIgRfeHDixdp1T3mKP9eFknVd0z+6FtlyOamc3bcnWzbUM="}]},"maintainers":[{"name":"anthony-mesg","email":"anthony@mesg.tech"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_1.2.3_1530690189500_0.2562521395540087"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"},"1.3.0":{"name":"mesg-js","version":"1.3.0","description":"<p align=\"center\">   <img src=\"https://cdn.rawgit.com/mesg-foundation/mesg-js/873333a6/logo.svg\" alt=\"MESG.js\" height=\"120\">   <br/><br/> </p>","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/client/proto/ ./lib/client/proto/","prepublish":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/client/proto/ ./istanbul/client/proto/ && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.3.0","grpc":"^1.13.0","js-yaml":"^3.12.0"},"devDependencies":{"@types/node":"^10.5.2","@types/sinon":"^5.0.1","@types/tape":"^4.2.32","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.18.2","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.9.1","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"gitHead":"2c2ff7182cb657ba8c6079d9990bb738a4d2104a","_id":"mesg-js@1.3.0","_npmVersion":"6.2.0","_nodeVersion":"10.8.0","_npmUser":{"name":"anthony-mesg","email":"anthony@mesg.tech"},"dist":{"integrity":"sha512-/1Mb4xPKXu28NJ78g8tzI9iyq21COYhwlkAazNV5zzGev/86MD4br4XoMCGfztuNtiz8RDGcphOCMyFXNdloeA==","shasum":"e10acf32effe8df285628ed34b8d3bbcb8d462ad","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-1.3.0.tgz","fileCount":63,"unpackedSize":122275,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbwIOfCRA9TVsSAnZWagAAxiQP/0qgm+B8/KRYsT3iSr4K\n5c1/RRQx62S5QfPxcU8WxuUSgBlUhXl3b7/ybfHN2Q2WfIjBe1+/AHsOb0mz\n1wS03FConk2xE//Va4UhZ7N5u8JWZxhZURBR6EXULbkpX34lLJ0jQvDkzqpL\nDc13HK48+kGBEPmP8HBFrfbilW4WbZWVh/LTGXaVEF8RfzC2zy2yvwnQHXJB\ns5nIYnVSwPwsVL/lucgrF3OMF4jckGgBR6hR6vG+4PunOi8xPZfNGvzYwXLD\nJbiBXzHyhHCBOStiR8tLrsCYGyAKHe9m9FjJRWs9oCZ6EQHTMTxL1KhsaBYb\nLUHApW0nZqkeBaNFIH6PK5fK7JfmU94y0Ba9zP7cGq7p3x6OOYiEAVeVE5PY\nS62OjU2FDo9xua7OK0e4eZnmq9dxu5KBrWkcbVMd+ySoJJFwCtugbizvFmXP\nCuj+BNUIgCSCgNWUPkEt5tW8NPF1BxLD52NUxmlN1vDOvzNmp5venWThI9Zi\nBMFushHZ5SBSzd/i4Wy1jY0X+O1RoXy2v59QgHPa+EjWE2s8DU+M23/E9wPQ\nE4Nz6WnnmiOkWTdkxTohvNGgwWxRr5Atw0/5aGv4StTo5H5xfbfIk8bW8ipn\nok16GGRF9zN8TL5m55QoJfg/MEzcxwTNOj6H76jGyhlLJTLU2Y2j4ENrQVrc\nujDu\r\n=KQKb\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICVLTHx1eGSOFTkarsqjyFUIIlgFSZrm0pSttd+Sw0NFAiEAj016V6V31f3icDeaGr2U+N9HJ2/U9lX/lNp/vrD4wnI="}]},"maintainers":[{"name":"anthony-mesg","email":"anthony@mesg.tech"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_1.3.0_1539343261972_0.7904933367196947"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"},"1.4.0":{"name":"mesg-js","version":"1.4.0","description":"<p align=\"center\">   <img src=\"https://cdn.rawgit.com/mesg-foundation/mesg-js/873333a6/logo.svg\" alt=\"MESG.js\" height=\"120\">   <br/><br/> </p>","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/client/proto/ ./lib/client/proto/","prepublish":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/client/proto/ ./istanbul/client/proto/ && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.3.0","clone":"^2.1.2","grpc":"^1.13.0","js-yaml":"^3.12.0"},"devDependencies":{"@types/node":"^10.5.2","@types/sinon":"^5.0.1","@types/tape":"^4.2.32","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.18.2","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.9.1","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"gitHead":"5a2e04c9933a90a1a6fbfd5a906d8f0850ccaa0c","_id":"mesg-js@1.4.0","_npmVersion":"6.2.0","_nodeVersion":"10.8.0","_npmUser":{"name":"anthony-mesg","email":"anthony@mesg.tech"},"dist":{"integrity":"sha512-kfiOcOV2dtsjK3t7LzP8apFcDjhyn7ZvX41CPWkI/5HLlxegV/ow4YgX951CFVtl+3VDHXHfb8Quv/n3niySFg==","shasum":"40e964eb9c1c3378528ee43a98e3e87fc5f4dd70","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-1.4.0.tgz","fileCount":63,"unpackedSize":134875,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbycrYCRA9TVsSAnZWagAAlBcP/iOAFi8rnJrd9MwrgScw\npV8KjaVXXhojQ1OG3iLIL9WJSga/O76Zzu471SZ93Z4LJzM7vUTtwx/n2vcD\nE8pQzCTGldOK1MCGFgHlH32fE0M4RaNpNuwjz5afVXmeN0QzHeDrOFc4DBdK\nQnrlk8aKRYowulGBkteXU1bHaZswYDXM2g7oZiJioaN0Fox61n421/2+vgT2\n9UQfF7B9oC2l78clgBE3MGdMnbMw5rcYsuvcrWBH6sODI01y1BRTDBtQ4LF8\nxTChj4Mxawb622L3WWFj/TsKpxDV0mbfHUx8FvzUUE9sKiwC81Ncv012eoSc\nQ2K/58qWBF30mmLt2EuLO4k8kclMiORSd5dMsuP24jQhA1fQfLrt1n3C0knY\nCNIrctmJtFODJmNn1zVl8/OnlKYAGv3mX82j9IHc1BHukZv6Ps/EQOoTJTQV\nclQw5qjzVGRbKxhRsTNhHV2taViUj/90cm4EgX2NvJkCIyg1fK0WudvUYx+x\nH/SnuaKCL8j88SWkRs7KXh1OP/eQEhG1X6nlSGkEotQh1VKZ9iyTKgOycIeC\nmB5Vg7CtcKjosP2nV8M7MvnHoQmg73u3UIAwJmOhTumsrxpLtizrBMsdSkZD\nGkr6LHQMzXhWlRl8fRO2mmIghsjiNUFsZ5PaF5zkV8Qymaym8q00cuaDm3rS\nQ3eX\r\n=lIee\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDvxNmGx3JAu31YhpTk6NtWXAu1xpfhpDEFkPW6CQPA2wIgWjTFM1Oj/qZNg94Y8ocOQ4t9y5mTgzO1enq25gGflFI="}]},"maintainers":[{"name":"anthony-mesg","email":"anthony@mesg.tech"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_1.4.0_1539951319566_0.4647508493143031"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"},"2.0.0":{"name":"mesg-js","version":"2.0.0","description":"<p align=\"center\">   <img src=\"https://cdn.rawgit.com/mesg-foundation/mesg-js/873333a6/logo.svg\" alt=\"MESG.js\" height=\"120\">   <br/><br/> </p>","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/proto/ ./lib/proto/","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/proto/ ./istanbul/proto && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.3.0","clone":"^2.1.2","grpc":"^1.13.0","js-yaml":"^3.12.0","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.5.2","@types/sinon":"^5.0.1","@types/tape":"^4.2.32","istanbul":"^0.4.5","is-uuid":"^1.0.2","ncp":"^2.0.0","nodemon":"^1.18.2","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.9.1","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"gitHead":"94236fa5e8d845022774d26e4db3531d1e35a50b","_id":"mesg-js@2.0.0","_npmVersion":"6.5.0","_nodeVersion":"10.4.1","_npmUser":{"name":"ilgooz","email":"ilkergoktugozturk@gmail.com"},"dist":{"integrity":"sha512-dOU2w7m92tghWVldQTeu4WbzTueR3ad9vAikVY1tZh4nLKHBLIfv+1cokzxOcHJVYxuRd6KUlEMcTfqQTIIr1g==","shasum":"25fb5003770cc465021a77c72dd56affd560d215","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-2.0.0.tgz","fileCount":45,"unpackedSize":107639,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcPvAbCRA9TVsSAnZWagAAWP8QAJCTbRHWFeLk2ybfBuo8\nAZ+OWoObsWUnRbrX1bc0AA9Q9t26Bp7dMT5lk9hcyvYc01wUnFIbNQpfnk0s\nBMr8cRUC/C96vY+a6KETsTR3A5h8Uzx10SxbgMwO0F6UteoeMbqI/41ZGg//\nuqVcXgZtPtchh8KsDFH6OSFvtb/M/GOzKKu2VWq8m+OpkqwVbr2DyTvEoc/J\n86gvHDUAWf4wEqvISOOLWrUHXnuJS1rGKIGWQYP0mMmC49XcUuUPlyA+dglt\nK9zu41A8WVJk2CeOlRVk+VDVcF1arXVme5YWqK3W9vncw6Ms3pQD1UuqhqAx\nSSpDvyLQJFT0jMdrzNPcOKWEaKiAnkmSzhSCidSYc8Uywd38BgNp4z8xcnzI\nENVj70IqZnDqFZW6W7/EYRQG1FI3zTrl5O8g8WfTqKO6Qoq6ktEwUyt77fdS\nYj0FHv5oO/+Z1ofjcQsm4TDDhECCnD4Ws1sIlhAR8yOJtJzuJQAPpo+oi8eY\nn+WmJl8clgXOADXBPEOTUSUaHx+QF2CYEqHbWDrbtWU2M22FlAnBdIpkTkA8\nF87Nyu0+8kNxDmHfL5u3RxDWpHNQr30XOygOasGCATM080jITrLyC8JAgqwi\n9xqdIiP7rpq4nOtWf1f/1zNuWqKliBWSr9SAcLhzRsQeUk5aTs2KveatmSJ/\n7Tod\r\n=5dPE\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCUD8BO7M4PPireDNbBOcY2TNhZj5v7FGEyM+vLTR6/VQIhAL6WOLBV5YxWpZA/KDiCSpcDHoksKbsVJwFwpPa4IhXq"}]},"maintainers":[{"name":"anthony-mesg","email":"anthony@mesg.tech"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_2.0.0_1547628570340_0.6300275715592172"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"},"2.0.1":{"name":"mesg-js","version":"2.0.1","description":"<p align=\"center\">   <img src=\"https://cdn.rawgit.com/mesg-foundation/mesg-js/873333a6/logo.svg\" alt=\"MESG.js\" height=\"120\">   <br/><br/> </p>","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/proto/ ./lib/proto/","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/proto/ ./istanbul/proto && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.3.0","clone":"^2.1.2","grpc":"^1.13.0","js-yaml":"^3.12.0","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.5.2","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.18.2","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.9.1","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"gitHead":"bc8b8e030223a5398190556ed359d9a5f4049a92","_id":"mesg-js@2.0.1","_npmVersion":"6.5.0","_nodeVersion":"10.4.1","_npmUser":{"name":"ilgooz","email":"ilkergoktugozturk@gmail.com"},"dist":{"integrity":"sha512-UqApC/fICS5mTtlnu3MEY8HgA2OO2pna++Gv698Fs634p6U3B8IOHJfdIyoBswRXYmc8LUyGjM3m2VX/CpnoqA==","shasum":"3bc28a308a34237fb37eb1b88a5009841de7833e","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-2.0.1.tgz","fileCount":45,"unpackedSize":108147,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcRuKoCRA9TVsSAnZWagAAS8gP/3V/FaBN2PVkN+ozzNe2\nGCNnI6Z9ns7w8srgTInPJuw0lvpyxYOEIO2hg0LV3+q94jHJozgXQH8sWtAg\nRKIG9SPdjSjK6+aYq0uP4WqoO4dB4EikvVrRJ3M+xO785Nr4kGg1gODsz/8o\nQRbTXXwjbyVuoc4B5HIWKqTLeO2VEQwggq/0BOCeEiDgrCiHk7EOY64L0xTY\ngRIKGRY+znEj8evYZTEr8jiQo/P7Bb/ongy/skVu1d3v+CYIq7wabsOo0RBf\n1bpFYz5llL3/Ycjgr39Ffy2LqsFRwGn+FJ64iVYW1W6rqPdcfa5HQw8T05oh\nPzuF7a5lGiB9EE4oDIfUUu1Vy/0HE4Geqp/ElnIrN4rY11EcId+rStAUBgxs\nYDW8v0P/Sou87xvgTIqOHaYjZjtmmu9srIKqqpLaZQmoTtQT7cmg7Z//Sh2+\n8qxCI7I+gy6pQGdN4j0F0sNFW0MNe0vf85hnRKEc+Mba5KIF1teO2YTOQGJp\nTT8nK/PyWAPunSjp4CGDKeSJWjO9Btaua0tYDvS0WpNQnL+K+4IZQ3XhJjgI\n/TIziyCFH6SIMV2aMESFLEXcTpoznt9milgYtrL3h/HxusjHakwPPuM22QUN\nmOt1s2K0qUngObPKYA2tyGclII/L6tr85KuPl6fM3O38MQa1ENYFbcLbotpg\nmBnw\r\n=iMZc\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDcSsa2BqVJydodjcpEPgewo5jgU6vkZDE9AtPTHm4a6wIgKn+1X6uOHc1NBBY/na5qDwVo/Z/zl/VnXw5k4B7+wwE="}]},"maintainers":[{"name":"anthony-mesg","email":"anthony@mesg.tech"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_2.0.1_1548149415525_0.5990634176213954"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"},"2.1.0":{"name":"mesg-js","version":"2.1.0","description":"<p align=\"center\">   <img src=\"https://cdn.rawgit.com/mesg-foundation/mesg-js/873333a6/logo.svg\" alt=\"MESG.js\" height=\"120\">   <br/><br/> </p>","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.3.0","clone":"^2.1.2","grpc":"^1.13.0","js-yaml":"^3.12.0","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.5.2","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.18.2","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.9.1","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"gitHead":"b18a74d8fb3bd1038a7f12a5597dc222a863b1f0","_id":"mesg-js@2.1.0","_nodeVersion":"10.15.1","_npmVersion":"6.9.0","dist":{"integrity":"sha512-mVK9dzsgBrvwb6PaZaBL/XcThbo1G2weTPS7aimPeRIW+z5D1q3MBGKhOu/EsLL78SA4HNDyXq0USq8W6Dn7IA==","shasum":"9dccd9b2418984451bd6bf2b128a279d0429e5b8","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-2.1.0.tgz","fileCount":47,"unpackedSize":113250,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc0rw1CRA9TVsSAnZWagAAJZwP/3w/wWRCRm+uPmWHMMEP\nMx7eUQFc6uI500cT6Z3Yd5y9zGhOMJlZRxK0LdX1G/te/pWYaWCO2pqy6jy8\nRJHglkShE0TfB63gRQED8ecHEoblcsrlpYtVyv2hvcNLX6y2uHP8GZ33NlQV\nfqgbToVa+sVX4OMucm8h+kjsKYcUNFbFkiDGRe4R+knV1v2JFu7UdVS3T6TI\nLtUAI1QjL6B8q3ueCIQ1XixGYpof+F6/GhfubG8/PFTWwwP035jF/aNwiAqz\ngcziUd3krD2TdvG9c6Zkb9k8UACtInmdzt76Pm/mNrB3TAlpYTZtuCZP4bXR\nsf8KKIkwuoSABxKxMWY9ilSy8Xbk9Nlv0LjxOEm+6P7wijE4DpIA7YQgbSMe\nuwaNgcwyYxETc22ui/y1L2xvpND6RYPBJnFJS5DRuOxXOidhxvF4V7sEFVy2\n4llP+mt4vwBzXOENI3E/1u30Jb3ylLcIYgXwIw7x6+pOpdia8j2RoYqQuO29\nDYYaVuIA5MFlVq1Ndz3+sHsZzMP6qGSRM8muGprrAqqMVfaelf6MUFgGZpzP\nDLuwrT5aoHFu0MVmxTP/hmFG38MCIgBg6WX2WnejrdAKBfb+AoPI9KyPeacP\nx085ICNx+Wavc0mbG1jgt6Sfh3d9xHKV45DTNFg+lLD3NUltcxn3f96NJf7m\ngwgk\r\n=B9LZ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDHuPTy4hExDE86/hpSklw12qyPq/MwBSA0j6Gu1soy/wIgC0NxUZ2JmacPFCaS4uG0MSDdLm9XBXlF9Lz8Vkh1nQY="}]},"maintainers":[{"name":"anthony-mesg","email":"anthony@mesg.tech"}],"_npmUser":{"name":"nicolas-mesg","email":"nicolas@mesg.tech"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_2.1.0_1557314613419_0.8580232907082126"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"},"3.0.0-beta.0":{"name":"mesg-js","version":"3.0.0-beta.0","description":"<p align=\"center\">   <img src=\"https://cdn.rawgit.com/mesg-foundation/mesg-js/873333a6/logo.svg\" alt=\"MESG.js\" height=\"120\">   <br/><br/> </p>","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.3.0","clone":"^2.1.2","grpc":"^1.13.0","js-yaml":"^3.12.0","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.5.2","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.18.2","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.9.1","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"readme":"<p align=\"center\">\n  <img src=\"https://cdn.rawgit.com/mesg-foundation/mesg-js/873333a6/logo.svg\" alt=\"MESG.js\" height=\"120\">\n  <br/><br/>\n</p>\n\n[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)\n\nMESG.js is the official JavaScript library to interact with [MESG Core](https://github.com/mesg-foundation/core).\n\nThis library can be used from an Application or a Service.\n\n# Status\n[![CircleCI](https://img.shields.io/circleci/project/github/mesg-foundation/mesg-js.svg)](https://github.com/mesg-foundation/mesg-js) [![codecov](https://codecov.io/gh/mesg-foundation/mesg-js/branch/master/graph/badge.svg)](https://codecov.io/gh/mesg-foundation/mesg-js)\n\n# Contents\n\n- [Installation](#installation)\n- [Application](#application)\n  - [Listen events](#listen-events)\n  - [Listen results](#listen-results)\n  - [Execute task](#execute-task)\n  - [Execute task and wait result](#execute-task-and-wait-result)\n  - [Advanced utilization](#advanced-utilization)\n- [Service](#service)\n  - [Task](#task)\n  - [Event](#event)\n  - [Advanced utilization](#advanced-utilization-1)\n- [Community](#community)\n- [Contribute](#contribute)\n\n# Installation\n\n```bash\nnpm i mesg-js\n```\n\n# Application\n\nRequire MESG.js as an application:\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst options = {\n  endpoint: \"localhost:50052\" // default\n}\nconst mesg = application(options)\n```\n\n## MESG Core endpoint\n\nBy default, the library connects to Core from the endpoint `localhost:50052`.\n\n## Listen events\n\nListen events from a service.\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n\nconst stream = mesg.listenEvent({\n  serviceID: __EVENT_SERVICE_ID__,\n  eventFilter: __EVENT_KEY__ // optional\n}).on('data', (event) => {\n  console.log('an event received:', event.eventKey, JSON.parse(event.eventData))\n}).on('error', (err) => {\n  console.error('an error has occurred:', err.message)\n}).on('end', () => {\n  console.log('stream closed')\n})\n\n// cancel stream anytime\nstream.cancel()\n```\n\nReference: \n[`ListenEventRequest`](#ListenEventRequest)\n[`EventData`](#EventData)\n\n## Listen results\n\nListen results from a service.\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n\nconst stream = mesg.listenResult({\n  serviceID: __RESULT_SERVICE_ID__\n  taskFilter: __TASK_KEY_FILTER__ // optional\n  outputFilter: __OUTPUT_KEY_FILTER__ // optional\n  tagFilters: [__TAG_FILTER_] // optional\n}).on('data', (result) => {\n  console.log('a result received:', result.outputKey, JSON.parse(result.outputData))\n}).on('error', (err) => {\n  console.error('an error has occurred:', err.message)\n}).on('end', () => {\n  console.log('stream closed')\n})\n\n// cancel stream anytime\nstream.cancel()\n```\n\nReference: \n[`ListenResultRequest`](#ListenResultRequest)\n[`ResultData`](#ResultData)\n\n## Execute task\n\nExecute task on a service.\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n\nmesg.executeTask({\n  serviceID: __TASK_SERVICE_ID__,\n  taskKey: __TASK_KEY__,\n  inputData: JSON.stringify(__INPUT_DATA__),\n  executionTags: [__ASSOCIATE_TAG__] // optional\n}).then((execution) => {\n  console.log('task in progress with execution id:', execution.executionID)\n}).catch((err) => {\n  console.error('task execution failed with err:', err.message)\n})\n```\n\nReference: \n[`ExecuteTaskRequest`](#ExecuteTaskRequest)\n[`ExecuteTaskReply`](#ExecuteTaskReply)\n\n## Execute task and wait result\n\nExecute task on a service and wait for its result.\nThis can be considered as a shortcut for using both `executeTask()` and `listenResult()` at same time.\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n\nmesg.executeTaskAndWaitResult({\n  serviceID: __TASK_SERVICE_ID__,\n  taskKey: __TASK_KEY__,\n  inputData: JSON.stringify(__INPUT_DATA__),\n  executionTags: [__ASSOCIATE_TAG__] // optional\n}).then((result) => {\n  console.log('a result received:', result.outputKey, JSON.parse(result.outputData))\n}).catch((err) => {\n  console.error('task execution failed with err:', err.message)\n})\n```\n\nReference: \n[`ExecuteTaskRequest`](#ExecuteTaskRequest)\n[`ResultData`](#ResultData)\n\n## Object definition\n\n### `ListenEventRequest`\n\n```ts\ninterface ListenEventRequest {\n  // Event's service ID.\n  serviceID: string\n\n  // Listen for this event's key. Leave empty or set `*` to listen for any event\n  // from this service.\n  eventFilter?: string\n}\n```\n\n### `EventData`\n\n```ts\ninterface EventData {\n  // Event's key.\n  eventKey: string\n\n  // Event's data. It's JSON encoded.\n  eventData: string\n}\n```\n\n### `ListenResultRequest`\n\n```ts\ninterface ListenResultRequest {\n  // Result's service ID.\n  serviceID: string\n\n  // Only listen for this task's key. Leave empty or set `*` to listen for any\n  // task's result from this service.\n  taskFilter?: string\n\n  // Only listen for the output key. If set, `taskFilter` is required.\n  // Leave it empty or set `*` to listen for any task's output from this service.\n  outputFilter?: string\n\n  // List of tags required to process this result. All inclusive filter.\n  tagFilters?: string[]\n}\n```\n\n### `ResultData`\n\n```ts\ninterface ResultData {\n  // Execution id of the task that result belongs to.\n  executionID: string\n\n  // Task key of the result.\n  taskKey: string\n\n  // Output key of the result.\n  outputKey: string\n\n  // Output data of the result. It's JSON encoded.\n  outputData: string\n\n  // Associated execution tags during the task execution.\n  executionTags: string[]\n\n  // Error is filled when task execution is failed.\n  error: string\n}\n```\n\n### `ExecuteTaskRequest`\n\n```ts\ninterface ExecuteTaskRequest {\n  // Task's service ID.\n  serviceID: string\n\n  // Task key to execute.\n  taskKey: string\n\n  // Input to pass on to the task.\n  // It must be JSON encoded and should fulfil the task's input definition types.\n  inputData: string\n\n  // List of tags to send for the execution. These tags can be static,\n  // generated based on an event or a result.\n  executionTags?: string[]\n}\n```\n\n### `ExecuteTaskReply`\n\n```ts\ninterface ExecuteTaskReply {\n  // Unique id for the execution. \n  executionID: string\n}\n```\n\n## Advanced utilization\n\nThe application can use gRPC APIs directly for advanced utilization.\n\nSee the [full list of available gRPC APIs](https://docs.mesg.com/api/core.html).\n\nHere some examples for the most useful gRPC APIs that your application can use:\n\n### Execute a task\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n\nmesg.api.ExecuteTask({\n  serviceID: __TASK_SERVICE_ID__,\n  taskKey: __TASK_KEY__,\n  inputData: JSON.stringify(__INPUT_DATA__)\n}, (error, reply) => {\n  if (error) {\n    console.error(error)\n    return\n  }\n  console.log('task in progress with execution id:', reply.executionID)\n})\n```\n\n[Documentation](https://docs.mesg.com/guide/application/execute-a-task.html)\n\n### Listen for an event\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n\nmesg.api.ListenEvent({\n  serviceID: __TASK_SERVICE_ID__,\n  eventFilter: __EVENT_KEY__\n}).on('error', (error) => {\n  console.error(error)\n}).on('data', (data) => {\n  console.log('Event received with data:', data)\n})\n```\n\n[Documentation](https://docs.mesg.com/guide/application/listen-for-events.html#listening-for-events-from-services)\n\n### Listen to a task's result\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n\nmesg.api.ListenResult({\n  serviceID: __TASK_SERVICE_ID__,\n  taskFilter: __TASK_KEY__,\n  outputFilter: __OUTPUT_KEY__\n}).on('error', (error) => {\n  console.error(error)\n}).on('data', (data) => {\n  console.log('Result received with data:', data)\n})\n```\n\n[Documentation](https://docs.mesg.com/guide/application/listen-for-events.html#listen-for-task-execution-outputs)\n\n# Service\n\nRequire MESG.js as a service:\n\n```javascript\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n```\n\n## Task\n\nThe service should call `mesg.listenTask` to register its available tasks to MESG Core. An object containing the tasks' key is the only parameter of this function and the tasks' functions are the values. This function returns an [event emitter](https://nodejs.org/api/events.html#events_class_eventemitter) with possible events `data` and `error`.\n\n```javascript\nmesg.listenTask({\n  __TASK_1_KEY__: (inputs, outputs) => {\n    // Function of the task 1\n  }, \n  __TASK_2_KEY__: (inputs, outputs) => {\n    // Function of the task 2\n  },\n}).on('error', (error) => {\n  console.error(error)\n})\n```\n\n`inputs` is containing the task's inputs as defined in its `service.yml`.\n\n`outputs` is containing the task's outputs as function as defined in its `service.yml`.\nThe `outputs` function returns a `Promise` and should **ONLY BE CALLED ONCE** per executed task with the desired data as parameters.\n\n### Example\n\nLet's use a multiplication service as an example. Its `service.yml` is:\n```yml\nname: \"service multiplication\"\ntasks:\n  multiply:\n    inputs:\n      a:\n        type: Number\n      b:\n        type: Number\n    outputs:\n      success:\n        data:\n          result:\n            type: Number\n      error:\n        data:\n          message:\n            type: String\n```\n\nIf you want more information about this file, check out the [documentation on service files](https://docs.mesg.com/guide/service/service-file.html).\n\n#### Task function\n\nTask functions should always accept `inputs` and `outputs` as parameters.\n\n```javascript\nconst taskMultiply = (inputs, outputs) => {}\n```\n\n#### Inputs\n\nThe parameter `inputs` is an object that contains the two task's inputs: `a` and `b`.\n\n#### Outputs\n\nThe parameter `outputs` is an object that contains the two tasks' outputs: `success` and `error`.\n\n`success` and `error` are functions that accept an object defined by its `data` structure as its only parameter. Those functions return a `Promise`.\n\n> **ONLY ONE** output function should be called per task execution.\n\n`success` is defined like:\n```javascript\noutputs.success({\n  result: __MULTIPLICATION_RESULT__\n}).catch((error) => {\n  console.error(error)\n})\n```\n\nAnd `error` is defined like:\n```javascript\noutputs.error({\n  message: __ERROR_MESSAGE__\n}).catch((error) => {\n  console.error(error)\n})\n```\n\n#### Register the task\n\nThe last step is to register the task function with MESG.\n\nThe service should call `mesg.listenTask` with a containing object as the key of the task, and the task's function as a value. In this example, the key is `multiply` and the function is `taskMultiply`\n\n```javascript\nmesg.listenTask({\n  multiply: taskMultiply\n}).on('error', (error) => {\n  console.error(error)\n})\n```\n\n#### Javascript code\n\n```javascript\n// Require MESG.js as a service\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n\n// create taskMultiply handler\nconst taskMultiply = (inputs, outputs) => {\n  if (inputs.a === undefined || inputs.b === undefined) {\n    // There is an error. Return the error output with the message.\n    outputs.error({\n      message: 'a and/or b are undefined'\n    }).catch((error) => {\n      console.error(error)\n    })\n  } else {\n    // Return the success output with the result of the multiplication\n    outputs.success({\n      result: inputs.a * inputs.b\n    }).catch((error) => {\n      console.error(error)\n    })\n  }\n}\n\n// Register the task multiply to MESG\nmesg.listenTask({\n  multiply: taskMultiply\n}).on('error', (error) => {\n  console.error(error)\n})\n```\n\n## Event\n\nTo emit an event, the service should call the `mesg.emitEvent` function with the event's key and event's data as parameters. This function returns a `Promise`.\n\n```javascript\nmesg.emitEvent(__EVENT_KEY__, __EVENT_DATA__).catch((error) => {\n  console.error(error)\n})\n```\n\n### Example\n\nLet's use a timer service as another example. It will emit a `minute` event every minute. Its `service.yml` is:\n```yml\nname: \"service timer\"\nevents:\n  minute:\n    timestamp:\n      date:\n        type: Number\n```\n\nAnd the JavaScript code:\n```javascript\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n\nfunction emitEvent () {\n  mesg.emitEvent('minute', {\n    timestamp: Date.now()\n  }).catch((error) => {\n    console.error(error)\n  })\n}\nsetInterval(emitEvent, 60 * 1000)\n```\n\n## Advanced utilization\n\nThe service can use gRPC APIs directly for advanced utilization.\n\nSee the [full list of available gRPC APIs](https://docs.mesg.com/api/service.html).\n\n# Community\n\nYou can find us and other MESG users on the [forum](https://forum.mesg.com). Feel free to check existing posts and help other users of MESG.\n\nAlso, be sure to check out the [blog](https://medium.com/mesg) to stay up-to-date with our articles.\n\n# Contribute\n\nContributions are more than welcome.\n\nIf you have any questions, please reach out to us directly on [Discord](https://discordapp.com/invite/SaZ5HcE).\n","readmeFilename":"README.md","gitHead":"e536fe49079c3b0d33d52be3b9c96143ff03485a","_id":"mesg-js@3.0.0-beta.0","_nodeVersion":"10.15.1","_npmVersion":"6.9.0","dist":{"integrity":"sha512-n/EaOHpogTFJRCr/5gCzFhFBPHFXHX4k4AWHHaZjOEsO/tLSWnJJ03tWupJ6EsXNjNjj0jp9n7qQdzfGfXkfdg==","shasum":"4c77e49159dde640510bbbcd4d4ba45b7e5795e6","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-3.0.0-beta.0.tgz","fileCount":47,"unpackedSize":113428,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc7MbuCRA9TVsSAnZWagAAbegP+wUxhxuYYiEAmoDmYRqn\nx0Un8XC4+kspPBLi5fLai6C/BT1P/Pp7RORJQ0Aog8oKuTmZyf0n//64/u8Y\nHtuwyuqHe3YUQlPwTydz1nwTr7Rz/i6qsfJ3nkOiuOEZ8xM8Skix9bQfOjJM\n4zHaH6zdAmKLUiGCOFkPr0xHRu3iNrTbaErsq2HMmBKQgaxKGCDCYxKQDf0f\ntml3EMX48veTuYNoaBTw55Aioi/j+aNVmxInC635nTeOLahBKBUOjE2p8Ahj\ntuyuh3pYzCNhtGaEuMV0yYQ6hwl4kJOsz1qR1bFhJQAQMn6ocNVS174xSNHB\nC+kMoEfNiwPLoQ4tj+F7GqiVxLueU689+kvrdeCdUg15y4lkCU0Z+deSv4il\nRwlpbAXFBEdINsC925Ng3VSQNiRE4j4gCkIuN9HXCHBPYNi7pbqK/CmmiDGj\nAyWPq2MZ5KQEh/zXv0ug5X7bdkn1awhcRkAQ9haqwjyDLyJo81lLxfXLdedE\nzbis+jQTyAOlbzfkun8Xvu6M8xM3D3NxeHuI6qnU3D+zrKRHIXytzHRLVMS7\nD9mp2jEnmNy48ucC2QsUxy3m42Uho8TDvWhNr5E9BV9tKGBBsTPcYMlTgxr+\nwLteIid/giTW6qYTqRL9Yert3vIHB8HjUXARx4j22lKVoEPckZwKZ7PwmwEO\nco2D\r\n=1Mn2\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC49420b0Zif6is/VQCV2B8zitXOtHJpxXncy8B93z2BAIgS4mawenWB4lTmUx1Ox/DhaRxk6rAWbEFyX4k+7ZxYHg="}]},"maintainers":[{"email":"anthony@mesg.tech","name":"anthony-mesg"},{"email":"ilkergoktugozturk@gmail.com","name":"ilgooz"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"nicolas-mesg","email":"nicolas@mesg.tech"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_3.0.0-beta.0_1559021294057_0.010996089648545704"},"_hasShrinkwrap":false,"deprecated":"new beta"},"3.0.0-beta.1":{"name":"mesg-js","version":"3.0.0-beta.1","description":"<p align=\"center\">   <img src=\"https://cdn.rawgit.com/mesg-foundation/mesg-js/873333a6/logo.svg\" alt=\"MESG.js\" height=\"120\">   <br/><br/> </p>","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.3.0","clone":"^2.1.2","grpc":"^1.13.0","js-yaml":"^3.12.0","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.5.2","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.18.2","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.9.1","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"readme":"<p align=\"center\">\n  <img src=\"https://cdn.rawgit.com/mesg-foundation/mesg-js/873333a6/logo.svg\" alt=\"MESG.js\" height=\"120\">\n  <br/><br/>\n</p>\n\n[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)\n\nMESG.js is the official JavaScript library to interact with [MESG Core](https://github.com/mesg-foundation/core).\n\nThis library can be used from an Application or a Service.\n\n# Status\n[![CircleCI](https://img.shields.io/circleci/project/github/mesg-foundation/mesg-js.svg)](https://github.com/mesg-foundation/mesg-js) [![codecov](https://codecov.io/gh/mesg-foundation/mesg-js/branch/master/graph/badge.svg)](https://codecov.io/gh/mesg-foundation/mesg-js)\n\n# Contents\n\n- [Installation](#installation)\n- [Application](#application)\n  - [Listen events](#listen-events)\n  - [Listen results](#listen-results)\n  - [Execute task](#execute-task)\n  - [Execute task and wait result](#execute-task-and-wait-result)\n  - [Advanced utilization](#advanced-utilization)\n- [Service](#service)\n  - [Task](#task)\n  - [Event](#event)\n  - [Advanced utilization](#advanced-utilization-1)\n- [Community](#community)\n- [Contribute](#contribute)\n\n# Installation\n\n```bash\nnpm i mesg-js\n```\n\n# Application\n\nRequire MESG.js as an application:\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst options = {\n  endpoint: \"localhost:50052\" // default\n}\nconst mesg = application(options)\n```\n\n## MESG Core endpoint\n\nBy default, the library connects to Core from the endpoint `localhost:50052`.\n\n## Listen events\n\nListen events from a service.\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n\nconst stream = mesg.listenEvent({\n  serviceID: __EVENT_SERVICE_ID__,\n  eventFilter: __EVENT_KEY__ // optional\n}).on('data', (event) => {\n  console.log('an event received:', event.eventKey, JSON.parse(event.eventData))\n}).on('error', (err) => {\n  console.error('an error has occurred:', err.message)\n}).on('end', () => {\n  console.log('stream closed')\n})\n\n// cancel stream anytime\nstream.cancel()\n```\n\nReference: \n[`ListenEventRequest`](#ListenEventRequest)\n[`EventData`](#EventData)\n\n## Listen results\n\nListen results from a service.\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n\nconst stream = mesg.listenResult({\n  serviceID: __RESULT_SERVICE_ID__\n  taskFilter: __TASK_KEY_FILTER__ // optional\n  outputFilter: __OUTPUT_KEY_FILTER__ // optional\n  tagFilters: [__TAG_FILTER_] // optional\n}).on('data', (result) => {\n  console.log('a result received:', result.outputKey, JSON.parse(result.outputData))\n}).on('error', (err) => {\n  console.error('an error has occurred:', err.message)\n}).on('end', () => {\n  console.log('stream closed')\n})\n\n// cancel stream anytime\nstream.cancel()\n```\n\nReference: \n[`ListenResultRequest`](#ListenResultRequest)\n[`ResultData`](#ResultData)\n\n## Execute task\n\nExecute task on a service.\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n\nmesg.executeTask({\n  serviceID: __TASK_SERVICE_ID__,\n  taskKey: __TASK_KEY__,\n  inputData: JSON.stringify(__INPUT_DATA__),\n  executionTags: [__ASSOCIATE_TAG__] // optional\n}).then((execution) => {\n  console.log('task in progress with execution id:', execution.executionID)\n}).catch((err) => {\n  console.error('task execution failed with err:', err.message)\n})\n```\n\nReference: \n[`ExecuteTaskRequest`](#ExecuteTaskRequest)\n[`ExecuteTaskReply`](#ExecuteTaskReply)\n\n## Execute task and wait result\n\nExecute task on a service and wait for its result.\nThis can be considered as a shortcut for using both `executeTask()` and `listenResult()` at same time.\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n\nmesg.executeTaskAndWaitResult({\n  serviceID: __TASK_SERVICE_ID__,\n  taskKey: __TASK_KEY__,\n  inputData: JSON.stringify(__INPUT_DATA__),\n  executionTags: [__ASSOCIATE_TAG__] // optional\n}).then((result) => {\n  console.log('a result received:', result.outputKey, JSON.parse(result.outputData))\n}).catch((err) => {\n  console.error('task execution failed with err:', err.message)\n})\n```\n\nReference: \n[`ExecuteTaskRequest`](#ExecuteTaskRequest)\n[`ResultData`](#ResultData)\n\n## Object definition\n\n### `ListenEventRequest`\n\n```ts\ninterface ListenEventRequest {\n  // Event's service ID.\n  serviceID: string\n\n  // Listen for this event's key. Leave empty or set `*` to listen for any event\n  // from this service.\n  eventFilter?: string\n}\n```\n\n### `EventData`\n\n```ts\ninterface EventData {\n  // Event's key.\n  eventKey: string\n\n  // Event's data. It's JSON encoded.\n  eventData: string\n}\n```\n\n### `ListenResultRequest`\n\n```ts\ninterface ListenResultRequest {\n  // Result's service ID.\n  serviceID: string\n\n  // Only listen for this task's key. Leave empty or set `*` to listen for any\n  // task's result from this service.\n  taskFilter?: string\n\n  // Only listen for the output key. If set, `taskFilter` is required.\n  // Leave it empty or set `*` to listen for any task's output from this service.\n  outputFilter?: string\n\n  // List of tags required to process this result. All inclusive filter.\n  tagFilters?: string[]\n}\n```\n\n### `ResultData`\n\n```ts\ninterface ResultData {\n  // Execution id of the task that result belongs to.\n  executionID: string\n\n  // Task key of the result.\n  taskKey: string\n\n  // Output key of the result.\n  outputKey: string\n\n  // Output data of the result. It's JSON encoded.\n  outputData: string\n\n  // Associated execution tags during the task execution.\n  executionTags: string[]\n\n  // Error is filled when task execution is failed.\n  error: string\n}\n```\n\n### `ExecuteTaskRequest`\n\n```ts\ninterface ExecuteTaskRequest {\n  // Task's service ID.\n  serviceID: string\n\n  // Task key to execute.\n  taskKey: string\n\n  // Input to pass on to the task.\n  // It must be JSON encoded and should fulfil the task's input definition types.\n  inputData: string\n\n  // List of tags to send for the execution. These tags can be static,\n  // generated based on an event or a result.\n  executionTags?: string[]\n}\n```\n\n### `ExecuteTaskReply`\n\n```ts\ninterface ExecuteTaskReply {\n  // Unique id for the execution. \n  executionID: string\n}\n```\n\n## Advanced utilization\n\nThe application can use gRPC APIs directly for advanced utilization.\n\nSee the [full list of available gRPC APIs](https://docs.mesg.com/api/core.html).\n\nHere some examples for the most useful gRPC APIs that your application can use:\n\n### Execute a task\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n\nmesg.api.ExecuteTask({\n  serviceID: __TASK_SERVICE_ID__,\n  taskKey: __TASK_KEY__,\n  inputData: JSON.stringify(__INPUT_DATA__)\n}, (error, reply) => {\n  if (error) {\n    console.error(error)\n    return\n  }\n  console.log('task in progress with execution id:', reply.executionID)\n})\n```\n\n[Documentation](https://docs.mesg.com/guide/application/execute-a-task.html)\n\n### Listen for an event\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n\nmesg.api.ListenEvent({\n  serviceID: __TASK_SERVICE_ID__,\n  eventFilter: __EVENT_KEY__\n}).on('error', (error) => {\n  console.error(error)\n}).on('data', (data) => {\n  console.log('Event received with data:', data)\n})\n```\n\n[Documentation](https://docs.mesg.com/guide/application/listen-for-events.html#listening-for-events-from-services)\n\n### Listen to a task's result\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n\nmesg.api.ListenResult({\n  serviceID: __TASK_SERVICE_ID__,\n  taskFilter: __TASK_KEY__,\n  outputFilter: __OUTPUT_KEY__\n}).on('error', (error) => {\n  console.error(error)\n}).on('data', (data) => {\n  console.log('Result received with data:', data)\n})\n```\n\n[Documentation](https://docs.mesg.com/guide/application/listen-for-events.html#listen-for-task-execution-outputs)\n\n# Service\n\nRequire MESG.js as a service:\n\n```javascript\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n```\n\n## Task\n\nThe service should call `mesg.listenTask` to register its available tasks to MESG Core. An object containing the tasks' key is the only parameter of this function and the tasks' functions are the values. This function returns an [event emitter](https://nodejs.org/api/events.html#events_class_eventemitter) with possible events `data` and `error`.\n\n```javascript\nmesg.listenTask({\n  __TASK_1_KEY__: (inputs, outputs) => {\n    // Function of the task 1\n  }, \n  __TASK_2_KEY__: (inputs, outputs) => {\n    // Function of the task 2\n  },\n}).on('error', (error) => {\n  console.error(error)\n})\n```\n\n`inputs` is containing the task's inputs as defined in its `service.yml`.\n\n`outputs` is containing the task's outputs as function as defined in its `service.yml`.\nThe `outputs` function returns a `Promise` and should **ONLY BE CALLED ONCE** per executed task with the desired data as parameters.\n\n### Example\n\nLet's use a multiplication service as an example. Its `service.yml` is:\n```yml\nname: \"service multiplication\"\ntasks:\n  multiply:\n    inputs:\n      a:\n        type: Number\n      b:\n        type: Number\n    outputs:\n      success:\n        data:\n          result:\n            type: Number\n      error:\n        data:\n          message:\n            type: String\n```\n\nIf you want more information about this file, check out the [documentation on service files](https://docs.mesg.com/guide/service/service-file.html).\n\n#### Task function\n\nTask functions should always accept `inputs` and `outputs` as parameters.\n\n```javascript\nconst taskMultiply = (inputs, outputs) => {}\n```\n\n#### Inputs\n\nThe parameter `inputs` is an object that contains the two task's inputs: `a` and `b`.\n\n#### Outputs\n\nThe parameter `outputs` is an object that contains the two tasks' outputs: `success` and `error`.\n\n`success` and `error` are functions that accept an object defined by its `data` structure as its only parameter. Those functions return a `Promise`.\n\n> **ONLY ONE** output function should be called per task execution.\n\n`success` is defined like:\n```javascript\noutputs.success({\n  result: __MULTIPLICATION_RESULT__\n}).catch((error) => {\n  console.error(error)\n})\n```\n\nAnd `error` is defined like:\n```javascript\noutputs.error({\n  message: __ERROR_MESSAGE__\n}).catch((error) => {\n  console.error(error)\n})\n```\n\n#### Register the task\n\nThe last step is to register the task function with MESG.\n\nThe service should call `mesg.listenTask` with a containing object as the key of the task, and the task's function as a value. In this example, the key is `multiply` and the function is `taskMultiply`\n\n```javascript\nmesg.listenTask({\n  multiply: taskMultiply\n}).on('error', (error) => {\n  console.error(error)\n})\n```\n\n#### Javascript code\n\n```javascript\n// Require MESG.js as a service\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n\n// create taskMultiply handler\nconst taskMultiply = (inputs, outputs) => {\n  if (inputs.a === undefined || inputs.b === undefined) {\n    // There is an error. Return the error output with the message.\n    outputs.error({\n      message: 'a and/or b are undefined'\n    }).catch((error) => {\n      console.error(error)\n    })\n  } else {\n    // Return the success output with the result of the multiplication\n    outputs.success({\n      result: inputs.a * inputs.b\n    }).catch((error) => {\n      console.error(error)\n    })\n  }\n}\n\n// Register the task multiply to MESG\nmesg.listenTask({\n  multiply: taskMultiply\n}).on('error', (error) => {\n  console.error(error)\n})\n```\n\n## Event\n\nTo emit an event, the service should call the `mesg.emitEvent` function with the event's key and event's data as parameters. This function returns a `Promise`.\n\n```javascript\nmesg.emitEvent(__EVENT_KEY__, __EVENT_DATA__).catch((error) => {\n  console.error(error)\n})\n```\n\n### Example\n\nLet's use a timer service as another example. It will emit a `minute` event every minute. Its `service.yml` is:\n```yml\nname: \"service timer\"\nevents:\n  minute:\n    timestamp:\n      date:\n        type: Number\n```\n\nAnd the JavaScript code:\n```javascript\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n\nfunction emitEvent () {\n  mesg.emitEvent('minute', {\n    timestamp: Date.now()\n  }).catch((error) => {\n    console.error(error)\n  })\n}\nsetInterval(emitEvent, 60 * 1000)\n```\n\n## Advanced utilization\n\nThe service can use gRPC APIs directly for advanced utilization.\n\nSee the [full list of available gRPC APIs](https://docs.mesg.com/api/service.html).\n\n# Community\n\nYou can find us and other MESG users on the [forum](https://forum.mesg.com). Feel free to check existing posts and help other users of MESG.\n\nAlso, be sure to check out the [blog](https://medium.com/mesg) to stay up-to-date with our articles.\n\n# Contribute\n\nContributions are more than welcome.\n\nIf you have any questions, please reach out to us directly on [Discord](https://discordapp.com/invite/SaZ5HcE).\n","readmeFilename":"README.md","gitHead":"9ae0a482a26f9bf0d7e11bc5b717d6979a17f637","_id":"mesg-js@3.0.0-beta.1","_nodeVersion":"10.15.1","_npmVersion":"6.9.0","dist":{"integrity":"sha512-MtXqaYJk2BiGzG2I1VV9is8tldV+TuswBgpV1Vs3ow7GepUADHGNs28bFyqaq9vgz6ga2fqibN+M1141kP/fug==","shasum":"1cf209153d4386daaa63299aacb1104f8d42db05","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-3.0.0-beta.1.tgz","fileCount":47,"unpackedSize":113294,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc7MgUCRA9TVsSAnZWagAAQnoP/juUTN4GYSshsmUUS3iw\nNyHf/26M6lXxDo06amhFkbTtBocnHbc/eg0uRgPOpgyngIfAp1zLwt7bxs7J\nBd9nT9xwsG9HPnJug3XYS2g3ZD0GyfaL1k+iz62g/qlm8EllDXRNXdEye+CF\nr7MYQ9gXLfN/bc6QYjIIHwAuwY+5pjpxAxe0lRhhbzipGYt1W4p+1usBGfKg\nrOZRJNsfbKRRK9UqBbTpTx0fwA3jWYqkZ7NKoILenmo2rRWr/LjU12NOdvn4\nLcJ2YO/9ecBurWJczc0/hs6GcdEJyZ5XVxBhpc8phwEbn9Jb9OpFLgWQ5Tk9\nIoFJLa57Zm/JLqct67c2EhwtqNaFsGKV2OMgwFHCRxbMTkc4nOO4e9Hyl/J9\nNi3C+YAr358859rmzAJcfhQHPhBWdN6oq4ctW7lg/e4sbxpkedG2Vq0bfoVb\nCB/Vj5kN5SdzT1LNTDYwzKADspVUr294Tk6tP6z3/dNumN/+WXzXUqcuT86w\nzvxgG0sWDcmHwxXsZINNKlx1ggN9HzeEH6P+UdDv5HdP82peFKYtKCR8N7Vp\n5wffLerCXNApZtuFFOfVf8wDeDwqOFpk3YyzEMxBJXbcXRRaaP0zh1R7SNpX\nZQG+eMxfwmVnIOYKX+y1ZDmsVqhtsF+DLAqXCDB6GDd10e6T8PiHL0Hm6d7t\ncXu9\r\n=xNkY\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDv+vheojOP2ymag2OutS0lAWLrgxxMeOv+tP021j6yLAIgUGLMFSF/NJbWjuGWtl3RUo7ENbpRSHY1vkjxFuc2t+A="}]},"maintainers":[{"email":"anthony@mesg.tech","name":"anthony-mesg"},{"email":"ilkergoktugozturk@gmail.com","name":"ilgooz"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"nicolas-mesg","email":"nicolas@mesg.tech"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_3.0.0-beta.1_1559021588256_0.1390131709166862"},"_hasShrinkwrap":false,"deprecated":"this version has been deprecated"},"3.0.0":{"name":"mesg-js","version":"3.0.0","description":"<p align=\"center\">   <img src=\"https://cdn.rawgit.com/mesg-foundation/mesg-js/873333a6/logo.svg\" alt=\"MESG.js\" height=\"120\">   <br/><br/> </p>","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.3.0","clone":"^2.1.2","grpc":"^1.21.1","js-yaml":"^3.13.1","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"gitHead":"3242c34b5c4536c551241dea81fba7db84f94e3b","_id":"mesg-js@3.0.0","_nodeVersion":"10.15.1","_npmVersion":"6.9.0","dist":{"integrity":"sha512-mAqQtLMonpoINjunsmdn2ik4sAygDYEcOoHe8rnAdytbPt9bEP1VeLnK3M7LmqCZZJ+D+0zVpl5ma1sCIaxoeQ==","shasum":"2cd65bf1930fb1d3989f711239a3f9d79af8fc53","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-3.0.0.tgz","fileCount":47,"unpackedSize":112901,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJc/gFTCRA9TVsSAnZWagAAcLgP/Rm8sr+A82xBqxR7799V\nZMExyhc1waTBu2a2BMSstRzOkfQRa+ygti0WI/zFXCIFXXZdsTAqZMVtxdta\nK5q2bH9iO3ngSuNMixCOJB01n0Oh5jamSMm40fQlF9GujaD3ssm+JE2ECErt\nTID4db71/qJ1ykhnsXJcGCbxXpMdZz9AJomPYsPsMh+lVlTL3UT3yRFQL7Um\nkKxo7QzsXHKNFPYkKtWV2M/5CedP1EF7cgl9dt8DdIwTfRodZvxFDcA5nS5W\nwxsIfdGDVcrKZyzcZeVqx6Qx9MIWxeqnym9yWm776GEDlSA/zZnWhIMSh0rZ\nK2NUTwC84U2hTNFfOHjCFR02zf+Y6J1PaMAIypPM+MxnZci1Pc0exHamzNDc\nvJ/r44WBUh7Y+9+jGh5ZW1KXjQektP1SEuyee7DhH6uZzeieXyVPCDcCGxqW\nrglZp7mDAtz8muK9IEVzTSzOS8mHp3PaVW+YK3qEOQPpZYXjIxSIaTu4NPyN\nbf7TDQzfX1DhAbQVhZc8lL7Ix+KRZiFIdP5S4AbgB9CunZvGzYqELKb7nwv+\nYzRsUrfTpDtS4LHjGZBGxU1BAVUO8S4oYF661QJkkikeprWylK+TZC195P+T\nvRoeLXxKxIpFhwSxDl4NPyAmvGBcK1jmYvk5Eh5EQw8ykc/03KIVRfPl5MdH\n4yGY\r\n=l2dZ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBogRxASg8ksw2/FjSVP3HFsjVBV8VETNW9RdBskhpMJAiBpFgZOR/MU2kt3QTJVYMV3D4Px8Af6L5qdWWoYsYLqpg=="}]},"maintainers":[{"email":"anthony@mesg.tech","name":"anthony-mesg"},{"email":"ilkergoktugozturk@gmail.com","name":"ilgooz"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"nicolas-mesg","email":"nicolas@mesg.tech"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_3.0.0_1560150355011_0.8336467578287123"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"},"4.0.0":{"name":"mesg-js","version":"4.0.0","description":"<p align=\"center\">   <img src=\"https://cdn.rawgit.com/mesg-foundation/mesg-js/873333a6/logo.svg\" alt=\"MESG.js\" height=\"120\">   <br/><br/> </p>","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","grpc":"^1.21.1","js-yaml":"^3.13.1","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"readme":"<p align=\"center\">\n  <img src=\"https://cdn.rawgit.com/mesg-foundation/mesg-js/873333a6/logo.svg\" alt=\"MESG.js\" height=\"120\">\n  <br/><br/>\n</p>\n\n[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)\n\nMESG.js is the official JavaScript library to interact with [MESG Engine](https://github.com/mesg-foundation/engine).\n\nThis library can be used from an Application or a Service.\n\n# Status\n[![CircleCI](https://img.shields.io/circleci/project/github/mesg-foundation/mesg-js.svg)](https://github.com/mesg-foundation/mesg-js) [![codecov](https://codecov.io/gh/mesg-foundation/mesg-js/branch/master/graph/badge.svg)](https://codecov.io/gh/mesg-foundation/mesg-js)\n\n# Contents\n\n- [Installation](#installation)\n- [Application](#application)\n  - [Listen events](#listen-events)\n  - [Listen results](#listen-results)\n  - [Execute task](#execute-task)\n  - [Execute task and wait result](#execute-task-and-wait-result)\n  - [Advanced utilization](#advanced-utilization)\n- [Service](#service)\n  - [Task](#task)\n  - [Event](#event)\n  - [Advanced utilization](#advanced-utilization-1)\n- [Community](#community)\n- [Contribute](#contribute)\n\n# Installation\n\n```bash\nnpm i mesg-js\n```\n\n# Application\n\nRequire MESG.js as an application:\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst options = {\n  endpoint: \"localhost:50052\" // default\n}\nconst mesg = application(options)\n```\n\n## MESG Engine endpoint\n\nBy default, the library connects to the MESG Engine from the endpoint `localhost:50052`.\n\n## Listen events\n\nListen events from a service.\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n\nconst stream = mesg.listenEvent({\n  filter: {\n    instanceHash: __EVENT_INSTANCE_HASH__,\n    key: __EVENT_KEY__ // optional\n  }\n}).on('data', (event) => {\n  console.log('an event received:', event.key, JSON.parse(event.data))\n}).on('error', (err) => {\n  console.error('an error has occurred:', err.message)\n}).on('end', () => {\n  console.log('stream closed')\n})\n\n// cancel stream anytime\nstream.cancel()\n```\n\n## Listen results\n\nListen results from a service.\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n\nconst stream = mesg.listenResult({\n  filter: {\n    instanceHash: __RESULT_INSTANCE_HASH__,\n    taskKey: __TASK_KEY_FILTER__, // optional\n    tags: [__TAG_FILTER_] // optional\n  }\n}).on('data', (result) => {\n  if (result.error) {\n    console.error('an error has occurred:', result.error)\n    return\n  }\n  console.log('a result received:', JSON.parse(result.outputs))\n}).on('error', (err) => {\n  console.error('an error has occurred:', err.message)\n}).on('end', () => {\n  console.log('stream closed')\n})\n\n// cancel stream anytime\nstream.cancel()\n```\n\n## Execute task\n\nExecute task on a service.\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n\nmesg.executeTask({\n  instanceHash: __TASK_INSTANCE_HASH__,\n  taskKey: __TASK_KEY__,\n  inputs: JSON.stringify(__INPUT_DATA__),\n  tags: [__ASSOCIATE_TAG__] // optional\n}).then((execution) => {\n  console.log('task in progress with execution:', execution.hash)\n}).catch((err) => {\n  console.error('task execution failed with err:', err.message)\n})\n```\n\n## Execute task and wait result\n\nExecute task on a service and wait for its result.\nThis can be considered as a shortcut for using both `executeTask()` and `listenResult()` at same time.\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n\nmesg.executeTaskAndWaitResult({\n  instanceHash: __TASK_INSTANCE_HASH__,\n  taskKey: __TASK_KEY__,\n  inputs: JSON.stringify(__INPUT_DATA__),\n  tags: [__ASSOCIATE_TAG__] // optional\n}).then((result) => {\n  if (result.error) {\n    console.error('an error has occurred:', result.error)\n    return\n  }\n  console.log('a result received:', JSON.parse(result.outputs))\n}).catch((err) => {\n  console.error('task execution failed with err:', err.message)\n})\n```\n\n# Service\n\nRequire MESG.js as a service:\n\n```javascript\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n```\n\n## Task\n\nThe service have to call `mesg.listenTask` to start listening for task to execute by passing an object containing the tasks' key and function.\n\n```javascript\nmesg.listenTask({\n  'TASK_1_KEY': (inputs) => {\n    // Function of the task 1\n    // Can directly throw error\n    if (inputs.foo === undefined) {\n      throw new Error('foo is undefined')\n    }\n    // Return an object\n    return { foo: inputs.a + 'bar' }\n  }, \n  'TASK_2_KEY': (inputs) => {\n    // Function of the task 2\n    // Return an Promise containing an object\n    return Promise.new(resolve => {\n      resolve( { foo: inputs.a + 'bar' })\n    })\n  },\n}).on('error', (error) => {\n  console.error(error)\n})\n```\n\n`mesg.listenTask` returns an [event emitter](https://nodejs.org/api/events.html#events_class_eventemitter) with possible events `data` and `error`.\n\n### Example\n\nLet's use a multiplication service as an example. Its `service.yml` is:\n```yml\nname: \"service multiplication\"\ntasks:\n  multiply:\n    inputs:\n      a:\n        type: Number\n      b:\n        type: Number\n    outputs:\n      result:\n        type: Number\n```\n\nIf you want more information about this file, check out the [documentation on service files](https://docs.mesg.com/guide/service/service-file.html).\n\n#### Task function\n\nTask functions accept `inputs` as parameter and returns the `outputs` as object or Promise of object.\n\nThe parameter `inputs` is an object that contains the two task's inputs: `a` and `b` in this example.\n\nThe task function have to return an object or a Promise of object containing the task's outputs: `result` in this example.\n\nThe task function can also throw an Error in case of error. The lib will catch it and send it to the MESG Engine.\n\n```javascript\nconst taskMultiply = (inputs) => {\n  if (inputs.foo === undefined) {\n    throw new Error('foo is undefined')\n  }\n  return { result: inputs.a * inputs.b }\n}\n```\n\n#### Listen for task\n\nThe service have to call `mesg.listenTask` function to start listening for task to execute.\n\nThis function accepts an object containing the tasks' keys as object keys, and the task's function as object value.\n\nIn this example, the key is `multiply` and the function is `taskMultiply`.\n\n```javascript\nmesg.listenTask({\n  multiply: taskMultiply\n}).on('error', (error) => {\n  console.error(error)\n})\n```\n\n#### Javascript code\n\nHere is the full Javascript code of this example:\n\n```javascript\n// Require MESG.js as a service\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n\n// create taskMultiply handler\nconst taskMultiply = (inputs) => {\n  if (inputs.a === undefined || inputs.b === undefined) {\n    // There is an error. Return the error output with the message.\n    throw new Error('a or b is undefined')\n  }\n  // Return the success output with the result of the multiplication\n  return {\n    result: inputs.a * inputs.b\n  }\n}\n\n// Register the task multiply to MESG\nmesg.listenTask({\n  multiply: taskMultiply\n}).on('error', (error) => {\n  console.error(error)\n})\n```\n\n## Event\n\nTo emit an event, the service should call the `mesg.emitEvent` function with the event's key and event's data as parameters. This function returns a `Promise`.\n\n```javascript\nmesg.emitEvent(__EVENT_KEY__, __EVENT_DATA__).catch((error) => {\n  console.error(error)\n})\n```\n\n### Example\n\nLet's use a timer service as another example. It will emit a `minute` event every minute. Its `service.yml` is:\n```yml\nname: \"service timer\"\nevents:\n  minute:\n    timestamp:\n      date:\n        type: Number\n```\n\nAnd the JavaScript code:\n```javascript\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n\nfunction emitEvent () {\n  mesg.emitEvent('minute', {\n    timestamp: Date.now()\n  }).catch((error) => {\n    console.error(error)\n  })\n}\nsetInterval(emitEvent, 60 * 1000)\n```\n\n## Advanced utilization\n\nThe service can use gRPC APIs directly for advanced utilization.\n\nSee the [full list of available gRPC APIs](https://docs.mesg.com/api/service.html).\n\n# Community\n\nYou can find us and other MESG users on the [forum](https://forum.mesg.com). Feel free to check existing posts and help other users of MESG.\n\nAlso, be sure to check out the [blog](https://medium.com/mesg) to stay up-to-date with our articles.\n\n# Contribute\n\nContributions are more than welcome.\n\nIf you have any questions, please reach out to us directly on [Discord](https://discordapp.com/invite/5tVTHJC).\n","readmeFilename":"README.md","gitHead":"b56fc6f563bbda236f3eb8eb8f7d891bfef08130","_id":"mesg-js@4.0.0","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-yFZkTHSUm6sdzSZIoLU097JAsa1Uj3tfrJN/WZYH1KWkDkgdY0OW8xtgt+oToiZv6B6EeNUe8pifm2rOeNeqnw==","shasum":"439093a8e4043b13ba7edf34464990bdfb372eff","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.0.0.tgz","fileCount":68,"unpackedSize":128885,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdHeHPCRA9TVsSAnZWagAApCwP/0FnoSmVdVw1dPFaQj5k\nQEiAKa/q4sU8kaI1+oUPX2ECYVJZ11vAecZjKnyBjXWGx6l3BmTdb1//TXX5\nZxfosAyF4B7CEgZf1DtQQRqC5IN+dHDNchNoRTRSbL7bzUXUDSQqGlG3hcoF\nRjq8W/EUqpS0fQtFAt2E0z93+LQv/CHASCpU+75InktUGeFK5eCPKFCPTTM7\nh3EWOULKtlYFNARhaMZKrcGUj2D9U2KpG2ZWK90cGgW0cD2DA/abZXJjwyqX\nP1WogThkYpau+edkG+PR/3ZRM9VGeQ0YiDjDgqu1BQ2d7dnZMautiBpUS4hJ\nn0otZdMUoB0G9nomMOecZ02aAvvZZiAVdBRFVLJiOB7tUu4TVX2W4eLedpsK\ntGwKKlZWNyHiLHb5nVrKD1tC9UH5k5A+/Ql6wU9I0behnqb5K097ts/yppEh\nm0zh8Y+7MgptMTTxI+oIBFf7hFl1gXdAnc8TA9ccvU24CyT7laj4Le3+ru71\nyuZqnLZIAdyZo4P1ioY2tJ5Rrk9neOuXtka5mQ+PC9m8sFnV/Ti8+SrKrLz1\ntaF7GI8oXjkSF4e2i6ozxou5yoR5wbsusfHYaA2phnJ2BgT+/A/HSsZHetru\n/3J4UvHDgARJsAzcnMFZOAJ0MtapEBq5pJRE/lBxFik6f3qAameVg3EmSeO6\nf/Cj\r\n=1e1h\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFMosH/kWB/47/62jNgFb9spOSD4/2R7sY99xSawE6JLAiEA7nHWqfvG4WDLA/wfMFu//WbzNpLy1hDMyovzTZpMOBg="}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"nicolas-mesg","email":"nicolas@mesg.tech"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.0.0_1562239438898_0.9764920128459185"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"},"4.1.0":{"name":"mesg-js","version":"4.1.0","description":"<p align=\"center\">   <img src=\"https://cdn.rawgit.com/mesg-foundation/mesg-js/873333a6/logo.svg\" alt=\"MESG.js\" height=\"120\">   <br/><br/> </p>","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","grpc":"^1.21.1","js-yaml":"^3.13.1","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"gitHead":"72c201ebcddfb71916e22b6efb5e08ec27d633aa","_id":"mesg-js@4.1.0","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-b2GDfoDHZMXnr3ea8XnWhQcazgRol3eBPH/qgn772gED51Zq5u4tfUB+godXO9cVK2jsw/N4ktvtPuLY2nAPeg==","shasum":"83f109b92e29b19e3e4cdd9bc9ab31dad90948df","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.1.0.tgz","fileCount":73,"unpackedSize":137622,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdHtsOCRA9TVsSAnZWagAArO4P/0voO16oZ7jV1RujURhf\n6cXLIy/Xic2f6Y+5mJ9JqEsmep7mAB0CrvsZGBzn+7AcSNcPhqZ8EC96L4ND\nbTRK+0CIsSiFB78jIEMapz4gsyOcLaCjrRCb5T9Zj6s4IWWQas0c5UxNI3JW\nmbPxi2PIBOuwyPF4eH1uL0YUmiferzDmpmX5s6t7qmidyK5WmkLTt6FasY+Z\nx/Rc5k4jMNpXtdw6TSms9tOYaltJ3woO4W3N/M5X7WVp5fq9x+2bLqpG1eCu\n35sygzQziuUm597fAbHvpAKCL66TtoQih/Fn+GGSz+6YazWF1yEwkGxwpa4F\nguUpSYIvgbag6+WCT4tjc2pBYd84GTuIdGcYOuIYjLA5LuRy3h8wfkfdFbVl\nFZTk+yaZCYgsstCdW0tf+StNDkwKUBj9CeKniBWTvjhFUjxlbuzo3eEWd9j2\nIkts9eCf1p5yWhiiWZmxz7UbCQVe8qDSvjbdPGNyzwBokhxPKhd9SftBd860\nKFLCpwYWO7eWdQZFtPQ+N2z509UbCGXVo3siPY6LhHO0lAmRWLJpaRuvRMz3\nCvSqWjBPl0ysqwoEMeqVOWBiLjHwLPt/dSFYsODn8n1Qzu43D6seelZPcLV6\nE7COpn3rQJfdOY27vWKqAwyzKE3ynEAOEQVZHq7O7Odv0NvPLvV3N2rdp97n\nSM82\r\n=umin\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDZKG50ZTIcNM+Sw0HCVlIn74jdCpKQntL01TIFaO7jTQIgROLMV5yYYw9hzlrLPazpGnkg7GH5gcYozjXeSQHJTI8="}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"nicolas-mesg","email":"nicolas@mesg.tech"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.1.0_1562303245740_0.8551244266300835"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"},"4.2.0-beta2":{"name":"mesg-js","version":"4.2.0-beta2","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","grpc":"^1.21.1","js-yaml":"^3.13.1","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"gitHead":"de92ba11842f6378a6a94191cd2abb103cb1245b","_id":"mesg-js@4.2.0-beta2","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-K/K8C4YDVUm+zTO5/Crn1Hi+vE36VlrXP4x7OeI3+xdmGrjDmfcLvRUqZMSUKgqPY3jdW2A2UU/cVW/nPzBYiQ==","shasum":"1c905d1db0ef542dc3b0a286675f93b8ab29743c","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.2.0-beta2.tgz","fileCount":37,"unpackedSize":123566,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdOsylCRA9TVsSAnZWagAAgNoP/iDsjPfj9yx/4dcFS71O\n5Sy1UB9Yh5OefJ8pN99oqvAsBt5GnGAbjSiihm3ml+3VJGcT3XT5kQFaNs7I\n8nVAF/y6W31jK21WqImpxUi0WNYGvZdLVJp7ktUCF+FNt9HnwiyTEUa9nhzk\n//rg3agGjg+RuIQJ0SJ56D/iuF771Nl9rmUHXPdpnFlwaFHdz86MiomcPulR\n5QxIMJMEJ4Ii+qtnbPmLp6gl7gNmebXeZfh9eCGXVCYeKTscOLUiZd2mwC6M\nu4dZ+x4RKLJDCHD+dkEPrDs4wL/FMGZPPX//Bq5QujbrNzHHNvBwVbylvc0z\nKQ73FmWF1Tq6p0Hrf1rh1tkQ1xo0TGOPn7KpQQx80zHRb3KY+/8SqRjZnECa\nQiFedWare4q6BF5d1vsVBvy/QWYd4fovS3DiFoCOXgwZ34U7kCpKzLPGXqjw\nI5oj2tyf2FgGjXBL7y1ZL847DicGpUtQhbDaYxSMnWRLoRYWGsCLy98zwO1x\nYanlmNrO1RHCGolJBHcCzv7Lwbv7egntAkWUcz5laOfqRFfMT4Ufw0pRKNw4\nRkOPNkozSL6fdn9s4bHK3OzsVloZTesi78fQqoZR4xs/l2bE8wzKMU3a7AuQ\nveb5MT8imNtryJrWHseGlaXQXqBDbgPUf5EDDj+lIdwjbl/I09tLssgm+tz5\nkc8N\r\n=ikTA\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCn0AfT4tUVmTybqTPf0dbGpc8EvVTrsagIkbNjB7Az+gIhAP/tMDqNK3Y5A8xAuvWeAxIfm8khYwZBoYC11aQU7/5Z"}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"nicolas-mesg","email":"nicolas@mesg.tech"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.2.0-beta2_1564134564965_0.38437923728933576"},"_hasShrinkwrap":false,"deprecated":"use new v4.2.0-beta3"},"4.2.0-beta3":{"name":"mesg-js","version":"4.2.0-beta3","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","grpc":"^1.21.1","js-yaml":"^3.13.1","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"gitHead":"95a08e3fbd9298f2662e83da6b416aeb3a7bab94","_id":"mesg-js@4.2.0-beta3","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-y+ddHOCfufk1T8u6Fe2mSIBPzl+AMjZHodb/1I+3nzESjOTBx6zt0ID75lMhFr66t4C+9WUr82OwXS9cmESwZg==","shasum":"6bf7b3bbe1d53307de9add067de16307f707d869","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.2.0-beta3.tgz","fileCount":80,"unpackedSize":232307,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdOtC6CRA9TVsSAnZWagAApUcP/A/DT08psylXoGrTlyTQ\njVOSbN6srnspeUc99LivQgK5FV1DKD94UruqEn7yo+5JjkWDgS14QtV80gQA\n1ojfdh5IqvXlP3iTXN4KXYQI8FXN21XQthrlzd3cT09y+fCcZNBLe10/GSly\n4ZgjxCoE/mwJG2DB+plXS3HnUN8KKoGPbomEnVRQ0/X3QhnoMuOPJaCR1amj\ntxLLhfgV0RUp17KXCCB2gWiw2BroO3yx+hrlW53fir7pLx4ISo66k6TqYnZM\nvcyweagKOI/fZBebYx9XsQ8LiazJZlfQK4Fdqx4Zg05WQLHmllTVBz8TOmps\nG5L/HQdDTXmF8twiL5e4ZPssBZe2MEi39c9h4+FXquJu7I6DbfT3VXHR2iy5\nZfmT/wizAODQ1d9Hsh/SkG15DVKD9gEWw8Zns1HG9udSN5Y71qiwEqt8jUqI\ngPD+dKBiD+hsyKkM+WT/HtTstEk8kcJxh9y5z19dqUvEqWoFS+oMbUm2kxYd\nOEMMT3OJ10UPMEdqIc76oa6nkYZWVqjAigA4HzFTky3jTJ0mZD4ddLk6LK+4\nTiyQFHykknuz7JOIx7Hk4JwuGu207A7NxU2wPJPhHzZhvx2umE3z+Ka8ADZF\n7wGLBHR9uhXXehdl0anF/NTibNpEzxofXkeFhbRRjzhEihEPTiPcLoJ6uP+W\neuti\r\n=O0Q7\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHlSH6BxavhhoxAPZX+qOwMn2SGxu4KSdwJW9/npeL7/AiEAkz06jlbiWQ8Yy8FqkZL8Oaa05T2n6eS0JAcS8ExJDcI="}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"anthony-mesg","email":"anthony@mesg.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.2.0-beta3_1564135609459_0.2262313694963225"},"_hasShrinkwrap":false,"deprecated":"use new v4.2.0-beta4"},"4.2.0-beta4":{"name":"mesg-js","version":"4.2.0-beta4","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"gitHead":"6c4b173a9b7f68bba6d93e591aae19920d6aa28c","_id":"mesg-js@4.2.0-beta4","_nodeVersion":"10.16.0","_npmVersion":"6.10.1","dist":{"integrity":"sha512-OXPxPtjSt55IiEk4X8/hZJYKQ9PZ6yAIaaFu5hnQJc+fWyzRrfvOlww+90CB1ZM3eP7RDfpups/FfiJd0CtJqA==","shasum":"95e266aa37513851db45cfc5ec529638b7ea0c75","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.2.0-beta4.tgz","fileCount":85,"unpackedSize":254534,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdPumSCRA9TVsSAnZWagAA7q0P+wf0l/Sza2v5ZncOOMqG\npa8+RMnC4j7FxyMtrd2UXvM72QEgcBngR1rOdHq6x1+f+YdXDkfxm604Zk7C\n06wUSmHXDDqqmdMnqAXG5YqTo00hVAXNeQECrtvj5Pj2vUdIPfunTv7IaWC7\n+XO7JAzer75XXykXmYqyBsgdX5wYN/eyIoy86nS4GzlPImuG/XrgV1DUbela\ncRFMoYu2aW+20yvWWRhxuIP7XBhXv07Tzqe+HYs+zcQlpOWV8Wo3PHhYDLHe\nUUFNXxVYuJN6bqNdHm4xYN9vNYW8GooEAADguhi4xU2XgXOuKIFHDVIiiJJm\n6vF7r5yAFneiU6ke4LsqCVyy0Lyt+oIPZDt/pQSQVG5Xotwfz6Rwsm94ORzK\n006cX/F+xKYyeJQvxnXpVe7LyKK7biO4O0FCeNbRylOv65Ej/wsia6q+9JWs\neHWCadUx+vNMiZ7YlmvM6OTSct1REWYGfmmzWZLh15am7aoygu94resyzeSY\nqzi/Mee+sL6IBSLd9E5SLD6rmkKF/mS8uF/8ZUdpT+dlVW4RjwhhdZLhkY/3\nLQiJsP0cvDojhlYXimMp5a9CMHXaSpLE+U1JkKn0vaB0KVny/ODAisZNPxhi\nfa1APLDBS2IxawAF9VQQgv6G+Q6Lr3acv6eDhqCle6252X5jrt7rB4WW17Jr\n5yQh\r\n=ERdE\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDfKG31spfKiMg7dzkqBZE0aZFYTRG7PDdZbFlKlz6k/gIhAKTeQz7pdixsPbbdUet/LpYnF57PBbS09Zo0vheJvC+m"}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"nicolas-mesg","email":"nicolas@mesg.tech"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.2.0-beta4_1564404113758_0.9776337327665612"},"_hasShrinkwrap":false,"deprecated":"use new v4.2.0-beta5"},"4.2.0-beta5":{"name":"mesg-js","version":"4.2.0-beta5","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"readme":"# mesg-js\n\n[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)\n\nmesg-js is the official JavaScript library to interact with [MESG Engine](https://github.com/mesg-foundation/engine).\n\nThis library can be used from an Application or a Service.\n\n# Status\n[![CircleCI](https://img.shields.io/circleci/project/github/mesg-foundation/mesg-js.svg)](https://github.com/mesg-foundation/mesg-js) [![codecov](https://codecov.io/gh/mesg-foundation/mesg-js/branch/master/graph/badge.svg)](https://codecov.io/gh/mesg-foundation/mesg-js)\n\n# Contents\n\n- [Installation](#installation)\n- [Application](#application)\n  - [Listen events](#listen-events)\n  - [Listen results](#listen-results)\n  - [Execute task](#execute-task)\n  - [Execute task and wait result](#execute-task-and-wait-result)\n  - [Resolve SID](#resolve-sid)\n- [Service](#service)\n  - [Task](#task)\n  - [Event](#event)\n- [Community](#community)\n- [Contribute](#contribute)\n\n# Installation\n\n```bash\nnpm i mesg-js\n```\n\n# Application\n\nRequire mesg-js as an application:\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n```\n\n## MESG Engine endpoint\n\nBy default, the library connects to the MESG Engine from the endpoint `localhost:50052`.\n\n## Listen events\n\nListen events from a service.\n\n```javascript\nmesg.listenEvent({\n  filter: {\n    instanceHash: 'EVENT_INSTANCE_HASH',\n    key: 'EVENT_KEY' // optional\n  }\n})\n.on('data', (event) => {\n  console.log('an event received:', event.key, mesg.decodeData(event.data))\n})\n```\n\n## Listen results\n\nListen results from a service.\n\n```javascript\nmesg.listenResult({\n  filter: {\n    instanceHash: 'RESULT_INSTANCE_HASH',\n    taskKey: 'TASK_KEY_FILTER', // optional\n    tags: ['TAG_FILTER'] // optional\n  }\n})\n.on('data', (result) => {\n  if (result.error) {\n    console.error('an error has occurred:', result.error)\n    return\n  }\n  console.log('a result received:', mesg.decodeData(result.outputs))\n})\n```\n\n## Execute task\n\nExecute task on a service.\n\n```javascript\nconst execution = await mesg.executeTask({\n  instanceHash: 'TASK_INSTANCE_HASH',\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nconsole.log('task in progress with execution:', execution.hash)\n```\n\n## Execute task and wait result\n\nExecute task on a service and wait for its result.\nThis can be considered as a shortcut for using both `executeTask()` and `listenResult()` at same time.\n\n```javascript\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash: 'TASK_INSTANCE_HASH',\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nif (result.error) {\n  console.error('an error has occurred:', result.error)\n  throw new Error(result.error)\n}\nconsole.log('a result received:', mesg.decodeData(result.outputs))\n```\n\n## Resolve SID\n\nInstead of hard-coding `instanceHash` in your application's env, your application can resolve dynamically using the service's SID.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash,\n  .....\n})\n```\n\n# Service\n\nRequire mesg-js as a service:\n\n```javascript\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n```\n\n## Task\n\nThe service have to call `mesg.listenTask` to start listening for task to execute by passing an object containing the tasks' key and function.\n\n```javascript\nmesg.listenTask({\n  'TASK_1_KEY': (inputs) => {\n    // Function of the task 1\n    // Can directly throw error\n    if (inputs.foo === undefined) {\n      throw new Error('foo is undefined')\n    }\n    // Return an object\n    return { foo: inputs.a + 'bar' }\n  }, \n  'TASK_2_KEY': async (inputs) => {\n    // Function of the task 2\n    // Return an Promise containing an object\n    const response = await fetch('...')\n    return response.json()\n  },\n})\n```\n\nThe task functions accept `inputs` as parameter and returns the `outputs` as object or Promise of object.\nThe task function can throw an Error in case of error. The lib will catch it and send it to the MESG Engine.\n\n## Event\n\nTo emit an event, the service should call the `mesg.emitEvent` function with the event's key and event's data as parameters. This function returns a `Promise`.\n\n```javascript\nmesg.emitEvent('EVENT_KEY', { foo: 'bar' })\n```\n\n# Community\n\nYou can find us and other MESG users on the [forum](https://forum.mesg.com). Feel free to check existing posts and help other users of MESG.\n\nAlso, be sure to check out the [blog](https://medium.com/mesg) to stay up-to-date with our articles.\n\n# Contribute\n\nContributions are more than welcome.\n\nIf you have any questions, please reach out to us directly on [Discord](https://discordapp.com/invite/5tVTHJC).\n","readmeFilename":"README.md","gitHead":"3bd491c482ca8452733ac13e51f2070fd1e3c085","_id":"mesg-js@4.2.0-beta5","_nodeVersion":"10.16.0","_npmVersion":"6.10.1","dist":{"integrity":"sha512-zzJFsN6NaTBya/PR9iJCeYbWpLXJ5TVdG7R0QRqVCZd+UhGgzUuI8WMAKlu3NTxbesYoaizXA8/zSnoWR+tQNA==","shasum":"da077e70d46fba2838e28ad1c04860bb301f3138","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.2.0-beta5.tgz","fileCount":85,"unpackedSize":254686,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdPySGCRA9TVsSAnZWagAAc/QP/icZOeZSso6uVJO3480v\n1fO3swtMtmHwOqJuy+sJ+XSvTnOmhaP1vPTTkLCFWJJO6f3I2ESMmFaF8F3e\n5AgG0jF5LJzn0zv9R9ZVVU+WFEEXg3j+fRCxpz/y+05LH/J2Y3bBnsTJ+eM5\nvuPrG6Y2RSQs6rUEfpOkV20Jahe+rARw480qeKgd43N8QAzD4IBWOG+jKaQ7\nodHsxUCE2VL+dQnPxDHyv+Kgjfk2FP/X+cwCJLuJkdPXPcbBrMKlg5WIl2B4\ntxm2P/pQeOETVqGqMeLCOztB7XnczQZ1tA1hYnFPXjWN3aP8g8aXrUNMWQBK\nnWOtfk6idcI1uxUnaEwcajDfd5gzucjhFtfTdVSZnx+91BfrrDXq0cOqwVNi\niN25p01KnHL8FNaSnRIq5Cab8QHGpoIvNZeqMbwJgWp//3yT1ujRRWyN8Qbh\nMNzPuSwHQTJM9Z6m03qQAVsJnwwC2JiXm2KpnpaTUrclGSorIuIjmJHazSTS\n3pEifrrYrDIBzsjC5aNdDn0LqwZqWZJdswJgZ7Q/7rePdciPIQTB2HF4sJPF\nu/9MdJFczwxBizDFDWuWw8DDLua6fIjJstiMHE/QxjqoZNlAGU6nTY1vTuz6\nWE8XX8sz3Oe75Lp/VIs9R1Lhx48aZb5TjpsxJS3tVNDy64WgYsxe6ltx4aPP\nsA/3\r\n=jjmW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCK8JEkYiHon/ZhJvLB6JLLzbaDjk9B97pVqqHvgH2GWgIgZ2WNM1G4TZ2VKoIAEeL9dF+sggIRF6ZmVM4FNq8VFFM="}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"nicolas-mesg","email":"nicolas@mesg.tech"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.2.0-beta5_1564419205982_0.5275861926956775"},"_hasShrinkwrap":false,"deprecated":"use new v4.2.0"},"4.2.0":{"name":"mesg-js","version":"4.2.0","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"gitHead":"3750a580ad656bfe0eb1a6351a6056c9a7cc75b7","_id":"mesg-js@4.2.0","_nodeVersion":"10.16.0","_npmVersion":"6.10.1","dist":{"integrity":"sha512-02SnUlcPgkOYZX2ahzksXDlmft3W+5xariXIamPA2CL9Qw4FaNoTXhR2ICCsWyfPuPKV1JEnkxZQqs1afH0I9g==","shasum":"4e191356a008797f0464655d178d358e7e2949db","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.2.0.tgz","fileCount":85,"unpackedSize":255112,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdPyZPCRA9TVsSAnZWagAAof4P+QAI0aoPnDiQNu6OSOUo\n+KNc14zlIbPnZIkQlB5Rm6/xwPvIr1M42mWpOTf9J3zb+HQxnhJSIFcME42b\nURn4Ac5IgPR1UytWqiPiVST2evj+57NRbeezQT0Kqpm+mnr3pmMNfU7msXB5\naT+3d6nzezuilkia3eetdCVq3204bJ6QPoLo8Y3YAL8K7OUh0+Awjkjo/AH/\nB7k9wjrpOIbrJFzy8dn/p+NtbKS+r2lrZmHUlrW/6Qvs9Ma7EvXdvsArJVLc\ntsGrb+rsSQ+hsUJJ+3eAYS77WFZQRJt6NJ4AXaUPfzmYCo7a6yTmz1W0ZCCH\njdhUbYigkhCvCqy+5P1Y+ubQVnzhIIBtu6Xw8VgtE8BS1jeOsxxkwoMrjmrN\nMWlVd6cZGbQk17WR/CQseCJm8R9m+rhw+2OBnUTjJTA2nXYdU9KblKNAolxw\ntEBiLaKpf4vvAIsIqTOl2R278mLgldH8Ws/Cwn/4iDH65bAPH9oHQfTs0oJq\nckEITZX6wvGPw6/VO1NF9BWjrh3h7jJitdNXyPXnANT0J7bJ7jmFAmee2oEn\nPlCnFNhy427FF8hNb7UfBhbC7Zp4bNv5CrJgyE817Q2yJ+xvvKQWiOwcaCtT\nHgIozoBAyghi4jslKib85aUbP7/1nuVsUpOTmdj9kNZC5dELju7y9vJxm5E6\nURXu\r\n=uwj1\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDPMU7js3aiOmjU4ngNk6Of845JwiZ6fCWL1Y4CVykpwgIhAN/kIekEIjH4P898znvJtdgV2aqjcO1IHpYdayEb+j/B"}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"nicolas-mesg","email":"nicolas@mesg.tech"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.2.0_1564419662720_0.617736144028098"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"},"4.2.1":{"name":"mesg-js","version":"4.2.1","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"gitHead":"cf8652a718b6b1ff60a8b16c19dc9d346ddc1dc5","_id":"mesg-js@4.2.1","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-s/KJfRjC1ao+Sdly+KoFhmxzRRp37b9b+hfc3zVt7RecG7dNXz9LLWfK8wnpXHbepdY/BhWXXcJTyyBT2/1mNg==","shasum":"7db755bf48e1bbb16bd6769140547cf5201a24da","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.2.1.tgz","fileCount":39,"unpackedSize":134162,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdQRHGCRA9TVsSAnZWagAAmt4P/3jARfTJSENANwANKgHK\neC+5taTXctxXEFXgU3AEWrX89CoJR14kE8VKJigN1Gt8zpDD9a5GtizexUZK\n2RhwzZ0zimxTYdbRy+XmNj1hhi8K7qBXZ+VuArm7hjmfN35JVmq3RvQmpUUq\n3GSjWrA8sunt22NzJp3YrNe9ZScinmsDr3dcD68u6e95L8dd2+3idnt5nJfr\ny8CQd4iN0ph7kSOLsdhUaxLSfdYFNuyf+FFohD6eWXkg5DLLJxyAQIt917zK\nuCd7WEMFqAAI2+S86+YWwftQzAMCmrVLgF3/ds+417cSDVIJOlWvbnj3ms+y\nyBivliR8d8dSSfIO7xcgTQ6BruxwIt4V0qyPc1M9ivaGvF0s8YdfkNR5aTm0\nJtOgJBATJ4nMJOZS7VpxeNyz11Y/9PnVZSZ+zCDRg0UKnX6mdWunJYKbUtyq\nplH6FhBhl+2Ic/qlidOrWndcMvLJqj2UbQGqxWG40J2d8zUU/HQo1wh/3l4Q\n2gvbKL92L5aAE/oNUzYqa7NzAuHSs5g50wmRSNpBLkYIb9mjFpFkBu36M6Xt\nRwbv5P8EXAWankAuCuLJrf6PZUJ8ID5Bzn2HR4r9Aa7S0yK5Xw0hPZHxt2D4\n5m8RK7gqZet2OGybYtdQisimEb9XdA4ViOaQBltUAflwdQJqxrMZMTI1hnGz\n+u6w\r\n=h4nI\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDjc+IomKfQdzq25P/l4EvQ43a/zQOGWZ7EzNXVJZF9RAiEAldUNUwfhgJWfNi3J8k6qHkHi2RGSjyXik8zDLHgnh2E="}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"nicolas-mesg","email":"nicolas@mesg.tech"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.2.1_1564545477333_0.9770511441445004"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"},"4.2.2":{"name":"mesg-js","version":"4.2.2","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"gitHead":"e228254a9e7bfee7bc9f1d2394b4189036a8244c","_id":"mesg-js@4.2.2","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-8/dZulhL9JHMFUTHPtExkHRTTQ1hMfGZehojpjdpv9zcC5o1mIAGQ7QylfdgzuJvEw9uOrBBa9yqDp7cYSK03w==","shasum":"2ce83ca8dfc7883c9b7cd49c17a48326f6196c3b","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.2.2.tgz","fileCount":85,"unpackedSize":255592,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdQRSaCRA9TVsSAnZWagAAcFcQAItH3fXaV7oTXEFzJq0I\nPIoYtUxjuYvIXp49lZvzhLJ23bMUCZAHbTLWnwd3GmtEj5GuVAFqb1UFrLAn\nAe4wj2OJ5MljldwsU4PacTV8reB9mwXJ1wRPmUrqBVg6pQjw2+g1HhkDuJ01\nFGznJfs7aN/WMwP9+Thm8I7w0bT6vKk5c+YBO0/KuWkgsCjjFXcYX3dS+dlD\nPO29ZCyqcbYLxBd8DydhBAqyXRz1ulc8y3ASv9cU3bevn7BHwNZnKrD3M32w\n6Gxi4P2MBK6/4JGKDH0PwYfpAzwmGbp59iczHX5KT0ByBcyXrODD09f78XYH\nuFU7PRexZJEf/xoa1mlmTwV7g/b0LrRDeGYZrOT5JKQpQ0Ph4AOraUA+/KUU\nS57PxAaJEeeZ6AXX7TKKaAWRZBJgHRJ+39SEnFQo5yylGUqMtj2TUDdEV1J/\ngkbyG+kAhI/ZG8sBTWIzjN4SBz1eOqfSub27hWKjTGoKoabG5GvlLhGzNN7k\njWyZumYgwIrd9WnHcd4Zw56jDfVspP9pDL0Eh52mOg22woZfU30rXIljJUCD\n5iQe09rHsosORTf/o9zhnzFt3Rlu0MyCOIBTQzzfi1zpiraaHMut7bhcnobU\nMH4l3fZT12aQmO7MlXb02hwjAkRyoPW3m/eLqEf860pRt4oiBMno+0n+d3IP\nEwqG\r\n=unHQ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFKVgeVm5zpSqT0dzLwFAwy+9FBW3zrH/Zsax5sBwz2jAiA28UCkrULjTp16omqbdG70K5/QczkI3L2u/qoS41TDeg=="}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"anthony-mesg","email":"anthony@mesg.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.2.2_1564546201824_0.7317171754033713"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"},"4.3.0-beta":{"name":"mesg-js","version":"4.3.0-beta","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"gitHead":"1c1f257cf2be6341f62471d5fe3baf1f045a5a10","_id":"mesg-js@4.3.0-beta","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-nFUSINLEeN/L+N+5eaL/XcXEE/HRiq/boG9JVj3Eg5WCB9xyATa4xEuC9FGqaEqQfya+udE9MbxXygcAy/wzhg==","shasum":"f4c62c3b6674e51c98644028914234af05eac149","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.3.0-beta.tgz","fileCount":90,"unpackedSize":282769,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdXQQ+CRA9TVsSAnZWagAARZwQAJrmfnzME1aNYlGapXXH\nkMPzV+H5aYNUmYthga0LYokPmVp9kzkGrr8ThQJKA3HqNfkpxUpwNXZPepNZ\nQwZn1Rnjwza0pOh5bJMri7jzImMV/Qpal1tdD2AJIJ7m4Vx26mQDKMyoXe+H\n4JuIy3Pxyedu2I6rqmQLeJG7NW9pxOrTRcU/mmHcku6JHhQB3QUzVtPFMuOO\nS3qb3PfFyOosxOJwTRvsgD6MmZmR5y1ZhAcA5cO0uOwJp3HmhLwIYAmn48uS\naw72PMNLvGEtDlgZmN3r11HCwJggjuL94l1ZaHD3h15Qg5+NaYNLBUzsPwJp\nfac9u9S4ccUrhNUYey/pokekWPG14ywz3Z8F1X4eIB53WKJo0XmpK4CP8x0z\noUqcpQ01agGkX/6hj4lc6oThufmxahfyo/TxOvRBXb906CI+ZzQiLmfTAwCw\nVwUi9wDO+OigHbAFWGF35VCkrnxfzE9tE4EbyoZYhC3vSGdEj0WVSyMWoEck\ntJ5wwInHYQPoPLA9N+vamsjfUIpJYKdfgnhKEYgJMcDkl0DH6ySJrRQxKMm2\n7gbvOmef5D4qnPlw/kxIUgdQ7TVAIcd7DBn1pQOsm2XQVs9mTPZWsZMkysSi\nYFSv1mDOPNrkfGrfoE08/E8NAt7HUDWYBnc0sDIymtNU5ZeLbWXDcMd1d0a5\n87EE\r\n=CEi9\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHC+Ab0/dQz8Ot/jqnh5z6kCHslVpQ9V3SfPrNOa8JA+AiEA9bDzXfDVOQk/ODwbCD9376KmC3ezUDItuXxnc1DIR1c="}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"anthony-mesg","email":"anthony@mesg.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.3.0-beta_1566377022217_0.8125427514650363"},"_hasShrinkwrap":false,"deprecated":"use new v4.3.0-beta.1"},"4.3.0-beta.1":{"name":"mesg-js","version":"4.3.0-beta.1","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","base-x":"^3.0.6","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"readme":"# mesg-js\n\n[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)\n\nmesg-js is the official JavaScript library to interact with [MESG Engine](https://github.com/mesg-foundation/engine).\n\nThis library can be used from an Application or a Service.\n\n# Status\n[![CircleCI](https://img.shields.io/circleci/project/github/mesg-foundation/mesg-js.svg)](https://github.com/mesg-foundation/mesg-js) [![codecov](https://codecov.io/gh/mesg-foundation/mesg-js/branch/master/graph/badge.svg)](https://codecov.io/gh/mesg-foundation/mesg-js)\n\n# Contents\n\n- [Installation](#installation)\n- [Application](#application)\n  - [Listen events](#listen-events)\n  - [Listen results](#listen-results)\n  - [Execute task](#execute-task)\n  - [Execute task and wait result](#execute-task-and-wait-result)\n  - [Resolve SID](#resolve-sid)\n- [Service](#service)\n  - [Task](#task)\n  - [Event](#event)\n- [Community](#community)\n- [Contribute](#contribute)\n\n# Installation\n\n```bash\nnpm i mesg-js\n```\n\n# Application\n\nRequire mesg-js as an application:\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n```\n\n## MESG Engine endpoint\n\nBy default, the library connects to the MESG Engine from the endpoint `localhost:50052`.\n\n## Listen events\n\nListen events from a service.\n\n```javascript\nmesg.listenEvent({\n  filter: {\n    instanceHash: 'EVENT_INSTANCE_HASH',\n    key: 'EVENT_KEY' // optional\n  }\n})\n.on('data', (event) => {\n  console.log('an event received:', event.key, mesg.decodeData(event.data))\n})\n```\n\n## Listen results\n\nListen results from a service.\n\n```javascript\nmesg.listenResult({\n  filter: {\n    instanceHash: 'RESULT_INSTANCE_HASH',\n    taskKey: 'TASK_KEY_FILTER', // optional\n    tags: ['TAG_FILTER'] // optional\n  }\n})\n.on('data', (result) => {\n  if (result.error) {\n    console.error('an error has occurred:', result.error)\n    return\n  }\n  console.log('a result received:', mesg.decodeData(result.outputs))\n})\n```\n\n## Execute task\n\nExecute task on a service.\n\n```javascript\nconst execution = await mesg.executeTask({\n  instanceHash: 'TASK_INSTANCE_HASH',\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nconsole.log('task in progress with execution:', execution.hash)\n```\n\n## Execute task and wait result\n\nExecute task on a service and wait for its result.\nThis can be considered as a shortcut for using both `executeTask()` and `listenResult()` at same time.\n\n```javascript\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash: 'TASK_INSTANCE_HASH',\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nif (result.error) {\n  console.error('an error has occurred:', result.error)\n  throw new Error(result.error)\n}\nconsole.log('a result received:', mesg.decodeData(result.outputs))\n```\n\n## Resolve SID\n\nInstead of hard-coding `instanceHash` in your application's env, your application can resolve dynamically using the service's SID.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash,\n  .....\n})\n```\n\n# Service\n\nRequire mesg-js as a service:\n\n```javascript\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n```\n\n## Task\n\nThe service have to call `mesg.listenTask` to start listening for task to execute by passing an object containing the tasks' key and function.\n\n```javascript\nmesg.listenTask({\n  'TASK_1_KEY': (inputs) => {\n    // Function of the task 1\n    // Can directly throw error\n    if (inputs.foo === undefined) {\n      throw new Error('foo is undefined')\n    }\n    // Return an object\n    return { foo: inputs.a + 'bar' }\n  }, \n  'TASK_2_KEY': async (inputs) => {\n    // Function of the task 2\n    // Return an Promise containing an object\n    const response = await fetch('...')\n    return response.json()\n  },\n})\n```\n\nThe task functions accept `inputs` as parameter and returns the `outputs` as object or Promise of object.\nThe task function can throw an Error in case of error. The lib will catch it and send it to the MESG Engine.\n\n## Event\n\nTo emit an event, the service should call the `mesg.emitEvent` function with the event's key and event's data as parameters. This function returns a `Promise`.\n\n```javascript\nmesg.emitEvent('EVENT_KEY', { foo: 'bar' })\n```\n\n# Community\n\nYou can find us and other MESG users on the [forum](https://forum.mesg.com). Feel free to check existing posts and help other users of MESG.\n\nAlso, be sure to check out the [blog](https://medium.com/mesg) to stay up-to-date with our articles.\n\n# Contribute\n\nContributions are more than welcome.\n\nIf you have any questions, please reach out to us directly on [Discord](https://discordapp.com/invite/5tVTHJC).\n","readmeFilename":"README.md","gitHead":"84048873362d94be91b120adea141a2d67cd13dc","_id":"mesg-js@4.3.0-beta.1","_nodeVersion":"10.16.0","_npmVersion":"6.10.2","dist":{"integrity":"sha512-0E42wR8fbOpCdgWlilnkzj+Dt9i8AWobjUJFsZCPgzIC3smjdvNAJEJfmU7VvaVpow7A0JwW4hGnhDxk3LZxHw==","shasum":"db69b0d854b15fc2e2c6df694f27d61e1409435c","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.3.0-beta.1.tgz","fileCount":94,"unpackedSize":295888,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdZ8UxCRA9TVsSAnZWagAAjQUQAJsvf18442nYsL4CwnBt\nB2QggMhb7vSr0JIpgrjXEUaNNzdZEqJK7wQWrmQYmIYWvP2WXBrCZqHFRz/t\nJElvpNdFLEe0JKTtC4DP3sEWEuO979QHNMvGsIKLBEyf6OPsAWO1dyrV3JWA\nFPtDk7xhcesjEMtWay/DokzuBCF+eSojm+AmsMLBnRKpfbKjcKhUigYkb6tK\nrHsF1271VNdhmkZFm71Rz4Tz6qEqUD3z7yzcpown904GRMAwesnjcYoboW9t\nNowwdTjZqXet07f4Y5ndNsdgNlQTJm0FEBgg969jk0siKE/+cQIDrMHMSjL9\n+nIJozLgyXkpOD1NsIE0hZq2AYlOELNvM1DkzzVWQcijxRV8WJWIJrWHVs4E\nkPz5qOKYlbXicgIFlpH1ldgUDnc5b8B+lnUCsHIe+PNciJJyXNtwmvMOyaDw\nPjbSnAoAcr2AQaPzPc36cPeIpQIbzJBRG7VuwE9fpTQXOIS165x/eKRLie33\natWYEddgUfN2R6xRDpnCapxGIxI/i0R+vGPMxv0akPojTLkWYunACzIQ82BO\nmfhqktPqXw+IvOtswkHnGyJiyafgdHYpUjYW9wwTflaDJ7W9JLHFcvSwchD3\nkS0a7zebuAQbrOD7K5jJxlKyaVlHJ/no1ZbS+DuOZB09ZdprW5JWHeor30fj\nSht5\r\n=qoz1\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCVFz38LESphHr5j9ydsfmGDu5efs/fgf9PW8il9nbrIQIgDi4U4uN7e6vSwp+V1qOVC80qwjJRQVxDFEMU4D/So9c="}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"nicolas-mesg","email":"nicolas@mesg.tech"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.3.0-beta.1_1567081776343_0.37790865625610404"},"_hasShrinkwrap":false,"deprecated":"use new v4.3.0"},"4.3.0-beta.2":{"name":"mesg-js","version":"4.3.0-beta.2","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","base-x":"^3.0.6","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"readme":"# mesg-js\n\n[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)\n\nmesg-js is the official JavaScript library to interact with [MESG Engine](https://github.com/mesg-foundation/engine).\n\nThis library can be used from an Application or a Service.\n\n# Status\n[![CircleCI](https://img.shields.io/circleci/project/github/mesg-foundation/mesg-js.svg)](https://github.com/mesg-foundation/mesg-js) [![codecov](https://codecov.io/gh/mesg-foundation/mesg-js/branch/master/graph/badge.svg)](https://codecov.io/gh/mesg-foundation/mesg-js)\n\n# Contents\n\n- [Installation](#installation)\n- [Application](#application)\n  - [Listen events](#listen-events)\n  - [Listen results](#listen-results)\n  - [Execute task](#execute-task)\n  - [Execute task and wait result](#execute-task-and-wait-result)\n  - [Resolve SID](#resolve-sid)\n- [Service](#service)\n  - [Task](#task)\n  - [Event](#event)\n- [Community](#community)\n- [Contribute](#contribute)\n\n# Installation\n\n```bash\nnpm i mesg-js\n```\n\n# Application\n\nRequire mesg-js as an application:\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n```\n\n## MESG Engine endpoint\n\nBy default, the library connects to the MESG Engine from the endpoint `localhost:50052`.\n\n## Listen events\n\nListen events from a service.\n\n```javascript\nmesg.listenEvent({\n  filter: {\n    instanceHash: 'EVENT_INSTANCE_HASH',\n    key: 'EVENT_KEY' // optional\n  }\n})\n.on('data', (event) => {\n  console.log('an event received:', event.key, mesg.decodeData(event.data))\n})\n```\n\n## Listen results\n\nListen results from a service.\n\n```javascript\nmesg.listenResult({\n  filter: {\n    instanceHash: 'RESULT_INSTANCE_HASH',\n    taskKey: 'TASK_KEY_FILTER', // optional\n    tags: ['TAG_FILTER'] // optional\n  }\n})\n.on('data', (result) => {\n  if (result.error) {\n    console.error('an error has occurred:', result.error)\n    return\n  }\n  console.log('a result received:', mesg.decodeData(result.outputs))\n})\n```\n\n## Execute task\n\nExecute task on a service.\n\n```javascript\nconst execution = await mesg.executeTask({\n  instanceHash: 'TASK_INSTANCE_HASH',\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nconsole.log('task in progress with execution:', execution.hash)\n```\n\n## Execute task and wait result\n\nExecute task on a service and wait for its result.\nThis can be considered as a shortcut for using both `executeTask()` and `listenResult()` at same time.\n\n```javascript\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash: 'TASK_INSTANCE_HASH',\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nif (result.error) {\n  console.error('an error has occurred:', result.error)\n  throw new Error(result.error)\n}\nconsole.log('a result received:', mesg.decodeData(result.outputs))\n```\n\n## Resolve SID\n\nInstead of hard-coding `instanceHash` in your application's env, your application can resolve dynamically using the service's SID.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash,\n  .....\n})\n```\n\n# Service\n\nRequire mesg-js as a service:\n\n```javascript\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n```\n\n## Task\n\nThe service have to call `mesg.listenTask` to start listening for task to execute by passing an object containing the tasks' key and function.\n\n```javascript\nmesg.listenTask({\n  'TASK_1_KEY': (inputs) => {\n    // Function of the task 1\n    // Can directly throw error\n    if (inputs.foo === undefined) {\n      throw new Error('foo is undefined')\n    }\n    // Return an object\n    return { foo: inputs.a + 'bar' }\n  }, \n  'TASK_2_KEY': async (inputs) => {\n    // Function of the task 2\n    // Return an Promise containing an object\n    const response = await fetch('...')\n    return response.json()\n  },\n})\n```\n\nThe task functions accept `inputs` as parameter and returns the `outputs` as object or Promise of object.\nThe task function can throw an Error in case of error. The lib will catch it and send it to the MESG Engine.\n\n## Event\n\nTo emit an event, the service should call the `mesg.emitEvent` function with the event's key and event's data as parameters. This function returns a `Promise`.\n\n```javascript\nmesg.emitEvent('EVENT_KEY', { foo: 'bar' })\n```\n\n# Community\n\nYou can find us and other MESG users on the [forum](https://forum.mesg.com). Feel free to check existing posts and help other users of MESG.\n\nAlso, be sure to check out the [blog](https://medium.com/mesg) to stay up-to-date with our articles.\n\n# Contribute\n\nContributions are more than welcome.\n\nIf you have any questions, please reach out to us directly on [Discord](https://discordapp.com/invite/5tVTHJC).\n","readmeFilename":"README.md","gitHead":"34d6654b9a714df60bd1751981914549299d7e17","_id":"mesg-js@4.3.0-beta.2","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-dSIeOTFB0aMmtQSuDrFieQl6OLbmssMLH5JHHCnMZ/GRy1BEXuhbtQVfOXRHBFEprp/gXYAmdKehN6l1R80FsA==","shasum":"015d0ced446caf8aa2c0e742d8b7cb010bceced1","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.3.0-beta.2.tgz","fileCount":94,"unpackedSize":303557,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdalPWCRA9TVsSAnZWagAAHCEP/jRvyI+sr1l8rCLZBdyK\n1fl1AIqmlG3LIc96j8d4auwXa7LRXZXFBawG5nDwtxEwBKE9vecmPRG/RwQ4\noXRKKHcwmjwLDhic7YeK/QN4by5WajoITciU1+r+ZDy6HE4jczDTlAUSZ8TL\n4MsjUMqZs9waZMxuAhdLJdyYaL9ex8fG+1lt/3IYbbwL3kyhdxbe8mMTpok6\nHlyTCPymeQHh8kWXqnFn0AdpJOEyPiKPhOsRj8RH2Y7CEmW38YW61gP8gFRw\no2lT/rYImI61pYM/HqwGu1ZSux8TvMWY2V/D41GmG/fVRm7ytmggAweH0A9o\n81VwSzSdiHdAL7oHKDUUuRzcHfYIuIFDhcD09dDFbxhPs3M959GdSYCKDkx0\n+x8UvWxX/p8jGiZk8xzENToSjJrka+P4ZOTzKsIorEwQyvtRjrr0ajMTupFO\nx31duI1nll9RXiiMXgS+/S+Yau15WTYOy/YTRAgcvHwkIde9zqttkwPZ6t4r\n3ngHGPz6c60vKHB0p1LdxgMc6ASqST7OUxESHw3MMBFU818z3Fs2/Z9zFvyB\nfpx8qevPA0JCPNb/KOfwGdZlgarvfWgCeX1SBuj6SVoc2Z0ML1pxb5YzSQtP\nGhDqhh72syHoSh9y29VA2QqXC5PIaNNWcIcuKdliZDO/AawiPX0rA0wrPY6G\nIlkh\r\n=VzVq\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAHx5scTKhxCnsC8jz/fZ1YoNdRAUVxpLafES6nNGnmQAiAclY4I1JHMn9aLAwlE1OK0wu0yPEIgd91g2XsUkjvPeg=="}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"anthony-mesg","email":"anthony@mesg.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.3.0-beta.2_1567249365390_0.3049287206274043"},"_hasShrinkwrap":false,"deprecated":"use new v4.3.0"},"4.3.0-beta.3":{"name":"mesg-js","version":"4.3.0-beta.3","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","base-x":"^3.0.6","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"readme":"# mesg-js\n\n[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)\n\nmesg-js is the official JavaScript library to interact with [MESG Engine](https://github.com/mesg-foundation/engine).\n\nThis library can be used from an Application or a Service.\n\n# Status\n[![CircleCI](https://img.shields.io/circleci/project/github/mesg-foundation/mesg-js.svg)](https://github.com/mesg-foundation/mesg-js) [![codecov](https://codecov.io/gh/mesg-foundation/mesg-js/branch/master/graph/badge.svg)](https://codecov.io/gh/mesg-foundation/mesg-js)\n\n# Contents\n\n- [Installation](#installation)\n- [Application](#application)\n  - [Listen events](#listen-events)\n  - [Listen results](#listen-results)\n  - [Execute task](#execute-task)\n  - [Execute task and wait result](#execute-task-and-wait-result)\n  - [Resolve SID](#resolve-sid)\n- [Service](#service)\n  - [Task](#task)\n  - [Event](#event)\n- [Community](#community)\n- [Contribute](#contribute)\n\n# Installation\n\n```bash\nnpm i mesg-js\n```\n\n# Application\n\nRequire mesg-js as an application:\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n```\n\n## MESG Engine endpoint\n\nBy default, the library connects to the MESG Engine from the endpoint `localhost:50052`.\n\n## Listen events\n\nListen events from a service.\n\n```javascript\nmesg.listenEvent({\n  filter: {\n    instanceHash: 'EVENT_INSTANCE_HASH',\n    key: 'EVENT_KEY' // optional\n  }\n})\n.on('data', (event) => {\n  console.log('an event received:', event.key, mesg.decodeData(event.data))\n})\n```\n\n## Listen results\n\nListen results from a service.\n\n```javascript\nmesg.listenResult({\n  filter: {\n    instanceHash: 'RESULT_INSTANCE_HASH',\n    taskKey: 'TASK_KEY_FILTER', // optional\n    tags: ['TAG_FILTER'] // optional\n  }\n})\n.on('data', (result) => {\n  if (result.error) {\n    console.error('an error has occurred:', result.error)\n    return\n  }\n  console.log('a result received:', mesg.decodeData(result.outputs))\n})\n```\n\n## Execute task\n\nExecute task on a service.\n\n```javascript\nconst execution = await mesg.executeTask({\n  instanceHash: 'TASK_INSTANCE_HASH',\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nconsole.log('task in progress with execution:', execution.hash)\n```\n\n## Execute task and wait result\n\nExecute task on a service and wait for its result.\nThis can be considered as a shortcut for using both `executeTask()` and `listenResult()` at same time.\n\n```javascript\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash: 'TASK_INSTANCE_HASH',\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nif (result.error) {\n  console.error('an error has occurred:', result.error)\n  throw new Error(result.error)\n}\nconsole.log('a result received:', mesg.decodeData(result.outputs))\n```\n\n## Resolve SID\n\nInstead of hard-coding `instanceHash` in your application's env, your application can resolve dynamically using the service's SID.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash,\n  .....\n})\n```\n\n# Service\n\nRequire mesg-js as a service:\n\n```javascript\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n```\n\n## Task\n\nThe service have to call `mesg.listenTask` to start listening for task to execute by passing an object containing the tasks' key and function.\n\n```javascript\nmesg.listenTask({\n  'TASK_1_KEY': (inputs) => {\n    // Function of the task 1\n    // Can directly throw error\n    if (inputs.foo === undefined) {\n      throw new Error('foo is undefined')\n    }\n    // Return an object\n    return { foo: inputs.a + 'bar' }\n  }, \n  'TASK_2_KEY': async (inputs) => {\n    // Function of the task 2\n    // Return an Promise containing an object\n    const response = await fetch('...')\n    return response.json()\n  },\n})\n```\n\nThe task functions accept `inputs` as parameter and returns the `outputs` as object or Promise of object.\nThe task function can throw an Error in case of error. The lib will catch it and send it to the MESG Engine.\n\n## Event\n\nTo emit an event, the service should call the `mesg.emitEvent` function with the event's key and event's data as parameters. This function returns a `Promise`.\n\n```javascript\nmesg.emitEvent('EVENT_KEY', { foo: 'bar' })\n```\n\n# Community\n\nYou can find us and other MESG users on the [forum](https://forum.mesg.com). Feel free to check existing posts and help other users of MESG.\n\nAlso, be sure to check out the [blog](https://medium.com/mesg) to stay up-to-date with our articles.\n\n# Contribute\n\nContributions are more than welcome.\n\nIf you have any questions, please reach out to us directly on [Discord](https://discordapp.com/invite/5tVTHJC).\n","readmeFilename":"README.md","gitHead":"bdadeed6650565a2bb20487f45ec10e62029cd85","_id":"mesg-js@4.3.0-beta.3","_nodeVersion":"10.16.0","_npmVersion":"6.11.2","dist":{"integrity":"sha512-ZEpL59+eFDQ3rcvxWLk6ejCOsouWP+IditTRMAE0rV5xV1heu+8EKDdXW7d1btMspr5skKqt+WRVPb1g1LJ5Fg==","shasum":"be298ce4ae376bcb19dd443fb7918551d8708a7a","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.3.0-beta.3.tgz","fileCount":94,"unpackedSize":303557,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdbPmuCRA9TVsSAnZWagAA+2oP/0Py1jukR8rK83rVWfBc\n+zwmIk3w5TnVPaWTdbtFu80SCnyBHLk3Gwt7PaF+PAFgKpOtr7fh5eu8lv8u\nD6uDjh7huHfkNFZiWgmJKbJhBSQ8QQntOAV8BnQxwlvXAxTo+6FB3bGtH8rO\nRRpcV2kIdC02sx020AIH3ZKt3iGjvbiKTHxvEZe/7WEUIfMh4reYfD4fnCIm\nGv7i3r5MYgQkYZsGiQvkOw45Q9GC0PXk+EgyQaCUhGTkfFkYGmY0aliRJ4wZ\nnmgZyil6g8X+gwaoog7jkclAsBHyYGwT6YHpjJex7hxzaboOh8Wh53D2aaQY\nwdsQ6f9Y1w+ZTBKjq323tTjR+/L9I4gqspDQ0wonlXd+GAWMC/F/8RsFu0hc\nHXzSmUfRusPNUWgfd/w8J0+GxlbLeTDWOkiulyFkdya1pQ0ATaeORb33fYqD\nySG0lJQbTZgXf+Rj9sgeoT2MUBQ5OySy9cLFtosnHWOG47ZYrtlqVb8/KhQg\nxDiWjGjxiOq332Kc31qr+Fvh74XSJH5XshonA4YCsg/yWiCPyQdleZcnqD24\n9bC3NKNwk07+JM1M/JPqAcF+9FJAp60CK25/u1PhirweRrROd9cNPBFPmu0c\nGWKOK/vukJiAc8dUVHNtpHLSiaZHvVTGK4NzbYkaDsVMQudNIF4SP5BzWHU8\nk6Bl\r\n=Mttk\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBppP3yzftWB9Wa7JRTUIEE+hKpRyYSErIZVeb561JO0AiAcGWEKPDctFKguR2ecxBB2QeVgpoPzM/syuYr8Hunr9A=="}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"nicolas-mesg","email":"nicolas@mesg.tech"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.3.0-beta.3_1567422893824_0.31358667149676234"},"_hasShrinkwrap":false,"deprecated":"use new v4.3.0"},"4.3.0-beta.4":{"name":"mesg-js","version":"4.3.0-beta.4","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","base-x":"^3.0.6","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"readme":"# mesg-js\n\n[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)\n\nmesg-js is the official JavaScript library to interact with [MESG Engine](https://github.com/mesg-foundation/engine).\n\nThis library can be used from an Application or a Service.\n\n# Status\n[![CircleCI](https://img.shields.io/circleci/project/github/mesg-foundation/mesg-js.svg)](https://github.com/mesg-foundation/mesg-js) [![codecov](https://codecov.io/gh/mesg-foundation/mesg-js/branch/master/graph/badge.svg)](https://codecov.io/gh/mesg-foundation/mesg-js)\n\n# Contents\n\n- [Installation](#installation)\n- [Application](#application)\n  - [Listen events](#listen-events)\n  - [Listen results](#listen-results)\n  - [Execute task](#execute-task)\n  - [Execute task and wait result](#execute-task-and-wait-result)\n  - [Resolve SID](#resolve-sid)\n- [Service](#service)\n  - [Task](#task)\n  - [Event](#event)\n- [Community](#community)\n- [Contribute](#contribute)\n\n# Installation\n\n```bash\nnpm i mesg-js\n```\n\n# Application\n\nRequire mesg-js as an application:\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n```\n\n## MESG Engine endpoint\n\nBy default, the library connects to the MESG Engine from the endpoint `localhost:50052`.\n\n## Listen events\n\nListen events from a service.\n\n```javascript\nmesg.listenEvent({\n  filter: {\n    instanceHash: 'EVENT_INSTANCE_HASH',\n    key: 'EVENT_KEY' // optional\n  }\n})\n.on('data', (event) => {\n  console.log('an event received:', event.key, mesg.decodeData(event.data))\n})\n```\n\n## Listen results\n\nListen results from a service.\n\n```javascript\nmesg.listenResult({\n  filter: {\n    instanceHash: 'RESULT_INSTANCE_HASH',\n    taskKey: 'TASK_KEY_FILTER', // optional\n    tags: ['TAG_FILTER'] // optional\n  }\n})\n.on('data', (result) => {\n  if (result.error) {\n    console.error('an error has occurred:', result.error)\n    return\n  }\n  console.log('a result received:', mesg.decodeData(result.outputs))\n})\n```\n\n## Execute task\n\nExecute task on a service.\n\n```javascript\nconst execution = await mesg.executeTask({\n  instanceHash: 'TASK_INSTANCE_HASH',\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nconsole.log('task in progress with execution:', execution.hash)\n```\n\n## Execute task and wait result\n\nExecute task on a service and wait for its result.\nThis can be considered as a shortcut for using both `executeTask()` and `listenResult()` at same time.\n\n```javascript\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash: 'TASK_INSTANCE_HASH',\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nif (result.error) {\n  console.error('an error has occurred:', result.error)\n  throw new Error(result.error)\n}\nconsole.log('a result received:', mesg.decodeData(result.outputs))\n```\n\n## Resolve SID\n\nInstead of hard-coding `instanceHash` in your application's env, your application can resolve dynamically using the service's SID.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash,\n  .....\n})\n```\n\n# Service\n\nRequire mesg-js as a service:\n\n```javascript\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n```\n\n## Task\n\nThe service have to call `mesg.listenTask` to start listening for task to execute by passing an object containing the tasks' key and function.\n\n```javascript\nmesg.listenTask({\n  'TASK_1_KEY': (inputs) => {\n    // Function of the task 1\n    // Can directly throw error\n    if (inputs.foo === undefined) {\n      throw new Error('foo is undefined')\n    }\n    // Return an object\n    return { foo: inputs.a + 'bar' }\n  }, \n  'TASK_2_KEY': async (inputs) => {\n    // Function of the task 2\n    // Return an Promise containing an object\n    const response = await fetch('...')\n    return response.json()\n  },\n})\n```\n\nThe task functions accept `inputs` as parameter and returns the `outputs` as object or Promise of object.\nThe task function can throw an Error in case of error. The lib will catch it and send it to the MESG Engine.\n\n## Event\n\nTo emit an event, the service should call the `mesg.emitEvent` function with the event's key and event's data as parameters. This function returns a `Promise`.\n\n```javascript\nmesg.emitEvent('EVENT_KEY', { foo: 'bar' })\n```\n\n# Community\n\nYou can find us and other MESG users on the [forum](https://forum.mesg.com). Feel free to check existing posts and help other users of MESG.\n\nAlso, be sure to check out the [blog](https://medium.com/mesg) to stay up-to-date with our articles.\n\n# Contribute\n\nContributions are more than welcome.\n\nIf you have any questions, please reach out to us directly on [Discord](https://discordapp.com/invite/5tVTHJC).\n","readmeFilename":"README.md","gitHead":"b15d7548e50ac4e6a72b54bd723685c2ca1e385c","_id":"mesg-js@4.3.0-beta.4","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-BXvOt2IRx8pzFvw//FNhzddxEln8bAO6mZbjU6+blKug6QCeeCfek7fxQDX78wlUcbOR/keFpktCtH0uyAV3cg==","shasum":"159ae8904e86dabf6239787e83672a47b231d57f","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.3.0-beta.4.tgz","fileCount":94,"unpackedSize":303557,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdb3KqCRA9TVsSAnZWagAAlnUP/1+4hrBcjVnMxed/M6Tn\nlL3TX9NCmqhcl3e3zNPxTr12TOJ8KkN38JcS67YifNNi3ExxYkSlVlM98YNT\nmG/TOJh1INjt8hi+1VLcK4ubdKw1SQ5X90SCkJozupEkSuk6DxDcImgu/u7R\nLABRC18K0Bp82Rl3MNHhRZWUYZUdCQ0anbi3Gk63WoLIUX+LlYxfyWpwelSK\nOFygHNvfMMRNZ3gRYOOzvQWJR8fkdGTZoU0OoTUp8YVz4MgzOltZ0FT1dkV7\n/vJcTzLXT+gojSYMj57rtbFOM10YAZr+yuVD1h18XaNL455oPWzCJvV61VFw\nQZ/vJGph9bw8rFlDyRggKS7qyGa2Bs4Ti8y1Ugi+h7j/fPcgE+JdaSnqsjCf\nsHxWygHp3pCY8U/xKOTqblRtpDalj3W0GO9RiT4/B8NynBGCx5QWOmtCA0m3\nSEZHHoic5Oqt1lkA2GovAyLsQpdcfr+M8N0YrQR57J2peMgLgjKpMtBF1PAB\nLHqndY5e+gMAEUgqLrPn1T+tIbauaiBw7TzFaCHyI4agucCm4Xmb+sEqClYX\nR6cCQnyyvmPupoarYVGo9Jg4m1zWBxSUfPHvU/jmM84TMga1BhCt5caIkv1G\nWLFchKkeZHbHtdYsJbf5QY4VfSo/a3IgJLVycg3I4ahvHKGbE2a+KMmdDVxy\nFdcD\r\n=plUd\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCdR2D+PPFd+MY5Ni/OUQfi8uD4Z1Hqf+ZseJ0eFeCKXQIgG7q8IEoRzCb8H4SDfHgskTaUFGOFJyAicZkQ6hYKndk="}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"anthony-mesg","email":"anthony@mesg.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.3.0-beta.4_1567584938299_0.33478384706187114"},"_hasShrinkwrap":false,"deprecated":"use new v4.3.0"},"4.3.0-beta.5":{"name":"mesg-js","version":"4.3.0-beta.5","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","base-x":"^3.0.6","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"readme":"# mesg-js\n\n[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)\n\nmesg-js is the official JavaScript library to interact with [MESG Engine](https://github.com/mesg-foundation/engine).\n\nThis library can be used from an Application or a Service.\n\n# Status\n[![CircleCI](https://img.shields.io/circleci/project/github/mesg-foundation/mesg-js.svg)](https://github.com/mesg-foundation/mesg-js) [![codecov](https://codecov.io/gh/mesg-foundation/mesg-js/branch/master/graph/badge.svg)](https://codecov.io/gh/mesg-foundation/mesg-js)\n\n# Contents\n\n- [Installation](#installation)\n- [Application](#application)\n  - [Listen events](#listen-events)\n  - [Listen results](#listen-results)\n  - [Execute task](#execute-task)\n  - [Execute task and wait result](#execute-task-and-wait-result)\n  - [Resolve SID](#resolve-sid)\n- [Service](#service)\n  - [Task](#task)\n  - [Event](#event)\n- [Community](#community)\n- [Contribute](#contribute)\n\n# Installation\n\n```bash\nnpm i mesg-js\n```\n\n# Application\n\nRequire mesg-js as an application:\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n```\n\n## MESG Engine endpoint\n\nBy default, the library connects to the MESG Engine from the endpoint `localhost:50052`.\n\n## Listen events\n\nListen events from a service.\n\n```javascript\nmesg.listenEvent({\n  filter: {\n    instanceHash: 'EVENT_INSTANCE_HASH',\n    key: 'EVENT_KEY' // optional\n  }\n})\n.on('data', (event) => {\n  console.log('an event received:', event.key, mesg.decodeData(event.data))\n})\n```\n\n## Listen results\n\nListen results from a service.\n\n```javascript\nmesg.listenResult({\n  filter: {\n    instanceHash: 'RESULT_INSTANCE_HASH',\n    taskKey: 'TASK_KEY_FILTER', // optional\n    tags: ['TAG_FILTER'] // optional\n  }\n})\n.on('data', (result) => {\n  if (result.error) {\n    console.error('an error has occurred:', result.error)\n    return\n  }\n  console.log('a result received:', mesg.decodeData(result.outputs))\n})\n```\n\n## Execute task\n\nExecute task on a service.\n\n```javascript\nconst execution = await mesg.executeTask({\n  instanceHash: 'TASK_INSTANCE_HASH',\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nconsole.log('task in progress with execution:', execution.hash)\n```\n\n## Execute task and wait result\n\nExecute task on a service and wait for its result.\nThis can be considered as a shortcut for using both `executeTask()` and `listenResult()` at same time.\n\n```javascript\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash: 'TASK_INSTANCE_HASH',\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nif (result.error) {\n  console.error('an error has occurred:', result.error)\n  throw new Error(result.error)\n}\nconsole.log('a result received:', mesg.decodeData(result.outputs))\n```\n\n## Resolve SID\n\nInstead of hard-coding `instanceHash` in your application's env, your application can resolve dynamically using the service's SID.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash,\n  .....\n})\n```\n\n# Service\n\nRequire mesg-js as a service:\n\n```javascript\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n```\n\n## Task\n\nThe service have to call `mesg.listenTask` to start listening for task to execute by passing an object containing the tasks' key and function.\n\n```javascript\nmesg.listenTask({\n  'TASK_1_KEY': (inputs) => {\n    // Function of the task 1\n    // Can directly throw error\n    if (inputs.foo === undefined) {\n      throw new Error('foo is undefined')\n    }\n    // Return an object\n    return { foo: inputs.a + 'bar' }\n  }, \n  'TASK_2_KEY': async (inputs) => {\n    // Function of the task 2\n    // Return an Promise containing an object\n    const response = await fetch('...')\n    return response.json()\n  },\n})\n```\n\nThe task functions accept `inputs` as parameter and returns the `outputs` as object or Promise of object.\nThe task function can throw an Error in case of error. The lib will catch it and send it to the MESG Engine.\n\n## Event\n\nTo emit an event, the service should call the `mesg.emitEvent` function with the event's key and event's data as parameters. This function returns a `Promise`.\n\n```javascript\nmesg.emitEvent('EVENT_KEY', { foo: 'bar' })\n```\n\n# Community\n\nYou can find us and other MESG users on the [forum](https://forum.mesg.com). Feel free to check existing posts and help other users of MESG.\n\nAlso, be sure to check out the [blog](https://medium.com/mesg) to stay up-to-date with our articles.\n\n# Contribute\n\nContributions are more than welcome.\n\nIf you have any questions, please reach out to us directly on [Discord](https://discordapp.com/invite/5tVTHJC).\n","readmeFilename":"README.md","gitHead":"bb7e984dd5bfbb237132d032c854c825b946f224","_id":"mesg-js@4.3.0-beta.5","_nodeVersion":"10.16.0","_npmVersion":"6.11.3","dist":{"integrity":"sha512-ryWNLfr9ZMisxO8I+84D9Kwf9ulJ+Wz29XAOssTyF8h54+i1LjAu5rC8CqzB1nF1DfYYBYYDllVNvL8yzVcM2g==","shasum":"2d4816e6603bc5046bcc1eba280b4e8ef7b62d2c","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.3.0-beta.5.tgz","fileCount":94,"unpackedSize":318327,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdc2dsCRA9TVsSAnZWagAA/QcP/1AwxGoZUmoViWv764Kx\nEt/VUlXI1R1hHDIAJAXyF3OJEFj/cLfDsBitVvMuLgjThgf81y2tioZF5y1Y\n30lXlfM3hmy/eNDzJsWn13PZrLkl3qY6B/EANC9zCGlwOczdwerwjOz9B8/h\nKtJMJBBInELcjOQpwz7z5zvHkIynhuGfJXY6CpFtecHYfTeN6ucms6CEvKGe\nnMIadRtjyqOoZHy/r9OPZxCQ2P8w4Jv5HcmliEd5xxuSo0VG90agBbU0B3a2\ndXFXbD2PQ1ypQNwm1iZiTACIRVRZWoURuyW4BTt5MeOcjDwBKhQssJX/AMdO\nXtXU2rqiJGJamQO30bIiW+hQK5n0NhuBkLw+hiU3F6V5NcMp7hy2A7jKFmaT\nRGzFWdJ4oiaO5QS0IPzeSAsxA/4fFsRBeuKCcBqH12HuzN8zWr5bc0kIbkwA\nHyUwNwDceqXEpo9Z1iuzokqB4ur7prNNGEsOlanS++JRS1Dpv96yn1WJR8Ge\nJ0cj96orxBXW8qJRrLMCU31Yku83+mMHjBedswCn3VA82xzNvoiNYHoEC615\nxSoLh9de8+rZ73TVVHyFAwQIhDgI4Cr5Mfmiwov1n37zSJM9J32KrwQmk2t1\nwfrSEgCB9FXhteGmeJBFmQt5uQnc0kMteU6mbwIumM+t8qSDEgo3ScElVFPl\n3Jah\r\n=OeSX\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCjzTYj+UsBd+aDjUHMG+zH7B0gQ3oGCV/y6BO9aBHfVAIgA8u1GhT/MTzZev82jc5UsszwXru0zsg7m0w3ywELSag="}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"nicolas-mesg","email":"nicolas@mesg.tech"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.3.0-beta.5_1567844203973_0.029605816257141093"},"_hasShrinkwrap":false,"deprecated":"use new v4.3.0"},"4.3.0-beta.6":{"name":"mesg-js","version":"4.3.0-beta.6","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp ./src/gogo/ ./lib/gogo/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && ncp ./src/gogo/ ./istanbul/gogo/ && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","base-x":"^3.0.6","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"readme":"# mesg-js\n\n[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)\n\nmesg-js is the official JavaScript library to interact with [MESG Engine](https://github.com/mesg-foundation/engine).\n\nThis library can be used from an Application or a Service.\n\n# Status\n[![CircleCI](https://img.shields.io/circleci/project/github/mesg-foundation/mesg-js.svg)](https://github.com/mesg-foundation/mesg-js) [![codecov](https://codecov.io/gh/mesg-foundation/mesg-js/branch/master/graph/badge.svg)](https://codecov.io/gh/mesg-foundation/mesg-js)\n\n# Contents\n\n- [Installation](#installation)\n- [Application](#application)\n  - [Listen events](#listen-events)\n  - [Listen results](#listen-results)\n  - [Execute task](#execute-task)\n  - [Execute task and wait result](#execute-task-and-wait-result)\n  - [Resolve SID](#resolve-sid)\n- [Service](#service)\n  - [Task](#task)\n  - [Event](#event)\n- [Community](#community)\n- [Contribute](#contribute)\n\n# Installation\n\n```bash\nnpm i mesg-js\n```\n\n# Application\n\nRequire mesg-js as an application:\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n```\n\n## MESG Engine endpoint\n\nBy default, the library connects to the MESG Engine from the endpoint `localhost:50052`.\n\n## Listen events\n\nListen events from a service.\n\n```javascript\nmesg.listenEvent({\n  filter: {\n    instanceHash: 'EVENT_INSTANCE_HASH',\n    key: 'EVENT_KEY' // optional\n  }\n})\n.on('data', (event) => {\n  console.log('an event received:', event.key, mesg.decodeData(event.data))\n})\n```\n\n## Listen results\n\nListen results from a service.\n\n```javascript\nmesg.listenResult({\n  filter: {\n    instanceHash: 'RESULT_INSTANCE_HASH',\n    taskKey: 'TASK_KEY_FILTER', // optional\n    tags: ['TAG_FILTER'] // optional\n  }\n})\n.on('data', (result) => {\n  if (result.error) {\n    console.error('an error has occurred:', result.error)\n    return\n  }\n  console.log('a result received:', mesg.decodeData(result.outputs))\n})\n```\n\n## Execute task\n\nExecute task on a service.\n\n```javascript\nconst execution = await mesg.executeTask({\n  instanceHash: 'TASK_INSTANCE_HASH',\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nconsole.log('task in progress with execution:', execution.hash)\n```\n\n## Execute task and wait result\n\nExecute task on a service and wait for its result.\nThis can be considered as a shortcut for using both `executeTask()` and `listenResult()` at same time.\n\n```javascript\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash: 'TASK_INSTANCE_HASH',\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nif (result.error) {\n  console.error('an error has occurred:', result.error)\n  throw new Error(result.error)\n}\nconsole.log('a result received:', mesg.decodeData(result.outputs))\n```\n\n## Resolve SID\n\nInstead of hard-coding `instanceHash` in your application's env, your application can resolve dynamically using the service's SID.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash,\n  .....\n})\n```\n\n# Service\n\nRequire mesg-js as a service:\n\n```javascript\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n```\n\n## Task\n\nThe service have to call `mesg.listenTask` to start listening for task to execute by passing an object containing the tasks' key and function.\n\n```javascript\nmesg.listenTask({\n  'TASK_1_KEY': (inputs) => {\n    // Function of the task 1\n    // Can directly throw error\n    if (inputs.foo === undefined) {\n      throw new Error('foo is undefined')\n    }\n    // Return an object\n    return { foo: inputs.a + 'bar' }\n  }, \n  'TASK_2_KEY': async (inputs) => {\n    // Function of the task 2\n    // Return an Promise containing an object\n    const response = await fetch('...')\n    return response.json()\n  },\n})\n```\n\nThe task functions accept `inputs` as parameter and returns the `outputs` as object or Promise of object.\nThe task function can throw an Error in case of error. The lib will catch it and send it to the MESG Engine.\n\n## Event\n\nTo emit an event, the service should call the `mesg.emitEvent` function with the event's key and event's data as parameters. This function returns a `Promise`.\n\n```javascript\nmesg.emitEvent('EVENT_KEY', { foo: 'bar' })\n```\n\n# Community\n\nYou can find us and other MESG users on the [forum](https://forum.mesg.com). Feel free to check existing posts and help other users of MESG.\n\nAlso, be sure to check out the [blog](https://medium.com/mesg) to stay up-to-date with our articles.\n\n# Contribute\n\nContributions are more than welcome.\n\nIf you have any questions, please reach out to us directly on [Discord](https://discordapp.com/invite/5tVTHJC).\n","readmeFilename":"README.md","gitHead":"f39fb25ef27e6c9838e7fc9fdc1ed34d177e3bdf","_id":"mesg-js@4.3.0-beta.6","_nodeVersion":"10.16.0","_npmVersion":"6.11.3","dist":{"integrity":"sha512-GtMQ8iouS3ERSI4OzKwzuYCUHN1T1UtfZAoPREggFhpiRDrv/8tv1CZeWUZO6Z4xPSCbYtffshKR+Se5FhqHEQ==","shasum":"641880644692dc854443b9cecb78d1b2c2a0f2b8","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.3.0-beta.6.tgz","fileCount":96,"unpackedSize":328056,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdc3DACRA9TVsSAnZWagAAOgAP/ibVOytNrq8FDlyxBuzj\ndUCf9EdDeWY7e/KRW8wXkklFgAkxkE4Cfi9W4NaG20GHoe2NKkYhpjYWIBdK\n62J+xXq7eofhLXQyhj+95LjNtk11osy1ifgHdCOb+wszf1HixCvSdos0YqVl\ndqu55I++EySi1dKLl1Y8P19egpM0nsNRzCZsUddgoQBJ+8VhjxTgrX1pJZzy\nh6q5nkpqmTyYtrDQ/jIQqEjkHadtiN72o43AxMeMZyXzQgaqpSh1n8t6NxdW\nW/64JoY653q/LAJEukUUKN0GF/dxGZK6GpHN8rrmohRf9O1hSA/Q+ZgPjQmz\nAPV5gPBpnSCHD5Fzl5847rITB5y/ekfICUuDnBoXOUmEeme0hxEzaRkS/Vsw\n16Fb1xrNBh589pp4WaVgPb3MPsM+LkVaUKtjBzdQ8xNZAe4Si11Sry934D/Q\n1jZcDgUtZK6Ebj8eBaPd5EiwCDM5vNXla9GV0s8gi96OMdHLXaIOmXgCxzdB\nuP5DO8f3cXeU1vGCwDcsHAVBatHAJ5KbsLfs8aV70GiERY9syOptk4CtJB8i\nwJCu8pgxR1dxAPG3fUoNyuIkYrhVonr+4dVNasj3om1gYI0nXEZoJlT1Hc7n\nd3Yivd2y7GzG7Pr9UaHlv549TZGNKeDA6VdFrOqgB6HkqRPMQsfKBPSURcS6\nN0QE\r\n=uOwH\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFQQ8IDTwdr3Emhg4pFmT3ljb3/XhRXjjmyIzT22iG9+AiAxinJNozM7a6wJ4JoJMIS2NGHa/SsbVHrfu0JUJifdUA=="}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"nicolas-mesg","email":"nicolas@mesg.tech"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.3.0-beta.6_1567846591594_0.6669721735153877"},"_hasShrinkwrap":false,"deprecated":"use new v4.3.0"},"4.3.0":{"name":"mesg-js","version":"4.3.0","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp ./src/gogo/ ./lib/gogo/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && ncp ./src/gogo/ ./istanbul/gogo/ && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","base-x":"^3.0.6","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"gitHead":"6a4af754817d9d6372550bb00e891d04b79c99b9","_id":"mesg-js@4.3.0","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-v5xYAW/pGgGoqLfnNEem5EKZeXYFijsTuY2D8QKu4CacSzPBat4JQk8t11JvlvKzmitne3eaKOS3RAZzdS1gtg==","shasum":"58af468ed702ee0ca9adba2ece161a06f950bda7","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.3.0.tgz","fileCount":96,"unpackedSize":328049,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJddQ0vCRA9TVsSAnZWagAAPxAP/AjwdbzJD+Z6i9g/dmKl\nqvJxT1Ecx6droOIOk1VOlLTnwpnY4MpwKIWGYmTL3h8ICcE77Pau64udFHe8\nPfzOuNZrv3rwf5AWhv/hmDOVlbfzAybgbwF9g8olAXyH3naOEYZVyY4al+lm\nXi1/Pq5iOyitg1roeJYaZQBNJUTZpk6ERd6D6rfp+ZyXT8FwLf9LKI4ry7h7\nkzJ2t0YwolGwZ3Hse+xAMi+SjaqyHvLNt14mIkXxJmKEVC+PmL/7H5JEExKO\nUWbl0OGvX1C6AbYE3UatFaoHfGbzqWBahrz3d/NhAGhRsuFDJHUJyT8jJ1MC\nrSjA6HqNwW7zgx1v60QbGtBRLtXwKZ/lCCw9CUEYQ99T192FfgBpYKM5slGF\n9ik+BrkNYDWebaGY3fTfIfZsvhatTFedn8rriG/U8O8r8/jweZoaaEyKbdB8\nKXeuY8x5q30r9a3hTPtiiLZxQRO392JMTBob6T7gfh29lQhHq5UbCc+ZyvVL\nNQJpFJSl4F2vV2zeKv7Wx855HOgMz+nlVEB2KV/a45rzDfyXvZqv2KPUMt1Y\nAUUmX6Ya/m4EzaWGFAELar9er/Hw17nbCwa/79t/5+E2nJyinwbxuZprFehX\nlrCPyCGztchA1lCBPPQHUsuAz7QxbAyM1NW+PIjgjkIDgIe/19Js0wg7henO\nBt65\r\n=SkoH\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC1nSjxPXU5quwrkDi9Hcl0aeIDG+L/NvANjH+q/MCnJQIgF/QWwkgH849lRtveooDqU+VsJ443CWnEq54NCOVooYs="}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"anthony-mesg","email":"anthony@mesg.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.3.0_1567952174874_0.0973909709949301"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"},"4.3.1":{"name":"mesg-js","version":"4.3.1","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp ./src/gogo/ ./lib/gogo/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && ncp ./src/gogo/ ./istanbul/gogo/ && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","base-x":"^3.0.6","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/long":"^4.0.0","@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"gitHead":"8eb7e7473956d84c5897635d57e96dca2e9dbe49","_id":"mesg-js@4.3.1","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-PgelJm19SKAe5BbPujIFxfJ+/yr5YwyFh7zEzJkFNunTiSN1qOvKbxAgtLvi9KJqBvo51rKjflXjv0NCYrx02A==","shasum":"4da5d596fa66444f56ad8408ec18b422bf80361a","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.3.1.tgz","fileCount":98,"unpackedSize":812114,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdeLOxCRA9TVsSAnZWagAASJoP/iQzqF8rlf7/iC1B/H0X\nf2juQhR6cQhvPmyV25Ihsy7RruxzMlHu7Zblvtxgb350FY88kL/o4TEvA78W\nCSxX4YoIUZhg79aFYH75fOzsTNiqONDrlgrhe5gQTXE40rwaBa0hwYJzIXk9\nK/mXf6xQrEx20uX1/Lod4kWl4VRXnDAIxdFLaT4kEKBWr39Mauq7upUwT0cx\nxbl0p/J6L/dmZAI0MJQJj4iBPHLFd8PNwxr/xwBXyikUh/xBr6ZxPAdEU7O0\n1jhOxuD6C14aOCDfdf9//dMcDl/Zu9vIz0cCHpQxFoeykDI5saApd68681WN\njWfbig9W8vXeBAOjBrELm+q6u6xGGkm1u4e1KeHkT9/LHfZV436I1o0oeSlu\nrENx/oE6v7CmoEg7D4WESFEV+rs+H5QViYFrYV51wo7a4ietwKPk0y1rvjcj\nIYDRzXD++0c2sdfXA15FoTnj18laHdAptH0Zfxm87n46CPx4Omjso/VyFerA\nRq6ZBoFYjkCsGiTRPpVhaN/IZz/q/75dL8QAOqFDgIoXJ3fE+TQ/JnmrL+Mh\nrP8PHn0Or2VmiJU7huZRqOjsuqvJBre3eAmQc5O4ExiW37OH2aGIj5C/1tp/\nwKY+Lgz1tEDi6oNefMAjIcXPrCjMTO3ymE0nYa+mXyU1m07X6azEVEtIBVL/\nf+hH\r\n=es7y\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIC9EAJE/EksfB//k2/d6YP811W4nQAX3EshfBL9ijPvnAiEAj5vc1JVeQUNZCnxfDpN4WbHyvbKtzxmEjNg5jtg54Xs="}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"anthony-mesg","email":"anthony@mesg.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.3.1_1568191408500_0.2773898288211438"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"},"4.4.0-beta.1":{"name":"mesg-js","version":"4.4.0-beta.1","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp ./src/gogo/ ./lib/gogo/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && ncp ./src/gogo/ ./istanbul/gogo/ && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","base-x":"^3.0.6","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/long":"^4.0.0","@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"readme":"# mesg-js\n\n[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)\n\nmesg-js is the official JavaScript library to interact with [MESG Engine](https://github.com/mesg-foundation/engine).\n\nThis library can be used from an Application or a Service.\n\n# Status\n[![CircleCI](https://img.shields.io/circleci/project/github/mesg-foundation/mesg-js.svg)](https://github.com/mesg-foundation/mesg-js) [![codecov](https://codecov.io/gh/mesg-foundation/mesg-js/branch/master/graph/badge.svg)](https://codecov.io/gh/mesg-foundation/mesg-js)\n\n# Contents\n\n- [Installation](#installation)\n- [Service](#service)\n  - [Task](#task)\n  - [Event](#event)\n- [Application](#application)\n  - [Resolve SID](#resolve-sid)\n  - [Listen events](#listen-events)\n  - [Listen results](#listen-results)\n  - [Execute task](#execute-task)\n  - [Execute task and wait result](#execute-task-and-wait-result)\n- [Community](#community)\n- [Contribute](#contribute)\n\n# Installation\n\n```bash\nnpm i mesg-js\n```\n\n# Service\n\nRequire mesg-js as a service:\n\n```javascript\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n```\n\n## Task\n\nThe service have to call `mesg.listenTask` to start listening for task to execute by passing an object containing the tasks' key and function.\n\n```javascript\nmesg.listenTask({\n  'TASK_1_KEY': (inputs) => {\n    // Function of the task 1\n    // Can directly throw error\n    if (inputs.foo === undefined) {\n      throw new Error('foo is undefined')\n    }\n    // Return an object\n    return { foo: inputs.a + 'bar' }\n  }, \n  'TASK_2_KEY': async (inputs) => {\n    // Function of the task 2\n    // Return an Promise containing an object\n    const response = await fetch('...')\n    return response.json()\n  },\n})\n```\n\nThe task functions accept `inputs` as parameter and returns the `outputs` as object or Promise of object.\nThe task function can throw an Error in case of error. The lib will catch it and send it to the MESG Engine.\n\n## Event\n\nTo emit an event, the service should call the `mesg.emitEvent` function with the event's key and event's data as parameters. This function returns a `Promise`.\n\n```javascript\nmesg.emitEvent('EVENT_KEY', { foo: 'bar' })\n```\n\n# Application\n\nRequire mesg-js as an application:\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n```\n\n## MESG Engine endpoint\n\nBy default, the library connects to the MESG Engine from the endpoint `localhost:50052`.\n\n## Resolve SID\n\nInstead of hard-coding `instanceHash` in your application's env, your application can resolve dynamically using the service's SID.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash,\n  .....\n})\n```\n\n## Listen events\n\nListen events from a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nmesg.listenEvent({\n  filter: {\n    instanceHash: instanceHash,\n    key: 'EVENT_KEY' // optional\n  }\n})\n.on('data', (event) => {\n  console.log('an event received:', event.key, mesg.decodeData(event.data))\n})\n```\n\n## Listen results\n\nListen results from a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nmesg.listenResult({\n  filter: {\n    instanceHash: instanceHash,\n    taskKey: 'TASK_KEY_FILTER', // optional\n    tags: ['TAG_FILTER'] // optional\n  }\n})\n.on('data', (result) => {\n  if (result.error) {\n    console.error('an error has occurred:', result.error)\n    return\n  }\n  console.log('a result received:', mesg.decodeData(result.outputs))\n})\n```\n\n## Execute task\n\nExecute task on a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst execution = await mesg.executeTask({\n  instanceHash: instanceHash,\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nconsole.log('task in progress with execution:', execution.hash)\n```\n\n## Execute task and wait result\n\nExecute task on a service and wait for its result.\nThis can be considered as a shortcut for using both `executeTask()` and `listenResult()` at same time.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash: instanceHash,\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nif (result.error) {\n  console.error('an error has occurred:', result.error)\n  throw new Error(result.error)\n}\nconsole.log('a result received:', mesg.decodeData(result.outputs))\n```\n\n# Community\n\nYou can find us and other MESG users on the [forum](https://forum.mesg.com). Feel free to check existing posts and help other users of MESG.\n\nAlso, be sure to check out the [blog](https://medium.com/mesg) to stay up-to-date with our articles.\n\n# Contribute\n\nContributions are more than welcome.\n\nIf you have any questions, please reach out to us directly on [Discord](https://discordapp.com/invite/5tVTHJC).\n","readmeFilename":"README.md","gitHead":"67478e0ad4c7f5f34f8fb9a79980e814e4c69a34","_id":"mesg-js@4.4.0-beta.1","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-FmyunfuTbZTdXcLx50SQP0g5MljC5JgxZvbeRbiptPMKlJzar+RI/hMG/BeqaPQLIY0rO94KkniNqfo23WxQTA==","shasum":"b32f37ec2b864ec8a27307bf46cc8bf64498c5cd","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.4.0-beta.1.tgz","fileCount":98,"unpackedSize":820141,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdedOJCRA9TVsSAnZWagAAXaQP/ipS3mVlLJosNVXnHg81\nTcVIYf1nPUKAzCEZGVymPa1iFy4aNUGD4djGRU6jFtIVnDw0OBL3r+S2NVA5\nOnD3Vyp6giYFxa3FNKMRDK28WUdvoV1F8g6LwGAeGMS144hXpYeBKvKH5w11\n6zrHSIypPazem5FEXL0K7e7ikt+unELdgboaN7MOAilXXvxVyA76Tg+bDWKE\nEVTA51jU/5Zlm1UkFOMHQ5yVTFjD6dvzvanpE7MuYuKTIwoz61ps4bxTbXkT\nK209ysrcx9nUwpiJMzl1QM5lkW/JNc3g8YEPdMTdn9itG13KBpPeZYh4M59Y\nUMTmCLuhP9s/fm+3pg2jerByPbFHRd1EvpZSsWgdGqCiAoa2wB3CE7cQxyv1\nhCZWJ16Wuxl8uX0QKpSS7Awb8cRUsvvjL1gb8x7X+ycc3FkOJspRQnD26JWQ\n72mkYKudYXhs8mYXbxAbsKVMK9swSr558kJ12gAP1KX9TKktZRJWVgSa+pXU\nei2o/visZ1kViU/+HzLQqxOvUX9qGccc/zvuYIuMovDnBIDiyePzp03z1Uxy\n8+lBXk/jC+t9Lqks5ZWDJVm7C9L+IcYRVQa7oV0YZtMPcQW58xZtovhS4pzW\n3PFo9jZvqzebqVIQ/C076Mx3qDXXroCa0fga90yw+sHbAuKKNVk/smAe3ii0\nEE9m\r\n=W28F\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDjVR1/30KqQ/b35XMMh7VZsCPN8B1onYRDUuTNHpxeGgIhAIl9cc5WQOGLKX5V2jsfEygAGBxPHLLt8LySc7GrNjEx"}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"anthony-mesg","email":"anthony@mesg.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.4.0-beta.1_1568265096450_0.314700270739553"},"_hasShrinkwrap":false,"deprecated":"v4.4.0"},"4.4.0-beta.2":{"name":"mesg-js","version":"4.4.0-beta.2","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp ./src/gogo/ ./lib/gogo/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && ncp ./src/gogo/ ./istanbul/gogo/ && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","base-x":"^3.0.6","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/long":"^4.0.0","@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"readme":"# mesg-js\n\n[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)\n\nmesg-js is the official JavaScript library to interact with [MESG Engine](https://github.com/mesg-foundation/engine).\n\nThis library can be used from an Application or a Service.\n\n# Status\n[![CircleCI](https://img.shields.io/circleci/project/github/mesg-foundation/mesg-js.svg)](https://github.com/mesg-foundation/mesg-js) [![codecov](https://codecov.io/gh/mesg-foundation/mesg-js/branch/master/graph/badge.svg)](https://codecov.io/gh/mesg-foundation/mesg-js)\n\n# Contents\n\n- [Installation](#installation)\n- [Service](#service)\n  - [Task](#task)\n  - [Event](#event)\n- [Application](#application)\n  - [Resolve SID](#resolve-sid)\n  - [Listen events](#listen-events)\n  - [Listen results](#listen-results)\n  - [Execute task](#execute-task)\n  - [Execute task and wait result](#execute-task-and-wait-result)\n- [Community](#community)\n- [Contribute](#contribute)\n\n# Installation\n\n```bash\nnpm i mesg-js\n```\n\n# Service\n\nRequire mesg-js as a service:\n\n```javascript\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n```\n\n## Task\n\nThe service have to call `mesg.listenTask` to start listening for task to execute by passing an object containing the tasks' key and function.\n\n```javascript\nmesg.listenTask({\n  'TASK_1_KEY': (inputs) => {\n    // Function of the task 1\n    // Can directly throw error\n    if (inputs.foo === undefined) {\n      throw new Error('foo is undefined')\n    }\n    // Return an object\n    return { foo: inputs.a + 'bar' }\n  }, \n  'TASK_2_KEY': async (inputs) => {\n    // Function of the task 2\n    // Return an Promise containing an object\n    const response = await fetch('...')\n    return response.json()\n  },\n})\n```\n\nThe task functions accept `inputs` as parameter and returns the `outputs` as object or Promise of object.\nThe task function can throw an Error in case of error. The lib will catch it and send it to the MESG Engine.\n\n## Event\n\nTo emit an event, the service should call the `mesg.emitEvent` function with the event's key and event's data as parameters. This function returns a `Promise`.\n\n```javascript\nmesg.emitEvent('EVENT_KEY', { foo: 'bar' })\n```\n\n# Application\n\nRequire mesg-js as an application:\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n```\n\n## MESG Engine endpoint\n\nBy default, the library connects to the MESG Engine from the endpoint `localhost:50052`.\n\n## Resolve SID\n\nInstead of hard-coding `instanceHash` in your application's env, your application can resolve dynamically using the service's SID.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash,\n  .....\n})\n```\n\n## Listen events\n\nListen events from a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nmesg.listenEvent({\n  filter: {\n    instanceHash: instanceHash,\n    key: 'EVENT_KEY' // optional\n  }\n})\n.on('data', (event) => {\n  console.log('an event received:', event.key, mesg.decodeData(event.data))\n})\n```\n\n## Listen results\n\nListen results from a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nmesg.listenResult({\n  filter: {\n    instanceHash: instanceHash,\n    taskKey: 'TASK_KEY_FILTER', // optional\n    tags: ['TAG_FILTER'] // optional\n  }\n})\n.on('data', (result) => {\n  if (result.error) {\n    console.error('an error has occurred:', result.error)\n    return\n  }\n  console.log('a result received:', mesg.decodeData(result.outputs))\n})\n```\n\n## Execute task\n\nExecute task on a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst execution = await mesg.executeTask({\n  instanceHash: instanceHash,\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nconsole.log('task in progress with execution:', execution.hash)\n```\n\n## Execute task and wait result\n\nExecute task on a service and wait for its result.\nThis can be considered as a shortcut for using both `executeTask()` and `listenResult()` at same time.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash: instanceHash,\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nif (result.error) {\n  console.error('an error has occurred:', result.error)\n  throw new Error(result.error)\n}\nconsole.log('a result received:', mesg.decodeData(result.outputs))\n```\n\n# Community\n\nYou can find us and other MESG users on the [forum](https://forum.mesg.com). Feel free to check existing posts and help other users of MESG.\n\nAlso, be sure to check out the [blog](https://medium.com/mesg) to stay up-to-date with our articles.\n\n# Contribute\n\nContributions are more than welcome.\n\nIf you have any questions, please reach out to us directly on [Discord](https://discordapp.com/invite/5tVTHJC).\n","readmeFilename":"README.md","gitHead":"86f13b5656e8fe432204849c2bc74b5e9fac1ae5","_id":"mesg-js@4.4.0-beta.2","_nodeVersion":"10.16.0","_npmVersion":"6.11.3","dist":{"integrity":"sha512-PR9xNohuzh4sNrsGcq6+r0YwsFCRL1nXnoha+M2NRu858lUxvWzlwjeCRyani6TIEvscIbTdTHwmkXbt6oTbrg==","shasum":"05c67fa6da433378089bb809b318876d4907391c","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.4.0-beta.2.tgz","fileCount":104,"unpackedSize":959983,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdggPYCRA9TVsSAnZWagAAw3sQAKCF97GrpmbiV4WUf035\n9+WRIaR24c6bKDyUvET7B3fzlfl2CKl+Sw9SfOrXBXV9HGKtMgnBLbI54mH0\nusuzI0tiJ2Geif6GKDCOt6hX5UIl4EKM2o1TgJp3Zc7TzVRQ+xiifhsT6cV3\nL7ngLaZE41MvfAOp4enUXF9IoIhllewjPNkbTikFEP/4xNFtSzEy5U5mqQ/u\nmTRHfLgmI2YiGheaK5uJWy9Rdu02v5gvoniMdWiKl+KrAoW3MqHjlA6kcvGa\nLJY8j4GqkOeOAKYgSe/x5M11/rMjMVl3RrupRTqlQmbvn6dM+id6+ih8HWBu\nL8VEtZ3GIv7z1bpMNtHPjf867YGtuits35V+21b/0IJO5QYIwZFpPV6c1KaJ\n2i3Y7eyOGXymDQ2sXaiG7AZpCp5ytMMTVIzf1r7rrKK/GCGdSqjCMFsIT2Qt\nyZRkZV915CqvU8hEZvbsA5i0Zo/Wy3RJ/e0k9LbRHJ0/eyt1us9TkKkWlbPG\n7Xh/EdcN5Qq32K1CY0vRwR8lHnz5LmGD63gl5HkaNl1+akbt+WyXddc6nf3G\nHo31c1GFeDgasH62uUDNYa70+P+7f6rGHT/qIdgpG0e8jOnSSTAb2445AeDq\nCeO1EWR6ArM8fM2+0W8THUeBrGntaOsgS7Mysxs1Yf04ltO46NS+pwmOkcv1\n6eGK\r\n=avG8\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIC3oNWLptJ4X/frCL74e0pIeSrDb/9ISDFX3V3wNyx/eAiEAog4iy7Sx1hHiO98e4+s6kvUIE92+kfZgu24oyEeii8s="}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"nicolas-mesg","email":"nicolas@mesg.tech"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.4.0-beta.2_1568801751926_0.4492090415689203"},"_hasShrinkwrap":false,"deprecated":"v4.4.0"},"4.4.0":{"name":"mesg-js","version":"4.4.0","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp ./src/gogo/ ./lib/gogo/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && ncp ./src/gogo/ ./istanbul/gogo/ && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","base-x":"^3.0.6","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/long":"^4.0.0","@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"gitHead":"10eaa7951eea6b91974434459d30146b7a4dcbb7","_id":"mesg-js@4.4.0","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-I/Sivhzg/ebPRe3ur+/DurXhx9g3heiYjHbmSQF9aYs5daIUWi3boCjz2qbU/s361lwTs2n2tKQ5o10TDPF3qA==","shasum":"0c4635dcec9be7cc35ff24faf605cd8185c34936","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.4.0.tgz","fileCount":104,"unpackedSize":960503,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdiHwfCRA9TVsSAnZWagAA9SgP/AtimTERazBcG+mhGBzl\nEYSSVkpQMF91fSvC9zuRinZLResZZ+C1LV2UM15RmV6MkQjpmDm5uZj+ad7C\nNP4GjZUO0cJpddoS/I5ttXCx/t4dOh1p1bpKQeLPstOoZObDB93bXui/onId\nJ2nqJdskoRun4RgNlc7qPtsxCyrdKZuXjj05Gjx1DvMBUgFs/CFfY1HmheeS\njWq/WH6NtXx27WaRmHIzF0XxexuEDGR7zspDC0PBgn3G3PG7z0PHWWepVUUV\nyi8kmMWtQUoThYJ57lEHL1eHI3FHBVEKTBdTURAfgeobiSUqessI/W+vu5xx\n6Km6ynlzq8ZbQ1sCY7q52VKFSsfJrxjxcFFEOt/YpFXwwsDk5hQvQnpnT31d\n7zMFkTTUscD+QLNzUTNt1JSwtdiwT8zFxsNc6HUZG6jI1C0v3m+xf45WLFBq\ne9Vpi8eA5MyHb9LF6xXlhlSN3iMp2P/aZr33K+RTq4ZHGJx+tYU/ltWBzTGg\nYT9inwuIg4ZikINzyn2+XJxKSOCHMhXaeYicvvGjeauARRC498idn8Qbyrxh\nKntz4M0ikdXjw6zdFfxDulsExWhPMQhe3xWx+u6K/+KBCIKlSI/sDIbMcnDm\nbl7ms88IAqUFFF1LuC6lGOAO2tBg9+8aoW54lp0sFyFkRScPTL30L5BEmPu7\nRmay\r\n=RZ5g\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGqmbsJAdzCSOgdbKVdcMOKLFkIzhyW5Iir6yt3ycvpxAiAw5FHbMlwSQsjfP49zzAkL4SrOeu7unl3IjCfQ33uHTA=="}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"anthony-mesg","email":"anthony@mesg.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.4.0_1569225758796_0.011845902917386297"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"},"4.5.0-beta.1":{"name":"mesg-js","version":"4.5.0-beta.1","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp ./src/gogo/ ./lib/gogo/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && ncp ./src/gogo/ ./istanbul/gogo/ && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","base-x":"^3.0.6","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/long":"^4.0.0","@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"readme":"# mesg-js\n\n[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)\n\nmesg-js is the official JavaScript library to interact with [MESG Engine](https://github.com/mesg-foundation/engine).\n\nThis library can be used from an Application or a Service.\n\n# Status\n[![CircleCI](https://img.shields.io/circleci/project/github/mesg-foundation/mesg-js.svg)](https://github.com/mesg-foundation/mesg-js) [![codecov](https://codecov.io/gh/mesg-foundation/mesg-js/branch/master/graph/badge.svg)](https://codecov.io/gh/mesg-foundation/mesg-js)\n\n# Contents\n\n- [Installation](#installation)\n- [Service](#service)\n  - [Task](#task)\n  - [Event](#event)\n- [Application](#application)\n  - [Resolve SID](#resolve-sid)\n  - [Listen events](#listen-events)\n  - [Listen results](#listen-results)\n  - [Execute task](#execute-task)\n  - [Execute task and wait result](#execute-task-and-wait-result)\n- [Community](#community)\n- [Contribute](#contribute)\n\n# Installation\n\n```bash\nnpm i mesg-js\n```\n\n# Service\n\nRequire mesg-js as a service:\n\n```javascript\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n```\n\n## Task\n\nThe service have to call `mesg.listenTask` to start listening for task to execute by passing an object containing the tasks' key and function.\n\n```javascript\nmesg.listenTask({\n  'TASK_1_KEY': (inputs) => {\n    // Function of the task 1\n    // Can directly throw error\n    if (inputs.foo === undefined) {\n      throw new Error('foo is undefined')\n    }\n    // Return an object\n    return { foo: inputs.a + 'bar' }\n  }, \n  'TASK_2_KEY': async (inputs) => {\n    // Function of the task 2\n    // Return an Promise containing an object\n    const response = await fetch('...')\n    return response.json()\n  },\n})\n```\n\nThe task functions accept `inputs` as parameter and returns the `outputs` as object or Promise of object.\nThe task function can throw an Error in case of error. The lib will catch it and send it to the MESG Engine.\n\n## Event\n\nTo emit an event, the service should call the `mesg.emitEvent` function with the event's key and event's data as parameters. This function returns a `Promise`.\n\n```javascript\nmesg.emitEvent('EVENT_KEY', { foo: 'bar' })\n```\n\n# Application\n\nRequire mesg-js as an application:\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n```\n\n## MESG Engine endpoint\n\nBy default, the library connects to the MESG Engine from the endpoint `localhost:50052`.\n\n## Resolve SID\n\nInstead of hard-coding `instanceHash` in your application's env, your application can resolve dynamically using the service's SID.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash,\n  .....\n})\n```\n\n## Listen events\n\nListen events from a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nmesg.listenEvent({\n  filter: {\n    instanceHash: instanceHash,\n    key: 'EVENT_KEY' // optional\n  }\n})\n.on('data', (event) => {\n  console.log('an event received:', event.key, mesg.decodeData(event.data))\n})\n```\n\n## Listen results\n\nListen results from a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nmesg.listenResult({\n  filter: {\n    instanceHash: instanceHash,\n    taskKey: 'TASK_KEY_FILTER', // optional\n    tags: ['TAG_FILTER'] // optional\n  }\n})\n.on('data', (result) => {\n  if (result.error) {\n    console.error('an error has occurred:', result.error)\n    return\n  }\n  console.log('a result received:', mesg.decodeData(result.outputs))\n})\n```\n\n## Execute task\n\nExecute task on a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst execution = await mesg.executeTask({\n  instanceHash: instanceHash,\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nconsole.log('task in progress with execution:', execution.hash)\n```\n\n## Execute task and wait result\n\nExecute task on a service and wait for its result.\nThis can be considered as a shortcut for using both `executeTask()` and `listenResult()` at same time.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash: instanceHash,\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nif (result.error) {\n  console.error('an error has occurred:', result.error)\n  throw new Error(result.error)\n}\nconsole.log('a result received:', mesg.decodeData(result.outputs))\n```\n\n# Community\n\nYou can find us and other MESG users on the [forum](https://forum.mesg.com). Feel free to check existing posts and help other users of MESG.\n\nAlso, be sure to check out the [blog](https://medium.com/mesg) to stay up-to-date with our articles.\n\n# Contribute\n\nContributions are more than welcome.\n\nIf you have any questions, please reach out to us directly on [Discord](https://discordapp.com/invite/5tVTHJC).\n","readmeFilename":"README.md","gitHead":"6732cd20da93343f8b23cc062eda7b3d9a58de38","_id":"mesg-js@4.5.0-beta.1","_nodeVersion":"10.16.0","_npmVersion":"6.11.3","dist":{"integrity":"sha512-Mi76+twd8H1iTpQdCLYRrjmtBNe/T5mCcXx8kR3b6ps0ypDz8kmrpyoQDQ1p4GQKh+fEIUKYKqFQ+DP8n4EaYA==","shasum":"8983fcdcf756d17fa901e9f73f1b095f813a0ff4","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.5.0-beta.1.tgz","fileCount":104,"unpackedSize":963131,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdivMLCRA9TVsSAnZWagAAlt0QAKQdVu8CckrNiruJvlRq\nrWdcZM+n5jt3WgMFZb4P0xkLUXzcqEoQC4PMuMX7eOilvYAeizHlmXvJCV9Q\nuI6sqWRXeTo8FLB4PmExQSldj6vRJUTSYmCkVT9O3rV1RMEnEGU9wRUUPePD\nRBBAOfdusXDn/P+z+M0z4AAb87IjCye9nwMYIWby/yG6Xs4scHLX477BqEpD\nghfCT/B0IUkYv2567EWUcQUDgNd9YIbC0b7NTvVfmhUYUc2YIrAPSdFTLo5S\nzsj0x2rR7Exp2ytt9+xMDHEKmi64ZaVrFSw49Un57CIf2EjpbpbA4kHfKBju\nE8rBttsLR50qXYuFnkIZGuC/nUN8PwICj0obiccHgJeTBo4bD5AT7pezbJoL\nlS7uudwOPrnGwJ8NDPQ0JfI0BUy57HsdN0EM0q/j2VUt5un9hnvb7WEttMuN\n3fucnc36HHZzLig0QFz2GqbdjBC30LP8JzIRonVKjHur1/W9Vt1XwiTWxyWC\nb2KsMDRpckEEEQCO3ki0mjfW2ifG+z9lIrsh3YBT+lPC2CedFdZzLSMWY3bt\nPv4dB7I5nmZ80xuGKjKT/6pXibC2a2WL9hG9r3E1/84Glyg+HqDsgmdpC8Py\nQn2FF/c2zs2T2Hs3qqxiz5Nv1UW6seF+j2QLimscPXFIUY+plsYP5m3YnIVR\n8dEM\r\n=wZdo\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBlGdiKtyeAd9wXDCT4xkm5a1yJY7d2AKZ/wNrYxLdXIAiBBfCoyhK6O40T6QeZOGITQWl1jDTq1H/goK1fR3LC2Yw=="}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"nicolas-mesg","email":"nicolas@mesg.tech"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.5.0-beta.1_1569387275095_0.07354386756131537"},"_hasShrinkwrap":false,"deprecated":"use v5.0.0"},"4.5.0-beta.2":{"name":"mesg-js","version":"4.5.0-beta.2","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp ./src/gogo/ ./lib/gogo/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && ncp ./src/gogo/ ./istanbul/gogo/ && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","base-x":"^3.0.6","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/long":"^4.0.0","@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"readme":"# mesg-js\n\n[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)\n\nmesg-js is the official JavaScript library to interact with [MESG Engine](https://github.com/mesg-foundation/engine).\n\nThis library can be used from an Application or a Service.\n\n# Status\n[![CircleCI](https://img.shields.io/circleci/project/github/mesg-foundation/mesg-js.svg)](https://github.com/mesg-foundation/mesg-js) [![codecov](https://codecov.io/gh/mesg-foundation/mesg-js/branch/master/graph/badge.svg)](https://codecov.io/gh/mesg-foundation/mesg-js)\n\n# Contents\n\n- [Installation](#installation)\n- [Service](#service)\n  - [Task](#task)\n  - [Event](#event)\n- [Application](#application)\n  - [Resolve SID](#resolve-sid)\n  - [Listen events](#listen-events)\n  - [Listen results](#listen-results)\n  - [Execute task](#execute-task)\n  - [Execute task and wait result](#execute-task-and-wait-result)\n- [Community](#community)\n- [Contribute](#contribute)\n\n# Installation\n\n```bash\nnpm i mesg-js\n```\n\n# Service\n\nRequire mesg-js as a service:\n\n```javascript\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n```\n\n## Task\n\nThe service have to call `mesg.listenTask` to start listening for task to execute by passing an object containing the tasks' key and function.\n\n```javascript\nmesg.listenTask({\n  'TASK_1_KEY': (inputs) => {\n    // Function of the task 1\n    // Can directly throw error\n    if (inputs.foo === undefined) {\n      throw new Error('foo is undefined')\n    }\n    // Return an object\n    return { foo: inputs.a + 'bar' }\n  }, \n  'TASK_2_KEY': async (inputs) => {\n    // Function of the task 2\n    // Return an Promise containing an object\n    const response = await fetch('...')\n    return response.json()\n  },\n})\n```\n\nThe task functions accept `inputs` as parameter and returns the `outputs` as object or Promise of object.\nThe task function can throw an Error in case of error. The lib will catch it and send it to the MESG Engine.\n\n## Event\n\nTo emit an event, the service should call the `mesg.emitEvent` function with the event's key and event's data as parameters. This function returns a `Promise`.\n\n```javascript\nmesg.emitEvent('EVENT_KEY', { foo: 'bar' })\n```\n\n# Application\n\nRequire mesg-js as an application:\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n```\n\n## MESG Engine endpoint\n\nBy default, the library connects to the MESG Engine from the endpoint `localhost:50052`.\n\n## Resolve SID\n\nInstead of hard-coding `instanceHash` in your application's env, your application can resolve dynamically using the service's SID.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash,\n  .....\n})\n```\n\n## Listen events\n\nListen events from a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nmesg.listenEvent({\n  filter: {\n    instanceHash: instanceHash,\n    key: 'EVENT_KEY' // optional\n  }\n})\n.on('data', (event) => {\n  console.log('an event received:', event.key, mesg.decodeData(event.data))\n})\n```\n\n## Listen results\n\nListen results from a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nmesg.listenResult({\n  filter: {\n    instanceHash: instanceHash,\n    taskKey: 'TASK_KEY_FILTER', // optional\n    tags: ['TAG_FILTER'] // optional\n  }\n})\n.on('data', (result) => {\n  if (result.error) {\n    console.error('an error has occurred:', result.error)\n    return\n  }\n  console.log('a result received:', mesg.decodeData(result.outputs))\n})\n```\n\n## Execute task\n\nExecute task on a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst execution = await mesg.executeTask({\n  instanceHash: instanceHash,\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nconsole.log('task in progress with execution:', execution.hash)\n```\n\n## Execute task and wait result\n\nExecute task on a service and wait for its result.\nThis can be considered as a shortcut for using both `executeTask()` and `listenResult()` at same time.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash: instanceHash,\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nif (result.error) {\n  console.error('an error has occurred:', result.error)\n  throw new Error(result.error)\n}\nconsole.log('a result received:', mesg.decodeData(result.outputs))\n```\n\n# Community\n\nYou can find us and other MESG users on the [forum](https://forum.mesg.com). Feel free to check existing posts and help other users of MESG.\n\nAlso, be sure to check out the [blog](https://medium.com/mesg) to stay up-to-date with our articles.\n\n# Contribute\n\nContributions are more than welcome.\n\nIf you have any questions, please reach out to us directly on [Discord](https://discordapp.com/invite/5tVTHJC).\n","readmeFilename":"README.md","gitHead":"d893af35f763bacf6dc91aebcde3cfeb4c582b30","_id":"mesg-js@4.5.0-beta.2","_nodeVersion":"10.16.0","_npmVersion":"6.11.3","dist":{"integrity":"sha512-niOGlTW+f9sJq5G6BsRmfsUMCmfvaXBOmTCjPYH86LH73+XdciNPlBcfK5U9HuLdtAX4TRYgMPzml+ilH0sa6Q==","shasum":"41b7f36f6f5ba23422fadcfcbece97062e2d2434","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.5.0-beta.2.tgz","fileCount":108,"unpackedSize":1066804,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdjd4YCRA9TVsSAnZWagAAW1gP+wdR5XlLZTr7T0jXrTYw\n6eFBr+IK/G3KxNsNS93gxZJp8gLQ3sGAKTxgnrwMdI5I0umXS2b9M06cNSII\nIGKN6B4U6fdQ4pMCudd8eKvsjEW6TJ55C9cdlNMIUE7swIs3TUnc4sDuDNDA\nnKWgdSedErY6PJWurQZNSh3TMBnCoRZsXPsaaNQrccKPoVc1yYOxHLUPh3QZ\nQ3inrY6q/HL02YcGkDdJIfHJe64hvVlBQqAH4VCrNqgwauoOeKKg/iPecXzV\n7P2OgyhGtGih+weK/BpZFx03lv395AlGR+Jw30FTTs3BYEQlFDgcrqhYM1nT\nD2BiWVgrPbFoRMJGT90/KHylQAx58IyTFGrUQvD1CaAY4SunQ7xN0DMNIq96\neM7WzUe0huwjqgLzjNWXk9INkxK2IHGWfJDACihozLVGrxSSuyxbLzxznTDz\nxiobNP1LzoHjVPyXa8jwj4a8QXngy/OwKxDY1aNCycD0Elsi39sLgL+xveWJ\ntJ9wvmvMYTYr8rXZG8sgEn/g2J2zHlRBEe0Jk2+DkRqIsaDD7dHtJ+qC8haA\nLd5CJf904Z40RdTxpo2Z/BtgNPKwm6Fprrw3uzsAfHMYF5tDBFGH0fUwuZv6\nBda5GEFfvhN7qYE0JzEKFMvSieucTiynCI+volbqH2cLiZYimvBChc3f9UiQ\nMWh/\r\n=4jRO\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCOg/LXarnQv81SflSczonTNToeyLa5ab+PWpBU4tYn6AIgcvya6NIpHDq5RkrHltMeSx1YDrmGcMmLjN4EL3R2e4I="}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"nicolas-mesg","email":"nicolas@mesg.tech"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.5.0-beta.2_1569578519416_0.9766113952866822"},"_hasShrinkwrap":false,"deprecated":"use v5.0.0"},"4.5.0-beta.3":{"name":"mesg-js","version":"4.5.0-beta.3","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp ./src/gogo/ ./lib/gogo/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && ncp ./src/gogo/ ./istanbul/gogo/ && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","base-x":"^3.0.6","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/long":"^4.0.0","@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"readme":"# mesg-js\n\n[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)\n\nmesg-js is the official JavaScript library to interact with [MESG Engine](https://github.com/mesg-foundation/engine).\n\nThis library can be used from an Application or a Service.\n\n# Status\n[![CircleCI](https://img.shields.io/circleci/project/github/mesg-foundation/mesg-js.svg)](https://github.com/mesg-foundation/mesg-js) [![codecov](https://codecov.io/gh/mesg-foundation/mesg-js/branch/master/graph/badge.svg)](https://codecov.io/gh/mesg-foundation/mesg-js)\n\n# Contents\n\n- [Installation](#installation)\n- [Service](#service)\n  - [Task](#task)\n  - [Event](#event)\n- [Application](#application)\n  - [Resolve SID](#resolve-sid)\n  - [Listen events](#listen-events)\n  - [Listen results](#listen-results)\n  - [Execute task](#execute-task)\n  - [Execute task and wait result](#execute-task-and-wait-result)\n- [Community](#community)\n- [Contribute](#contribute)\n\n# Installation\n\n```bash\nnpm i mesg-js\n```\n\n# Service\n\nRequire mesg-js as a service:\n\n```javascript\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n```\n\n## Task\n\nThe service have to call `mesg.listenTask` to start listening for task to execute by passing an object containing the tasks' key and function.\n\n```javascript\nmesg.listenTask({\n  'TASK_1_KEY': (inputs) => {\n    // Function of the task 1\n    // Can directly throw error\n    if (inputs.foo === undefined) {\n      throw new Error('foo is undefined')\n    }\n    // Return an object\n    return { foo: inputs.a + 'bar' }\n  }, \n  'TASK_2_KEY': async (inputs) => {\n    // Function of the task 2\n    // Return an Promise containing an object\n    const response = await fetch('...')\n    return response.json()\n  },\n})\n```\n\nThe task functions accept `inputs` as parameter and returns the `outputs` as object or Promise of object.\nThe task function can throw an Error in case of error. The lib will catch it and send it to the MESG Engine.\n\n## Event\n\nTo emit an event, the service should call the `mesg.emitEvent` function with the event's key and event's data as parameters. This function returns a `Promise`.\n\n```javascript\nmesg.emitEvent('EVENT_KEY', { foo: 'bar' })\n```\n\n# Application\n\nRequire mesg-js as an application:\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n```\n\n## MESG Engine endpoint\n\nBy default, the library connects to the MESG Engine from the endpoint `localhost:50052`.\n\n## Resolve SID\n\nInstead of hard-coding `instanceHash` in your application's env, your application can resolve dynamically using the service's SID.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash,\n  .....\n})\n```\n\n## Listen events\n\nListen events from a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nmesg.listenEvent({\n  filter: {\n    instanceHash: instanceHash,\n    key: 'EVENT_KEY' // optional\n  }\n})\n.on('data', (event) => {\n  console.log('an event received:', event.key, mesg.decodeData(event.data))\n})\n```\n\n## Listen results\n\nListen results from a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nmesg.listenResult({\n  filter: {\n    instanceHash: instanceHash,\n    taskKey: 'TASK_KEY_FILTER', // optional\n    tags: ['TAG_FILTER'] // optional\n  }\n})\n.on('data', (result) => {\n  if (result.error) {\n    console.error('an error has occurred:', result.error)\n    return\n  }\n  console.log('a result received:', mesg.decodeData(result.outputs))\n})\n```\n\n## Execute task\n\nExecute task on a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst execution = await mesg.executeTask({\n  instanceHash: instanceHash,\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nconsole.log('task in progress with execution:', execution.hash)\n```\n\n## Execute task and wait result\n\nExecute task on a service and wait for its result.\nThis can be considered as a shortcut for using both `executeTask()` and `listenResult()` at same time.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash: instanceHash,\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nif (result.error) {\n  console.error('an error has occurred:', result.error)\n  throw new Error(result.error)\n}\nconsole.log('a result received:', mesg.decodeData(result.outputs))\n```\n\n# Community\n\nYou can find us and other MESG users on the [forum](https://forum.mesg.com). Feel free to check existing posts and help other users of MESG.\n\nAlso, be sure to check out the [blog](https://medium.com/mesg) to stay up-to-date with our articles.\n\n# Contribute\n\nContributions are more than welcome.\n\nIf you have any questions, please reach out to us directly on [Discord](https://discordapp.com/invite/5tVTHJC).\n","readmeFilename":"README.md","gitHead":"f3b80da32a71c999c5f37c8ed95381c34036f1a5","_id":"mesg-js@4.5.0-beta.3","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-hLTWQDQsQcxuQmErGlnmqH+wykZG5X5zlxkHyfTJ3++ZSjgBbKp1gTMDr/Wr4DRZEYxrNp0rMbXD7+DJDi6skw==","shasum":"cc7eb235adb6b63575ce9dc125f9893d0d01ffba","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.5.0-beta.3.tgz","fileCount":108,"unpackedSize":1071767,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdkdaJCRA9TVsSAnZWagAAoYMP/1MuQuaDxHAVUZfdM+yS\nUjnJflfV608dxI0eniuIVesXRn08gP0AgXOg52JMSj+g6j2CngFqrDBPSAAL\nbDhU+hhhvA5bvsAXTf40smDzVXZCZae9U8Qpk04mFh3xzeVIq8yOAuo5Vk5a\nJvfi3EL8B4g+BXQzU8Me6/QSoVnzxzW1rXpuYO7Kchn5qNVWTFtKsOswmZmO\n4/E3x7qikIMCZSYhfoOLh/k52bcXZVnWxJei1UDJXWxnUtGf8rR624t1uSm2\n25a/thowHmg/3LpkP14AUWDgI9JmT6AZ+Br+TZxJ8/9MzhYEJ4CP/i9GgdCs\nBqPc2MlSmUpSehzq1QcViAX1hvLP7+HsSxAHXF48ngt80F1v3ikZr/l8tAIj\nM/gcGjrOQTznQtYpuP6uxhTRa5z7fs/xgGyb1z8Jp60Jyj7yrPcbgsq2ahPm\nmVZs/bwlRFVKIPOZabF1Vu5wWQuWnfx/FJfnDJqV3UpRd6PB6bKZKkN8HXsC\nmPc9xpBEOqKSa8gnUuvOcayxd6qlaXwocJP07xZGJQWkAc4FLXWMOQG7gfwv\nRIg5P52+x4tVSwWlVFUs94IdbhFeh4O4OBWOp75y8fOxfZaN49uZpnTJd6iK\nKNGgjjyZJ1jJhTv2NSFobgWqaTdZgWxpkLqoyYSPxEuIbu7PGdv2vOx42KH6\n4r5X\r\n=qJ6m\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC/iWZeOIJ3nSMQkRVM+6RXwm4HmXlpWYhRM4aSk58GrwIgdIHqQQGAQkOZqQx7Ok+C7+pNVB7zftkl2T1rTCBpN/s="}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"anthony-mesg","email":"anthony@mesg.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.5.0-beta.3_1569838728937_0.8163061508460863"},"_hasShrinkwrap":false,"deprecated":"use v5.0.0"},"4.5.0-beta.4":{"name":"mesg-js","version":"4.5.0-beta.4","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp ./src/gogo/ ./lib/gogo/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && ncp ./src/gogo/ ./istanbul/gogo/ && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","base-x":"^3.0.6","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/long":"^4.0.0","@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"readme":"# mesg-js\n\n[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)\n\nmesg-js is the official JavaScript library to interact with [MESG Engine](https://github.com/mesg-foundation/engine).\n\nThis library can be used from an Application or a Service.\n\n# Status\n[![CircleCI](https://img.shields.io/circleci/project/github/mesg-foundation/mesg-js.svg)](https://github.com/mesg-foundation/mesg-js) [![codecov](https://codecov.io/gh/mesg-foundation/mesg-js/branch/master/graph/badge.svg)](https://codecov.io/gh/mesg-foundation/mesg-js)\n\n# Contents\n\n- [Installation](#installation)\n- [Service](#service)\n  - [Task](#task)\n  - [Event](#event)\n- [Application](#application)\n  - [Resolve SID](#resolve-sid)\n  - [Listen events](#listen-events)\n  - [Listen results](#listen-results)\n  - [Execute task](#execute-task)\n  - [Execute task and wait result](#execute-task-and-wait-result)\n- [Community](#community)\n- [Contribute](#contribute)\n\n# Installation\n\n```bash\nnpm i mesg-js\n```\n\n# Service\n\nRequire mesg-js as a service:\n\n```javascript\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n```\n\n## Task\n\nThe service have to call `mesg.listenTask` to start listening for task to execute by passing an object containing the tasks' key and function.\n\n```javascript\nmesg.listenTask({\n  'TASK_1_KEY': (inputs) => {\n    // Function of the task 1\n    // Can directly throw error\n    if (inputs.foo === undefined) {\n      throw new Error('foo is undefined')\n    }\n    // Return an object\n    return { foo: inputs.a + 'bar' }\n  }, \n  'TASK_2_KEY': async (inputs) => {\n    // Function of the task 2\n    // Return an Promise containing an object\n    const response = await fetch('...')\n    return response.json()\n  },\n})\n```\n\nThe task functions accept `inputs` as parameter and returns the `outputs` as object or Promise of object.\nThe task function can throw an Error in case of error. The lib will catch it and send it to the MESG Engine.\n\n## Event\n\nTo emit an event, the service should call the `mesg.emitEvent` function with the event's key and event's data as parameters. This function returns a `Promise`.\n\n```javascript\nmesg.emitEvent('EVENT_KEY', { foo: 'bar' })\n```\n\n# Application\n\nRequire mesg-js as an application:\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n```\n\n## MESG Engine endpoint\n\nBy default, the library connects to the MESG Engine from the endpoint `localhost:50052`.\n\n## Resolve SID\n\nInstead of hard-coding `instanceHash` in your application's env, your application can resolve dynamically using the service's SID.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash,\n  .....\n})\n```\n\n## Listen events\n\nListen events from a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nmesg.listenEvent({\n  filter: {\n    instanceHash: instanceHash,\n    key: 'EVENT_KEY' // optional\n  }\n})\n.on('data', (event) => {\n  console.log('an event received:', event.key, mesg.decodeData(event.data))\n})\n```\n\n## Listen results\n\nListen results from a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nmesg.listenResult({\n  filter: {\n    instanceHash: instanceHash,\n    taskKey: 'TASK_KEY_FILTER', // optional\n    tags: ['TAG_FILTER'] // optional\n  }\n})\n.on('data', (result) => {\n  if (result.error) {\n    console.error('an error has occurred:', result.error)\n    return\n  }\n  console.log('a result received:', mesg.decodeData(result.outputs))\n})\n```\n\n## Execute task\n\nExecute task on a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst execution = await mesg.executeTask({\n  instanceHash: instanceHash,\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nconsole.log('task in progress with execution:', execution.hash)\n```\n\n## Execute task and wait result\n\nExecute task on a service and wait for its result.\nThis can be considered as a shortcut for using both `executeTask()` and `listenResult()` at same time.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash: instanceHash,\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nif (result.error) {\n  console.error('an error has occurred:', result.error)\n  throw new Error(result.error)\n}\nconsole.log('a result received:', mesg.decodeData(result.outputs))\n```\n\n# Community\n\nYou can find us and other MESG users on the [forum](https://forum.mesg.com). Feel free to check existing posts and help other users of MESG.\n\nAlso, be sure to check out the [blog](https://medium.com/mesg) to stay up-to-date with our articles.\n\n# Contribute\n\nContributions are more than welcome.\n\nIf you have any questions, please reach out to us directly on [Discord](https://discordapp.com/invite/5tVTHJC).\n","readmeFilename":"README.md","gitHead":"d8a2c66e9b33075e2c8c28059d8bb48047309a1f","_id":"mesg-js@4.5.0-beta.4","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-E8+p1fzG/0Q5QAh6r/hOlkZmUbAtf1HcPrQ/I88q++qMQLyxjwo1lKG2OyDVqCZGY/uIHK3EFmTlQPEDK98MRA==","shasum":"6e939417c5ef69ec62d6815e39501e3484541f63","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.5.0-beta.4.tgz","fileCount":108,"unpackedSize":1072526,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdkwGwCRA9TVsSAnZWagAAiL8P/01Mlq1jun+Q8QjKT8Bz\nBmw/KWmavabgJa81EGPfdzWFjhxM45qe3UthbJKOcn37lYWntqNW2cMZnkZf\nzg2lFSHYXoXRbXmKDNRlA+41xMlkFlWr4o8k3bhucU9ZY1Q2yZKJsLehpI4L\nCeMHIW1YtcdphO0FJyuz6tpSGCdPsgMnK8EWyJDg+7Ei0GgIutB1k1GJopZY\nzzvv/A13+vqwGbuT70K7kpTyNTT68U5Aw/817JaHNQeppaT9YuMAzKv3R+TJ\n/2T++TmVpH7eiTAD2Xcb1VTHl9LSsJRgQc2N7al0yF8eKgJQIUQUeMRueq6M\nMjv6uDbIB7yUdS4MksCCZ53/YxHh0uFIeNikRxyZL/2ZZFPzyIE0G5OV494B\niM/xT2Mye7N0tHvQHmoDbnLx+ntszSU+LCmulmW4RkYtdTEpNwuamzz/i4d0\nrMP4Zp2TqoDRpoEEcvIhyvm9Cdt/mEyRNcLdQInYb5JPEtgd9CIk/Jsid1G4\ny7Bc7xPSF93DTvx7nwZ1ey1CtTZ7ajJE9d3TbmbMfxOtmZ8TshLaJDhmTkGo\nWANfCvguQNTF8PVc6W2awtp6HNkEMsUzuOmdHzABTrzQOzjymDc2rH9ay+zQ\n1APcQhV+hJAjFLiqWvdVkHWYxpgJMWry1qV8CnM/MvjFDx+k+aNrwPCY4KhL\nla4/\r\n=6c1m\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDMVgf0km3Mp/Dc+iHknUYUrp/Dp1ZHX2pCzubSv+CGpgIhAMPMUQJV5HK7iGFNzYt5L+tlCu+9iR6je+OOKnzclx7k"}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"anthony-mesg","email":"anthony@mesg.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.5.0-beta.4_1569915311644_0.3171277211685626"},"_hasShrinkwrap":false,"deprecated":"use v5.0.0"},"4.5.0-beta.5":{"name":"mesg-js","version":"4.5.0-beta.5","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp ./src/gogo/ ./lib/gogo/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && ncp ./src/gogo/ ./istanbul/gogo/ && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","base-x":"^3.0.6","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/long":"^4.0.0","@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"readme":"# mesg-js\n\n[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)\n\nmesg-js is the official JavaScript library to interact with [MESG Engine](https://github.com/mesg-foundation/engine).\n\nThis library can be used from an Application or a Service.\n\n# Status\n[![CircleCI](https://img.shields.io/circleci/project/github/mesg-foundation/mesg-js.svg)](https://github.com/mesg-foundation/mesg-js) [![codecov](https://codecov.io/gh/mesg-foundation/mesg-js/branch/master/graph/badge.svg)](https://codecov.io/gh/mesg-foundation/mesg-js)\n\n# Contents\n\n- [Installation](#installation)\n- [Service](#service)\n  - [Task](#task)\n  - [Event](#event)\n- [Application](#application)\n  - [Resolve SID](#resolve-sid)\n  - [Listen events](#listen-events)\n  - [Listen results](#listen-results)\n  - [Execute task](#execute-task)\n  - [Execute task and wait result](#execute-task-and-wait-result)\n- [Community](#community)\n- [Contribute](#contribute)\n\n# Installation\n\n```bash\nnpm i mesg-js\n```\n\n# Service\n\nRequire mesg-js as a service:\n\n```javascript\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n```\n\n## Task\n\nThe service have to call `mesg.listenTask` to start listening for task to execute by passing an object containing the tasks' key and function.\n\n```javascript\nmesg.listenTask({\n  'TASK_1_KEY': (inputs) => {\n    // Function of the task 1\n    // Can directly throw error\n    if (inputs.foo === undefined) {\n      throw new Error('foo is undefined')\n    }\n    // Return an object\n    return { foo: inputs.a + 'bar' }\n  }, \n  'TASK_2_KEY': async (inputs) => {\n    // Function of the task 2\n    // Return an Promise containing an object\n    const response = await fetch('...')\n    return response.json()\n  },\n})\n```\n\nThe task functions accept `inputs` as parameter and returns the `outputs` as object or Promise of object.\nThe task function can throw an Error in case of error. The lib will catch it and send it to the MESG Engine.\n\n## Event\n\nTo emit an event, the service should call the `mesg.emitEvent` function with the event's key and event's data as parameters. This function returns a `Promise`.\n\n```javascript\nmesg.emitEvent('EVENT_KEY', { foo: 'bar' })\n```\n\n# Application\n\nRequire mesg-js as an application:\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n```\n\n## MESG Engine endpoint\n\nBy default, the library connects to the MESG Engine from the endpoint `localhost:50052`.\n\n## Resolve SID\n\nInstead of hard-coding `instanceHash` in your application's env, your application can resolve dynamically using the service's SID.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash,\n  .....\n})\n```\n\n## Listen events\n\nListen events from a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nmesg.listenEvent({\n  filter: {\n    instanceHash: instanceHash,\n    key: 'EVENT_KEY' // optional\n  }\n})\n.on('data', (event) => {\n  console.log('an event received:', event.key, mesg.decodeData(event.data))\n})\n```\n\n## Listen results\n\nListen results from a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nmesg.listenResult({\n  filter: {\n    instanceHash: instanceHash,\n    taskKey: 'TASK_KEY_FILTER', // optional\n    tags: ['TAG_FILTER'] // optional\n  }\n})\n.on('data', (result) => {\n  if (result.error) {\n    console.error('an error has occurred:', result.error)\n    return\n  }\n  console.log('a result received:', mesg.decodeData(result.outputs))\n})\n```\n\n## Execute task\n\nExecute task on a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst execution = await mesg.executeTask({\n  instanceHash: instanceHash,\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nconsole.log('task in progress with execution:', execution.hash)\n```\n\n## Execute task and wait result\n\nExecute task on a service and wait for its result.\nThis can be considered as a shortcut for using both `executeTask()` and `listenResult()` at same time.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash: instanceHash,\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nif (result.error) {\n  console.error('an error has occurred:', result.error)\n  throw new Error(result.error)\n}\nconsole.log('a result received:', mesg.decodeData(result.outputs))\n```\n\n# Community\n\nYou can find us and other MESG users on the [forum](https://forum.mesg.com). Feel free to check existing posts and help other users of MESG.\n\nAlso, be sure to check out the [blog](https://medium.com/mesg) to stay up-to-date with our articles.\n\n# Contribute\n\nContributions are more than welcome.\n\nIf you have any questions, please reach out to us directly on [Discord](https://discordapp.com/invite/5tVTHJC).\n","readmeFilename":"README.md","gitHead":"a7334c4b9beb07f4e6c20a61bf0e1985cbef91d9","_id":"mesg-js@4.5.0-beta.5","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-MAFzktWMa5uU5nSzSPHjT5I+YY1oebpdPwViYV8JJkZJxxQrqUnXtVqWdh/wDBkJS/N1fji4HWj2Psg+maU17Q==","shasum":"3a4bae2f79fcbc3d84654838155f2a9e33a998d2","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-4.5.0-beta.5.tgz","fileCount":108,"unpackedSize":1072526,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdkzinCRA9TVsSAnZWagAA/Q4P/ihzOMY1EG5nLOMgZs4o\naEjxn+y2XlJNnxVyJeEofqDUleiw5zG6pvi+aQiXkBkxgVLJ4b6XFJew/TO7\n5ROQruDQHW1y5Um25w0uHGdrlOlvH9VPOWHOtMLhqGS72xOB1pRxrIZt9Wq3\n7+NlPk3/QKtrJ2avtt9LThKUHWNg+cPXikzl3x1L53RR8phwDYvi/rK2FAFR\nZz1S75V6+A94Qj11LWnEPAK2UZj6W/quPMuVW92C+prVYwm1bjGMTb5YNAFk\nAZS3krjsFlcn70MgZ/URhLSaTzPVtoS7VBCqlOWnjQIg7uS2Jw4LofoRCYsg\nOxVIWdhyopAVtSp36+69NgIcZkoF0lSo9l+2Nt0kEX0WKB9LFB94JZ2aM7Of\nHcte8R6o0xP6apBsCGRaR6vEqvHt+iU1QbcPD1sWPuV1y5QM7glqwW0NgZbK\nZmC3UzaXhgp4riCy72eyK6sQawDx3k8u8IEhWSttAcyUf9+E/1Qw+pArdXGW\n9u+difmtP+QHDt2R6pLPfXqMLmMZDsSYNWnvlrVMCxME6KZldWU6q44Q+CwC\n87jZvlF0yc/eTEuqSxeyyA8ingXyomZK2WJTFz2+4rKgDeZTPxWML8b5tVZS\nSulurI5M2CSW3ZSbWnE3bZKaq/r+C34uaQfJsWPI8ApQIsfNPvx1aeLKX2CQ\nYOed\r\n=iOi7\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDkrhr3271wxmtyJR0oQfhRqxAqxHaRHn18Z/tIqidkPwIhALqWCSbtFdemv3xKqyt4Wpm8d2l/FH2pCLrv3CDLQ+AO"}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"anthony-mesg","email":"anthony@mesg.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_4.5.0-beta.5_1569929382770_0.36058206186624897"},"_hasShrinkwrap":false,"deprecated":"use v5.0.0"},"5.0.0-beta.1":{"name":"mesg-js","version":"5.0.0-beta.1","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp ./src/gogo/ ./lib/gogo/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && ncp ./src/gogo/ ./istanbul/gogo/ && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","base-x":"^3.0.6","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/long":"^4.0.0","@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"readme":"# mesg-js\n\n[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)\n\nmesg-js is the official JavaScript library to interact with [MESG Engine](https://github.com/mesg-foundation/engine).\n\nThis library can be used from an Application or a Service.\n\n# Status\n[![CircleCI](https://img.shields.io/circleci/project/github/mesg-foundation/mesg-js.svg)](https://github.com/mesg-foundation/mesg-js) [![codecov](https://codecov.io/gh/mesg-foundation/mesg-js/branch/master/graph/badge.svg)](https://codecov.io/gh/mesg-foundation/mesg-js)\n\n# Contents\n\n- [Installation](#installation)\n- [Service](#service)\n  - [Task](#task)\n  - [Event](#event)\n- [Application](#application)\n  - [Resolve SID](#resolve-sid)\n  - [Listen events](#listen-events)\n  - [Listen results](#listen-results)\n  - [Execute task](#execute-task)\n  - [Execute task and wait result](#execute-task-and-wait-result)\n- [Community](#community)\n- [Contribute](#contribute)\n\n# Installation\n\n```bash\nnpm i mesg-js\n```\n\n# Service\n\nRequire mesg-js as a service:\n\n```javascript\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n```\n\n## Task\n\nThe service have to call `mesg.listenTask` to start listening for task to execute by passing an object containing the tasks' key and function.\n\n```javascript\nmesg.listenTask({\n  'TASK_1_KEY': (inputs) => {\n    // Function of the task 1\n    // Can directly throw error\n    if (inputs.foo === undefined) {\n      throw new Error('foo is undefined')\n    }\n    // Return an object\n    return { foo: inputs.a + 'bar' }\n  }, \n  'TASK_2_KEY': async (inputs) => {\n    // Function of the task 2\n    // Return an Promise containing an object\n    const response = await fetch('...')\n    return response.json()\n  },\n})\n```\n\nThe task functions accept `inputs` as parameter and returns the `outputs` as object or Promise of object.\nThe task function can throw an Error in case of error. The lib will catch it and send it to the MESG Engine.\n\n## Event\n\nTo emit an event, the service should call the `mesg.emitEvent` function with the event's key and event's data as parameters. This function returns a `Promise`.\n\n```javascript\nmesg.emitEvent('EVENT_KEY', { foo: 'bar' })\n```\n\n# Application\n\nRequire mesg-js as an application:\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n```\n\n## MESG Engine endpoint\n\nBy default, the library connects to the MESG Engine from the endpoint `localhost:50052`.\n\n## Resolve SID\n\nInstead of hard-coding `instanceHash` in your application's env, your application can resolve dynamically using the service's SID.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash,\n  .....\n})\n```\n\n## Listen events\n\nListen events from a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nmesg.listenEvent({\n  filter: {\n    instanceHash: instanceHash,\n    key: 'EVENT_KEY' // optional\n  }\n})\n.on('data', (event) => {\n  console.log('an event received:', event.key, mesg.decodeData(event.data))\n})\n```\n\n## Listen results\n\nListen results from a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nmesg.listenResult({\n  filter: {\n    instanceHash: instanceHash,\n    taskKey: 'TASK_KEY_FILTER', // optional\n    tags: ['TAG_FILTER'] // optional\n  }\n})\n.on('data', (result) => {\n  if (result.error) {\n    console.error('an error has occurred:', result.error)\n    return\n  }\n  console.log('a result received:', mesg.decodeData(result.outputs))\n})\n```\n\n## Execute task\n\nExecute task on a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst execution = await mesg.executeTask({\n  instanceHash: instanceHash,\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nconsole.log('task in progress with execution:', execution.hash)\n```\n\n## Execute task and wait result\n\nExecute task on a service and wait for its result.\nThis can be considered as a shortcut for using both `executeTask()` and `listenResult()` at same time.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash: instanceHash,\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nif (result.error) {\n  console.error('an error has occurred:', result.error)\n  throw new Error(result.error)\n}\nconsole.log('a result received:', mesg.decodeData(result.outputs))\n```\n\n# Community\n\nYou can find us and other MESG users on the [forum](https://forum.mesg.com). Feel free to check existing posts and help other users of MESG.\n\nAlso, be sure to check out the [blog](https://medium.com/mesg) to stay up-to-date with our articles.\n\n# Contribute\n\nContributions are more than welcome.\n\nIf you have any questions, please reach out to us directly on [Discord](https://discordapp.com/invite/5tVTHJC).\n","readmeFilename":"README.md","gitHead":"7edb3f7c855ea93f080aa609366a8f55005ecf1e","_id":"mesg-js@5.0.0-beta.1","_nodeVersion":"10.16.0","_npmVersion":"6.11.3","dist":{"integrity":"sha512-VDtRt4pm9URAAMnGOR7C6lFYAqgKVuP2TUUArq9NselIgsHJGa4/HQepSgd78rkHA5WunA58LLvDd/iqa4CJIA==","shasum":"2298303357162f09e2c4b256d17e1e997d8819b1","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-5.0.0-beta.1.tgz","fileCount":108,"unpackedSize":1072526,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdsnZoCRA9TVsSAnZWagAA6AMP/RczFRPiV4ZPmXD2thYN\nlDHnZ1Zdz9vndJ2Mn1OUlctxpnDxlvHq/inLCDyfvf/EZjHeELSSRvjjaZNH\nx1Yq88+kIx7Bimq/c8hG2CXcn8+mCZadhMukVAozWDqZ/IIBplOwTdWXNiHa\nQoETumLI2lSNHiErU68CZuuAOzvHG51dy5RQhs+WRJ5BMzTVx7aFszWl5hrs\n4yb2pTzyyVOpuzv8C2C4JgONTgrO83h+Un/1yehxHuqax7/hSrbEIqxJEobT\n+tAusyRuuFQQM7JrH168cgv3b05Vh10ePzIfaKhzzdRSoqboBHKiEo76j+i7\nX3QwGzzVplC9EirWuE8pUkYTxNRKiLdT6pr8qc/aNZah5eVpd5Rg7RNmhAX1\nlIksQhSB2870tVXSIrzZ2v5rQhgfS9XDoEcjFjA1T2felEivQVz0DAZ8mQxi\nJwAy29nnu4u+4UCgEh/l3ghsqsw9ReTqZbJnWs+zhIy52uyAuSz3BSPTA1ny\noyGnRyAS9mU68LzcoHH00ZA8CVTpmDMbC/+p9pbxt7QdHhkE6iYUptKeb6eW\nAuUeGCY9t4bK5ZPJeSvsL/zXJj3RdrfsGszwPLenAON3eblYDQy+GnVUHuox\nqxmCIyFR9ayxSpjwFKogqkCC/8p8oY2Ia5Kf2HbHJCTfu/04E/VTUEwfx3Bh\nPdZs\r\n=5Y3f\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBNcar+eDlLyukv634PgCYQQIUctf+I24oTME6mYiUqTAiEAvAVH0rfLTdYZdUcUxtnrrNGBzQXswDWV7Tc63tsiv34="}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"nicolas-mesg","email":"nicolas@mesg.tech"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_5.0.0-beta.1_1571976808078_0.7995665214573056"},"_hasShrinkwrap":false,"deprecated":"use v5.0.0"},"5.0.0":{"name":"mesg-js","version":"5.0.0","description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","main":"lib/index.js","scripts":{"build":"rimraf ./lib && tsc && ncp ./src/protobuf/ ./lib/protobuf/ && ncp ./src/gogo/ ./lib/gogo/ && ncp src/api/typedef lib/api/typedef","prepublishOnly":"npm run test && npm run build","test":"ts-node ./node_modules/tape/bin/tape 'src/**/*_test.ts'","coverage":"rimraf ./istanbul && tsc --project tsconfig-istanbul.json && ncp ./src/protobuf/ ./istanbul/protobuf && ncp ./src/gogo/ ./istanbul/gogo/ && istanbul cover -x 'istanbul/**/*_test.js' --report html ./node_modules/.bin/tape 'istanbul/**/*_test.js'","dev":"nodemon -e ts src --exec 'npm run test'","ts-node":"ts-node"},"author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","dependencies":{"@grpc/proto-loader":"^0.5.1","base-x":"^3.0.6","grpc":"^1.21.1","js-yaml":"^3.13.1","pb-util":"^0.1.1","uuid":"^3.3.2"},"devDependencies":{"@types/long":"^4.0.0","@types/node":"^10.14.8","@types/sinon":"^5.0.2","@types/tape":"^4.2.32","is-uuid":"^1.0.2","istanbul":"^0.4.5","ncp":"^2.0.0","nodemon":"^1.19.1","protobufjs":"^6.8.8","rimraf":"^2.6.2","sinon":"^6.1.3","tape":"^4.10.2","ts-node":"^7.0.0","tsc":"^1.20150623.0","typescript":"^2.9.2"},"typings":"lib/index.d.ts","typescript":{"definition":"lib/index.d.ts"},"gitHead":"8744829ece6ef51619f43e9ae3c49503468eaed1","_id":"mesg-js@5.0.0","_nodeVersion":"10.16.0","_npmVersion":"6.11.3","dist":{"integrity":"sha512-pk0iiXcSTD1zdlR4iAcs9nPfpIGez8nZMeIcenaz3T7Zfs4KjK94HqU2nVvvk8bAcyzavJO4+2gxvPArIJTMsw==","shasum":"b5e61666a872435b34cbf00e46bcf84d6731bc91","tarball":"https://registry.npmjs.org/mesg-js/-/mesg-js-5.0.0.tgz","fileCount":108,"unpackedSize":1072519,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdstd4CRA9TVsSAnZWagAAM0wQAIUQmNEecIBUwPmBTMIo\nfmnyue30is+3ndONP0XWt+sDQ15P5novXLSeogSAC3ASX1weIlxhBqLSvdEB\nReIvsOYwZDVC+GSjBmf2U4ZveOszBOCi9zcuBVDYmBMmPum4K5TKQNQyBDjv\nxlqWm4YvBYa3BR11cZsLaEHw9Vb6wDUyDfsU5mw51uqEkNfwwURBg2pcI5D6\n6v/jlw5nbUCdlY2KluXMr+8vQBMRC+FY0FUQg/Pt/VN0qQK0tANm7rjsAipy\nGnXBG3W/DgxicTr2W5ZZx8CPiR8Q+M4VSXIz/+H9eoPI7v9uOTdjtOanENvj\n23CaXYgF5lFVVi4/X0zBzkSh08FWSdsxW28g/9R4ldPCiqpQt49lECtAFCs/\np2w956X2vzzXJS41Kd8sg/1ZfHJvtBYNsGQyIxxK61bYN19cDBx76emCvKYa\nj5Z8YxKNZ8j655NRoPwR1TzuCqYzfU49KccglIV3iv07bYc8FAIMUX7cWiNb\no7KUeKLwyKRWKdS7ZJ4uGc4qcHSEA0+2C/KWE30/uBQeET+qfkQcuuhe4oDA\nmgKkFJ6eO4Nmaj4rlOaTJyiJanDSGXikrSUh8b3qN65kH6pY5Y8b0yjLuauU\niO7F8QbGIqgFt/RdQnnIzlLDfDp002QRYXZA+RlS+kZFuC/ryfnbBSkuNKSF\n6702\r\n=/USx\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDrtiSYeD6L/MnByxDzkkcK1vlksSwkAWzhgYMfQjY+GAiEA15qQe83sa+kzzkt3hSYNKSyMwB7/nQHheJkI657kTkg="}]},"maintainers":[{"email":"anthony@mesg.com","name":"anthony-mesg"},{"email":"nicolas@mesg.tech","name":"nicolas-mesg"}],"_npmUser":{"name":"nicolas-mesg","email":"nicolas@mesg.tech"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mesg-js_5.0.0_1572001655965_0.9635391813240948"},"_hasShrinkwrap":false,"deprecated":"This package moved to @mesg/service and @mesg/application"}},"time":{"created":"2018-06-06T18:19:06.856Z","1.0.0":"2018-06-06T18:19:06.924Z","modified":"2022-05-09T04:28:37.003Z","1.1.0":"2018-06-06T23:15:21.710Z","1.1.1":"2018-06-10T01:41:35.837Z","1.1.2":"2018-06-13T16:21:49.052Z","1.2.0":"2018-06-17T08:55:28.326Z","1.2.1":"2018-06-20T05:50:47.528Z","1.2.2":"2018-06-28T04:05:24.881Z","1.2.3":"2018-07-04T07:43:09.648Z","1.3.0":"2018-10-12T11:21:02.285Z","1.4.0":"2018-10-19T12:15:19.797Z","2.0.0":"2019-01-16T08:49:30.451Z","2.0.1":"2019-01-22T09:30:15.663Z","2.1.0":"2019-05-08T11:23:33.591Z","3.0.0-beta-1":"2019-05-28T05:19:57.782Z","3.0.0-beta.0":"2019-05-28T05:28:14.202Z","3.0.0-beta.1":"2019-05-28T05:33:08.416Z","3.0.0":"2019-06-10T07:05:55.146Z","4.0.0":"2019-07-04T11:23:59.052Z","4.1.0":"2019-07-05T05:07:25.880Z","4.2.0-beta2":"2019-07-26T09:49:25.099Z","4.2.0-beta3":"2019-07-26T10:06:49.595Z","4.2.0-beta4":"2019-07-29T12:41:53.940Z","4.2.0-beta5":"2019-07-29T16:53:26.217Z","4.2.0":"2019-07-29T17:01:02.904Z","4.2.1":"2019-07-31T03:57:57.513Z","4.2.2":"2019-07-31T04:10:01.952Z","4.3.0-beta":"2019-08-21T08:43:42.397Z","4.3.0-beta.1":"2019-08-29T12:29:36.463Z","4.3.0-beta.2":"2019-08-31T11:02:45.599Z","4.3.0-beta.3":"2019-09-02T11:14:54.129Z","4.3.0-beta.4":"2019-09-04T08:15:38.453Z","4.3.0-beta.5":"2019-09-07T08:16:44.135Z","4.3.0-beta.6":"2019-09-07T08:56:31.777Z","4.3.0":"2019-09-08T14:16:14.978Z","4.3.1":"2019-09-11T08:43:28.609Z","4.4.0-beta.1":"2019-09-12T05:11:36.645Z","4.4.0-beta.2":"2019-09-18T10:15:52.059Z","4.4.0":"2019-09-23T08:02:38.973Z","4.5.0-beta.1":"2019-09-25T04:54:35.262Z","4.5.0-beta.2":"2019-09-27T10:01:59.560Z","4.5.0-beta.3":"2019-09-30T10:18:49.079Z","4.5.0-beta.4":"2019-10-01T07:35:11.812Z","4.5.0-beta.5":"2019-10-01T11:29:42.908Z","5.0.0-beta.1":"2019-10-25T04:13:28.196Z","5.0.0":"2019-10-25T11:07:36.159Z"},"maintainers":[{"email":"nicolas@mahe.me","name":"nicolasmahe"},{"email":"nicolas@liteflow.com","name":"nicolas-mesg"},{"email":"anthony@liteflow.com","name":"anthony-mesg"}],"description":"[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)","author":{"name":"Anthony Estebe","email":"anthony@mesg.tech"},"license":"ISC","readme":"# mesg-js\n\n[Website](https://mesg.com/) - [Docs](https://docs.mesg.com/) - [Forum](https://forum.mesg.com/) - [Chat](https://discordapp.com/invite/SaZ5HcE) - [Blog](https://medium.com/mesg)\n\nmesg-js is the official JavaScript library to interact with [MESG Engine](https://github.com/mesg-foundation/engine).\n\nThis library can be used from an Application or a Service.\n\n# Status\n[![CircleCI](https://img.shields.io/circleci/project/github/mesg-foundation/mesg-js.svg)](https://github.com/mesg-foundation/mesg-js) [![codecov](https://codecov.io/gh/mesg-foundation/mesg-js/branch/master/graph/badge.svg)](https://codecov.io/gh/mesg-foundation/mesg-js)\n\n# Contents\n\n- [Installation](#installation)\n- [Service](#service)\n  - [Task](#task)\n  - [Event](#event)\n- [Application](#application)\n  - [Resolve SID](#resolve-sid)\n  - [Listen events](#listen-events)\n  - [Listen results](#listen-results)\n  - [Execute task](#execute-task)\n  - [Execute task and wait result](#execute-task-and-wait-result)\n- [Community](#community)\n- [Contribute](#contribute)\n\n# Installation\n\n```bash\nnpm i mesg-js\n```\n\n# Service\n\nRequire mesg-js as a service:\n\n```javascript\nconst { service } = require('mesg-js')\n\nconst mesg = service()\n```\n\n## Task\n\nThe service have to call `mesg.listenTask` to start listening for task to execute by passing an object containing the tasks' key and function.\n\n```javascript\nmesg.listenTask({\n  'TASK_1_KEY': (inputs) => {\n    // Function of the task 1\n    // Can directly throw error\n    if (inputs.foo === undefined) {\n      throw new Error('foo is undefined')\n    }\n    // Return an object\n    return { foo: inputs.a + 'bar' }\n  }, \n  'TASK_2_KEY': async (inputs) => {\n    // Function of the task 2\n    // Return an Promise containing an object\n    const response = await fetch('...')\n    return response.json()\n  },\n})\n```\n\nThe task functions accept `inputs` as parameter and returns the `outputs` as object or Promise of object.\nThe task function can throw an Error in case of error. The lib will catch it and send it to the MESG Engine.\n\n## Event\n\nTo emit an event, the service should call the `mesg.emitEvent` function with the event's key and event's data as parameters. This function returns a `Promise`.\n\n```javascript\nmesg.emitEvent('EVENT_KEY', { foo: 'bar' })\n```\n\n# Application\n\nRequire mesg-js as an application:\n\n```javascript\nconst { application } = require('mesg-js')\n\nconst mesg = application()\n```\n\n## MESG Engine endpoint\n\nBy default, the library connects to the MESG Engine from the endpoint `localhost:50052`.\n\n## Resolve SID\n\nInstead of hard-coding `instanceHash` in your application's env, your application can resolve dynamically using the service's SID.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash,\n  .....\n})\n```\n\n## Listen events\n\nListen events from a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nmesg.listenEvent({\n  filter: {\n    instanceHash: instanceHash,\n    key: 'EVENT_KEY' // optional\n  }\n})\n.on('data', (event) => {\n  console.log('an event received:', event.key, mesg.decodeData(event.data))\n})\n```\n\n## Listen results\n\nListen results from a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nmesg.listenResult({\n  filter: {\n    instanceHash: instanceHash,\n    taskKey: 'TASK_KEY_FILTER', // optional\n    tags: ['TAG_FILTER'] // optional\n  }\n})\n.on('data', (result) => {\n  if (result.error) {\n    console.error('an error has occurred:', result.error)\n    return\n  }\n  console.log('a result received:', mesg.decodeData(result.outputs))\n})\n```\n\n## Execute task\n\nExecute task on a service.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst execution = await mesg.executeTask({\n  instanceHash: instanceHash,\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nconsole.log('task in progress with execution:', execution.hash)\n```\n\n## Execute task and wait result\n\nExecute task on a service and wait for its result.\nThis can be considered as a shortcut for using both `executeTask()` and `listenResult()` at same time.\n\n```javascript\nconst instanceHash = await mesg.resolve('SID_OF_THE_SERVICE')\n\nconst result = await mesg.executeTaskAndWaitResult({\n  instanceHash: instanceHash,\n  taskKey: 'TASK_KEY',\n  inputs: mesg.encodeData({ key: 'INPUT_DATA' }),\n  tags: ['ASSOCIATE_TAG'] // optional\n})\nif (result.error) {\n  console.error('an error has occurred:', result.error)\n  throw new Error(result.error)\n}\nconsole.log('a result received:', mesg.decodeData(result.outputs))\n```\n\n# Community\n\nYou can find us and other MESG users on the [forum](https://forum.mesg.com). Feel free to check existing posts and help other users of MESG.\n\nAlso, be sure to check out the [blog](https://medium.com/mesg) to stay up-to-date with our articles.\n\n# Contribute\n\nContributions are more than welcome.\n\nIf you have any questions, please reach out to us directly on [Discord](https://discordapp.com/invite/5tVTHJC).\n","readmeFilename":"README.md"}